I’m trying to use glVertexAttribPointer instead of the normal glVertexPointer, glColorPointer, etc. But I can’t get it to work in my program. Shouldn’t these be equivalent?

glColorPointer(4, GL_FLOAT, sizeof(SVertexBasis), &vl->dux);


glVertexAttribPointerNV(3, 4, GL_FLOAT, sizeof(SVertexBasis), &vl->dux);

But, while the first works perfectly with my vertex program, the second does absolutely nothing at all. Using the glVertexAttribPointer function, my scene is rendered with whatever color was last set with glColor. I have the same problem if I try and use glVertexAttribPointer(0, …) instead of glVertexPointer. Can anyone tell me what I’m doing wrong? I’ve tried calling the glGetVertexAttribPointer to see if it was even getting set, but it returns the correct address to my data. Is there another state that I may be forgetting to set?


BTW, here’s the vertex program I’m using. It was originally more complicated, but I stripped it down to just this while trying to debug this problem.

DP4 o[HPOS].x, c[0], v[0];
DP4 o[HPOS].y, c[1], v[0];
DP4 o[HPOS].z, c[2], v[0];
DP4 o[HPOS].w, c[3], v[0];
MOV o[TEX0], v[8];
MOV o[TEX1], v[9];

MOV o[COL0], v[3];

I’ve done exactly like that in the past ( just checked some old code ) and it should work. The only difference is that I use 3 for the size where as you have 4. It shouldn’t make a difference though. Maybe you w coordinates are messed up but then your original code should not work either…

Okay, I feel stupid! My vertex program was originally much more complicated, and while trying to fix a problem with it, I stripped it down to do just basic texturing and lighting. Well, when I then made the changes to use the vertexAttribPointer function, I apparently messed it up so it never activated the vertex program. I didn’t realize the scene was being rendered with the standard fixed-function pipeline. And it looks like AttribPointer’s are ignored if there isn’t an active vertex program. So I guess that’s why using glVertexPointer, glColorPointer, etc. worked, but not glAttribPointer.

(Banging my head on a wall)


Also be careful to use glVertexPointer(…)
or glVertexAttribPointer(0,…), but not both.

If both client arrays are enabled (generic attribute or conventional arrays) the conventional array always takes precedence.

Thanks -