FadeOut problem using directdraw palette ?!

Started by
4 comments, last by nlo 24 years ago
I created a FadeOut function using DirectDraw''s palette, but the result is : the palette change then fade to black, can someone help me with this problem ?! here''s my code : int DDFadeOut(void) { PALETTEENTRY tempPal[256]; int i=0,j=0; // copy the original palette to work palette 1st IDirectDrawPalette_GetEntries(g_pDDPAL,0,0,256,tempPal); // So set the palette to black for (j=1; j<255; j++) { for (i=1; i<255; i++) { tempPal.peRed--; if(tempPal.peRed<0) tempPal.peRed=0; tempPal.peGreen–; if(tempPal.peGreen<0) tempPal.peGreen=0; tempPal.peBlue–; if(tempPal.peBlue<0) tempPal.peBlue=0; //tempPal.peFlags = 0; } IDirectDrawPalette_SetEntries(g_pDDPAL,0,1,255,tempPal); Sleep(4); } return (1); } My compiled .exe file can find here (21kb zipped): http://www.onnet.com.hk/nganlo/dx01.zip </i>
Advertisement
Well, part of the problem is that you can''t just subtract your palette entries like that. If you have a color that is RGB(255,128,128), after 128 cycles, your color is (128,0,0), which is NOT what you want it to be, since it would go from a pinkish color to a darkish red.

At ''half brightness'' it should be (128,64,64), so you don''t want to SUBTRACT your palette rgb numbers, you want to take a percentage of them, like this:

short percent;
float fpercent;

for (percent=100;percent>=0;percent--) {
fpercent=percent/100;
r*=fpercent;
g*=fpercent;
b*=fpercent;
}

At 100%, all the rbg entries get multiplied by one...
At 50%, all the rgb entries get multiplied by .5
At 0%, all the rgb entries get multiplied by 0, and are totally black.


-- Goodlife

-----------------------------
Think of your mind as a door on a house. Leave the door always closed, and it's not a house, it's a prison. Leave the door always open, and it's not a house, it's a wilderness-- all the vermin creep in.
-- Goodlife-----------------------------Those whom the gods would destroy, they first drive mad.--DirectX design team official motto
Fades are better with gamma controls. See the DX help files.
Not everyone supports the fade gamma controls. If your game is coming out in the next two years, people will still have some non-gamma cards around.

Besides, it looks like this is 256 color mode fading-- is that supported in card gamma? I don''t know why it wouldn''t be, but it seems I read somewhere that you have to be in 16-color mode.

Best idea is to do it both ways, like I said, if your game is coming out in the next two years.


-- Goodlife

-----------------------------
Think of your mind as a door on a house. Leave the door always closed, and it's not a house, it's a prison. Leave the door always open, and it's not a house, it's a wilderness-- all the vermin creep in.
-- Goodlife-----------------------------Those whom the gods would destroy, they first drive mad.--DirectX design team official motto
BESIDES...
What the heck is wrong with knowing the real way to do it? I mean, lordy, all I see, day in and day out, are programmers whose answer to "how do I do this new thing" is "wait until Microsoft supports it!"

I mean, jeez, if he implements gamma fade himself, he can do all sorts of special effects-- fade every color but certain ones down (so monster eyes glow in the dark), fade certain colors in and out (can make certain areas of the screen look torchlit).

I''m tired of the old "Hey, how do I do this?" "Use the directx function to do it! It''s faster than anything YOU''LL ever come up with, you cretin! If it doesn''t support what you want to do, why do you want to do it???"

Man! In ten years, games are gonna progress about one inch, because we''re letting some API programmers do our innovating for us!



-- Goodlife

-----------------------------
Think of your mind as a door on a house. Leave the door always closed, and it's not a house, it's a prison. Leave the door always open, and it's not a house, it's a wilderness-- all the vermin creep in.
-- Goodlife-----------------------------Those whom the gods would destroy, they first drive mad.--DirectX design team official motto
Thankz everyone !

Yup, that''s a 256 color fadeout function, I wanna do that b''cuz gamma fadeout not support b4 DirectX5 (am i right ?), and not all vga card can do gamma fadeout in 256 color mode. I knew about gamma control in DirectX7, it''s cool but less portable.

Actually, I''m creating my own DX wrapper using early DX version with Lcc-win32(free Win32 C compiler).

Goodlife : I''ll try your method, thankz !!

This topic is closed to new replies.

Advertisement