Solved

Fade in DirectX

Posted on 2000-05-14
7
723 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

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 …
As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

679 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