pouët.net

just another GLSL vertex attributes related question

category: code [glöplog]
 
I go like
Code: glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(float)*6, (void*)0); glEnableVertexAttribArray(0); glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(float)*6, (void*)3); glEnableVertexAttribArray(1);

Yeah I know I should align things.

then I get all
Code: unsigned sp = glCreateProgram(); /* attach shaders and that */ glBindAttribLocation(sp, 0, "ATTRIB_A"); glBindAttribLocation(sp, 1, "ATTRIB_B"); glLinkProgram(sp);

and it doesn't work.

when I
Code: glVertexAttribPointer(glGetAttribLocation(sp, "ATTRIB_A"), 3, GL_FLOAT, GL_FALSE, sizeof(float)*6, (void*)0); glVertexAttribPointer(glGetAttribLocation(sp, "ATTRIB_B"), 3, GL_FLOAT, GL_FALSE, sizeof(float)*6, (void*)3);

It works, and binding then getting doesn't work. What am I missing?
added on the 2010-07-15 06:23:26 by xernobyl xernobyl
I want the glBindAttribLocation way of doing it and it's not working. From my interpretation of the OpenGL 3.2 specification it should work. Ideas?
added on the 2010-07-15 06:31:35 by xernobyl xernobyl
If nothing else, I'm pretty sure you want the pointer parameter to be a multiple of sizeof(float)?

Like:

Code: glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(float)*6, (void*)(sizeof(float) * 3));
added on the 2010-07-15 08:58:54 by leblane leblane
/facepalm

OK. Thank you.
added on the 2010-07-15 14:48:33 by xernobyl xernobyl

login