Sign in to follow this  
bobrules

Repositioning Vertex in glsl

Recommended Posts

bobrules    102
Hi guys, I just started learning GLSL and was wondering how I would reposition an object? For example in my old fixed function code i would have

[code]
glRotatef ( -mCamera.mRotation.mY, 0, 1, 0 );
glTranslatef ( -mCamera.mPosition.mX, -mCamera.mPosition.mY, -mCamera.mPosition.mZ );
for ( all visible models )
{
glPushMatrix ();
glTranslatef ( model->mPosition.mX, model->mPosition.mY, model->mPosition.mZ );
model->Draw ();
glPopMatrix ();
}
[/code]


This is what I have for my programmable pipeline version:
[code]
CMatrix matrix;
matrix.SetProjection ( left, right, bottom blah ) ...
matrix.MultiplyByRotationMatrix ( -mCamera.mRotation.mY, 0, 1, 0 );

CMatrix copy = matrix;

for ( all visible models )
{
matrix = copy;
matrix.MultiplyByTranslationMatrix ( model->mPosition.mX, model->mPosition.mY, model->mPosition.mZ );
glUniformMatrix4fv ( projectionModelviewLocation, 1, false, matrix.AsFloatArray () );
model->Draw ();
}
[/code]

Is this the appropriate way to move my models? Thanks guys.

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