technique to draw Sprite with fast speed?
i have a Sprite component, which will draw every sprites( bitmap) into a buffer( defined with dimension: 320x240)using GDI functions.
- M1: if Window app want to display in a sprite its DC, this component support function to get the buffer pointer and display it into screen.
- M2: if Direct3D want too, i will predefined a texture, call the get buffer pointer function, access to buffer of the texture surface, copy bit to bit and render this texture onto the screen.
They all work well. However, M2 take lot of CPU process than M1, and they are all require lots of CPU process. Therefore, it is not suitable to develop this component in real time.
i wonder if was something unnecessary on my technique .
Can anybody explain why M2 took lot of CPU proces than M1? and how to improve this?
i have do research from internet and i relize that GDI functions is not suitable for this because they used to release a slow performance,especially in Direct3D. But if i want my component to run in any kind of application(direct3D ,Direct show, Win32 app...), which technique to draw sprite image should i stand at?
Your main problem with method 2 is that you're probably copying from system memory into video memory. It's one of the worst things you can do. You would probably get better performance copying directly to the screen.
The real answer is to write different blitters for each scenario. You want to load directly from file into your texture, only once on start-up, for maximum speed. Then you never mess with the texture again until you need to get rid of it.
By the way, Direct3D can be used in any type of complex windows application. The only reason you wouldn't want to use Direct3D is if you're working on another OS.
The real answer is to write different blitters for each scenario. You want to load directly from file into your texture, only once on start-up, for maximum speed. Then you never mess with the texture again until you need to get rid of it.
By the way, Direct3D can be used in any type of complex windows application. The only reason you wouldn't want to use Direct3D is if you're working on another OS.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement