--- a/CMakeLists.txt Tue Dec 17 00:02:52 2013 +0400
+++ b/CMakeLists.txt Tue Nov 10 17:45:14 2015 +0100
@@ -15,7 +15,6 @@
option(NOSERVER "Disable gameServer build (off)]" OFF)
option(NOPNG "Disable screenshoot compression (off)" OFF)
option(NOVIDEOREC "Disable video recording (off)" OFF)
-option(NOSDL2 "Disable SDL2+ and use SDL 1.2 (off)" OFF)
#libraries are built shared unless explicitly added as a static
option(BUILD_SHARED_LIBS "Build libraries as shared modules (on)" ON)
--- a/INSTALL Tue Dec 17 00:02:52 2013 +0400
+++ b/INSTALL Tue Nov 10 17:45:14 2015 +0100
@@ -2,10 +2,10 @@
- CMake >= 2.6.0
- FreePascal >= 2.2.0
- Qt >= 4.5.0
- - SDL >= 1.2.5
- - SDL_net >= 1.2.5
- - SDL_mixer >= 1.2
- - SDL_image >= 1.2
+ - SDL >= 2.0
+ - SDL_net >= 2.0
+ - SDL_mixer >= 2.0
+ - SDL_image >= 2.0
- SDL_ttf >= 2.0
- Lua >= 5.1.0
- Physfs >= 2.1.0
--- a/QTfrontend/CMakeLists.txt Tue Dec 17 00:02:52 2013 +0400
+++ b/QTfrontend/CMakeLists.txt Tue Nov 10 17:45:14 2015 +0100
@@ -19,17 +19,10 @@
message(FATAL_ERROR "This version of QT is known *not* to work, please update or use a lower version")
endif()
-if(${NOSDL2})
- find_package(SDL REQUIRED) #video in SDLInteraction
- find_package(SDL_mixer REQUIRED) #audio in SDLInteraction
- include_directories(${SDL_INCLUDE_DIR})
- include_directories(${SDLMIXER_INCLUDE_DIR})
-else(${NOSDL2})
- find_package(SDL2 REQUIRED)
- find_package(SDL2_mixer REQUIRED) #audio in SDLInteraction
- include_directories(${SDL2_INCLUDE_DIR})
- include_directories(${SDL2MIXER_INCLUDE_DIR})
-endif(${NOSDL2})
+find_package(SDL2 REQUIRED)
+find_package(SDL2_mixer REQUIRED) #audio in SDLInteraction
+include_directories(${SDL2_INCLUDE_DIR})
+include_directories(${SDL2MIXER_INCLUDE_DIR})
if(${FFMPEG_FOUND})
add_definitions(-DVIDEOREC -D__STDC_CONSTANT_MACROS)
@@ -207,17 +200,10 @@
${QT_LIBRARIES}
)
-if(NOSDL2)
- list(APPEND HW_LINK_LIBS
- ${SDL_LIBRARY}
- ${SDLMIXER_LIBRARY}
- )
-else()
- list(APPEND HW_LINK_LIBS
- ${SDL2_LIBRARY}
- ${SDL2MIXER_LIBRARY}
- )
-endif()
+list(APPEND HW_LINK_LIBS
+ ${SDL2_LIBRARY}
+ ${SDL2MIXER_LIBRARY}
+ )
if(WIN32 AND NOT UNIX)
if(NOT SDL_LIBRARY)
--- a/QTfrontend/util/SDLInteraction.cpp Tue Dec 17 00:02:52 2013 +0400
+++ b/QTfrontend/util/SDLInteraction.cpp Tue Nov 10 17:45:14 2015 +0100
@@ -84,7 +84,6 @@
{
QStringList result;
-#if SDL_VERSION_ATLEAST(2, 0, 0)
int modesNumber = SDL_GetNumDisplayModes(0);
SDL_DisplayMode mode;
@@ -95,22 +94,6 @@
if ((mode.w >= 640) && (mode.h >= 480))
result << QString("%1x%2").arg(mode.w).arg(mode.h);
}
-#else
- 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);
- }
-#endif
return result;
}
@@ -121,7 +104,7 @@
QStringList result;
#if SDL_VERSION_ATLEAST(2, 0, 0)
-
+// TODO or not TODO?
#else
int i = 0;
while(i < 1024 && sdlkeys[i][1][0] != '\0')
@@ -280,14 +263,9 @@
QSize SDLInteraction::getCurrentResolution()
{
-#if SDL_VERSION_ATLEAST(2, 0, 0)
SDL_DisplayMode mode;
SDL_GetDesktopDisplayMode(0, &mode);
return QSize(mode.w, mode.h);
-#else
- SDL_VideoInfo * vi = SDL_GetVideoInfo();
- return QSize(vi->current_w, vi->current_h);
-#endif
}
--- a/hedgewars/CMakeLists.txt Tue Dec 17 00:02:52 2013 +0400
+++ b/hedgewars/CMakeLists.txt Tue Nov 10 17:45:14 2015 +0100
@@ -1,19 +1,10 @@
enable_language(Pascal)
-if(${NOSDL2})
- find_package(SDL REQUIRED)
- find_package(SDL_image REQUIRED)
- find_package(SDL_net REQUIRED)
- find_package(SDL_ttf REQUIRED)
- find_package(SDL_mixer REQUIRED)
-else(${NOSDL2})
- find_package(SDL2 REQUIRED)
- find_package(SDL2_image REQUIRED)
- find_package(SDL2_net REQUIRED)
- find_package(SDL2_ttf REQUIRED)
- find_package(SDL2_mixer REQUIRED)
- add_definitions(-dSDL2)
-endif(${NOSDL2})
+find_package(SDL2 REQUIRED)
+find_package(SDL2_image REQUIRED)
+find_package(SDL2_net REQUIRED)
+find_package(SDL2_ttf REQUIRED)
+find_package(SDL2_mixer REQUIRED)
include (CheckLibraryExists)
@@ -107,24 +98,12 @@
endif()
-#DEPENDECIES AND EXECUTABLES SECTION
-if(NOT ${BUILD_ENGINE_LIBRARY} AND APPLE AND ${NOSDL2})
- #on OSX we need to provide the SDL_main() function when building as executable
- add_subdirectory(sdlmain)
- list(APPEND HW_LINK_LIBS SDLmain)
- add_flag_append(CMAKE_Pascal_FLAGS -Fl${LIBRARY_OUTPUT_PATH})
-endif()
-
if(FFMPEG_FOUND)
add_subdirectory(avwrapper)
list(APPEND HW_LINK_LIBS avwrapper)
add_definitions(-dUSE_VIDEO_RECORDING)
add_flag_append(CMAKE_Pascal_FLAGS -Fl${LIBRARY_OUTPUT_PATH})
- if(${NOSDL2})
- #only for SDL < 2, linking carried out by fpc
- find_package_or_disable_msg(GLUT NOVIDEOREC "Video recording will not be built")
- endif(${NOSDL2})
endif()
find_package_or_disable_msg(PNG NOPNG "Screenshots will be saved in BMP")
@@ -160,18 +139,6 @@
list(APPEND HW_LINK_LIBS physlayer)
#Mix_Init/Mix_Quit from SDL_mixer 1.2.10
-if(${NOSDL2})
- check_library_exists(${SDLMIXER_LIBRARY} Mix_Init "" HAVE_MIXINIT)
- if(HAVE_MIXINIT)
- add_definitions(-dSDL_MIXER_NEWER)
- endif(HAVE_MIXINIT)
-
- #IMG_Init/IMG_Quit from SDL_image 1.2.8
- check_library_exists(${SDLIMAGE_LIBRARY} IMG_Init "" HAVE_IMGINIT)
- if(HAVE_IMGINIT)
- add_definitions(-dSDL_IMAGE_NEWER)
- endif(HAVE_IMGINIT)
-endif(${NOSDL2})
#needs to be last
add_definitions(-dDEBUGFILE)
--- a/hedgewars/SDLh.pas Tue Dec 17 00:02:52 2013 +0400
+++ b/hedgewars/SDLh.pas Tue Nov 10 17:45:14 2015 +0100
@@ -55,57 +55,29 @@
{$IFDEF DARWIN}
{$IFNDEF HWLIBRARY}
- {$IFDEF SDL2}
- {$linkframework SDL2}
- {$linkframework SDL2_net}
- {$linkframework SDL2_image}
- {$linkframework SDL2_ttf}
- {$linkframework SDL2_mixer}
- {$ELSE}
- {$linklib SDLmain}
- {$PASCALMAINNAME SDL_main}
- {$linkframework Cocoa}
- {$linkframework OpenGL}
- {$linkframework SDL}
- {$linkframework SDL_net}
- {$linkframework SDL_image}
- {$linkframework SDL_ttf}
- {$linkframework SDL_mixer}
- {$ENDIF}
+ {$linkframework SDL2}
+ {$linkframework SDL2_net}
+ {$linkframework SDL2_image}
+ {$linkframework SDL2_ttf}
+ {$linkframework SDL2_mixer}
{$ENDIF}
{$ENDIF}
(* SDL *)
const
-{$IFDEF SDL2}
- {$IFDEF WIN32}
- SDLLibName = 'SDL2.dll';
- SDL_TTFLibName = 'SDL2_ttf.dll';
- SDL_MixerLibName = 'SDL2_mixer.dll';
- SDL_ImageLibName = 'SDL2_image.dll';
- SDL_NetLibName = 'SDL2_net.dll';
- {$ELSE}
- SDLLibName = 'libSDL2';
- SDL_TTFLibName = 'libSDL2_ttf';
- SDL_MixerLibName = 'libSDL2_mixer';
- SDL_ImageLibName = 'libSDL2_image';
- SDL_NetLibName = 'libSDL2_net';
- {$ENDIF}
+{$IFDEF WIN32}
+ SDLLibName = 'SDL2.dll';
+ SDL_TTFLibName = 'SDL2_ttf.dll';
+ SDL_MixerLibName = 'SDL2_mixer.dll';
+ SDL_ImageLibName = 'SDL2_image.dll';
+ SDL_NetLibName = 'SDL2_net.dll';
{$ELSE}
- {$IFDEF WIN32}
- SDLLibName = 'SDL.dll';
- SDL_TTFLibName = 'SDL_ttf.dll';
- SDL_MixerLibName = 'SDL_mixer.dll';
- SDL_ImageLibName = 'SDL_image.dll';
- SDL_NetLibName = 'SDL_net.dll';
- {$ELSE}
- SDLLibName = 'libSDL';
- SDL_TTFLibName = 'libSDL_ttf';
- SDL_MixerLibName = 'libSDL_mixer';
- SDL_ImageLibName = 'libSDL_image';
- SDL_NetLibName = 'libSDL_net';
- {$ENDIF}
+ SDLLibName = 'libSDL2';
+ SDL_TTFLibName = 'libSDL2_ttf';
+ SDL_MixerLibName = 'libSDL2_mixer';
+ SDL_ImageLibName = 'libSDL2_image';
+ SDL_NetLibName = 'libSDL2_net';
{$ENDIF}
/////////////////////////////////////////////////////////////////
@@ -117,14 +89,9 @@
SDL_INIT_AUDIO = $00000010;
SDL_INIT_VIDEO = $00000020; // implies SDL_INIT_EVENTS (sdl2)
SDL_INIT_JOYSTICK = $00000200; // implies SDL_INIT_EVENTS (sdl2)
-{$IFDEF SDL2}
SDL_INIT_HAPTIC = $00001000;
SDL_INIT_GAMECONTROLLER = $00002000; // implies SDL_INIT_JOYSTICK
SDL_INIT_EVENTS = $00004000;
-{$ELSE}
- SDL_INIT_CDROM = $00000100;
- SDL_INIT_EVENTTHREAD = $01000000;
-{$ENDIF}
SDL_INIT_NOPARACHUTE = $00100000;
//SDL_INIT_EVERYTHING // unsafe, init subsystems one at a time
@@ -138,7 +105,6 @@
SDL_BUTTON_WHEELDOWN = 5;
-{$IFDEF SDL2}
SDL_TEXTEDITINGEVENT_TEXT_SIZE = 32;
SDL_TEXTINPUTEVENT_TEXT_SIZE = 32;
@@ -234,39 +200,6 @@
SDL_WINDOWEVENT_FOCUS_GAINED = 12; //*< Window has gained keyboard focus
SDL_WINDOWEVENT_FOCUS_LOST = 13; //*< Window has lost keyboard focus
SDL_WINDOWEVENT_CLOSE = 14; //*< The window manager requests that the window be closed */
-{$ELSE}
- // SDL_Event types
- SDL_NOEVENT = 0;
- SDL_ACTIVEEVENT = 1;
- SDL_KEYDOWN = 2;
- SDL_KEYUP = 3;
- SDL_MOUSEMOTION = 4;
- SDL_MOUSEBUTTONDOWN = 5;
- SDL_MOUSEBUTTONUP = 6;
- SDL_JOYAXISMOTION = 7;
- SDL_JOYBALLMOTION = 8;
- SDL_JOYHATMOTION = 9;
- SDL_JOYBUTTONDOWN = 10;
- SDL_JOYBUTTONUP = 11;
- SDL_QUITEV = 12;
- SDL_VIDEORESIZE = 16;
-
- // SDL_Surface flags
- SDL_SWSURFACE = $00000000;
- SDL_HWSURFACE = $00000001;
- SDL_OPENGL = $00000002;
- SDL_ASYNCBLIT = $00000004;
- SDL_RESIZABLE = $00000010;
- SDL_NOFRAME = $00000020;
- SDL_HWACCEL = $00000100;
- SDL_SRCCOLORKEY = $00001000;
- SDL_RLEACCEL = $00004000;
- SDL_SRCALPHA = $00010000;
- SDL_ANYFORMAT = $00100000;
- SDL_HWPALETTE = $20000000;
- SDL_DOUBLEBUF = $40000000;
- SDL_FULLSCREEN = $80000000;
-{$ENDIF}
{$IFDEF ENDIAN_LITTLE}
RMask = $000000FF;
@@ -356,25 +289,18 @@
// http://www.freepascal.org/docs-html/prog/progsu144.html
type
-{$IFDEF SDL2}
PSDL_Window = Pointer;
PSDL_Renderer = Pointer;
PSDL_Texture = Pointer;
PSDL_GLContext= Pointer;
TSDL_TouchId = Int64;
-{$ENDIF}
TSDL_FingerId = Int64;
TSDL_eventaction = (SDL_ADDEVENT, SDL_PEEPEVENT, SDL_GETEVENT);
PSDL_Rect = ^TSDL_Rect;
TSDL_Rect = record
-{$IFDEF SDL2}
x, y, w, h: LongInt;
-{$ELSE}
- x, y: SmallInt;
- w, h: Word;
-{$ENDIF}
end;
TPoint = record
@@ -383,7 +309,6 @@
PSDL_PixelFormat = ^TSDL_PixelFormat;
TSDL_PixelFormat = record
-{$IFDEF SDL2}
format: LongWord;
palette: Pointer;
BitsPerPixel : Byte;
@@ -403,25 +328,6 @@
Ashift: Byte;
refcount: LongInt;
next: PSDL_PixelFormat;
-{$ELSE}
- palette: Pointer;
- BitsPerPixel : Byte;
- BytesPerPixel: Byte;
- Rloss : Byte;
- Gloss : Byte;
- Bloss : Byte;
- Aloss : Byte;
- Rshift: Byte;
- Gshift: Byte;
- Bshift: Byte;
- Ashift: Byte;
- RMask : LongWord;
- GMask : LongWord;
- BMask : LongWord;
- AMask : LongWord;
- colorkey: LongWord;
- alpha: Byte;
-{$ENDIF}
end;
PSDL_Surface = ^TSDL_Surface;
@@ -429,18 +335,14 @@
flags : LongWord;
format: PSDL_PixelFormat;
w, h : LongInt;
- pitch : {$IFDEF SDL2}LongInt{$ELSE}Word{$ENDIF};
+ pitch : LongInt;
pixels: Pointer;
-{$IFDEF SDL2}
userdata: Pointer;
locked: LongInt;
lock_data: Pointer;
clip_rect: TSDL_Rect;
map: Pointer;
refcount: LongInt;
-{$ELSE}
- offset: LongInt;
-{$ENDIF}
end;
@@ -455,18 +357,14 @@
(* SDL_RWops and friends *)
PSDL_RWops = ^TSDL_RWops;
-{$IFDEF SDL2}
TSize = function( context: PSDL_RWops): Int64; cdecl;
TSeek = function( context: PSDL_RWops; offset: Int64; whence: LongInt ): Int64; cdecl;
-{$ELSE}
- TSeek = function( context: PSDL_RWops; offset: LongInt; whence: LongInt ): LongInt; cdecl;
-{$ENDIF}
TRead = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt; cdecl;
TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; cdecl;
TClose = function( context: PSDL_RWops ): LongInt; cdecl;
TStdio = record
- autoclose: {$IFDEF SDL2}Boolean{$ELSE}LongInt{$ENDIF};
+ autoclose: Boolean;
fp: Pointer;
end;
@@ -478,9 +376,7 @@
TUnknown = record
data1: Pointer;
-{$IFDEF SDL2}
data2: Pointer;
-{$ENDIF}
end;
{$IFDEF ANDROID}
@@ -497,7 +393,7 @@
size, left: LongInt;
end;
TWindowsio = record
- append : {$IFDEF SDL2}Boolean{$ELSE}LongInt{$ENDIF};
+ append : Boolean;
h : Pointer;
buffer : TWinbuffer;
end;
@@ -505,9 +401,7 @@
{$ENDIF}
TSDL_RWops = record
-{$IFDEF SDL2}
size: TSize;
-{$ENDIF}
seek: TSeek;
read: TRead;
write: TWrite;
@@ -529,7 +423,6 @@
{* SDL_Event type definition *}
-{$IFDEF SDL2}
TSDL_Keysym = record
scancode: LongInt;
sym: LongInt;
@@ -630,167 +523,92 @@
end;
TSDL_OSEvent = TSDL_CommonEvent;
-{$ELSE}
- TSDL_KeySym = record
- scancode: Byte;
- sym: LongWord;
- modifier: LongWord;
- unicode: Word;
- end;
-
- TSDL_ActiveEvent = record
- type_: Byte;
- gain: Byte;
- state: Byte;
- end;
-
- TSDL_ResizeEvent = record
- type_: Byte;
- w, h: LongInt;
- end;
-{$ENDIF}
TSDL_KeyboardEvent = record
-{$IFDEF SDL2}
type_: LongWord;
timestamp: LongWord;
windowID: LongWord;
state, repeat_, padding2, padding3: Byte;
-{$ELSE}
- type_, which, state: Byte;
-{$ENDIF}
keysym: TSDL_Keysym;
end;
TSDL_MouseMotionEvent = record
-{$IFDEF SDL2}
type_: LongWord;
timestamp: LongWord;
windowID: LongWord;
which, state: LongWord;
x, y, xrel, yrel: LongInt;
-{$ELSE}
- type_, which, state: Byte;
- x, y, xrel, yrel: Word;
-{$ENDIF}
end;
TSDL_MouseButtonEvent = record
-{$IFDEF SDL2}
type_: LongWord;
timestamp: LongWord;
windowID: LongWord;
which: LongWord;
button, state, padding1, padding2: Byte;
x, y: LongInt;
-{$ELSE}
- type_, which, button, state: Byte;
- x, y: Word;
-{$ENDIF}
end;
TSDL_MouseWheelEvent = record
type_: LongWord;
-{$IFDEF SDL2}
timestamp: LongWord;
windowID: LongWord;
which: LongWord;
-{$ELSE}
- which: Byte;
-{$ENDIF}
x, y: LongInt;
end;
TSDL_JoyAxisEvent = record
-{$IFDEF SDL2}
type_: LongWord;
timestamp: LongWord;
which: LongWord;
-{$ELSE}
- type_: Byte;
- which: Byte;
-{$ENDIF}
axis: Byte;
-{$IFDEF SDL2}
padding1, padding2, padding3: Byte;
value: LongInt;
padding4: Word;
-{$ELSE}
- value: SmallInt;
-{$ENDIF}
end;
TSDL_JoyBallEvent = record
-{$IFDEF SDL2}
type_: LongWord;
timestamp: LongWord;
which: LongWord;
-{$ELSE}
- type_: Byte;
- which: Byte;
-{$ENDIF}
ball: Byte;
-{$IFDEF SDL2}
padding1, padding2, padding3: Byte;
-{$ENDIF}
xrel, yrel: SmallInt;
end;
TSDL_JoyHatEvent = record
-{$IFDEF SDL2}
type_: LongWord;
timestamp: LongWord;
which: LongWord;
-{$ELSE}
- type_: Byte;
- which: Byte;
-{$ENDIF}
hat: Byte;
value: Byte;
-{$IFDEF SDL2}
padding1, padding2: Byte;
-{$ENDIF}
end;
TSDL_JoyButtonEvent = record
-{$IFDEF SDL2}
type_: LongWord;
timestamp: LongWord;
-{$ELSE}
- type_: Byte;
-{$ENDIF}
which: Byte;
button: Byte;
state: Byte;
-{$IFDEF SDL2}
padding1: Byte;
-{$ENDIF}
end;
TSDL_QuitEvent = record
-{$IFDEF SDL2}
type_: LongWord;
timestamp: LongWord;
-{$ELSE}
- type_: Byte;
-{$ENDIF}
end;
TSDL_UserEvent = record
-{$IFDEF SDL2}
type_: LongWord;
timestamp: LongWord;
windowID: LongWord;
-{$ELSE}
- type_: Byte;
-{$ENDIF}
code: LongInt;
data1, data2: Pointer;
end;
PSDL_Event = ^TSDL_Event;
TSDL_Event = record
-{$IFDEF SDL2}
case LongInt of
SDL_FIRSTEVENT: (type_: LongWord);
SDL_COMMONDEVENT: (common: TSDL_CommonEvent);
@@ -826,25 +644,6 @@
SDL_DOLLARGESTURE: (dgesture: TSDL_DollarGestureEvent);
SDL_DROPFILE: (drop: TSDL_DropEvent);
SDL_ALLEVENTS: (foo: shortstring);
-{$ELSE}
- case Byte of
- SDL_NOEVENT: (type_: Byte);
- SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent);
- SDL_KEYDOWN,
- SDL_KEYUP: (key: TSDL_KeyboardEvent);
- SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
- SDL_MOUSEBUTTONDOWN,
- SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent);
- SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent);
- SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent);
- SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent);
- SDL_JOYBUTTONDOWN,
- SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent);
- SDL_QUITEV: (quit: TSDL_QuitEvent);
- //SDL_SYSWMEVENT,SDL_EVENT_RESERVEDA,SDL_EVENT_RESERVEDB
- SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent);
- SDL_ALLEVENTS: (foo: shortstring);
-{$ENDIF}
end;
TSDL_EventFilter = function( event : PSDL_Event ): Integer; cdecl;
@@ -874,7 +673,6 @@
SDL_GL_MULTISAMPLEBUFFERS,
SDL_GL_MULTISAMPLESAMPLES,
SDL_GL_ACCELERATED_VISUAL,
-{$IFDEF SDL2}
SDL_GL_RETAINED_BACKING,
SDL_GL_CONTEXT_MAJOR_VERSION,
SDL_GL_CONTEXT_MINOR_VERSION,
@@ -882,12 +680,8 @@
SDL_GL_CONTEXT_FLAGS,
SDL_GL_CONTEXT_PROFILE_MASK,
SDL_GL_SHARE_WITH_CURRENT_CONTEXT
-{$ELSE}
- SDL_GL_SWAP_CONTROL
-{$ENDIF}
);
-{$IFDEF SDL2}
TSDL_ArrayByteOrder = ( // array component order, low Byte -> high Byte
SDL_ARRAYORDER_NONE,
SDL_ARRAYORDER_RGB,
@@ -897,7 +691,6 @@
SDL_ARRAYORDER_BGRA,
SDL_ARRAYORDER_ABGR
);
-{$ENDIF}
// Joystick/Controller support
PSDL_Joystick = ^TSDL_Joystick;
@@ -1002,7 +795,6 @@
function SDL_RWFromFile(filename, mode: PChar): PSDL_RWops; cdecl; external SDLLibName;
function SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: LongInt): LongInt; cdecl; external SDLLibName;
-{$IFDEF SDL2}
function SDL_CreateWindow(title: PChar; x,y,w,h: LongInt; flags: LongWord): PSDL_Window; cdecl; external SDLLibName;
function SDL_CreateRenderer(window: PSDL_Window; index: LongInt; flags: LongWord): PSDL_Renderer; cdecl; external SDLLibName;
function SDL_DestroyWindow(window: PSDL_Window): LongInt; cdecl; external SDLLibName;
@@ -1039,13 +831,6 @@
function SDL_AllocFormat(format: LongWord): PSDL_PixelFormat; cdecl; external SDLLibName;
procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat); cdecl; external SDLLibName;
-{$ELSE}
-function SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: TSDL_eventaction; mask: LongWord): LongInt; cdecl; external SDLLibName;
-
-function SDL_EnableUNICODE(enable: LongInt): LongInt; cdecl; external SDLLibName;
-function SDL_EnableKeyRepeat(timedelay, interval: LongInt): LongInt; cdecl; external SDLLibName;
-function SDL_VideoDriverName(namebuf: PChar; maxlen: LongInt): PChar; cdecl; external SDLLibName;
-{$ENDIF}
function SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
@@ -1060,8 +845,9 @@
procedure SDL_SetEventFilter(filter: TSDL_EventFilter); cdecl; external SDLLibName;
function SDL_ShowCursor(toggle: LongInt): LongInt; cdecl; external SDLLibName;
-procedure SDL_WarpMouse(x, y: Word); {$IFDEF SDL2}inline{$ELSE}cdecl; external SDLLibName{$ENDIF};
-function SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName {$IFDEF SDL2} name 'SDL_GetKeyboardState'{$ENDIF};
+procedure SDL_WarpMouse(x, y: Word); inline;
+
+function SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName name 'SDL_GetKeyboardState';
procedure SDL_WM_SetIcon(icon: PSDL_Surface; mask : Byte); cdecl; external SDLLibName;
procedure SDL_WM_SetCaption(title: PChar; icon: PChar); cdecl; external SDLLibName;
@@ -1070,14 +856,14 @@
(* remember to mark the threaded functions as 'cdecl; export;'
(or have fun debugging nil arguments) *)
-function SDL_CreateThread(fn: Pointer; {$IFDEF SDL2}name: PChar;{$ENDIF} data: Pointer): PSDL_Thread; cdecl; external SDLLibName;
+function SDL_CreateThread(fn: Pointer; name: PChar; data: Pointer): PSDL_Thread; cdecl; external SDLLibName;
procedure SDL_WaitThread(thread: PSDL_Thread; status: PLongInt); cdecl; external SDLLibName;
procedure SDL_KillThread(thread: PSDL_Thread); cdecl; external SDLLibName;
function SDL_CreateMutex: PSDL_mutex; cdecl; external SDLLibName;
procedure SDL_DestroyMutex(mutex: PSDL_mutex); cdecl; external SDLLibName;
-function SDL_LockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName {$IFNDEF SDL2}name 'SDL_mutexP'{$ENDIF};
-function SDL_UnlockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName {$IFNDEF SDL2}name 'SDL_mutexV'{$ENDIF};
+function SDL_LockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName;
+function SDL_UnlockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName;
function SDL_GL_SetAttribute(attr: TSDL_GLattr; value: LongInt): LongInt; cdecl; external SDLLibName;
procedure SDL_GL_SwapBuffers; cdecl; external SDLLibName;
@@ -1188,7 +974,6 @@
function SDLNet_Read32(buf: Pointer): LongWord;
implementation
-{$IFDEF SDL2}
uses uStore;
// for sdl1.2 we directly call SDL_WarpMouse()
@@ -1199,16 +984,11 @@
begin
WarpMouse(x, y);
end;
-{$ENDIF}
function SDL_MustLock(Surface: PSDL_Surface): Boolean;
begin
SDL_MustLock:=
-{$IFDEF SDL2}
((surface^.flags and SDL_RLEACCEL) <> 0)
-{$ELSE}
- ( surface^.offset <> 0 ) or (( surface^.flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) <> 0)
-{$ENDIF}
end;
{$IFNDEF SDL_MIXER_NEWER}
--- a/hedgewars/hwengine.pas Tue Dec 17 00:02:52 2013 +0400
+++ b/hedgewars/hwengine.pas Tue Nov 10 17:45:14 2015 +0100
@@ -137,11 +137,7 @@
var event: TSDL_Event;
PrevTime, CurrTime: Longword;
isTerminated: boolean;
-{$IFDEF SDL2}
previousGameState: TGameState;
-{$ELSE}
- prevFocusState: boolean;
-{$ENDIF}
begin
isTerminated:= false;
PrevTime:= SDL_GetTicks;
@@ -149,10 +145,9 @@
begin
SDL_PumpEvents();
- while SDL_PeepEvents(@event, 1, SDL_GETEVENT, {$IFDEF SDL2}SDL_FIRSTEVENT, SDL_LASTEVENT{$ELSE}SDL_ALLEVENTS{$ENDIF}) > 0 do
+ while SDL_PeepEvents(@event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT) > 0 do
begin
case event.type_ of
-{$IFDEF SDL2}
SDL_KEYDOWN:
if (GameState = gsChat) then
KeyPressChat(event.key.keysym.sym)
@@ -211,45 +206,6 @@
SDL_FINGERUP:
onTouchUp(event.tfinger.x, event.tfinger.y, event.tfinger.fingerId);
{$ENDIF}
-{$ELSE}
- SDL_KEYDOWN:
- if GameState = gsChat then
- KeyPressChat(event.key.keysym.unicode, event.key.keysym.sym)
- else
- if GameState >= gsGame then ProcessKey(event.key);
- SDL_KEYUP:
- if (GameState <> gsChat) and (GameState >= gsGame) then
- ProcessKey(event.key);
-
- SDL_MOUSEBUTTONDOWN:
- if GameState = gsConfirm then
- ParseCommand('quit', true)
- else
- if (GameState >= gsGame) then ProcessMouse(event.button, true);
-
- SDL_MOUSEBUTTONUP:
- if (GameState >= gsGame) then ProcessMouse(event.button, false);
-
- SDL_ACTIVEEVENT:
- if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then
- begin
- prevFocusState:= cHasFocus;
- cHasFocus:= event.active.gain = 1;
- if prevFocusState xor cHasFocus then
- onFocusStateChanged()
- end;
-
- SDL_VIDEORESIZE:
- begin
- // using lower values than cMinScreenWidth or cMinScreenHeight causes widget overlap and off-screen widget parts
- // Change by sheepluva:
- // Let's only use even numbers for custom width/height since I ran into scaling issues with odd width values.
- // Maybe just fixes the symptom not the actual cause(?), I'm too tired to find out :P
- cNewScreenWidth:= max(2 * (event.resize.w div 2), cMinScreenWidth);
- cNewScreenHeight:= max(2 * (event.resize.h div 2), cMinScreenHeight);
- cScreenResizeDelay:= RealTicks+500;
- end;
-{$ENDIF}
SDL_JOYAXISMOTION:
ControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value);
SDL_JOYHATMOTION:
@@ -350,11 +306,7 @@
if not cOnlyStats then SDLTry(SDL_Init(SDL_INIT_VIDEO or SDL_INIT_NOPARACHUTE) >= 0, 'SDL_Init', true);
WriteLnToConsole(msgOK);
-{$IFDEF SDL2}
//SDL_StartTextInput();
-{$ELSE}
- SDL_EnableUNICODE(1);
-{$ENDIF}
SDL_ShowCursor(0);
WriteToConsole('Init SDL_ttf... ');
--- a/hedgewars/options.inc Tue Dec 17 00:02:52 2013 +0400
+++ b/hedgewars/options.inc Tue Nov 10 17:45:14 2015 +0100
@@ -60,10 +60,6 @@
{$ENDIF}
{$ENDIF}
-{$IFDEF USE_TOUCH_INTERFACE}
- {$DEFINE SDL2}
-{$ENDIF}
-
//TODO: cruft to be removed
{$DEFINE _S:=}
--- a/hedgewars/uAI.pas Tue Dec 17 00:02:52 2013 +0400
+++ b/hedgewars/uAI.pas Tue Nov 10 17:45:14 2015 +0100
@@ -490,7 +490,7 @@
FillBonuses(((Me^.State and gstAttacked) <> 0) and (not isInMultiShoot));
SDL_LockMutex(ThreadLock);
-ThinkThread:= SDL_CreateThread(@Think{$IFDEF SDL2}, 'think'{$ENDIF}, Me);
+ThinkThread:= SDL_CreateThread(@Think, 'think', Me);
SDL_UnlockMutex(ThreadLock);
end;
--- a/hedgewars/uChat.pas Tue Dec 17 00:02:52 2013 +0400
+++ b/hedgewars/uChat.pas Tue Nov 10 17:45:14 2015 +0100
@@ -31,12 +31,8 @@
procedure DrawChat;
procedure SendHogSpeech(s: shortstring);
-{$IFDEF SDL2}
procedure KeyPressChat(Sym: Longword);
procedure TextInput(var event: TSDL_TextInputEvent);
-{$ELSE}
-procedure KeyPressChat(Key, Sym: Longword);
-{$ENDIF}
implementation
uses uInputHandler, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO;
@@ -316,16 +312,11 @@
begin
FreezeEnterKey;
history:= 0;
-{$IFDEF SDL2}
SDL_StopTextInput();
-{$ELSE}
- SDL_EnableKeyRepeat(0,0);
-{$ENDIF}
GameState:= gsGame;
ResetKbd;
end;
-{$IFDEF SDL2}
procedure TextInput(var event: TSDL_TextInputEvent);
var s: shortstring;
l: byte;
@@ -345,9 +336,6 @@
end;
procedure KeyPressChat(Sym: Longword);
-{$ELSE}
-procedure KeyPressChat(Key, Sym: Longword);
-{$ENDIF}
const firstByteMark: array[0..3] of byte = (0, $C0, $E0, $F0);
var i, btw, index: integer;
utf8: shortstring;
@@ -397,35 +385,6 @@
action:= false;
end;
-{$IFNDEF SDL2}
- if not action and (Key <> 0) then
- begin
- if (Key < $80) then
- btw:= 1
- else if (Key < $800) then
- btw:= 2
- else if (Key < $10000) then
- btw:= 3
- else
- btw:= 4;
-
- utf8:= '';
-
- for i:= btw downto 2 do
- begin
- utf8:= char((Key or $80) and $BF) + utf8;
- Key:= Key shr 6
- end;
-
- utf8:= char(Key or firstByteMark[Pred(btw)]) + utf8;
-
- if byte(InputStr.s[0]) + btw > 240 then
- exit;
-
- InputStrL[byte(InputStr.s[0]) + btw]:= InputStr.s[0];
- SetLine(InputStr, InputStr.s + utf8, true)
- end
-{$ENDIF}
end;
procedure chChatMessage(var s: shortstring);
@@ -468,11 +427,7 @@
begin
s:= s; // avoid compiler hint
GameState:= gsChat;
-{$IFDEF SDL2}
SDL_StartTextInput();
-{$ELSE}
- SDL_EnableKeyRepeat(200,45);
-{$ENDIF}
if length(s) = 0 then
SetLine(InputStr, '', true)
else
--- a/hedgewars/uInputHandler.pas Tue Dec 17 00:02:52 2013 +0400
+++ b/hedgewars/uInputHandler.pas Tue Nov 10 17:45:14 2015 +0100
@@ -205,7 +205,6 @@
end
end;
-{$IFDEF SDL2}
procedure ProcessKey(event: TSDL_KeyboardEvent); inline;
var code: LongInt;
begin
@@ -213,15 +212,6 @@
//writelntoconsole('[KEY] '+inttostr(code)+ ' -> ''' +KeyNames[code] + ''', type = '+inttostr(event.type_));
ProcessKey(code, event.type_ = SDL_KEYDOWN);
end;
-{$ELSE}
-procedure ProcessKey(event: TSDL_KeyboardEvent); inline;
-var code: LongInt;
-begin
- code:= event.keysym.sym;
- //MaskModifier(code, event.keysym.modifier);
- ProcessKey(code, event.type_ = SDL_KEYDOWN);
-end;
-{$ENDIF}
procedure ProcessMouse(event: TSDL_MouseButtonEvent; ButtonDown: boolean);
begin
@@ -311,7 +301,6 @@
end;
-{$IFDEF SDL2}
procedure InitKbdKeyTable;
var i, j, k, t: LongInt;
s: string[15];
@@ -362,63 +351,6 @@
InitDefaultBinds
end;
-{$ELSE}
-procedure InitKbdKeyTable;
-var i, j, k, t: LongInt;
- s: string[15];
-begin
-//TODO in sdl13 this overrides some values (A and B) change indices to some other values at the back perhaps?
-KeyNames[1]:= 'mousel';
-KeyNames[2]:= 'mousem';
-KeyNames[3]:= 'mouser';
-KeyNames[4]:= 'wheelup';
-KeyNames[5]:= 'wheeldown';
-
-for i:= 6 to cKeyMaxIndex do
- begin
- s:= shortstring(sdl_getkeyname(i));
- //AddFileLog('uInputHandler - ' + IntToStr(i) + ': ' + s + ' ' + IntToStr(cKeyMaxIndex));
- if s = 'unknown key' then KeyNames[i]:= ''
- else
- begin
- for t:= 1 to Length(s) do
- if s[t] = ' ' then
- s[t]:= '_';
- KeyNames[i]:= LowerCase(s)
- end;
- end;
-
-
-// get the size of keyboard array
-SDL_GetKeyState(@k);
-
-// Controller(s)
-for j:= 0 to Pred(ControllerNumControllers) do
- begin
- for i:= 0 to Pred(ControllerNumAxes[j]) do
- begin
- keynames[k + 0]:= 'j' + IntToStr(j) + 'a' + IntToStr(i) + 'u';
- keynames[k + 1]:= 'j' + IntToStr(j) + 'a' + IntToStr(i) + 'd';
- inc(k, 2);
- end;
- for i:= 0 to Pred(ControllerNumHats[j]) do
- begin
- keynames[k + 0]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'u';
- keynames[k + 1]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'r';
- keynames[k + 2]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'd';
- keynames[k + 3]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'l';
- inc(k, 4);
- end;
- for i:= 0 to Pred(ControllerNumButtons[j]) do
- begin
- keynames[k]:= 'j' + IntToStr(j) + 'b' + IntToStr(i);
- inc(k, 1);
- end;
- end;
-
- InitDefaultBinds
-end;
-{$ENDIF}
--- a/hedgewars/uMisc.pas Tue Dec 17 00:02:52 2013 +0400
+++ b/hedgewars/uMisc.pas Tue Nov 10 17:45:14 2015 +0100
@@ -30,11 +30,7 @@
function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
function MakeScreenshot(filename: shortstring; k: LongInt): boolean;
function GetTeamStatString(p: PTeam): shortstring;
-{$IFDEF SDL2}
function SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect; inline;
-{$ELSE}
-function SDL_RectMake(x, y: SmallInt; width, height: Word): TSDL_Rect; inline;
-{$ENDIF}
implementation
uses SysUtils, uVariables, uUtils
@@ -261,7 +257,7 @@
image^.size:= size;
image^.buffer:= p;
-SDL_CreateThread(@SaveScreenshot{$IFDEF SDL2}, 'snapshot'{$ENDIF}, image);
+SDL_CreateThread(@SaveScreenshot, 'snapshot', image);
MakeScreenshot:= true; // possibly it is not true but we will not wait for thread to terminate
end;
@@ -279,11 +275,7 @@
end;
end;
-{$IFDEF SDL2}
function SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect; inline;
-{$ELSE}
-function SDL_RectMake(x, y: SmallInt; width, height: Word): TSDL_Rect; inline;
-{$ENDIF}
begin
SDL_RectMake.x:= x;
SDL_RectMake.y:= y;
@@ -299,29 +291,14 @@
end;
procedure initModule;
-{$IFDEF SDL2}
const SDL_PIXELFORMAT_ABGR8888 = (1 shl 28) or (6 shl 24) or (7 shl 20) or (6 shl 16) or (32 shl 8) or 4;
-{$ELSE}
-const format: TSDL_PixelFormat = (
- palette: nil; BitsPerPixel: 32; BytesPerPixel: 4;
- Rloss: 0; Gloss: 0; Bloss: 0; Aloss: 0;
- Rshift: RShift; Gshift: GShift; Bshift: BShift; Ashift: AShift;
- RMask: RMask; GMask: GMask; BMask: BMask; AMask: AMask;
- colorkey: 0; alpha: 255);
-{$ENDIF}
begin
-{$IFDEF SDL2}
conversionFormat:= SDL_AllocFormat(SDL_PIXELFORMAT_ABGR8888);
-{$ELSE}
- conversionFormat:= @format;
-{$ENDIF}
end;
procedure freeModule;
begin
-{$IFDEF SDL2}
SDL_FreeFormat(conversionFormat);
-{$ENDIF}
end;
end.
--- a/hedgewars/uStore.pas Tue Dec 17 00:02:52 2013 +0400
+++ b/hedgewars/uStore.pas Tue Nov 10 17:45:14 2015 +0100
@@ -53,9 +53,7 @@
procedure InitOffscreenOpenGL;
{$ENDIF}
-{$IFDEF SDL2}
procedure WarpMouse(x, y: Word); inline;
-{$ENDIF}
procedure SwapBuffers; {$IFDEF USE_VIDEO_RECORDING}cdecl{$ELSE}inline{$ENDIF};
procedure SetSkyColor(r, g, b: real);
@@ -63,18 +61,13 @@
uses uMisc, uConsole, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands
, uPhysFSLayer
, uDebug
- {$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF}
- {$IF NOT DEFINED(SDL2) AND DEFINED(USE_VIDEO_RECORDING)}, glut {$ENDIF};
+ {$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF};
//type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel, gvApple);
var MaxTextureSize: LongInt;
-{$IFDEF SDL2}
SDLwindow: PSDL_Window;
SDLGLcontext: PSDL_GLContext;
-{$ELSE}
- SDLPrimSurface: PSDL_Surface;
-{$ENDIF}
squaresize : LongInt;
numsquares : LongInt;
ProgrTex: PTexture;
@@ -689,9 +682,6 @@
{$ELSE}
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
{$ENDIF}
-{$IFNDEF SDL2} // vsync is default in SDL2
- SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, LongInt((cReducedQuality and rqDesyncVBlank) = 0));
-{$ENDIF}
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
@@ -708,16 +698,10 @@
tmpint: LongInt;
tmpn: LongInt;
begin
-{$IFDEF SDL2}
AddFileLog('Setting up OpenGL (using driver: ' + shortstring(SDL_GetCurrentVideoDriver()) + ')');
-{$ELSE}
- buf[0]:= char(0); // avoid compiler hint
- AddFileLog('Setting up OpenGL (using driver: ' + shortstring(SDL_VideoDriverName(buf, sizeof(buf))) + ')');
-{$ENDIF}
AuxBufNum:= AuxBufNum;
-{$IFDEF SDL2}
// TODO: this function creates an opengles1.1 context
// un-comment below and add proper logic to support opengles2.0
//SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
@@ -726,7 +710,6 @@
SDLGLcontext:= SDL_GL_CreateContext(SDLwindow);
SDLTry(SDLGLcontext <> nil, 'SDLGLcontext', true);
SDLTry(SDL_GL_SetSwapInterval(1) = 0, 'SDL_GL_SetSwapInterval', true);
-{$ENDIF}
// get the max (h and v) size for textures that the gpu can support
glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize);
@@ -1084,7 +1067,6 @@
end;
{$IFDEF USE_VIDEO_RECORDING}
-{$IFDEF SDL2}
procedure InitOffscreenOpenGL;
begin
// create hidden window
@@ -1095,30 +1077,13 @@
SDLTry(SDLwindow <> nil, 'SDL_CreateWindow', true);
SetupOpenGL();
end;
-{$ELSE}
-procedure InitOffscreenOpenGL;
-var ArgCount: LongInt;
- PrgName: pchar;
-begin
- ArgCount:= 1;
- PrgName:= 'hwengine';
- glutInit(@ArgCount, @PrgName);
- glutInitWindowSize(cScreenWidth, cScreenHeight);
- // we do not need a window, but without this call OpenGL will not initialize
- glutCreateWindow('hedgewars video rendering (glut hidden window)');
- glutHideWindow();
- // we do not need to set this callback, but it is required for GLUT3 compat
- glutDisplayFunc(@SwapBuffers);
- SetupOpenGL();
-end;
-{$ENDIF} // SDL2
{$ENDIF} // USE_VIDEO_RECORDING
procedure chFullScr(var s: shortstring);
var flags: Longword = 0;
reinit: boolean = false;
{$IFNDEF DARWIN}ico: PSDL_Surface;{$ENDIF}
- {$IFDEF SDL2}x, y: LongInt;{$ENDIF}
+ x, y: LongInt;
begin
if cOnlyStats then
begin
@@ -1141,30 +1106,12 @@
end;
AddFileLog('Preparing to change video parameters...');
-{$IFDEF SDL2}
if SDLwindow = nil then
-{$ELSE}
- if SDLPrimSurface = nil then
-{$ENDIF}
begin
// set window title
- {$IFNDEF SDL2}
- SDL_WM_SetCaption(_P'Hedgewars', nil);
- {$ENDIF}
WriteToConsole('Init SDL_image... ');
SDLTry(IMG_Init(IMG_INIT_PNG) <> 0, 'IMG_Init', true);
WriteLnToConsole(msgOK);
- // load engine icon
- {$IFNDEF DARWIN}
- {$IFNDEF SDL2}
- ico:= LoadDataImage(ptGraphics, 'hwengine', ifIgnoreCaps);
- if ico <> nil then
- begin
- SDL_WM_SetIcon(ico, 0);
- SDL_FreeSurface(ico)
- end;
- {$ENDIF}
- {$ENDIF}
end
else
begin
@@ -1189,10 +1136,6 @@
//uTextures.freeModule; //DEBUG ONLY
{$ENDIF}
AddFileLog('Freeing old primary surface...');
- {$IFNDEF SDL2}
- SDL_FreeSurface(SDLPrimSurface);
- SDLPrimSurface:= nil;
- {$ENDIF}
{$ENDIF}
end;
@@ -1206,7 +1149,6 @@
*)
SetupOpenGLAttributes();
{$ENDIF}
-{$IFDEF SDL2}
// these values in x and y make the window appear in the center
x:= SDL_WINDOWPOS_CENTERED_MASK;
y:= SDL_WINDOWPOS_CENTERED_MASK;
@@ -1227,23 +1169,6 @@
if SDLwindow = nil then
SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags);
SDLTry(SDLwindow <> nil, 'SDL_CreateWindow', true);
-{$ELSE}
- flags:= SDL_OPENGL or SDL_RESIZABLE;
- if cFullScreen then
- flags:= flags or SDL_FULLSCREEN;
- if not cOnlyStats then
- begin
- {$IFDEF WIN32}
- s:= SDL_getenv('SDL_VIDEO_CENTERED');
- SDL_putenv('SDL_VIDEO_CENTERED=1');
- {$ENDIF}
- SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, 0, flags);
- SDLTry(SDLPrimSurface <> nil, true);
- {$IFDEF WIN32}
- SDL_putenv(str2pchar('SDL_VIDEO_CENTERED=' + s));
- {$ENDIF}
- end;
-{$ENDIF}
SetupOpenGL();
if reinit then
@@ -1266,7 +1191,6 @@
end;
end;
-{$IFDEF SDL2}
// for sdl1.2 we directly call SDL_WarpMouse()
// for sdl2 we provide a SDL_WarpMouse() which just calls this function
// this has the advantage of reducing 'uses' and 'ifdef' statements
@@ -1275,17 +1199,12 @@
begin
SDL_WarpMouseInWindow(SDLwindow, x, y);
end;
-{$ENDIF}
procedure SwapBuffers; {$IFDEF USE_VIDEO_RECORDING}cdecl{$ELSE}inline{$ENDIF};
begin
if GameType = gmtRecord then
exit;
-{$IFDEF SDL2}
SDL_GL_SwapWindow(SDLwindow);
-{$ELSE}
- SDL_GL_SwapBuffers();
-{$ENDIF}
end;
procedure SetSkyColor(r, g, b: real);
@@ -1312,22 +1231,16 @@
// init all count texture pointers
for i:= Low(CountTexz) to High(CountTexz) do
CountTexz[i] := nil;
-{$IFDEF SDL2}
SDLwindow:= nil;
SDLGLcontext:= nil;
-{$ELSE}
- SDLPrimSurface:= nil;
-{$ENDIF}
end;
procedure freeModule;
begin
StoreRelease(false);
TTF_Quit();
-{$IFDEF SDL2}
SDL_GL_DeleteContext(SDLGLcontext);
SDL_DestroyWindow(SDLwindow);
-{$ENDIF}
SDL_Quit();
end;
end.