Skip to content

Commit c191a1f

Browse files
committed
This is an initial (mostly working) port to SDL2.
By default SDL1.2 is still used, but by chaning the config.make option, SDL2 is used instead as a build-time option. What works, what doesn't? Working fine: Joystick input Mouse input Keyboard input Sound Fullscreen mode-switching - now working Issues: Fullscreen (native resolution) *mostly* (there is often some flickering, switching back and forth fixes it. Needs investigating.) Okay, I think this is related to the problems with the splash screen. There's a problem with the GL bounds I think. I'm not an OpenGL expert by any means, so I'm not sure what the problem is. Might be an SDL bug. Splash screen - code is there and no longer prevents startup. It works sometimes. Usually the first time. Always works under wayland (with the Wayland SDL video backend), see below. Windows support is untested. I tried not to break it. Wayland - I will test this shortly, it works, even the splash screen! There were some issues resizing under Weston, lack of SSD makes it tricky anyway! Worked fine under Enlightenment/Wayland. Android/iPhone, obscure devices ... Probably needs OpenGL ES ... maybe it just works like Wayland. There is a lot of code that could be simplified, in particular it's possible the SDL2 Windows support works...? Testers/reviewers more than welcome! Especially help with the GL issues mentioned above.
1 parent 3e76dd4 commit c191a1f

File tree

7 files changed

+317
-242
lines changed

7 files changed

+317
-242
lines changed

GNUmakefile

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
include $(GNUSTEP_MAKEFILES)/common.make
22
include config.make
33

4-
vpath %.m src/SDL:src/Core:src/Core/Entities:src/Core/Materials:src/Core/Scripting:src/Core/OXPVerifier:src/Core/Debug
5-
vpath %.h src/SDL:src/Core:src/Core/Entities:src/Core/Materials:src/Core/Scripting:src/Core/OXPVerifier:src/Core/Debug:src/Core/MiniZip
6-
vpath %.c src/SDL:src/Core:src/BSDCompat:src/Core/Debug:src/Core/MiniZip
4+
ifeq ($(OO_SDL2_ENABLED),yes)
5+
OO_SDL_DIR = src/SDL2
6+
SDL_CFLAGS = `sdl2-config --cflags` -DOO_ENABLE_SDL2
7+
SDL_OBJCFLAGS = `sdl2-config --cflags` -DOO_ENABLE_SDL2
8+
SDL_OBJC_LIBS = -lSDL2main -lSDL2
9+
else
10+
OO_SDL_DIR = src/SDL
11+
SDL_CFLAGS = `sdl-config --cflags`
12+
SDL_OBJCFLAGS = `sdl-config --cflags`
13+
SDL_OBJC_LIBS = -lSDLmain -lSDL
14+
endif
15+
16+
vpath %.m $(OO_SDL_DIR):src/Core:src/Core/Entities:src/Core/Materials:src/Core/Scripting:src/Core/OXPVerifier:src/Core/Debug
17+
vpath %.h $(OO_SDL_DIR):src/Core:src/Core/Entities:src/Core/Materials:src/Core/Scripting:src/Core/OXPVerifier:src/Core/Debug:src/Core/MiniZip
18+
vpath %.c $(OO_SDL_DIR):src/Core:src/BSDCompat:src/Core/Debug:src/Core/MiniZip
719
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_USER_ROOT)
820
ifeq ($(GNUSTEP_HOST_OS),mingw32)
921
GNUSTEP_OBJ_DIR_NAME := $(GNUSTEP_OBJ_DIR_NAME).win
@@ -23,11 +35,11 @@ ifeq ($(GNUSTEP_HOST_OS),mingw32)
2335
else
2436
JS_IMPORT_LIBRARY = js32ECMAv5
2537
endif
26-
ADDITIONAL_INCLUDE_DIRS = -I$(WIN_DEPS_DIR)/include -I$(JS_INC_DIR) -Isrc/SDL -Isrc/Core -Isrc/BSDCompat -Isrc/Core/Scripting -Isrc/Core/Materials -Isrc/Core/Entities -Isrc/Core/OXPVerifier -Isrc/Core/Debug -Isrc/Core/Tables -Isrc/Core/MiniZip
27-
ADDITIONAL_OBJC_LIBS = -lglu32 -lopengl32 -lopenal32.dll -lpng14.dll -lmingw32 -lSDLmain -lSDL -lvorbisfile.dll -lvorbis.dll -lz -lgnustep-base -l$(JS_IMPORT_LIBRARY) -lwinmm -mwindows
28-
ADDITIONAL_CFLAGS = -DWIN32 -DNEED_STRLCPY `sdl-config --cflags` -mtune=generic
38+
ADDITIONAL_INCLUDE_DIRS = -I$(WIN_DEPS_DIR)/include -I$(JS_INC_DIR) -I$(OO_SDL_DIR) -Isrc/Core -Isrc/BSDCompat -Isrc/Core/Scripting -Isrc/Core/Materials -Isrc/Core/Entities -Isrc/Core/OXPVerifier -Isrc/Core/Debug -Isrc/Core/Tables -Isrc/Core/MiniZip
39+
ADDITIONAL_OBJC_LIBS = -lglu32 -lopengl32 -lopenal32.dll -lpng14.dll -lmingw32 $(SDL_OBJC_LIBS) -lvorbisfile.dll -lvorbis.dll -lz -lgnustep-base -l$(JS_IMPORT_LIBRARY) -lwinmm -mwindows
40+
ADDITIONAL_CFLAGS = -DWIN32 -DNEED_STRLCPY $(SDL_CFLAGS) -mtune=generic
2941
# note the vpath stuff above isn't working for me, so adding src/SDL and src/Core explicitly
30-
ADDITIONAL_OBJCFLAGS = -DLOADSAVEGUI -DWIN32 -DXP_WIN -Wno-import -std=gnu99 `sdl-config --cflags` -mtune=generic
42+
ADDITIONAL_OBJCFLAGS = -DLOADSAVEGUI -DWIN32 -DXP_WIN -Wno-import -std=gnu99 $(SDL_OBJCFLAGS) -mtune=generic
3143
ifneq ($(GNUSTEP_HOST_CPU),x86_64)
3244
ADDITIONAL_LDFLAGS += -Wl,--large-address-aware
3345
else
@@ -49,10 +61,10 @@ else
4961
LIBJS_LIB_DIR = $(LIBJS_ROOT)/dist/lib
5062
LIBJS = js_static
5163

52-
ADDITIONAL_INCLUDE_DIRS = -I$(LIBJS_INC_DIR) -Isrc/SDL -Isrc/Core -Isrc/BSDCompat -Isrc/Core/Scripting -Isrc/Core/Materials -Isrc/Core/Entities -Isrc/Core/OXPVerifier -Isrc/Core/Debug -Isrc/Core/Tables -Isrc/Core/MiniZip
53-
ADDITIONAL_OBJC_LIBS = -lGLU -lGL -lX11 -lSDL -lgnustep-base -l$(LIBJS) `nspr-config --libs` -lstdc++ -lopenal -lz -lvorbisfile
54-
ADDITIONAL_CFLAGS = -Wall -DLINUX -DNEED_STRLCPY `sdl-config --cflags` `nspr-config --cflags`
55-
ADDITIONAL_OBJCFLAGS = -Wall -std=gnu99 -DLOADSAVEGUI -DLINUX -DXP_UNIX -Wno-import `sdl-config --cflags` `nspr-config --cflags`
64+
ADDITIONAL_INCLUDE_DIRS = -I$(LIBJS_INC_DIR) -I$(OO_SDL_DIR) -Isrc/Core -Isrc/BSDCompat -Isrc/Core/Scripting -Isrc/Core/Materials -Isrc/Core/Entities -Isrc/Core/OXPVerifier -Isrc/Core/Debug -Isrc/Core/Tables -Isrc/Core/MiniZip
65+
ADDITIONAL_OBJC_LIBS = -lGLU -lGL -lX11 $(SDL_OBJC_LIBS) -lgnustep-base -l$(LIBJS) `nspr-config --libs` -lstdc++ -lopenal -lz -lvorbisfile
66+
ADDITIONAL_CFLAGS = -Wall -DLINUX -DNEED_STRLCPY $(SDL_CFLAGS) `nspr-config --cflags`
67+
ADDITIONAL_OBJCFLAGS = -Wall -std=gnu99 -DLOADSAVEGUI -DLINUX -DXP_UNIX -Wno-import $(SDL_OBJCFLAGS) `nspr-config --cflags`
5668
oolite_LIB_DIRS += -L$(LIBJS_LIB_DIR) -L/usr/X11R6/lib/
5769

5870
ifeq ($(use_deps),yes)

config.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ OO_LOCALIZATION_TOOLS = yes
2222
DEBUG_GRAPHVIZ = yes
2323
OO_JAVASCRIPT_TRACE = yes
2424
OO_FOV_INFLIGHT_CONTROL_ENABLED = no
25+
OO_SDL2_ENABLED = no

src/Core/OOJoystickManager.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ enum {
151151
//SDL Abstracted constants
152152

153153
#if OOLITE_SDL
154-
155154
#import <SDL.h>
156155

157156
enum

src/Core/OOOpenGLOnly.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ MA 02110-1301, USA.
5757
// the standard SDL_opengl.h
5858
#include <SDL_opengl.h>
5959

60+
#if OO_ENABLE_SDL2
61+
#include <GL/glu.h>
62+
#endif
63+
6064
// include an up-to-date version of glext.h
6165
#include <GL/glext.h>
6266

src/SDL2/MyOpenGLView.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ extern int debug;
166166

167167
// Windowed mode
168168
NSSize currentWindowSize;
169-
SDL_Surface *surface;
169+
SDL_Window *mainWindow;
170+
SDL_GLContext *glContext;
170171

171172
BOOL showSplashScreen;
172173

@@ -176,7 +177,7 @@ extern int debug;
176177
BOOL updateContext;
177178
BOOL saveSize;
178179
unsigned keyboardMap;
179-
HWND SDL_Window;
180+
HWND Main_Window;
180181
MONITORINFOEX monitorInfo;
181182
RECT lastGoodRect;
182183

0 commit comments

Comments
 (0)