PDA

View Full Version : Square not being clipped correctly



NoKKiE
10-19-2008, 09:30 PM
Hello, I am doing a simple square using

glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glBegin(GL_POLYGON);
glColor3f(0, 0, 0);
glVertex3f(0, 0, 1);
glVertex3f(1, 0, 1);
glVertex3f(1, 0, 2);
glVertex3f(0, 0, 2);
glEnd();

When I resize the window so that it slightly clips the square a diagonal line appears from the bottom left to the top right of the square. This only happens on my laptop which runs on XP, but works fine on my desktop which runs vista. Does this have to do with my drivers or something?

MarkS
10-20-2008, 07:54 AM
To put it bluntly, the XP implementation of OpenGL sucks. You've probably stumbled upon a bug. The only possible solution I can think of is to split your rectangle into two triangles.

PureSpider
10-20-2008, 09:27 AM
Same happens for polygon stipple if the rect is partly out of the screen...

NoKKiE
10-20-2008, 09:43 AM
Thanks a lot! I'll stick to using triangles instead

MarkS
10-20-2008, 12:50 PM
No problem. XP's implementation is one of the driving factors for me to upgrade to Vista.

ZbuffeR
10-20-2008, 12:52 PM
No problem. XP's implementation is one of the driving factors for me to upgrade to Vista.
.. For ATI you mean ?

MarkS
10-20-2008, 12:55 PM
Not sure what you mean? I use nVidia. Are ATi's drivers better?

Keith Z. Leonard
10-20-2008, 12:58 PM
I'm confused, what implementation of OpenGL on XP sucks?? There isn't one, there a driver for each card, and they implement OpenGL. There may be software implementations on certain OS's, but that's a different story. If you are hitting some part of the GL that the software backup is being used, it's going to run badly, so this seems like a driver bug to me.

MarkS
10-20-2008, 01:02 PM
I may be stating it wrong. Everything I've read states that Microsoft basically forces all GL calls to be wrapped by calls to DirectX in XP or something like that. My personal experience is that GL is faster and more stable on Vista.

MarkS
10-20-2008, 01:34 PM
NoKKiE, can you post your code? I've just tried it and it works perfectly.

Keith Z. Leonard
10-20-2008, 02:44 PM
MarkS, that is certainly not the case. If your card does not have a native OpenGL driver there have been wrappers based upon direct X, but they have been pretty bad. A card with native OpenGL support does not have to go through DirectX, this includes nVidia, ATi, Intel parts, etc...

Read this:
http://www.opengl.org/pipeline/article/vol003_9/

XP should perform equally or better than Vista for most games, for instance.

MarkS
10-20-2008, 03:51 PM
I stand corrected and gratefully so. I must have misread.

NoKKiE
10-21-2008, 11:35 AM
NoKKiE, can you post your code? I've just tried it and it works perfectly.

It was a pretty simple test I used. I just drew the cube as above with the following transformations:
glLoadIdentity(); // clear current matrix

// Viewpoint Transformations
gluLookAt(5, 5, 0,
0, 0, 0,
0, 1, 0);


OnSize has this code:

glViewport(0, 0, (GLint) w, (GLint) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective((GLdouble)45.0, (GLdouble) ((double)w)/h, 0, 10000);
glMatrixMode(GL_MODELVIEW);


I am now using glBegin(GL_LINE_LOOP); and it works perfectly. I'm sure it's a bug with the implementation.