I working on in-browser jogl game … and weird thing I got it working great until yesterday where I change something and everything start crashing …
looking back in the Java trace I see :
Exception in thread “AWT-EventQueue-2” java.lang.ClassCastException: java.nio.DirectByteBuffer cannot be cast to com.sun.opengl.impl.x11.JAWT_X11DrawingSurfaceInfo
at com.sun.opengl.impl.x11.X11OnscreenGLDrawable.lockSurface(X11OnscreenGLDrawable.java:152)
at com.sun.opengl.impl.x11.X11OnscreenGLContext.makeCurrentImpl(X11OnscreenGLContext.java:61)
at com.sun.opengl.impl.GLContextImpl.makeCurrent(GLContextImpl.java:134)
at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:182)
When running as Application, everything works great. However, the problem is in applet mode. For info … I am using JOGL 1, Linux and Chrome. I am running the following the Following Code for my GLListerner
public class AppJavaTestWebStart implements GLEventListener {
//When running as an application
public static void main(String[] args){
AppJavaTestWebStart objApp= new AppJavaTestWebStart();
Frame frame = new Frame("Simple JOGL Application");
GLCanvas canvas = new GLCanvas();
canvas.addGLEventListener(this);
frame.add(canvas);
frame.setSize(640, 480);
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() {
@Override
public void run() {
System.exit(0);
}
}).start();
}
});
// Center frame
frame.setLocationRelativeTo(null);
frame.setVisible(true);
while(true)
canvas.display();
}
@Override
public void init(GLAutoDrawable drawable) {
[...]
}
@Override
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
[...]
}
@Override
public void display(GLAutoDrawable drawable) {
[...]
}
public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
}
And this code for my applet
public class AppletJavaTestWebStart extends Applet{
private Animator m_objAnimator;
private GLCanvas m_objcanvas;
@Override
public void init(){
setLayout(new BorderLayout());
m_objcanvas= new GLCanvas();
m_objcanvas.addGLEventListener(new AppJavaTestWebStart());
m_objcanvas.setSize(getSize());
add(m_objcanvas, BorderLayout.CENTER);
m_objAnimator= new Animator(m_objcanvas);
}
@Override
public void start(){
m_objAnimator.start();
}
@Override
public void stop(){
m_objAnimator.stop();
}
The following HTML:
<applet code="org.bianisoft.tests.javatestwebstart.AppletJavaTestWebStart"
width=640
height=480
<param name="codebase_lookup" value="true">
<param name="subapplet.displayname" value="JOGL Gears Applet">
<param name="noddraw.check" value="true">
<param name="progressbar" value="true">
<param name="java_arguments" value="-Dsun.java2d.noddraw=true">
<param name="jnlp_href" value="JavaTestWebStart_local.jnlp">
</applet>
The following JNLP:
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="./" href="JavaTestWebStart_local.jnlp">
<information>
<title>JavaTestWebStart Demo</title>
<vendor>Alain Petit</vendor>
<homepage href="http://www.alainpetit.me/"/>
<description> JavaTest Web Start Demo</description>
<description kind="short">The simplest possible JOGL Java Web Start demo - draws one triangle.</description>
<offline-allowed/>
</information>
<update check="background" policy="always"/>
<security>
<all-permissions/>
</security>
<resources>
<j2se href="http://java.sun.com/products/autodl/j2se" version="1.6+"/>
<property name="sun.java2d.noddraw" value="true"/>
<extension name="JOGL" href="JOGL_local.jnlp" />
<jar href="JavaTestWebStart.jar" main="true"/>
<jar href="JavaTestWebStart_res.jar"/>
</resources>
<applet-desc
name="JavaTestWebStart Demo Applet"
main-class="org.bianisoft.tests.javatestwebstart.AppletJavaTestWebStart"
width="640"
height="480">
</applet-desc>
<!-- application-desc
main-class="org.bianisoft.tests.javatestwebstart.JavaTestWebStart">
</application-desc -->
</jnlp>
It’s got to be something trivial …