Advertisement

glViewport

Started by August 12, 2003 09:58 AM
3 comments, last by MV 21 years, 6 months ago
Hi guys, On a mouse_down event, I try to center the viewport on the mouse coordinates, but it doesnt work as it should. Can someone see something wrong in the following statements ? GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); glViewport((GLint)( mouse_x - viewport[2] / 2), (GLint)(mouse_y - viewport[3] / 2), (GLsizei)viewport[2], (GLsizei)viewport[3]); Thx in advance
Try this:

glViewport((GLint)( (mouse_x - viewport[2]) / 2), (GLint)((mouse_y - viewport[3]) / 2), (GLsizei)viewport[2], (GLsizei)viewport[3]); 


It''s because the divide will be done before the subtraction.
Advertisement
No, troubles are still here.
Someone has ever played with glViewport ?
Shouldn''t the size of the viewport be smaller than the size of the window that you are rendering in?

If you read it back from OpenGL the size of the viewport will be the same as your entire window and having a viewport that is outside the window probably has ''issues''.
I dont think so... but we never know...
The fact is that i''m trying to debug my picking process, by rendering the zone processed by the glRenderMode(GL_SELECT) to a texture.

The nehe''s tutorial uses the gluPickMatrix function, but I already saw some programs using the glViewport function.

Does someone know how all this works, I mean what glViewport exactly does ?

This topic is closed to new replies.

Advertisement