Advertisement Jump to content


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


Change screen res on runtime

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

Hi, I'm having problme changening the screen res during run time. When I use the folowing code:
bool DD::ChangeScreenRes()

// screenWidht, screenHeight and ScreenBpp are global variables

	// release the clipper first

	if (lpddclipper != NULL) {
		lpddclipper = NULL;
		WriteLog("Clipper released\n");

	// release the secondary surface

	if (lpddsback != NULL) {
		lpddsback = NULL;
		WriteLog("Backbuffer released\n");

	// release the primary surface

	if (lpddsprimary != NULL) {
	   lpddsprimary = NULL;
	   WriteLog("Primary surface released\n");

	// Set the display mode

	if (FAILED(lpdd->SetDisplayMode(screenWidth,screenHeight,screenBpp,0,0))) {
		WriteLog("SetDisplayMode(%d,%d,%d) failed !\n", screenWidth, screenHeight, screenBpp);
		return false;
	WriteLog("SetDisplayMode(%d,%d,%d) success\n", screenWidth, screenHeight, screenBpp);

	// Create the primary surface

	ddsd.dwSize = sizeof(ddsd);

	// We need to let dd know that we want a complex 

	// flippable surface structure, set flags for that


	// Set the backbuffer count to 1

	ddsd.dwBackBufferCount = 1;

	// Create the primary surface

	if(FAILED(lpdd->CreateSurface(&ddsd,&lpddsprimary,NULL))) {
		WriteLog("CreateSurface() failed\n");
		return false;

	// Query for the backbuffer i.e the secondary surface

	ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
	if(FAILED(lpddsprimary->GetAttachedSurface(&ddscaps,&lpddsback))) {
		WriteLog("GetAttachedSurface() failed\n");
		return false;

	return true;
The game boots me back to windows (win 2k) when I try to change the res (no matter if I go form 1024x768 to 800x600 or vise versa). Before I call the function I release all my graphic and then reload it after. I have alos tried with completely shuting down direct draw and then re-initializing it with the new screen size but then SetCooperativeLevel() fails. Any idea as to what might be causing this problem? Thanks in advance Leon Ljunggren [Edit] Fixed code box [edited by - Spearhawk on June 28, 2002 11:50:22 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!