Skip to content

Commit

Permalink
Merge pull request #227 from q4a/xd_dev_sdl2
Browse files Browse the repository at this point in the history
SDL2 support
  • Loading branch information
Xottab-DUTY authored Aug 5, 2018
2 parents 6f3a74a + c6bbc9c commit b9026bf
Show file tree
Hide file tree
Showing 185 changed files with 3,036 additions and 2,431 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ os:
- linux
before_script:
- g++ --version
- sudo apt-get install libegl1-mesa-dev libgles2-mesa-dev libpugixml-dev libopenal-dev libtbb-dev libcrypto++-dev
- sudo apt-get install libegl1-mesa-dev libgles2-mesa-dev libpugixml-dev libopenal-dev libtbb-dev libcrypto++-dev liblockfile-dev libfreeimage-dev
- sudo apt-get install cmake lua5.1-dev libssl-dev libogg-dev libtheora-dev libvorbis-dev libsdl2-dev liblzo2-dev libjpeg-dev libncurses5-dev
- mkdir bin
- cd bin
Expand Down
8 changes: 7 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ configuration:
platform:
- x64
- x86
cache:
- packages -> **\packages.config
before_build:
- cmd: git submodule update --init --recursive
- cmd: >-
nuget restore src\engine.sln
git submodule update --init --recursive
build:
project: src/engine.sln
parallel: true
Expand Down
1 change: 1 addition & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# exclude binaries and temporary files
ipch/
packages/

# User-specific files
*.suo
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ add_subdirectory(Layers)
add_subdirectory(xrAICore)
add_subdirectory(xrCDB)
add_subdirectory(xrCore)
#add_subdirectory(xrEngine)
add_subdirectory(xrEngine)
#add_subdirectory(xrGame)
#add_subdirectory(xrNetServer)
add_subdirectory(xrParticles)
Expand Down
8 changes: 8 additions & 0 deletions src/Common/Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@
#include "Common/CommonImportExport.inl"
#include "Common/FSMacros.hpp"
#include "Include/xrAPI/xrAPI.h"

#if __has_include(<SDL.h>)
#include <SDL.h>
#endif

#if __has_include(<SDL_syswm.h>)
#include <SDL_syswm.h>
#endif
109 changes: 83 additions & 26 deletions src/Common/PlatformLinux.inl
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,27 @@
#define __pragma(...) _Pragma(#__VA_ARGS__)
#define __declspec(x)
#define CALLBACK
#define TEXT(x) strdup(x)

inline char* _strlwr_l(char* str, locale_t loc)
{
//TODO
}

inline char* _strupr_l(char* str, locale_t loc)
{
//TODO
}

#define VOID void
#define HKL void*
#define ActivateKeyboardLayout(x, y) {}
#define ScreenToClient(hwnd, p) {}

#define __except(X) catch(X)

/*
static inline long InterlockedExchange(volatile long *val, long new_val)
static inline long InterlockedExchange(volatile long* val, long new_val)
{
long old_val;
do {
Expand All @@ -75,11 +91,11 @@ inline void Sleep(int ms)
}

inline void _splitpath (
const char *path, // Path Input
char *drive, // Drive : Output
char *dir, // Directory : Output
char *fname, // Filename : Output
char *ext // Extension : Output
const char* path, // Path Input
char* drive, // Drive : Output
char* dir, // Directory : Output
char* fname, // Filename : Output
char* ext // Extension : Output
){}

inline unsigned long GetLastError()
Expand All @@ -94,28 +110,34 @@ inline int GetExceptionCode()

#define xr_unlink unlink

typedef char BOOL;
#include <inttypes.h>
typedef int32_t BOOL;
typedef uint8_t BYTE;
typedef uint16_t WORD;
typedef uint32_t DWORD;
typedef int32_t LONG;
#ifndef _LIBRAW_TYPES_H
typedef int64_t INT64;
typedef uint64_t UINT64;
#endif

typedef char* LPSTR;
typedef char* PSTR;
typedef char* LPTSTR;
typedef const char* LPCSTR;
typedef const char* LPCTSTR;
typedef unsigned char BYTE;
typedef unsigned char* LPBYTE;
typedef unsigned int UINT;
typedef int INT;
typedef long LONG;
typedef unsigned long ULONG;
typedef unsigned long& ULONG_PTR;
typedef long long int LARGE_INTEGER;
typedef unsigned long long int ULARGE_INTEGER;

typedef unsigned short WORD;
typedef unsigned short* LPWORD;
typedef unsigned long DWORD;
typedef unsigned long* LPDWORD;
typedef const void *LPCVOID;
typedef long long int *PLARGE_INTEGER;
typedef const void* LPCVOID;
typedef long long int* PLARGE_INTEGER;

typedef wchar_t WCHAR;

Expand All @@ -131,6 +153,28 @@ typedef struct {
WORD cbSize;
} WAVEFORMATEX, *LPWAVEFORMATEX;

typedef struct tagSTICKYKEYS
{
DWORD cbSize;
DWORD dwFlags;
} STICKYKEYS, *LPSTICKYKEYS;

typedef struct tagFILTERKEYS
{
UINT cbSize;
DWORD dwFlags;
DWORD iWaitMSec;
DWORD iDelayMSec;
DWORD iRepeatMSec;
DWORD iBounceMSec;
} FILTERKEYS, *LPFILTERKEYS;

typedef struct tagTOGGLEKEYS
{
DWORD cbSize;
DWORD dwFlags;
} TOGGLEKEYS, *LPTOGGLEKEYS;

typedef struct _EXCEPTION_POINTERS {
} EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;

Expand All @@ -145,18 +189,16 @@ typedef long LONG_PTR;
#endif // XR_X64

typedef int HANDLE;
typedef void *HMODULE;
typedef void *LPVOID;
typedef void* HMODULE;
typedef void* LPVOID;
typedef UINT_PTR WPARAM;
typedef LONG_PTR LPARAM;
typedef long HRESULT;
typedef long LRESULT;
typedef long _W64;
//typedef void *HWND;
typedef SDL_Window *HWND;
typedef void *HDC;
//typedef void *HGLRC;
typedef SDL_GLContext HGLRC;
//typedef void* HWND;
typedef SDL_Window* HWND;
typedef void* HDC;
typedef float FLOAT;
typedef unsigned char UINT8;

Expand All @@ -172,10 +214,15 @@ typedef struct tagPOINT {
long y;
} POINT, *PPOINT, *LPPOINT;

#define DWORD_PTR UINT_PTR
#define WM_USER 0x0400
#define WA_INACTIVE 0
#define HIWORD(l) ((WORD)((DWORD_PTR)(l) >> 16))
#define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xFFFF))

#define TRUE 1
#define FALSE 0

#define TRUE true
#define FALSE false
#define NONE 0
#define CONST const

Expand All @@ -196,9 +243,12 @@ typedef dirent DirEntryType;
#define strcmpi stricmp
#define lstrcpy strcpy
#define stricmp strcasecmp
#define strncpy_s(dest, size, source, num) strncpy(dest, source, num)
#define strcpy_s(dest, num, source) strcpy(dest, source)
#define strupr SDL_strupr
#define strncpy_s(dest, size, source, num) (NULL == strncpy(dest, source, num))
#define strcpy_s(dest, num, source) (NULL == strcpy(dest, source))
#define strcat_s(dest, num, source) (dest == strcat(dest, source))
#define _vsnprintf vsnprintf
#define vsprintf_s(dest, size, format, args) vsprintf(dest, format, args)
#define _alloca alloca
#define _snprintf snprintf
#define sprintf_s(buffer, buffer_size, stringbuffer, ...) sprintf(buffer, stringbuffer, ##__VA_ARGS__)
Expand Down Expand Up @@ -241,7 +291,11 @@ inline int _filelength(int fd)
#define __max(a, b) std::max(a, b)
#define __min(a, b) std::min(a, b)

#define xr_itoa SDL_itoa
#define itoa SDL_itoa
#define _itoa_s(value, buffer, radix) SDL_itoa(value, buffer, radix)
#define _locale_t locale_t
#define _isalpha_l isalpha_l
#define _create_locale(category, arg) newlocale(category, arg, (locale_t) 0)

#define ZeroMemory(p, sz) memset((p), 0, (sz))
#define CopyMemory(d, s, n) memcpy(d, s, n)
Expand All @@ -256,4 +310,7 @@ inline int _filelength(int fd)
#define _MAX_DRIVE 3
#define _MAX_DIR 256
#define _MAX_FNAME 256
#define _MAX_EXT 256
#define _MAX_EXT 256

#define SEM_FAILCRITICALERRORS 1
#define SetErrorMode(x) {}
1 change: 0 additions & 1 deletion src/Common/PlatformWindows.inl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define IDIRECTPLAY2_OR_GREATER // ?
#define DIRECTINPUT_VERSION 0x0800 //

#ifndef _WIN32_WINNT
// Request Windows 7 functionality
Expand Down
1 change: 1 addition & 0 deletions src/Include/editor/engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class engine_base
virtual void pause(bool const& value) = 0;
virtual void capture_input(bool const& value) = 0;
virtual void disconnect() = 0;
virtual bool quit_requested() const = 0;
// shared_str support
virtual void value(LPCSTR value, shared_str& result) = 0;
virtual LPCSTR value(shared_str const& value) = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRender/D3DXRenderBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ class D3DXRenderBase : public IRender, public pureFrame
virtual void OnDeviceDestroy(bool bKeepTextures) override;
virtual void ValidateHW() override;
virtual void DestroyHW() override;
virtual void Reset(HWND hWnd, u32& dwWidth, u32& dwHeight, float& fWidth_2, float& fHeight_2) override;
virtual void Reset(SDL_Window* hWnd, u32& dwWidth, u32& dwHeight, float& fWidth_2, float& fHeight_2) override;
// Init
virtual void SetupStates() override;
virtual void OnDeviceCreate(const char* shName) override;
virtual void Create(HWND hWnd, u32& dwWidth, u32& dwHeight, float& fWidth_2, float& fHeight_2, bool) override;
virtual void Create(SDL_Window* hWnd, u32& dwWidth, u32& dwHeight, float& fWidth_2, float& fHeight_2) override;
virtual void SetupGPU(bool bForceGPU_SW, bool bForceGPU_NonPure, bool bForceGPU_REF) override;
// Overdraw
virtual void overdrawBegin() override;
Expand Down
Loading

0 comments on commit b9026bf

Please sign in to comment.