[LWJGL] Why are GL and GLU not singletons?

Hi, quick policy question. Why do GL and GLU not work as singletons? Considering the way that Display, Keyboard, Mouse etc all work as singletons with static create() and destroy() methods, why aren’t the OpenGL bindings handled the same way?

I expect there’s some cunning and devious reason for it, but I haven’t worked out what it is yet. Anyone care to enlighten me?

The cunning, devious reason is that we’re waiting for static import to make it into the language, at which point all GL and AL methods will become static - just as they are in every other language. In the meantime just soldier on with it.

Cas :slight_smile:

Ah, of course! Don’t hold your breath about static import however - I don’t see it happening any time soon. :-/

Just trying to find a “nice” way to propogate references to the rendering context over a GUI component tree. I don’t think there’s any point in passing them into the render method, seems a bit over the top to duplicate GL and GLU reference over ALL your objects however, considering making the base GUI class static and having package-visibility GL and GLU fields…

That’s what I did. Actually I used a protected static final GL rather than package visibility because it’s reasonable to extend the GUI into other packages.

Cas :slight_smile: