Sign in to follow this  
jhoward

Passing the model view matrix to and ARB vertex program

Recommended Posts

jhoward    122
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?

Share this post


Link to post
Share on other sites
MARS_999    1627
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 };



Share this post


Link to post
Share on other sites
rhummer    550
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

Share this post


Link to post
Share on other sites
_the_phantom_    11250
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]

Share this post


Link to post
Share on other sites
jhoward    122
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?

Share this post


Link to post
Share on other sites
MARS_999    1627
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...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this