|
@@ -561,28 +561,28 @@ bool VideoDriver_SDL::PollEvent()
|
|
|
case SDL_VIDEOEXPOSE: {
|
|
|
/* Force a redraw of the entire screen. Note
|
|
|
* that SDL 1.2 seems to do this automatically
|
|
|
* in most cases, but 1.3 / 2.0 does not. */
|
|
|
_num_dirty_rects = MAX_DIRTY_RECTS + 1;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
const char *VideoDriver_SDL::Start(const StringList &parm)
|
|
|
const char *VideoDriver_SDL::Start(const StringList ¶m)
|
|
|
{
|
|
|
char buf[30];
|
|
|
_use_hwpalette = GetDriverParamInt(parm, "hw_palette", 2);
|
|
|
_use_hwpalette = GetDriverParamInt(param, "hw_palette", 2);
|
|
|
|
|
|
/* Just on the offchance the audio subsystem started before the video system,
|
|
|
* check whether any part of SDL has been initialised before getting here.
|
|
|
* Slightly duplicated with sound/sdl_s.cpp */
|
|
|
int ret_code = 0;
|
|
|
if (SDL_WasInit(SDL_INIT_EVERYTHING) == 0) {
|
|
|
ret_code = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
|
|
|
} else if (SDL_WasInit(SDL_INIT_VIDEO) == 0) {
|
|
|
ret_code = SDL_InitSubSystem(SDL_INIT_VIDEO);
|
|
|
}
|
|
|
if (ret_code < 0) return SDL_GetError();
|
|
|
|
|
@@ -590,24 +590,26 @@ const char *VideoDriver_SDL::Start(const
|
|
|
|
|
|
GetVideoModes();
|
|
|
if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height)) {
|
|
|
return SDL_GetError();
|
|
|
}
|
|
|
|
|
|
SDL_VideoDriverName(buf, sizeof buf);
|
|
|
DEBUG(driver, 1, "SDL: using driver '%s'", buf);
|
|
|
|
|
|
MarkWholeScreenDirty();
|
|
|
SetupKeyboard();
|
|
|
|
|
|
this->is_game_threaded = !GetDriverParamBool(param, "no_threads") && !GetDriverParamBool(param, "no_thread");
|
|
|
|
|
|
return nullptr;
|
|
|
}
|
|
|
|
|
|
void VideoDriver_SDL::SetupKeyboard()
|
|
|
{
|
|
|
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
|
|
SDL_EnableUNICODE(1);
|
|
|
}
|
|
|
|
|
|
void VideoDriver_SDL::Stop()
|
|
|
{
|
|
|
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
|
@@ -638,30 +640,34 @@ void VideoDriver_SDL::InputLoop()
|
|
|
/* Determine which directional keys are down. */
|
|
|
_dirkeys =
|
|
|
(keys[SDLK_LEFT] ? 1 : 0) |
|
|
|
(keys[SDLK_UP] ? 2 : 0) |
|
|
|
(keys[SDLK_RIGHT] ? 4 : 0) |
|
|
|
(keys[SDLK_DOWN] ? 8 : 0);
|
|
|
|
|
|
if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged();
|
|
|
}
|
|
|
|
|
|
void VideoDriver_SDL::MainLoop()
|
|
|
{
|
|
|
this->StartGameThread();
|
|
|
|
|
|
for (;;) {
|
|
|
if (_exit_game) break;
|
|
|
|
|
|
this->Tick();
|
|
|
this->SleepTillNextTick();
|
|
|
}
|
|
|
|
|
|
this->StopGameThread();
|
|
|
}
|
|
|
|
|
|
bool VideoDriver_SDL::ChangeResolution(int w, int h)
|
|
|
{
|
|
|
return CreateMainSurface(w, h);
|
|
|
}
|
|
|
|
|
|
bool VideoDriver_SDL::ToggleFullscreen(bool fullscreen)
|
|
|
{
|
|
|
_fullscreen = fullscreen;
|
|
|
GetVideoModes(); // get the list of available video modes
|
|
|
bool ret = !_resolutions.empty() && CreateMainSurface(_cur_resolution.width, _cur_resolution.height);
|