Solved

Fade in DirectX

Posted on 2000-05-14
7
714 Views
Last Modified: 2013-12-26
Hello.

I'm writing a game (boring tetris clone, but it's a start). I now need to fade from my opening screen to the game screen, and the same from the game to gameover, highscore an things like that.

If you got a tutorial on that, using directX, or can show me where to get an example, it would help me a lot.

If it is written in VB you'll get an A for sure if it works.

Thanks
Endre
0
Comment
Question by:esolem
7 Comments
 

Expert Comment

by:dhaineault
ID: 2817918
I'm very new to DirectX, but in the DOS days, all you had to do was grab the color palette and, in a loop, decrease the intensity of each color until zero.

This worked fine for 256 colors, but I'm not certain if it is that easy with 16/24/32 bits.

So if DirectX supports palette manipulation (and I'm pretty sure it does), you may want to start looking there.
0
 

Accepted Solution

by:
Sadam earned 50 total points
ID: 2820302
When you initiate DDraw and create all your surfaces, create a palette too.

globals...

LPDIRECTDRAWPALETTE gvDDPalette = NULL;    
PALETTEENTRY Palette[256];


code..


// For this example i'll just setup a gray scale palette
for (n=0; n<256; n++)
{
   Palette[n].peRed   = n;
   Palette[n].peGreen = n;
   Palette[n].peBlue  = n;
}

hRet = gvDD->CreatePalette(DDPCAPS_8BIT, Palette, &gvDDPalette, NULL);
if (hRet != DD_OK) return(FALSE);

gvDDSPrimary->SetPalette(gvDDPalette);


Now you've created it.
When ever you want to change the palette just edit the Palette array and call...

gvDDPalette->SetEntries(0, 0, 256, Palette);




If you want to fade a screen out then just set the starting palette to that of your bitmap or currently visible surface, and then in a loop, decrement each of the palette values, until all of them are 0;


-out.
0
 

Author Comment

by:esolem
ID: 2821615
The code from Sadam looks good, but I'm using 16 bits colors.

So, I don't think I can use that method. Or am I wrong?


Endre
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Expert Comment

by:Sadam
ID: 2837774
Sorry I only answer now...

I didn't get a notification mail from EE???

Just lucky I checked here now.

anyway...

You can still create a palette in 16 bit color mode and it will not crash.

However it will have no effect.

But, 16 bit is also easy to fade.


Make the back surface equal to the contents of the front surface.

"Lock" the back surface to allow direct memory manipulation.

In a loop of sizeof(BackBuffer) decrement all the values a bit.

Swap the front and back buffers and do it again.

till it's all black.

easy.

-out.

0
 
LVL 5

Expert Comment

by:laeuchli
ID: 2838929
this might be more helpfull, I don't know. Anyway, check it out. Comes with full source.
http://www.gamedev.net/reference/programming/features/gamma/
0
 

Expert Comment

by:Sadam
ID: 2895854
Sheesh... Experts-Exchange doesn't mail me anymore.

Sorry for the delay, laeuchli.

I looked at the site... yep. It's the right way to fade.
It's better than mine too since you don't loose your primary surface data.

Oh well, I guess you've already done this. ?

-out.
0
 
LVL 5

Expert Comment

by:laeuchli
ID: 2897605
<<Oh well, I guess you've already done this. ? <<No, I don't use directx, so I never used that method.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now