Author Topic: How to use ogl on an applet  (Read 10133 times)

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
How to use ogl on an applet
« on: May 15, 2008, 07:25:37 pm »
Hi, I have already done applets with opengl by signing them, but I dont know how to distribute them, because of the dll file needed. My question is? How to pack, join, merge, or whatever, all the dlls needed for running an applet that use dlls!!!!!
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How to use ogl on an applet
« Reply #1 on: May 15, 2008, 09:06:33 pm »
LWJGL includes an applet loader that handles these things. I've never used it myself, but i guess paulscode has for this demo applets of the SoundManager.

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: How to use ogl on an applet
« Reply #2 on: May 16, 2008, 02:13:51 am »
If you prefer not to use the appletloader, or if you have other dlls you want to distribute besides the lwjgl natives, it is possible to do it yourself.

I have not done this before, but I believe the basic idea is to pack your DLL's into the JAR, then programatically copy them onto the user's computer.  To gain access for copying the files, your JAR must be signed.  This lets the user chose whether or not to give your applet access to his computer.  There are a lot of guides online for how to sign a JAR, but I have not found an easy one to follow.  The process seems to be extremely complicated and counter-intuitive, so unfortunately I can't help you out much with that part.

The other thing you would need to do, is to have your applet determine if the user's computer is running Windows, Mac, or Linux.  The dynamic libraries for each OS are different.  For example, in the lwjgl library, the natives consist of DLL's for Windows, SO's for Mac, and JNLIB's and DYLIB's for Linux.

I was thinking since the developers of lwjgl have done it when they created the appletloader, you might be able to get some help on the lwjgl forums, http://www.lwjgl.org (although I have not found them to be very useful in my opinion).  Might be worth a shot.

Oh, BTW, if you prefer to just use the appletloader, I can help you out with that, since I have had experience using it, and I know what kind of problems you might run into.
« Last Edit: May 16, 2008, 02:22:28 am by paulscode »

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: How to use ogl on an applet
« Reply #3 on: May 16, 2008, 04:11:25 pm »
I have som eother dlls in this project. I guess that packing them with the jar is the best idea.

Now my question is: Once the dll is inside the jar, how can I unpack it from the jar? I am thinking on using the FileInput/OutputStreams but the path wont be valid! Any ideas?
Nada por ahora

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: How to use ogl on an applet
« Reply #4 on: May 17, 2008, 02:25:22 am »
I haven't tried this, but I think you should be able to do something like this:

Code: [Select]
java.net.URL myResource = this.getClass().getResource( "filename" );
java.io.FileInputStream myFileStream = new java.io.FileInputStream( myResource.getFile());

I'm writing this at a friend's house from my laptop, so I can't test it at the moment.  I'll try it out tomorrow when I have some time.  If this doesn't work, I'll see if I can figure out the correct way to do it.

Offline .jayderyu

  • long
  • ***
  • Posts: 116
    • View Profile
Re: How to use ogl on an applet
« Reply #5 on: July 08, 2008, 08:19:37 am »
This is mostly to Paul or anyone who knows how to do ogl in an applet with the appletLoader.

I'm stumped. I use the appletLoader and I get a Fatal Error(7). I tried looking for in on the LWJGL, but am can't seem to find it. Since There is some one here who knows what they are doing in getting JPCT and JWGL working with an applet. How does it work?

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: How to use ogl on an applet
« Reply #6 on: July 15, 2008, 09:15:51 pm »
This is mostly to Paul or anyone who knows how to do ogl in an applet with the appletLoader.

I'm stumped. I use the appletLoader and I get a Fatal Error(7). I tried looking for in on the LWJGL, but am can't seem to find it. Since There is some one here who knows what they are doing in getting JPCT and JWGL working with an applet. How does it work?

Sorry to answer you so late, I was on vacation.  If you still need help with this, here is how I have been using the appletLoader (v 2.0, Beta 1).

NOTE: I have not seen the Fatal Error(7) before, so I don't know if this will help you or not.

You must place the following files (plus your program jar) somewhere online:
Code: [Select]
jpct.jar
lwjgl.jar
lwjgl_util.jar
lzma.jar
windows_natives.jar.lzma
linux_natives.jar.lzma
macosx_natives.jar.lzma
Plus the two loader image files (in this example I am using paulscodelogo.png and paulscodeprogress.gif)

Next you need to create an html file to load the applet.  Here is an example:
Code: [Select]
<html><body>
<applet code="org.lwjgl.util.applet.AppletLoader"
archive="http://www.paulscode.com/source/lwjgl/JARs/lwjgl_util_applet.jar,
http://www.paulscode.com/source/lwjgl/JARs/lzma.jar"
codebase="." width="640" height="480">

<param name="al_title" value="Helicopter">
<param name="al_main" value="Helicopter">
<param name="al_logo" value="http://www.paulscode.com/source/lwjgl/paulscodelogo.png">
<param name="al_progressbar" value="http://www.paulscode.com/source/lwjgl/paulscodeprogress.gif">
<param name="al_jars"
value="http://www.paulscode.com/source/SoundManager/13APR2008/Helicopter.jar,
http://www.paulscode.com/source/jpct/jpct.jar,
http://www.paulscode.com/source/lwjgl/JARs/lwjgl.jar.pack.lzma,
http://www.paulscode.com/source/lwjgl/JARs/jinput.jar.pack.lzma,
http://www.paulscode.com/source/lwjgl/JARs/lwjgl_util.jar.pack.lzma,
http://www.paulscode.com/source/lwjgl/JARs/res.jar.lzma">
<param name="al_windows" value="http://www.paulscode.com/source/lwjgl/JARs/windows_natives.jar.lzma">
<param name="al_linux" value="http://www.paulscode.com/source/lwjgl/JARs/linux_natives.jar.lzma">
<param name="al_mac" value="http://www.paulscode.com/source/lwjgl/JARs/macosx_natives.jar.lzma">

             <!-- Use this to change version so applet won't download every time -->
<!-- <param name="al_version" value="0.5">  -->

<!-- main applet specific params -->
</applet>
</body></html>

Just substitute your own file and class names.

Create a text file named ".htaccess".
If you are running Windows, it will complain, because that is not a valid filename, according to Bill.  You'll have to name it something like ".htaccess.txt", then rename it later after uploading it.

Edit the file you created, with notepad or other text editor.  Add the line:
AddType application/x-lzma .lzma

Save your file, and FTP it to wherever lwjgl_util_applet.jar and lzma.jar are located.  If necessary, rename your file ".htaccess" (remove the ".txt" extension)
Make sure you are allowed to use .htaccess before doing this!  Some of the things that .htaccess is able to do can compromise a server configuration.  For this reason, some web hosting companies may require them to be set up by an admin, so don't get in trouble.  You should CHMOD your .htaccess file to 644 (RW-R--R--) to prevent people from messing with it


That's it.  Let me know if you need any further clarification.

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: How to use ogl on an applet
« Reply #7 on: September 16, 2008, 04:44:47 pm »
And what about using the lwjglInstaller class that cames with the lwjgl API.??? Have anybody use it?
Nada por ahora