OpenGL Perspective Projection Right Handed to Left Handed
HTML-код
- Опубликовано: 6 фев 2025
- OpenGL uses a right-handed coordinate system until the perspective projection where OpenGL switches to a left-handed coordinate space for the depth buffer (z-buffer) test.
Just for clarification. The statement that "OpenGL is a Right-Handed Coordinate System" is not entirely accurate. OpenGL allows you to use left or right. Direct3D (Part of DirectX) is strictly Left-Handed. OpenGL however has functions that allow you to choose which set of vectors you want to use. With that said though, most people use Right-Handed, since it's the most common and is taught in most tutorials. How would you write OpenGL to use Left-Handed ? You would mirror, or flip, your transforms to what you normally would with Right-Handed.
I've been reading this a lot, but I just don't get it. Why does OpenGL "use" a right-handed coordinate system? I mean, OpenGL is not actually using anything in particular! It's _me_, the programmer, using a coordinate system, and I can have my model, world and camera space all in left-handed if I want, just gotta feed an appropriate left-handed projection matrix (with a non-inverted homogenous z-base vector in it, e.g. with a w-component = 1, instead of -1 like gluPerspective does) into OpenGL, right?
Also, couldn't I have clip space in right-handed no problem by just feeding in a right-handed projection matrix and setting the depth compare function to greater-than?
Not to mention that modern OpenGL doesn't even have a matrix stack anymore, and all relevant transformations are fully programmable - are required to be programmed by the client even!
Is there a particular reason why people keep insisting (and teaching in University, for that matter) that OpenGL "is right-handed"?
If I am not wrong, opengl uses, in fact, the right-hand rule. If you draw a line from 0 - 1 in x-axis, 0 - 1 in y-axis, and 0-1 in z-axis, you will se that it is a right-hand standard. Also try to make simple rotation around a single axis, you will see the rotation also following the right-hand.
Of course that, with appropriated matrix manipulation you can make your system behave in opposite direction, but, in essence, I beleave that the righ-hand is the norm.
good question.
Why was the other objects geting smushed to a 2d plane while this cube didn't in the perspective transform?
This video is not in the github list. There is no code for this tutorial.
Why are you such a liar, Jamie? :)
He said he lied in 3 consecutive videos :D