Hello Guest

glGetFloatv()

  • 2 Replies
  • 13425 Views
glGetFloatv()
« on: September 19, 2006, 10:45:15 »
My question relates to approximating the C++ getFloatV()  in LWJGL. My examples are taken from NeHe tutorial22 (so I assume as working) and the LWJGL equivalents are taken from Mark Bernards LWJGL conversion of the same(also assumed as working).



C++ example:

Code: [Select]
GlFloat Minv[16];
glGetFloatv(GL_MODELVIEW_MATRIX,Minv);
....
VMatMult(Minv,l);


LWJGL eample of the same function:

Code: [Select]
float Minv[]=newfloat[16];
ByteBuffer temp = ByteBuffer.allocateDirect(64);
temp.order(ByteOrder.nativeOrder());
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, (FloatBuffer)temp.asFloatBuffer());
temp.asFloatBuffer().get(Minv);
....
VMatMult(Minv,l);


showing that after all the buffer stuff, Minv can be used in exactly the same way as in the C++ code


the same C++ code is used in a later method but the LWJGL code is different:

Code: [Select]
float Minv[]=newfloat[16];
ByteBuffer temp = ByteBuffer.allocateDirect(64);
temp.order(ByteOrder.nativeOrder());
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, (FloatBuffer)temp.asFloatBuffer().put(Minv).flip());
....
VMatMult(Minv,l);




My question is :- is this merely a different way of achieving the same thing or is something different happening?

*

Offline Matzon

  • *****
  • 2242
glGetFloatv()
« Reply #1 on: September 19, 2006, 11:57:26 »
the first one is writing to an empty buffer
the second one is a bit different, since it adds the old values to the buffer, flips it and writes the values.
Why thats being done in the 2nd example. I have no idea of.

glGetFloatv()
« Reply #2 on: September 19, 2006, 12:13:59 »
thanks for your quick reply.

so, if I was to use this, I should probably use the first example each time?