lookof
08-26-2011, 08:58 PM
Hi all,
I tried writing a practice program which is used to draw massive cubics using instance tech. I learnt it from here: http://sol.gfxile.net/instancing.html
I sent a matrix to vertex_shader as an attribute by using glVertexAttribPointer, and it works as expected. However, when I comment this matrix in the vertex shader , and instead used gl_ModelViewProjectionMatrix itself, it's failed to draw anything.
Actually the matrix I sent to the vertex_shader is an indentity matrix. It won't affect anything to the result.
So I want to ask why ? Must I use the attribute in the shader which is sent from the host program?
+++++vertex_shader+++++
attribute mat4 transMat;
void main(void)
{
mat4 mvp = gl_ModelViewProjectionMatrix * transMat ; // --works!
//mat4 mvp = gl_ModelViewProjectionMatrix ; // --failed!
gl_Position = mvp * gl_Vertex ;
gl_FrontColor = vec4(1, 0, 0, 0);
}
I tried writing a practice program which is used to draw massive cubics using instance tech. I learnt it from here: http://sol.gfxile.net/instancing.html
I sent a matrix to vertex_shader as an attribute by using glVertexAttribPointer, and it works as expected. However, when I comment this matrix in the vertex shader , and instead used gl_ModelViewProjectionMatrix itself, it's failed to draw anything.
Actually the matrix I sent to the vertex_shader is an indentity matrix. It won't affect anything to the result.
So I want to ask why ? Must I use the attribute in the shader which is sent from the host program?
+++++vertex_shader+++++
attribute mat4 transMat;
void main(void)
{
mat4 mvp = gl_ModelViewProjectionMatrix * transMat ; // --works!
//mat4 mvp = gl_ModelViewProjectionMatrix ; // --failed!
gl_Position = mvp * gl_Vertex ;
gl_FrontColor = vec4(1, 0, 0, 0);
}