Passing the model view matrix to and ARB vertex program
How can I pass the current model view matrix to my vertex program? As I understand, I can pass a float4 array variable by using:
glProgramLocalParameter4fARB(type, index, x, y, z, w);
or
glProgramLocalParameter4vfARB(type, index, v);
Is there an equivalent to passing a 4x4 matrix, so that it can be used in the vertex program?
Quote:Original post by jhoward
How can I pass the current model view matrix to my vertex program? As I understand, I can pass a float4 array variable by using:
glProgramLocalParameter4fARB(type, index, x, y, z, w);
or
glProgramLocalParameter4vfARB(type, index, v);
Is there an equivalent to passing a 4x4 matrix, so that it can be used in the vertex program?
I don't know why you would do that when you can just get the matrix in the VP
PARAM mvp[4] = { state.matrix.mvp };
You have access to pretty much all the OpenGL state settings in a VP using GLSL anything prefixed with gl_ is reserved for use by GLSL. so the model view matrix is gl_ModelViewMatrx
Quote:Original post by rhummer
You have access to pretty much all the OpenGL state settings in a VP using GLSL anything prefixed with gl_ is reserved for use by GLSL. so the model view matrix is gl_ModelViewMatrx
while what you said is indeed true the OP was talking about the vertex program interface not the GLSL vertex shader interface [smile]
OK, thanks for the replies so far. I'm using Cg for the GPU programming (as opposed to GLSL) and using the Cg compiler with the -profile arbvp1.
However, I can't anything to render on the screen. I've even tried using the vertex program in the Cg documentation (with a little bit of modification). The program looks like this:
void main(
in float4 position : POSITION,
in float4 color : COLOR0,
in float4 texCoord : TEXCOORD0,
out float4 positionO : POSITION,
out float4 colorO : COLOR0,
out float4 texCoordO : TEXCOORD0)
{
positionO = mul(position, glstate.matrix.mvp);
colorO = color;
texCoordO = texCoord;
}
When the vertex program is enabled, nothing is rendered on the screen. When it is disabled, I get my polygons as normal. I made sure my clear colour wasn't black, just in case for some reason the polygons were getting rendered as black.
Can anyone think of what I'm doing wrong here?
However, I can't anything to render on the screen. I've even tried using the vertex program in the Cg documentation (with a little bit of modification). The program looks like this:
void main(
in float4 position : POSITION,
in float4 color : COLOR0,
in float4 texCoord : TEXCOORD0,
out float4 positionO : POSITION,
out float4 colorO : COLOR0,
out float4 texCoordO : TEXCOORD0)
{
positionO = mul(position, glstate.matrix.mvp);
colorO = color;
texCoordO = texCoord;
}
When the vertex program is enabled, nothing is rendered on the screen. When it is disabled, I get my polygons as normal. I made sure my clear colour wasn't black, just in case for some reason the polygons were getting rendered as black.
Can anyone think of what I'm doing wrong here?
I am not sure but can you check for errors when loading the vertex program? I know that if you have any errors in either Vp/Fp you will not get anything to render...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement