hi all. i am writing a visualization program for 3D files like .stl files. until now everything is fine. the visualization, rotation, zoom of the 3D structure works perfect. but now i want to pick single triangles or groups of triangles. but nothing gets on the buffer in selection mode. and i don't really understand where my fault is. one idea is, that i can't use the picking feature without the
glutMainLoop();
i don't use this in my program. and in every example i found, the glut main loop is used. am i right that i can't pick my objects without it?
Here some of my steps:
when i am switching to select mode by pressing a key and klicking on the screen to pick something the screen gets black, nothing gets displayed any more and the variable hits has the value zero all the time. my pick tolerance is 100. for the moment.
i can't understand.
any tips for me?
thanks in advance!
greets andy
glutMainLoop();
i don't use this in my program. and in every example i found, the glut main loop is used. am i right that i can't pick my objects without it?
Here some of my steps:
Code:
unsigned int PickBuffer[PICK_BUF_SZ];
glSelectBuffer(PICK_BUF_SZ, PickBuffer);
glRenderMode(GL_SELECT);
glInitNames();
glPushName(0xffffffff);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
lGetIntegerv(GL_VIEWPORT, viewport);
gluPickMatrix((double)x, (double)(viewport[3]-y), PICK_TOL, PICK_TOL, viewport);
gluPerspective(45.0f,(GLfloat)w/(GLfloat)h,1.0f,600.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(xmove,-ymove,-50.0f+zoom);
glRotatef(rotation,0.0f,1.0f,0.0f);
glRotatef(rot2,1.0f,0.0f,0.0f);
if (RenderMode == GL_SELECT) glLoadName(through);
while ...
{
if (RenderMode == GL_SELECT) glLoadName(through);
glBegin(display);
glColor3f(0.9f,0.9f,0.9f);
glNormal3f(matrix[through][0], matrix[through][1], matrix[through][2]);
glVertex3f(matrix[through][3], matrix[through][4], matrix[through][5]);
glVertex3f(matrix[through][6], matrix[through][7], matrix[through][8]);
glVertex3f(matrix[through][9], matrix[through][10], matrix[through][11]);
glEnd();
through++;
}
glMatrixMode(GL_PROJECTION);
glPopMatrix();
hits = glRenderMode(GL_RENDER);
i can't understand.
any tips for me?
thanks in advance!
greets andy