LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: kevingc on February 08, 2008, 00:00:03

Title: Making a lwjgl program into an Applet - no instructions on wiki?
Post by: kevingc on February 08, 2008, 00:00:03
Hi everyone,

I'm new to the openjgl scene (coming over from JOGL), and I'm having problems porting an application to an applet. Are there special types and methods I should be using when trying to get an lwjgl app (for example, gears) running as an Applet?

PS. I know that the Applet demo has an applet version of Gears inside it, but I'm asking for a "for dummies" version of how to turn the regular Gears sample (from the lwjgl website) into an applet. I know there's something more to it than just extending from Applet, because that didn't work...
Title: Re: Making a lwjgl program into an Applet - no instructions on wiki?
Post by: Matzon on February 08, 2008, 08:09:27
http://lwjgl.org/wiki/doku.php/lwjgl/tutorials/applet

This canvas  (http://java-game-lib.svn.sourceforge.net/viewvc/java-game-lib/trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTGearsCanvas.java?view=markup)is used for some glGears stuff:
Title: Re: Making a lwjgl program into an Applet - no instructions on wiki?
Post by: kevingc on February 08, 2008, 12:22:56
So, basically, you're saying that I need to extend AWTGLCanvas?

I'm a little confused. The wiki instructions say that I need to extend Applet, but the example you linked to only extends AWTGLCanvas. Am I missing something?
Title: Re: Making a lwjgl program into an Applet - no instructions on wiki?
Post by: kappa on February 08, 2008, 12:37:55
you extend Applet and place an AWTGLCanvas on it to use LWJGL.
Title: Re: Making a lwjgl program into an Applet - no instructions on wiki?
Post by: kevingc on February 08, 2008, 19:47:51
Ok, thanks, I think I get it.

1. Extend Applet in a dummy class.
2. Write the rendering in a class that extends AWTGLCanvas.
3. Add the AWTGLCanvas-derived class to the layout of the applet.

Update:

I tried extending the Gears sample with AWTGLCanvas. That seemed to work and was trivial to do.

However, I don't think I'm adding it to the applet correctly. First, I call this.add on the altered Gears sample. Then I call Gears.main(null). This creates an applet window and a second window. The gears are only rendered in the second window. If I do not call Gears.main, then nothing happens.