Selection Buffer is too short
hello to u all, i have implemented the selection buffer into my app, it works, but it detecs hits only when im very close to the object im clicking on, do u know why is that?
im using a very deep viewing frustum.
October 16, 2000 01:14 PM
Im having a simular problem with the selection buffer.
Mine is detecting hits alittle lower than it should and
not high enough... like its shifted slightly down.
heres my click routine that gets called on LBUTTONDOWN
and the render function..
Mine is detecting hits alittle lower than it should and
not high enough... like its shifted slightly down.
heres my click routine that gets called on LBUTTONDOWN
and the render function..
void PickObj(float mousex, float mousey)
{
GLuint selectbuffer[512];
GLint hits;
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT,viewport);
glSelectBuffer(512,selectbuffer);
glRenderMode(GL_SELECT);
glInitNames();
glPushName(0);
glMatrixMode (GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPickMatrix((GLdouble) mousex, (GLdouble) (viewpor[3] - mousey),1.0f,1.0f,viewport);
gluPerspective(45.0f,(GLfloat)800/(GLfloat) 600,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW);
DrawGLScene(GL_SELECT);
hits = glRenderMode(GL_RENDER);
if(hits>0)processhits(hits,selectbuffer);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}int DrawGLScene(GLenum mode) // Here''s Where We Do All The Drawing
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity();
glTranslatef(0.0f,0.0f,-10.0f );
// glRotatef(rot,1,1,0);
if(mode == GL_SELECT)glLoadName(1);
glBegin(GL_QUADS);
glColor3f(1,0,0); glVertex3f(0,0,0);
glColor3f(1,1,0); glVertex3f(0,1,0);
glColor3f(0,1,0); glVertex3f(1,1,0);
glColor3f(1,0,1); glVertex3f(1,0,0);
glEnd();
if(mode == GL_SELECT)glPushName(2);
glBegin(GL_QUADS);
glColor3f(1,0,0); glVertex3f(-2,-2,0);
glColor3f(1,1,0); glVertex3f(-2,-1,0);
glColor3f(0,1,0); glVertex3f(-1,-1,0);
glColor3f(1,0,1); glVertex3f(-1,-2,0);
glEnd();
if(mode == GL_SELECT)glPushName(3);
glBegin(GL_QUADS);
glColor3f(1,0,0); glVertex3f(2,2,0);
glColor3f(1,1,0); glVertex3f(2,3,0);
glColor3f(0,1,0); glVertex3f(3,3,0);
glColor3f(1,0,1); glVertex3f(3,2,0);
glEnd();
rot+=0.5f;
return TRUE;
}
October 16, 2000 01:24 PM
I added mousey+=15; before the gluPickMatrix() and now its right
on... but im still unsure why it was off..
on... but im still unsure why it was off..
You can define the width and height of the picking region with your gluPickMatrix(GLdouble x, GLdouble y, GLdouble width, GLdouble height, GLint viewport[4]). Add to the width and height to get a bigger picking region.
I think that''ll help you.
Bye,
Martin
I think that''ll help you.
Bye,
Martin
______________Martin EstevaolpSoftware
November 08, 2000 09:47 PM
Why use the selection buffer?? It would seem much easier to do your own calculations...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement