• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
BennyK

DirectX9 Direct3D 2D games...

27 posts in this topic

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

Share this post


Link to post
Share on other sites
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..
0

Share this post


Link to post
Share on other sites
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;


0

Share this post


Link to post
Share on other sites
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.

0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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?
0

Share this post


Link to post
Share on other sites
DirectDraw, VS6 and VB6 are old.

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

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites
I would not use Direct3D either. I would use a library or engine more suited for the 2D game you have in mind.
0

Share this post


Link to post
Share on other sites
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...
0

Share this post


Link to post
Share on other sites
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().
0

Share this post


Link to post
Share on other sites
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 [url]http://geekswithblogs.net/clingermangw/articles/83997.aspx[/url]

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
0

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites
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)
0

Share this post


Link to post
Share on other sites
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.

0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
Assuming you're using Managed DirectX9 with VB.Net, I would also recommend reading through Mr. Clingerman's first 2 tutorials (page showing links to all 3 tutorials in the series here: http://geekswithblogs.net/clingermangw/category/5002.aspx ).

They helped me quite a bit in getting my 2D graphics library started (I'm using SlimDX, though, which is quite similar to Managed DirectX ... I first worked up a Managed DirectX version of what I wanted to do, then tweaked things to fit the slight changed needed for SlimDX .).

Good luck with your project,
-Matt
0

Share this post


Link to post
Share on other sites
Thanks MattWorden,
I have a question about "Gee, I can make black form." (http://geekswithblogs.net/clingermangw/articles/83997.aspx)
what do I need To do about the main loop (Where and how do I need to put it) if I'm initializing D3D through the game form (aGameEngine)?
Take a look in my project in DirectDraw to see what I'm talking about - http://www.mediafire.com/?1nkmz7d42ah

Thanks in advance,
Benny
0

Share this post


Link to post
Share on other sites
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.


Go ahead and try it yourself. Specify that you want a hardware video surface, and then use SDL_VideoDriverName to see what driver its using (Windib is their name for the GDI driver).

Presumably SDL leaves in DDraw support for platforms that still support it in hardware.
0

Share this post


Link to post
Share on other sites
In the future DirectDraw will not be supported anymore.
Everything will be done in Direct3D. This is not a very difficult task actually.
the first thing you have to do is initialize a Direct3d device. This may be difficult if you haven't read my first post. but I can help you if you have problems.

the next task is to create a sprite object and draw a texture to the screen using one of the three commonly used methods for the gameloop.

1. Using the onPaint method.
which is not very fast actually.

2. Using the DoEvents() method.
which is not vry fast either.

3. using the peekmessage method.
this one is fast.
it will check if there are any windows messages waiting. if not it
executes a defined code (like update and draw or something).

Your imagination is your only limitation. I made a game engine with sprites, tilemaps, sound (fmod) and input (directInput & clr input) with c# and managed direct3D. vb could also be used.

It may take a while to make a game with managed DX and VB but it can be done.
It took me about one evening to make a ponggame with my game engine (including graphics,sound,input).

my point is: Managed DX isn't very hard, but you need to have a understanding of how games are coded since DX only handels the graphics part.

[Edited by - id0001 on February 16, 2008 3:55:52 AM]
0

Share this post


Link to post
Share on other sites
I have another question ( I found a way around my last problem):
In the tutorial
http://geekswithblogs.net/clingermangw/articles/83997.aspx
the game engine is initialized through the Direct3D engine, nut then the Direct3D is initialized through the game engine

In DX3DEngine:

Public Shared Sub Main()
'Create a form to attach the DirectX device to
Dim aMainForm As New Windows.Forms.Form
'Create the Game engine
Dim aGameEngine As New GameEngine(aMainForm)
'Display the form
aMainForm.Show()
'Continue the game loop while the form is still running
Do While aMainForm.IsDisposed = False
'Give the computer a chance to process some other things
Application.DoEvents()
'Render the scene
aGameEngine.Render()
Loop
'Destroy the Game Engine
aGameEngine = Nothing
'Destroy the Main form
aMainForm = Nothing
End Sub


In GameEngine:

Private mGraphics As DX3DEngine
'Description: The class constructor. Create the objects for the class
Public Sub New(ByVal theRenderTarget As Control)
mGraphics = New DX3DEngine(theRenderTarget, True)
End Sub


Can someone please explain what this is about?
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0