just another GLSL vertex attributes related question
category: code [glöplog]
I go like
Yeah I know I should align things.
then I get all
and it doesn't work.
when I
It works, and binding then getting doesn't work. What am I missing?
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?
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?
If nothing else, I'm pretty sure you want the pointer parameter to be a multiple of sizeof(float)?
Like:
Like:
Code:
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(float)*6, (void*)(sizeof(float) * 3));
/facepalm
OK. Thank you.
OK. Thank you.