PDA

View Full Version : Strange back buffer artefact



XChanger
10-14-2002, 10:34 PM
Hi all,
some days ago I has sent a question about cube's faces selection. After discussion here I decided to use selection technique based on drawing of cube's copy to back buffer with color faces ( my cube is drawing in GL_LINE polygon mode ). This technique, described in Red book now is partially working. But there remains strange artefact in application - cube's left and right sides are selectable, but it seems boundaries of cube in back buffer before glutSwapBuffers() are different in front buffer (visible) after this function! Similarly, if I click on imaginable bottom face (which in my situation is invisible and culled), selection appears on upper face. Is there GLUT's artefact? Or it is viewport coords mistake of me? If someone can look to my code (it is a bit large to show in this post)please replay...

XChanger

mikael_aronsson
10-14-2002, 10:42 PM
Hi !

You do swap your mouse Y values right...

Mikael

XChanger
10-15-2002, 02:28 AM
Sorry, Mikael, a bit wider explanation needed - beginner's problem http://www.opengl.org/discussion_boards/ubb/frown.gif

XChanger

SThomas
10-15-2002, 03:49 AM
what he means is that you're probably forgetting to swap the mouse input's y coordinate. in the gl viewport, the y coordinate is 0 at the bottom of the screen, and (window_height-1) at the top of the screen. in windows, the window coordinates go from 0 at the top of the screen to (window_height-1) at the bottom of the screen. thus, when you process a mouse click, you need to convert it from a windows coordinate to a gl viewport coordinate.

gl_coord.y = (window_height-1) - mouse_coord.y;

-steve.