DX9 Menu

Started by
10 comments, last by ferr 18 years, 9 months ago
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?
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.
Turring Machines are better than C++ any day ^_~
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.
did you to set your other matricies to identity while rendering the GUI?
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..
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.
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.
Turring Machines are better than C++ any day ^_~
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...
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)
Here be the link.

This topic is closed to new replies.

Advertisement