Skip to content

Commit

Permalink
This is an initial (mostly working) port to SDL2.
Browse files Browse the repository at this point in the history
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.

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.
  • Loading branch information
sjnewbury committed Jul 1, 2017
1 parent 3e76dd4 commit 8f7bb2f
Show file tree
Hide file tree
Showing 7 changed files with 299 additions and 233 deletions.
34 changes: 23 additions & 11 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
include $(GNUSTEP_MAKEFILES)/common.make
include config.make

vpath %.m src/SDL:src/Core:src/Core/Entities:src/Core/Materials:src/Core/Scripting:src/Core/OXPVerifier:src/Core/Debug
vpath %.h src/SDL:src/Core:src/Core/Entities:src/Core/Materials:src/Core/Scripting:src/Core/OXPVerifier:src/Core/Debug:src/Core/MiniZip
vpath %.c src/SDL:src/Core:src/BSDCompat:src/Core/Debug:src/Core/MiniZip
ifeq ($(OO_SDL2_ENABLED),yes)
OO_SDL_DIR = src/SDL2
SDL_CFLAGS = `sdl2-config --cflags` -DOO_ENABLE_SDL2
SDL_OBJCFLAGS = `sdl2-config --cflags` -DOO_ENABLE_SDL2
SDL_OBJC_LIBS = -lSDL2main -lSDL2
else
OO_SDL_DIR = src/SDL
SDL_CFLAGS = `sdl-config --cflags`
SDL_OBJCFLAGS = `sdl-config --cflags`
SDL_OBJC_LIBS = -lSDLmain -lSDL
endif

vpath %.m $(OO_SDL_DIR):src/Core:src/Core/Entities:src/Core/Materials:src/Core/Scripting:src/Core/OXPVerifier:src/Core/Debug
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
vpath %.c $(OO_SDL_DIR):src/Core:src/BSDCompat:src/Core/Debug:src/Core/MiniZip
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_USER_ROOT)
ifeq ($(GNUSTEP_HOST_OS),mingw32)
GNUSTEP_OBJ_DIR_NAME := $(GNUSTEP_OBJ_DIR_NAME).win
Expand All @@ -23,11 +35,11 @@ ifeq ($(GNUSTEP_HOST_OS),mingw32)
else
JS_IMPORT_LIBRARY = js32ECMAv5
endif
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
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
ADDITIONAL_CFLAGS = -DWIN32 -DNEED_STRLCPY `sdl-config --cflags` -mtune=generic
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
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
ADDITIONAL_CFLAGS = -DWIN32 -DNEED_STRLCPY $(SDL_CFLAGS) -mtune=generic
# note the vpath stuff above isn't working for me, so adding src/SDL and src/Core explicitly
ADDITIONAL_OBJCFLAGS = -DLOADSAVEGUI -DWIN32 -DXP_WIN -Wno-import -std=gnu99 `sdl-config --cflags` -mtune=generic
ADDITIONAL_OBJCFLAGS = -DLOADSAVEGUI -DWIN32 -DXP_WIN -Wno-import -std=gnu99 $(SDL_OBJCFLAGS) -mtune=generic
ifneq ($(GNUSTEP_HOST_CPU),x86_64)
ADDITIONAL_LDFLAGS += -Wl,--large-address-aware
else
Expand All @@ -49,10 +61,10 @@ else
LIBJS_LIB_DIR = $(LIBJS_ROOT)/dist/lib
LIBJS = js_static

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
ADDITIONAL_OBJC_LIBS = -lGLU -lGL -lX11 -lSDL -lgnustep-base -l$(LIBJS) `nspr-config --libs` -lstdc++ -lopenal -lz -lvorbisfile
ADDITIONAL_CFLAGS = -Wall -DLINUX -DNEED_STRLCPY `sdl-config --cflags` `nspr-config --cflags`
ADDITIONAL_OBJCFLAGS = -Wall -std=gnu99 -DLOADSAVEGUI -DLINUX -DXP_UNIX -Wno-import `sdl-config --cflags` `nspr-config --cflags`
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
ADDITIONAL_OBJC_LIBS = -lGLU -lGL -lX11 $(SDL_OBJC_LIBS) -lgnustep-base -l$(LIBJS) `nspr-config --libs` -lstdc++ -lopenal -lz -lvorbisfile
ADDITIONAL_CFLAGS = -Wall -DLINUX -DNEED_STRLCPY $(SDL_CFLAGS) `nspr-config --cflags`
ADDITIONAL_OBJCFLAGS = -Wall -std=gnu99 -DLOADSAVEGUI -DLINUX -DXP_UNIX -Wno-import $(SDL_OBJCFLAGS) `nspr-config --cflags`
oolite_LIB_DIRS += -L$(LIBJS_LIB_DIR) -L/usr/X11R6/lib/

ifeq ($(use_deps),yes)
Expand Down
1 change: 1 addition & 0 deletions config.make
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ OO_LOCALIZATION_TOOLS = yes
DEBUG_GRAPHVIZ = yes
OO_JAVASCRIPT_TRACE = yes
OO_FOV_INFLIGHT_CONTROL_ENABLED = no
OO_SDL2_ENABLED = no
1 change: 0 additions & 1 deletion src/Core/OOJoystickManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ enum {
//SDL Abstracted constants

#if OOLITE_SDL

#import <SDL.h>

enum
Expand Down
4 changes: 4 additions & 0 deletions src/Core/OOOpenGLOnly.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ MA 02110-1301, USA.
// the standard SDL_opengl.h
#include <SDL_opengl.h>

#if OO_ENABLE_SDL2
#include <GL/glu.h>
#endif

// include an up-to-date version of glext.h
#include <GL/glext.h>

Expand Down
5 changes: 3 additions & 2 deletions src/SDL2/MyOpenGLView.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ extern int debug;

// Windowed mode
NSSize currentWindowSize;
SDL_Surface *surface;
SDL_Window *mainWindow;
SDL_GLContext *glContext;

BOOL showSplashScreen;

Expand All @@ -176,7 +177,7 @@ extern int debug;
BOOL updateContext;
BOOL saveSize;
unsigned keyboardMap;
HWND SDL_Window;
HWND Main_Window;
MONITORINFOEX monitorInfo;
RECT lastGoodRect;

Expand Down
Loading

0 comments on commit 8f7bb2f

Please sign in to comment.