File diff r7169:b87d36998a2d → r7170:38b143754b40
src/video/sdl_v.cpp
Show inline comments
 
@@ -14,20 +14,22 @@
 
#include "../network/network.h"
 
#include "../variables.h"
 
#include "../blitter/factory.hpp"
 
#include "sdl_v.h"
 
#include <SDL.h>
 

	
 
static FVideoDriver_SDL iFVideoDriver_SDL;
 

	
 
static SDL_Surface *_sdl_screen;
 
static bool _all_modes;
 

	
 
#define MAX_DIRTY_RECTS 100
 
static SDL_Rect _dirty_rects[MAX_DIRTY_RECTS];
 
static int _num_dirty_rects;
 

	
 
static void SdlVideoMakeDirty(int left, int top, int width, int height)
 
void VideoDriver_SDL::MakeDirty(int left, int top, int width, int height)
 
{
 
	if (_num_dirty_rects < MAX_DIRTY_RECTS) {
 
		_dirty_rects[_num_dirty_rects].x = left;
 
		_dirty_rects[_num_dirty_rects].y = top;
 
		_dirty_rects[_num_dirty_rects].w = width;
 
		_dirty_rects[_num_dirty_rects].h = height;
 
@@ -412,13 +414,13 @@ static int PollEvent()
 
			break;
 
		}
 
	}
 
	return -1;
 
}
 

	
 
static const char *SdlVideoStart(const char * const *parm)
 
const char *VideoDriver_SDL::Start(const char * const *parm)
 
{
 
	char buf[30];
 

	
 
	const char *s = SdlOpen(SDL_INIT_VIDEO);
 
	if (s != NULL) return s;
 

	
 
@@ -431,18 +433,18 @@ static const char *SdlVideoStart(const c
 

	
 
	SDL_CALL SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
 
	SDL_CALL SDL_EnableUNICODE(1);
 
	return NULL;
 
}
 

	
 
static void SdlVideoStop()
 
void VideoDriver_SDL::Stop()
 
{
 
	SdlClose(SDL_INIT_VIDEO);
 
}
 

	
 
static void SdlVideoMainLoop()
 
void VideoDriver_SDL::MainLoop()
 
{
 
	uint32 cur_ticks = SDL_CALL SDL_GetTicks();
 
	uint32 last_cur_ticks = cur_ticks;
 
	uint32 next_tick = cur_ticks + 30;
 
	uint32 pal_tick = 0;
 
	uint32 mod;
 
@@ -502,31 +504,22 @@ static void SdlVideoMainLoop()
 
			DrawMouseCursor();
 
			DrawSurfaceToScreen();
 
		}
 
	}
 
}
 

	
 
static bool SdlVideoChangeRes(int w, int h)
 
bool VideoDriver_SDL::ChangeResolution(int w, int h)
 
{
 
	return CreateMainSurface(w, h);
 
}
 

	
 
static void SdlVideoFullScreen(bool full_screen)
 
void VideoDriver_SDL::ToggleFullscreen(bool fullscreen)
 
{
 
	_fullscreen = full_screen;
 
	_fullscreen = fullscreen;
 
	GetVideoModes(); // get the list of available video modes
 
	if (_num_resolutions == 0 || !_video_driver->change_resolution(_cur_resolution[0], _cur_resolution[1])) {
 
	if (_num_resolutions == 0 || !this->ChangeResolution(_cur_resolution[0], _cur_resolution[1])) {
 
		// switching resolution failed, put back full_screen to original status
 
		_fullscreen ^= true;
 
	}
 
}
 

	
 
const HalVideoDriver _sdl_video_driver = {
 
	SdlVideoStart,
 
	SdlVideoStop,
 
	SdlVideoMakeDirty,
 
	SdlVideoMainLoop,
 
	SdlVideoChangeRes,
 
	SdlVideoFullScreen,
 
};
 

	
 
#endif /* WITH_SDL */