![]() |
| [[ Home | Forums | 3D Engines Database | Wiki | Articles/Tutorials | Game Dev Jobs | IRC Chat Network | Contact Us ]] |
|
|
#1 |
|
DevMaster Staff
Join Date: Oct 2004
Location: Seattle, WA
Posts: 3,707
|
Many games take up the entire screen, and when they start up there is often an unsightly few seconds in which the window creation, video mode changes and so forth cause the screen to flicker, the desktop to wink in and out of existence, and so forth. This code sample shows how to make the desktop smoothly fade to black when an application starts, allowing the messy details of graphics initialization to be hidden.
The demo operates by creating a borderless, captionless popup window covering the entire screen. Initially, this window is transparent because it does not paint itself. Then an OpenGL context is created that has no back buffer, so all draw calls operate directly on the displayed image. Each frame, a full-screen alpha-blended rectangle is drawn, fading the image gradually toward black. Any color (or texture) could be chosen, but black is probably the best in most cases. After the fadeout is complete, the application can switch video modes and create its main window, and then destroy the fadeout window. The demo program creates a new OpenGL context and renders a spinning cube until you press Escape. The core of the effect is in this message handler for the fadeout window: Code:
I have tried the program on an nVIDIA GeForce 6800 and on an ATI Radeon 9600, but I would love to hear if it works (or fails) on other cards. :) The full source code and binary are available here, with the source distributed under the BSD license. The source also demonstrates some parts of a lightweight, extensible framework for graphics applications that I've been developing for an engine I'm working on. Some improvements that could be made to the code: * Sometimes on ATI cards the taskbar isn't affected by the fadeout, though it disappears a few seconds after the main window is created. You might be able to fix this by making the fadeout window "topmost," though I haven't gotten around to trying it. * Some useful work, like loading resources, could be done in the background while the fadeout is occurring. Currently the program just enters a busy wait between frames: since the window is not validated, Windows spams us with WM_PAINT messages, which are ignored until it's time for the next fadeout frame. This could be done with a timer instead. |
|
|
|
|
|
#2 |
|
DevMaster Staff
Join Date: Sep 2003
Location: Hell
Posts: 1,109
|
I like it, I like it a lot. Thanks for sharing this.
Works perfectly on a gf4 ti 4200. |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Oct 2005
Location: Pensacola, FL
Posts: 1,028
|
Works great with a Mobile Intel 915GM Express on this laptop. Looks sexy, I like it!
Were transparent windows supported prior to Windows 2000/XP? I'm just wondering if this would fail on Windows 98, but that may not matter much anymore... ![]() |
|
|
|
|
|
#4 | |
|
DevMaster Staff
Join Date: Oct 2004
Location: Seattle, WA
Posts: 3,707
|
Quote:
It's only transparent in the sense that it fails to paint itself or establish a background brush, so I think it should still work on Win98. I know XP has some fancy features for alpha-blended windows and stuff, but I'm not using that ![]()
___________________________________________
Currently working at Sucker Punch reedbeta.com - OpenGL demos and other projects Luabridge - a lightweight, dependency-free C++/Lua binding library. CD Lite - an unobtrusive, minimal CD player application for Windows. |
|
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Sep 2005
Location: Jönköping, Sweden
Posts: 546
|
Great idea, works fine here too.
Still, there is a really akward color artifact visible. The colors don't fade to black linearly. It looks more like when you move your head in front of an old, low quality LCD screen. I think this might look better if the number of fading frames was lower, so the integer math would get some more precission to play with. |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Sep 2005
Location: .nl
Posts: 505
|
very sexy. on my ati 9600 the taskbar remains visible indeed.
|
|
|
|
|
|
#7 |
|
Member
Join Date: Jun 2005
Posts: 62
|
I really like this, nice work!
|
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Jan 2003
Location: Switzerland
Posts: 1,333
|
works great. only the always-on-top friend-icons from msgplus have some issue while blending..
haw about fading back once you quit your app? ![]()
___________________________________________
davepermen.net -Loving a Person is having the wish to see this Person happy, no matter what that means to yourself. -No matter what it means to myself.... |
|
|
|
|
|
#9 |
|
New Member
Join Date: Sep 2005
Location: Netherlands
Posts: 4
|
Very nice!
I might use this in my programs in the future. It works on my ATI Radeon 9200SE. Though I think I might have to reset my refresh rate now, I'm getting headaches now just looking at my screen (started the moment I pressed Escape). But I don't think it's something to do with your program. Well, it might, since this only happens to some fullscreen programs. |
|
|
|
|
|
#10 |
|
Valued Member
Join Date: Aug 2004
Location: Quebec, Canada
Posts: 109
|
awesome!
I really like it, makes your spinning cube application look real polished ![]() thanks for the tip |
|
|
|
|
|
#11 |
|
New Member
Join Date: Dec 2005
Posts: 5
|
Really cool Reedbeta
Works fine on my gf7800gt (winxp sp2 - forceware 84.21) and on my X700pro (winxp sp2 - catalyst 6.3). Last edited by JeGX : 04-16-2006 at 12:47 PM. |
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|