Screen Fades in DirectDraw

Started by
2 comments, last by iedirisi 21 years, 10 months ago
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.
Advertisement
If it''s in 8-bit colour, then simply step through your palette and decrement each colour a certain amount each frame.
Thanks for the reply, I''ll definitely try that.



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.peRed*Value) else RB:=255;<br><br> if round(Palette.peGreen*Value)<=255 then GB:=round(Palette.peGreen*Value) else GB:=255;<br> if round(Palette.peBlue*Value)<=255 then BB:=round(Palette.peBlue*Value) else BB:=255;<br><br> RealPalette.peRed:=RB;<br> RealPalette.peGreen:=GB;<br> RealPalette.peBlue:=BB;<br> end;<br> <br> FDDPal.SetEntries(0,0,256,@RealPalette);<br> FDDSPrimary.SetPalette(FDDPal);<br> <br>end;<br>//////////////////////////////////////////////<br><br> </i>

This topic is closed to new replies.

Advertisement