Hey everyone,
I thought its time to give up trying to find the (probably really simple) solution for this particular problem. When I started using OpenGL I had an ATI graphics card and everything was fine, until recently I made a switch to a pair of 8800gtx’s. (Interesting fact: the same primitive 2D opengl program ran like a hundred times faster on the old ati card but thats an another topic…)
So heres the deal: when I draw lines with glBegin(GL_LINES), GL_LINE_STRIP, GL_LINE_LOOP the lines are always 1 pixel left and under the correct coordinates. Oddly enough GL_QUADS, GL_POINTS, etc. works fine. I know its not a big deal but it seems that glRasterPos, glRect and a few other opengl functions are setting/drawing to the wrong coordinates also so adding all the inaccuracy produced by these functions together results in a rather unpleasant final render.
I’ve modified the 2nd lesson from NeHe’s opengl site to make sure the rest of the code is correct (at least I hope so…). Here are the changes:
In GLvoid ReSizeGLScene(GLsizei width, GLsizei height) i replaced
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
with
glOrtho(0, width, 0, height, -1.0, 1.0);
and in int DrawGLScene(GLvoid)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity();
{...}
glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd();
with
glColor3f(1,1,1);
glBegin(GL_LINE_LOOP);
glVertex2i(10, 10);
glVertex2i(100, 10);
glVertex2i(100, 100);
glVertex2i(10, 100);
glEnd();
glColor3f(1,0,0);
glBegin(GL_QUADS);
glVertex2i(10, 10);
glVertex2i(100, 10);
glVertex2i(100, 100);
glVertex2i(10, 100);
glEnd();
And the result:
I’m not exactly sure that this is what I should be seeing since on other graphics cards (ATI, and even on an integrated intel) you can’t see the line since the second glBegin() paints on it.
By the way I’m using the latest drivers so that shouldn’t be the problem.
Thanks in advance,
Fr4G