Selection Buffer (OGL)

Started by
1 comment, last by Kudaba 23 years, 6 months ago
Very simple, I bond my selection function to the mouse movement, check it every move, yet when I do this my program freezes before it even gets a chance to draw the first frame. Here''s the code for the function: GLint Selection(GLint x, GLint y) { // Pass in the mouse x and y GLuint Buffer[16]; // Selection Buffer GLint hits, viewport[4]; // Hit counter and viewport glSelectBuffer(16, Buffer); // Set up the buffer glGetIntegerv(GL_VIEWPORT, viewport); // Get the viewport glMatrixMode(GL_PROJECTION);// Projection mode glPushMatrix(); glRenderMode(GL_SELECT); // Change rendering mode glLoadIdentity(); // Get clipping volume (2x2 pixels from the mouse) gluPickMatrix(x, viewport[3] - y, 2, 2, viewport); gluPerspective(60.0f, (GLfloat)3/4, 1.0f, 10.0f); // apply perspective RenderMenu(); // render the scene hits = glRenderMode(GL_RENDER); // Rendering Mode glMatrixMode(GL_PROJECTION); // Set everything back to normal glPopMatrix(); glMatrixMode(GL_MODELVIEW); if (hits == 1) // if there is one hit return Buffer[3]; // return what is hit return MenuSel; // else return what it is already. } Heres the code for calling it: if (LOWORD(lParam) != curx || HIWORD(lParam) != cury) MenuSel = Selection(LOWORD(lParam), HIWORD(lParam)); curx = LOWORD(lParam); cury = HIWORD(lParam); Retired Pokemon Master of Prgramming Problems I already had them all.
This Space for rent.
Advertisement
try sticking a few glGetError() calls in your code

http://members.xoom.com/myBollux
Thanks, I''ll try that tommorrow and reply how it goes.

Retired Pokemon Master of Prgramming Problems

I already had them all.
This Space for rent.

This topic is closed to new replies.

Advertisement