Some problems with new version :)

hi its been a while since i used jogl and i have noticed quite some changes
so i took a look at some examples but i am still a bit stuck with glu.gluLookAt()
is there some new method to do this now or?

this is my code:


import javax.media.opengl.*;
import javax.media.opengl.glu.*;

public class TestRenderer implements GLEventListener
{
    private GL gl;
    private GLU glu;
    private GLAutoDrawable glDrawable;

    public void init(GLAutoDrawable drawable)
    {
    	this.gl = drawable.getGL();
        this.glDrawable = drawable;
        glu = new GLU();
        
        drawable.setGL( new DebugGL(gl));

        System.out.println("Init GL is " + gl.getClass().getName());
    }

    public void display(GLAutoDrawable drawable)
    {
        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );
        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();

        gl.glColor3f(1.0f, 0.0f, 0.0f );

        gl.glBegin( GL.GL_TRIANGLES );
            gl.glVertex3f( 0.0f, 0.0f, 0.0f );
            gl.glVertex3f( 1.0f, 0.0f, 0.0f );
            gl.glVertex3f( 1.0f, 1.0f, 0.0f );
        gl.glEnd();
        
        gl.glBegin( GL.GL_TRIANGLES );
        	gl.glVertex3f( 0.0f, 0.0f, 0.0f );
        	gl.glVertex3f( -1.0f, 0.0f, 0.0f );
        	gl.glVertex3f( -1.0f, -1.0f, 0.0f );
        gl.glEnd();
        
    	glu.gluLookAt(	0.0, 10.0, -10.0,
				0.0, 0.0, 0.0,
				0.0, 1.0, 0.0);
    }

    public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
    {
    }

    public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
    {
    }
}

i can change the values of first line in glu.gluLookAt at anything i want the view still doenst change?
what do i do wrong? thx for the help

maybe it’s because you are in the projection matrix mode. try changing that to the modelview mode.

also, you dont seem to specifiy a viewport, in the init or reshape function as well as some other necessary stuff seems to be missing.

did this code ever work before?

i use the lookat method instead of a viewport at least that worked with earlier versions

One problem is that you’re doing the gluLookAt after you render your geometry. I think you should use something other than an identity projection matrix, but regardless, you should switch to the modelview matrix afterward, load the identity matrix, and then do your gluLookAt, before rendering your triangles.

The viewport is set up automatically by JOGL, but you can override its setting in your reshape() method.

so what class/methods do i best use to make some sort of camera?

I’d recommend you take a look at the ExaminerViewer class in the gleem package in the jogl-demos workspace. It’s used in several of the demos and works pretty well, and also supports interaction.

is there anyway is can still work with glu.gluLookAt()? cause i am quite used to it
when i do GLU glu = new GLU() in my init the glu appears to be null? :s
quite confused here :frowning:
thx for any helpa

If you really want to use gluLookAt I suggest looking at the source of Chris Campbell’s BezierAnim3D demo. He has a Camera object that uses gluLookAt so you can at least see how he did it.

http://download.java.net/javadesktop/blogs/campbell/2007.01.23/BezierAnim3D.zip