コード例 #1
0
ファイル: Window.cpp プロジェクト: cristicbz/AdventureMiner
	void Window::setVideoMode( const VideoMode& mode ) {
		log << "Setting video mode " << mode << ".\n";

		if(!mode.isValid()) {
			log << "VideoModeNotSupportedException raised.\n";
			throw VideoModeNotSupportedException();
		}

		if( mode == mode_ ) {
			log << "No changes detected. Not doing anything.\n";
			return;
		}

		bool opOk;
		int w = mode.getWidth();
		int h = mode.getHeight();
		int bpp = mode.getBpp();
		int flags = SDL_OPENGL;

		if( mode.isFullscreen() )
			flags |= SDL_FULLSCREEN;

		if( !mode.isDecorated() )
			flags |= SDL_NOFRAME;

		_putenv(_strdup("SDL_VIDEO_CENTERED=1")); 
		SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);
		SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL,mode.hasVSync()?1:0);
		
		opOk = SDL_SetVideoMode(w,h,bpp,flags) != 0;
		if( !opOk ) {
			log << "Warning: Mode reported it was valid, but SDL_SetVideoMode() failed.\n";
			throw VideoModeNotSupportedException();
		}

		mode_ = mode;
		log << "Video mode set.\n";
	}