Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


DirectX9 Direct3D 2D games...


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
27 replies to this topic

#1 BennyK   Members   -  Reputation: 122

Like
0Likes
Like

Posted 12 February 2008 - 07:44 AM

***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

Sponsor:

#2 HolyGrail   Members   -  Reputation: 115

Like
0Likes
Like

Posted 12 February 2008 - 07:58 AM

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..

#3 sirlemonhead   Members   -  Reputation: 184

Like
0Likes
Like

Posted 12 February 2008 - 10:33 AM

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;




#4 MJP   Moderators   -  Reputation: 11569

Like
0Likes
Like

Posted 12 February 2008 - 02:33 PM

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.



#5 Armadon   Members   -  Reputation: 1086

Like
0Likes
Like

Posted 12 February 2008 - 04:36 PM

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.

#6 BennyK   Members   -  Reputation: 122

Like
0Likes
Like

Posted 12 February 2008 - 05:28 PM

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?

#7 Boder   Members   -  Reputation: 918

Like
0Likes
Like

Posted 12 February 2008 - 05:32 PM

DirectDraw, VS6 and VB6 are old.

I can't believe I bought Windows Game Programming for Dummies in 2004 [depressed]

#8 adam4813   Members   -  Reputation: 663

Like
0Likes
Like

Posted 12 February 2008 - 05:32 PM

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.

#9 BennyK   Members   -  Reputation: 122

Like
0Likes
Like

Posted 12 February 2008 - 05:48 PM

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

#10 Boder   Members   -  Reputation: 918

Like
0Likes
Like

Posted 12 February 2008 - 05:52 PM

I would not use Direct3D either. I would use a library or engine more suited for the 2D game you have in mind.

#11 BennyK   Members   -  Reputation: 122

Like
0Likes
Like

Posted 12 February 2008 - 08:02 PM

So what would you use?
I still can't find a tutorial suitable for Direct3D 2D games :( .
Try not to take this post's purpose to a different direction...

#12 adam4813   Members   -  Reputation: 663

Like
0Likes
Like

Posted 12 February 2008 - 08:34 PM

As I mentioned look up using D3DXSprites as they are a utility for easy 2d image display without needed to do any 3d work. Just initialize DirectX and call LoadTexture(). Then to draw its simple sprite.draw().

#13 BennyK   Members   -  Reputation: 122

Like
0Likes
Like

Posted 13 February 2008 - 01:50 AM

Quote:
Original post by adam4813
... Just initialize DirectX ...

THATS THE WHOLE PROBLEM!!!




#14 id0001   Members   -  Reputation: 122

Like
0Likes
Like

Posted 13 February 2008 - 02:28 AM

there are quite a few tutorials about managed directX and direct3D out there on the internet.
just google for it.

I typed "vb direct3d sprite tutorial"
and I found http://geekswithblogs.net/clingermangw/articles/83997.aspx

good luck with your 2d game. Im making a 2d game engine myself with c# so if you have any further questions regarding sprites, etc. you can ask me.

ID

#15 jollyjeffers   Crossbones+   -  Reputation: 1542

Like
0Likes
Like

Posted 13 February 2008 - 02:45 AM

BennyK, VB.NET does not appear to be a popular game development language these days. Sure, people do use it, but the vast majority (gaming or otherwise) of .NET material is for C#. Native application development on Windows is primarily C/C++.

If you go against the common flow in any technology then you have to appreciate that there are less resources and less people available to answer your specific questions.

Thankfully .NET API's are pretty much identical regardless of which language you use. I'm sure you can read enough C#-Direct3D code to get a good idea of what to type for your VB.NET-Direct3D code. Intellisense, documentation and these forums will fill in the final few details.

Have a go at reading the C# samples and articles and see where you get to. If there are any specific fragments of DX-specific code you can't translate then feel free to come back here, post what you found, post your attempted conversion and see if we can help out.

Best of luck!

Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

#16 BennyK   Members   -  Reputation: 122

Like
0Likes
Like

Posted 13 February 2008 - 04:13 AM

Thanks id0001, I have a look there. Looks promising...
jollyjeffers: I don't think C# is more or less popular then VB... They are basically the same languages except that C# looks a bit more like C or Java as far as I can tell. Most of the tutorials I found have both VB and C# examples...
BTW, is that true for all .NET languages?(besides ASP)

#17 id0001   Members   -  Reputation: 122

Like
0Likes
Like

Posted 13 February 2008 - 05:08 AM

Quote:
BTW, is that true for all .NET languages?(besides ASP)

you can convert any .net language into an other .net language.

I exported my game engine into a dll file and then I made a game with vb using my game engine's dll included as a reference.



#18 HolyGrail   Members   -  Reputation: 115

Like
0Likes
Like

Posted 13 February 2008 - 08:27 AM

Quote:
Original post by MJP
SDL defaults to GDI, even if you specify that you want a hardware device. This is because DirectDraw no longer provides hardware acceleration.


Ok.
Is there any link or proof your statement ?
You say that DirectDraw no longer provides hardware acceleration.
If it's the case, I don't understand because ddraw.dll is still present.

#19 BennyK   Members   -  Reputation: 122

Like
0Likes
Like

Posted 13 February 2008 - 05:07 PM

The main problem with using DirectDraw in DirectX9 is that It doesn't support blitting anymore which was why it was so fast.
Now it's much slower without this option, and even slower when not using FullScreenExclusive mode, which makes a LOT of problems.

#20 sirlemonhead   Members   -  Reputation: 184

Like
0Likes
Like

Posted 13 February 2008 - 11:03 PM

Quote:
Original post by HolyGrail
Quote:
Original post by MJP
SDL defaults to GDI, even if you specify that you want a hardware device. This is because DirectDraw no longer provides hardware acceleration.


Ok.
Is there any link or proof your statement ?
You say that DirectDraw no longer provides hardware acceleration.
If it's the case, I don't understand because ddraw.dll is still present.


DirectDraw is still there and is usable, but it's not hardware accelerated anymore. Modern GPU's just dont have any support for that stuff in hardware anymore because directdraw is obsolete.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS