Jump to content
  • Advertisement
Sign in to follow this  
smally

OpenGL Viewing Matrix problems

This topic is 4074 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, I need some help to do with my viewing matrix in OpenGL. I am new to open and used to using Direct3D so bear with me. I am trying to set the Viewmatrix, previously I have just be doing: glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); // Eyepos, InterestPos, Up vec glu( 3, 4, 5, 0, 0, 0, 0, 1, 0 ); But I have now implemented a moving camera, in Direct3D I did it like this: D3DXMATRIX rotateHeading, rotateIncline, playerPos, cameraPos; D3DXMatrixRotationY (&rotateHeading, heading); D3DXMatrixRotationX (&rotateIncline, incline); D3DXMatrixTranslation(&playerPos, position.x, position.y, position.z); D3DXMatrixTranslation(&cameraPos, cameraPosX, cameraPosY, cameraPosZ); D3DXMATRIX StepOne = rotateHeading * rotateIncline; D3DXMATRIX StepTwo = playerPos * StepOne; D3DXMATRIX StepThree = cameraPos * StepTwo; d3dDevice->SetTransform(D3DTS_VIEW, &StepThree); This is my flexible camera withough the use of the matrix LookAt, how do I go about doing this but for OpenGL? [Edited by - smally on May 23, 2007 1:35:00 PM]

Share this post


Link to post
Share on other sites
Advertisement
In OpenGL you don't have a matrix class so you'll have to use a 3rd party library or create your own matrix class.

I also started with DirectX but then moved on to OpenGL. However, I had my own matrix class from the beginning which I use to create the camera matrix from scratch and load it to D3D/OpenGL. This class supports the general matrix operations like multiplication, transposing etc. and has constructors for various matrix types (like translation, rotation, camera like gluLookAt() ).

When converting from D3D to OpenGL you should remember that OpenGL and D3D may use different matrix layouts, so transposing the matrice might me necessary.

Share this post


Link to post
Share on other sites
Quote:
Original post by Lord_Evil
When converting from D3D to OpenGL you should remember that OpenGL and D3D may use different matrix layouts, so transposing the matrice might me necessary.


In particular, matrices in OpenGL are column-major, whereas in DirectX they are row-major (or, more specifically, D3DMATRIX is).

Also, OpenGL has some support for simple matrix operations. Functions such as glRotate* and glTranslate* will do pretty much what you expect them to do with the current matrix stack.

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!