Thread: float to pixel(OpenGL)

  1. #1
    Hi ay_okay's Avatar
    Join Date
    Dec 2004
    Location
    Here
    Posts
    69

    float to pixel(OpenGL)

    what float number is equal to 1 pixel. I'm working in OpenGL, 800 x 600 window, and I want to make a box a certain amount of pixels long and wide. Help would be appreciated

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    1.0f?

    Converting a float to a pixel is not possible. But since pixels are normally represented as integers and offsets as unsigned longs then you must convert from float to one of these.

    But OpenGL will do that for you. If you want a box that is 50 units wide by 50 units tall you can do two things.

    Either create a unit box or a box that has length and height of 1.0f and then scale it to 50.0f via a matrix scaling operation, or you can specify a box with a length and height of 50.0f.

  3. #3
    Hi ay_okay's Avatar
    Join Date
    Dec 2004
    Location
    Here
    Posts
    69
    what matrix scaling operation and when I specify the box with a length of 50.0f, it goes of the screen.

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    This is my first thought, look into glProject and glUnProject

  5. #5
    Hi ay_okay's Avatar
    Join Date
    Dec 2004
    Location
    Here
    Posts
    69
    have any sites for that?

  6. #6
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    google

    I told you the wrong functions, this is what it should be gluProject and gluUnProject

  7. #7
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    If you are looking to make specific pixel size objects in opengl, use an ortho projection.
    http://nehe.gamedev.net/data/lessons....asp?lesson=21
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 05-13-2009, 03:25 PM
  2. Replies: 14
    Last Post: 06-28-2006, 01:58 AM
  3. Could somebody please help me with this C program
    By brett73 in forum C Programming
    Replies: 6
    Last Post: 11-25-2004, 02:19 AM
  4. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 05:26 PM