Main Menu

glGetFloatv()

Started by TheSmit, September 19, 2006, 10:45:15

Previous topic - Next topic

TheSmit

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:

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


LWJGL eample of the same function:

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:

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?

Matzon

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.

TheSmit

thanks for your quick reply.

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