Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  JOGL and applets  (Read 476 times)
0 Members and 2 Guests are viewing this topic.
Offline alain21

JGO n00b
*

Posts: 2



« on: 2011-08-22 00:29:52 »

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

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  
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

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  
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:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
          <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:

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  
<?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 ....
Offline gouessej

JGO Kernel
*****

Posts: 3560
Medals: 30


TUER


« Reply #1 on: 2011-08-22 08:41:21 »

Hi

JOGL 1.1.1a is obsolete, please switch to JOGL 2. This bug is not reproducible with JOGL 2 but take care not mixing the both, clean your environment before switching.

Julien Gouesse
Offline alain21

JGO n00b
*

Posts: 2



« Reply #2 on: 2011-08-22 10:59:46 »

Rgr,

Tks I'll try that
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.068 seconds with 20 queries.