Jump to content
  • Advertisement
Sign in to follow this  
DEVOXE

OpenGL Direct3D state stack

This topic is 4839 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 am trying to adopt from OpenGL to DirectX api and wondering if there is a stack mechanism in directx as well to push and pop back the states. To put it an other way, are there any glPush(), glPop() similiar functions? For instance, to render an object with blending support, should we set the proper states and take them back not to effect the next rendering object? Or any other ways to handle these kind of state changes? Thanks a lot for any ideas.

Share this post


Link to post
Share on other sites
Advertisement
You can save/capture and restore state blocks, but that's it.
There is no stack in D3D for render states.
You could always implement a state stack yourself, which is what I did for a good while.

Share this post


Link to post
Share on other sites
Quote:
Original post by sordid
You could always implement a state stack yourself, which is what I did for a good while.

Thanks for the information. BTW, do you think it is essential to code such a stack or just a design issue, trying to emulate the accustomed API? If you think it eases the life quite a bit, can you suggest some design tips to start with?

Share this post


Link to post
Share on other sites
I think he means a stack for state changes.

Never having used OpenGL, I've never even heard of a state stack before, but I can't really think of why I'd need one. You just set the render states that you need and draw; I'm not sure what advantages a stack would give me, as it's not like states are applied in a hierarchy.

Share this post


Link to post
Share on other sites
There is no state stack in OGL, only a Transform ( Matrix Stack ) and the ID3DXMatrixStack is similar to the one in OGL...

Share this post


Link to post
Share on other sites
For D3D state changes, I recommend that you use some sort of tree, instead of the traditional stack. Kind of like this:

Shader1 Shader2
|--------|--------| |--------|--------|
TextureSet1 TextureSet2 TextureSet3 TextureSet4
|--------|--------| ... ... ...
ConstantSet1 ConstantSet2
| |
Entity1 Entity5
Entity2 Entity6
Entity3
Entity4

This tree will let you efficiently managed and change all states - shaders, textures, constants, stream sources, and render states.

Share this post


Link to post
Share on other sites
Quote:
Original post by JoCCo
There is no state stack in OGL, only a Transform ( Matrix Stack )


There is a kind of mechanism to push and pop the current attributes with

glPushAttrib(BITFLAG) and glPopAttrib(). With this functionality you dont have to recode the states especially if that state needs a more than one function call.

Share this post


Link to post
Share on other sites
Quote:
Original post by circlesoft
For D3D state changes, I recommend that you use some sort of tree, instead of the traditional stack.


Thank you very much for the idea. I will give a try for the implementation.

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!