hats off to anyone who can get my fade to work
Why will my fade to black not work correctly? Here is my fade Function:
void fade()
{
PALETTEENTRY pe[COLORS];
lpPrimaryPalette->GetEntries(NULL, 0, COLORS, pe);
for(int n = 0; n < 256; n++)
{
for(int i = 0; i < COLORS; i++)
{
if(pe.peRed > 0)
pe.peRed–;
if(pe.peGreen > 0)
pe.peGreen–;
if(pe.peBlue > 0)
pe.peBlue–;
}
Sleep(1);
lpPrimaryPalette->SetEntries(NULL, 0, COLORS, pe);
}
}
Here is my palette initialization:
LPDIRECTDRAWPALETTE CreatePalette(LPDIRECTDRAWSURFACE surface){
//create surface palette
PALETTEENTRY pe[COLORS]; //new palette
LPDIRECTDRAWPALETTE lpDDPalette; //direct draw palette
//construct pe[], set to black
for(int i=0; i<COLORS; i++)
pe.peRed=pe.peGreen=pe.peBlue=0;
//create direct draw palette
if(FAILED(lpDirectDrawObject->
CreatePalette(DDPCAPS_8BIT,pe,&lpDDPalette,NULL)))
return NULL;
//load direct draw palette to surface
surface->SetPalette(lpDDPalette);
return lpDDPalette;
} //CreatePalette
Every thing fades to black as it is supposed to, accept for white! I have tried everything, and can''t figure it out. It wont fade the 265th color in the palette. download this image if you want, and notice how the white line wont fade with this code. Hats off to anyone who can figure out why, it has taken 2 months and no solution yet.
http://members.tripod.com/ctrl_alt_del1/picture.bmp </i>
Yes, I have tried doing that, it looks like the forum took it as some sort of HTMl tag and turned the rest of my post to italics.
First, make sure you''ve got the number of colors correct. If you''re using a 256 color pallete... I think you want colors to be 256. Also, try to find exactly where in the array white is, then start doing value testing. Put in some break points and step through, checking values.
Though I doubt it, white may be unsigned {255, 255, 255} which might translate to signed { -1, -1, -1 } depending on what type of variables the pallete entry are, and whether everything is being compared correctly. Anyway, hope this helps.
Though I doubt it, white may be unsigned {255, 255, 255} which might translate to signed { -1, -1, -1 } depending on what type of variables the pallete entry are, and whether everything is being compared correctly. Anyway, hope this helps.
Thanks warden, I took your suggestions, and this is what I found out. If a paint a fusha(sp?) line in my bitmap, which is in slot #265 in the array, it will show up white on the computer screen. All of the other colors are right. This white line will than not fade. (even though it is not white, it is fusha). I don''t if this will give anyone any ideas, but it might help. I appreciate the responses.
And it does help.
I don''t remember the actual call flags, but when initializing the palette with Direct Draw, there is a flag you have to specify to use ALL 256 colors. If its not specified, Direct Draw will reserved spots for black and white colors.
I only have the SDK v8 so I don''t know the flags, but I ran into this problem before..
I don''t remember the actual call flags, but when initializing the palette with Direct Draw, there is a flag you have to specify to use ALL 256 colors. If its not specified, Direct Draw will reserved spots for black and white colors.
I only have the SDK v8 so I don''t know the flags, but I ran into this problem before..
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement