DirectX9 Direct3D 2D games...

Started by
26 comments, last by Tom 16 years, 2 months ago
***Introduction: Hi everyone, I'm using VB.NET 2005 and I developed many games using Visual Studio's designer. As you'd probably expect, I soon enough found it less suitable for more serious games. Then I moved on to DirectX's DirectDraw. Having encountered many problems I sought help here. I've been warmheartedly recommended against using DirectDraw, and using Direct3D instead, even for 2D games. ***Bottom line: I'm having many problems in initializing Direct3D for 2D games (I remember reading something about orthographic projection)and actually drawing something. most of the guides I read aren't clear, many of them don't work, and all of them aren't suitable for 2D games. Plus, ms's examples either don't work after being converted to VB 2005 or stop working as soon as I try to add some code of my own. I'd really appreciate it if someone will find me a good, step-by-step tutorial for initialization of direct3D, suitable for 2D games. Benny
Advertisement
Yo can still use DirectDraw this is what I am doing and it's far less complicated, only surfaces blitting.
Even SDL exclusively relies on Direct Draw ( if you target win32 machines of course ).
This API is marked as deprecated by Microsoft but it is still supported by DirectX 9 and 10.
Even with D3D interfaces you can get a DDraw surface.
If you want to use DDraw again, you need a C++ compiler.

I would recommend first to design a good 2d game with SDL or DDraw then migrating to Direct 3d.
This is my opinion it's up to you..
EDIT: I don't have a clue about DX in VB so just change the code below so it's suitable for VB. /EDIT

It's pretty pointless using DirectDraw these days. Even setting it up is pretty painful. It's not hardware accelerated in new video cards anymore as far as I know.

Probably the easiest way to do 2D with Direct3D is look into using a Vertex format with a RHW value, which would basically give you pre-transformed vertexes, which means you can specify co-ordinates as screen pixel values rather than having to mess with projection matrixes and orthographic projection and all that :)

use this as your FVF and just set it with d3d.lpD3DDevice->SetVertexShader( D3DFVF_TLVERTEX); or whatever is equivelant for your code

[source code="cpp"]typedef struct _D3DTLVERTEX {    union {        float sx;        float dvSX;    };    union {        float sy;        float dvSY;    };    union {        float sz;        float dvSZ;    };    union {        float rhw;        float dvRHW;    };    union {        D3DCOLOR color;        D3DCOLOR dcColor;    };    union {        D3DCOLOR specular;        D3DCOLOR dcSpecular;    };    union {        float tu;        float dvTU;    };    union {        float tv;        float dvTV;    };#if (defined __cplusplus) && (defined D3D_OVERLOADS)    _D3DTLVERTEX() { }    _D3DTLVERTEX(const D3DVECTOR& v,float w,D3DCOLOR col,D3DCOLOR spec, float _tu, float _tv)        { sx = v.x; sy = v.y; sz = v.z; rhw=w;          color = col; specular = spec;          tu = _tu; tv = _tv;    }#endif} D3DTLVERTEX, *LPD3DTLVERTEX;
Quote:Original post by HolyGrail
Even SDL exclusively relies on Direct Draw ( if you target win32 machines of course ).


SDL defaults to GDI, even if you specify that you want a hardware device. This is because DirectDraw no longer provides hardware acceleration.

Hi there BennyK,
What you should be looking at is the following, Look at the D3DFVF_XYZRHW format if you are using Direct3D9. This basically specifies that the components of the vertex have already been transformed and no transformation operation will be performed on them. This allows you to place objects at exact locations in screen space.

I hope this helps.
Take care.
Thanks people,
HolyGrail: I already have a functioning DirectDraw game. I decided to move on to Direct3D and I don't think the reasons are worth discussing again.

As for sirlemonhead and Armadon, I barely have a clue about DirectX.Direct3D (let alone on CPP) so I couldent quite figure out what you are writing about...

BTW, can I attach a file here?
DirectDraw, VS6 and VB6 are old.

I can't believe I bought Windows Game Programming for Dummies in 2004 [depressed]
You could try just using D3DXSprite its simple and easy to use for basic 2d drawing. You can rotate and scale if you want to, but you don't have to disable them if you don't want them.
I'd also appreciate it if people will read my post and find out what I asked for before replying.
A link to my DirectDraw game so you'll be able to see what I'm looking for in Direct3D: http://www.mediafire.com/?1nkmz7d42ah
I would not use Direct3D either. I would use a library or engine more suited for the 2D game you have in mind.

This topic is closed to new replies.

Advertisement