Errors with NeHe JOGL ports.

Hi everyone, I’m new here. Spent the last few days trawling these forums looking for a thread to participate in without making myself look a fool, with no luck! At last I have a reason post :slight_smile:

I’m working my way through the JOGL ports of the NeHe OpenGL tutorials, and I’ve come across some function calls that, as far as I can tell, don’t exist for me. An example would be the following code, found in lesson 2.

public void reshape(GLDrawable gLDrawable, int x, int y, int width, int height)
    {
      final GL gl = gLDrawable.getGL();
      final GLU glu = gLDrawable.getGLU();

      if (height <= 0) // avoid a divide by zero error!
        height = 1;
      final float h = (float)width / (float)height;
      gl.glViewport(0, 0, width, height);
      gl.glMatrixMode(GL.GL_PROJECTION);
      gl.glLoadIdentity();
      glu.gluPerspective(45.0f, h, 1.0, 20.0);
      gl.glMatrixMode(GL.GL_MODELVIEW);
      gl.glLoadIdentity();
    }

The first two function calls, to getGL() and getGLU(), I see very often in the tutorials I stumble across. However, to get this code working I’ve had to change it to:

public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
    {
    	final GL2 gl = drawable.getGL().getGL2();
        final GLU glu = new GLU();

        ...

        gl.glMatrixMode(GL2.GL_PROJECTION);
        ...
        gl.glMatrixMode(GL2.GL_MODELVIEW);
        ...
    }

Have certain functions been removed from the later versions of JOGL? If so, is there somewhere I can look to find all the changes? I’m relatively new to both Java and JOGL, and so I’m unsure if the workaround I’m being forced to use is the correct way to do so.

EDIT: Typo.

A lot of stuff has been removed from OpenGL, and NeHe is long out of date. Unfortunately I’m not sure what has replaced it.

The layout of JOGL changed a while back.

When the NeHe tutorials were written the GL interface was a collecting of every single function OpenGL supported. How ever OpenGL is layered into different versions and not every device/driver supports all those versions. To give the developer a greater control about the requirements of the application, the JOGL interface was changed to reflect the layers of OpenGL.

This page gives a good overview about the Jogl layout: link

Basically the GL interface now contains only those functions that are shared over every single version of OpenGL. For the most functions you need to specify your level of OpenGL more in detail.

At the end, the functions moved around, but none got removed. Everything is still there, you just have to find it.

Nitram

Thanks for the responses guys, and thanks a lot for the link :slight_smile:

I’m having trouble finding up-to-date tutorials, especially ones that have been ported to java. I bought myself the 3.0/3.1 edition of the OpenGL RedBook to get myself started, and getting the examples running with JOGL involves an annoying amount of trial and error for me :frowning: maybe I ought to rewrite a few of the NeHe tutorials myself for the current JOGL version once I get my head around it :smiley: