Hi:
I’ve used JOGL before on windows. I’ve been programming in something else for a while now and I have passed to a x64 Kubuntu. So I download NetBeans and JOGL from the package manager and then I try to compile Lesson02 from NeHe. Making a couple of changes since the functions I needed to implemente used AutoDrawables and not the Drawables than the lesson had. Anyway the code looks like this:
import java.awt.*;
import java.awt.event.*;
import javax.media.opengl.*;
import javax.media.opengl.glu.GLU;
import javax.media.opengl.GLCanvas;
public class lesson02 {
static class Renderer
implements GLEventListener,
KeyListener
{
/** Called by the drawable to initiate OpenGL rendering by the client.
* After all GLEventListeners have been notified of a display event, the
* drawable will swap its buffers if necessary.
* @param gLDrawable The GLDrawable object.
*/
public void display(GLAutoDrawable gLADrawable)
{
final GL gl = gLADrawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
gl.glTranslatef(-1.5f, 0.0f, -6.0f);
gl.glBegin(GL.GL_TRIANGLES); // Drawing Using Triangles
gl.glVertex3f( 0.0f, 1.0f, 0.0f); // Top
gl.glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
gl.glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
gl.glEnd(); // Finished Drawing The Triangle
gl.glTranslatef(3.0f, 0.0f, 0.0f);
gl.glBegin(GL.GL_QUADS); // Draw A Quad
gl.glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left
gl.glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right
gl.glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
gl.glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
gl.glEnd(); // Done Drawing The Quad
gl.glFlush();
}
/** Called when the display mode has been changed. <B>!! CURRENTLY UNIMPLEMENTED IN JOGL !!</B>
* @param gLDrawable The GLDrawable object.
* @param modeChanged Indicates if the video mode has changed.
* @param deviceChanged Indicates if the video device has changed.
*/
public void displayChanged(GLAutoDrawable gLDrawable, boolean modeChanged, boolean deviceChanged)
{
}
/** Called by the drawable immediately after the OpenGL context is
* initialized for the first time. Can be used to perform one-time OpenGL
* initialization such as setup of lights and display lists.
* @param gLDrawable The GLDrawable object.
*/
public void init(GLAutoDrawable gLDrawable)
{
final GL gl = gLDrawable.getGL();
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl.glShadeModel(GL.GL_FLAT);
gLDrawable.addKeyListener(this);
}
/** Called by the drawable during the first repaint after the component has
* been resized. The client can update the viewport and view volume of the
* window appropriately, for example by a call to
* GL.glViewport(int, int, int, int); note that for convenience the component
* has already called GL.glViewport(int, int, int, int)(x, y, width, height)
* when this method is called, so the client may not have to do anything in
* this method.
* @param gLDrawable The GLDrawable object.
* @param x The X Coordinate of the viewport rectangle.
* @param y The Y coordinate of the viewport rectanble.
* @param width The new width of the window.
* @param height The new height of the window.
*/
public void reshape(GLAutoDrawable gLDrawable, int x, int y, int width, int height)
{
final GL gl = gLDrawable.getGL();
final GLU glu = new GLU();
if (height <= 0) // avoid a divide by zero error!
height = 1;
final float h = (float)width / (float)height;
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(45.0f, h, 1.0, 20.0);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
}
/** Invoked when a key has been pressed.
* See the class description for {@link KeyEvent} for a definition of
* a key pressed event.
* @param e The KeyEvent.
*/
public void keyPressed(KeyEvent e)
{
if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
System.exit(0);
}
/** Invoked when a key has been released.
* See the class description for {@link KeyEvent} for a definition of
* a key released event.
* @param e The KeyEvent.
*/
public void keyReleased(KeyEvent e) {}
/** Invoked when a key has been typed.
* See the class description for {@link KeyEvent} for a definition of
* a key typed event.
* @param e The KeyEvent.
*/
public void keyTyped(KeyEvent e) {}
}
/** Program's main entry point
* @param args command line arguments.
*/
public static void main(String[] args)
{
Frame frame = new Frame("Lesson 2: Your First Polygon");
GLCanvas canvas = new GLCanvas(new GLCapabilities());
canvas.addGLEventListener(new Renderer());
frame.add(canvas);
frame.setSize(640, 480);
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
frame.show();
canvas.requestFocus();
}
}
I have created new libraries (by using the tools -> libraries option to create the library JOGL and I included the path for jogl.jar, jogl-1.1.1.jar, and gluegen-rt-1.1.1,jar ) and added them to the project. However when I compile I get this error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no gluegen-rt in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1698)
at java.lang.Runtime.loadLibrary0(Runtime.java:840)
at java.lang.System.loadLibrary(System.java:1047)
at com.sun.gluegen.runtime.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:102)
at com.sun.gluegen.runtime.NativeLibLoader.access$000(NativeLibLoader.java:51)
at com.sun.gluegen.runtime.NativeLibLoader$1.run(NativeLibLoader.java:70)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.gluegen.runtime.NativeLibLoader.loadGlueGenRT(NativeLibLoader.java:68)
at com.sun.gluegen.runtime.NativeLibrary.ensureNativeLibLoaded(NativeLibrary.java:399)
at com.sun.gluegen.runtime.NativeLibrary.open(NativeLibrary.java:163)
at com.sun.gluegen.runtime.NativeLibrary.open(NativeLibrary.java:129)
at com.sun.opengl.impl.x11.DRIHack.begin(DRIHack.java:109)
at com.sun.opengl.impl.x11.X11GLDrawableFactory.<clinit>(X11GLDrawableFactory.java:99)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at javax.media.opengl.GLDrawableFactory.getFactory(GLDrawableFactory.java:111)
at javax.media.opengl.GLCanvas.chooseGraphicsConfiguration(GLCanvas.java:520)
at javax.media.opengl.GLCanvas.<init>(GLCanvas.java:131)
at javax.media.opengl.GLCanvas.<init>(GLCanvas.java:90)
at lesson02.main(lesson02.java:127)
Java Result: 1
BUILD SUCCESSFUL (total time: 6 seconds)
Can any one tell what I’ve done wrong or how I can fix this problem?
Thank you very much for any help.