heinz85
01-17-2012, 02:37 PM
Hello.
I'm trying to pass attributes of vertices in my application to the vertex shader.
Here is the code for attribute passing:
GLuint inCentroidNormal =
glGetAttribLocation(m_program,"centroidNormal");
vec4 * centroidNormals = (*it)->getFlatShadingNormals();
GLsizei totalNormals = (*it)->getFlatShadingNormalsSize();
glBindBuffer(GL_ARRAY_BUFFER, buffer[TNORMAL_BUFFER_IDX]);
glBufferData(GL_ARRAY_BUFFER, totalNormals*sizeof(vec4),
centroidNormals, GL_STATIC_DRAW);
glEnableVertexAttribArray(inCentroidNormal);
glVertexAttribPointer(inCentroidNormal, 4, GL_FLOAT, GL_FALSE, 0,0);
But it is quite obvious from the output of the program that the outputs do not pass correctly since the color of the rendered triangle is different from what I expect, and when I hardcode into the shader, I DO get the expected result, so obviously the data is not passing as I expect it...
Is there anything wrong with the way I pass the vertex attribute "centroidNormal"?
The single vertex array I use is bound at the top of the code...
Thanks,
Heinrich
I'm trying to pass attributes of vertices in my application to the vertex shader.
Here is the code for attribute passing:
GLuint inCentroidNormal =
glGetAttribLocation(m_program,"centroidNormal");
vec4 * centroidNormals = (*it)->getFlatShadingNormals();
GLsizei totalNormals = (*it)->getFlatShadingNormalsSize();
glBindBuffer(GL_ARRAY_BUFFER, buffer[TNORMAL_BUFFER_IDX]);
glBufferData(GL_ARRAY_BUFFER, totalNormals*sizeof(vec4),
centroidNormals, GL_STATIC_DRAW);
glEnableVertexAttribArray(inCentroidNormal);
glVertexAttribPointer(inCentroidNormal, 4, GL_FLOAT, GL_FALSE, 0,0);
But it is quite obvious from the output of the program that the outputs do not pass correctly since the color of the rendered triangle is different from what I expect, and when I hardcode into the shader, I DO get the expected result, so obviously the data is not passing as I expect it...
Is there anything wrong with the way I pass the vertex attribute "centroidNormal"?
The single vertex array I use is bound at the top of the code...
Thanks,
Heinrich