Ronald A. Richardson.com
i burn in your atmosphere



Awesome Processing 1.0 BETA h4ck
comment No Comments Written by Ronald on February 15, 2008 – 11:51 pm

Up until now, it has been almost impossible to use OpenGL in an applet on a website. Thankfully that has all changed recently, thanks to the fine work of the people who maintain JOGL and Sun, with their JSR-231 release.

With this new release, Sun have signed the OpenGL files, so that your Java plug-in will tell you that an applet using the OpenGL files is trustworthy, and can do nothing malicious.

Requirements

This needs processing-0111 or later, this is essential as all previous versions would require extra self-signing steps.

Method

Create your OpenGL sketch as usual, including the opengl library from the processing menus. Once you are happy with it, export the sketch as normal.

Now comes the manual parts.

HTML changes

You need to edit the index.html file which processing created. The directory with the files should have automaticly opened when you exported.

Open the index.html file with a text editor, or your HTML editor of choice.

You now need to change the following lines:

<applet code="MySketch" archive="MySketch.jar" 
width="800" height="600" mayscript="true">
<param name="image" value="loading.gif">
<param name="boxmessage" value="Loading Processing software...">
<param name="boxbgcolor" value="#FFFFFF">
 
<!-- This is the message that shows up when people don't have
     Java installed in their browser. Any HTML can go here
     (i.e. if you wanted to include an image other links, 
     or an anti-Microsoft diatribe. -->
To view this content, you need to install Java from <A HREF="http://java.com">java.com</A>
 
</applet>

You only need to change the line, and add 2 more lines.

<!-- This is the new <applet...> part -->
<applet code="com.sun.opengl.util.JOGLAppletLauncher" 
archive="jogl.jar,MySketch.jar"
width="800" height="600" mayscript="true">
 
<!-- and now the 2 extra lines -->
<param name="subapplet.classname" VALUE="MySketch">
<param name="subapplet.displayname" VALUE="My Sketch called Foo">
 
<param name="image" value="loading.gif">
<param name="boxmessage" value="Loading Processing software...">
<param name="boxbgcolor" value="#FFFFFF">
 
<!-- This is the message that shows up when people don't have
     Java installed in their browser. Any HTML can go here
     (i.e. if you wanted to include an image other links, 
     or an anti-Microsoft diatribe. -->
To view this content, you need to install Java from <A HREF="http://java.com">java.com</A>
 
</applet>

The first change enables the special Applet Launcher code, that enables the applet to use OpenGL with the trusted jar files. The two other lines just tell the magic code what your sketchname is, so that it can run it once it’s loaded and set up the OpenGL stuff.

Files needed

Now, to publish the applet you only need a few of the files in the applet folder, and some processing ones. I suggest creating a new subdirectory in the applet directory, to marshall the files before uploading them.

In this new directory you need these files from the applet directory:

  • MySketch.jar
  • index.html
  • MySketch.pde – Optional. It’s just so other people can look at your sketch source.

You’ll also need to go to the processing-0111 directory, then look in libraries/opengl/library directory and copy the following files to the directory you created:

  • jogl.jar
  • jogl-natives-win32.jar
  • jogl-natives-macosx.jar
  • jogl-natives-linux.jar

Once you have all these files together, you can upload them all together to your website, and it should work just fine.

If you enjoyed the article, why not subscribe?

Related Post

  • No Related Post

Post a Comment

About The Author: Ronald

I am Ronald A. Richardson, champion of the underworld!

Want to subscribe?

 Subscribe in a reader Or, subscribe via email:
Enter your email address: