• Advertisement
Sign in to follow this  

Repositioning Vertex in glsl

This topic is 2413 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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


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 ();
}



This is what I have for my programmable pipeline version:

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 ();
}


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

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement