LWJGL
October 24, 2014, 11:44:13 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.9.1 released!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Weird numbers in glGetFloat( GL11.GL_MODELVIEW_MATRIX, fb)  (Read 2487 times)
sober
Newbie
*
Posts: 5


« on: July 31, 2005, 07:17:05 »

Here is the excamplecode:

I just open GL Stuff, call LoadIdentity and than glGetFloat()
normaly the Matrix should look like:

1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

so the System.out.println should print something like 1 right?

Well, I get a "Weird Number: 4.6006E-41"

Anyone around, who can tell me how to get Numbers I can work with?
I testet glGetInteger, glGetDouble and glGetPointer also, no better result...

Code:

import java.nio.ByteBuffer;
import java.nio.FloatBuffer;

import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.glu.GLU;

public class MatrixError
{
public static void main(String[] args)
{
new MatrixError();
}
public MatrixError()
{
try
{
DisplayMode dm = org.lwjgl.util.Display.getAvailableDisplayModes(
800,600,800,600,32,32,60,60)[0];
Display.setDisplayMode(dm);
Display.setFullscreen(false);
Display.create();
Display.setTitle("Error");

GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glClearColor(0.0f,0.0f,0.0f,0.0f);
GL11.glClearDepth(3.0f);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDepthFunc(GL11.GL_LEQUAL);
GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT,GL11.GL_NICEST);

        GL11.glViewport(0,0,800,600);
      GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glLoadIdentity();
        GLU.gluPerspective(45.0f,800f/600f,0.1f,100.0f);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glLoadIdentity();

        FloatBuffer fb = ByteBuffer.allocateDirect( 16*4).asFloatBuffer();
       
        GL11.glGetFloat( GL11.GL_MODELVIEW_MATRIX, fb);
        fb.rewind();
        System.out.println( "Weird Number: " + (float) fb.get());
        fb.rewind();
        Display.update();
    Display.destroy();
        System.exit(0);
}
catch( Exception e)
{
/* Don't ask ;) Quick and dirty */
}
}
}
Logged
Orangy Tang
Talks Too Much
***
Posts: 199



« Reply #1 on: July 31, 2005, 09:50:28 »

You didn't order your float buffer according to the native byte order. Instead use BufferUtils.createFloatBuffer() which does exactly that.
Logged
sober
Newbie
*
Posts: 5


« Reply #2 on: July 31, 2005, 10:41:10 »

Thanks, works perfectly.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!