Locking the backbuffer

Started by
1 comment, last by King_DuckZ 19 years, 1 month ago
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?
[ King_DuckZ out-- ]
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.
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! :))
[ King_DuckZ out-- ]

This topic is closed to new replies.

Advertisement