Jump to content
  • Advertisement
Sign in to follow this  
nini

OpenGL OpenGL model view transform

This topic is 4500 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 all , I'm new to OpenGL so it may seem stupid for you... I know D3D well , but i want my renderer to work either with D3D or OpenGL API for portability purpose.. The world transform (D3DTS_WORLD) does not exist in opengl so here is what i think to be true about openGL : modelview transform = world * camera view matrix but how to set a world transform only without changing the view matrix... actually i do this but it don't works (why ?) glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glLoadMatrixf(Camera.View.GetOpenglMatrix()); // then to set the world transform glPushMatrix(); glLoadMatrixf(Object.World.GetOpenglMatrix()); Object.Render(); glPopMatrix(); what is wrong with this method? thanx for your help

Share this post


Link to post
Share on other sites
Advertisement
You might give the following changes a try:
glMatrixMode(GL_MODELVIEW);
// Don't need this line, since the next line overwrites it anyway
//glLoadIdentity();
glLoadMatrixf(Camera.View.GetOpenglMatrix());

glPushMatrix();
//glLoadMatrixf(Object.World.GetOpenglMatrix());
// Calling glLoadMatrixf() here overwrites the view matrix, which
// I'm guessing isn't what you want. Instead, you want to
// combine the transforms, like this:
glMultMatrixf(Object.World.GetOpenglMatrix());
Object.Render();
glPopMatrix();

Share this post


Link to post
Share on other sites
Quote:
Original post by jyk
You might give the following changes a try:
glMatrixMode(GL_MODELVIEW);
// Don't need this line, since the next line overwrites it anyway
//glLoadIdentity();
glLoadMatrixf(Camera.View.GetOpenglMatrix());

glPushMatrix();
//glLoadMatrixf(Object.World.GetOpenglMatrix());
// Calling glLoadMatrixf() here overwrites the view matrix, which
// I'm guessing isn't what you want. Instead, you want to
// combine the transforms, like this:
glMultMatrixf(Object.World.GetOpenglMatrix());
Object.Render();
glPopMatrix();


okay that was it ! thank you very much jyk , you've been already answer me for a matrix question so again thank you , now that thing works , i can go deeper...

Share this post


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