Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (762)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (846)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Error following switch to more recent JOGL build.  (Read 2450 times)
0 Members and 1 Guest are viewing this topic.
Offline Alfryd

Junior Devvie





« Posted 2009-05-24 23:41:42 »

I'm running a fairly new MacBook under OS X.4, and I'm afraid I can't make head nor tail of it myself, so I'll just post it here:

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  
Exception in thread "Thread-2" javax.media.opengl.GLException: java.lang.ClassCastException: java.nio.DirectByteBuffer
   at javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:271)
   at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:263)
   at javax.media.opengl.GLCanvas.display(GLCanvas.java:130)
   at com.sun.opengl.util.Animator.display(Animator.java:144)
   at com.sun.opengl.util.Animator$MainLoop.run(Animator.java:181)
   at java.lang.Thread.run(Thread.java:613)
Caused by: java.lang.ClassCastException: java.nio.DirectByteBuffer
   at com.sun.opengl.impl.macosx.MacOSXOnscreenGLDrawable.lockSurface(MacOSXOnscreenGLDrawable.java:180)
   at com.sun.opengl.impl.macosx.MacOSXOnscreenGLContext.makeCurrentImpl(MacOSXOnscreenGLContext.java:57)
   at com.sun.opengl.impl.GLContextImpl.makeCurrent(GLContextImpl.java:134)
   at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:182)
   at javax.media.opengl.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java:305)
   at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
   at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: Attempt to make the same context current twice on thread Thread[AWT-EventQueue-0,6,main]
   at com.sun.opengl.impl.GLContextLock.lock(GLContextLock.java:83)
   at com.sun.opengl.impl.GLContextImpl.makeCurrent(GLContextImpl.java:131)
   at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:182)
   at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:265)
   at javax.media.opengl.GLCanvas.display(GLCanvas.java:130)
   at javax.media.opengl.GLCanvas.paint(GLCanvas.java:142)
   at sun.awt.RepaintArea.paintComponent(RepaintArea.java:276)
   at sun.awt.RepaintArea.paint(RepaintArea.java:241)
   at apple.awt.ComponentModel.handleEvent(ComponentModel.java:251)
   at java.awt.Component.dispatchEventImpl(Component.java:4126)
   at java.awt.Component.dispatchEvent(Component.java:3885)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
   at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)


Is this at all familiar?  What am I doing wrong?
Offline Alfryd

Junior Devvie





« Reply #1 - Posted 2009-05-25 10:37:36 »

If it helps any, this is the precise code I was trying to run (it compiles fine)

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  
import javax.media.opengl.* ;
import java.awt.BorderLayout;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import javax.swing.JFrame;
import com.sun.opengl.util.BufferUtil ;
import javax.media.opengl.glu.*;
import com.sun.opengl.util.*;

public class VertexArrayTest extends JFrame implements GLEventListener {
   
    private GL gl;
    private GLU glu;
    private GLCanvas canvas;
    private Animator anim;

   
    public VertexArrayTest() {
        canvas = new GLCanvas() ;
        canvas.addGLEventListener(this);
       
        getContentPane().add(canvas, BorderLayout.CENTER);
        setSize(500, 500);
        setTitle("Red Book Example ");
        setVisible(true);
        anim = new Animator(canvas);            // calls display() periodically
        anim.start();        
       
        this.addWindowListener(new WindowListener() {

            public void windowOpened(WindowEvent arg0) {}

            public void windowClosing(WindowEvent arg0) {
                anim.stop();
                setVisible(false);
                System.exit(0);
            }

            public void windowClosed(WindowEvent arg0) {}
            public void windowIconified(WindowEvent arg0) {}
            public void windowDeiconified(WindowEvent arg0) {}
            public void windowActivated(WindowEvent arg0) {}
            public void windowDeactivated(WindowEvent arg0) {}
        });
       
    }    
   
    public static void main(String[] args) {
        VertexArrayTest desk = new VertexArrayTest();
    }

    public void init(GLAutoDrawable arg0) {
        gl = arg0.getGL();
        glu = new GLU();
       
        gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

        int[] v = new int[] {25, 25,
            100, 325,
            175, 25,
            175, 325,
            250, 25,
            325, 325};
        float[] c = new float[] {
                1.0f, 0.2f, 0.2f,
                0.2f, 0.2f, 1.0f,
                0.8f, 1.0f, 0.2f,
                0.75f, 0.75f, 0.75f,
                0.35f, 0.35f, 0.35f,
                0.5f, 0.5f, 0.5f};

        IntBuffer vertices = BufferUtil.newIntBuffer(6*2);
        FloatBuffer colors = BufferUtil.newFloatBuffer(6*3);
       
        vertices.put(v);
        colors.put(c);

       
        gl.glEnableClientState (GL.GL_COLOR_ARRAY);
        gl.glEnableClientState (GL.GL_VERTEX_ARRAY);        
       
        gl.glColorPointer (3, GL.GL_FLOAT, 0, colors);
        gl.glVertexPointer (2, GL.GL_INT, 0, vertices);        
    }

    public void display(GLAutoDrawable arg0) {
        gl.glClear(GL.GL_COLOR_BUFFER_BIT );
        gl.glDrawArrays (GL.GL_TRIANGLES, 0, 6);
        gl.glFlush ();
    }

   
    public void reshape(GLAutoDrawable drawable, int x, int y, int width,
            int height) {
        gl.glViewport (0, 0, width,  height);
        gl.glMatrixMode (GL.GL_PROJECTION);
        gl.glLoadIdentity ();
        glu.gluOrtho2D (0.0, width, 0.0, height);
    }

    public void displayChanged(GLAutoDrawable arg0, boolean arg1, boolean arg2) {}
   
}
Offline Alfryd

Junior Devvie





« Reply #2 - Posted 2009-05-25 17:45:11 »

It's the most recent universal binary build I could get, but I guess this is something unusual... I'll try running some of the demos and see if that helps.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline lhkbob

JGO Knight


Medals: 32



« Reply #3 - Posted 2009-05-25 17:45:49 »

I tested your code and it gave me a different exception than the one you reported.  When you call glVertexPointer and glColorPointer, it reads in data from the buffer using its current position and limit.  The way you've written your code, each buffer's position is at its capacity, so it crashed.  What you should do is this:
1  
2  
gl.glColorPointer (3, GL.GL_FLOAT, 0, colors.clear());
gl.glVertexPointer (2, GL.GL_INT, 0, vertices.clear());


Also, I generally recommend that you don't hold onto a GL instance as a class variable.  In this case I don't think it's causing you problems, but it is much safer to always call getGL() in each display(GLAutoDrawable) method.

Offline Alfryd

Junior Devvie





« Reply #4 - Posted 2009-05-25 19:52:21 »

Thanks for the pointer, but I'm almost certain that would give rise to a different kind of bug- I still get the precise same error message after I implement those fixes- heck, it still pops up if I comment out the display method's innards entirely!

The exact source of the error message seems to be here:
http://www.koders.com/java/fid6FACC71CCFAB70D7AFF2E93E92E1309C5C36A5F4.aspx

But I don't know why it's complaining about more than one GL context here... did you run the app under OSX?

EDIT:  The bug also seems very similar to one reported on the Xith3d forums-
http://xith.org/forum/index.php?topic=993.0
Offline lhkbob

JGO Knight


Medals: 32



« Reply #5 - Posted 2009-05-26 05:10:57 »

If the bug is similar to the one reported in the xith3d forums (which it does seem like), then all I can say is make sure you have up to date versions of both the jars and native libraries (for both jogl and gluegen) and that you haven't placed anything related to that in your java system directory.

Also, I did test it on OS X (but it was 10.5.7 and not 10.4).

Offline Alfryd

Junior Devvie





« Reply #6 - Posted 2009-05-26 14:42:22 »

Right.  Thanks for the help anyway.

Thing is, this IS the latest version of jogl (for all libs/jars,) whereas my previous version (from early '07) ran fine (albeit very inefficiently for some reason, hence the switch.)  I guess I might have to give lwjgl a try at this point.

EDIT: typo
Offline Alfryd

Junior Devvie





« Reply #7 - Posted 2009-05-26 19:54:38 »

Ah, wait- I see what I did wrong:  I was actually referring to the native libraries in an older version of the same project!  My mistake.
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (359 views)
2018-06-10 19:43:48

EgonOlsen (360 views)
2018-06-10 19:43:44

EgonOlsen (298 views)
2018-06-10 19:43:20

DesertCoockie (533 views)
2018-05-13 18:23:11

nelsongames (857 views)
2018-04-24 18:15:36

nelsongames (840 views)
2018-04-24 18:14:32

ivj94 (1285 views)
2018-03-24 14:47:39

ivj94 (410 views)
2018-03-24 14:46:31

ivj94 (1073 views)
2018-03-24 14:43:53

Solater (420 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05
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!