• Create Account

# What makes OpenGL right handed?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

63 replies to this topic

### #1GaryNas  Members   -  Reputation: 134

Like
0Likes
Like

Posted 25 March 2010 - 12:11 AM

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?

### #2gtdelarosa2  Members   -  Reputation: 121

Like
0Likes
Like

Posted 25 March 2010 - 12:53 AM

Negative Z points away from the camera origin( into the screen ) and Positive Y points up, Positive X points towards the right.

### #3V-man  Members   -  Reputation: 813

Like
0Likes
Like

Posted 25 March 2010 - 01:04 AM

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.

### #4GaryNas  Members   -  Reputation: 134

Like
0Likes
Like

Posted 25 March 2010 - 01:13 AM

Quote:
 Original post by gtdelarosa2Negative 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?

### #5Yann L  Members   -  Reputation: 1802

Like
0Likes
Like

Posted 25 March 2010 - 01:26 AM

Quote:
Original post by GaryNas
Quote:
 Original post by gtdelarosa2Negative 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.

### #6batabek  Members   -  Reputation: 148

Like
0Likes
Like

Posted 25 March 2010 - 01:30 AM

### #7cgrant  Members   -  Reputation: 1589

Like
0Likes
Like

Posted 25 March 2010 - 01:36 AM

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.

### #8szecs  Members   -  Reputation: 2782

Like
0Likes
Like

Posted 25 March 2010 - 01:40 AM

I have a hunch that this will be a multi-paged thread (probably closed too)

### #9GaryNas  Members   -  Reputation: 134

Like
0Likes
Like

Posted 25 March 2010 - 01:40 AM

Quote:
 Original post by Yann LWhy 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.

### #10szecs  Members   -  Reputation: 2782

Like
0Likes
Like

Posted 25 March 2010 - 01:42 AM

Your models will be mirrored (I hope God, I'm right...)

### #11GaryNas  Members   -  Reputation: 134

Like
0Likes
Like

Posted 25 March 2010 - 01:42 AM

Quote:
 Original post by cgrantThe 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".

### #12Yann L  Members   -  Reputation: 1802

Like
0Likes
Like

Posted 25 March 2010 - 01:47 AM

Quote:
 Original post by GaryNasDo 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 GaryNasLet 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.

### #13MrDaaark  Members   -  Reputation: 3556

Like
0Likes
Like

Posted 25 March 2010 - 01:54 AM

Quote:
 Original post by GaryNasI'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.

### #14haegarr  Crossbones+   -  Reputation: 7160

Like
0Likes
Like

Posted 25 March 2010 - 02:15 AM

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.

### #15V-man  Members   -  Reputation: 813

Like
0Likes
Like

Posted 25 March 2010 - 02:34 AM

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.

### #16scgames  Members   -  Reputation: 2078

Like
0Likes
Like

Posted 25 March 2010 - 08:26 AM

Quote:
Original post by Daaark
Quote:
 Original post by GaryNasI'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.)

### #17szecs  Members   -  Reputation: 2782

Like
0Likes
Like

Posted 25 March 2010 - 08:31 AM

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.

### #18scgames  Members   -  Reputation: 2078

Like
0Likes
Like

Posted 25 March 2010 - 08:55 AM

Quote:
 Original post by szecsMaybe 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).

### #19swiftcoder  Senior Moderators   -  Reputation: 17689

Like
0Likes
Like

Posted 25 March 2010 - 09:00 AM

Quote:
 Original post by jykif 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 - Software Engineer @ Amazon - [swiftcoding] [GitHub]

### #20Kwizatz  Members   -  Reputation: 1343

Like
0Likes
Like

Posted 25 March 2010 - 09:00 AM

Quote:
 Original post by jykI 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 ]

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS