View Full Version : OpenGL correctness
I'm having problems drawing my isometric tiles in ortho graphic view. I have tried drawing the triangles both with and without the glTranslated(0.375,0.375,0.375) tweak.
This is the result..
Does anyone know how to draw primitives with exact pixel positions in ortho mode?
06-25-2004, 06:29 AM
OpenGL coordinates are not integers, all coordinates are float.
Pixels are no integers either, but small rectangular areas (simplified and abstacted).
Simply spoken, to draw a pixel in OpenGL you have to make sure the drawing primitive includes the pixel area's center (more exactly, rasterization adheres to the diamond exit rule.)
In your example, make sure your glOrtho setup is a 2D window area aligned size, but shift it down and left by half a pixel (-0.5, -0.5). Modelview needs to be identity.
Now if you send integers all coordinates are at pixel centers. (Actually this is not the perfect choice for screen aligned primitives (rect, drawpixels etc.), because you're on a razor's edge between drawing and not drawing a pixel. But give it a try.)
Two adjacent triangles will only perfectly share an edge without stitches, if you use the exact same coordinates for the shared edge.
In your case the coordinates are one unit apart. OpenGL drew it correctly as you specified.
ok, that seemed to work after a bit
of tweaking, thanks alot :D :p
06-30-2004, 07:57 PM
O-san, this is an important point. If it weren't for this, polygon meshes would never work. If two polygons share an edge, they should have no overlapping pixels.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.