View Full Version : Direct3D to OpenGL

MikeC531

05-07-2010, 12:09 PM

I was wondering if someone could help me understand the differents between OpenGL equivelants to device.Transform.World = Matrix.Translation(dx, dy, dz) and

device.Transform.World *= Matrix.Translation(dx, dy, dz)

Thanks in advance

MikeC531

MikeC531

05-07-2010, 12:55 PM

Just basicly need to know where to put the:

glPushMatrix(); and glPopMatrix(); and

glLoadIdentity(); for the

= Matrix.Translation(dx, dy, dz) and the

*= Matrix.Translation(dx, dy, dz)

Thanks again

MikeC531

HAL-10K

05-07-2010, 05:13 PM

OpenGL doesn't feature utility functions like this.

You have to construct your own transform matrices (no big deal, right?).

Kelvin

05-07-2010, 09:10 PM

The (fixed function) OpenGL matrix commands operate directly on the matrix on top of the current "matrix stack":

You can use glLoadMatrix() to assign a defined matrix directly to the top ModelView, Projection or Texture matrix.

If you want to set the top matrix to a particular translation matrix, you can set it to identity, and then multiply it by a translation matrix, like so:

glLoadIdentity()

glTranslate()

If you want to multiply in an additional translation to the current matrix, all you need is this:

glTranslate()

If you want to save and restore the current matrix so you can undo the matrix changes after some drawing, you can use Push/Pop matrix and the above two cases become:

glPushMatrix()

glLoadIdentity()

glTranslate()

// draw some stuff

glPopMatrix // back to the matrix state before the push

and

glPushMatrix()

glTranslate()

// draw some stuff.

glPopMatrix()

But these OpenGL commands do not operate on "your" matrices. They operate on the OpenGL matrix stacks.

There are no OpenGL helper functions to provide generic manipulation of any matrices. Although you could read the resulting matrix off the top of the matrix stack with glGetFloatv, I suppose.

These matrix manipulation commands are more associated with the classic OpenGL fixed function pipeline, and I imagine they are rarely used with shaders (I believe they have been deprecated in recent GL specifications).

Powered by vBulletin® Version 4.2.5 Copyright © 2018 vBulletin Solutions Inc. All rights reserved.