LWJGL Forum

Programming => General Java Game Development => Topic started by: sys0r on March 03, 2005, 23:26:00

Title: glMultMatrix .. quiz: what's wrong
Post by: sys0r on March 03, 2005, 23:26:00
The Code:

float bb[]=new float[]{
   1,0,0,0,
   0,1,0,0,
   0,0,1,0,
   0,0,0,1
   }; // NORMALMATRIX (=

FloatBuffer buffer = ByteBuffer.allocateDirect(16*4).asFloatBuffer();
buffer.put(bb);
buffer.rewind(); //  have i to rewind the buffer ?!?
GL11.glMultMatrix(buffer);
// Draw Something
GL11.glPopMatrix();


i'm not very good in math, but isn't:
MATRIX * NORMALMATRIX = MATRIX ?

why i get none my beautiful polygons on the screen if i use glMultMatrix ? if i remark glMultMatrix it works...
Title: glMultMatrix .. quiz: what's wrong
Post by: tomb on March 04, 2005, 01:26:59
When creating a direct buffer you need to specify the byte order:
ByteBuffer.allocateDirect(16*4).order(ByteOrder.nativeOrder()).asFloatBuffer();

Also make sure that popMatrix matches a pushMatrix.
Title: glMultMatrix .. quiz: what's wrong
Post by: sys0r on March 04, 2005, 10:29:04
thank you nativebyteorder is the solution