|
@@ -653,48 +653,50 @@ int VideoDriver_SDL::PollEvent()
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
const char *VideoDriver_SDL::Start(const StringList &parm)
|
|
|
{
|
|
|
/* Explicitly disable hardware acceleration. Enabling this causes
|
|
|
* UpdateWindowSurface() to update the window's texture instead of
|
|
|
* its surface. */
|
|
|
SDL_SetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION, "0");
|
|
|
SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "1");
|
|
|
|
|
|
/* 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_VIDEO) == 0) {
|
|
|
ret_code = SDL_InitSubSystem(SDL_INIT_VIDEO);
|
|
|
}
|
|
|
if (ret_code < 0) return SDL_GetError();
|
|
|
|
|
|
this->UpdateAutoResolution();
|
|
|
|
|
|
GetVideoModes();
|
|
|
if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height, false)) {
|
|
|
return SDL_GetError();
|
|
|
}
|
|
|
|
|
|
const char *dname = SDL_GetCurrentVideoDriver();
|
|
|
DEBUG(driver, 1, "SDL2: using driver '%s'", dname);
|
|
|
|
|
|
MarkWholeScreenDirty();
|
|
|
|
|
|
_draw_threaded = !GetDriverParamBool(parm, "no_threads") && !GetDriverParamBool(parm, "no_thread");
|
|
|
|
|
|
SDL_StopTextInput();
|
|
|
this->edit_box_focused = false;
|
|
|
|
|
|
return nullptr;
|
|
|
}
|
|
|
|
|
|
void VideoDriver_SDL::Stop()
|
|
|
{
|
|
|
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
|
|
if (SDL_WasInit(SDL_INIT_EVERYTHING) == 0) {
|
|
|
SDL_Quit(); // If there's nothing left, quit SDL
|
|
|
}
|
|
@@ -909,25 +911,33 @@ bool VideoDriver_SDL::ToggleFullscreen(b
|
|
|
} else {
|
|
|
DEBUG(driver, 0, "SDL_SetWindowFullscreen() failed: %s", SDL_GetError());
|
|
|
}
|
|
|
|
|
|
return ret == 0;
|
|
|
}
|
|
|
|
|
|
bool VideoDriver_SDL::AfterBlitterChange()
|
|
|
{
|
|
|
int w, h;
|
|
|
SDL_GetWindowSize(_sdl_window, &w, &h);
|
|
|
return CreateMainSurface(w, h, false);
|
|
|
}
|
|
|
|
|
|
void VideoDriver_SDL::AcquireBlitterLock()
|
|
|
{
|
|
|
if (_draw_mutex != nullptr) _draw_mutex->lock();
|
|
|
}
|
|
|
|
|
|
void VideoDriver_SDL::ReleaseBlitterLock()
|
|
|
{
|
|
|
if (_draw_mutex != nullptr) _draw_mutex->unlock();
|
|
|
}
|
|
|
|
|
|
Dimension VideoDriver_SDL::GetScreenSize() const
|
|
|
{
|
|
|
SDL_DisplayMode mode;
|
|
|
if (SDL_GetCurrentDisplayMode(0, &mode) != 0) return VideoDriver::GetScreenSize();
|
|
|
|
|
|
return { static_cast<uint>(mode.w), static_cast<uint>(mode.h) };
|
|
|
}
|
|
|
|
|
|
#endif /* WITH_SDL2 */
|