Advertisement

changing display mode in menu

Started by July 05, 2001 10:08 AM
2 comments, last by leblebi 23 years, 7 months ago
How can I change the displaymode from one to another. It is always fullscreen. I think simply using ChangeDisplaySettings(blah, blah); should work(without destroying-recreating anything), but it seems it is not working. Any ideas?
Try this code:

  // Change screen size and resolution (Full Screen)void ChangeScreen(HWND hwnd, int width, int height, int bits){	DEVMODE dmScreenSettings;								// Device Mode	memset(&dmScreenSettings,0,sizeof(dmScreenSettings));	// Makes Sure Memory''s Cleared	dmScreenSettings.dmSize=sizeof(dmScreenSettings);		// Size Of The Devmode Structure	dmScreenSettings.dmPelsWidth	= width;				// Selected Screen Width	dmScreenSettings.dmPelsHeight	= height;				// Selected Screen Height	dmScreenSettings.dmBitsPerPel	= bits;					// Selected Bits Per Pixel	dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;	// Try To Set Selected Mode And Get Results.  NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.	if(ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)		SHOW_ERROR("Requested Screen Parameters not supported on your video card", 0);	SetWindowPos(hwnd, HWND_TOP, 0, 0, width, height, SWP_SHOWWINDOW);		bWindowed = TRUE;}  


Also remember to change the perspective and viewport:

  		case WM_SIZE:			{				int width = LOWORD(lparam);  // width of client area 				int height = HIWORD(lparam); // height of client area  				if (height==0)		// Prevent A Divide By Zero By					height=1;									glViewport(0,0,width,height);	// Reset The Current Viewport				glMatrixMode(GL_PROJECTION);	// Select The Projection Matrix				glLoadIdentity();				// Reset The Projection Matrix				// Calculate The Aspect Ratio Of The Window				gluPerspective(22.0f,(GLfloat)width/(GLfloat)height, 1.0f,4000.0f);								// Changes Viewport				glViewport(0, 0, width, height);				glMatrixMode(GL_MODELVIEW);		// Select The Modelview Matrix				glLoadIdentity();								SCREEN_WIDTH  = width;				SCREEN_HEIGHT = height;				break;			}  


... And don''t forget to restore the default display mode when on exit:

  case WM_DESTROY:			{				// Deselect the current rendering context and delete it				wglMakeCurrent(hdc,NULL);				wglDeleteContext(hrc);				// Delete the palette (if any)				if(hPalette != NULL)					DeleteObject(hPalette);				// Set display settings to normal				ChangeDisplaySettings(NULL,0);				quit = TRUE;				PostQuitMessage(0);				break;			}  


Hope this help!

mailto:ramirez2@entelchile.net

Cristián Ramírez (gameovercl)
ICQ #38991565
Viña del Mar
CHILE
Advertisement
thanx. I forgot to SetWindowPos().
Oztan what is your mail adress ?
Baris "ßrok£N®" AKIN

This topic is closed to new replies.

Advertisement