Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (483)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (550)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2 3 ... 5
  ignore  |  Print  
  How to: Getting started with JOGL  (Read 149817 times)
0 Members and 1 Guest are viewing this topic.
Offline gregorypierce

Senior Member




I come upon thee like the blue screen of death....


« Posted 2003-07-12 14:39:51 »

Getting up and running with JOGL  JOGL is Sun's open sourced OpenGL binding for Java. It is actively supported by many developers with Sun's newly established Java Gaming Group. With JOGL it is possible to finally be able to create (API supported) OpenGL games in Java. The only credible competing API is the LWJGL (Lightweight Java Game Library) which strives to be the Java gaming equivalent of DirectX.  

Both libraries utilize a hefty amount of native code, but where LWJGL seeks to be a complete gaming solution - the Sun APIs (JOGL, JOAL, and JInput) allow you to mix and match what you need to create your solution. In addition, JOGL integrates cleanly with AWT and Swing components whereas LWJGL creates its own native window - defying any attempts to integrate it with a Java application.


This article deals specifically with getting JOGL installed on your machine and getting it to render a single cheesy triangle. As you will shortly discover, this takes little effort (unless you are unfamiliar with the OpenGL APIs). The first step required is to obtain the binaries that you will need in order to compile and run your applications. These pre-compiled binaries can be obtained from the project website file sharing area Project Files. Download the binaries for your platform (currently there are binaries available for OSX (Panther DP or greater), Linux, Solaris, and Windows. This pretty much covers all of the major platforms so I doubt you'll find yourself trying to compile the library yourself.


Now that you have the binaries you will note that you hava a .jar file and a JNI library (.dll, .so, .jnilib). You will need to install the jogl.jar file in the classpath of your build environment in order to be able to compile an application with JOGL. Since many people these days are using IDEs like Eclipse, JBuilder, and IntelliJ - it is fairly straightforward to add the .jar file to your build. Follow the instructions for your specific build environment.


Next comes the slightly trickier part, the installation of the native library. You won't need this in order to compile your application, but you will need it in order to run your application. Java developers usually don't find themselves installing native libraries (for obvious reasons) so it usually escapes us as to how its done. Java loads native libraries from the directories listed in the java.library.path environment variable. Best to just print this out and put the native library into one of these directories. One of these directories is likely to be the extension (ext) directory of the JRE for your IDE. Unless you only want to run the application from inside the IDE, don't install it here.


You can confirm this by creating a test program that does System.loadLibrary("jogl");. If the application throws an UnsatisfiedLinkException, the JRE running your application cannot find the native library. This isn't too likely if you've installed it in one of the directories listed in java.library.path, but just in case - try again Smiley

Now that you have JOGL installed, you want to feed cool L33t geometry to your video card and have it do cool stuff. Well at the moment I want to feed myself so I tell you about that. Coming up next - actually understanding the API enough to be able to get something on the screen!


http://www.gregorypierce.com

She builds, she builds oh man
When she links, she links I go crazy
Cause she looks like good code but she's really a hack
I think I'll run upstairs and grab a snack!
Offline gregorypierce

Senior Member




I come upon thee like the blue screen of death....


« Reply #1 - Posted 2003-07-12 15:15:24 »

Okay, no food that doesn't require cooking so I will press forward and cover as much as I can until I pass out from starvation  Wink

You will build your JOGL application much the same as you build any other AWT application (for now):

1  
2  
            Frame testFrame = new Frame("TestFrame");
            testFrame.setSize( 512, 384 );


Note here that I am creating a frame and giving that frame a size. Since at the moment I don't plan to have any extra stuff in that frame other than the rendered component this is fine and I won't worry about a layoutmanager.

The next thing you need is a warm piece of GLCanvas to draw on. Since you cannot directly instantiate GLCanvas (which is good OO design) you must obtain it from the factory that creates them. This is GLDrawableFactory. We will tell this factory that we want it to create and return to us a GLCanvas with a default set of capabilities.

1  
            GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas( new GLCapabilities() );


The capabilities that you want a GLCanvas to have are specified in GLCapabilities. So if you want something with specific buffers, bitdepths, etc, you would create a GLCapabilities() object that has those capabilities and pass that into the factory as so:

1  
2  
3  
4  
5  
6  
7  
            GLCapabilities glCaps = new GLCapabilities();
            glCaps.setRedBits(8);
            glCaps.setBlueBits(8);
            glCaps.setGreenBits(8);
            glCaps.setAlphaBits(8);
            
            GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas( glCaps );


There is a lot of stuff you can do with GLCapabilities but I'm not going to cover that here - explore and experiment.

Now that you have your GLCanvas done you need to add it to the Frame so that people will be able to see it.

1  
            testFrame.add( canvas );


So now you have a GLCanvas on a Frame and when that frame comes up it will do.... nothing  Grin The reason it won't do anything is because of the architecture of JOGL. JOGL will emit a series of events that will tell you what's going on with the framework so that you can listen for those events and do the right thing. JOGL refers to this as a GLEventListener. The GLEventListener contains the methods that we're most interested in: init(), display(), reshape(), and displayChanged().

When the GLCanvas (which is a GLDrawable) is rendered for the first time, init(GLDrawable) is called. In this method you would do the same thing you would do in an init call to your old OpenGL engines. Set up any initial settings and get yourself ready to draw. If you aren't following the JOGL architecture properly, you may be able to hack some drawing into this method but DO NOT do this. You will make your life harder later. Load textures, geometry, etc here, but don't start trying to render anything in this method.

1  
2  
3  
4  
5  
6  
7  
8  
9  
    public void init(GLDrawable drawable)
    {
        this.gl = drawable.getGL();
        this.glDrawable = drawable;

        drawable.setGL( new DebugGL(drawable.getGL() ));

        System.out.println("Init GL is " + gl.getClass().getName());
    }


When a GLDrawable is told to render, this method is called. Note that this is a good way to decouple the rendering interface from any sort of frame rate limiter or timing system. Anyways, THIS is the method where you want to do your drawing.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
    public void display(GLDrawable drawable)
    {
        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );
        gl.glLoadIdentity();

        gl.glColor3f(1.0f, 0.0f, 0.0f );

        gl.glBegin( GL.GL_TRIANGLES );
            gl.glVertex3f( 0.0f, 0.0f, 0.0f );
            gl.glVertex3f( 1.0f, 0.0f, 0.0f );
            gl.glVertex3f( 1.0f, 1.0f, 0.0f );
        gl.glEnd();
    }


There has been some question as to whether or not one should reacquire gl in the display method. I have as of yet found it unnecessary to do this and I'm not sure why its recommended as the GLDrawable should not be destroyed at any point during rendering and as such should be cacheable as should GL and GLU.

The next method of interest is reshape(). Just like with GLUT, reshape is called when your context changes shape. Its useful to make camera adjustments and the like when this occurs in this method. Since I currently don't support these operations this method is undefined:

1  
2  
3  
    public void reshape(GLDrawable drawable, int x, int y, int width, int height)
    {
    }


The same can be said of display changed. If the device or display mode changes, JOGL will let you know so you can handle your rendering accordingly.

1  
2  
3  
    public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged)
    {
    }


So now you have the code for what I refer to at the TestRenderer, but you can call it whatever you want so long as it implements GLEventListener.

Now that you have a GLEventListener lo and behold you application renders... nothing still  Grin The reason is again in the JOGL architecture. Recall that the display method needs to be called before anything gets drawn to the screen. Well - you don't have anything calling display(). You COULD throw in a while loop that spun forever calling display(), but there is really a better way. JOGL includes the concept of an Animator. This animator basically holds the tempo of when display gets called. Personally I think RenderLoop might have been a better name, but hey you can extend it and call it whatever you want right  Wink

To make a long story short you need to add an Animator so that display is getting called. For this tutorial I will use the one provided for by JOGL, though one that handles frame rates properly is likely going to make a LOT more sense for anything running in a Window. No sense having JOGL running in a window yet taking up so much CPU that nothing else can really run either. The last chunk of code that you need is

1  
2  
3  
4  
5  
6  
7  
8  
9  
            final Animator animator = new Animator(canvas);
            testFrame.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                  animator.stop();
                  System.exit(0);
                }
              });
            testFrame.show();
            animator.start();


There you have it. Go ahead and compile/run and you will have one cheesy triangle. The world is now yours to control because if you can draw one triangle, you can draw millions of triangles in 3D space with textures and stuff and have a real game. At this point you might want to take a look at some OpenGL resources as it won't matter whether or not you're coding in C++ or Java as OpenGL is OpenGL and it will be simple to tell what needs to be syntactically changed to work with JOGL (or LWJGL for that matter).

http://www.gregorypierce.com

She builds, she builds oh man
When she links, she links I go crazy
Cause she looks like good code but she's really a hack
I think I'll run upstairs and grab a snack!
Offline gregorypierce

Senior Member




I come upon thee like the blue screen of death....


« Reply #2 - Posted 2003-07-12 15:27:26 »

Test.java

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
import net.java.games.jogl.*;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class Test
{
    public static void main( String[] args )
    {
        try
        {
            Frame testFrame = new Frame("TestFrame");
            testFrame.setSize( 512, 384 );

            GLCapabilities glCaps = new GLCapabilities();
            glCaps.setRedBits(8);
            glCaps.setBlueBits(8);
            glCaps.setGreenBits(8);
            glCaps.setAlphaBits(8);

            GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas( glCaps );

            testFrame.add( canvas );

            canvas.addGLEventListener(new TestRenderer());

            final Animator animator = new Animator( canvas);
            testFrame.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                  animator.stop();
                  System.exit(0);
                }
              });
            testFrame.show();
            animator.start();
        }
        catch( Exception e )
        {
            e.printStackTrace();
        }
    }
}


TestRenderer.java

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
import net.java.games.jogl.GLEventListener;
import net.java.games.jogl.GL;
import net.java.games.jogl.GLDrawable;
import net.java.games.jogl.DebugGL;


public class TestRenderer implements GLEventListener
{
    private GL              gl;
    private GLDrawable      glDrawable;

    public void init(GLDrawable drawable)
    {
        this.gl = drawable.getGL();
        this.glDrawable = drawable;

        drawable.setGL( new DebugGL(drawable.getGL() ));

        System.out.println("Init GL is " + gl.getClass().getName());
    }

    public void display(GLDrawable drawable)
    {
        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );
        gl.glLoadIdentity();

        gl.glColor3f(1.0f, 0.0f, 0.0f );

        gl.glBegin( GL.GL_TRIANGLES );
            gl.glVertex3f( 0.0f, 0.0f, 0.0f );
            gl.glVertex3f( 1.0f, 0.0f, 0.0f );
            gl.glVertex3f( 1.0f, 1.0f, 0.0f );
        gl.glEnd();
    }

    public void reshape(GLDrawable drawable, int x, int y, int width, int height)
    {
    }

    public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged)
    {
    }

}

http://www.gregorypierce.com

She builds, she builds oh man
When she links, she links I go crazy
Cause she looks like good code but she's really a hack
I think I'll run upstairs and grab a snack!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline DavidYazel

Junior Member




Java games rock!


« Reply #3 - Posted 2003-07-12 18:47:38 »

Thank you, that was a nice introduction!

David Yazel
Xith3D Project Founder
http://xith3d.dev.java.net

It may look complicated, but in the end it is just a bunch of triangles
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #4 - Posted 2003-07-13 00:28:57 »

Yes, thanks!  That was excellent.  Perhaps it should be placed in the Wiki so that when this thread is long lost this info is still easy to find.

Archimedes
Guest
« Reply #5 - Posted 2003-07-13 04:43:07 »

A very nice introduction. Simple and robust; so it should be with Java all day. :-)
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #6 - Posted 2003-07-14 09:26:06 »

Thanks for writing this introduction. Do you have it in HTML form? Let's check it in under the doc/ subdirectory of the jogl project.
Offline gregorypierce

Senior Member




I come upon thee like the blue screen of death....


« Reply #7 - Posted 2003-07-14 15:07:53 »

Not yet, but I'll convert it into an HTML form and email it to you. I'm going to continue on by adding some stuff on getting a textured triangle since there is some VERY understandable weirdness and confusion about loading textures and doing some basic input (not using JInput until I get finished with learning Cocoa to handle input for OSX).

http://www.gregorypierce.com

She builds, she builds oh man
When she links, she links I go crazy
Cause she looks like good code but she's really a hack
I think I'll run upstairs and grab a snack!
Offline Markus_Persson

JGO Wizard


Medals: 14
Projects: 19


Mojang Specifications


« Reply #8 - Posted 2003-07-23 17:25:31 »

Has anyone gotten this to run on linux?

I was trying to figure out why Wurm was having trouble on linux, so got rid of everything but the example here and uploaded it.
The Guy(tm) who's running linux (I'm not) gets this:

net.java.games.jogl.GLException: Error making context current
at net.java.games.jogl.impl.x11.X11GLContext.makeCurrent(X11GLContext.java:141)
at net.java.games.jogl.impl.x11.X11OnscreenGLContext.makeCurrent(X11OnscreenGLContext.java:111)
at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:162)
at net.java.games.jogl.GLCanvas.displayImpl(GLCanvas.java:196)
at net.java.games.jogl.GLCanvas.display(GLCanvas.java:91)
at net.java.games.jogl.Animator$1.run(Animator.java:104)
at java.lang.Thread.run(Thread.java:536)

Play Minecraft!
Offline gregorypierce

Senior Member




I come upon thee like the blue screen of death....


« Reply #9 - Posted 2003-07-23 19:06:02 »

I'll fire up RedHat 9 tonight and see what i can find in terms of running general applications. I haven't had any problems with Linux in the past so it would be surprising to find something now.

http://www.gregorypierce.com

She builds, she builds oh man
When she links, she links I go crazy
Cause she looks like good code but she's really a hack
I think I'll run upstairs and grab a snack!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline nlmueng

Junior Member





« Reply #10 - Posted 2003-07-23 20:37:03 »

You need to change the GLCapabilities part.  If you just switch it to say new GLCapabilities() instead of creating a defined one it works fine.  I think it has something to do with being 32 bit.

Nathan
Offline AndersDahlberg

Junior Member





« Reply #11 - Posted 2003-07-23 20:49:12 »

I'm "the guy(tm)" Grin

Strange thing is, the jogl demos works fine (i.e. gears)!
Offline AndersDahlberg

Junior Member





« Reply #12 - Posted 2003-07-23 20:55:36 »

1  
2  
You need to change the GLCapabilities part.  If you just switch it to say new GLCapabilities() instead of creating a defined one it works fine.  I think it has something to do with being 32 bit.
 


That actually makes sense, that it tries to switch bpp. That was my first thought Sad

http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=Announcements;action=display;message=10;thread=1058284789

Maybe that's not the problem though?

And if it is - could the error message include some more information (i.e. "couldn't switch to 32bpp"?)
Offline gregorypierce

Senior Member




I come upon thee like the blue screen of death....


« Reply #13 - Posted 2003-07-23 23:03:31 »

I am able to on RedHat 9 using the latest NVidia drivers on a GeForce 4200 able to get that GLCapabilities() to work. Not sure why yours wouldn't. You should have enough video memory for that to work unless you're requesting an incredibly large GLContext, or potentially something that's non-square'd, though that's rarely an issue these days.

http://www.gregorypierce.com

She builds, she builds oh man
When she links, she links I go crazy
Cause she looks like good code but she's really a hack
I think I'll run upstairs and grab a snack!
Offline nlmueng

Junior Member





« Reply #14 - Posted 2003-07-23 23:37:45 »

it fails on my box too if I leave it that way.  When I just did it like new GLCapabilities() it works.

I only have the 810 onboard video in the box.

nathan
Offline Markus_Persson

JGO Wizard


Medals: 14
Projects: 19


Mojang Specifications


« Reply #15 - Posted 2003-07-24 11:10:12 »

Quote
I'm "the guy(tm)" Grin


Actually, you're not. The other Guy(tm) I talked about in the wurm thread started getting the same error as you did..


Anyway, I'll try this. Thanks, all. =D

Play Minecraft!
Offline AndersDahlberg

Junior Member





« Reply #16 - Posted 2003-07-24 11:34:50 »

*sob* I'm not the guy(tm) *sob*  Embarrassed

Well, I guess I'll get over it some day in the distant future  Grin
Offline Markus_Persson

JGO Wizard


Medals: 14
Projects: 19


Mojang Specifications


« Reply #17 - Posted 2003-07-24 11:35:35 »

You can be The Man(tm), if you want to.  Grin

Now go test if wurm works for you. Wink

Play Minecraft!
Offline AndersDahlberg

Junior Member





« Reply #18 - Posted 2003-07-24 13:08:32 »

<background music: twilight zone theme/>
muahahaha Smiley
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
Java Web Start 1.4.2 Konsol, startades Thu Jul 24 17:04:59 CEST 2003
Java 2 Runtime Environment: Version 1.4.2 av Sun Microsystems Inc.
Loggar till filen: /home/anders/log.txt
net.java.games.jogl.GLException: Error making context current
        at net.java.games.jogl.impl.x11.X11GLContext.makeCurrent(X11GLContext.java:141)
        at net.java.games.jogl.impl.x11.X11OnscreenGLContext.makeCurrent(X11OnscreenGLContext.java:111)
        at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:162)
        at net.java.games.jogl.GLCanvas.displayImpl(GLCanvas.java:196)
        at net.java.games.jogl.GLCanvas.display(GLCanvas.java:91)
        at com.wurmonline.client.WurmClient$4.run(WurmClient.java:565)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
Offline Markus_Persson

JGO Wizard


Medals: 14
Projects: 19


Mojang Specifications


« Reply #19 - Posted 2003-07-24 13:14:33 »

So now it works for the Guy(tm), but not the Man(tm).

Excuse me, I'll go kill myself now..

Play Minecraft!
Offline Markus_Persson

JGO Wizard


Medals: 14
Projects: 19


Mojang Specifications


« Reply #20 - Posted 2003-07-24 13:16:26 »

Btw, I'm back to using the AWT dispatch thread instead of an Animator, since wurm just hung for the Guy(tm) if any thread but the awt dispatch tread tried to perform any opengl commands.

Play Minecraft!
Offline AndersDahlberg

Junior Member





« Reply #21 - Posted 2003-07-24 13:19:12 »

I can almost feel your pain  :-/

Offline jujumen

Senior Newbie




java is the juju within.....


« Reply #22 - Posted 2003-07-31 23:00:41 »

people another novice here!

winxp Hed p4 2.6ghz nvidiagf4
jbuilder9 personal j2sdk1.4.

now where do i install the
1 jogl.jar
2 jogl.dll
3 jogl_cg.dll
4 ant 1.5
5 antlr 2.72
then how do i run the demos from jbuilder or cant i? i tried following the instructions here but i got lost;

From the land beyond beyond........
across all hope and fear........
i bid you JAVA do appear.
Offline liberte

Innocent Bystander




Java games rock!


« Reply #23 - Posted 2004-09-06 01:37:16 »

I am just adding a reply to this thread to bump it to the top. It took me over an hour to find this thread, and it appears to be the best intro to using jogl still.  If there is something better, please point it out.

Better yet, please add docs to the JOGL home page.  It appears JOGL is ready for more than hard-core java developers to start using it, folks such as myself who just want to dive in to using in without much fooling around.   But without docs, getting started becomes an adventure on its own.  I'd rather spend the time more productively.

Thanks for your work.   It is much appreciated.
Offline Mithrandir

Senior Member




Cut from being on the bleeding edge too long


« Reply #24 - Posted 2004-09-06 05:21:31 »

There are several external sites actively putting together collections of JOGL tutorials right now.  Expect to see intro threads for them appearing here in the next couple of weeks.

The site for 3D Graphics information http://www.j3d.org/
Aviatrix3D JOGL Scenegraph http://aviatrix3d.j3d.org/
Programming is essentially a markup language surrounding mathematical formulae and thus, should not be patentable.
Offline sparklight

Junior Newbie




Java games rock!


« Reply #25 - Posted 2004-09-15 09:28:22 »

Please help a newbie out.  You said:

Java loads native libraries from the directories listed in the java.library.path environment variable. Best to just print this out and put the native library into one of these directories.

I tried:

System.out.println(java.library.path);

I got:

Error   : Undefined variable, class, or package name: java
Hello1.java line 15      System.out.println(java.library.path);

What was I really supposed to do?

running CodeWarrior Learning Edition 4, macosx 10.3.5
Offline nnevatie

Junior Member




It is slightly better to be simple than correct.


« Reply #26 - Posted 2004-09-15 09:49:31 »

That would be:

System.out.println(System.getProperty("java.library.path"));

Awards:
- Nobel Prize in Physics for inventing his Doomsday Machine
- Nobel Peace Prize for not using it

http://www.g0dmode.com -- a collection of things not real
Offline shinsato

Junior Newbie




Java games rock!


« Reply #27 - Posted 2004-09-27 22:21:11 »

I've tried calling System.loadLibrary("jogl");

I get an UnsatisfiedLinkError:
C:\myjavalibs\jogl.dll: Can't find dependent libraries

This happens, even though C:\myjavalibs\jogl.dll exists, and in fact JOGL works without this call, but I need to know whether or not the needed JOGL native libraries are available before I start calling the JOGL API's.

Is there a JOGL API call I can make to see if the JOGL library is available?

      Thanks,
      Harold


Offline shinsato

Junior Newbie




Java games rock!


« Reply #28 - Posted 2004-09-27 23:10:05 »

Not to be talking to myself, but I found an answer that seems to work, rather than System.loadLibrary (pardon the awkward formatting, this bb seems to format the code for me):

static {
   try {

       GLCapabilities gLCapabilities = new GLCapabilities();
       (GLDrawableFactory.getFactory()).createGLCanvas(gLCapabilities);

       // do stuff that indicates that JOGL is available

   } catch (NoClassDefFoundError err) {

       // do stuff that indicates that JOGL isn't available

   } catch (UnsatisfiedLinkError err) {

       // do stuff that indicates that JOGL isn't available
   }
Offline zingbat

Senior Member




Java games rock!


« Reply #29 - Posted 2004-09-28 07:39:10 »

I was able to run the example very easly except for actualy knowing how to run it with the required library path Tongue .

Its a very simple and direct example. I hope youre not thinking on expanding the example. Its the simplicity of it that makes it useful.

There is just one little thing i would like to see on it: an explanation of the most simple way to run and compile the example.

I have created a directory to run the example "jogl_test" and two subdirs "libs" (containing jogl.jar, jogl.dll and jogl_cg.dll) and "src".

In src i created the file "test1.java" with the example and created two batch files:

compile.bat

@echo off
set CLASSPATH=.;..\libs\jogl.jar;..\libs\joal.jar
set CMDARGS=-cp %CLASSPATH%
javac %ARGS% %1 %2 %3 %4 %5 %6 %7 %8 %9

and run.bat

@echo off
set CLASSPATH=.;..\libs\jogl.jar;..\libs\joal.jar
set PATH=.;..\libs;%PATH%
set CMDARGS=-cp %CLASSPATH% -server
java %ARGS% %1 %2 %3 %4 %5 %6 %7 %8 %9

At first i was trying to use -Djava.library.path=..\libs but it doesn't work. Apparently that property is read-only and i couldn't find it documented anywhere it is so.

Damn it, isn't there a way to set the java.library.path without messing with windows environment variables ?
Pages: [1] 2 3 ... 5
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CopyableCougar4 (18 views)
2014-08-22 19:31:30

atombrot (28 views)
2014-08-19 09:29:53

Tekkerue (25 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (15 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (63 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (38 views)
2014-08-06 19:49:38
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!