I would like to prefix this by saying I don't know a great deal about OpenGL programming. But I am neck deep in it, so I must move forward;)
I am working on an application that draws images on the screen. Two to be exact. They live side by side so the user can do a comparison. I need to draw a circle on top of both images. When I draw that circle (either before or after the glDrawPixels() to draw the images), the circle always shows up behind the image. I can see only part of the circle, the part that is being drawn outside of the images.
Before calling the code to display the image or the circle:
CRect rect;
GetClientRect(rect);
glViewport( 0, 0, rect.Width(), rect.Height());
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, (GLdouble) rect.Width(), 0.0, (GLdouble) rect.Height());
glMatrixMode(GL_MODELVIEW);
glRasterPos2i(0, 0);
glClearColor(0.5, 0.5, 0.5, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
When I am displaying the image I am doing this, basically:
glPixelTransferf(GL_RED_SCALE, 1.0);
glPixelTransferf(GL_GREEN_SCALE, 1.0);
glPixelTransferf(GL_BLUE_SCALE, 1.0);
glDisable(GL_BLEND);
glRasterPos2i(xOffset, 2);
glDrawPixels(x, y, GL_RGB, GL_UNSIGNED_BYTE, image);
And this is how I am drawing the circle:
glBegin(GL_LINE_LOOP);
for(float i = 0; i < PI*2; i += increments)
{
x = radius * sin(i) + xmid;
y = radius * cos(i) + ymid;
glVertex2f( x, y);
}
glEnd();
Carleton