Hello friends
I want to program with windows98 and opengl
In my program, i draw some lines (first, i load this lines with differentes names), and after i prick with the right bottom of the mouse in my windows of opengl.
Then, my program, in “pulsaraton” procedure open a little window beneath the point where i prick (glupickmatrix) with my mouse. And my program should sense if there is any line in this little window. If there is any line, then varying hit=1, but my program don´t sense any line. Why?
I post a copy of part of my program.
Thank´s for helping.
//here i loaded the lines wich i draw
#define A 1
#define B 2
#define C 3
#define D 4
#define E 5
#define F 6
void
drawTorus(void)
{
glBegin(GL_LINES);
glInitNames();
glPushName(0);
glLoadName(A);
glVertex2f(0.0, 0.0);
glVertex2f(2.0, -2.0);
glLoadName(B);
glVertex2f(2.0, -2.0);
glVertex2f(0.0, -2.0);
glLoadName©;
glVertex2f(2.0, -2.0);
glVertex2f(2.0, 0.0);
glLoadName(D);
glVertex2f(2.0, 0.0);
glVertex2f(0.0, -0.0);
glLoadName(E);
glVertex2f(0.0, 0.0);
glVertex2f(0.0, -2.0);
glLoadName(F);
glVertex2f(0.0, -2.0);
glVertex2f(2.0, 0.0);
glEnd();
glPopMatrix();
return;
}
void
pulsaraton (float x, float y)
{
GLuint selectBuff[BUFFER_LENGTH];
GLint hits, viewport[4];
glSelectBuffer(BUFFER_LENGTH, selectBuff);
glGetIntegerv(GL_VIEWPORT, viewport);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glRenderMode(GL_SELECT);
glLoadIdentity();
glTranslatef(-1.0, 1.0, 0.0);
gluPickMatrix(x, y, 0.5, 0.5, viewport);
gluPerspective(45.0f, aspect, 1.0, 3.0);
drawTorus();
hits = glRenderMode(GL_RENDER);
if (hits==1);
prueba11(selectBuff);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}
void
prueba11(GLuint *pselectBuff)
{
int id = pselectBuff[3];
return;
}
LRESULT APIENTRY
WindProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case WM_RBUTTONDOWN:
GLfloat d, e;
d = LOWORD(lParam);
e = HIWORD(lParam);
pulsaraton(d, e);
break;
}
/* Deal with any unprocessed messages */
return DefWindowProc(hWnd, message, wParam, lParam);
}