PDA

View Full Version : drawing a viewport border



cbpetro
12-28-2006, 09:23 PM
I'm using OpenGL to draw a charting app. I have three viewports, two to draw the X and Y axis stuff, the third to draw in the charting area. I draw a box enclosing the third viewport but the box flickers(not the stuff inside just the box) during operation. I am using the following to draw the box.


glPushMatrix();

glViewport(50, 50, cx - 100, cy - 100); // 3rd viewport

// SetOrtho
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

glOrtho( xMin, xMax, yMin, yMax, -zMax, zMax);
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();

// DrawAxisBox
glLineWidth(1.0f);
glBegin(GL_LINE_STRIP);
glVertex3f(xMin, yMin, 0.0f);
glVertex3f(xMin, yMax, 0.0f);
glVertex3f(xMax, yMax, 0.0f);
glVertex3f(xMax, yMin, 0.0f);
glVertex3f(xMin, yMin, 0.0f);
glEnd();

glPopMatrix();

k_szczech
12-29-2006, 12:12 AM
glPushMatrix();
(...)
glMatrixMode(GL_PROJECTION);
(...)
glMatrixMode(GL_MODELVIEW);
(...)
glPopMatrix();Try moving glPushMatrix after glMatrixMode(GL_MODELVIEW). (before glLoadIdentity).

cbpetro
12-29-2006, 01:09 AM
Thanks for the suggestion but that doesn't seem to work. I think my problem is that the Box is being clipped by the viewport extents during drawing since I am drawing right on the edge of the viewport. The left edge and bottom of the GL_LINE_STRIP is what's flickering mostly.