Reputation: 197
I'm using the OpenGL core profile, version 3.3
When I call glVertexAttribPointer I get GL_INVALID_OPERATION. I've already checked out http://www.opengl.org/sdk/docs/man3/xhtml/glVertexAttribPointer.xml
struct
{
GLuint program;
GLint uni_texture;
GLint att_coord;
} shader_fbo;
...
shader_fbo.att_coord = glGetAttribLocation(shader_fbo.program, "coordIn");
glGenVertexArrays(1, &vao);
glGenBuffers(1, &vbo);
/*shader_fbo.att_coord stores now 0*/
/*vao stores now 1*/
...
GLfloat vertices[] = { -1.0, -1.0,
-1.0, 1.0,
1.0, -1.0,
1.0, 1.0 };
GLubyte indices[] = { 0, 1, 2,
1, 2, 3 };
...
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBindVertexArray(vao);
glEnableVertexAttribArray(shader_fbo.att_coord);
glVertexAttribPointer(shader_fbo.att_coord,
2,
GL_FLOAT,
GL_FALSE,
0,
vertices);
...
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices);
And here comes my vertex shader
#version 330
in vec2 coordIn;
out vec2 coordFS;
void main() {
gl_Position = vec4(coordIn, 0.0, 1.0);
coordFS = (1.0+coordIn)/2.0;
}
It compiles and links without any errors.
Update: glVertexAttribPointer works now but I get a GL_OUT_OF_MEMORY error when I call glDrawElements. The code is updated.
Upvotes: 0
Views: 606
Reputation: 1846
GL_INVALID_OPERATION is generated if zero is bound to the GL_ARRAY_BUFFER buffer object binding point and the pointer argument is not NULL.
You don't seem to have bound the buffer object. glVertexAttribArray associates the most recently buffer object with the specified vertex attribute.
Upvotes: 2