Skip to main content
GameDev.net gamedev.net
🔒 Locked

What makes OpenGL right handed?

Started by GaryNas Mar 25, 2010 at 6:11 AM 62 replies 28.3k views
Original Post
GaryNas
GaryNas
I often hear OpenGL referred to as using a right handed coordinate system, but I'm a little unclear as to the precise reason why this is so. Sure, the gluXXX helper functions operate in a right handed system, but what specifically about OpenGL makes it right handed?
gtdelarosa2
gtdelarosa2
Negative Z points away from the camera origin( into the screen ) and Positive Y points up, Positive X points towards the right.
V-man
V-man
It's because of the projection matrix. I believe it is because of the 3rd row, 3 column. I'm not sure since I haven't bothered with that matrix in years.
GaryNas
GaryNas
Quote:
Original post by gtdelarosa2
Negative Z points away from the camera origin( into the screen ) and Positive Y points up, Positive X points towards the right.


Yes, that's a right handed system, but what about OpenGL requires this?
Yann L
Yann L
Quote:
Original post by GaryNas
Quote:
Original post by gtdelarosa2
Negative Z points away from the camera origin( into the screen ) and Positive Y points up, Positive X points towards the right.


Yes, that's a right handed system, but what about OpenGL requires this?


Why do some countries drive on the right and some on the left side of the road ? It's a convention. They had to pick something.
Great_White
Great_White
check this link http://www.geometrictools.com/Documentation/LeftHandedToRightHanded.pdf
"A human being is a part of a whole, called by us,universe, a part limited in time and space. He experiences himself, his thoughts and feelings as something separated from the rest... a kind of optical delusion of his consciousness. This delusion is a kind of prison for us, restricting us to our personal desires and to affection for a few persons nearest to us. Our task must be to free ourselves from this prison by widening our circle of compassion to embrace all living creatures and the whole o
cgrant
cgrant
The pipeline requires the data to be as such for processing..i.e internally it makes the assumption that stuff are in a right handed coordinate system. Not directly related, but APIs have to make certain assumptions, ex. that is why by default vertices in GL have to be specified counter-clockwise...thats just the way it is.
GaryNas
GaryNas
Quote:
Original post by Yann L
Why do some countries drive on the right and some on the left side of the road ? It's a convention. They had to pick something.


Do you mean they had to pick something for the glu library, or for OpenGL?

Let me give an example. Assume my models, and world are left handed. I use this left handed world in OpenGL and do not convert to a right handed system. Which part of OpenGL will have trouble with this left handed system? I believe the problem would be in clip space, but I'm not sure.
GaryNas
GaryNas
Quote:
Original post by cgrant
The pipeline requires the data to be as such for processing..i.e internally it makes the assumption that stuff are in a right handed coordinate system. Not directly related, but APIs have to make certain assumptions, ex. that is why by default vertices in GL have to be specified counter-clockwise...thats just the way it is.


Ah, this is exactly what I'm getting at. Do you know which part of the pipeline requires a right handed system? I've searched all over for this info, but all I can find is "OpenGL is right handed", "DirectX is left handed".
Yann L
Yann L
Quote:
Original post by GaryNas
Do you mean they had to pick something for the glu library, or for OpenGL?

glu is the OpenGL utility library, it's evident that both have to use the same conventions.

Quote:
Original post by GaryNas
Let me give an example. Assume my models, and world are left handed. I use this left handed world in OpenGL and do not convert to a right handed system. Which part of OpenGL will have trouble with this left handed system?

None at all. It will just not be displayed the way you intended it to be. Up, down, left, right, in, out - all that are human concepts. A mathematical processing framework, such as OpenGL, can't use these. You have to map these concepts of human perception to absolute mathematical terms. Just as OpenGL doesn't know what the colour red is, but it knows (1,0,0).

By supplying your own projection matrix to OpenGL, you can make it left or right handed. Or, assuming some vertex shader magic, you could even specify your points in a totally different coordinate system. Spherical polar, for example. It's all a question of conventions.

So to answer your question, there is no part of OpenGL that requires a certain handedness. Assuming we're talking about modern, non-FFP OpenGL.
Daaark
Daaark
Quote:
Original post by GaryNas
I've searched all over for this info, but all I can find is "OpenGL is right handed", "DirectX is left handed".
That's all you can find, because that's the entirety of it. There's nothing more to say about it.

haegarr
haegarr
The difference I see is actually in projection computation (as was already mentioned above). If you choose the view local x and y directions for spanning the view plane, and let stuff at less depth cover stuff at greater depth, then choosing whether depth increases with increasing local z or else increases with decreasing local z makes the difference. The former method would be LHS, and the latter one RHS.
V-man
V-man
Yup, it is the projection matrix. I have done some D3D and GL code where both had to be right handed. I just manipulated the projection for D3D (actually, they have D3DXPersPectiveRH) and also for modelview rotation, there is the RH versions. Translation is universal. Scale is universal.

The other thing left to do is setup culling for D3D.
Zakwayda
Zakwayda
Quote:
Original post by Daaark
Quote:
Original post by GaryNas
I've searched all over for this info, but all I can find is "OpenGL is right handed", "DirectX is left handed".
That's all you can find, because that's the entirety of it. There's nothing more to say about it.
I'm not sure it's quite that simple.

I said this same thing in another recent thread, but as far as I can tell, Direct3D/DirectX is no more left-handed than it is right-handed. It works fine with both left- and right-handed systems (as far as I can tell, at least), and the DX math library includes transform functions for each handedness.

Why Direct3D is thought of as being left-handed, I'm not sure, but I suspect it may be historical. Maybe someone else can shed some light on this.

My guess is that OpenGL can be used with a left-handed system just as easily as Direct3D can be used with a right-handed system (as was suggested previously). I haven't actually tried this myself though, so I can't say for sure.

If that's true though, then I would think that the only thing that makes OpenGL 'right-handed' is the few convenience functions that build transforms for which handedness matters (gluLookAt, gluPerspective, etc.). If you take these out of the picture (e.g. by using glLoad/MultMatrix, or by using the programmable pipeline), then I'm not sure that OpenGL can be said to have an inherent handedness.

So to get back to the original question, my guess is that the only thing that makes OpenGL 'right-handed' is a few convenience functions that you can easily do without, and that in fact are no longer even included as part of the API. (I could be overlooking something though.)
szecs
szecs
Maybe I will tell a totally dumb thing, but I'm a bit tired.
I think that makes openGL right-handed, is that if you don't apply any transformations (identity as model-view and projection), a model made and viewed in a left handed editor would appear mirrored in onenGL in the said conditions.

Some one please clarify this.
Zakwayda
Zakwayda
Quote:
Original post by szecs
Maybe I will tell a totally dumb thing, but I'm a bit tired.
I think that makes openGL right-handed, is that if you don't apply any transformations (identity as model-view and projection), a model made and viewed in a left handed editor would appear mirrored in onenGL in the said conditions.

Some one please clarify this.
I don't think that's right; if the projection matrix is identity, I don't think the visual output will be anything meaningful (in the general case, at least).
swiftcoder
swiftcoder
Quote:
Original post by jyk
if the projection matrix is identity, I don't think the visual output will be anything meaningful (in the general case, at least).
Sure it will. An identity projection matrix is just an unscaled orthographic projection.
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
Kwizatz
Kwizatz
Quote:
Original post by jyk
I said this same thing in another recent thread, but as far as I can tell, Direct3D/DirectX is no more left-handed than it is right-handed.


You may be thinking about row mayor vs column mayor notation, but anyway in order to use the opposite handedness multiply your matrices by/or use this as your identity matrix:

 [ 1  0  0  0 ][ 0  1  0  0 ][ 0  0 -1  0 ][ 0  0  0  1 ]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.