PDA

View Full Version : glViewport use/misuse question



sqrt[-1]
12-12-2005, 09:55 PM
Just say I have a render target of say 512x512 is it valid OpenGL code to set a viewport like:

glViewport(-512,-512,2048,2048);

It seems that there is nothing in the spec to dis-allow this (and my current thinking is that it works on Nvidia) but I was wondering if it was a mis-use of the call.

To more precisely describe what I am doing, I am magnifying a part of scene - and I can't easily modify the perspective matrix. (My code is not the code that creates/sets or uses the matrix)

So in summary, is it standard/valid to set viewport limits outside the current render target area?

Tom Nuydens
12-12-2005, 10:28 PM
The spec only imposes constraints on the width and height of the viewport, not on the origin. More specifically, it states that the width and height are clamped to the maximum viewport dimensions, and that they must not be negative. Since nothing is said about the viewport origin, I would say your code is valid.

knackered
12-13-2005, 02:25 AM
I can't imagine why it would ever be considered a problem, it's just a simple scale/bias no matter what numbers are fed in.

sqrt[-1]
12-13-2005, 04:37 PM
Thanks guys,I only asked as "some other" 3D API has problems with viewports outside the render area.