Jump to content
  • Advertisement
Sign in to follow this  
gadem

OpenGL Finding similar OpenGL function in DirectX

This topic is 3696 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

I'm converting frrom OpenGL to DirectX, I have a problem, the function glGetFloatv(GL_MODELVIEW_MATRIX, mat) in opengl outputs the modelview matrix of the current object to the'mat' variable. Is there a corresponding function to use in DirectX? Much appreciated, ga'dem.

Share this post


Link to post
Share on other sites
Advertisement
DirectX doesn't have a concept of the "current object", the current object is just what you're about to render (or have just rendered, depending on your definition). You'd be responsible for keeping track of that matrix for each object you render, since DirectX doesn't have a concept of objects either (Just lists of vertices and triangles).

You can get the currently set world view and matrices (modelview in OpenGL is view * world in DirectX) with:

D3DXMATRIX matWorld, matView;
pDevice->GetTransform(D3DTS_WORLD, &matWorld);
pDevice->GetTransform(D3DTS_VIEW, &matView);

Share this post


Link to post
Share on other sites
You can call IDirect3DDevice9::GetTransform() to retrieve the matrix for a given world/view/projection/bone slot.

Bare in mind that this won't work for pure devices, but these have all but vanished in recent years so you're probably fine.

hth
Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by jollyjeffers
Bare in mind that this won't work for pure devices, but these have all but vanished in recent years so you're probably fine.
Really? Why's that? I still request pure devices in my code >_>

Share this post


Link to post
Share on other sites
Thank you for the quick reply, everything you wrote makes perfect sense if there is no predefined modelview, I'll continue reading up on DirectX and hopefully have my projects fully converted soon.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
DirectX doesn't have a concept of the "current object", the current object is just what you're about to render (or have just rendered, depending on your definition). You'd be responsible for keeping track of that matrix for each object you render, since DirectX doesn't have a concept of objects either (Just lists of vertices and triangles).

Neither has OpenGL. The OP was a little confused, it seems.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Quote:
Original post by jollyjeffers
Bare in mind that this won't work for pure devices, but these have all but vanished in recent years so you're probably fine.
Really? Why's that? I still request pure devices in my code >_>


Probably to prevent everyone and their dog from writing device wrappers to keep track of these variables themselves [wink] It seems odd to remove support for pure devices, but I guess advances in the drivers/runtime/architecture/CPUs makes the overhead of non-pure device only a marginal concern?

Share this post


Link to post
Share on other sites
Quote:
Original post by remigius
Probably to prevent everyone and their dog from writing device wrappers to keep track of these variables themselves [wink] It seems odd to remove support for pure devices, but I guess advances in the drivers/runtime/architecture/CPUs makes the overhead of non-pure device only a marginal concern?
Perhaps, but then I keep track of state information anyway so I can recover from a lost device nicely (rather than have each object that I render apply it's entire device state each render tick).

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Perhaps, but then I keep track of state information anyway so I can recover from a lost device nicely (rather than have each object that I render apply it's entire device state each render tick).


Well, looking at the way they went with XNA where nothing (neither sprites nor effects) saves state by default, just setting all device states as you need them would seem to be the latest best practice. I'm not sure what I think about this though [wink]

Share this post


Link to post
Share on other sites
My comments on pure devices was just my interpretation - I don't know of any specific decision for/against keeping them.

They originally popped up when there was still a lot of fixed function code floating around and theoretically it made sense to have a mode whereby the drivers/runtime could abdicate responsibility for maintaining app-visible state. Less responsibilities for them = lighter and tighter code.

That said, I never really noticed much performance difference between a regular HAL and PD device (on various GPU's I've owned) so I was sceptical as to whether the drivers really changed their behaviour much.

With D3D10 there doesn't strike me as being any case for the differentiation given that there are only a handful of state objects and its all shader based.

Quote:
just setting all device states as you need them would seem to be the latest best practice. I'm not sure what I think about this though
Interesting - I wasn't aware it behaved like that. Is this actually noticeable if you grab a PIX call stream? Do XNA apps generate many more Set**() calls per frame?

hth
Jack

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!