Sign in to follow this  
Deathlike

GUI Objects

Recommended Posts

Hello folks, 

 

I'm trying to render a super simple GUI object (like a square that "overlaps" the actual game scene). A GUI object should always stay on screen, overlapping any other object and, most important, must stand still where it is. 

 

How can I achieve so?

 

I think a solution could be to render the object without setting up the zbuffer. So that object will always appear on screen. But I'm not sure that it would work. Also, I would need to create another device context to achieve so.

 

Another solution could be to manually edit the view matrix so the object stands still in place. But is it even possible?

 

I know the "best" solution is to use an external library, but I would like to avoid it. Also, I don't really need it. I just need a simple square that overlaps the game scene anyway.

 

Thanks in advance.

 

Share this post


Link to post
Share on other sites

Yeah, you need to do these things:

  1. Not use the depth buffer
  2. Use a different projection matrix (2D instead of 3D)
  3. Render it after the 3D scene (so it's on top of it)

That's the simplest way to render UI elements. And of course undo all that when you start rendering 3D again the next frame!

Share this post


Link to post
Share on other sites

Yeah, you need to do these things:

  1. Not use the depth buffer
  2. Use a different projection matrix (2D instead of 3D)
  3. Render it after the 3D scene (so it's on top of it)

That's the simplest way to render UI elements. And of course undo all that when you start rendering 3D again the next frame!

 

That's what I meant! Now:

 

1. Ho do I "turn off" the depth buffer? Because, I'm setting it up as soon as I initalize the D3D device.

2. Sorry, what is it? XD

 

Thanks for answers.

Share this post


Link to post
Share on other sites

1. Ho do I "turn off" the depth buffer? Because, I'm setting it up as soon as I initalize the D3D device.

 

You can turn it off and on at will by specifying a new depth stencil state:

https://msdn.microsoft.com/en-us/library/windows/desktop/bb205074(v=vs.85).aspx 

 

(set DepthEnable to FALSE in the D3D11_DEPTH_STENCIL_DESC)

Share this post


Link to post
Share on other sites

 

1. Ho do I "turn off" the depth buffer? Because, I'm setting it up as soon as I initalize the D3D device.

 

You can turn it off and on at will by specifying a new depth stencil state:

https://msdn.microsoft.com/en-us/library/windows/desktop/bb205074(v=vs.85).aspx 

 

(set DepthEnable to FALSE in the D3D11_DEPTH_STENCIL_DESC)

 

 

2nd EDIT: I've found the jigsaw I was missing: https://msdn.microsoft.com/en-us/library/windows/desktop/bb205074(v=vs.85).aspx

 

I will, eventually, update later. Thanks for help. :)

Edited by Deathlike

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this