about glGetFloat

I can’t use glGetFloat() function well. please help me.

I wrote this code.


GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
GL11.glScalef(10.f, 10.f, 10.f);
FloatBuffer FB = ByteBuffer.allocateDirect(16 * 4).asFloatBuffer();
GL11.glGetFloat(GL11.GL_MODELVIEW, FB);

for(int i = 0 ; i < 16 ; ++i)
{
  System.out.println(FB.get(i));
}

but, this program out put this.
0.0
0.0
0.0
0.0

0.0
all Zero.
this output is not good.
it is different from I expected.
Where is wrong?

I’m Japanese. So My English may have some problems. Please pardon me.


GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
GL11.glScalef(10, 10, 10);
FloatBuffer modelview = BufferUtils.createFloatBuffer(16);
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelview);
for(int i = 0 ; i < 16 ; i++)
{
  System.out.println(modelview.get(i));
}

Mike

The answer is here:
http://lwjgl.org/forum/index.php?topic=1215.0

Mickelukas, rewind() is not necessary in this case, isn’t it?

Thank you for your appropriate answers !

I could get good program output,
because I used BufferUtils.createFloatBuffer() Instead of BufferUtils.createFloatBuffer(),
I used glGetFloat(GL11.GL_MODELVIEW_MATRIX…) Instead of glGetFloat(GL11.GL_MODELVIEW…)

My problem is solved!.
Thank you.

Those are the same thing :stuck_out_tongue:

oh … miss take! :o
I used BufferUtils.createFloatBuffer() Instead of ByteBuffer.allocateDirect(16 * 4).asFloatBuffer();

Haha alright :slight_smile:

That’s true, I copied the necessary lines from my code and it snuck in :slight_smile: I’ve adjusted my code so that no one spreads it.

Mike