New to jogl

Hi there,

I read the introduction in the thread “How to: Getting started with JOGL”
and I’d like to know whether it’s useful to use JOGL just
for speeding up my Iso2D-RPG-game.
You may laugh and say: “Do it 3D”
but I really want the Iso Engine with which much more is possible to do
when you’ve got only a 1-Person-Production :wink:
I also like all the little details rather than big triangles that don’t fit into a nice shape
if you understand :-
So here’s the thing, I used Graphics2D and Fullscreenmode so far, but
am not satisfied with the fps, the usual thing I guess ;D
My question at last:
Is it possible to use JOGL instead of Graphics2D to speed up
the rendering-routine and if so,
is it really necessary for people playing my game later on to
install anything beside the JRE ?

I’d really like to learn something new, as of now I’m also not used to OpenGL
itself…
So it this makes sense, please tell me :slight_smile:

You can definitely use JOGL to improve your 2d performance. There is actually a 2d graphics library called slick that’s based off of lwjgl (another opengl binding) that is designed to resemble Graphics2D as closely as possible. I’d recommend starting there. You will have to include the slick code and lwjgl libraries with your game, but it’s not another install, if you know what I mean.

Thanks
that should be what I’m searching for then. :slight_smile:
I understand, you’re saying, that when creating the .jar archive
there’s just some extra code and libraries to include, right ?
That’s what I was hoping, because I really don’t want
people to have to install something else, it could prevent them
from playing the game :’(
So let’s see what Jogl is capable of …

If they had to install something, it’s not that hard to write some code that auto-downloads some files and copies them to the correct folder (you can search for this). If their computer doesn’t have the security like Vista, the users won’t even notice it.

So now it works in one way.
I downloaded jogl, imported it with eclipse
and the testprogram from the thread “How to: Getting started with JOGL”
is running after some changes (f.e. GLAutoDrawable instead of GLDrawable which didn’t exist
in the actual build I downloaded…).
I can the see triangle :wink:
My problem now is, I can run the testprogram from eclipse, but my usual .bat-file
isn’t working.

The .bat-file looks like this:


SET CLASSPATH=.
java -Xmx1024m Test

and the errormessage I get is:


Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/opengl/GL
Canvas
Caused by: java.lang.ClassNotFoundException: javax.media.opengl.GLCanvas
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: Test.  Program will exit.

I put the jogl.jar with its libraries into a subfolder of my Test-project directory.
Eclipse is satisfied with this, there are no errormessages.
What can I do ?

JGame might be interesting too for your purposes.

When adding a jar to your classpath, you need to point to it directly, so besides ‘.’ you’d need to add ‘./folder1/2/jogl.jar’. Also you’ll need to set the native library path so that jogl.dll, etc. can be found.

In case of my example:


SET CLASSPATH=.
java -Xmx1024m Test

how would I add something to the CLASSPATH ?
I’m really not used to this, so I need some help there…
What is the difference with the native library path?
How can I set this one in my .bat-file as well ?

The classpath will be multiple directories and jar files separated by a semi-colon or colon (I believe windows likes the semi-colon, mac/unix like the colon). Instead of setting an environment variable, you should use the -classpath commandline argument to java to set it.

Jogl requires some native code to handle the graphics, so you have to set the java.library.path so that jogl will discover its native libraries.
Here is what you’ll want to run, it should just be one line:


java -Djava.library.path=./lib -classpath .;lib/jogl.jar;lib/gluegen-rt.jar -Xmx1024m Test

The above assumes that you have a folder named ‘lib’ in your working directory that contains jogl.jar, gluegen-rt.jar, jogl.dll etc (all the parts needed for jogl to work).

And remember, google is your friend :slight_smile:

Thank you again :slight_smile:
This worked and as you assumed, I have all the stuff in
a subdirectory called ‘lib’.
Just as I want it, so I can share the game with anybody
interested without having them install anything beside JRE,
which of course everbody should have on their pc :wink:
I know google and I already looked it up how to
separate classpath entries, but with


SET CLASSPATH=.....

it just led to java not finding my starterclass anymore :-
Your suggestion seems to me better anyway, so
I’ll use my .bat-files this way in the future.

Now I can really start with the fun stuff of JOGL.
I’m really curious how much JOGL improves my fps.
I already have a little testprogram for
some “weathereffects” like rain, snow, mist, earthquakes, light and dark etc.
But when activating all of it at the same time with heavy rain/snow/mist
my fps drop to ~20.
I’ll write again, when I have the results with JOGL.

Here goes… :smiley:


Done !!!
I tried out slick as you mentioned in your first post,
set it up with the classpath entries and libraries
and changed my effecttester.
It’s now using slick and the fps is around 50 with
double the amount of raindrops and snow 8)
Also the timer in slick seems to be really thought out.
If I had known this earlier…
I have a strategygame with Graphics2D as “engine”
and did (performance tuning)³ to achieve 23 fps
from 5 fps at the beginning.
It was a really long way there, but
for some nice weathereffects a better engine would help.
I learned much by changing every single detail
to give better performance,
but I guess with slick now
I can use a sledge-hammer to crack nuts ;D