Jump to content
  • Advertisement
Sign in to follow this  
Wurmknight

OpenGL Direct3D or DirectDraw

This topic is 4591 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm sure this question has been asked elsewhere..but for the life of me, I cannot find it. My dilemma is: Me and a co-worker are planning on making an RPG and chose DirectX as our API-of-choice. We are both fluent C# programmers (which is the language we plan on writing this) and i've done some OpenGL stuff in the past. So my question is, is it more efficient with todays graphic card capabilities to use Direct3D or use the DirectDraw method for our graphics? Not sure if I mentioned it, but we our aiming our first game to be a single-player 2D RPG. I know there is probably no definitive answer, but i'm hoping for any opinions here. Thanks, Dustin

Share this post


Link to post
Share on other sites
Advertisement
Can't comment on speed, but DirectDraw was in fact dropped (back in DX8 I think?) from the API a while ago. Add advances in 3d accelerated hardware into the mix, and I'll dare go out on a leg here and say that D3D ought to be faster (this constitues subjective opinion not backed up by any benchmarks). Another plus is that you already know OGL so you'll probably find D3D more intuitive.

Share this post


Link to post
Share on other sites
I recommend using Direct3D. You will have a lot more options as far as scaling/rotating/alpha blending your sprites for some pretty cool effects. You'll also learn about the Direct3D interface in case you want to make a 3D project at a later date.

I recommends taking a look at the Direct3DX Sprite class. It will be handling the bulk of your work and is a good place to start.

Share this post


Link to post
Share on other sites
Quote:
Original post by Etherstar
I recommends taking a look at the Direct3DX Sprite class. It will be handling the bulk of your work and is a good place to start.


Last time I tried to work with Direct3DX sprite class, it all ended in disaster. You can only use images that size is in power of two and images will be resized for some weird reason (and thus it looks blurred and different). I wasn't able to render my 64x64 bitmap file into the screen as 64x64 image that looks the same as the original. And did I mention it was slow? My engine slowed already below 20fps when I rendered 20x10 tilemap on the screen. That's hardly enough for a decent RPG which I tried to create (so I went for DirectDraw, and it's way faster).

Share this post


Link to post
Share on other sites
D3DX Sprite class is quite slow. If you implement it by yourself, it will be way faster. DirectDraw of course works on non-3d-accelerated graphics cards, but if you don't need such backward-compatibility, you should use D3D instead.

Share this post


Link to post
Share on other sites
I'd go with Direct3D any day. Setting up and using D3D isn't harder than using DD and you get lots of cool effects for free. If you use D3DXSprite it's easy as cake. I don't believe D3DXSprite is slow at all. It was before, but MS have fixed it.

Share this post


Link to post
Share on other sites
I just recently dipped my toe into Managed Direct3D recently. I admit I ran into a few issues while getting the code to do what I wanted. Most of these issues were caused by my preconcieved notions about how to do 2D Graphics. Once I got passed that, and coded my application in a more appropriate way, I found that not only was Managed Direct3D easier, but also that the scene rendered faster. I know some other posters say that DirectDraw is faster, but I have a feeling that this is mostly cause by trying to use Direct3D incorrectly.

For example my first draft of my code tried to create a vertex buffer, set the texture and draw primatives each time I wanted to draw 1 tile. This seemed like the normal way to do it given past expirence with DirectDraw, but it was really slow. what I didn't know is the correct way to do it in direct3d, is to create a big list of points in 3D space that describe all the places you want 1 texture, and call DrawPrimitives once for each texture. Changing my code to work in this manner made all the difference in the world. I now render a 24x12 space of tiles with 48x48 tiles in about 35 milliseconds using Direct3D. So the myth about Direct3D being slow for 2D is untrue.

The real challenge I was facing is that most of the resources you will find for Direct3D are C++ and are for unmanaged code. I was looking primarily for VB.Net code which I was unable to find. I ended up translating a lot of C# and unamaged C++ examples to get what I needed.

Rather than say use Direct3D, but it will be hard, I'll do you one better than that. I wrote up my expirences as they happened to create working tutorial on 2D in Direct3D that does the most common things people do with 2D graphics. It focuses on windowed mode, but it could be applied to full screen. It uses colorkey transparency since that seems to be more common in 2D land. It also is geared towards the "take a rectangle from here and draw it there" line of thinking by providing some fucntions to convert source and destination rectangles into Vertices for Direct3D to use. The only thing you might not like about it is the sample code is in vb.net but I find translating vb.net to c# and vice versa is pretty easy. I am also very anxious to get some feedback on it.

If your still interested check it out at http://www.k2wrpg.org/wiki/index.php?Direct3DVbDotNet

Share this post


Link to post
Share on other sites
I have a similar question.

I'm working on a system in c# where I need to construct sharp 2d images (a combination of pictures and text) using managed directx, store them as a texture/surface and then display them on the screen, either as flat 2d quads or as part of a 3d object.

Unfortunately my boss wants the system to be easily upgradable in the future, so deprecated parts of directX, i.e. directdraw, aren't really acceptable.

I've been trying to get the system working using Direct3dx's sprite system and textures, but I'm left with slightly blurred images when loading simple images from disk and displaying them.

I've turned off the filtering for the TextureLoader, but the problems persist.
Is this a problem with the D3DX sprite system? Do I somehow have to disable filtering for the entire system, and if so can anyone give me a pointer?

If it is a problem with D3DX sprites, then can anyone tell me any ways to quickly load and display images with the same sharpness as the original image?
Or do I have to go back to my boss and tell him it's DirectDraw or nothing? :)

Share this post


Link to post
Share on other sites
Thanks everyone for the replies. I have chosen Direct3D over DirectDraw after reading everyones opinions and searching around, I really think D3D will allow me to use features I might find much harder to do with DirectDraw surfaces.

@Zangetsu:
I appreciate the link and I plan on looking over the site better when I get home (at work right now). I am curious though, and this is directed at anyone who can answer this. On your tutorial, you have a function (sub-routine i guess in VB) that disposes the D3D device.. In managed C#, wouldn't it dispose itself when the 'form' was destroyed/closed, because it is a member variable of that class. I could be thinking wrong, so that is why i'm so curious about this. I'm sure disposing it really doesn't hinder anything but I am curious if this step even needs to be called.

Share this post


Link to post
Share on other sites
Quote:
Original post by Habba
Quote:
Original post by Etherstar
I recommends taking a look at the Direct3DX Sprite class. It will be handling the bulk of your work and is a good place to start.


Last time I tried to work with Direct3DX sprite class, it all ended in disaster. You can only use images that size is in power of two and images will be resized for some weird reason (and thus it looks blurred and different). I wasn't able to render my 64x64 bitmap file into the screen as 64x64 image that looks the same as the original. And did I mention it was slow? My engine slowed already below 20fps when I rendered 20x10 tilemap on the screen. That's hardly enough for a decent RPG which I tried to create (so I went for DirectDraw, and it's way faster).


Quote:
Original post by Joni-Matti
D3DX Sprite class is quite slow. If you implement it by yourself, it will be way faster. DirectDraw of course works on non-3d-accelerated graphics cards, but if you don't need such backward-compatibility, you should use D3D instead.


Funny, I don't seem to have that problem.



6 different sprites, none of them having power of 2 dimensions (all loaded with the straight forward TextureLoader.FromFile method), being randomly placed on the screen every frame (when running it just looks like a flashy blob of color), with alpha blending used (50%), and the sprites are being placed out of order (instead of 6 loops, there is one loop that draws one instance of each per iteration) to avoid texture optimization. Properly ordered (draw all of one sprite first, then the next), the framerate more then doubles to 560 fps. Written in Visual C# Express, Managed DirectX 9, using the Sprite class.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!