2D in DX9 What is the way to go.

Started by
9 comments, last by HexDump 21 years ago
Hello guys, I have read some dx9 info and I have seen that you can use ddraw methods in dx9. The thing is, what should be the way to go for my upcoming GUI rendering, billboards or render with directdraw? If you think direct draw is the right decision is it dificult to use with d3d?. Thanks in advance. HexDump.
Advertisement
You can''t use DirectDraw in D3D. D3D does have some similar function calls to DD, but I haven''t found them particularly useful compared to the other stuff D3D can do.

So use billboards, but that''s probably not the correct term for them. Billboards are usually objects in some sort of 3D environment. For a GUI you would probably use transformed quads. (which I think is what you meant anyway).

- Fuzz
billboards imply some math to face things toward the user. Use screen space quads or an ortho projection.

Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces"
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
Just have all of your verticies in screen-space coords. This is what I do and is also whatCrazed Genius has suggested.

Dwiel
I suggest to use D3D, using textured quads as sprites, alpha channel as color key. And geometry pipeline is something that you can't miss. It allows your 2D game to be resolution independent. How cool is that!

Doing 2D with D3D will also make your life easier when you decide moving to 3D.

throw Exception( "End of post" );

[edited by - alnite on March 18, 2003 1:22:19 PM]
quote:And geometry pipeline is something that you can''t miss. It allows your 2D game to be resolution independent


Know any good tutorials on that subject? I''ve been messing with a 2D GUI using D3D for some time now. For instance, I''m using textured quads to display text. To save some time, I would want to render stuff like text and misc. graphic to a another texture/surface (lets call it surface X), and then render X to the screen. This should save a lot of time since rendering one large surface is much faster than rendering several smaller ones. Besides, X only has to updated when its contents change. Problem is that I can''t get it to work properly, the things I render to X become garbled. But if I render the text directly to the screen, they look ok. So.. does anyone know of a tutorial that covers this topic as well?

Regards / Fyyar
Also, it sometimes easier to just use DrawUserPrimatives (or is it DrawPrimativesUP?) when doing 2d because making a vertex buffer for a single quad is kinda pointless/bad.
quote:Original post by Fyyar
Know any good tutorials on that subject?
Unfortunately, I don''t have any. I read it from "Focus on 2D in Direct3D."
Here''s the way I do it:

// set Projection matrix
D3DXMATRIX tmatProj;
D3DXMatrixIdentity(&tmatProj);
tmatProj._22 = -( 2.0f / (float) TILECOUNT_VERTICAL );
tmatProj._11 = -tmatProj._22 * .75f;
tmatProj._41 = -1.0f;
tmatProj._42 = 1.0f;
pD3DDevice->SetTransform( D3DTS_PROJECTION, &tmatProj );

where TILECOUNT_VERTICAL is the maximum number of tiles you want to display on the vertical axis (y axis), assuming that each tile is 1.0 width and 1.0 height.

So, let''s say, you want to see 20x15 tiles on the screen, you use 15 for TILECOUNT_VERTICAL.

Current project: 2D in Direct3D engine.
% completed: ~20%
Thx! Btw, do you recommend that book?
quote:Original post by Fyyar
Btw, do you recommend that book?
Totally.

Current project: 2D in Direct3D engine.
% completed: ~20%

This topic is closed to new replies.

Advertisement