Jump to content
  • Advertisement
Sign in to follow this  
ferr

DX9 Menu

This topic is 4842 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 need to add Menus/Etc to a game I'm working on, it should cover everything from Inventory View, Barter View, Conversation View, and Battle Log. I can't just toss up text as that would be ugly as hell, so what would be a good way to go about adding the surface that I need in these situations? The only way I know of is to just add a texture, but then you have to go through the trouble of rotation and translating until it's in perfect view of the camera.. and that just doesn't really work well because the user could be panning the camera around in just about any direction before accessing a menu leading to it being sideways. I'm really looking for something that comes up flat "against" the screen similar to how DXFonts work. What should I do?

Share this post


Link to post
Share on other sites
Advertisement
While rendering your GUI you need to switch your matrix to an ortoographic projection. I can't remember the right function name for unmanaged Dx, but it is in D3DX and should be something along the lines of OrthoLH.

Share this post


Link to post
Share on other sites
Quote:
Original post by intrest86
While rendering your GUI you need to switch your matrix to an ortoographic projection. I can't remember the right function name for unmanaged Dx, but it is in D3DX and should be something along the lines of OrthoLH.


Hm, trying this out, but it doesn't seem to work right at all. The vertex renders in the same area but acts very strange when I pan the camera..

here's the code, mostly pseudo:

D3D_Device->BeginScene();

//Found the following code in another post (googled)
D3DXMATRIX ProjMtx;
D3DXMatrixIdentity(&ProjMtx);
D3DXMatrixOrthoLH(&ProjMtx, 800.0f, 600.0f, 1.0f, 1000.0f);
D3D_Device->SetTransform(D3DTS_PROJECTION, &ProjMtx);

... Draw Vertex Triangle Code Here ...

SetPerspective(); //put it back to Projection

... Do other stuff ...


If I could get some example code of actually doing what I need that'd be great, I think the code I'm finding might be the wrong technique.

edit: Just noticed "D3DTS_PROJECTION" in the code I found, I bet that's a problem.

Share this post


Link to post
Share on other sites
Ugh, well I think I have it set up correctly now and it isn't really what I'm looking for.. panning the camera causes the ortho'd object to move around, the fact is it has a spacial position independent of the view, I really want something that behaves like DXFonts..

Share this post


Link to post
Share on other sites
Quote:
Original post by cjb0087
did you to set your other matricies to identity while rendering the GUI?


I didn't at first, just added it and nothing seemed to change.

Share this post


Link to post
Share on other sites
Quote:
Original post by ferr
Ugh, well I think I have it set up correctly now and it isn't really what I'm looking for.. panning the camera causes the ortho'd object to move around, the fact is it has a spacial position independent of the view, I really want something that behaves like DXFonts..

You can change the view matrix for different things. While rendering your GUI, make sure that the view matrix is the identity. Then change it to whatever view you want to use the rest of the time.

The other possibility is to use Pre-transfirmed vertices, but I generally find that to be the inferior approach to this issue.

Share this post


Link to post
Share on other sites
Can anyone point me to a tutorial covering the use of Ortho in DX? The only reason I posted here was because I couldn't find anything on google or anywhere else, and the only book I have on DX basically says, "I won't be covering this." Right now I'm stuck and don't really know what to do about this.

I'm surprised, every 3D game I've ever played has had flat-against-the-screen textures, so I'd assume this would be an easier topic to research...

Share this post


Link to post
Share on other sites
Hi

I used to use pretransformed vertices but that meant locking the vertex buffer and changing the screen-space positions of the vertices every time you wanted draw a quad of a different size.

A month ago or something, I moved to having only one vertex buffer then using the ortho projection that other posters have talked of to project a rectangle to the screen. IMHO that's better because you don't have to keep locking your vertex buffer and it's much more flexible as you basically have a matrix per-rectangle.

I'll try to find it for you! (y)

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!