Results 1 to 5 of 5

Thread: gluOrtho2D (left and right)

  1. #1
    Newbie Newbie
    Join Date
    Feb 2014
    Posts
    3

    gluOrtho2D (left and right)

    I have a set up which calls

    Code :
    gluOrtho2D(65535.5,65536.5,0.0,360.0)

    drawn my points with x between 65535.5 and 65536.5 with constant delta x of (0.025) - ( meaning current p.x = 65535.5 then the next point is p.x1 = 65535.5 + 0,025 until its greater or equalt 65536.5). I found that point that is beyond or less than 65536.0 are correctly spaced and points past 65536.0 somehow the projection is wrong (there are more space in between points).

    Code :
    Trying to picture it
     
    65536.5                                65536.0                                 65536.5
    |                                           |                                         |
    ............................................. . . . . . . . . . . . . . . . . . . . . .

    If Ill bring all my points to zero as my starting point (by subtracting some offset) and Ill use
    Code :
    gluOrtho2D(0.0,length,0.0,360.0)
    things will be rendered right.

    What did I miss in gluOrtho2D functionality? Is this some limitation to 16bit (65536) value?

    baray98

  2. #2
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,214
    You don't have a problem with gluOrtho2D(), but with general precision.
    Simply, the numbers you need cannot be represented by single precision floating-point values with enough accuracy.
    Consider moving the segment to a coordinate-system origin.

  3. #3
    Newbie Newbie
    Join Date
    Feb 2014
    Posts
    3
    Thanks Aleksandar, by not moving the segment to a coodinate system origin will save me some work ( i dont have to subract some offset) which really helpful since this project is performance sensitive. Is there any other option other than moving it to the origin? Can I supply some double precision to some matrix stack?

  4. #4
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,214
    It is possible to avoid subtracting offsets, but it is not recommended, because:

    1. double precision is not supported in legacy OpenGL (since you are using gluOrtho2D you are probably confined to it),

    2. double precision is not supported on pre-GT200 cards and on some newer ones,

    3. double precision is far more expensive than single precision even on the most powerful GPUs specially designed for double precision calculation,

    4. simulating double precision in shaders is even more expensive than double precision (where it is supported)

    5. try to subtract offsets, or even better make objects without that offset if it is possible, and try performance (maybe it is not as expensive as you think).

  5. #5
    Newbie Newbie
    Join Date
    Feb 2014
    Posts
    3
    Thanks , I don't have an option but to live with an offset then. Thanks once again

Similar Threads

  1. From gluOrtho2D to 3D
    By Henry90 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-11-2014, 09:58 AM
  2. gluOrtho2D
    By mikeglaz in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 06-11-2010, 10:29 AM
  3. glViewport from top left, not bottom left
    By sol in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 06-20-2007, 01:07 AM
  4. gluOrtho2D?
    By nurulfaiz in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-14-2004, 08:30 AM
  5. No gluOrtho2D?!
    By riisXIV in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-30-2000, 04:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean