INVALID_OPERATION on glVertexAttribPointer on 3.2+

(…on ATI only.)

I heard it’s related to offset being zero or something similar but I don’t really understand it.

e.g. now I have

glVertexAttribPointer(in_Vertex_location, 3, GL_FLOAT, GL_FALSE, 6sizeof(GLfloat), BUFFER_OFFSET(0));
glVertexAttribPointer(in_Normal_location, 3, GL_FLOAT, GL_FALSE, 6
sizeof(GLfloat), BUFFER_OFFSET(3*sizeof(GLfloat)));

where BUFFER_OFFSET(i) is ((char *)NULL + (i))

What should change to be proper?

(…on ATI only.)

You probably didn’t create a vertex array object. Just create one in your initialization code. This is required by the OpenGL 3.2+ core specifications, but NVIDIA tends to play somewhat loose with the spec.

Interesting, why not just do:

BUFFER_OFFSET(i) ((char const*)(i))

works for me.

I guess I’ll have to create one. But what’s the point. Will it be an empty one with nothing in it?

EDIT: oh, I think I misunderstood something fundamental. VAOs are not old Vertex Arrays but something added on 3.0. I’ll have to read about it.

That didn’t fix it.

Notice it’s something I didn’t notice on NVIDIA on 3.3 core context but I see on ATI unless it’s on 3.1.

ok, I understood what it is but this puzzles me:

Are vertex buffer objects required?

I understand it’s cleaner code but can one draw in OpenGL 3.2+ without one?

e.g. I made a ‘dummy’ one, it didn’t get any data (or any proper data) and now the scene is blank. I suppose that’s normal but it poses the question, are VAOs required?

[Does NVIDIA ‘automatically’ create one for each vertexattribpointer?]

Are vertex buffer objects required?

I understand it’s cleaner code but can one draw in OpenGL 3.2+ without one?

Are you talking about vertex buffer objects or vertex array objects? Because these are two completely different things.

Both are required for GL 3.2 core. Neither is required for GL 3.2 compatibility.

Sorry I meant, vertex array objects.

oh, interesting.

I guess NVIDIA didn’t help write better code. ATI forces properly the context so it won’t let me run a core context without vertex array objects in use.

Only problem is if it’s complex enough, it’s hard to incorporate it properly…

Now I’m trying to figure out what exactly must be ‘grouped’…

Now I’m trying to figure out what exactly must be ‘grouped’…

There’s nothing to properly group. There’s nothing complex here. After you create your context, just put these three lines in:


GLuint vao;
glGenVertexArray(1, &vao);
glBindVertexArray(vao);

And everything works exactly as it did before.

Yeah, it is the dummy vao trick.

It did not work here properly. I was a getting a blank screen (without error).

However, it did work properly after I properly grouped the relevant (state) calls anyway (in various VAOs for each mesh I was drawing), which is I suppose the best.

I suppose I did something (wrong) in between that disrupted the normal operation or it’s a bug.