Jump to content
  • Advertisement

Archived

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

iedirisi

Screen Fades in DirectDraw

This topic is 5855 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 am putting the finishing touches on my tetris clone and I''m wondering if someone could point me in the right direction about implementing screen fades in DirectDraw. The only article I have found uses Gamma Controls but it says you need atleast a 16-bit primary surface to use that technique. My game runs in 8-bit color at 640 by 480 resolution. Any hints would be greatly appreciated.

Share this post


Link to post
Share on other sites
Advertisement
If it''s in 8-bit colour, then simply step through your palette and decrement each colour a certain amount each frame.

Share this post


Link to post
Share on other sites
Hi,
as i think - change brightness in 256-color mode more simply than in others, because you don''t need to change huge surface data, you need only change palette. There procedure which i already use.( In bottom of message )

I have only one problem to change brightness with palette -
in different videocards it''s work not equal. For example on
1 Mb ATI - it work very fast (FPS = 80), but in 32 Mb Riva TNT 2 Pro its very slow (FPS = 20). Because calling one of this methods:
FDDPal.SetEntries(0,0,256,@RealPalette)
or
FDDSPrimary.SetPalette(FDDPal);
(i don''t remember exact which one ...) take very much time.
Why so, i dont know , somebody talk - "it''s because videoadapter
waiting some event for refreshing palette "...

---------------------------------------------------------------
/// DirectDraw Objects
var
// DirectDraw Palette object must be init before calling
//brightness procedure
FDDPal:IDirectDrawPalette;

// PrimarySurface,,,
FDDSPrimary:IDirectDrawSurface;


var
// This array store palette from source bitmap, it''s not
// changing during all time of work
Palette :array [0..255] of TPaletteEntry;

//This array store current palette, which may be
// more darken or lighten than source Palette.
// Its data changing by calling Brightness procedure
RealPalette:array [0..255] of TPaletteEntry;

/////////////////////////////////////////////////////////////
BRIGHTNESS
///////////////////////////////////////////////////////////
/// Value changes from 0-1; ...it also may be more than 1
/// it''s look as more lighten image than source.
/// 0 - full darkness
/// 1 - normal
procedure Brightness(Value:single);
var
I,J:integer;
RB,GB,BB:byte
hRet:HRESULT;
begin

for I:=0 to 255 do begin

if round(Palette.peRed*Value)<=255 then RB:=round(Palette[I].peRed*Value) else RB:=255;

if round(Palette[I].peGreen*Value)<=255 then GB:=round(Palette[I].peGreen*Value) else GB:=255;
if round(Palette[I].peBlue*Value)<=255 then BB:=round(Palette[I].peBlue*Value) else BB:=255;

RealPalette[I].peRed:=RB;
RealPalette[I].peGreen:=GB;
RealPalette[I].peBlue:=BB;
end;

FDDPal.SetEntries(0,0,256,@RealPalette);
FDDSPrimary.SetPalette(FDDPal);

end;
//////////////////////////////////////////////

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!