Public Group

# Units in OpenGL and/or Direct3D

This topic is 4994 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I was just wondering if there are any representation or meaning to the units used in OpenGL and Direct3D. I mean, if I give a length of 1.0f to one of my vectors, is it 1 foot, 1 meter, 1 undefined unit? Does it work the same in OpenGL and in Direct3D? thanks

##### Share on other sites
The units are completely arbitrary. You can make them be whatever you want depending on what sort of game you're writing.

##### Share on other sites
It means whatever you want. Just make sure everything else is relative to that unit, whatever you decide it should "mean".

##### Share on other sites
Ok, so if I want it to be inches, the perspective will adjust the same as if I want it to be feet or meters (with the proper unit convertion, naturally)?

thanks a lot

##### Share on other sites
Generally when rendering a 2D game one unit corresponds to one pixel. However, in 3D it makes little difference as the size a thing appears on screen depends on how close the thing is to the camera.
The size of one unit is up to you. It could represent a centimetre, and inch, a metre or 1000 kilometres (galaxy simulators etc). Chose a measurement and then try to build your models to the correct proportion.

Hope this helps,
Jackson Allan

##### Share on other sites
Excellent! Thanks a lot!!

##### Share on other sites
Of cource you can choose what you want to mean the value 1.0f:

a meter, a cm, a km, etc.

but keep in mind than in my experience in Direct 3D
if you use very small values (I mean for example 1.0f = 1 meter and have a model of a coin) that some rendering errors may be noticed. (if your 3D engine let's say render the coin from a "near" clipping plane).

Just consider that near-clipping-plane in Direct3D is the item [4, 4] of the VIEW_MATRIX, if you have a small value to this some rendering errors occurs in distant scenery (looks like
z-Buffering does not work well). But if you want to "view" with
your 3d engine from a close distance small objects like
a coin etc you sould give to the item [4,4] a small
value.

1. 1
2. 2
Rutin
22
3. 3
JoeJ
18
4. 4
5. 5

• 15
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631724
• Total Posts
3001903
×