Example #1
0
static int
getvideomode(void)
{
    int mode = ScreenMode();
    /*
     * in mode C80 we might have loaded a different font
     */
    if (mode == C80)
        if (ScreenRows() > 25)
           mode = C4350;
    return(mode);
}
	Image* RenderBackendSDL::setScreenMode(const ScreenMode& mode) {
		uint16_t width = mode.getWidth();
		uint16_t height = mode.getHeight();
		uint16_t bitsPerPixel = mode.getBPP();
		bool fs = mode.isFullScreen();
		uint32_t flags = mode.getSDLFlags();

		SDL_Surface* screen = NULL;

		if (bitsPerPixel != 0) {
			uint16_t bpp = SDL_VideoModeOK(width, height, bitsPerPixel, flags);
			if (!bpp){
				throw SDLException("Selected video mode not supported!");
			}
		}

		screen = SDL_SetVideoMode(width, height, bitsPerPixel, flags);
		if( !screen ) {
			throw SDLException("Unable to set video mode selected!");
		}

		FL_LOG(_log, LMsg("RenderBackendSDL")
			<< "Videomode " << width << "x" << height
			<< " at " << int(screen->format->BitsPerPixel) << " bpp");

		//update the screen mode with the actual flags used
		m_screenMode = ScreenMode(width,
		                          height,
		                          bitsPerPixel,
		                          screen->flags);

		if (!screen) {
			throw SDLException(SDL_GetError());
		}

		delete m_screen;
		m_screen = new SDLImage(screen);
		return m_screen;
	}
Example #3
0
	ScreenMode DeviceCaps::getNearestScreenMode(uint16_t width, uint16_t height, uint16_t bpp, const std::string& renderer, bool fs) const {
		ScreenMode mode;
		bool foundMode = false;

		bool widthCheck = false;
		bool heightCheck = false;
		bool bppCheck = false;
		bool rendCheck = false;
		bool fsCheck = false;


		for (uint32_t i = 0; i < m_screenModes.size(); i++) {
			if (m_screenModes[i].getWidth() == width) {
				widthCheck = true;
			}
			if (m_screenModes[i].getHeight() == height) {
				heightCheck = true;
			}
			if (m_screenModes[i].getBPP() == bpp) {
				bppCheck = true;
			}
			if (m_screenModes[i].isFullScreen() == fs) {
				fsCheck = true;
			}

			if ((m_screenModes[i].isOpenGL() && (renderer == "OpenGL" || renderer == "OpenGLe")) || (!m_screenModes[i].isOpenGL() && renderer == "SDL")){
				rendCheck = true;
			}

			//check for exact match
			if (widthCheck && heightCheck && bppCheck && fsCheck && rendCheck) {
				mode = m_screenModes[i];
				foundMode = true;
				break;
			}

			//@note When the width and height to 0 that means that all
			//resolutions are supported
			if (m_screenModes[i].getWidth() == 0 && m_screenModes[i].getHeight() == 0 && bppCheck && fsCheck && rendCheck) {
				mode = ScreenMode(width, height, bpp, m_screenModes[i].getSDLFlags());
				foundMode = true;
				break;
			}

			//current screen bpp selected
			if (widthCheck && heightCheck && bpp == 0 && fsCheck && rendCheck) {
				mode = ScreenMode(width, height, bpp, m_screenModes[i].getSDLFlags());
				foundMode = true;
				break;
			}

			if (m_screenModes[i].getWidth() == 0 && m_screenModes[i].getHeight() == 0  && bpp == 0 && fsCheck && rendCheck) {
				mode = ScreenMode(width, height, bpp, m_screenModes[i].getSDLFlags());
				foundMode = true;
				break;
			}


			widthCheck = false;
			heightCheck = false;
			bppCheck = false;
			rendCheck = false;
			fsCheck = false;
		}

		if (!foundMode) {
			throw NotSupported("Could not find a maching screen mode for the values given!");
		}

		return mode;
	}
Example #4
0
	void DeviceCaps::fillDeviceCaps() {
		//buffer to store driver name
		const uint32_t bufferSize = 256;
		char buffer[bufferSize];

		//clear in case this is called twice
		reset();

		//FLAGS
#ifdef HAVE_OPENGL
		const uint32_t numFlags = 6;
		uint32_t flags[numFlags];

		//OpenGL, windowed, hw accel
		flags[0] = ScreenMode::HW_WINDOWED_OPENGL;
		//OpenGL, fullscree, hw accel
		flags[1] = ScreenMode::HW_FULLSCREEN_OPENGL;
		//SDL, windowed
		flags[2] = ScreenMode::WINDOWED_SDL;
		//SDL, windowed, hw surface, double buffer
		flags[3] = ScreenMode::WINDOWED_SDL_DB_HW;
		//SDL, fullscreen
		flags[4] = ScreenMode::FULLSCREEN_SDL;
		//SDL, fullscreen, hw surface, double buffer
		flags[5] = ScreenMode::FULLSCREEN_SDL_DB_HW;

#else
		const uint32_t numFlags = 4;
		uint32_t flags[numFlags];

		//SDL, windowed
		flags[0] = ScreenMode::WINDOWED_SDL;
		//SDL, windowed, hw surface, double buffer
		flags[1] = ScreenMode::WINDOWED_SDL_DB_HW;
		//SDL, fullscreen
		flags[2] = ScreenMode::FULLSCREEN_SDL;
		//SDL, fullscreen, hw surface, double buffer
		flags[3] = ScreenMode::FULLSCREEN_SDL_DB_HW;
#endif

		//BITS PER PIXEL
		const uint32_t numBPP = 3;
		uint16_t bpps[numBPP];

		bpps[0] = 16;
		bpps[1] = 24;
		bpps[2] = 32;

		//COMMON FS RESOLUTIONS
		const uint32_t numRes = 16;
		uint16_t resolutions[numRes][2] = {
			{640, 480},
			{800, 600},
			{1024, 600},
			{1024, 768},
			{1152, 864},
			{1280, 768},
			{1280, 800},
			{1280, 960},
			{1280, 1024},
			{1366, 768},
			{1440, 900},
			{1600, 900},
			{1600, 1200},
			{1680, 1050},
			{1920, 1080},
			{1920, 1200}
		};


		for (uint32_t i = 0; i < numBPP; ++i){
			for (uint32_t j = 0; j < numFlags; ++j) {
				for ( uint32_t k = 0; k < numRes; ++k) {
					uint16_t bpp;
					if (flags[j] & SDL_FULLSCREEN) {
						bpp = SDL_VideoModeOK(resolutions[k][0],resolutions[k][1], bpps[i], flags[j]);

						if (bpp > 0) {
							m_screenModes.push_back(ScreenMode(resolutions[k][0],resolutions[k][1], bpps[i], flags[j]));
						}
					}
					else {  //windowed mode
						//check an arbitrary value as we know all resolutions are supported in windowed mode.
						//we are checking to make sure the bpp is supported here.
						bpp = SDL_VideoModeOK(resolutions[k][0],resolutions[k][1], bpps[i], flags[j]);
						if (bpp > 0) {
							m_screenModes.push_back(ScreenMode(0,0, bpps[i], flags[j]));
							break; //insert windowed mode once as all resolutions are supported.
						}
					}

				}
			}
		}

		//sort the list to keep the most preferred modes at the top of the selection process
		//in getNearestScreenMode()
		std::sort(m_screenModes.begin(), m_screenModes.end());
		std::reverse(m_screenModes.begin(), m_screenModes.end());

		if(SDL_VideoDriverName(buffer, bufferSize) != NULL) {
			m_driverName = std::string(buffer);
		}
		else {
			m_driverName = "Unknown";
		}

		const SDL_VideoInfo* vInfo = SDL_GetVideoInfo();

		m_hwAvailable = vInfo->hw_available;
		m_wmAvailable = vInfo->wm_available;
		m_hwBlitAccel = vInfo->blit_hw;
		m_hwCCBlitAccel = vInfo->blit_hw_CC;
		m_hwToHwAlphaBlitAccel = vInfo->blit_hw_A;
		m_swToHwBlitAccel = vInfo->blit_sw;
		m_swToHwCCBlistAccel = vInfo->blit_sw_CC;
		m_swToHwAlphaBlitAccel = vInfo->blit_sw_A;
		m_BlitFillAccel = vInfo->blit_fill;
		m_videoMem = vInfo->video_mem;
		m_desktopWidth = vInfo->current_w;
		m_desktopHeight = vInfo->current_h;
	}