Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC,WIP] Initial experimental SDL2 support #234

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
121 changes: 121 additions & 0 deletions src/SDL2/Comparison.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
//
// $Id: Comparison.h,v 1.3 2004/12/12 20:17:24 will_mason Exp $
//
// vi: set ft=objc:

/*
* ObjectiveLib - a library of containers and algorithms for Objective-C
*
* Copyright (c) 2004
* Will Mason
*
* Portions:
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1997
* Moscow Center for SPARC Technology
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* You may contact the author at [email protected].
*/

#if defined(GNUSTEP)

#if !defined(__COMPARISON_OL_GUARD)
#define __COMPARISON_OL_GUARD

#include <Foundation/NSObject.h>

/**
* @category NSObject(OLComparisonMethods) Comparison.h Objectivelib/Comparison.h
*
* Comparison methods used in @ref Functors "function objects". These comparison
* methods are only required to be included when GNUstep is the platform, as
* Cocoa already defines them. Under Cocoa they are declared in the
* intuitively-named file @c NSScriptWhoseTests.h. All of these methods send
* the message @c compare: to the receiving object.
*
* @pre The receiving object must implement the method @c compare:.
*/
@interface NSObject (OLComparisonMethods)

/**
* Return whether another object is equal to this one. This message returns YES if
* and only if the message @c compare: returns @c NSOrderedSame.
*
* @param object the object to which to compare this one
* @return YES if @a object is equal to this one, NO otherwise
*/
- (BOOL) isEqualTo: (id)object;

/**
* Return whether this object is greater than another one. This message returns
* YES if and only if @c compare: returns @c NSOrderedDescending.
*
* @param object the object to which to compare this one
* @return YES if this object is greater than @a object, NO otherwise
*/
- (BOOL) isGreaterThan: (id)object;

/**
* Return whether this object is greater than or equal to another one. This message returns
* YES if and only if @c compare: does not return @c NSOrderedAscending.
*
* @param object the object to which to compare this one
* @return YES if this object is greater than or equal to @a object, NO otherwise
*/
- (BOOL) isGreaterThanOrEqualTo: (id)object;

/**
* Return whether this object is less than another one. This message returns
* YES if and only if @c compare: returns @c NSOrderedAscending.
*
* @param object the object to which to compare this one
* @return YES if this object is less than @a object, NO otherwise
*/
- (BOOL) isLessThan: (id)object;

/**
* Return whether this object is less than or equal to another one. This message returns
* YES if and only if @c compare: does not return @c NSOrderedDescending.
*
* @param object the object to which to compare this one
* @return YES if this object is less than or equal to @a object, NO otherwise
*/
- (BOOL) isLessThanOrEqualTo: (id)object;

/**
* Return whether another object is not equal to this one. This message returns YES if
* and only if the message @c compare: does not return @c NSOrderedSame.
*
* @param object the object to which to compare this one
* @return YES if @a object is not equal to this one, NO otherwise
*/
- (BOOL) isNotEqualTo: (id)object;

@end

#endif

#endif
88 changes: 88 additions & 0 deletions src/SDL2/Comparison.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
//
// $Id: Comparison.m,v 1.3 2004/11/29 23:35:50 will_mason Exp $
//
// vi: set ft=objc:

/*
* ObjectiveLib - a library of containers and algorithms for Objective-C
*
* Copyright (c) 2004
* Will Mason
*
* Portions:
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1997
* Moscow Center for SPARC Technology
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* You may contact the author at [email protected].
*/

#if defined(GNUSTEP)

#include "Comparison.h"
#include <Foundation/NSString.h>

@implementation NSObject (OLComparison)

- (BOOL) isEqualTo: (id)object
{
return (object != nil && [self compare: object] == NSOrderedSame) ?
YES : NO;
}

- (BOOL) isGreaterThan: (id)object
{
return (object != nil && [self compare: object] == NSOrderedDescending) ?
YES : NO;
}

- (BOOL) isGreaterThanOrEqualTo: (id)object
{
return (object != nil && [self compare: object] != NSOrderedAscending) ?
YES : NO;
}

- (BOOL) isLessThan: (id)object
{
return (object != nil && [self compare: object] == NSOrderedAscending) ?
YES : NO;
}

- (BOOL) isLessThanOrEqualTo: (id)object
{
return (object != nil && [self compare: object] != NSOrderedDescending) ?
YES : NO;
}

- (BOOL) isNotEqualTo: (id)object
{
return (object != nil && [self compare: object] != NSOrderedSame) ?
YES : NO;
}

@end

#endif
Loading