Esempio n. 1
0
void AddSupportedModesForBPP(GraphicsDevice *device, int bpp)
{
	SDL_Rect** modes;
	SDL_PixelFormat fmt;
	int i;
	memset(&fmt, 0, sizeof fmt);
	fmt.BitsPerPixel = (Uint8)bpp;

	modes = SDL_ListModes(&fmt, SDL_FULLSCREEN);
	if (modes == (SDL_Rect**)0)
	{
		return;
	}
	if (modes == (SDL_Rect**)-1)
	{
		return;
	}

	for (i = 0; modes[i]; i++)
	{
		int validScaleFactors[] = { 1, 2, 3, 4 };
		int j;
		for (j = 0; j < 4; j++)
		{
			int scaleFactor = validScaleFactors[j];
			int w, h;
			if (modes[i]->w % scaleFactor || modes[i]->h % scaleFactor)
			{
				continue;
			}
			if (modes[i]->w % 4)
			{
				// TODO: why does width have to be divisible by 4? 1366x768 doesn't work
				continue;
			}
			w = modes[i]->w / scaleFactor;
			h = modes[i]->h / scaleFactor;
			if (w < 320 || h < 240)
			{
				break;
			}
			AddGraphicsMode(device, w, h, scaleFactor);
		}
	}
}
Esempio n. 2
0
int CGraphics_SDL::GetVideoModes(CVideoMode *pModes, int MaxModes)
{
	int NumModes = sizeof(g_aFakeModes)/sizeof(CVideoMode);
	SDL_Rect **ppModes;

	if(g_Config.m_GfxDisplayAllModes)
	{
		int Count = sizeof(g_aFakeModes)/sizeof(CVideoMode);
		mem_copy(pModes, g_aFakeModes, sizeof(g_aFakeModes));
		if(MaxModes < Count)
			Count = MaxModes;
		return Count;
	}
	
	// TODO: fix this code on osx or windows
		
	ppModes = SDL_ListModes(NULL, SDL_OPENGL|SDL_GL_DOUBLEBUFFER|SDL_FULLSCREEN);
	if(ppModes == NULL)
	{
		// no modes
		NumModes = 0;
	}
	else if(ppModes == (SDL_Rect**)-1)
	{
		// all modes
	}
	else
	{
		NumModes = 0;
		for(int i = 0; ppModes[i]; ++i)
		{
			if(NumModes == MaxModes)
				break;
			pModes[NumModes].m_Width = ppModes[i]->w;
			pModes[NumModes].m_Height = ppModes[i]->h;
			pModes[NumModes].m_Red = 8;
			pModes[NumModes].m_Green = 8;
			pModes[NumModes].m_Blue = 8;
			NumModes++;
		}
	}
	
	return NumModes;
}
GHOST_TSuccess GHOST_DisplayManagerSDL::getNumDisplaySettings(GHOST_TUns8 display,
        GHOST_TInt32& numSettings) const
{
    GHOST_ASSERT(display < 1, "Only single display systems are currently supported.\n");
    int i;
    SDL_Rect **vidmodes;

    vidmodes = SDL_ListModes(NULL, SDL_HWSURFACE | SDL_OPENGL |
                             SDL_FULLSCREEN | SDL_HWPALETTE);
    if (!vidmodes) {
        fprintf(stderr, "Could not get available video modes: %s.\n",
                SDL_GetError());
        return GHOST_kFailure;
    }
    for (i = 0; vidmodes[i]; i++);
    numSettings = GHOST_TInt32(i);

    return GHOST_kSuccess;
}
Esempio n. 4
0
File: sdl_vid.c Progetto: otty/cake3
/*
===============
GLimp_DetectAvailableModes
===============
*/
static void GLimp_DetectAvailableModes(void)
{
	char            buf[MAX_STRING_CHARS] = { 0 };
	SDL_Rect      **modes;
	int             numModes;
	int             i;

	modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);

	if(!modes)
	{
		ri.Printf(PRINT_WARNING, "Can't get list of available modes\n");
		return;
	}

	if(modes == (SDL_Rect **) - 1)
	{
		ri.Printf(PRINT_ALL, "Display supports any resolution\n");
		return;					// can set any resolution
	}

	for(numModes = 0; modes[numModes]; numModes++);

	if(numModes > 1)
		qsort(modes + 1, numModes - 1, sizeof(SDL_Rect *), GLimp_CompareModes);

	for(i = 0; i < numModes; i++)
	{
		const char     *newModeString = va("%ux%u ", modes[i]->w, modes[i]->h);

		if(strlen(newModeString) < (int)sizeof(buf) - strlen(buf))
			Q_strcat(buf, sizeof(buf), newModeString);
		else
			ri.Printf(PRINT_WARNING, "Skipping mode %ux%x, buffer too small\n", modes[i]->w, modes[i]->h);
	}

	if(*buf)
	{
		buf[strlen(buf) - 1] = 0;
		ri.Printf(PRINT_ALL, "Available modes: '%s'\n", buf);
		ri.Cvar_Set("r_availableModes", buf);
	}
}
Esempio n. 5
0
VideoQueryResult CApplication::GetVideoResolutionList(std::vector<Math::IntPoint> &resolutions,
                                                      bool fullScreen, bool resizeable)
{
    resolutions.clear();

    const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
    if (videoInfo == nullptr)
        return VIDEO_QUERY_ERROR;

    Uint32 videoFlags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE;

    // Use hardware surface if available
    if (videoInfo->hw_available)
        videoFlags |= SDL_HWSURFACE;
    else
        videoFlags |= SDL_SWSURFACE;

    // Enable hardware blit if available
    if (videoInfo->blit_hw)
        videoFlags |= SDL_HWACCEL;

    if (resizeable)
        videoFlags |= SDL_RESIZABLE;

    if (fullScreen)
        videoFlags |= SDL_FULLSCREEN;


    SDL_Rect **modes = SDL_ListModes(NULL, videoFlags);

    if (modes == reinterpret_cast<SDL_Rect **>(0) )
        return VIDEO_QUERY_NONE; // no modes available

    if (modes == reinterpret_cast<SDL_Rect **>(-1) )
        return VIDEO_QUERY_ALL; // all resolutions are possible


    for (int i = 0; modes[i] != NULL; ++i)
        resolutions.push_back(Math::IntPoint(modes[i]->w, modes[i]->h));

    return VIDEO_QUERY_OK;
}
Esempio n. 6
0
static int resol_enter(struct state *st, struct state *prev)
{
    if (!st_back)
    {
        /* Note the parent screen if not done yet. */

        st_back = prev;
    }

    back_init("back/gui.png");

    modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);

    if (modes == (SDL_Rect **) -1)
        modes = NULL;

    audio_music_fade_to(0.5f, "bgm/inter.ogg");

    return resol_gui();
}
Esempio n. 7
0
VIDEOMODE_resolution_t *PLATFORM_AvailableResolutions(unsigned int *size)
{
	SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN);
	VIDEOMODE_resolution_t *resolutions;
	unsigned int num_modes;
	unsigned int i;
	if (modes == (SDL_Rect**)0 || modes == (SDL_Rect**)-1)
		return NULL;
	/* Determine number of available modes. */
	for (num_modes = 0; modes[num_modes] != NULL; ++num_modes);

	resolutions = Util_malloc(num_modes * sizeof(VIDEOMODE_resolution_t));
	for (i = 0; i < num_modes; i++) {
		resolutions[i].width = modes[i]->w;
		resolutions[i].height = modes[i]->h;
	}
	*size = num_modes;

	return resolutions;
}
Esempio n. 8
0
QStringList SDLInteraction::getResolutions() const
{
    QStringList result;

    SDL_Rect **modes;

    modes = SDL_ListModes(NULL, SDL_FULLSCREEN);

    if((modes == (SDL_Rect **)0) || (modes == (SDL_Rect **)-1))
    {
        result << "640x480";
    } else
    {
        for(int i = 0; modes[i]; ++i)
            if ((modes[i]->w >= 640) && (modes[i]->h >= 480))
                result << QString("%1x%2").arg(modes[i]->w).arg(modes[i]->h);
    }

    return result;
}
Esempio n. 9
0
std::vector<VideoMode> GetAvailableVideoModes()
{
	std::vector<VideoMode> modes;
	//querying modes using the current pixel format
	//note - this has always been sdl_fullscreen, hopefully it does not matter
	SDL_Rect **sdlmodes = SDL_ListModes(NULL, SDL_HWSURFACE | SDL_FULLSCREEN);

	if (sdlmodes == 0)
		OS::Error("Failed to query video modes");

	if (sdlmodes == reinterpret_cast<SDL_Rect **>(-1)) {
		// Modes restricted. Fall back to 800x600
		modes.push_back(VideoMode(800, 600));
	} else {
		for (int i=0; sdlmodes[i]; ++i) {
			modes.push_back(VideoMode(sdlmodes[i]->w, sdlmodes[i]->h));
		}
	}
	return modes;
}
Esempio n. 10
0
	void PrintAttributes(void)
	{
		int value;

		// current resolution
		SDL_Surface *surface = SDL_GetVideoSurface();
		SDL_PixelFormat *format = surface->format;
		DebugPrint("\nCurrent: %dx%d %dbpp\n", surface->w, surface->h, format->BitsPerPixel);

		// get fullscreen resolutions
		DebugPrint("\nResolutions:\n");
		SDL_Rect **modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
		for (SDL_Rect **mode = modes; *mode != NULL; ++mode)
			DebugPrint("%dx%d\n", (*mode)->w, (*mode)->h);

		const char *attrib[] =
		{
			"SDL_GL_RED_SIZE",
			"SDL_GL_GREEN_SIZE",
			"SDL_GL_BLUE_SIZE",
			"SDL_GL_ALPHA_SIZE",
			"SDL_GL_BUFFER_SIZE",
			"SDL_GL_DOUBLEBUFFER",
			"SDL_GL_DEPTH_SIZE",
			"SDL_GL_STENCIL_SIZE",
			"SDL_GL_ACCUM_RED_SIZE",
			"SDL_GL_ACCUM_GREEN_SIZE",
			"SDL_GL_ACCUM_BLUE_SIZE",
			"SDL_GL_ACCUM_ALPHA_SIZE",
			"SDL_GL_STEREO",
			"SDL_GL_MULTISAMPLEBUFFERS",
			"SDL_GL_MULTISAMPLESAMPLES",
			"SDL_GL_ACCELERATED_VISUAL",
			"SDL_GL_SWAP_CONTROL"
		};
		for (int i = 0; i < SDL_arraysize(attrib); ++i)
		{
			SDL_GL_GetAttribute( SDL_GLattr(i), &value );
			DebugPrint( "%s: %d\n", attrib[i], value);
		}
	}
Esempio n. 11
0
//! \return Pointer to a list with all video modes supported
video::IVideoModeList* CIrrDeviceSDL::getVideoModeList()
{
	if (!VideoModeList.getVideoModeCount())
	{
		// enumerate video modes.
		const SDL_VideoInfo *vi = SDL_GetVideoInfo();
		SDL_Rect **modes = SDL_ListModes(vi->vfmt, SDL_Flags);
		if (modes != 0)
		{
			if (modes == (SDL_Rect **)-1)
				os::Printer::log("All modes available.\n");
			else
			{
				for (u32 i=0; modes[i]; ++i)
					VideoModeList.addMode(core::dimension2d<s32>(modes[i]->w, modes[i]->h), vi->vfmt->BitsPerPixel);
			}
		}
	}

	return &VideoModeList;
}
Esempio n. 12
0
void PrintAvailableResolutions()
{
	// Get available fullscreen/hardware modes
	SDL_Rect** modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_OPENGL);
	if (modes == (SDL_Rect**)0) {
		LOG("Supported Video modes: No modes available!");
	} else if (modes == (SDL_Rect**)-1) {
		LOG("Supported Video modes: All modes available.");
	} else {
		char buffer[1024];
		unsigned char n = 0;
		for (int i = 0; modes[i]; ++i) {
			n += SNPRINTF(&buffer[n], 1024-n, "%dx%d, ", modes[i]->w, modes[i]->h);
		}
		// remove last comma
		if (n >= 2) {
			buffer[n - 2] = '\0';
		}
		LOG("Supported Video modes: %s", buffer);
	}
}
GHOST_TSuccess
GHOST_DisplayManagerSDL::getDisplaySetting(GHOST_TUns8 display,
        GHOST_TInt32 index,
        GHOST_DisplaySetting& setting) const
{
    GHOST_ASSERT(display < 1, "Only single display systems are currently supported.\n");

    int i;
    SDL_Rect **vidmodes;
    /* NULL is passed in here to get the modes for the current bit depth.
     * Other bit depths may be possible; in that case, an SDL_PixelFormat struct
     * should be passed in. To get a complete profile, all possible bit depths
     * would need to be iterated over. - z0r */
    vidmodes = SDL_ListModes(NULL, SDL_HWSURFACE | SDL_OPENGL |
                             SDL_FULLSCREEN | SDL_HWPALETTE);
    if (!vidmodes) {
        fprintf(stderr, "Could not get available video modes: %s.\n",
                SDL_GetError());
        return GHOST_kFailure;
    }
    for (i = 0; vidmodes[i]; i++);
    GHOST_ASSERT(index < i, "Requested setting outside of valid range.\n");

    setting.xPixels = vidmodes[index]->w;
    setting.yPixels = vidmodes[index]->h;

    SDL_Surface *surf;
    surf = SDL_GetVideoSurface();
    if (surf == NULL) {
        fprintf(stderr, "Getting display setting: %s\n", SDL_GetError());
        /* Just guess the bit depth */
        setting.bpp = 32;
    } else {
        setting.bpp = surf->format->BitsPerPixel;
    }
    /* Just guess the frequency :( */
    setting.frequency = 60;

    return GHOST_kSuccess;
}
OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager(uint desktopWidth, uint desktopHeight, SdlEventSource *eventSource)
    : SdlGraphicsManager(eventSource), _lastVideoModeLoad(0), _hwScreen(nullptr), _lastRequestedWidth(0), _lastRequestedHeight(0),
      _graphicsScale(2), _ignoreLoadVideoMode(false), _gotResize(false), _wantsFullScreen(false), _ignoreResizeEvents(0),
      _desiredFullscreenWidth(0), _desiredFullscreenHeight(0) {
	// Setup OpenGL attributes for SDL
	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

	// Retrieve a list of working fullscreen modes
	const SDL_Rect *const *availableModes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
	if (availableModes != (void *)-1) {
		for (;*availableModes; ++availableModes) {
			const SDL_Rect *mode = *availableModes;

			_fullscreenVideoModes.push_back(VideoMode(mode->w, mode->h));
		}

		// Sort the modes in ascending order.
		Common::sort(_fullscreenVideoModes.begin(), _fullscreenVideoModes.end());
	}

	// In case SDL is fine with every mode we will force the desktop mode.
	// TODO? We could also try to add some default resolutions here.
	if (_fullscreenVideoModes.empty() && desktopWidth && desktopHeight) {
		_fullscreenVideoModes.push_back(VideoMode(desktopWidth, desktopHeight));
	}

	// Get information about display sizes from the previous runs.
	if (ConfMan.hasKey("last_fullscreen_mode_width", Common::ConfigManager::kApplicationDomain) && ConfMan.hasKey("last_fullscreen_mode_height", Common::ConfigManager::kApplicationDomain)) {
		_desiredFullscreenWidth  = ConfMan.getInt("last_fullscreen_mode_width", Common::ConfigManager::kApplicationDomain);
		_desiredFullscreenHeight = ConfMan.getInt("last_fullscreen_mode_height", Common::ConfigManager::kApplicationDomain);
	} else {
		// Use the desktop resolutions when no previous default has been setup.
		_desiredFullscreenWidth  = desktopWidth;
		_desiredFullscreenHeight = desktopHeight;
	}
}
Esempio n. 15
0
// returns possible (fullscreen) resolutions if any.
int gr_list_modes( u_int32_t gsmodes[] )
{
	SDL_Rect** modes;
	int i = 0, modesnum = 0;
#ifdef OGLES
	int sdl_check_flags = SDL_FULLSCREEN; // always use Fullscreen as lead.
#else
	int sdl_check_flags = SDL_OPENGL | SDL_FULLSCREEN; // always use Fullscreen as lead.
#endif

	if (sdl_no_modeswitch) {
		/* TODO: we could use the tvservice to list resolutions on the RPi */
		return 0;
	}

	modes = SDL_ListModes(NULL, sdl_check_flags);

	if (modes == (SDL_Rect**)0) // check if we get any modes - if not, return 0
		return 0;


	if (modes == (SDL_Rect**)-1)
	{
		return 0; // can obviously use any resolution... strange!
	}
	else
	{
		for (i = 0; modes[i]; ++i)
		{
			if (modes[i]->w > 0xFFF0 || modes[i]->h > 0xFFF0 // resolutions saved in 32bits. so skip bigger ones (unrealistic in 2010) (changed to 0xFFF0 to fix warning)
				|| modes[i]->w < 320 || modes[i]->h < 200) // also skip everything smaller than 320x200
				continue;
			gsmodes[modesnum] = SM(modes[i]->w,modes[i]->h);
			modesnum++;
			if (modesnum >= 50) // that really seems to be enough big boy.
				break;
		}
		return modesnum;
	}
}
Esempio n. 16
0
void Game_reshape(Game *g) {

    glEnable(GL_TEXTURE_2D);
    glEnable(GL_BLEND);
    glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA);
    glBlendColor(1.f, 1.f, 1.f, 1.f);

    if(g->fullscreen) {
        /* La doc ne dit pas s'il faut libérer le tableau à la fin. */
        SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN);
        switch((intptr_t)modes) {
        case  0: /* Aucun mode n'est disponible. */ break;
        case -1: /* Tout mode peut convenir. */ break;
        /* Dans les deux cas ci-dessus, on peut toujours 
         * passer en fullscreen, mais c'est juste moche. */
        default: /* On a une liste de modes. */
            g->old_window_size.x = g->window_size.x;
            g->old_window_size.y = g->window_size.y;
            g->window_size.x = modes[0]->w;
            g->window_size.y = modes[0]->h;
            break;
        }
    } else if(g->old_window_size.x) {
        g->window_size.x = g->old_window_size.x;
        g->window_size.y = g->old_window_size.y; 
        g->old_window_size.x = 0;
    }
    if(!SDL_SetVideoMode(
            g->window_size.x, 
            g->window_size.y, 
            g->bits_per_pixel, 
            SDL_OPENGL | SDL_DOUBLEBUF | SDL_RESIZABLE
            |(g->fullscreen ? SDL_FULLSCREEN : 0))) {
        fprintf(stderr, "SDL_SetVideoMode() failed :\n\t%s\n Exitting.\n",
                        SDL_GetError());
        exit(EXIT_FAILURE);
    }
    Game_resizeViewports(g);
    Game_resizeSprites(g);
}
static VALUE sdl_listModes(VALUE mod,VALUE flags)
{
  SDL_Rect **modes;
  int i;
  VALUE modesArray;
  
  modes=SDL_ListModes(NULL,NUM2UINT(flags));

  if( modes == NULL )
    return Qnil;/* no modes available */
  if( modes == (SDL_Rect **)-1)
    return Qtrue;/* all resolutions available */

  /* available modes into modesArray */
  modesArray=rb_ary_new();
  
  for(i=0;modes[i]!=NULL;++i){
    rb_ary_push( modesArray,
		 rb_ary_new3( 2, INT2NUM(modes[i]->w), INT2NUM(modes[i]->h)) );
  }
  return modesArray;
}
int initFullScreen(unsigned int * width,unsigned int * height)
{
    SDL_Rect ** modes;

    modes = SDL_ListModes(NULL,SDL_FULLSCREEN|SDL_OPENGL);
    if ((modes == (SDL_Rect **)0)||(modes == (SDL_Rect **)-1))
        return 0;

    if (width != NULL)
        *width = modes[0]->w;
    if (height != NULL)
        *height = modes[0]->h;
    if (SDL_SetVideoMode(modes[0]->w,
                         modes[0]->h,
                         SDL_GetVideoInfo()->vfmt->BitsPerPixel,
                         SDL_FULLSCREEN|SDL_OPENGL) == NULL)
        return -1;
    else
    {
        return 0;
    }
}
Esempio n. 19
0
static void get_closest_mode(int *w, int *h) {
	int i;
	int bestw,besth;
	SDL_Rect **modes = modes=SDL_ListModes(NULL, SDL_FULLSCREEN);

	bestw=99999;
	besth=99999;
	if(modes != (SDL_Rect **)0 && modes != (SDL_Rect **)-1){
		for(i=0;modes[i];++i) {
			if (modes[i]->w >= *w && modes[i]->w <= bestw
				&& modes[i]->h >= *h && modes[i]->h <= besth
				&& SDL_VideoModeOK(modes[i]->w, modes[i]->h, 32, SDL_FULLSCREEN)) {
				bestw=modes[i]->w;
				besth=modes[i]->h;
			}
		}
	}
	if ( bestw != 99999) {
		*w=bestw;
		*h=besth;
	}
}
Esempio n. 20
0
static void sdl_ctx_get_video_size(void *data,
      unsigned *width, unsigned *height)
{
   driver_t *driver     = driver_get_ptr();
   settings_t *settings = config_get_ptr();
   gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)driver->video_context_data;

   if (!sdl)
      return;

   *width  = sdl->g_width;
   *height = sdl->g_height;

   if (!sdl->g_win)
   {
      int i = settings->video.monitor_index;

#ifdef HAVE_SDL2
      SDL_DisplayMode mode = {0};

      if (SDL_GetCurrentDisplayMode(i, &mode) < 0)
         RARCH_WARN("[SDL_GL]: Failed to get display #%i mode: %s\n", i,
                    SDL_GetError());
#else
      SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
      SDL_Rect mode = {0};

      if (!modes)
         RARCH_WARN("[SDL_GL]: Failed to detect available video modes: %s\n",
                    SDL_GetError());
      else if (*modes)
         mode = **modes;
#endif

      *width  = mode.w;
      *height = mode.h;
   }
}
Esempio n. 21
0
static void AutoAdjustColorDepth(void)
{
    SDL_Rect **modes;
    SDL_PixelFormat format;
    const SDL_VideoInfo *info;
    int flags;

    if (fullscreen)
    {
        flags = SDL_FULLSCREEN;
    }
    else
    {
        flags = 0;
    }

    format.BitsPerPixel = screen_bpp;
    format.BytesPerPixel = (screen_bpp + 7) / 8;

    // Are any screen modes supported at the configured color depth?

    modes = SDL_ListModes(&format, flags);

    // If not, we must autoadjust to something sensible.

    if (modes == NULL)
    {
        printf("I_InitGraphics: %ibpp color depth not supported.\n",
               screen_bpp);

        info = SDL_GetVideoInfo();

        if (info != NULL && info->vfmt != NULL)
        {
            screen_bpp = info->vfmt->BitsPerPixel;
        }
    }
}
Esempio n. 22
0
bool WindowManager::CreateSDLWindow()
{
	if(SDL_Init(SDL_INIT_EVERYTHING) < 0) {						// Initialize everything
        return false;											// or return that there was an error
    }

	TTF_Init();

	if( Mix_OpenAudio( 22050, MIX_DEFAULT_FORMAT, 2, 4096 ) == -1 )
	{
		return false;
	}

	_FSModes = SDL_ListModes(NULL, SDL_OPENGL | SDL_HWSURFACE | SDL_FULLSCREEN);
	if(_FSModes == (SDL_Rect**)0 || _FSModes == (SDL_Rect **)-1)
		return false;
	_CurrentFSMode=_FSModes[0];					// Point the global window variable to the new SDL surface
	
	if(_Fullscreen)
	{
		_Window=SDL_SetVideoMode(_CurrentFSMode->w, _CurrentFSMode->h, 0, SDL_HWSURFACE|SDL_OPENGL|SDL_FULLSCREEN);			//			and resizable, or return that there has been an error
	}
	else
	{
		SDL_Rect Mode;
		Mode.x = Mode.y = 0;
		Mode.w = 800;
		Mode.h = 600;
		_CurrentWMode = Mode;
		_Window=SDL_SetVideoMode(_CurrentWMode.w, _CurrentWMode.h, 0, SDL_HWSURFACE | SDL_OPENGL);
	}

	SDL_WM_SetCaption( "VoA: Variations on Asteroids", NULL );

	GrabMouse();

    return true;	
}
Esempio n. 23
0
void t_screen::togglefullscreen()
{
    fullscreen^= 1;
    if(fullscreen)
    {
	SDL_Rect **modes= SDL_ListModes(0, SDL_OPENGL|SDL_FULLSCREEN);
	int bestidx= 0, bestdiff= INT_MAX;
	int scrsize= width*height;
	if(modes!=(SDL_Rect**)-1 && modes!=0 && modes[0]!=0)
	{
	    for(int i= 0; modes[i]; i++)
	    {
		int msize= modes[i]->w*modes[i]->h,
		    diff= msize-scrsize;
		if(msize>=scrsize && diff<bestdiff)
		    bestidx= i, bestdiff= diff;
	    }
	    printf("Selected fullscreen mode %dx%d\n", modes[bestidx]->w, modes[bestidx]->h);
	    init(modes[bestidx]->w, modes[bestidx]->h, fullscreen);
	}
    }
    else init(width, height, fullscreen);
}
Esempio n. 24
0
int enumerate_sdl_modes (int *width, int *height, FILE *out)
{
    SDL_Rect **modes;
    int w = -1;
    int h = -1;
    int m = -1;
    int i;

    modes = SDL_ListModes (NULL, SDL_HWSURFACE | SDL_FULLSCREEN);

    if (! modes)
        fatal (2, "no SDL display modes available\n");

    if (modes == (SDL_Rect **) -1)
        fatal (2, "all SDL resolutions available (on hardware?)\n");

    for (i = 0; modes [i]; i++)
    {
        if (out)
            fprintf (out, "  mode %d: %d x %d\n", i, modes [i]->w, modes [i]->h);
        // find the largest resolution for the screen
        if ((modes [i]->w >= w) && (modes [i]->h >= h))	{
            w = modes [i]->w;
            h = modes [i]->h;
            m = i;
        }

    }

    if (m < 0)
        fatal (2, "no matching SDL video modes found\n");

    *width = w;
    *height = h;
    return (m);
}
Esempio n. 25
0
ModeListModel::ModeListModel()
{
    /* Get available fullscreen/hardware modes */
    SDL_Rect **modes = SDL_ListModes(nullptr, SDL_FULLSCREEN | SDL_HWSURFACE);

    /* Check which modes are available */
    if (modes == static_cast<SDL_Rect **>(nullptr))
    {
        logger->log1("No modes available");
    }
    else if (modes == reinterpret_cast<SDL_Rect **>(-1))
    {
        logger->log1("All resolutions available");
    }
    else
    {
        for (int i = 0; modes[i]; ++ i)
        {
            const std::string modeString =
                toString(static_cast<int>(modes[i]->w)) + "x"
                + toString(static_cast<int>(modes[i]->h));
            mVideoModes.push_back(modeString);
        }
    }
    addCustomMode("640x480");
    addCustomMode("800x600");
    addCustomMode("1024x768");
    addCustomMode("1280x1024");
    addCustomMode("1400x900");
    addCustomMode("1500x990");
    addCustomMode(toString(mainGraphics->mWidth) + "x"
        + toString(mainGraphics->mHeight));

    std::sort(mVideoModes.begin(), mVideoModes.end(), modeSorter);
    mVideoModes.push_back("custom");
}
Esempio n. 26
0
void	GL_SDL_GetGLModes()
{
	const SDL_VideoInfo *info;
	SDL_Rect **modes;
	int i;

	//always keep mode 0 open?
	gl_mode_num = 1;
	
	info = SDL_GetVideoInfo();
	if (info)
	{
		Console_DPrintf("Current display: %d bits-per-pixel\n",info->vfmt->BitsPerPixel);
		if ( info->vfmt->palette == NULL ) {
			Console_DPrintf("	Red Mask = 0x%.8x\n", info->vfmt->Rmask);
			Console_DPrintf("	Green Mask = 0x%.8x\n", info->vfmt->Gmask);
			Console_DPrintf("	Blue Mask = 0x%.8x\n", info->vfmt->Bmask);
		}
	}
	/* Print available fullscreen video modes */
	modes = SDL_ListModes(NULL, SDL_FULLSCREEN);
	if ( modes == (SDL_Rect **)0 )
	{
		Console_DPrintf("No available fullscreen video modes\n");
	}
	else
	if ( modes == (SDL_Rect **)-1 )
	{
		Console_DPrintf("No special fullscreen video modes\n");
	}
	else
	{
		Console_DPrintf("Fullscreen video modes:\n");
		for ( i=0; modes[i]; ++i )
		{
			if (_mode_exists(modes[i]) || info->vfmt->BitsPerPixel <= 16 || (modes[i]->w<=640&&modes[i]->h<=480))
			{
			  	continue;
			}
			gl_modes[gl_mode_num].width = modes[i]->w;
			gl_modes[gl_mode_num].height = modes[i]->h;
			gl_modes[gl_mode_num].bpp = info->vfmt->BitsPerPixel;
			BPrintf(gl_modes[gl_mode_num].name, 20, "%dx%d", modes[i]->w, modes[i]->h);
			gl_modes[gl_mode_num].fullscreen = true;
			Console_DPrintf("\t%dx%d\n", modes[i]->w, modes[i]->h);
			gl_mode_num++;
		}
	}
	
	GL_GetWindowedModes();
	
	if (info)
	{
		if ( info->wm_available ) {
			Console_DPrintf("A window manager is available\n");
		}
		if ( info->hw_available ) {
			Console_DPrintf("Hardware surfaces are available (%dK video memory)\n",
				info->video_mem);
		}
		if ( info->blit_hw ) {
			Console_DPrintf("Copy blits between hardware surfaces are accelerated\n");
		}
		if ( info->blit_hw_CC ) {
			Console_DPrintf("Colorkey blits between hardware surfaces are accelerated\n");
		}
		if ( info->blit_hw_A ) {
			Console_DPrintf("Alpha blits between hardware surfaces are accelerated\n");
		}
		if ( info->blit_sw ) {
			Console_DPrintf("Copy blits from software surfaces to hardware surfaces are accelerated\n");
		}
		if ( info->blit_sw_CC ) {
			Console_DPrintf("Colorkey blits from software surfaces to hardware surfaces are accelerated\n");
		}
		if ( info->blit_sw_A ) {
			Console_DPrintf("Alpha blits from software surfaces to hardware surfaces are accelerated\n");
		}
		if ( info->blit_fill ) {
			Console_DPrintf("Color fills on hardware surfaces are accelerated\n");
		}
	}
}
Esempio n. 27
0
bool OpenGLSdlGraphicsManager::setupFullscreenMode() {
	SDL_Rect const* const*availableModes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_OPENGL);

	// SDL_ListModes() returns -1 in case any dimension is okay. In that
	// case we'll reuse the current desktop resolution for fullscreen.
	if (availableModes == (void *)-1) {
		_videoMode.hardwareWidth = _desktopWidth;
		_videoMode.hardwareHeight = _desktopHeight;
		_activeFullscreenMode = -2;
		return true;
	}

	// If -2, autodetect the fullscreen mode
	// The last used fullscreen mode will be prioritized, if there is no last fullscreen
	// mode, the desktop resolution will be used, and in case the desktop resolution
	// is not available as a fullscreen mode, the one with smallest metric will be selected.
	if (_activeFullscreenMode == -2) {
		// Desktop resolution
		int desktopModeIndex = -1;

		// Best metric mode
		const SDL_Rect *bestMode = availableModes[0];
		int bestModeIndex = 0;
		uint bestMetric = (uint)-1;

		// Iterate over all available fullscreen modes
		for (int i = 0; const SDL_Rect *mode = availableModes[i]; i++) {
			// Try to setup the last used fullscreen mode
			if (mode->w == _lastFullscreenModeWidth && mode->h == _lastFullscreenModeHeight) {
				_videoMode.hardwareWidth = _lastFullscreenModeWidth;
				_videoMode.hardwareHeight = _lastFullscreenModeHeight;
				_activeFullscreenMode = i;
				return true;
			}

			if (mode->w == _desktopWidth && mode->h == _desktopHeight)
				desktopModeIndex = i;

			if (mode->w < _videoMode.overlayWidth)
				continue;
			if (mode->h < _videoMode.overlayHeight)
				continue;

			uint metric = mode->w * mode->h - _videoMode.overlayWidth * _videoMode.overlayHeight;
			if (metric < bestMetric) {
				bestMode = mode;
				bestMetric = metric;
				bestModeIndex = i;
			}
		}

		if (desktopModeIndex >= 0) {
			_videoMode.hardwareWidth = _desktopWidth;
			_videoMode.hardwareHeight = _desktopHeight;

			_activeFullscreenMode = desktopModeIndex;
			return true;
		} else if (bestMode) {
			_videoMode.hardwareWidth = bestMode->w;
			_videoMode.hardwareHeight = bestMode->h;

			_activeFullscreenMode = bestModeIndex;
			return true;
		}
	} else {
		// Use last fullscreen mode if looping backwards from the first mode
		if (_activeFullscreenMode == -1) {
			do {
				_activeFullscreenMode++;
			} while(availableModes[_activeFullscreenMode]);
			_activeFullscreenMode--;
		}

		// Use first fullscreen mode if looping from last mode
		if (!availableModes[_activeFullscreenMode])
			_activeFullscreenMode = 0;

		// Check if the fullscreen mode is valid
		if (availableModes[_activeFullscreenMode]) {
			_videoMode.hardwareWidth = availableModes[_activeFullscreenMode]->w;
			_videoMode.hardwareHeight = availableModes[_activeFullscreenMode]->h;
			return true;
		}
	}

	// Could not find any suiting fullscreen mode, return false.
	return false;
}
Esempio n. 28
0
File: options.c Progetto: s0be/naev
/**
 * @brief Initializes the video window.
 */
static void opt_video( unsigned int wid )
{
   (void) wid;
   int i, j, nres, res_def;
   char buf[16];
   int cw;
   int w, h, y, x, l;
   SDL_Rect** modes;
   char **res;
   const char *s;

   /* Get size. */
   window_dimWindow( wid, &w, &h );

   /* Close button */
   window_addButton( wid, -20, 20,
         BUTTON_WIDTH, BUTTON_HEIGHT,
         "btnClose", "Close", opt_close );
   window_addButton( wid, -20 - 1*(BUTTON_WIDTH+20), 20,
         BUTTON_WIDTH, BUTTON_HEIGHT,
         "btnApply", "Apply", opt_videoSave );
   window_addButton( wid, -20 - 2*(BUTTON_WIDTH+20), 20,
         BUTTON_WIDTH, BUTTON_HEIGHT,
         "btnDefaults", "Defaults", opt_videoDefaults );

   /* Resolution bits. */
   cw = (w-60)/2;
   x = 20;
   y = -60;
   window_addText( wid, x+20, y, 100, 20, 0, "txtSRes",
         NULL, &cDConsole, "Resolution" );
   y -= 40;
   window_addInput( wid, x, y, 100, 20, "inpRes", 16, 1, NULL );
   snprintf( buf, sizeof(buf), "%dx%d", conf.width, conf.height );
   window_setInput( wid, "inpRes", buf );
   window_setInputFilter( wid, "inpRes",
         "abcdefghijklmnopqrstuvwyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()-=*/\\'\"~<>!@#$%^&|_`" );
   window_addCheckbox( wid, x+20+100, y, 100, 20,
         "chkFullscreen", "Fullscreen", NULL, conf.fullscreen );
   y -= 30;
   modes = SDL_ListModes( NULL, SDL_OPENGL | SDL_FULLSCREEN );
   j = 1;
   for (i=0; modes[i]; i++) {
      if ((modes[i]->w == conf.width) && (modes[i]->h == conf.height))
         j = 0;
   }
   res   = malloc( sizeof(char*) * (i+j) );
   nres  = 0;
   if (j) {
      res[0]   = malloc(16);
      snprintf( res[0], 16, "%dx%d", conf.width, conf.height );
      res_def  = 0;
      nres     = 1;
   }
   for (i=0; modes[i]; i++) {
      res[ nres ] = malloc(16);
      snprintf( res[ nres ], 16, "%dx%d", modes[i]->w, modes[i]->h );
      if ((modes[i]->w == conf.width) && (modes[i]->h == conf.height))
         res_def = i;
      nres++;
   }
   window_addList( wid, x, y, 140, 100, "lstRes", res, nres, -1, opt_videoRes );
   y -= 150;

   /* FPS stuff. */
   window_addText( wid, x+20, y, 100, 20, 0, "txtFPSTitle",
         NULL, &cDConsole, "FPS Control" );
   y -= 30;
   s = "FPS Limit";
   l = gl_printWidthRaw( NULL, s );
   window_addText( wid, x, y, l, 20, 1, "txtSFPS",
         NULL, &cBlack, s );
   window_addInput( wid, x+l+20, y, 40, 20, "inpFPS", 4, 1, NULL );
   toolkit_setListPos( wid, "lstRes", res_def);
   window_setInputFilter( wid, "inpFPS",
         "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()-=*/\\'\"~<>!@#$%^&|_`" );
   y -= 30;
   window_addCheckbox( wid, x, y, cw, 20,
         "chkFPS", "Show FPS", NULL, conf.fps_show );
   y -= 40;

   /* OpenGL options. */
   x = 20+cw+20;
   y = -60;
   window_addText( wid, x+20, y, 100, 20, 0, "txtSGL",
         NULL, &cDConsole, "OpenGL" );
   y -= 30;
   window_addCheckbox( wid, x, y, cw, 20,
         "chkVSync", "Vertical Sync", NULL, conf.vsync );
   y -= 20;
   window_addCheckbox( wid, x, y, cw, 20,
         "chkVBO", "Vertex Buffer Objects*", NULL, conf.vbo );
   y -= 20;
   window_addCheckbox( wid, x, y, cw, 20,
         "chkMipmaps", "Mipmaps*", NULL, conf.mipmaps );
   y -= 20;
   window_addCheckbox( wid, x, y, cw, 20,
         "chkInterpolate", "Interpolation*", NULL, conf.interpolate );
   y -= 20;
   window_addCheckbox( wid, x, y, cw, 20,
         "chkNPOT", "NPOT Textures*", NULL, conf.npot );
   y -= 30;
   window_addText( wid, x, y, cw, 20, 1,
         "txtSCompat", NULL, &cBlack, "*Disable for compatibility." );
   y -= 40;

   /* Features. */
   window_addText( wid, x+20, y, 100, 20, 0, "txtSFeatures",
         NULL, &cDConsole, "Features" );
   y -= 30;
   window_addCheckbox( wid, x, y, cw, 20,
         "chkEngineGlow", "Engine Glow (More RAM)", NULL, conf.engineglow );
   y -= 20;

   /* Restart text. */
   window_addText( wid, 20, 10, 3*(BUTTON_WIDTH + 20),
         30, 0, "txtRestart", &gl_smallFont, &cBlack, NULL );
}
Esempio n. 29
0
File: Pi.cpp Progetto: Snaar/pioneer
void Pi::Init()
{
	config.Load(GetPiUserDir() + "config.ini");

	Pi::detail.planets = config.Int("DetailPlanets");
	Pi::detail.cities = config.Int("DetailCities");

	int width = config.Int("ScrWidth");
	int height = config.Int("ScrHeight");
	const SDL_VideoInfo *info = NULL;
	Uint32 sdlInitFlags = SDL_INIT_VIDEO | SDL_INIT_JOYSTICK;
#if defined _WIN32 && defined _DEBUG
	sdlInitFlags |= SDL_INIT_NOPARACHUTE;
#endif
	if (SDL_Init(sdlInitFlags) < 0) {
		fprintf(stderr, "Video initialization failed: %s\n", SDL_GetError());
		exit(-1);
	}

	InitJoysticks();

	// no mode set, find an ok one
	if ((width <= 0) || (height <= 0)) {
		SDL_Rect **modes = SDL_ListModes(NULL, SDL_HWSURFACE | SDL_FULLSCREEN);
		
		if (modes == 0) {
			fprintf(stderr, "It seems no video modes are available...");
		}
		if (modes == (SDL_Rect **)-1) {
			// hm. all modes available. odd. try 800x600
			width = 800; height = 600;
		} else {
			width = modes[0]->w;
			height = modes[0]->h;
		}
	}

	info = SDL_GetVideoInfo();
	printf("SDL_GetVideoInfo says %d bpp\n", info->vfmt->BitsPerPixel);
	switch (info->vfmt->BitsPerPixel) {
		case 16:
			SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
			SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
			SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
			break;
		case 24:
		case 32:
			SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
			SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
			SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
			break;
		default:
			fprintf(stderr, "Invalid pixel depth: %d bpp\n", info->vfmt->BitsPerPixel);
	} 
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

	Uint32 flags = SDL_OPENGL;
	if (config.Int("StartFullscreen")) flags |= SDL_FULLSCREEN;

	if ((Pi::scrSurface = SDL_SetVideoMode(width, height, info->vfmt->BitsPerPixel, flags)) == 0) {
		// fall back on 16-bit depth buffer...
		SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
		fprintf(stderr, "Failed to set video mode. (%s). Re-trying with 16-bit depth buffer.\n", SDL_GetError());
		if ((Pi::scrSurface = SDL_SetVideoMode(width, height, info->vfmt->BitsPerPixel, flags)) == 0) {
			fprintf(stderr, "Failed to set video mode: %s", SDL_GetError());
		}
	}

	glewInit();
	SDL_WM_SetCaption("Pioneer","Pioneer");
	Pi::scrWidth = width;
	Pi::scrHeight = height;
	Pi::scrAspect = width / (float)height;

	Pi::rng.seed(time(NULL));

	InitOpenGL();
	GLFTInit();
	// Gui::Init shouldn't initialise any VBOs, since we haven't tested
	// that the capability exists. (Gui does not use VBOs so far)
	Gui::Init(scrWidth, scrHeight, 800, 600);
	if (!GLEW_ARB_vertex_buffer_object) {
		Error("OpenGL extension ARB_vertex_buffer_object not supported. Pioneer can not run on your graphics card.");
	}
	Render::Init(width, height);
	draw_progress(0.1f);
	Galaxy::Init();
	draw_progress(0.2f);
	NameGenerator::Init();
	if (config.Int("DisableShaders")) Render::ToggleShaders();
	if (config.Int("EnableHDR")) Render::ToggleHDR();

	draw_progress(0.3f);
	LmrModelCompilerInit();

//unsigned int control_word;
//_clearfp();
//_controlfp_s(&control_word, _EM_INEXACT | _EM_UNDERFLOW, _MCW_EM);
//double fpexcept = Pi::timeAccelRates[1] / Pi::timeAccelRates[0];


	draw_progress(0.4f);
	ShipType::Init();


	draw_progress(0.5f);
	GeoSphere::Init();
	draw_progress(0.6f);
	Space::Init();
	draw_progress(0.7f);
	Polit::Init();
	draw_progress(0.8f);
	SpaceStation::Init();
	draw_progress(0.9f);

	if (!config.Int("DisableSound")) {
		Sound::Init();
		Sound::SetGlobalVolume(config.Float("SfxVolume"));
		Sound::Pause(0);
	}
	draw_progress(1.0f);

	// test code to produce list of ship stats

	FILE *pStatFile = fopen("shipstat.csv","wt");
	if (pStatFile)
	{
		fprintf(pStatFile, "name,lmrname,hullmass,capacity,xsize,ysize,zsize,facc,racc,uacc,aacc\n");
		for (std::map<std::string, ShipType>::iterator i = ShipType::types.begin();
				i != ShipType::types.end(); ++i)
		{
			ShipType *shipdef = &(i->second);
			LmrModel *lmrModel = LmrLookupModelByName(shipdef->lmrModelName.c_str());
			LmrObjParams lmrParams; memset(&lmrParams, 0, sizeof(LmrObjParams));
			LmrCollMesh *collMesh = new LmrCollMesh(lmrModel, &lmrParams);
			Aabb aabb = collMesh->GetAabb();
		
			double hullmass = shipdef->hullMass;
			double capacity = shipdef->capacity;
			double xsize = aabb.max.x-aabb.min.x;
			double ysize = aabb.max.y-aabb.min.y;
			double zsize = aabb.max.z-aabb.min.z;
			double brad = aabb.GetBoundingRadius();
			double simass = (hullmass + capacity) * 1000.0;
			double angInertia = (2/5.0)*simass*brad*brad;
			double acc1 = shipdef->linThrust[ShipType::THRUSTER_FORWARD] / (9.81*simass);
			double acc2 = shipdef->linThrust[ShipType::THRUSTER_REVERSE] / (9.81*simass);
			double acc3 = shipdef->linThrust[ShipType::THRUSTER_UP] / (9.81*simass);
			double acca = shipdef->angThrust/angInertia;

			fprintf(pStatFile, "%s,%s,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%f\n",
				shipdef->name.c_str(), shipdef->lmrModelName.c_str(), hullmass, capacity,
				xsize, ysize, zsize, acc1, acc2, acc3, acca);
		}
		fclose(pStatFile);
	}

	gameMenuView = new GameMenuView();
	config.Save();
}
Esempio n. 30
0
File: window.c Progetto: clobber/UME
static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight)
{
	int minimum_width, minimum_height, target_width, target_height;
	int i;
	float size_score, best_score = 0.0f;
	SDL_Rect **modes;

	// determine the minimum width/height for the selected target
	window->target->compute_minimum_size(minimum_width, minimum_height);

	// use those as the target for now
	target_width = minimum_width * MAX(1, window->prescale);
	target_height = minimum_height * MAX(1, window->prescale);

	// if we're not stretching, allow some slop on the minimum since we can handle it
	{
		minimum_width -= 4;
		minimum_height -= 4;
	}

#if 1 // defined(SDLMAME_WIN32)
	/*
	 *  We need to do this here. If SDL_ListModes is
	 * called in init_monitors, the call will crash
	 * on win32
	 */
	modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_DOUBLEBUF);
#else
	modes = window->monitor->modes;
#endif

	if (modes == (SDL_Rect **)0)
	{
		mame_printf_error("SDL: No modes available?!\n");
		exit(-1);
	}
	else if (modes == (SDL_Rect **)-1)  // all modes are possible
	{
		*fswidth = window->maxwidth;
		*fsheight = window->maxheight;
	}
	else
	{
		for (i = 0; modes[i]; ++i)
		{
			// compute initial score based on difference between target and current
			size_score = 1.0f / (1.0f + fabsf((INT32)modes[i]->w - target_width) + fabsf((INT32)modes[i]->h - target_height));

			// if the mode is too small, give a big penalty
			if (modes[i]->w < minimum_width || modes[i]->h < minimum_height)
				size_score *= 0.01f;

			// if mode is smaller than we'd like, it only scores up to 0.1
			if (modes[i]->w < target_width || modes[i]->h < target_height)
				size_score *= 0.1f;

			// if we're looking for a particular mode, that's a winner
			if (modes[i]->w == window->maxwidth && modes[i]->h == window->maxheight)
				size_score = 2.0f;

			mame_printf_verbose("%4dx%4d -> %f\n", (int)modes[i]->w, (int)modes[i]->h, size_score);

			// best so far?
			if (size_score > best_score)
			{
				best_score = size_score;
				*fswidth = modes[i]->w;
				*fsheight = modes[i]->h;
			}

		}
	}
}