Passing GL to methods

Started by Tobbe A, November 16, 2003, 14:30:25

Previous topic - Next topic

Tobbe A

Hi,

Is it possible to have objects render themselves in a render() method? This is what I'd like to do in my game loop:

mesh.render(GL);

This doesn't work for me though since GL is abstract. Is there a solution to this?

thanks

----
EDIT

or, am I just making it more troublesome than it is? Can I just import lwjgl in my mesh class and use GL to render? probably. I'm off to try and forget about OO and be more static in my thinking. see ya...

/EDIT

the2bears

GL is designed for static referencing in lwjgl.  While this has some people requesting changes for multiple windows it does make the design and implementation easier.

This makes it easy for you to do what you want.  You need not worry about passing a reference to some GL object around, you just access it statically.  That means you merely include in your object's render() method the typical stuff... GL.glBegin() etc.  

Bill
the2bears - the indie shmup blog

Tobbe A

Ok, thanks for your confirmation (see edit) ... I'll think harder before i post something the next time :)