Is the OpenGL coordinate system right or left?

Let's say I use Matrix Identity for my ModelViewTransformation matrix in OpenGL ES 2.0. The coordinate system in this case is the OpenGL canonical coordinate system, which extends from (-1, -1, -1) to (1,1,1).

Is this coordinate system right or left?

The broader question is: is there a document with OpenGL that can display all the mathematical conventions followed by the API?

+4
source share
4 answers

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

By default, OpenGL is always right. You can observe this through automatic normal creation. You can force the left normal creation by pointing it to a point, but as a rule, the right rule applies all the time. See 9.150 in the OpenGL FAQ for a more detailed discussion of OpenGL law, based on law only.

... all the math conventions and then the API?

It is not clear what you are asking. Mathematics is a basic linear algebra with a strong focus on matrix mathematics and linear transformations .

EDIT to answer comments question:

Remember, however, that if you use uniform matrix calls, rather than the old glRotates, etc., you must indicate whether you are using main matrices or main columns. In this case (from the code mentioned in the comment):

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

In this call, GL_FALSE reports that it is the main matrix of the column, and thus the rotation result will be a carry over of what was intended. Therefore, the rotation will be inverted as the left coordinate system.

Change it to GL_TRUE and everything will be fine.

Here is a very simple example from the OpenGL discussion panel related to this particular topic.

Another change to respond to a comment request : Here is another detailed explanation of the matrix pipeline in OpenGL. Notice the GL_MODELVIEW diagram with three axes: they illustrate the right coordinate system. The above quote in the FAQ also still applies.

+7
source

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

the openGL illusion is the right hand because in a fixed pipeline, a fixed function is right, like glOrtho (...), glFrustrum (..), all of these functions are deprecated. In programmable periods.

OpenGL does not care about which transferred coordinate system you use for intermediate matrix processes. you can use the axis coordinate system if you want, as long as you mirror it in the NDC.

forget about Camera!

because our screen is a two-dimensional plane. Imagine your viewport is a yellow rubber plane. Return these four corners to NDC. something like that: enter image description here

all vertices in the NDC fell on the yellow rubber plane along the -z axis. This is what you see on the real screen.

+4
source

The canonical scope of the view, as well as the normalized coordinates of the device, is / left. This is easy to verify by passing the identity matrix and drawing two triangles:

 float points[] = { -1, 1, -0.5, -1, -1, -0.5, 1, -1, -0.5, 1, 1, 0.5, -1, -1, 0.5, 1, -1, 0.5 }; 

and looking at the results (with glEnable (GL_DEPTH_TEST))

So your vertex shader will look like this:

 uniform mat4 mvp_mat; // Incoming per vertex... position (fills in 1 for w if from vec3 buf) layout (location = 0) in vec4 v_vertex; void main(void) { // multiplying by identity doesn't transform the geometry gl_Position = mvp_mat * v_vertex; } 

or you could even test it more simply since the identity matrix does nothing

 layout (location = 0) in vec4 v_vertex; void main(void) { //no transformation, no confusion, just straight to OpenGL gl_Position = v_vertex; } 

Obviously, you will need to make the colors of the triangles different so that you can see how they overlap.

Also see this post and my comment / question in it: plus.google.com/114825651948330685771/posts/AmnfvYssvSe

I don’t know where all the wrong information comes from the Internet and even into textbooks. OpenGL only works by default if you are talking about a triangular winding to determine the front edge (CCW by default = right). World space, object space and eye space does not exist for OpenGL, only for a graphic programmer. OpenGL just takes the dots, clamps something outside the scope of the canonical representation [-1, -1, -1] x [1, 1, 1] and converts them to screen / window coordinates, which are [0, w by default) x [0, h) x [0, 1]. If depth checking is enabled, the default behavior is left, looking down + z.

There are several ways to account for OpenGL's left hand. Most people deal with this in their matrices (although they do not understand this). I think you can also change it with glDepthFunc and set it to GL_GREATER.

http://www.opengl.org/sdk/docs/man3/xhtml/glDepthFunc.xml

Further evidence that it is left is here http://www.opengl.org/sdk/docs/man3/xhtml/glDepthRange.xml

"After clipping and dividing by w, the coordinates of the depth vary from -1 to 1, which corresponds to the plane of near and far clipping," that is, a positive z goes to the screen = left. You can also use DepthRange to change the behavior on the right.

EDIT: In response to Bob Cross's insistence that I am mistaken, there is only one file program that shows that I am right. https://github.com/rswinkle/opengl_reference/blob/master/src/left_handed.c

You can see the screenshot in README https://github.com/rswinkle/opengl_reference

+3
source

The Opengl ES coordinate system is truly a right-handed system, including the canonical volume (-1, -1, -1) - (1,1,1). I checked this through code.

+1
source

Source: https://habr.com/ru/post/1341990/


All Articles