pixel coordinates(opengl)

This is a discussion on pixel coordinates(opengl) within the Game Programming forums, part of the General Programming Boards category; is there any way for a given point in 3d space to get its projection in screen pixel coordinates using ...

  1. #1
    Registered User white's Avatar
    Join Date
    Nov 2004
    Posts
    39

    pixel coordinates(opengl)

    is there any way for a given point in 3d space to get its projection in screen pixel coordinates using opengl and glut?

    the problem is that i need to know where each of my point is going to be drawn in the screen before it does. I know how to do it analytically but i would prefer to avoid such thing.

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    I think you use glUnProject().

  3. #3
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    actually you would want to project, not unproject to get window coords from object ones.

    see gluProject
    and for reference gluUnProject

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    ...3d space to get its projection in screen pixel coordinates ...
    Sounds like he wants to move from 3D space to 2D screen space. In that case an unproject is required to undo the projection performed on the vertices.

  5. #5
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    hmm, i think we're on different wavelengths here.

    In OpenGL you have a 3D representation of your model. You then project the 3D coordinates to screen space to get the 2D coords (this is done in the pipeline to render the frame). Given the current state of the matrices you can then unproject the 2D screen coords to get the original 3D coords.

    So, moving from 3D object space to 2D screen space is a projection, not an unprojection.

    Quote Originally Posted by OpenGL Reference

    gluProject map object coordinates to window coordinates
    gluUnProject map window coordinates to object coordinates

  6. #6
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Duh. Yep that would be a projection. Dunno what I was thinking.

    Too much MFC me thinks.


  7. #7
    ---
    Join Date
    May 2004
    Posts
    1,379
    >>Too much MFC me thinks.

    Microsoft has claimed another soul

  8. #8
    Registered User white's Avatar
    Join Date
    Nov 2004
    Posts
    39
    well gluProject worked even better than I thougnt thank for the tip

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Changing pixel colour
    By redruby147 in forum C Programming
    Replies: 11
    Last Post: 06-09-2009, 05:28 AM
  2. How can I make this code more elegant?
    By ejohns85 in forum C++ Programming
    Replies: 3
    Last Post: 04-02-2009, 08:55 AM
  3. Reading pixel color data from screen
    By JJFMJR in forum Windows Programming
    Replies: 8
    Last Post: 08-22-2008, 12:27 PM
  4. Getting Pixel Colour Screen
    By god_of_war in forum C++ Programming
    Replies: 3
    Last Post: 03-14-2006, 12:17 PM
  5. getting pixel information
    By Mr Silvertongue in forum C++ Programming
    Replies: 4
    Last Post: 03-28-2004, 10:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21