Jump to content
  • Advertisement
Sign in to follow this  
mv348

Can't get integer vertex attributes to work with shader/vbo

This topic is 2304 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am able to get vec2, vec3, vec4 and float attributes to work, but I can't seem to get an integer vertex attribute to work.
Here's the process I'm using:


Data creation:

GLuint * int_array = new GLuint[lPolygonVertexCount];
for (int i=0; i < lPolygonVertexCount; i++)
{

int_array=(GLuint)2;
}


VBO creation:

glGenBuffers(VBO_COUNT, mVBONames);

...
glBindBuffer(GL_ARRAY_BUFFER, mVBONames[INT_VBO]);
glBufferData(GL_ARRAY_BUFFER, lPolygonVertexCount*sizeof(GLuint), int_array,GL_STATIC_DRAW);
delete[] int_array;


Before drawing:

GLint my_int_id = glGetAttribLocation(shader_program,"my_int");
...
glBindBuffer(GL_ARRAY_BUFFER, mVBONames[INT_VBO]);
glEnableVertexAttribArray(my_int_id);
glVertexAttribPointer(my_int_id,1, GL_UNSIGNED_INT, GL_FALSE, 0, 0);


shader:

attribute uint my_int;
void main()
{
...
}

The value of my_int always ends up being 0 and not 2. If I change all the relavent types to float, the attribute works just fine.
Any ideas for what the problem could be?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!