W and H are the width and height of the window
void drawHud()
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,W,0,H,-1,10);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDisable(GL_LIGHTING);
glTranslatef(hudPosX,H-hudPosY-hudHeight,0);
glColor4f(1,1,1,0.5);
glBegin(GL_POLYGON);
glVertex3f(120,0,0);
glVertex3f(120,30,0);
glVertex3f(0,30,0);
glVertex3f(0,0,0);
glEnd();
<some stuff more>
}
then picking:
void mouseMotion(int x, int y)
{
GLfloat sx,sy;
sx = x-mouseOriginX;
sy = y-mouseOriginY;
if((x>hudPosX) && (x<(hudPosX+hudLength)) &&
(y>hudPosY) && (y<(hudPosY+hudHeight)))
{
hudPosX = origHudPosX + sx;
hudPosY = origHudPosY + sy;
}
glutPostRedisplay();
}
|