nt
08-31-2007, 11:01 AM
I woulld like to know how to turn on aliasing and turn off aliasing after the aliasing is done in each frame.
What I am trying is to draw a compass card in to a predefined location that contains other images. I only want to blend the compass card and don't want to affect any other images on the screen. But what I am getting is a diagonal line across the screen and the aliasing is affecting all other models on the screen.
I am attaching the code here.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluOrtho2D(-112, 112, -112, 112);
//turn on the aliasing = during every frame
glShadeModel(GL_FLAT);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
glPushMatrix();
glColor3f (1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f (-220, 220, 0.0);
glVertex3f (220, 220, 0.0);
glVertex3f (220,-220,0.0);
glVertex3f (-220,-220, 0.0);
glEnd();
glColor3f (0.0, 0.0, 0.0);
glBegin(GL_LINES);
glLineWidth( (GLfloat)(50));
glVertex2f(-100,-100);
glVertex2f(100,100);
glEnd();
//trying to turn off aliasing after draw
glPopMatrix();
glDisable(GL_LINE_SMOOTH);
glDisable(GL_POLYGON_SMOOTH);
glDisable(GL_BLEND);
appreciate any help.
What I am trying is to draw a compass card in to a predefined location that contains other images. I only want to blend the compass card and don't want to affect any other images on the screen. But what I am getting is a diagonal line across the screen and the aliasing is affecting all other models on the screen.
I am attaching the code here.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluOrtho2D(-112, 112, -112, 112);
//turn on the aliasing = during every frame
glShadeModel(GL_FLAT);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
glPushMatrix();
glColor3f (1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f (-220, 220, 0.0);
glVertex3f (220, 220, 0.0);
glVertex3f (220,-220,0.0);
glVertex3f (-220,-220, 0.0);
glEnd();
glColor3f (0.0, 0.0, 0.0);
glBegin(GL_LINES);
glLineWidth( (GLfloat)(50));
glVertex2f(-100,-100);
glVertex2f(100,100);
glEnd();
//trying to turn off aliasing after draw
glPopMatrix();
glDisable(GL_LINE_SMOOTH);
glDisable(GL_POLYGON_SMOOTH);
glDisable(GL_BLEND);
appreciate any help.