Can anybody tell me how exactly do we use GL_INT_2_10_10_10_REV as type parameter in glVertexAttribPointer() ? I am trying to pass color values using this type. Also what is the significance of "REV" suffix in this type ? Does it require any special treatment in the shaders ?
My code is as follows :
GLuint red=1023,green=1023,blue=1023,alpha=3;
GLuint val = 0;
val = val | (alpha << 30);
val = val | (blue << 20);
val = val | (green << 10);
val = val | (red << 0);
GLuint test_data[]={val,val,val,val};
loadshaders();
glBindAttribLocation(ps,0,"tk_position");
glBindAttribLocation(ps,1,"color");
LinkShader();
glUseProgram(ps);
glEnableVertexAttribArray (0);
glVertexAttribPointer(0, 4, GL_FLOAT, 0, 0, vertices);
glEnableVertexAttribArray (1);
glVertexAttribPointer(1,GL_BGRA,GL_UNSIGNED_INT_2_10_10_10_REV,GL_TRUE,0,test_data);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
The shaders are : Vertex Shader -
#version 150
in vec4 tk_position;
in vec4 color;
out vec4 v_color;
void main()
{
v_color = color;
gl_Position = tk_position;
}
Fragment shader -
#version 150
in vec4 v_color;
out vec4 fragColor;
void main()
{
fragColor = v_color;
}
The program object is validated as well. No issues there. This code works fine on AMD card,but fails on NVidia. Failing means I get NULL Pointer access at glDrawArrays() call.
Access violation
Exception Flag: 0x00000000
Exception Addr: 0x055f32ce