Jump to content
  • Advertisement
Sign in to follow this  
King_DuckZ

Locking the backbuffer

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

Hello. I need to apply an effect to the backbuffer at everyframe. That is, I want to convert it to a luminance map, and then I want to use the value of each pixel as the index of a palette. Last, I wanna set the value of the same pixel to the value in the palette, scaled by a factor. All this implies reading and writing to the backbuffer, but LockRect() on the backbuffer keeps on failing. Also, I tried to StretchRect() the backbuffer on another surface, so I can lock the second surface, but StretchRect() fails as well. I remember in DirectDraw there were issues when reading video memory, so maybe I should place the backbuffer on system memory. But if possible I would avoid to do so. Is there any trick/technique to access the backbuffer without slowing down things too much?

Share this post


Link to post
Share on other sites
Advertisement
The back buffer needs to be in video memory. There is a flag you must specify in the presentparams if you require a lockable back buffer. Locking and reading the buffer will be slow (except single digit FPS).

Another option is to render your scene to a texture. Then, using this texture, render a fullscreen quad to the backbuffer and do the luma conversion and new value lookup in a pixel shader. Should be blazingly fast.

Share this post


Link to post
Share on other sites
Ok, I succeeded in locking the backbuffer, the effect I'm writing looks good enough :) Though its slowness got to the overkill level, so I think I'll try the technique you said. Thank you very much! :))

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!