4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
10 /** @file sdl.cpp Implementation of SDL support. */
19 /** Number of users of the SDL library. */
20 static int _sdl_usage
;
22 #ifdef DYNAMICALLY_LOADED_SDL
24 #include "os/windows/win32.h"
27 static const char sdl_files
[] =
30 M("SDL_InitSubSystem")
32 M("SDL_QuitSubSystem")
36 M("SDL_WM_SetCaption")
46 M("SDL_UnlockSurface")
51 M("SDL_EnableKeyRepeat")
52 M("SDL_EnableUNICODE")
53 M("SDL_VideoDriverName")
62 M("SDL_Linked_Version")
69 static const char *LoadSdlDLL()
71 if (sdl_proc
.SDL_Init
!= NULL
) {
74 if (!LoadLibraryList((Function
*)(void *)&sdl_proc
, sdl_files
)) {
75 return "Unable to load sdl.dll";
80 #endif /* DYNAMICALLY_LOADED_SDL */
83 * Open the SDL library.
84 * @param x The subsystem to load.
86 const char *SdlOpen(uint32 x
)
88 #ifdef DYNAMICALLY_LOADED_SDL
90 const char *s
= LoadSdlDLL();
91 if (s
!= NULL
) return s
;
94 if (_sdl_usage
++ == 0) {
95 if (SDL_CALL
SDL_Init(x
| SDL_INIT_NOPARACHUTE
) == -1) return SDL_CALL
SDL_GetError();
97 if (SDL_CALL
SDL_InitSubSystem(x
) == -1) return SDL_CALL
SDL_GetError();
104 * Close the SDL library.
105 * @param x The subsystem to close.
107 void SdlClose(uint32 x
)
110 SDL_CALL
SDL_QuitSubSystem(x
);
112 if (--_sdl_usage
== 0) {