Hello, I’ve written a small applet using jogl. When you open your browser (I use firefox but others have the same problem) the applet loads and works really fine and every event (e.g. MouseMotion-Events) will be handled without any problems. Now if you press the reload-button, the applet will be reloaded once again and renders also without any problems. But now if you enter the GLCanvas-window in the browser with your mouse the whole system freezes and cpu-usage is 100%. I guess there’s a problem with the event-handling, because if you don’t register any event-handler, the problem won’t arise.
Had anyone the same problem, or knows anyone a workaround. It would be very helpful.
My Applet-Code for testing is this:
import java.awt.;
import java.awt.event.;
import java.applet.;
import java.io.;
import java.net.*;
import net.java.games.jogl.*;
public class joglapplet extends Applet
implements MouseMotionListener {
static GLCapabilities cap=new GLCapabilities();
GLCanvas canvas=null;
String model3D;
OpenGLView oglview;
int xold, yold;
public joglapplet() {
super();
System.out.println("Konstruktor");
}
public void init ()
{
model3D = getParameter("Model3D");
if (model3D != null) {
canvas = GLDrawableFactory.getFactory().createGLCanvas (cap);
oglview = new OpenGLView();
canvas.addGLEventListener(oglview);
canvas.addMouseMotionListener(this);
canvas.setSize(getWidth(), getHeight());
canvas.setVisible(true);
add(canvas);
}
}
public void start() {
oglview.start();
}
public void stop() {
oglview.stop();
}
public void mouseDragged(MouseEvent e) {
e.consume();
}
public void mouseMoved(MouseEvent e) {
xold = e.getX(); yold = e.getY();
e.consume();
}
}
and my OpenGLView-class:
public class OpenGLView
implements GLEventListener {
Animator animator;
double anglex = 0, angley = 145, anglez = 0, zoom = -3;
public void init(GLDrawable drawable) {
drawable.addMouseMotionListener(this);
drawable.addKeyListener(this);
GL gl = drawable.getGL();
gl.glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );
animator = new Animator(drawable);
}
public void display(GLDrawable drawable) {
GL gl = drawable.getGL ();
GLU glu = drawable.getGLU ();
Dimension dim = drawable.getSize();
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective (60.0,((double)dim.width)/dim.height,1.0,2000.0);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glTranslated(0,0,zoom);
gl.glRotated(angley, 0,1,0);
gl.glEnable(GL.GL_DEPTH_TEST);
gl.glClearColor (0f, 0f, 0f, 0f);
gl.glClear(GL.GL_DEPTH_BUFFER_BIT | GL.GL_COLOR_BUFFER_BIT);
gl.glClear( GL.GL_COLOR_BUFFER_BIT );
}
public void reshape(GLDrawable drawable, int x, int y, int width, int height) {
if (height > 0) {
GL gl = drawable.getGL ();
GLU glu = drawable.getGLU ();
gl.glViewport ( 0, 0, width, height );
gl.glMatrixMode ( GL.GL_PROJECTION );
gl.glLoadIdentity();
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
gl.glViewport( 0, 0, width, height );
glu.gluPerspective (60.0,width/height,1.0,2000.0);
}
}
public void displayChanged(GLDrawable arg0, boolean arg1, boolean arg2) {}
}