Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the OpenGL Coordinate System right-handed or left-handed?

Say I am using an Identity Matrix for my modelViewTransformation Matrix on an OpenGL ES 2.0 program. The Co-ordinate system in this case is the canonical OpenGL co-ordinate system which extends from (-1,-1,-1) to (1,1,1).

Is this coordinate system right-handed or left-handed?

A broader question: Is there a document with OpenGL which can list all the mathematical conventions followed by the API?

like image 263
praveen Avatar asked Mar 02 '11 13:03

praveen


2 Answers

ALWAYS REMEMBER!! OPENGL ONLY KNOWS NDC ,AND IT IS LEFT_HANDED!

the illusion openGL is right handed,because in fixed pipeline,the fixed function is right handed,like glOrtho(...),glFrustrum(..), all these functions have been deprecated In programmable-pipline times.

OpenGL doesn`t care what handed coordinate system you use for intermediate matrix processes. you can use axis coordinate system if you want,as long as you mirror that to NDC.

forget about Camera!

because our screen is a 2D plane.Imagine this,your viewport is a yellow rubber plane.pine those four corner to NDC. something like this: enter image description here

all vertex in NDC hit on on the yellow rubber plane along the -z axis.That`s what you see on real screen.

like image 188
ZK_ Avatar answered Oct 04 '22 14:10

ZK_


My question is, is this coordinate system right-handed or left-handed?

By default, OpenGL is always right-handed. You can observe this by the automatic normal creation. You can force a left-handed normal creation by specifying it per point but, in general, right hand rule applies all the time. See 9.150 in the OpenGL FAQ for more discussion of the right-hand-only nature of OpenGL.

... all the mathematical conventions followed by the API?

It's not clear what you're asking for. The math is basic linear algebra with a strong focus on matrix math and linear transformations.

EDIT to respond to comment question:

REMEMBER, however, that if you are using the uniform matrix calls rather than the older glRotates, etc, that you must specify whether you are using row-major or column-major matrices. In this case (from the code mentioned in the comment):

glUniformMatrix4fv(uniforms[UNIFORM_MVP], 16, GL_FALSE, mvpMatrixZRotation);

In this call, GL_FALSE is telling the call that this is a column-major matrix and, as such, the rotation that results will be the transpose of what was intended. Therefore, the rotation will be inverted, looking like a left-handed coordinate system.

Change that to GL_TRUE and all will be well.

Here is a very simple example from the OpenGL discussion board that's relevant to this specific topic.

Yet another edit to respond to the request for comment: Here is another detailed explanation of the matrix pipeline in OpenGL. Notice the GL_MODELVIEW diagram with the three axes: they illustrate the right-handed coordinate system. The above citation in the FAQ also still applies.

like image 36
Bob Cross Avatar answered Oct 04 '22 14:10

Bob Cross