Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (481)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (548)
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 [4] 5
  ignore  |  Print  
  How to: Getting started with JOGL  (Read 149781 times)
0 Members and 1 Guest are viewing this topic.
Offline mr_incredible

Junior Newbie





« Reply #90 - Posted 2008-04-03 15:21:36 »

This example is terribly out of date. There is no longer a

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

call.
Offline cylab

JGO Ninja


Medals: 43



« Reply #91 - Posted 2008-04-16 20:10:02 »

Here is a working example:

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  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
package org.yourorghere;

import com.sun.opengl.util.Animator;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;



/**
 * SimpleJOGL.java <BR>
 * author: Brian Paul (converted to Java by Ron Cemer and Sven Goethel) <P>
 *
 * This version is equal to Brian Paul's version 1.2 1999/10/21
 */

public class SimpleJOGL implements GLEventListener {

    public static void main(String[] args) {
        Frame frame = new Frame("Simple JOGL Application");
        GLCanvas canvas = new GLCanvas();

        canvas.addGLEventListener(new SimpleJOGL());
        frame.add(canvas);
        frame.setSize(640, 480);
        final Animator animator = new Animator(canvas);
        frame.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                // Run this on another thread than the AWT event queue to
               // make sure the call to Animator.stop() completes before
               // exiting
               new Thread(new Runnable() {

                    public void run() {
                        animator.stop();
                        System.exit(0);
                    }
                }).start();
            }
        });
        // Center frame
       frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        animator.start();
    }

    public void init(GLAutoDrawable drawable) {
        // Use debug pipeline
       // drawable.setGL(new DebugGL(drawable.getGL()));

        GL gl = drawable.getGL();
        System.err.println("INIT GL IS: " + gl.getClass().getName());

        // Enable VSync
       gl.setSwapInterval(1);

        // Setup the drawing area and shading mode
       gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        gl.glShadeModel(GL.GL_SMOOTH); // try setting this to GL_FLAT and see what happens.
   }

    public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
        GL gl = drawable.getGL();
        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();
    }

    public void display(GLAutoDrawable drawable) {
        GL gl = drawable.getGL();

        // Clear the drawing area
       gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
        // Reset the current matrix to the "identity"
       gl.glLoadIdentity();

        // Move the "drawing cursor" around
       gl.glTranslatef(-1.5f, 0.0f, -6.0f);

        // Drawing Using Triangles
       gl.glBegin(GL.GL_TRIANGLES);
            gl.glColor3f(1.0f, 0.0f, 0.0f);    // Set the current drawing color to red
           gl.glVertex3f(0.0f, 1.0f, 0.0f);   // Top
           gl.glColor3f(0.0f, 1.0f, 0.0f);    // Set the current drawing color to green
           gl.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
           gl.glColor3f(0.0f, 0.0f, 1.0f);    // Set the current drawing color to blue
           gl.glVertex3f(1.0f, -1.0f, 0.0f);  // Bottom Right
       // Finished Drawing The Triangle
       gl.glEnd();

        // Move the "drawing cursor" to another position
       gl.glTranslatef(3.0f, 0.0f, 0.0f);
        // Draw A Quad
       gl.glBegin(GL.GL_QUADS);
            gl.glColor3f(0.5f, 0.5f, 1.0f);    // Set the current drawing color to light blue
           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
       // Done Drawing The Quad
       gl.glEnd();

        // Flush all drawing operations to the graphics card
       gl.glFlush();
    }

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

Mathias - I Know What [you] Did Last Summer!
Offline Trussell

Junior Member




Game Developer


« Reply #92 - Posted 2008-04-26 21:36:54 »

When I try the code above, I get the following error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no jogl in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
        at java.lang.Runtime.loadLibrary0(Runtime.java:823)
        at java.lang.System.loadLibrary(System.java:1030)
        at com.sun.opengl.impl.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:189)
        at com.sun.opengl.impl.NativeLibLoader.access$000(NativeLibLoader.java:49)
        at com.sun.opengl.impl.NativeLibLoader$DefaultAction.loadLibrary(NativeLibLoader.java:80)
        at com.sun.opengl.impl.NativeLibLoader.loadLibrary(NativeLibLoader.java:103)
        at com.sun.opengl.impl.NativeLibLoader.access$200(NativeLibLoader.java:49)
        at com.sun.opengl.impl.NativeLibLoader$1.run(NativeLibLoader.java:111)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.opengl.impl.NativeLibLoader.loadCore(NativeLibLoader.java:109)
        at com.sun.opengl.impl.windows.WindowsGLDrawableFactory.<clinit>(WindowsGLDrawableFactory.java:60)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at javax.media.opengl.GLDrawableFactory.getFactory(GLDrawableFactory.java:106)
        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 javax.media.opengl.GLCanvas.<init>(GLCanvas.java:83)
        at joglscape.SimpleJOGL.main(SimpleJOGL.java:25)

I am a noob attempting to make a video game.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cylab

JGO Ninja


Medals: 43



« Reply #93 - Posted 2008-04-26 22:37:13 »

You have to start your program with configured native libraries. This means you have to add
1  
-Djava.library.path=<path/to/jogl/natives/folder>:<path/to/gluegen-rt/natives/folder>

to the command line starting your app. If you use an IDE add this to the JVM-ARGS parameter in your IDEs run configuration.

If you use NetBeans, you can try our OpenGL Pack.

If you haven't already, read the JOGL User's Guide. It also describes an alternative configuration option that involves modifying your systems CLASSPATH and PATH/LD_LIBRARY_PATH environment variables, which might be less cumbersome if you use the commandline instead of an IDE.

Mathias - I Know What [you] Did Last Summer!
Offline gorgonzola

Junior Newbie





« Reply #94 - Posted 2008-04-28 08:30:49 »

I finally got it working, turned out while trying to install about 5000 times over and over I had left some old jogl.jar files in another of my classpath so I still got the unlinked-blabla-error. When I removed them everything worked ^_^
Offline gorgonzola

Junior Newbie





« Reply #95 - Posted 2008-04-29 10:11:01 »

Btw I think this should be included somewhere in this topic, maybe in the first post Tongue
http://fivedots.coe.psu.ac.th/~ad/jg2/

It's the best tutorial I have found by far after several hours of searching.
Offline KeySabreur

Innocent Bystander





« Reply #96 - Posted 2008-06-21 00:37:47 »

Here is a working example:

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  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
package org.yourorghere;

import com.sun.opengl.util.Animator;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;



/**
 * SimpleJOGL.java <BR>
 * author: Brian Paul (converted to Java by Ron Cemer and Sven Goethel) <P>
 *
 * This version is equal to Brian Paul's version 1.2 1999/10/21
 */

public class SimpleJOGL implements GLEventListener {

    public static void main(String[] args) {
        Frame frame = new Frame("Simple JOGL Application");
        GLCanvas canvas = new GLCanvas();

        canvas.addGLEventListener(new SimpleJOGL());
        frame.add(canvas);
        frame.setSize(640, 480);
        final Animator animator = new Animator(canvas);
        frame.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                // Run this on another thread than the AWT event queue to
               // make sure the call to Animator.stop() completes before
               // exiting
               new Thread(new Runnable() {

                    public void run() {
                        animator.stop();
                        System.exit(0);
                    }
                }).start();
            }
        });
        // Center frame
       frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        animator.start();
    }

    public void init(GLAutoDrawable drawable) {
        // Use debug pipeline
       // drawable.setGL(new DebugGL(drawable.getGL()));

        GL gl = drawable.getGL();
        System.err.println("INIT GL IS: " + gl.getClass().getName());

        // Enable VSync
       gl.setSwapInterval(1);

        // Setup the drawing area and shading mode
       gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        gl.glShadeModel(GL.GL_SMOOTH); // try setting this to GL_FLAT and see what happens.
   }

    public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
        GL gl = drawable.getGL();
        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();
    }

    public void display(GLAutoDrawable drawable) {
        GL gl = drawable.getGL();

        // Clear the drawing area
       gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
        // Reset the current matrix to the "identity"
       gl.glLoadIdentity();

        // Move the "drawing cursor" around
       gl.glTranslatef(-1.5f, 0.0f, -6.0f);

        // Drawing Using Triangles
       gl.glBegin(GL.GL_TRIANGLES);
            gl.glColor3f(1.0f, 0.0f, 0.0f);    // Set the current drawing color to red
           gl.glVertex3f(0.0f, 1.0f, 0.0f);   // Top
           gl.glColor3f(0.0f, 1.0f, 0.0f);    // Set the current drawing color to green
           gl.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
           gl.glColor3f(0.0f, 0.0f, 1.0f);    // Set the current drawing color to blue
           gl.glVertex3f(1.0f, -1.0f, 0.0f);  // Bottom Right
       // Finished Drawing The Triangle
       gl.glEnd();

        // Move the "drawing cursor" to another position
       gl.glTranslatef(3.0f, 0.0f, 0.0f);
        // Draw A Quad
       gl.glBegin(GL.GL_QUADS);
            gl.glColor3f(0.5f, 0.5f, 1.0f);    // Set the current drawing color to light blue
           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
       // Done Drawing The Quad
       gl.glEnd();

        // Flush all drawing operations to the graphics card
       gl.glFlush();
    }

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


Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/gluegen/runtime/DynamicLookupHelper
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at java.security.SecureClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.access$000(Unknown Source)
   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)
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at java.security.SecureClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.access$000(Unknown Source)
   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)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Unknown Source)
   at javax.media.opengl.GLDrawableFactory.getFactory(GLDrawableFactory.java:106)
   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 javax.media.opengl.GLCanvas.<init>(GLCanvas.java:83)
   at SimpleJOGL.main(SimpleJOGL.java:25)
Caused by: java.lang.ClassNotFoundException: com.sun.gluegen.runtime.DynamicLookupHelper
   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)
   ... 32 more

What happened? What should I do?
Offline cylab

JGO Ninja


Medals: 43



« Reply #97 - Posted 2008-06-21 23:25:37 »

This usually happens if you either don't have the gluegen-rt.jar on your classpath or you have a conflicting jogl/gluegen installation somewhere in your system directories like jre/ext, C:\windows\system32 etc. Make sure you only have one installation of jogl/gluegen on your system in a dedicated (non-system) directory (e.g. "C:\development\jogl", "/home/<user>/development/jogl" or something like that) and either setup your environment variables accordingly or start your app with the right commanline options (see above)

Mathias - I Know What [you] Did Last Summer!
Offline ajith_kgs

Junior Newbie





« Reply #98 - Posted 2008-08-05 14:46:29 »

Hi. I am a beginner in JOGL and I was trying out some tutorials I got from nehe.gamedev.net (for c / c++)..

I hit a snag when I was doing the 3d shapes tutorial, the tutorial says, that we need to move the drawing point to the loc (-1.5, 0, -6.0), using glTranslatef() func. I tried the same but I am getting just a black screen. I tried the code without changing the drawing point, i.e leaving it at its original place (0, 0, 0), then I could see a very big pyramid rotating. Here is the code. I am using eclipse, with the latest JRE and JOGL library. Can somebody please tell me, what I am doing wrong. Cheesy Thanks in advance.

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  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
import javax.media.opengl.*;
import com.sun.opengl.util.Animator;
import javax.media.opengl.GLEventListener;
import java.awt.*;
import java.awt.event.*;

class SimpleEventListener implements GLEventListener{
   
   float rt;
   Animator anim;
   
   public void init(GLAutoDrawable drawable){
     
      GL gl = drawable.getGL();
      gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
           
      rt=0.0f;
      anim= new Animator(drawable);
      anim.start();
     
   }
   public void display(GLAutoDrawable drawable){
     
      GL gl = drawable.getGL();
     
      gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );
        gl.glLoadIdentity();
       
        gl.glTranslatef(-1.5f, 0.0f, -6.0f);
        gl.glRotatef(rt, 0.0f, 1.0f, 0.0f);
     
      gl.glBegin(GL.GL_TRIANGLES);
     
      gl.glColor3f(1.0f,0.0f,0.0f);        
      gl.glVertex3f( 0.0f, 1.0f, 0.0f);
      gl.glColor3f(0.0f,1.0f,0.0f);        
      gl.glVertex3f(-1.0f,-1.0f, 1.0f);      
      gl.glColor3f(0.0f,0.0f,1.0f);        
      gl.glVertex3f( 1.0f,-1.0f, 1.0f);      
      gl.glColor3f(1.0f,0.0f,0.0f);        
      gl.glVertex3f( 0.0f, 1.0f, 0.0f);        
      gl.glColor3f(0.0f,0.0f,1.0f);        
      gl.glVertex3f( 1.0f,-1.0f, 1.0f);      
      gl.glColor3f(0.0f,1.0f,0.0f);        
      gl.glVertex3f( 1.0f,-1.0f, -1.0f);      
      gl.glColor3f(1.0f,0.0f,0.0f);        
      gl.glVertex3f( 0.0f, 1.0f, 0.0f);        
      gl.glColor3f(0.0f,1.0f,0.0f);        
      gl.glVertex3f( 1.0f,-1.0f, -1.0f);        
      gl.glColor3f(0.0f,0.0f,1.0f);        
      gl.glVertex3f(-1.0f,-1.0f, -1.0f);        
      gl.glColor3f(1.0f,0.0f,0.0f);        
      gl.glVertex3f( 0.0f, 1.0f, 0.0f);        
      gl.glColor3f(0.0f,0.0f,1.0f);        
      gl.glVertex3f(-1.0f,-1.0f,-1.0f);        
      gl.glColor3f(0.0f,1.0f,0.0f);        
      gl.glVertex3f(-1.0f,-1.0f, 1.0f);  
     
       gl.glEnd();
               
        rt+=0.2f;
       
   }
   public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h){}
   public void displayChanged(GLAutoDrawable drawable, boolean b1, boolean b2){}
   
}
public class SimpleTest {

   public static void main(String[] args)
   {
      Frame frame= new Frame("SimpleTest");
   
      GLCanvas canvas= new GLCanvas();
      SimpleEventListener listener= new SimpleEventListener();
   
      frame.setSize(640, 480);
      frame.add(canvas);
      frame.setVisible(true);
     
      canvas.addGLEventListener(listener);
   
      frame.addWindowListener(new WindowAdapter() {
     
         public void windowClosing(WindowEvent e)
         {
            System.exit(0);
         }
      });
   }
}
Offline GKW

Senior Member




Revenge is mine!


« Reply #99 - Posted 2008-08-05 15:45:34 »

You need to set up your projection matrix.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ajith_kgs

Junior Newbie





« Reply #100 - Posted 2008-08-05 15:49:39 »

ok.. how am I supposed to do that?
Offline cylab

JGO Ninja


Medals: 43



« Reply #101 - Posted 2008-08-05 16:27:56 »

Take a look at the SimpleJOGL example some post above, and copy the reshape()-method to your SimpleEventListener  class. Also the Animator should not be instantiated and started inside the init() callback. Chances are, that init() is called multiple times on e.g. window resize and you would instantiate and start multiple animators this way, which could lead to an application freeze. Again, take a look at the SimpleJOGL example.


Mathias - I Know What [you] Did Last Summer!
Offline ajith_kgs

Junior Newbie





« Reply #102 - Posted 2008-08-05 17:33:24 »

yea, i tried it. it works ..  Grin thank you..
Offline nortino

Junior Newbie





« Reply #103 - Posted 2008-08-25 22:31:34 »

Hi, I've read this thread and googled around, but I'm having a problem getting JOGl to run in an Eclipse project. I've followed the instructions here:

http://www.geofx.com/html/OpenGL_Eclipse/OpenGL_Eclipse.html

to make a simple Eclipse RCP application with a single View that implements GLEventListener, and basically the project builds OK, but when I run it I get the following exception:

java.lang.NoClassDefFoundError: javax/media/opengl/GLEventListener

Now, I have a directory called "C:\jogl-1.1.1-windows-i586" which is an unzip of the jogl-1.1.1-windows-i586.zip, and so contains the JOGl dlls and jars, and I have included the gluegen-rt.jar and jogl.jar from here in my Eclipse project.  As I say, Eclipse is happy with this and the project builds fine, and it can 'see' javax/media/opengl/GLEventListener, but it fails at runtime. I have tried adding "C:\jogl-1.1.1-windows-i586" and the "C:\jogl-1.1.1-windows-i586\lib" subdirectory to my Path environment variable, but I get the same error. Any help would be appreciated.

Offline nortino

Junior Newbie





« Reply #104 - Posted 2008-08-26 23:06:06 »

Right, I've solved this now. For anyone with a similar issue, here is my understanding of the situation:

To recap, I'm trying to get a minimal JOGL example working in an Eclipse RCP application. The application compiles fine, but craps out at runtime with "java.lang.NoClassDefFoundError: javax/media/opengl/GLEventListener". This seems like typical classpath fun and games, so I fart around and set my CLASSPATH environment variable (I'm on Win XP) to include the world and his wife, but of course it still doesn't work. I try putting all the JOGL crap in the "\jdk1.6.0_01\jre\lib\ext" directory. This not only doesn't solve the problem, but now it won't even build (Eclipse complains about Access Restriction on the JOGL stuff; great) - I know putting the JOGL stuff in here is naughty but I'm just trying to get it to work, so w/e.
What I didn't realise is that Eclipse ignores the CLASSPATH variable, so messing around with that is a waste of time. My understanding was that if you included a JAR in the Project > Properties > Libraries > Add External Jars bit, then Eclipse would sort out the CLASSPATH stuff for you, and certainly it adds some stuff to its little .classpath file, but it doesn't work at runtime, so there you go.
Anyway, I think this is some special wierdness of making an RCP application. I think you have to do Other Things to get the CLASSPATH sorted for external JARs in an Eclipse RCP application. Here's what I did:

Start a clean RCP Plug-In project in Eclipse. Add a lib directory to it. Put the gluegen-rt.jar and jogl.jar in there. Right-click on them in Eclipse and do 'Add to Build Path'. Right-click your MANIFEST.MF file and do 'Open With' > 'Plug-in Manifest Editor'. In the Manifest Editor select the Runtime tab. On there, under the Classpath bit click 'Add...', and select your lib/gluegen-rt.jar and lib/jogl.jar. That's it really. This is basically following the steps here:

http://dev.eclipse.org/newslists/news.eclipse.platform.rcp/msg06980.html

To see some JOGL stuff, add a View and if you use the code from here it should work:

http://www.geofx.com/html/OpenGL_Eclipse/OpenGL_Eclipse.html

Hope this is helpful to someone.



Offline EpicNerd

Junior Newbie





« Reply #105 - Posted 2009-06-11 16:02:33 »

I'm getting an error similar to the one listed a couple of posts above.  I've double-checked and there is only one instance of the gluegen-rt.jar file on my system and it is in the same directory as my jogl.jar file (which Java is finding correctly).

Here is the command I'm running and here is the error:
[CODE]
c:\JOGL\Examples>java -Djava.library.path=c:\jogl\native -classpath c:\jogl\jogl.jar;. SimpleJOGL

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/gluegen/runtime/DynamicLookupHelper
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at javax.media.opengl.GLDrawableFactory.getFactory(GLDrawableFactory.java:106)
        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 javax.media.opengl.GLCanvas.<init>(GLCanvas.java:83)
        at SimpleJOGL.main(SimpleJogl.java:23)
Caused by: java.lang.ClassNotFoundException: com.sun.gluegen.runtime.DynamicLookupHelper
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        ... 32 more
[/CODE]
Offline bienator

Senior Member




OutOfCoffeeException


« Reply #106 - Posted 2009-06-11 16:08:40 »

you forgot to add gluegen-rt.jar to the classpath.
c:\JOGL\Examples>java -Djava.library.path=c:\jogl\native -classpath c:\jogl\jogl.jar;c:\jogl\gluegen-rt.jar;. SimpleJOGL

Offline EpicNerd

Junior Newbie





« Reply #107 - Posted 2009-06-11 16:12:00 »

That would be it.  Thanks! Isn't there a better way to set that somehow?  At least now I can play around with stuff.  Thanks again.
Offline cylab

JGO Ninja


Medals: 43



« Reply #108 - Posted 2009-06-11 21:03:45 »

That would be it.  Thanks! Isn't there a better way to set that somehow?  At least now I can play around with stuff.  Thanks again.

You could add the jars to the CLASSPATH environment variable and the directories with the native libraries to the PATH. Oh and also read the "Jogl Users Guide" ;-)

Mathias - I Know What [you] Did Last Summer!
Offline falcon

Junior Newbie





« Reply #109 - Posted 2009-08-15 20:14:54 »

It seems there are some changes in the API. I updated the code.

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  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
import com.sun.opengl.util.Animator;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.*;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;
import javax.media.opengl.awt.GLCanvas;


/**
 * SimpleJOGL2.java <BR>
 * author: Brian Paul (converted to Java by Ron Cemer and Sven Goethel) <P>
 *
 * This version is equal to Brian Paul's version 1.2 1999/10/21
 */

public class SimpleJOGL implements GLEventListener {

    public static void main(String[] args) {
        Frame frame = new Frame("Simple JOGL Application");
        GLCanvas canvas = new GLCanvas();

        canvas.addGLEventListener(new SimpleJOGL());
        frame.add(canvas);
        frame.setSize(640, 480);
        final Animator animator = new Animator(canvas);
        frame.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                // Run this on another thread than the AWT event queue to
               // make sure the call to Animator.stop() completes before
               // exiting
               new Thread(new Runnable() {

                    public void run() {
                        animator.stop();
                        System.exit(0);
                    }
                }).start();
            }
        });
        // Center frame
       frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        animator.start();
    }

    public void init(GLAutoDrawable drawable) {
        // Use debug pipeline
       // drawable.setGL(new DebugGL(drawable.getGL()));

       GL2 gl = drawable.getGL().getGL2();
        System.err.println("INIT GL IS: " + gl.getClass().getName());

        // Enable VSync
       gl.setSwapInterval(1);

        // Setup the drawing area and shading mode
       gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        gl.glShadeModel(GL2.GL_SMOOTH); // try setting this to GL_FLAT and see what happens.
   }

    public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
        GL2 gl = drawable.getGL().getGL2();
        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(GL2.GL_PROJECTION);
        gl.glLoadIdentity();
        glu.gluPerspective(45.0f, h, 1.0, 20.0);
        gl.glMatrixMode(GL2.GL_MODELVIEW);
        gl.glLoadIdentity();
    }

    public void display(GLAutoDrawable drawable) {
        GL2 gl = drawable.getGL().getGL2();

        // Clear the drawing area
       gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
        // Reset the current matrix to the "identity"
       gl.glLoadIdentity();

        // Move the "drawing cursor" around
       gl.glTranslatef(-1.5f, 0.0f, -6.0f);

        // Drawing Using Triangles
       gl.glBegin(GL2.GL_TRIANGLES);
            gl.glColor3f(1.0f, 0.0f, 0.0f);    // Set the current drawing color to red
           gl.glVertex3f(0.0f, 1.0f, 0.0f);   // Top
           gl.glColor3f(0.0f, 1.0f, 0.0f);    // Set the current drawing color to green
           gl.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
           gl.glColor3f(0.0f, 0.0f, 1.0f);    // Set the current drawing color to blue
           gl.glVertex3f(1.0f, -1.0f, 0.0f);  // Bottom Right
       // Finished Drawing The Triangle
       gl.glEnd();

        // Move the "drawing cursor" to another position
       gl.glTranslatef(3.0f, 0.0f, 0.0f);
        // Draw A Quad
       gl.glBegin(GL2.GL_QUADS);
            gl.glColor3f(0.5f, 0.5f, 1.0f);    // Set the current drawing color to light blue
           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
       // Done Drawing The Quad
       gl.glEnd();

        // Flush all drawing operations to the graphics card
       gl.glFlush();
    }

     public void dispose(GLAutoDrawable drawable){}
   
    public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
    }
}
Offline bienator

Senior Member




OutOfCoffeeException


« Reply #110 - Posted 2009-08-15 20:44:00 »

(the whole thread is deprecated regarding JOGL2, its an introduction to JOGL1. Maybe a moderator should detach the thread from being the first in this forum)

Offline Justmaker

Junior Newbie





« Reply #111 - Posted 2009-12-03 16:41:30 »

I have a problem: I can't find the jogl.jar file! I (finally) suceeded in building Jogl, and in the jogl\build folder i have 3 other folders:
jogl, nativewindow, newt.
In the jogl folder, I have a whole list of jogl.XXX.jar files but never the simple jogl.jar file...
Because of this, I cannot run the simple System.loadLibrary("jogl"); command...

Any advice?
Offline Xerxes

Innocent Bystander





« Reply #112 - Posted 2009-12-27 19:43:48 »

Im sorry but i am horribly confused about creating and binding a context to GL! What exactly is the recommended Window ToolKit? In the FAQ you can read, awt and swing are bad but i cant get the native Window toolkit running. http://kenai.com/projects/jogl/forums/forum/topics/1691-How-to-create-a-native-window- <- i found this here where you can see how to create a native window. But i have no idea how to get a GLDrawable out of the window in order to add it to an Animator. If this question doesnt belong here please forgive me! Since this is my problem with the "getting started" part.
Offline gingerfish

Junior Newbie





« Reply #113 - Posted 2010-01-15 08:17:41 »

hey people,

i wanna use new jogl package (i mean javax.media.opengl....), but i get errors  Cry

where i can download the latest release??

thanks Smiley

Offline rhdxmr

Senior Newbie





« Reply #114 - Posted 2010-01-19 15:54:12 »

you can download it from here.  Smiley
http://download.java.net/media/jogl/builds/archive/
Offline davips

Junior Newbie





« Reply #115 - Posted 2010-05-01 18:41:53 »

Hello  Smiley,
I'm developing the applet http://analisegrafica.net/applet.html.
Some people report Java can't find the Main class, but it works on my Windows and Linux environments.
I checked browser/Java/SO versions and all was equal to mine. What's wrong?
Should I use JOGL 2? Is there a specific Topic about?
Is there a Netbeans plugin for JOGL 2?

Thanks  persecutioncomplex
Offline gouessej
« Reply #116 - Posted 2011-06-30 22:07:23 »

No, you should download it from here:
http://jogamp.org/deployment/archive/rc/

Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #117 - Posted 2011-06-30 23:01:04 »

hey people,

i wanna use new jogl package (i mean javax.media.opengl....), but i get errors  Cry

where i can download the latest release??

thanks Smiley


In the future instead of resurrecting an old thread, just make a new topic with your question. Smiley

See my work:
OTC Software
Offline cylab

JGO Ninja


Medals: 43



« Reply #118 - Posted 2011-07-01 09:07:39 »

Quote from: Eli Delventhal
Quote from: gingerfish on January 15, 2010
(...)
In the future instead of resurrecting an old thread (...)
LOL

Mathias - I Know What [you] Did Last Summer!
Offline lhkbob

JGO Knight


Medals: 32



« Reply #119 - Posted 2011-07-01 15:37:32 »

hey people,

i wanna use new jogl package (i mean javax.media.opengl....), but i get errors  Cry

where i can download the latest release??

thanks Smiley


In the future instead of resurrecting an old thread, just make a new topic with your question. Smiley
What happened to going green? We need to recycle, man!

Pages: 1 2 3 [4] 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.

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

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

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

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

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

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

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

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

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
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!