Archived

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

Problems with selection in perspective and ortho

This topic is 5893 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I recently created a context menu (right click menu in windows) for my 3D game and it draws correctly, but I cannot seem to get the selection working properly. I am using the OpenGL supported selection (with gluPickMatrix, glPush/PopName, etc.) and it works fine on the game world that is rendered in perspective but it does not work properly on my context menu rendered in ortho2d. When I process the hits, all of the context menu buttons appear in the buffer, regardless of the mouse location. (The context menu buttons do not overlap on the screen.) Does gluPickMatrix work with orthogonal projections? There''s nothing in the red or blue books that I''ve seen to indicate that it doesn''t work. Here''s the code I''ve been using: ** For perspective ** glMatrixMode( GL_PROJECTION ); glPushMatrix(); glLoadIdentity(); gluPickMatrix( (GLdouble)ui->mouse_position.x, (GLdouble)( viewport[ 3 ] - ui->mouse_position.y ), 2.0f, 2.0f, viewport ); gluPerspective( PERSPECTIVE_ANGLE, (GLfloat)window_coord_width/(GLfloat)window_coord_height, PERSPECTIVE_NEAR, PERSPECTIVE_FAR); ** For orthogonal, called after perspective ** // Set up the orthogonal view needed for the UI glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); if( display_mode == GL_SELECT ) { GLint viewport[ 4 ]; glGetIntegerv( GL_VIEWPORT, viewport ); gluPickMatrix( (GLdouble)mouse_position.x, (GLdouble)( viewport[ 3 ] - mouse_position.y ), 2.0f, 2.0f, viewport ); } glOrtho(0.0, width, 0.0, height, -1.0, 1.0); Any help would be greatly appreciated! -Scott-

Share this post


Link to post
Share on other sites
Never mind! I moved some lines around and it started working. I have no idea exactly what got it to work, but I''m just glad it is working now.

-Scott-

Share this post


Link to post
Share on other sites