JOGL 1.1 beta 5 applet problem

Hi!

Although I have some experience in Opengl using C++ I’m a completely newcomer to Java and JOGL.

I has trying to build a very simple applet using JOGL, and it was working just fine with beta 4, but know that I’ve upgraded my JOGL version to beta 5 I’m unable to execute the following chunk of code within the browser (in eclipse it works fine)

try
{
   Class c = Class.forName("GLPanel1");
   JPanel panel = (JPanel) c.newInstance();
   this.getContentPane().add(panel);
}
catch (Exception e)
{
   joglSupport = false;
}

It keeps cathing the exception…
I only have one JVM installed and the JOGL jar and dlls are in the correct place in the JRE. I don’t have it in the JDK.

Here is the full source:

import javax.swing.*;

public class JOGLTutorialApplet1 extends JApplet
{
      public void init()
      {
            boolean joglSupport = false;
            
            try
            {
                  Class.forName("net.java.games.jogl.GLCanvas");
                  joglSupport = true;
            }
            catch(ClassNotFoundException e)
            {
                  joglSupport = false;
            }
            
            if(joglSupport)
            {
                  try
                  {
                        Class c = Class.forName("GLPanel1");
                        JPanel panel = (JPanel) c.newInstance();
                        this.getContentPane().add(panel);
                  }
                  catch (Exception e)
                  {
                        joglSupport = false;
                  }
            }
            
            if(!joglSupport)
            {
                  this.getContentPane().add(new JLabel("JOGL not installed"));
            }
      }
}






import net.java.games.jogl.*;
import javax.swing.*;

public class GLPanel1 extends JPanel implements GLEventListener
{
      private GLCanvas canvas;
      
      /**
       * Constructor of the Panel.
       * The constructor creates a GLCanvas and then adds it to itself.
       */
      public GLPanel1()
      {
            super();
            
            /**
             * First we create the capabilities for our canvas
             */
            GLCapabilities capabilities = new GLCapabilities();
            capabilities.setHardwareAccelerated(true);      //We want hardware accelleration
            capabilities.setDoubleBuffered(true);           //And double buffering
            
            /**
             * Then we create the canvas.
             */
            canvas=GLDrawableFactory.getFactory().createGLCanvas(capabilities);
            
            /**
             * We add the eventlistener, so that the display will be updated at the appropriate times.
             */
            canvas.addGLEventListener(this);
            
            /**
             * Finally we add the canvas and set its size
             */
            this.add(canvas);
            this.setSize(640,480);
            canvas.setSize(640,480);//We want the JPanel and the GLCanvas to have the same size
            canvas.setVisible(true);//This is somehow necessary
      }
      
      /**
       * The init method will be called when the GLCanvas is constructed.
       * Here we put the basic settings that will only be called once.
       * @param glDrawable
       */
      public void init(GLDrawable glDrawable)
      {
            GL myGL=glDrawable.getGL();//Get the GL object from glDrawable
            
            myGL.glClearColor (0.2f, 0.5f, 0.8f, 0.0f);
            myGL.glShadeModel(GL.GL_FASTEST);
      }
      
      /**
       * This is the function where the drawing is done.
       * This method is called everytime repaint() is called.
       * JOGL uses Javas events, which makes it a lot easier to use.
       * @param glDrawable
       */
      public void display(GLDrawable glDrawable)
      {
            GL myGL=glDrawable.getGL();
            
            myGL.glClear(GL.GL_COLOR_BUFFER_BIT);
            
            myGL.glColor3f(0.2f, 0.6f , 0.5f);
            myGL.glBegin(GL.GL_QUADS);
            
            myGL.glVertex3f(-50,50,0);
            myGL.glVertex3f(50,50,0);
            myGL.glVertex3f(50,-50,0);
            myGL.glVertex3f(-50,-50,0);
            
            myGL.glEnd();
      }
      /**
       * Reshape will be called everytime the canvas changes shape.
       * This is a good place the MATRIX setup if you want the 'camera' settings to change when the display is resized.
       * @param glDrawable
       * @param i
       * @param i1
       * @param i2
       * @param i3
       */
      public void reshape(GLDrawable glDrawable, int i, int i1, int i2, int i3)
      {
            GL myGL=glDrawable.getGL();
            int width=canvas.getWidth();
            int height=canvas.getHeight();
            
            myGL.glMatrixMode(GL.GL_PROJECTION);
            myGL.glLoadIdentity();
            myGL.glOrtho(-width/2,width/2,-height/2,height/2,-10,10);
      }
      
      public void displayChanged(GLDrawable glDrawable, boolean b, boolean b1)
      {
      }
}

Hope someone can help me.

Thanx,
hellder.

What’s the stack trace of the thrown exception?

It fails in the following line:

canvas=GLDrawableFactory.getFactory().createGLCanvas(capabilities);

But I can’t figure out why, 'cause I’m just setting hardware acceleration and double buffer in the capabilities, nothing fancy here.

Can anyone tell me what changed in driver capabilities chooser from beta4 to beta5?

Another strange thing is that it works on the applet viewer when running from Eclipse but not in the browser. Even the demos from https://jogl-demos.dev.java.net page have stopped to work (permission denied error).

Any thoughts?

hellder.

We need the entire stack trace to see what is going on. That line could be throwning any number of exceptions so we need to see the actual trace.

[quote]We need the entire stack trace to see what is going on. That line could be throwning any number of exceptions so we need to see the actual trace.
[/quote]
Yeah, I know that, but can you help me doing that? As I’ve already said I’m completely new to java and the problem only arises when running in the browser. I have no clue on how to give you the stack trace. ???

About the exception…

canvas=GLDrawableFactory.getFactory().createGLCanvas(capabilities);

is throwing the following exception:

java.security.AccessControlException: access denied (java.lang.RuntimePermission shutdownHooks)

By the way, I’m running Windows XP and JRE 1.4.2_05.

Hope it helps…
Thanx.

Thanks. We will look into it.

Thank YOU!

Please drop me a line if you manage to figure out what’s going on.

Cheers.

Looks like I forgot to include a bit of securty code in the last update. Hopefully I will get a fix up this weekend. If you go to my site and grab JOGL.jar you can test what I have done so far. I do not have an applet handy to test it on so I don’t know if it works yet.

Thank you once again, GKW!

I’ve downloaded the JOGL.jar from your site and it worked beautifully! :wink:

Thanx man, for all your effort!