AnsweredAssumed Answered

Problem when rendering with a single VBO containing only GL_BYTE data

Question asked by james on Feb 18, 2013
Latest reply on Feb 21, 2013 by nowhere-01

If I try to render using a single VBO which only contains GL_BYTE or GL_UNSIGNED_BYTE data the input to my vertex shader seems to be constantly 0 regardless of the data i have put into the VBO (though on an Nvidia card the data shows up as expected)

 

If I create a 2nd, unused, dummy VBO attach it to the VAO's vertex attribute description and fill with GL_FLOAT data then the input to the shader appears as expected.

 

For example if i have the shader:

#version 420 core
layout(location = 5) in unsigned int inByte;
out vec3 colour;
void main()
{
    if(inByte==0)
    {
        colour = vec3(1,0,0);
        gl_Position = vec4(-0.5, -0.5, 0 ,1.0);
    }
    else if(inByte==1)
    {
        colour = vec3(0,1,0);
        gl_Position = vec4(0.5, -0.5, 0 ,1.0);
    }
    else
    {
        colour = vec3(0,0,1);
        gl_Position = vec4(0.0, 0.5, 0 ,1.0);
    }
}

 

and i try glDrawArrays(GL_TRIANGLES, 0, 3); using the VAO:

glBindVertexArray(vao);
glBindBuffer(GL_ARRAY_BUFFER, ab_byte);
glVertexAttribIPointer(5, 1, GL_UNSIGNED_BYTE, sizeof(unsigned char), BUFFER_OFFSET(0));
glEnableVertexAttribArray(5);

nothing shows up. (ab_byte is filled with unsigned char [] = {0,1,2})

 

however changing the vao to this

glBindVertexArray(vao);
glBindBuffer(GL_ARRAY_BUFFER, ab_byte);
glVertexAttribIPointer(5, 1, GL_UNSIGNED_BYTE, sizeof(unsigned char), BUFFER_OFFSET(0));
//dummy buffer
glBindBuffer(GL_ARRAY_BUFFER, ab);
glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, sizeof(float), BUFFER_OFFSET(0));
glEnableVertexAttribArray(5);
glEnableVertexAttribArray(0);

(where ab is filled with float [] = {0,0,0}, and the shader and draw call are unchanged)

allows me to draw the triangle as originally intended even though the data in ab is never used.

 

Is this an issue with ATI cards? or have i misunderstood the spec?

 

Thanks for any help.

 

(I am using an A10-4655M APU with Radeon 7620G if that helps)

Outcomes