Codehead's Corner
Random ramblings on hacking, coding, fighting with infrastructure and general tech
Where Is The Origin?
Posted: 12 Oct 2006 at 10:13 by Codehead

I have written a few wrappers and objects for OpenGL during the development of AMBER. The first was a general OpenGL wrapper. This used the top left of the screen as the origin for orthographic projections, mainly because I was used to it being there and it avoided problems with mouse coordinates.

Next came the CBFG text class. This was intended to be dropped into other people’s code, so I used a bottom left origin as seems to be standard in OpenGL.

More recently I’ve incorporated my GUI class into the GL wrapper and bolted my text object onto it to provide textboxes, lists, etc…

This is where the problems began, the GL class and the GUI object use the top left as origin and the text class uses the bottom, so all the text in the controls was upside down.

I’ve rewritten the GL class and GUI class to use the bottom as the origin as this is the OpenGL way. However, it seems strange that every other system I’ve used treats the top of the screen as the Y axis origin. Why does GL have to be different? Is there any gain to be had by doing this? Or could I just fudge the projection matrix to use the top as the origin?

Ah well, it’s done now, I may re-visit this during optimisation, but that’s a long way off.

Categories: Projects AMBER CBFG
Tags: #OpenGL #Rant



Site powered by Hugo.
Polymer theme by pdevty, tweaked by Codehead