Swapping OpenGL's Y coordinates.
I've written an limited SVG (just path commands) to OpenGL parser and everything
works except the drawings are "reflected about the horizontal". Or is that rotated 180degress around the horizon in my openGL program. Here's a very rough ascii
"picture" of what's happening:
I believe I've seen a one line openGL command that can flip the Y coordinates.
but I can't find the code and I've been unsuccessful in phrasing my queries.
If this would fix my problem does anybody know this technique off the top of their heads?
Btw, is this a bug per se? or is it just that Adobe Illustrator and OpenGL has simply
defined their Y coordinates to be in different directions? Or is there something that
I should have done differently?
thanks!
works except the drawings are "reflected about the horizontal". Or is that rotated 180degress around the horizon in my openGL program. Here's a very rough ascii
"picture" of what's happening:
Code:
A
BCD
E
==== becomes
E
BCD
AI believe I've seen a one line openGL command that can flip the Y coordinates.
but I can't find the code and I've been unsuccessful in phrasing my queries.
If this would fix my problem does anybody know this technique off the top of their heads?
Btw, is this a bug per se? or is it just that Adobe Illustrator and OpenGL has simply
defined their Y coordinates to be in different directions? Or is there something that
I should have done differently?
thanks!
glScalef(1, -1, 1); before you draw stuff.
or when you set up your projection matrix (instead of inverting the modelview matrix), with gluPerspective, gluOrtho etc, you are setting the coordinate system.
or when you set up your projection matrix (instead of inverting the modelview matrix), with gluPerspective, gluOrtho etc, you are setting the coordinate system.
Sir, e^iπ + 1 = 0, hence God exists; reply!
Bingo! Thank You very much!
Minor quibble, but since OpenGL is a graphic's API, shouldn't this have been made the
default setting? Or does the fault lie with my drawing program when it save off the SVG file? Or is this just arbitrary decisions and I should just shut up and deal with it
Isn't glScale(1,1,1) appropiate when sending text to window and incrementing y will cause text to be appended at bottom of existing text and thus be in same order as reading and writing?
Quote:...before you draw stuff.
Minor quibble, but since OpenGL is a graphic's API, shouldn't this have been made the
default setting? Or does the fault lie with my drawing program when it save off the SVG file? Or is this just arbitrary decisions and I should just shut up and deal with it

Isn't glScale(1,1,1) appropiate when sending text to window and incrementing y will cause text to be appended at bottom of existing text and thus be in same order as reading and writing?
which way up y goes is irrelevant, given that you can change it so easily 
Some graphics APIs (QuickDraw, Quartz, Java2D, etc) use y top-to-bottom. This is good for UIs, etc. where things tend to need to be relative to the top of the window.
Some graphics APIs (OpenGL, Postscript, Cocoa, etc) use y bottom-to-top. This is the "right" way mathematically...

Some graphics APIs (QuickDraw, Quartz, Java2D, etc) use y top-to-bottom. This is good for UIs, etc. where things tend to need to be relative to the top of the window.
Some graphics APIs (OpenGL, Postscript, Cocoa, etc) use y bottom-to-top. This is the "right" way mathematically...
OneSadCookie Wrote:Some graphics APIs (QuickDraw, Quartz, Java2D, etc) use y top-to-bottom..Isn't divercity great, every time I try to do anything with graphics I have to do bloody y coordinate inversion thanks to apple's stupid non-standard coordinate system.
Some graphics APIs (OpenGL, Postscript, Cocoa, etc) use y bottom-to-top..
Didn't they notice everyone was getting along fine with the book like coordinate system, inverting it kinda gets in the way of everything.
Sir, e^iπ + 1 = 0, hence God exists; reply!
unknown Wrote:Isn't divercity great, every time I try to do anything with graphics I have to do bloody y coordinate inversion thanks to apple's stupid non-standard coordinate system.Ummm...![]()
Didn't they notice everyone was getting along fine with the book like coordinate system, inverting it kinda gets in the way of everything.
The old 2D coordinate system, with y going down, stems from the good old days when CRTs (TV) scanned from left to right and top to bottom (as that is the way the European languages are read).
Having y go up is the mathematically right way to do it, and since 3D APIs, such as OpenGL, rely heavily on linear algebra, that's how it is done. And that's how it should be done. Why some even relatively modern standards do it the other way around is a mystery to me.
What you guys are calling "the right way to do it mathematically" is as arbitrary as anything else. Going bottom-to-top might make some mathematical elitists happy, and going top-to-bottom might make sense to someone thinking about text or the way the screen refreshes, but neither approach is more legitimate or "correct" than the other.
If he's using an orthographic view, he could just as easily swap the top and bottom parameters and then he could have 0,0 at the top left. I do that for my UI layers in OpenGL. If he's doing this in a perspective view, then glScale probably is the only way.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| openal coordinates vs. opengl coordinates | gerald | 1 | 5,356 |
Feb 3, 2011 10:04 PM Last Post: OneSadCookie |
|
| Dynamically swapping between RAM and VRAM | Shunter | 7 | 3,488 |
May 22, 2009 11:44 AM Last Post: backslash |
|

