Locking the backbuffer
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?
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement