Jump to content
  • Advertisement
Sign in to follow this  

Fastest way to write to video memory

This topic is 5145 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 trying to write an application that writes directly to video memory. This should be a really easy thing to do so I start out with direct draw but remembers that is now included in direct3d so i switched to d3d9 (can this be a misstake?). The problem is now that there are several ways of accessing (writing to) the video memory. One could use GetDc, LockRect D3DXLoadSurfaceFromMemory and so on. I realize ofcourse that every function has it's own advantages but I guess I have to figure out what it is.. My question is really which is the fastes and best method to use when I want to update the entire screen with a content that is specific per pixel and no texture or built in primitives can be used? An example of such an application is a fractal zoomer. The method I have used so far is locking the surface updating it one pixel after the other and then unlocking it. I guess this is not optimal and would guess it is best to render the content to system memory and then copy it to video memory. Is this a correct assumption? Are there any specifc methods prefered? Or I'm I just out of my mind trying to do this in windows and direct3d?

Share this post

Link to post
Share on other sites
Avoid anything to do with a DC, it's SLOW. For demo style pixel effects it will not fly.

They way I did it for a standard Fire effect is:
1)Create a texture, with the DYNAMIC flag set if it's supported. This is where you'll render. You'll want this relatively small and then stretched to full, you'll have to experiment with the speed/size trade-off.
2)Calculate effect in a system memory array (optional, if the effect doesn't need to read from the array, it's purely write-only then you don't need to do this)
3)Lock the texture
4)Write to the texture
5)Unlock texture
6)Render to backbuffer as a quad

Actually you should make 2 textures and double-buffer.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!