Results 1 to 5 of 5

Thread: opengl coordinate system

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2011
    Posts
    13

    opengl coordinate system

    I find the OpenGL Co-ordinate system really hard to use. I would much rather have things like glVertex2f(-100,-100) put a vertex back 100 pixels in the X and Y direction from the origin, instead of it being totally off the screen. Is there any way that I can do this? I was thinking mabey just glTranslate'ing out in the Z direction but I am not sure if this will work.

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: opengl coordinate system

    If you want to use pixel coordinates, use the correct projection, like for example :
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity ();
    glOrtho(0, WindowWidthInPixels, 0, WindowHeightInPixels, -1, 1);

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2011
    Posts
    13

    Re: opengl coordinate system

    Thanks for your answer.
    When I use that method, the origin (0,0) seems to be at the bottom left corner of the screen. Is there anyway to make it the top right? I don't really understand the left, right, top, bottom paramaters.

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Mar 2009
    Location
    Karachi, Pakistan
    Posts
    810

    Re: opengl coordinate system

    With GL u decide what to do. As pointed out by ZBuffer set the appropriate projection matrix and u will have what u want.
    Regards,
    Mobeen

  5. #5
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: opengl coordinate system

    Top right ? This is unusual.
    left, right, top, bottom paramaters define the range of GL coordinates visible on the glViewPort. So reverse order to reverse axes, like :
    glOrtho(width,0,height,0,-1,1);

Similar Threads

  1. draw Coordinate system on OpenGL window
    By Doctor100 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 09-30-2014, 05:40 AM
  2. Which 3D coordinate system OpenGL uses?
    By Javac in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 10-14-2003, 02:55 AM
  3. Replies: 8
    Last Post: 08-18-2003, 05:22 AM
  4. How does the coordinate system work in OpenGL?
    By in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 05-03-2001, 08:04 PM
  5. OpenGL coordinate system
    By KurtCob in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 10-04-2000, 07:58 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