Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: OpenGL correctness

  1. #1
    Guest

    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?

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,527

    Re: OpenGL correctness

    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.

  3. #3
    Guest

    Re: OpenGL correctness

    ok, that seemed to work after a bit
    of tweaking, thanks alot

  4. #4
    Junior Member Regular Contributor
    Join Date
    Jan 2004
    Location
    Los Angeles, CA, USA
    Posts
    216

    Re: OpenGL correctness

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •