Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

DirectXFreak

How to do Splash Screens

This topic is 5703 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
well, initializing a device generally takes less time than loading textures and levels, so you have two options:

- a gdi-based splash screen. create a window whose wndproc paints a nice picture all over itself, do the loading, destroy this window, then show your main window. pretty easy to implement. you can also use the main window for splash screen, but then you may have to resize it to fit your splash screen.

- d3d-based one. create a d3d object, create a device, and immediately draw something and call present(). then load whatever else you''ve got, and in the process the user will see your "splash" screen.

Paul DiLascia wrote a nice splash screen class that used a separate thread for message processing in msj a while ago (microsoft journal, now msdn magazine).

Share this post


Link to post
Share on other sites
I''d really recommend using multi-threading while in the splash screen (or loading screen for that matter).

If for some reason something fails and your program hangs, it will shut-down much cleaner if you''re reading the messages.

Nothing is more frustrating than a window that doesn''t close .

Share this post


Link to post
Share on other sites
Unreal Tournament (the original) used the GDI approach. But even using your rendering API is perfectly fine because it takes a split second to initialize. Initialize only the rendering API and use it to display the splash screen, then do everything else.

~CGameProgrammer( );

Share this post


Link to post
Share on other sites
Here''s Unreal''s splash screen code from UnEngineWin.h in UnrealPubSrc224v.zip. It shouldn''t take five minutes to remove the Unreal specific stuff...


//
// Splash screen, implemented with old-style Windows code so that it
// can be opened super-fast before initialization.
//
BOOL CALLBACK SplashDialogProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
return uMsg==WM_INITDIALOG;
}
HWND hWndSplash = NULL;
void InitSplash( HINSTANCE hInstance, UBOOL Show, const TCHAR* Filename )
{
if( Show )
{
hWndSplash = TCHAR_CALL_OS(CreateDialogW(hInstance, MAKEINTRESOURCEW(IDDIALOG_Splash), NULL, SplashDialogProc),CreateDialogA(hInstance, MAKEINTRESOURCEA(IDDIALOG_Splash), NULL, SplashDialogProc) );
check(hWndSplash);
FWindowsBitmap Bitmap;
verify(Bitmap.LoadFile( Filename ) );
INT screenWidth = GetSystemMetrics( SM_CXSCREEN );
INT screenHeight = GetSystemMetrics( SM_CYSCREEN );
HWND hWndLogo = GetDlgItem(hWndSplash,IDC_Logo);
check(hWndLogo);
ShowWindow( hWndSplash, SW_SHOW );
SendMessageX( hWndLogo, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)Bitmap.GetBitmapHandle() );
SetWindowPos( hWndSplash, NULL, (screenWidth - Bitmap.SizeX)/2, (screenHeight - Bitmap.SizeY)/2, Bitmap.SizeX, Bitmap.SizeY, 0 );
UpdateWindow( hWndSplash );
}
}
void ExitSplash()
{
if( hWndSplash )
DestroyWindow( hWndSplash );
}

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!