Imagination PowerVR SDK Blog

Vertex color attributes


#1

PVFrame: SDK build 2.05.0782





I am having a bit of a problem trying to stream vertex color attributes. I have no problem with positions, uvs etc but for some reason can’t get colors to works.





It works with constant vertex attributes ie:





     glEnableVertexAttribArray(4);GL_ErrorCheck();


     glVertexAttrib4fv(1,color.ptr());GL_ErrorCheck();     





but it fails with my vertex arrays:





     glEnableVertexAttribArray(4);GL_ErrorCheck();


     glVertexAttribPointer(1,4,GL_FLOAT,0,0,afColors);GL_ErrorCheck();





Essentially, with custom vertex arrays, I always end up with 0,0,0,1 ( black) inside my shader, regardless of what is in the array.





I know my color array is fine ( the same array works with GLES 1.x ) but for some reason I just can’t get it to work with gles2.





I haven’t had a chance to test it with the real thing ( iPhone/iPad) but with PVFrame based emulation, it fails on 2 different graphics cards so I don’t think this is a driver issue.





I wondering if this is a known issue ( I couldn’t find anything, and as I mentioned it works fine with GLES 1.x)





Thanks


#2

Hi, others know more about this than I do, but I one problem of the code is that the first argument (the attribute location index) of all these functions should match. And the constant vertex attribute is only relevant if the vertex array is disabled. I.e. the first code should probably be:

glDisableVertexAttribArray(1);GL_ErrorCheck();


glVertexAttrib4fv(1,color.ptr());GL_ErrorCheck(); 

and the second code should be:

glEnableVertexAttribArray(1);GL_ErrorCheck();


glVertexAttribPointer(1,4,GL_FLOAT,0,0,afColors);GL_ErrorCheck();



Maybe the problem is that you have enabled the vertex attribute arrays for the wrong attribute location?





#3

Thanks





Actually, that was just my copying/pasting mistake.





Anyway, once I get update my provisioning on my apple devices I will try there and see … if it still doesn’t work then obviously something is wrong in my code.



#4

I got it … .it was some stupid coding mistake which happened not to have any effect on certain attribute definitions while screwing others.





Everything is cool again.