I draw an overlay of a triangle shape over an image. The triangle tip points to a known location (x,y,z) on the image. I want the triangle to stay the same size even if I zoom in.
Here is my code:
glDisable(GL_DEPTH_TEST);
glPushMatrix()
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glTranslatef(x, y, z);
glBegin(GL_TRIANGLES);
glColor4f(1,0,0,0.75);
glVertex3f(0,0,0);
glVertex3f(0,0-0.5f,0);
glVertex3f(0+0.5f,0,0);
glEnd();
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
glPopMatrix();
When I zoom in, the triangle is still points to the same point of the image but its size get bigger.
Also, is there any redundancy in the call to those functions?
I figured out the solution and I want to share it with you all.
//Step 1: Convert from world coordinates to display window coordinates:
double modelMatrix[16];
double projMatrix[16];
int viewPort[16];
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glMatrixMode(GL_PROJECTION);
glPushMatrix();