View Full Version : Drawing issue
11-07-2011, 03:49 AM
I have a beginner problem which I don't success to resolve...
I draw a grid on floor (z=0) using GL_LINES and I draw X, Y and Z axis on it (z=0) using GL_LINES with line with of 3.0f.
I have stitching (z-fighting) between grid and axis.
How can I solve this problem ? (I need depth testing).
11-07-2011, 03:56 AM
Offset the axes or the plane a little. You can also draw the plane, disable depth testing and then draw the axes.
BTW, OpenGL uses Y as the the "up" axis. The plane which most likely servers as the "floor" is most likely the XZ-plane. Are you sure about your coordinates or is it a typo?
11-07-2011, 04:37 AM
Yes I have done some typo errors.
So, I draw the floor as a grid on XZ plane.
Next, I draw axis.
Next, I draw a simple polygon (to test).
And as grid and X/Z axis have same Y, there is a stitching phenomena between them.
11-07-2011, 06:01 AM
I will be clearest saying that my problem is drawing line over another line with same Y coordinate renders unpredictable behavior because we don't know which line will be drawn over the other.
Can you tell me if I am correct, and what could be the solution ?
11-07-2011, 06:07 AM
As I said, you can simply offset the coordinate axes a little in y-direction. That's the easiest way.
11-07-2011, 06:09 AM
I'd rather want to not alter axis coordinates. Is there another solution to tell that last drawn primitives over pixels are the one which may appear ?
11-07-2011, 08:48 AM
You are going to run into that situation often because the z values will not be exactly for 2 lines that are rendered at the same location and if their vertices don't match.
1. Reduce the difference between the znear and zfar values for your projection matrix.
2. Make sure the znear and zfar are not invalid values, such as 0.0 for gluPerspective/glFrustum.
3. You can set glDepthTest(GL_LEQUAL)
4. Or just disable depth testing and you must sort the lines yourself.
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.