Problems with selection in perspective and ortho

Started by
0 comments, last by Edge42 22 years, 5 months ago
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-
Advertisement
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-

This topic is closed to new replies.

Advertisement