glVertexAttribIPointer

Hej everybody,
I actually have a problem with sending 4 unsigned byte values to the gpu. To understand the problem I will give you some code snippets so you get an idea what I´m trying to do.

I define an VBO with my vertex attributes that only contains 4 simple unsigned Bytes.

glVertexAttribIPointer(0, 4, GL_UNSIGNED_BYTE, myVertexSize, ofs);

And in the vertex shader I map this values to an unsigned int like that

layout(location = 0) in uint in_data;

Afterwards I extract my values from the unsigned int value like that:
uvec4 dataBytes;
dataBytes[0] = (in_data& 0xff000000) >> 24;
dataBytes[1] = (in_data& 0x00ff0000) >> 16;
dataBytes[2] = (in_data& 0x0000ff00) >> 8;
dataBytes[3] = (in_data& 0x000000ff);

This actually does not work. I get data but values are wrong! But when I actually set the vertex Attribute like that glVertexAttribIPointer(0, 1, GL_UNSIGNED_INT, myVertexSize, ofs); everything works like expected.

Has anybody an idea why it is working with one GL_UNSIGNED_INT but not with four GL_UNSIGNED_BYTE?!

Your first case is mapping a 4 component attribute to a 1 component input data and you expect that to pack the data according to its byte size irrespective of the number of components.
Instead the logical result would be that the first attribute component is put into your one component input and the other three attribute components are dropped.

The second approach works because the number of components and type match.

That is correct…

Unfortunately putting/mapping the data into an 4 compononent attribute does not work either. (Sorry - I should have mentioned that in advance.)

So when I set up my data like this:
glVertexAttribIPointer(0, 4, GL_UNSIGNED_BYTE, myVertexSize, ofs);


layout(location = 0) in uvec4 in_data;


uvec4 dataBytes;
dataBytes[0] = in_data[0];
dataBytes[1] = in_data[1];
dataBytes[2] = in_data[2];
dataBytes[3] = in_data[3];

does not work for me. Actually it looks like the component values of in_data are all 0.

Can anybody reproduce the problem!?

Actually its no problem at all - just a performance issue in my eyes. I just want to know if the problem is me or if its an unsupported feature!?