DX 9 2d graphic problem

Started by
1 comment, last by SteveS2003 20 years, 7 months ago
I already read the article about textured quads and it works fine but I''m pretty new to Direct3d. I''m trying to develop a geo political simulator with a user interface at the top and bottom of the screen and a large world map in the middle of the screen which I can scroll. Now the question is: How can I implement all this in DX9 with textured quads. -Is there any easy way to implement some simple kind of scrolling (without the use f too much matrices and te like) -Is it correct to use 2 quads one for the interface and one for the map or do I have to learn multitexturing. If I need to of them, which parameters do I have to set for correct alphablending. (My problem here was that I always was able to see only one quad but not both of them)
Advertisement
You don''t need multi-texturing (although you can get some cool effects if you do). Just pretend that your quad is your "bitmap" and that you''re still "blitting" it to the screen.

One suggestion for optimization: Figure out how many different sizes of quads you are rendering to the screen and set up vertex sets for each one. This way you can blit to the screen without monkeying around with the vertex lists.
Q: Now the question is: How can I implement all this in DX9 with textured quads?

A: Yes you can.
- The number of quads I use depends on size (width and height), one for each distinct width and height (rule of thumb only).

- for instance
A. 1 quad for Top interface area (seamless background texture)
1) 1 quad for each of the user interface elements that are the same size (resource counts, labels, message ballons etc.). This saves a vertex buffer switch in your render method, you only have to translate the quad and change texture.

B. 1 quad for bottom interface area (seamless background texture) if the size is different from upper interface quad, else share the quad.

1) same as A. 1)


C. If by map you mean something like mini-map (Ala AOE)? if so I do not know. But if you mean like a tiled terrain map, 1 quad/vertexbuffer that is shared by all tiles (because they are all the same size).



Q: Is it correct to use 2 quads one for the interface and one for the map?

A: See answer above.

Q: Which parameters do I have to set for correct alphablending?

A:
//Turn lighting off unless you are positive it is
//setup correctly. If lighting is not setup correctly
//the sprites will display a all black
device.RenderState.Lighting = false;

//These render states are required for Transparent sprites
// {SourceBlend, DestinationBlend, AlphaBlendEnable}
device.RenderState.SourceBlend = Blend.SourceAlpha;
device.RenderState.DestinationBlend = Blend.InvSourceAlpha;
device.RenderState.AlphaBlendEnable = true;



Note: I can send you a very simple sprite demo (C#) using D3D and textured quads (actually 2 triangle triangle-strip), but it's rather large (1.2 MB). I will not send it unless you request it.

Tommyboy

[edited by - Tommyboy on September 6, 2003 4:59:52 AM]

[edited by - Tommyboy on September 6, 2003 5:04:14 AM]
Tommyboy

This topic is closed to new replies.

Advertisement