Bug with glOrtho ?

Hello,
I use glOrtho for 2D drawing, and i ve noticed a problem : for example if i draw 4 connected lines that represent a lozenge, that lines are not connected on the screen, but if i draw this shape like a fill polygon, it’s work properly… I work on a nvidia GeForce 3 on Win NT.
Can it be a driver problem, OpenGL implementation ?

thanks in advance

What do you mean with “not connected”? Do you use GL_LINES or GL_LINE_STRIP?

little example :

(width = screenwidth & height = screenheight)

glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f,width,height,0.0f,-1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glBegin(GL_LINES);
//line 1
glVertex2i(80,70);
glVertex2i(70,60);

//line 2
glVertex2i(70,60);
glVertex2i(60,70);

//line 3
glVertex2i(60,70);
glVertex2i(70,80);

//line 4
glVertex2i(70,80);
glVertex2i(80,70);
glEnd();

with this code you think the lines are connected, but when i draw they are not !!!

there is some space pixels, despite of the end point of a line is the same of the first point of the following line.

Try using GL_LINE_LOOP.

Originally posted by patapon:
Hello,
I use glOrtho for 2D drawing, and i ve noticed a problem : for example if i draw 4 connected lines that represent a lozenge, that lines are not connected on the screen, but if i draw this shape like a fill polygon, it’s work properly… I work on a nvidia GeForce 3 on Win NT.
Can it be a driver problem, OpenGL implementation ?

There’s another possibility you missed – there could be a problem with your code

GL_LINES draws disjoint lines. (See page 44 of the Red Book, for example).

If you want the lines joined, use GL_LINE_STRIP or GL_LINE_LOOP.

Also, remember the start pixel for subsequent lines in your case is the same as the end pixel for the prev line. Now,if you have various blending things set up you could fall foul of this!

Try making each line a different colour!

Switch off all blending etc.

Just a thought, but I have seen this brought up before …

R.

In my code I use GL_LINE_STRIP, that was just to show a simple example. Also it’s not usual that 2 lines that have a shared point (in particular the first or last point) are disjoint : when you draw a line you give the first & last point, others are interpolated with bresenham, so with my GLORTHO projection, when you call

glBegin(GL_LINES);
glVertex2i(70,60);
glVertex2i(80,70);
glEnd();

in your window the last point have to be at the pos 80 pixel in x & 70 pixel in y

now if you draw that lines :

glBegin(GL_LINES);
glVertex2i(80,70);
glVertex2i(70,80);
glEnd();

the firts point must match with the last point of the previous line.

I have try LINE_LOOP, LINE_STRIP, I have try to draw with GL_POLYGON in the mode glPolygonMode(GL_FRONT_AND_BACK,GL_LINE), but in all case line are disjoint !!

If you don’t see what I mean try the example of my previous topic and draw the four line you will see!

Thanks for your answer.

thanks Rob but the problem persist

Do you remember on which graphic accelerator
you ve notice that, can it be a bug in the nvidia s opengl implementation ?

I tried it out and you are right, the lines are not connected (in all modes: lines, line_loop, line_strip)! (Geforce card)

kon

Thanks Kon. I ve just try on a Matrox G450 and there is no problem, so i think its nvidia bug, i will try to send them a mail!

no problem on GeForce 4 Ti 4600

Look at this thread:
http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/009726.html

Thanks for this one Jambolo … I just knew I had seen it before and the workround …

There you go patapon!

Rob.

Thanks men

The problem definatly has to be win NT… Windows NT IS THE DEVIL!