Archived

This topic is now archived and is closed to further replies.

MV

glViewport

Recommended Posts

MV    122
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

Share this post


Link to post
Share on other sites
llyod    122
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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''.

Share this post


Link to post
Share on other sites
MV    122
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 ?

Share this post


Link to post
Share on other sites