Jump to content
  • Advertisement
Sign in to follow this  
Drakon

Changing resolution causes bitmaps to not appear

This topic is 4843 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

I've been struggling with this tutorial for a while now thinking it just wasn't working... then I turned off the code that changes my resolution, and it worked fine. Commenting out if ( FAILED( lpDD->SetDisplayMode( 800, 600, 16, 0, 0 ) ) ) return FALSE; will let it run fine, and bitmaps display fine. Uncommented, it changes the res, but I can't see my bitmaps. Any way to have both?
//static void InitApp(HINSTANCE hInstance,int nCmdShow)
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)

{
WNDCLASS		windowClass;
HWND			hwnd;

	// fill out the window class structure
	//windowClass.cbSize			= sizeof(WNDCLASS);
	windowClass.style			= CS_HREDRAW || CS_VREDRAW;
	windowClass.lpfnWndProc		= WndProc;
	windowClass.cbClsExtra		= 0;
	windowClass.cbWndExtra		= 0;
	windowClass.hInstance		= hInstance;
	windowClass.hIcon			= LoadIcon(NULL, IDI_APPLICATION);			// default icon
	windowClass.hCursor			= LoadCursor(NULL, IDC_ARROW);				// default arrow
	windowClass.hbrBackground	= (HBRUSH)GetStockObject(BLACK_BRUSH);		// white background
	windowClass.lpszMenuName	= NULL;										// no menu
	windowClass.lpszClassName	= "MyClass";
	//windowClass.hIconSm			= LoadIcon(NULL, IDI_WINLOGO);			// windows logo small icon
	
	if (!RegisterClass(&windowClass)) 
	{
	//	cErrorReporter.WriteErrorMessage(ERR_REGISTERCLASS,true);
	}

	hwnd = CreateWindowEx(NULL,								// extended style
						  "MyClass",						// class name
						  "A REAL Windows Application!",	// app name
						  WS_POPUP | WS_VISIBLE,	// style
						  100, 100,							// x,y coordinate
						  400, 400,							// width, height
						  NULL,								// handle to parent
						  NULL,								// handle to menu
						  hInstance,						// application instance
						  NULL);
	
	if (!hwnd) 
	{
	//	cErrorReporter.WriteErrorMessage(ERR_CREATEWIN,true);
	}

	ShowWindow(hwnd,nCmdShow);
	UpdateWindow(hwnd);

if ( FAILED( DirectDrawCreateEx( NULL, ( LPVOID* )&lpDD,IID_IDirectDraw7, NULL ) ) )
{
   return FALSE;
}

if ( FAILED( lpDD->SetCooperativeLevel( hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT ) ) )
   return FALSE;

if ( FAILED( lpDD->SetDisplayMode( 800, 600, 16, 0, 0 ) ) )
   return FALSE;

ZeroMemory( &ddsd, sizeof( ddsd ) );
ddsd.dwSize = sizeof( ddsd );

ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;

ddsd.dwBackBufferCount = 1;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;

if ( FAILED( lpDD->CreateSurface( &ddsd, &lpDDSPrimary, NULL ) ) )
   return FALSE;

ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;

if ( FAILED( lpDDSPrimary->GetAttachedSurface( &ddsd.ddsCaps, &lpDDSBack ) ) )
   return FALSE;

if ( ( lpDDSBitmap = DDLoadBitmap( lpDD, "blue.bmp", 0, 0) ) == NULL )
   return FALSE;


RECT rcFrom;
rcFrom.left = 0;
rcFrom.top = 0;
rcFrom.right = 800;
rcFrom.bottom = 600;

if ( FAILED( lpDDSBack->BltFast( 0, 0, lpDDSBitmap, &rcFrom, DDBLTFAST_WAIT ) ) )
   return FALSE; 
if ( FAILED( lpDDSPrimary->BltFast( 0, 0, lpDDSBitmap, &rcFrom, DDBLTFAST_WAIT ) ) )
   return FALSE; 


return TRUE;
}

Share this post


Link to post
Share on other sites
Advertisement
Hi there Drakon,
How are you doing?

[The Problem]
Your bitmaps are not displaying when you resize the window?

[The Solution]
The most probable cause of this might be that your device is being lost in the resizing of the window.

Read this part of the documentation on handling lost devices.
Handling Lost Devices

I hope this helps a bit.
Take care.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!