Skip to main content
gamedev.net
🔒 Locked

Problems showing bitmap

Started by drb2k2 May 5, 2004 at 4:03 PM 0 replies 200+ views
Original Post
drb2k2
drb2k2
Hi all i'm trying to display a simple bitmap as a start screen to a game. At the moment i'm not too bothered about switching into the game. In a test program where I wrote the CGDIBitmap class (g_BitmapHelper is an instance of this)it all worked fine. However now I've put it into my main code it doesn't work. The error is definately in this code as the class does work! Here is the relevant code:
 // Register the window class

    WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, 
                      GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
                      "3D Game", NULL };
	
    RegisterClassEx( &wc );

    // Create the application's window

	HWND hWnd = CreateWindow( "3D Game", "3D Game:", 
                              WS_OVERLAPPEDWINDOW, 0, 0, 1024, 768,
                              GetDesktopWindow(), NULL, wc.hInstance, NULL );


    // Initialize Direct3D

    if( SUCCEEDED( InitD3D( hWnd ) ) )
    { 
        // Create the scene geometry

        if( SUCCEEDED( InitGeometry() ) )
        {
            // Show the window

            ShowWindow( hWnd, SW_SHOWDEFAULT );
            UpdateWindow( hWnd );
			SetupMatrices();


            // Enter the message loop

            MSG msg; 
            ZeroMemory( &msg, sizeof(msg) );


			HDC hdcWindow = GetDC(hWnd);
			HDC CompatibleBitmap = CreateCompatibleDC(hdcWindow);
			g_BitmapHelper.Load(CompatibleBitmap,"StartMenu.bmp");
			ReleaseDC(hWnd, hdcWindow);

			// get the time instance

			TimeInterval();
            while( msg.message!=WM_QUIT )
            {
                if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
                {
                    TranslateMessage( &msg );
                    DispatchMessage( &msg );
                }
                else
					ShowWelcome(hWnd);
                 //   GameLoop();


            }
        }
    }


    UnregisterClass( "3D Game", wc.hInstance );
    return 0;
}


   
void ShowWelcome(HWND hWnd)
{
			PAINTSTRUCT ps;

			// get the DC we're supposed to use from Windows

			BeginPaint(hWnd, &ps);
			HDC hdc = ps.hdc;
      
			// paint our window (function is defined above)

			//PaintWindow(hdc);

			SetMapMode(hdc, MM_TEXT);
			StretchBlt(hdc,0, 0, 1024, 768,g_BitmapHelper.GetBitmapDC(), 0, 0, g_BitmapHelper.GetWidth(), g_BitmapHelper.GetHeight(), SRCCOPY);
			// tell Windows we're done painting.

			EndPaint(hWnd, &ps);
			
}
What happens is that the window appears in the taskbar, but nothing is displayed. If I minimize then maximise the window the frame appears for a second then does nothing. Can anyone point me in the direction of what is going wrong. Cheers DRb2k2 [edited by - drb2k2 on May 5, 2004 5:04:54 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.