Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL: Convention for which axis is "up"?

Tags:

opengl

I'm new to OpenGL. It appears that I can make whatever axis be "up" that I want. However, what is idiomatic/conventional?

like image 360
Nick Heiner Avatar asked Sep 20 '10 20:09

Nick Heiner


People also ask

How do coordinates work in OpenGL?

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.

Where is the origin in OpenGL?

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.

What is left handed rotation?

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 what 3d direction does the object space positive y-axis point in world space?

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.


2 Answers

Generally

  • X is horizontal
  • Y is up
  • Z is depth (hence Z-buffer)

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.

like image 136
Cruachan Avatar answered Sep 22 '22 16:09

Cruachan


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".

like image 22
genpfault Avatar answered Sep 22 '22 16:09

genpfault