How to: Getting started with JOGL

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

I can almost feel your pain :-/

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;

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.

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.

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

That would be:

System.out.println(System.getProperty(“java.library.path”));

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

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
}

I was able to run the example very easly except for actualy knowing how to run it with the required library path :stuck_out_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 ?

Actually, there is :).

java -Djava.library.path=path/to/libraries mypackage.MyClass

Cheers

It doesn’t change anything. I assume the property is read-only.

I don’t quite follow… Read-only, as in it cannot be set from Java code? What are you trying to accomplish? How would you like to alter the library path?

OK never mind. There was a bug in my dos batch file. ;D

It should have been:

@echo off
set CLASSPATH=.;…\libs\jogl.jar;…\libs\joal.jar
set LIBPATH=…\libs
set CMDARGS=-cp %CLASSPATH% -Djava.library.path=%LIBPATH% -server
java ;D %CMDARGS% ;D %1 %2 %3 %4 %5 %6 %7 %8 %9

Hi

The 2004 releases doesn’t seem to include jogl.so files… Are they needed for running applications, and if so, where do I get one?

Hello, I just installed jogl on gentoo linux.
I documented it on my wiki page. Feel free to check it out.
http://wiki.denatus.org/moin.cgi/Documentation/Tips

Hi all!
Can you help to novice in Jogl?
I was trying to compile end run such code:

import net.java.games.jogl.;
import java.awt.
;

public class StartApp {
public static void main (String args[]) {
try {
Frame window = new Frame(“Jogl Demo 1”);
GLCapabilities capab = new GLCapabilities();
GLCanvas context = GLDrawableFactory.getFactory().createGLCanvas(capab);
window.add(context);
window.setSize(300, 300);
window.addWindowListener(new java.awt.event.WindowAdapter()
{
public void windowClosing(java.awt.event.WindowEvent e)
{
System.exit(0);
}
});
window.setVisible(true);

} catch (Exception e) {
  System.out.println(e);
}

}
}

and get an error:

java.lang.UnsatisfiedLinkError: CreateDummyWindow
at net.java.games.jogl.impl.windows.WGL.CreateDummyWindow(Native Method)
at net.java.games.jogl.impl.windows.WindowsGLContextFactory$NativeWindowThread.run(WindowsGLContextFactory.java:266)

Please tell me what is wrong?
I had installed Jogl exactly as described in tutorials, JDK 1.4.2, WinXP, NetBeans 3.6.
So what’s wrong?

Hi, this thread is certainly not the good one to ask this question but…
I think you need to add the .dll (or .so) file to your java.library.path, which can be done in some “expert” tab of Netbeans 3.6 execution properties.

Im using linux
Whatś the problem? and the solution for this error???

Exception in thread “Thread-1” net.java.games.jogl.GLException: java.lang.reflect.InvocationTargetException
at net.java.games.jogl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:225)
at net.java.games.jogl.GLCanvas.display(GLCanvas.java:75)
at net.java.games.jogl.Animator$1.run(Animator.java:107)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.reflect.InvocationTargetException
at java.awt.EventQueue.invokeAndWait(EventQueue.java:851)
at net.java.games.jogl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:220)
… 3 more
Caused by: net.java.games.jogl.GLException: Error making context current
at net.java.games.jogl.impl.x11.X11GLContext.makeCurrent(X11GLContext.java:173)
at net.java.games.jogl.impl.x11.X11OnscreenGLContext.makeCurrent(X11OnscreenGLContext.java:111)
at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:246)
at net.java.games.jogl.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java:258)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

Greetings. As a novice to OpenGL, I humbly come with a bit of confusion in my mind.

The example worked pretty well. Then I went to NeHe’s tutorial and I thought I’d include bits of that in this example, and sure enough, coloured triangles and quads were soon spinning on my window. But not everything went ok.

The three points of this post:

  1. The usual proportion for windows is 4:3 and so is the one proposed in this example, at 512x384. But that kind of flattens the proportions of the objects, so how does one decouple the dimensions of the window from the ones of the drawing space?

2)NeHe uses a glTranslatef(float,float,float) line to translate (duh) stuff on the drawing space, but if I can’t seem to make it work for the Z axis. Take the example in this thread exactly as it is and put a gl.glTranslatef(x,y,z) line before the glcolor. Changes to x and y will show up, but changes to z will be erratic. Between -1.0 and 1.0, it won’t change at all, and any other value will make the triangle disappear. Is this something that requires more than the simple inits performed in this example, or is it something jogl-related?

(ok, I had forgotten the 3rd point)

  1. Have the GL-types been implemented in jogl, or should one use standard java types?

Thanks for your time in advance.

Immano