Jump to content
  • Advertisement
Sign in to follow this  
bobrules

Repositioning Vertex in glsl

This topic is 2559 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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!