PDA

View Full Version : Bug with glOrtho ?



patapon
08-27-2002, 10:43 PM
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

Xmas
08-28-2002, 07:17 AM
What do you mean with "not connected"? Do you use GL_LINES or GL_LINE_STRIP?

patapon
08-28-2002, 11:37 PM
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.

Overmind
08-29-2002, 01:31 AM
Try using GL_LINE_LOOP.

nutball
08-29-2002, 01:34 AM
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 http://www.opengl.org/discussion_boards/ubb/frown.gif

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.

Rob Fletcher
08-29-2002, 03:11 AM
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.

patapon
08-29-2002, 03:30 AM
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.

patapon
08-29-2002, 03:37 AM
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 ?

kon
08-29-2002, 04:35 AM
I tried it out and you are right, the lines are not connected (in all modes: lines, line_loop, line_strip)! (Geforce card)

kon

patapon
08-29-2002, 04:50 AM
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!

patapon
08-29-2002, 05:05 AM
no problem on GeForce 4 Ti 4600

Jambolo
08-30-2002, 12:02 PM
Look at this thread:
http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/009726.html

Rob Fletcher
09-02-2002, 07:02 AM
Thanks for this one Jambolo ... I just *knew* I had seen it before and the workround ...

There you go patapon!

Rob.

patapon
09-02-2002, 10:55 PM
Thanks men

31337
09-03-2002, 02:38 PM
The problem definatly has to be win NT... Windows NT IS THE DEVIL!