I'm new to OpenGL. It appears that I can make whatever axis be "up" that I want. However, what is idiomatic/conventional?
The convention in OpenGL is to work with a coordinate system in which the positive z-direction points toward the viewer and the negative z-direction points away from the viewer. The transformation into default coordinates reverses the direction of the z-axis.
The origin is in the center of the screen. X points right, Y points up, and Z points out of the screen. Since you aren't changing the projection matrix, it goes from -1 to 1 in each direction.
Rotations use the left-handed rotation rule. To predict the direction of positive rotation, curl your fingers on your left hand and point your thumb in the direction of the rotational axis. Your fingers will curl in the direction of positive rotation along that axis.
In both coordinate systems, the positive x-axis points to the right, and the positive y-axis points up. You can remember which direction the positive z-axis points by pointing the fingers of either your left or right hand in the positive x direction and curling them into the positive y direction.
Generally
you can largely adopt any convention you wish as long as you are internally consistent, but the above is pretty much the standard and using it yourself will make other code easier to understand.
I like +Z to be "up". Makes it easier for me to reason about glVertex()
, glNormal()
, and glTexCoord()
calls.
That said the default/identity GL_MODELVIEW
matrix has +Y being "up".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With