Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

nlo

FadeOut problem using directdraw palette ?!

This topic is 6936 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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[i].peRed<0) tempPal[i].peRed=0; tempPal[i].peGreen--; if(tempPal[i].peGreen<0) tempPal[i].peGreen=0; tempPal[i].peBlue--; if(tempPal[i].peBlue<0) tempPal[i].peBlue=0; //tempPal[i].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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 !!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!