| | |
DirectDraw 8-bit color algorithm
Please support our Game Development advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
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:
Here's my setPixel function:
lpScreen is defined as an array of BYTEs.
And here is the implementation in WinMain:
For some reason, this comes out as a greenish-blue when it should be pure red.
Here is the macro:
c++ Syntax (Toggle Plain Text)
#define RGB_8BIT(r, g, b) ((r & 224) + ((g & 224) >> 3) + (b >> 6))
c++ Syntax (Toggle Plain Text)
VOID setPixel(INT x, INT y, BYTE color) { lpScreen[x + y * lPitch] = color; }
And here is the implementation in WinMain:
c++ Syntax (Toggle Plain Text)
setPixel(0, 0, RGB_8BIT(255, 0, 0));
For some reason, this comes out as a greenish-blue when it should be pure red.
That'll do it. Don't forget to mark the thread solved.
Chaos
Lost Souls: text based RPG
MUDseek: MUD gaming search
Lost Souls: text based RPG
MUDseek: MUD gaming search
![]() |
Other Threads in the Game Development Forum
- Previous Thread: Text Based Mafia game
- Next Thread: Web Based Tactical ORPG
Views: 1203 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Game Development
3d advertising ai algorithm ban c++ cambridge camera censorship china competition console development engine fov fpx game gamedevelopment gameprogramming gamer games gaming gauntanamo government graphics idaho in-gameadvertisement intel intellectualproperty l-systems laracroft larrabee lindenmayer live manhunt math mathematics matrix mercenaries microsoft mmorpg modded msn multicore naked news nintendo obama opengl palin physics pirate playstation politics processor projection ps3 rpg search selection software sony stephenhawking stocks studio technology terrorism tombraider uk videogame web wii world-of-warcraft xbox xbox-live xbox360





