Updating to LWJGL 0.7

Working on getting my stuff from 0.6 to 0.7.

Couple questions.

  1. Have you removed Quadrics??? I understand that you were wanting to move all quadrics (sphere, cylinder, etc) to native Java, but why, oh why, did you remove it before the new version was ready??

  2. Can you point me to a good example to use for obtaining matrix information via glGetFloatv.

  1. Coz our implementation, though it sorta worked, was too clunky. The JOGL GLU stuff is the right way to go, being implemented in pura Java, and we might have to pinch it.


FloatBuffer matrix = ByteBuffer.allocateDirect(64).order(ByteOrder.nativeOrder()).asFloatBuffer();
...
matrix.clear();
GL.glGetFloat(GL.GL_MODELVIEW_MATRIX, matrix);

Ok, things are going well now. I have most everything working now. Just a few anomilies. First, my bitmap font is not displaying. I can’t see anything wrong with what I’m doing…

here’s the old code:


public void print(int x, int y, String text, int set) {
        if (set > 1) {
            set = 1;
        } else if (set < 0) {
            set = 0;
        }

        TextureManager.getTextureManager().bind(texId);
        
        //set the GL states to how we want them.
        if(isBlended) {
            gl.enable(GL.BLEND);
        }
        gl.disable(GL.DEPTH_TEST);
        gl.enable(GL.TEXTURE_2D);
        gl.matrixMode(GL.PROJECTION);
        gl.pushMatrix();
        gl.loadIdentity();
        gl.ortho(0, gl.getWidth(), 0, gl.getHeight(), -1, 1);
        gl.matrixMode(GL.MODELVIEW);
        gl.pushMatrix();
        gl.loadIdentity();
        gl.translated(x, y, 0);
        gl.listBase(base - 32 + (128 * set));

        //Put the string into a "pointer"
        ByteBuffer scratch = ByteBuffer.allocateDirect(text.getBytes().length);
        scratch.put(text.getBytes());
        gl.color4f(red,green,blue,alpha);
        //call the list for each letter in the string.
        gl.callLists(
            text.length(),
            GL.BYTE,
            Sys.getDirectBufferAddress(scratch));
        
        //reset the GL states.
        if(isBlended) {
            gl.disable(GL.BLEND);
        }
        gl.matrixMode(GL.PROJECTION);
        gl.popMatrix();
        gl.matrixMode(GL.MODELVIEW);
        gl.popMatrix();
        gl.enable(GL.DEPTH_TEST);
        gl.disable(GL.TEXTURE_2D);
    }


and the ported code:


public void print(int x, int y, String text, int set) {
        if (set > 1) {
            set = 1;
        } else if (set < 0) {
            set = 0;
        }

        TextureManager.getTextureManager().bind(texId);

        //set the GL states to how we want them.
        if (isBlended) {
            GL.glEnable(GL.GL_BLEND);
        }
        GL.glDisable(GL.GL_DEPTH_TEST);
        GL.glEnable(GL.GL_TEXTURE_2D);
        GL.glMatrixMode(GL.GL_PROJECTION);
        GL.glPushMatrix();
        GL.glLoadIdentity();
        GL.glOrtho(0, Window.getWidth(), 0, Window.getHeight(), -1, 1);
        GL.glMatrixMode(GL.GL_MODELVIEW);
        GL.glPushMatrix();
        GL.glLoadIdentity();
        GL.glTranslatef(x, y, 0);
        GL.glListBase(base - 32 + (128 * set));

        //Put the string into a "pointer"
        ByteBuffer scratch =
            ByteBuffer.allocateDirect(text.getBytes().length);
        scratch.put(text.getBytes());
        GL.glColor4f(red, green, blue, alpha);
        //call the list for each letter in the string.
        GL.glCallLists(scratch);

        //reset the GL states.
        if (isBlended) {
            GL.glDisable(GL.GL_BLEND);
        }
        GL.glMatrixMode(GL.GL_PROJECTION);
        GL.glPopMatrix();
        GL.glMatrixMode(GL.GL_MODELVIEW);
        GL.glPopMatrix();
        GL.glEnable(GL.GL_DEPTH_TEST);
        GL.glDisable(GL.GL_TEXTURE_2D);
    }


The main difference being:


//Put the string into a "pointer"
        ByteBuffer scratch =
            ByteBuffer.allocateDirect(text.getBytes().length);
        scratch.put(text.getBytes());
        GL.glColor4f(red, green, blue, alpha);
        //call the list for each letter in the string.
        GL.glCallLists(scratch);

Yet nothing displays to the screen. All the remaining code stayed the same (except for the static GL calls), but I can also put up anything else you’d like to see.

i think you need a scrach.flip() after your scratch.put(…) but i could be wrong :smiley:

Not only were you not wrong… you were right! Thanks a lot nala.

I’d also chuck in a .order(ByteOrder.nativeOrder()) as well if I were you, just to avoid headaches later.

i agree… good catch ;D