Solved

Fade in DirectX

Posted on 2000-05-14
7
718 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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 …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

813 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

18 Experts available now in Live!

Get 1:1 Help Now