Skip to main content
gamedev.net
🔒 Locked

[java] Installing JOGL

Started by temp_ie_cant_thinkof_name Oct 9, 2004 at 3:49 AM 4 replies 1.4k views
Original Post
temp_ie_cant_thinkof_name
temp_ie_cant_thinkof_name
Edit: new problems... I don't need to edit the environment variables. I have my jogl.dll in my C:\jdk1.5.0\jre\bin. I now know this is the default path to java.library.path; however, when i make my own system env variable called java.library.path, and set it to C:\Program Files\Java\jre1.5.0\bin, and put jogl.dll there, it can't be found by java.exe (which is in c:\jdk1.5.0\bin). Why is this? I tried making my own CLASSPATH variable, but I predict that will fail too and i'll end up having to do -classpath c:\jdk1.5.0\jre\lib\ext every time I want to compile a jogl app. What should I do about this? What directory is the "default" classpath? Am I right in puting jogl.jar in c:\jdk1.5.0\jre\lib\ext? I'll probably find out soon enough, but I just want to heare peoples' thoughts on that. I am satisfied with having my sdk directory hold my libraries, but there's something else... I got the run-time linking errors again spit out by java.exe when i'm running JoglTest.class (which basically just does a System.loadLibrary("jogl")). A message box pops up saying cannot load jawt.dll dependency [for jogl.dll]. That is, jogl.dll imports from jawt.dll which is another library that java.exe must find. Now, you'd think that having jawt.dll and jogl.dll in the same directory (where jawt.dll resides in the sdk)--c:\jdk1.5.0\jre\bin--would be alright, but for some reason I get that link error. Now, being intuitive as I am I said 'I remember reading that windows searches for .dlls starting with the current directory and working all the way to c:\windows\system32 (where you can usually find any installed .dll). So, shocked as to why jawt.dll couldn't be found in the same directory jogl.dll was in, I went ahead and copied jawt.dll into system32 folder. What happens again? -- another link error, but this time if you read carefully it says awt.dll, not jawt.dll. So one would assume jawt.dll depends on awt.dll (sort of like swing depends on awt), so being intuitive again I copied awt.dll into system32. Ta-da! It finally works -- no link errors. Okay, now that I can actually load a library from my erm... library path, I can continue learning the jogl api. But it still bugs me that I had to put jawt.dll and awt.dll that were in c:\jdk1.5.0\jre\bin in system32 in order for jogl.dll which is also in c:\jdk1.5.0\jre\bin to be loaded. Any takers? [Edited by - temp_ie_cant_thinkof_name on October 9, 2004 5:35:03 AM]
"I study differential and integral calculus in my spare time." -- Karl Marx
temp_ie_cant_thinkof_name
temp_ie_cant_thinkof_name
Thanks for the suggestion. What's the difference btw javaw.exe and java.exe? Can't I just set my path variable in windows so I won't need a batch file? Why are two things set in your batch file (path AND library.path)? Is it just-in-case?
"I study differential and integral calculus in my spare time." -- Karl Marx
temp_ie_cant_thinkof_name
temp_ie_cant_thinkof_name
I'm having problems with the following pieces of code:
// Example1.javaimport java.awt.*;import net.java.games.jogl.*;public class Example1 extends Frame implements GLEventListener{	static int HEIGHT = 400, WIDTH = 400;	static GL gl; // interface to OpenGL	static GLCanvas canvas; // drawable in a frame	public Example1()	{		// 1. specify a drawable: canvas		GLCapabilities caps = new GLCapabilities();		canvas = GLDrawableFactory.getFactory().createGLCanvas(caps);		// 2. listen to the events related to canvas: reshape		canvas.addGLEventListener(this);		// 3. add the canvas to fill the Frame container		add(canvas, BorderLayout.CENTER);		// 4. interface to OpenGL functions		gl = canvas.getGL();	}	public static void main(String[] args)	{		Example1 frame = new Example1();		// 5. set the size of the frame andmake it visible		frame.setSize(WIDTH, HEIGHT);		frame.setVisible(true);	}	// Called once for OpenGL initialization	public void init(GLDrawable drawable)	{		// 6. specify a drawing color: red		gl.glColor3f(1.0f, 0.0f, 0.0f);	}	// Called for handling reshaped drawing area	public void reshape(		GLDrawable drawable,		int x,		int y,		int width,		int height)	{		// 7. specify the drawing area (frame) coordinates		gl.glMatrixMode(GL.GL_PROJECTION);		gl.glLoadIdentity();		gl.glOrtho(0, width, 0, height, -1.0, 1.0);	}	// Called for OpenGL rendering every reshape	public void display(GLDrawable drawable)	{		// 8. specify to draw a point		gl.glBegin(GL.GL_POINTS);			gl.glVertex2i(WIDTH/2, HEIGHT/2);		gl.glEnd();	}	// Called if display mode or device are changed	public void displayChanged(		GLDrawable drawable,		boolean modeChanged,		boolean deviceChanged)	{	}}


//Example2.java import net.java.games.jogl.*;import java.awt.*;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;public class Example2{    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(); // deprecated!!            testFrame.setVisible(true);            animator.start();        }        catch( Exception e )        {            e.printStackTrace();        }    }}//TestRenderer.javaimport 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)    {    }}


Screenshot of example 1:

Console output of example 1:
Using ATI workaround of dispatching display() on event thread
Using ATI workaround of dispatching display() on event thread

Screenshot of example 2:

Console output of example 2:
Using ATI workaround of dispatching display() on event thread
Using ATI workaround of dispatching display() on event thread
Init GL is net.java.games.jogl.impl.windows.WindowsGLImpl

Explanation: At first (the first time I ran example 1) there would be only dithered-looking, checkerboard "fuzz" on the screen (ie no red), but I'm too lazy to shrink the image to upload it. Then, the second and other times I ran example 1, i'd get left overs of example 2 with a little distortion, so that's what you see of example 1. Example 2 seems to run just fine. What should I do?
"I study differential and integral calculus in my spare time." -- Karl Marx
temp_ie_cant_thinkof_name
temp_ie_cant_thinkof_name
Right now i'm comparing example 1 to example 2, the explicit setting of glCaps (ie glCaps.alphaBits(8), etc) didn't make a difference, so I guess the default is 8 bits on each channel (RGBA), still go the wierd display. And is the "Using ATI workaround" anything to worry about? Because if it's referring to the software renderer b/c of lack of support, that would suck, b/c there would be no point for me to use opengl. I'm on a laptop btw.
"I study differential and integral calculus in my spare time." -- Karl Marx
temp_ie_cant_thinkof_name
temp_ie_cant_thinkof_name
Okay, this line fixed it (duh):
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
Just have one more question:
Is
final Animator animator = new Animator( canvas);
testFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
animator.stop();
System.exit(0);
}
});
equivalent to JFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)? Are there any caveats before I use JFrame and Swing instead of Frame? (edit:) ie, does JOGL bind OpenGL to JFrame with as much support as it does with binding to Frame?
"I study differential and integral calculus in my spare time." -- Karl Marx

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.