|
From: Pontus L. <po...@ly...> - 2000-01-28 10:27:01
|
On Thu, 27 Jan 2000, Max Gilead wrote:
> Hi!
>
> In my application I need variables gl and glu in GLCanvas public instead
> of protected. It is needed for remote rendering possibilities - for
> example:
>
> //class in package opengl
> public class GLViewport extends GLCanvas
> {
> private ClassThatDrawsObjects ctdo;
>
> public void display()
> {
> //setup
> ctdo.drawMyself(this);
> }
> }
>
> //class in package geometry
> public class ClassThatDrawsObjects
> extends SomeOtherNeededClass
> {
> public void drawMyself(GLViewport viewport)
> {
> viewport.gl.glBegin(viewport.GL_TRIANGLES);
> viewport.gl.glVertex*(...);
> ...
> viewport.gl.glEnd();
> }
> }
>
> so when program reaches display() method it calls method drawMyself() in
> some other class and this class performs rendering (it needs GLFunc to
> do so). Have I made myself clear? :-)
>
> Is there any better way to do so? I need this because in my modeler I
> want each object to draw itself.
Can't you just pass gl and glu as parameters to your rendering function?
The way I did it is I wrote a class that extends java.awt.Graphics that
takes gl and glu as arguments to its constructor, and this new Graphics
object is passed as argument to all my rendering functions.
The reason I decided to extend Graphics is just so that existing classes
written to render using pure JDK methods can now render OpenGL with no
changes ;)
--
Pontus Lidman, po...@ma..., Software Engineer
No matter how cynical you get, it's impossible to keep up.
Scene: www.dc-s.com | MUD: tyme.envy.com 6969 | irc: irc.quakenet.eu.org
|