Jump to content
  • Advertisement
Sign in to follow this  
JohnnyDude

Using SlimDX to draw "dynamic" 2D bitmap

This topic is 2662 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

Howdy. I'm currently working on an 3DO emulator called 4DO (www.fourdo.com). For controller support, SlimDX was the bomb-diggity. For video support, so far I've just used basic C# windows forms (GDI). It's slow and I have no way to achieve VSync. I'm now tackling changing that to use DirectX/SlimDX. The requirements aren't terribly complicated, but I'm rather confused as to the best way to approach it because this is new territory for me.

The system emulation produces 60 video frames per second. These video frames are not in a plain bitmap format (it's indexed 565 rgb with extra data at the end of each row of pixels). As a result, the next stage is changing that data into a real bitmap.

From here, when using GDI, I manually populated a System.Drawing.Bitmap with the data. Later on, the draw to the screen accepts a System.Drawing.Bitmap, so that's pretty much the end of that story.

However, with DirectX (and SlimDX in my situation) I don't understand the best way to proceed. I started with a Direct2D render target and I'm pretty confident that's best in my situation. From there, the only way I see to draw an image is to use a Direct2D.Bitmap. I see options to create this Direct2D.Bitmap by copying from another memory location. This ultimately doesn't seem like what I want because that looks like it would be a needless copy of the image 60 times a second. I attempted to update the Direct2D.Bitmap data directly, but I've found no way to access it. I also found the CreateSharedBitmap function off the render target, but I've been unable to get it to work at all, and all the documentation I find seems to indicate it's a last resort for sharing between D3D and D2D contexts. Am I on the right track with that function, or did I miss something obvious about how to just access the bitmap data?

Share this post


Link to post
Share on other sites
Advertisement
I don't know that you're going to be able to avoid the copying of your surface; obviously you need to get the memory across the bus onto the graphics card. Since it seems like you want to do all your own rendering, and since Direct2D is more focused on vector graphics than raster graphics, I'd suggest just using a few D3D calls to lock a texture and fill the data as you generate it. That would hopefully be the most efficient way of doing it.

Share this post


Link to post
Share on other sites
Hi Mike, and thanks for the helpful reply.

I have come to the same conclusion that direct2d wasn't the best choice. I've also since found that direct2d isn't supported on XP, so I need to migrate away from it anyway. The ability to "lock" textures looks like the right approach in my situation. I was getting errors when attempting this last time, but I'll be giving it another go and hopefully won't get stuck on it.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!