?
Solved

Fade in DirectX

Posted on 2000-05-14
7
Medium Priority
?
742 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
[X]
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
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 100 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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: 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.

Question has a verified solution.

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

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 …
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

650 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