Using 16 bit surfaces

I’m porting some graphics stuff I’ve written in 8 bits to 16 bits. One
of the problems I’m encountering is replacing memset as a filling
function. For example, to set an entire surface to a certain color.
Because 16 bits uses more than one byte for the color description, I am
unable to do this. How can I go about doing this on a 16 bit surface?
I’ve considered ideas…but they don’t sound too practical:

(1) Use memcpy to copy a color template (line) to the destination
surface one line at a time

(2) Manually set the pixels one by one? (yuck) …

One example of this was a Fill_Box function I wrote that used memset to
set a number of bytes (line) in a surface from a mapped pointer…

What’s the best means of going about doing this?

Paul Lowe
xpaull at ultraviolet.org

Paul Lowe skrev:

(2) Manually set the pixels one by one? (yuck) …

Isn?t this the way it?s done anyway?

What’s the best means of going about doing this?

I think most of the videocards nowadays have functions for clearing the
backbuffer with a specified color in notime. Perhaps that could be a
nice thing to implement in the SDL-api?

That didn?t realy answer your question did it? :wink:

Sorry, but palettebased colormodes and truecolormodes are very hard to
combine without loosing a lot of cpu-power in one end or the other.

/ Christian

Christian Granstr?m, Bryggerigatan 4A, 733 34 Sala, Sweden
home:0224-77312, cellular:070-4961587, work:018-184470
@christian.granstrom, christian.granstrom at home.se

I think most of the videocards nowadays have functions for clearing the
backbuffer with a specified color in notime. Perhaps that could be a
nice thing to implement in the SDL-api?

This is already in SDL 0.9.x as SDL_FillRect()

See ya!
-Sam Lantinga (slouken at devolution.com)–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/

Sam Lantinga skrev:

I think most of the videocards nowadays have functions for clearing the
backbuffer with a specified color in notime. Perhaps that could be a
nice thing to implement in the SDL-api?

This is already in SDL 0.9.x as SDL_FillRect()

See ya!

Great!!!
Use it guys!

/ Christian

Christian Granstr?m, Bryggerigatan 4A, 733 34 Sala, Sweden
home:0224-77312, cellular:070-4961587, work:018-184470
@christian.granstrom, christian.granstrom at home.se