Jean-Marie ABISROR wrote:
>
>
> Hi,
>
> I Have a big problem in the conception of my programs with gl4java
> (Windows version) :
>
(doesn't care, if it is the dirty win32 os :-)
> I Have a subdirectory opengl in which I want to describe geometrics
> shapes (box,cylinder, etc.).
> In that subdirectory, I have a program named BoxNodeOpenGL.java where
> I have the display() routine for the description of the box.
>
> In the main directory, I have a program where I'd like to call (only
> once) the constructor cvs = new MyCanvas(640,480), in order to be able
> to call display() in BoxNodeOpenGL.class, CylinderNodeOpenGL.class,
> and so on.
>
> Is that possible ? How do you implement this kind of structure ?
> Do I need to use GLAnimCanvas with a thread ?
> If you have an example, please send it ...
> Thank's for your help.
>
> Looking forward to reading from you.
>
>
> Jean-Marie ABISROR
>
>
>
>
Well, I guess you have something like a scenegraph,
a data structure of items, which are renderable !
Just let them implement GLEnum and GLUEnum (just for your convinience),
and design them like:
public interface Node {
protected Node(GLFunc gl, GLUFunc glu);
public void draw();
public void init();
public void tick(long ms);
}
public class LineNode
implements Node, GLEnum, GLUEnum
{
protected LineNode(GLFunc gl, GLFunc glu)
{ save the gl, glu paras. }
public LineNode(GLFunc gl, GLUFunc glu, point p1, point p2)
{ this(gl, glu); save the p1, p2 }
public void init()
{ some initialisations ... }
public void draw()
{ draw from p1 till p2, using gl and glu }
public void tick(long ms)
{ move the element with its behavior to its new place,
assuming that ms milliseconds are passed (speed, vector, ...)
FOR ANIMATION !
}
}
Threads has nothing todo with this design !
Yours, Sven
--
mailto:sgo...@ja...
www : http://www.jausoft.com
voice : +49-521-2399440, +49-170-2115963; fax: +49-521-2399442
|