Skip to main content
GameDev.net gamedev.net
🔒 Locked

Implement a PowerPoint like program using Direct3D?

Started by ncite Sep 7, 2010 at 5:09 PM 7 replies 2k views
Original Post
ncite
ncite
Dear all, I am new to 3D programming, and getting frustrated with 2D programming in 3D environment.

I currently plan to improve performance of a GDI based program. That program is just a simple PowerPoint like Program which supports animation, text scrolling, and some basic 2D effect. I bet I should use SDKs like Direct3D or OpenGL instead of GDI to boost the performance. But I am not sure about how to implement this to Direct3D. I read online and found out that I can do my drawings on dynamic texture and draw to a sprite. Each time I need to refresh my drawings, I should lock my texture and play with pixels then draw back on sprite... Well, it seems to be a lot of work to do if I need to directly access every pixel instead of using some APIs like those in GDI+. But it is fine if the path is correct. Could I ask if this is method the right way to implement "PowerPoint" like Program on Direct3D or we have better ways?

Thank you!

[Edited by - ncite on September 7, 2010 5:44:47 PM]
Promit
Promit
You might want to look at Direct2D as a simpler alternative for handling this, assuming you can require Vista SP1 or later.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
ncite
ncite
Quote:
Original post by Promit
You might want to look at Direct2D as a simpler alternative for handling this, assuming you can require Vista SP1 or later.


Thank you, but I need to make sure XP sp3 is supported...
MJP
MJP
If you implement rendering by locking a texture and filling it, you're still doing all of your rendering on the CPU. So you won't be gaining anything, and will just make things slower if you do it wrong.

The whole point of an API like D3D is to have the GPU render those pixels, which it can do many times faster than the CPU could do it. Obviously the interface is very different from something like GDI since the functionality is completely different. Like Promit mentioned Direct2D is a layer implemented on top of D3D that's meant to provide the same functionality as GDI/GDI+, so it's probably a better alternative. It's of course possible to do everything in D3D directly, but you'll have to spend the time learning how the pipeline works.

[Edited by - MJP on September 7, 2010 7:16:36 PM]
ncite
ncite
Quote:
Original post by MJP
If you implement rendering by locking a texture and filling it, you're still doing all of your rendering on the CPU. So you won't be gaining anything, and will just make things slower if you do it wrong.

The whole point of an API like D3D is to have the GPU render those pixels, which it can do many times faster than the GPU could do it. Obviously the interface is very different from something like GDI since the functionality is completely different. Like Promit mentioned Direct2D is a layer implemented on top of D3D that's meant to provide the same functionality as GDI/GDI+, so it's probably a better alternative. It's of course possible to do everything in D3D directly, but you'll have to spend the time learning how the pipeline works.


O, thank you! It looks like I am planning to spend a lot of energy to do the wrong thing. I will take some time to study pipeline. Could you recommend articles or books on this topic? Thank you again!
Fire Lancer
Fire Lancer
Look at optimising the GDI first.

Are you redrawing the whole thing say 30 times a second? If so don't do this, instead just redraw the areas of the window that need to be redrawn, and only when they need to be redraw (ie animations). The less you have to do each frame the better.

Doing it in Direct3D will be a lot of work, and will be slower if you do not offload as much of the work to the GPU as possible (even with a dynamic texture writing to it is fairly slow, and you wont get performance better than GDI).
ncite
ncite
Quote:
Original post by Fire Lancer
Look at optimising the GDI first.

Are you redrawing the whole thing say 30 times a second? If so don't do this, instead just redraw the areas of the window that need to be redrawn, and only when they need to be redraw (ie animations). The less you have to do each frame the better.

Doing it in Direct3D will be a lot of work, and will be slower if you do not offload as much of the work to the GPU as possible (even with a dynamic texture writing to it is fairly slow, and you wont get performance better than GDI).


Thank you! In fact the situation is worse. We had some effect like text crawling which required us to refresh with 60 fps. The effect would not smooth even a single frame is missed. My guess is that GDI should not be correct way to do 60 fps drawings (plus we have back buffer in DirectX and OpenGL, should be better than our own double buffer implementation). Am I right on this part?

Sorry I have one more question. Let's say I put each of elements in that powerpoint like app (Text, Image and Animation) as sprites. If I just play with the sprites to deal with the effect like crawling and update the texture in sprites only when required. Could it be better?

Thank you very much!


MJP
MJP
Sprites are very easy, and will definitely be very fast. D3D9's utility library (D3DX) even has a helper class that makes it very easy to draw a texture as a sprite. Where it gets tricky is if you have to start rendering custom 3D geometry, or if you want to use shaders to do custom per-pixel effects.
ncite
ncite
Quote:
Original post by MJP
Sprites are very easy, and will definitely be very fast. D3D9's utility library (D3DX) even has a helper class that makes it very easy to draw a texture as a sprite. Where it gets tricky is if you have to start rendering custom 3D geometry, or if you want to use shaders to do custom per-pixel effects.


O, I believe most of effect we had are 2d, like blinds, stretch and dissolve. Well, after a few googling, I found out that I can even avoid pixel manipulation by create surface and do GUI drawings there and convert the surface to texture... Maybe not fast enough though. thank you! Really appreciate your help!!

[Edited by - ncite on September 9, 2010 11:55:15 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.