I have made a very simple jogl thingy with just a wire spehere and when I resize or make the canvas redraw in some way the spehere rotates…
Anybody who knows why?
thx
I have made a very simple jogl thingy with just a wire spehere and when I resize or make the canvas redraw in some way the spehere rotates…
Anybody who knows why?
thx
Knowing without code will be difficult, but maybe you forget to call glLoadIdentity (or reset your projection matrix, …) in your display method which will be called each time you resize the Canvas.
public void init(GLAutoDrawable drawable)
{
GL gl = drawable.getGL();
gl.glClearColor(0, 0, 0, 0);
gl.glEnable(GL.GL_DEPTH_TEST);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(-1, 1, -1, 1, -1, 1);
}
public void display(GLAutoDrawable drawable)
{
GL gl = drawable.getGL();
GLU glu = new GLU();
GLUT glut = new GLUT();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
glu.gluLookAt(0,0,0, 1,1,1, 0,1,0);
gl.glColor4d(1,0,0,1);
glut.glutWireSphere(1, 100, 100);
}
Do you implement the reshape method?
gluLookAt multiplies the current matrix; it doesn’t replace it. You should switch to the modelview matrix and call glLoadIdentity() before calling gluLookAt.
thx Ken Russell … stupido me=)