Added finer control over viewport setting on begin/end

As suggested in issue #1199
Merge pull request #1221 from Darkyenus/patch-1

Added finer control over viewport setting on begin/end