Example #1
0
void Vid::SetMode( int ModeValue ) {
	if ( BackBuffer ) {
		Shutdown();
	}

	WindowWidth = ModeList[ModeValue].Width;
	WindowHeight = ModeList[ModeValue].Height;

	BufferHeight = WindowHeight;
	BufferWidth = WindowWidth;

	if ( ModeList[ModeValue].Type == ModeState::WINDOWED ) {
		SetWindowedMode( ModeValue );
	} else {
		SetFullscrenMode( ModeValue );
	}

	ShowWindow( MainWindow, SW_SHOWDEFAULT );

	HDC DeviceContext = GetDC( MainWindow );
	PatBlt( DeviceContext, 0, 0, BufferWidth, BufferHeight, BLACKNESS );
	ReleaseDC( MainWindow, DeviceContext );

	// define our bitmap info
	BitMapInfo.bmiHeader.biSize = sizeof( BitMapInfo.bmiHeader );
	BitMapInfo.bmiHeader.biWidth = BufferWidth;
	BitMapInfo.bmiHeader.biHeight = -BufferHeight;
	BitMapInfo.bmiHeader.biPlanes = 1;
	BitMapInfo.bmiHeader.biBitCount = 8 * BytesPerPixel;
	BitMapInfo.bmiHeader.biCompression = BI_RGB;

	BackBuffer = FrameBuffer( BufferWidth, BufferHeight, BytesPerPixel );
}
Example #2
0
void WindowManager::ProcessEvent(SDL_Event *event)
{
	MainMenu *mainmenu = (MainMenu *)SM->GetSceneByName("Main Menu");
	OptionsMenu *optionsmenu = (OptionsMenu *)SM->GetSceneByName("Options Menu");
	switch(event->type)					// See which event it is
    {
		// When window is resized or is toggled between window and fullscreen
	case SDL_VIDEORESIZE:
		//Cleanup();
		InitOpenGL();
		IsGLErrors("Video Resize");
		if(!WM->IsFullscreen())
		{
			SetWindowedMode(0, 0, event->resize.w, event->resize.h);
		}
		glViewport(0,0,event->resize.w,event->resize.h);		// Resize OpenGL Viewport to fit the screen/window
		SM->InitAll();
		break;
		// When user quits the game
	case SDL_VIDEOEXPOSE:
		if(Game->GetCurrentMode() != GM_PLAY)
		{
			mainmenu->Resize();
			optionsmenu->Resize();
		}
		break;
    case SDL_QUIT:
		_Running=false;
        break;
	case SDL_ACTIVEEVENT:
		if(event->active.state & SDL_APPACTIVE)
		{
			if(event->active.gain)
				_Active = true;
			else
				_Active = false;
		}
		break;
	default:
		break;
	}
}