iDevGames Forums
Unable to implement OES_matrix_palette - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: Unable to implement OES_matrix_palette (/thread-8102.html)



Unable to implement OES_matrix_palette - mariocaprino - Sep 14, 2010 09:43 AM

I've lately been trying to implement the OES_matrix_palette extension in my project. Sadly I am unable to get my test of vertex skinning working Sad

I've started a new OpenGL ES template in XCode - forcing it to use OpenGL ES 1 by default. I've used the example code at the end of the OES_matrix_palette extension description for implementation details.

I try to add the following code to the drawFrame() method:
Code:
//For my test-case we only have one "bone" - and try to use GL_MATRIX_PALETTE_OES to transform the vertices, rather than GL_MODELVIEW.
static const float squareWeights[] = {1, 1, 1, 1};
static const GLubyte squareMatrixIndices[] = {0, 0, 0, 0};

//Set up the additional pointers for matrix skinning of the template's cube
glWeightPointerOES (1, GL_FLOAT, 0, squareWeights);
glEnableClientState(GL_WEIGHT_ARRAY_OES);
glMatrixIndexPointerOES (1, GL_UNSIGNED_BYTE, 0, squareMatrixIndices);
glEnableClientState(GL_MATRIX_INDEX_ARRAY_OES);

//Transfer the GL_MODELVIEW matrix to PaletteMatrix 0
glMatrixMode(GL_MATRIX_PALETTE_OES);
glCurrentPaletteMatrixOES(0);
glLoadPaletteFromModelViewMatrixOES();

//Flush the GL_MODELVIEW matrix to make sure it does not have any influence over the vertex transform
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

My goal with the test-case is to have the cube move in the same pattern as the template - but using GL_MATRIX_PALETTE_OES to achieve the translation.

The cube is drawn in my test but without any translation applied! I'm obviously misunderstanding something about the extension - but what am I missing?

Thank you for your help.
Doh... found the answer after reading the "fine print" in the extension description. Don't they know we only look at the examples Wink

Naturally you have to enable the feature by calling glEnable (GL_MATRIX_PALETTE_OES) for vertex skinning to take effect!

Thank you for reading.