Skip to main content
GameDev.net gamedev.net
🔒 Locked

16-bit

Started by theonlymcc Sep 26, 2000 at 6:35 AM 4 replies 450+ views
Original Post
theonlymcc
theonlymcc
I have tried all this stuff about 16-bit and can''t get it to work. If I use this macro out of WGPFD #define _RGB16BIT(r,g,b) ((b%32) + ((g%32) << 5) + ((r%32) << 10)) and just use 255 for r and 0 for g & b. then the screen is gold. if I use 31 it is still gold. I am using LPDIRECTDRAW7 and LPDIRECTDRAWSURFACE7. I am sure that it compiles right and that it is in 16-bit. Somebody please give me something that works. Say its a function, what variable type do I declare my color? Like in the macro above. Do I declare it a WORD or USHORT or what? I am so confused.
NuffSaid
NuffSaid
You must shift the r value by 11 bits, not 10. That''s where your problem is.
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
theonlymcc
theonlymcc
Cool. That worked. Just shifted it to 11. Why does that work? And..what type of variable should my color be? Should I make it a USHORT? ULONG? Since it is 16-bit, does that mean when I want to make a color that each rgb value''s max is 31? or is it still 255?
Thanks.
Quantum
Quantum
most video cards use 5 bits for red, 6 for green, and 5 for blue

giving you a colour range of 31, 63, and 31 respectively

but some cards still use 555 mode..
you should detect the pixel format and then have a function pointer or something like that...

use lpddsprimary->GetPixelFormat() and then get the dwGBitMask to get which pixel format it is
i cant remember the exact values for the green bit mask atm..
theonlymcc
theonlymcc
I tried using 31,63,31 to see if I could make white. I Blt it to the surface and I get purple but I can get red, blue or green alone. So I tried 31,31,31 and I still got purple. But I just figured it out. I switched the macro from this:
RGB16BIT(r,g,b) ((b%32) + ((g%32) << 5) + ((r%32) << 11))
to this:
RGB16BIT(r,g,b) ((b%32) + ((g%32) << 6) + ((r%32) << 11))

so it works officially. So does that mean My card uses 565? Thanks to all for your help. I am sorry for not catching on as quick as the like here on the board. I apologize for being so cumbersome.

Edited by - theonlymcc on September 26, 2000 8:13:51 AM
furby100
furby100
Your card is 565, yes. The reason it is purple, is that the macro for 565 is in fact:

#define RGB16BIT(r, g, b) ((b%32)+((g%64)<<5)+((r%32)<<11))

or in the faster form:

#define RGB16BIT(r, g, b) ((b&31)|((g&63)<<5)|((r&31)<<11))

However, if you want a to use the macros identically, you should use your macro.


------------------------------
#pragma twice


sharewaregames.20m.com

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.