DirectDraw 8-bit color algorithm

Please support our Game Development advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Apr 2006
Posts: 357
Reputation: death_oclock will become famous soon enough death_oclock will become famous soon enough 
Solved Threads: 37
death_oclock's Avatar
death_oclock death_oclock is offline Offline
Posting Whiz

DirectDraw 8-bit color algorithm

 
0
  #1
Jul 29th, 2008
I am using DirectDraw to make a game and I am running it in 8-bit color mode. What I am having a problem with is making a macro to convert RGB values into a single 8-bit color.
Here is the macro:
  1. #define RGB_8BIT(r, g, b) ((r & 224) + ((g & 224) >> 3) + (b >> 6))
Here's my setPixel function:
  1. VOID setPixel(INT x, INT y, BYTE color)
  2. {
  3. lpScreen[x + y * lPitch] = color;
  4. }
lpScreen is defined as an array of BYTEs.
And here is the implementation in WinMain:
  1. setPixel(0, 0, RGB_8BIT(255, 0, 0));

For some reason, this comes out as a greenish-blue when it should be pure red.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 357
Reputation: death_oclock will become famous soon enough death_oclock will become famous soon enough 
Solved Threads: 37
death_oclock's Avatar
death_oclock death_oclock is offline Offline
Posting Whiz

Re: DirectDraw 8-bit color algorithm

 
0
  #2
Jul 29th, 2008
Ooops, I just found out that 8-bit mode has to be palletized, so the macro is actually coming up with an arbitrary index to a color in the default pallet.
Last edited by death_oclock; Jul 29th, 2008 at 6:30 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 46
Reputation: chaosprime is an unknown quantity at this point 
Solved Threads: 4
chaosprime's Avatar
chaosprime chaosprime is offline Offline
Light Poster

Re: DirectDraw 8-bit color algorithm

 
0
  #3
Jul 29th, 2008
That'll do it. Don't forget to mark the thread solved.
Chaos
Lost Souls: text based RPG
MUDseek: MUD gaming search
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Game Development Forum


Views: 1203 | Replies: 2
Thread Tools Search this Thread



Tag cloud for Game Development
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC