Backbuffer color

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
Lorth
Posts: 139
Joined: July 19th, 2012, 4:12 pm

Backbuffer color

Post by Lorth » November 27th, 2012, 10:01 pm

Hey guys!

i am watching lesson 8 when we implement the running man, and i found this fillvalue which we change to change color of the background.

at first it was 0x00 which was black, and we changed it into 0xE0 to a more gray like color to se the char, now i try to acctually change this into something else than black or white, i wanna have lika a light green background, have changed this defined fillvalue to all sorts of combination but i only get something between black/ white.

anyone that can help me out :/

Muttley
Posts: 39
Joined: October 19th, 2012, 6:00 am

Re: Backbuffer color

Post by Muttley » November 27th, 2012, 10:37 pm


Lorth
Posts: 139
Joined: July 19th, 2012, 4:12 pm

Re: Backbuffer color

Post by Lorth » November 28th, 2012, 7:30 am

Yeah i google to found out other color combinations before i posted here :)

but with any different combination i use it only becomes either black/white or any shade of grey

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Backbuffer color

Post by LuX » November 28th, 2012, 2:27 pm

I think you are talking about the memset function, as I remember chili using it to clear the buffer.
The reason why it will only work on grayscale, is because memset will take the char you want to set the memory and put all the values of it at that value.

Example; you set the D3DCOLOR buffer with 0xFF -> each byte of D3DCOLOR will become 0xFF. D3DCOLOR being 4 bytes you will get pixels of 0xFFFFFFFF (white). If you set 0xE0 the pixels will become 0xE0E0E0E0 and so on.
ʕ •ᴥ•ʔ

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Backbuffer color

Post by chili » November 29th, 2012, 2:11 pm

LuX strikes again! If you want to fill the backbuffer with a non-greyscale color, you'll need to use a routine that copies data with 32-bit granularity. Memset, like memcpy, only has 8-bit granularity. You could just replace it with a loop, but it will definately be slower (might be pretty fast with SSE optimization turned on, but I wouldn't hold my breath with the free compiler). Maybe there's a fast routine like memcpy but for 32-bit values, but you'd have to look into that. Anyways, a loop should do you fine.
Chili

Post Reply