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 7 of 7

Thread: Unit of length in OpenGL

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2007
    Location
    VietNam
    Posts
    21

    Unit of length in OpenGL

    Dear everybody,

    I got a question about unit of length in OpenGL. Assuming that I want to render a cube with the length of the sides of the cube is 20 millimetre, then what number I have to put in command glutWireCube( ???? f)


  2. #2
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    3,768

    Re: Unit of length in OpenGL

    I got a question about unit of length in OpenGL.
    There is no unit of length in OpenGL. It is whatever you want it to be, based on your projection matrices and camera location.

  3. #3
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,119

    Re: Unit of length in OpenGL

    You simply assume any unit you want.
    For example - you may assume unit is 1m and draw cube that has size of 0.02 or you can assume it's 1mm and draw a cube of size 20.
    You just need to use the same units when defining your view
    frustum (projection matrix).

    I always use 1m since it's the basic unit used in many physics related formulas.

  4. #4
    Junior Member Newbie
    Join Date
    Oct 2007
    Location
    VietNam
    Posts
    21

    Re: Unit of length in OpenGL

    Thank you.

    but It's hard to understand, an example woulb be helpful for me

  5. #5
    Intern Contributor
    Join Date
    May 2007
    Posts
    53

    Re: Unit of length in OpenGL

    That means is the size of cube you look at the screen can be looked has the different size through the projection matrix with different parameters although you set the same size for the cube.
    Note,you are draw in the space of virtual world,not the real world.

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

    Re: Unit of length in OpenGL

    In short : use the units you want, it will not matter.
    It can be 1 gl unit = 1 meter, 1 inch, Pi*lightspeed, whatever.

  7. #7
    Advanced Member Frequent Contributor
    Join Date
    Feb 2006
    Location
    Sweden
    Posts
    748

    Re: Unit of length in OpenGL

    I usually use 1 unit = 1 meter, it makes everything easy when adding motion, physics and stuff like that, as you can just copy the values and formulas directly from an SI based physics book.

Posting Permissions

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