Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Fade in DirectX

Posted on 2000-05-14
7
720 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

839 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