glViewport
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:
It''s because the divide will be done before the subtraction.
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.
August 13, 2003 07:09 AM
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''.
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 ?
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
Popular Topics
Advertisement
Recommended Tutorials
Advertisement