Skip to content

Commit b9026bf

Browse files
authored
Merge pull request #227 from q4a/xd_dev_sdl2
SDL2 support
2 parents 6f3a74a + c6bbc9c commit b9026bf

File tree

185 files changed

+3036
-2431
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+3036
-2431
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ os:
99
- linux
1010
before_script:
1111
- g++ --version
12-
- sudo apt-get install libegl1-mesa-dev libgles2-mesa-dev libpugixml-dev libopenal-dev libtbb-dev libcrypto++-dev
12+
- sudo apt-get install libegl1-mesa-dev libgles2-mesa-dev libpugixml-dev libopenal-dev libtbb-dev libcrypto++-dev liblockfile-dev libfreeimage-dev
1313
- sudo apt-get install cmake lua5.1-dev libssl-dev libogg-dev libtheora-dev libvorbis-dev libsdl2-dev liblzo2-dev libjpeg-dev libncurses5-dev
1414
- mkdir bin
1515
- cd bin

appveyor.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@ configuration:
1212
platform:
1313
- x64
1414
- x86
15+
cache:
16+
- packages -> **\packages.config
1517
before_build:
16-
- cmd: git submodule update --init --recursive
18+
- cmd: >-
19+
nuget restore src\engine.sln
20+
21+
git submodule update --init --recursive
22+
1723
build:
1824
project: src/engine.sln
1925
parallel: true

src/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# exclude binaries and temporary files
22
ipch/
3+
packages/
34

45
# User-specific files
56
*.suo

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ add_subdirectory(Layers)
55
add_subdirectory(xrAICore)
66
add_subdirectory(xrCDB)
77
add_subdirectory(xrCore)
8-
#add_subdirectory(xrEngine)
8+
add_subdirectory(xrEngine)
99
#add_subdirectory(xrGame)
1010
#add_subdirectory(xrNetServer)
1111
add_subdirectory(xrParticles)

src/Common/Common.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@
55
#include "Common/CommonImportExport.inl"
66
#include "Common/FSMacros.hpp"
77
#include "Include/xrAPI/xrAPI.h"
8+
9+
#if __has_include(<SDL.h>)
10+
#include <SDL.h>
11+
#endif
12+
13+
#if __has_include(<SDL_syswm.h>)
14+
#include <SDL_syswm.h>
15+
#endif

src/Common/PlatformLinux.inl

Lines changed: 83 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,27 @@
5050
#define __pragma(...) _Pragma(#__VA_ARGS__)
5151
#define __declspec(x)
5252
#define CALLBACK
53+
#define TEXT(x) strdup(x)
54+
55+
inline char* _strlwr_l(char* str, locale_t loc)
56+
{
57+
//TODO
58+
}
59+
60+
inline char* _strupr_l(char* str, locale_t loc)
61+
{
62+
//TODO
63+
}
64+
65+
#define VOID void
66+
#define HKL void*
67+
#define ActivateKeyboardLayout(x, y) {}
68+
#define ScreenToClient(hwnd, p) {}
5369

5470
#define __except(X) catch(X)
5571

5672
/*
57-
static inline long InterlockedExchange(volatile long *val, long new_val)
73+
static inline long InterlockedExchange(volatile long* val, long new_val)
5874
{
5975
long old_val;
6076
do {
@@ -75,11 +91,11 @@ inline void Sleep(int ms)
7591
}
7692

7793
inline void _splitpath (
78-
const char *path, // Path Input
79-
char *drive, // Drive : Output
80-
char *dir, // Directory : Output
81-
char *fname, // Filename : Output
82-
char *ext // Extension : Output
94+
const char* path, // Path Input
95+
char* drive, // Drive : Output
96+
char* dir, // Directory : Output
97+
char* fname, // Filename : Output
98+
char* ext // Extension : Output
8399
){}
84100

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

95111
#define xr_unlink unlink
96112

97-
typedef char BOOL;
113+
#include <inttypes.h>
114+
typedef int32_t BOOL;
115+
typedef uint8_t BYTE;
116+
typedef uint16_t WORD;
117+
typedef uint32_t DWORD;
118+
typedef int32_t LONG;
119+
#ifndef _LIBRAW_TYPES_H
120+
typedef int64_t INT64;
121+
typedef uint64_t UINT64;
122+
#endif
123+
98124
typedef char* LPSTR;
99125
typedef char* PSTR;
100126
typedef char* LPTSTR;
101127
typedef const char* LPCSTR;
102128
typedef const char* LPCTSTR;
103-
typedef unsigned char BYTE;
104129
typedef unsigned char* LPBYTE;
105130
typedef unsigned int UINT;
106131
typedef int INT;
107-
typedef long LONG;
108132
typedef unsigned long ULONG;
109133
typedef unsigned long& ULONG_PTR;
110134
typedef long long int LARGE_INTEGER;
111135
typedef unsigned long long int ULARGE_INTEGER;
112136

113-
typedef unsigned short WORD;
114137
typedef unsigned short* LPWORD;
115-
typedef unsigned long DWORD;
116138
typedef unsigned long* LPDWORD;
117-
typedef const void *LPCVOID;
118-
typedef long long int *PLARGE_INTEGER;
139+
typedef const void* LPCVOID;
140+
typedef long long int* PLARGE_INTEGER;
119141

120142
typedef wchar_t WCHAR;
121143

@@ -131,6 +153,28 @@ typedef struct {
131153
WORD cbSize;
132154
} WAVEFORMATEX, *LPWAVEFORMATEX;
133155

156+
typedef struct tagSTICKYKEYS
157+
{
158+
DWORD cbSize;
159+
DWORD dwFlags;
160+
} STICKYKEYS, *LPSTICKYKEYS;
161+
162+
typedef struct tagFILTERKEYS
163+
{
164+
UINT cbSize;
165+
DWORD dwFlags;
166+
DWORD iWaitMSec;
167+
DWORD iDelayMSec;
168+
DWORD iRepeatMSec;
169+
DWORD iBounceMSec;
170+
} FILTERKEYS, *LPFILTERKEYS;
171+
172+
typedef struct tagTOGGLEKEYS
173+
{
174+
DWORD cbSize;
175+
DWORD dwFlags;
176+
} TOGGLEKEYS, *LPTOGGLEKEYS;
177+
134178
typedef struct _EXCEPTION_POINTERS {
135179
} EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
136180

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

147191
typedef int HANDLE;
148-
typedef void *HMODULE;
149-
typedef void *LPVOID;
192+
typedef void* HMODULE;
193+
typedef void* LPVOID;
150194
typedef UINT_PTR WPARAM;
151195
typedef LONG_PTR LPARAM;
152196
typedef long HRESULT;
153197
typedef long LRESULT;
154198
typedef long _W64;
155-
//typedef void *HWND;
156-
typedef SDL_Window *HWND;
157-
typedef void *HDC;
158-
//typedef void *HGLRC;
159-
typedef SDL_GLContext HGLRC;
199+
//typedef void* HWND;
200+
typedef SDL_Window* HWND;
201+
typedef void* HDC;
160202
typedef float FLOAT;
161203
typedef unsigned char UINT8;
162204

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

217+
#define DWORD_PTR UINT_PTR
175218
#define WM_USER 0x0400
219+
#define WA_INACTIVE 0
220+
#define HIWORD(l) ((WORD)((DWORD_PTR)(l) >> 16))
221+
#define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xFFFF))
176222

177-
#define TRUE 1
178-
#define FALSE 0
223+
224+
#define TRUE true
225+
#define FALSE false
179226
#define NONE 0
180227
#define CONST const
181228

@@ -196,9 +243,12 @@ typedef dirent DirEntryType;
196243
#define strcmpi stricmp
197244
#define lstrcpy strcpy
198245
#define stricmp strcasecmp
199-
#define strncpy_s(dest, size, source, num) strncpy(dest, source, num)
200-
#define strcpy_s(dest, num, source) strcpy(dest, source)
246+
#define strupr SDL_strupr
247+
#define strncpy_s(dest, size, source, num) (NULL == strncpy(dest, source, num))
248+
#define strcpy_s(dest, num, source) (NULL == strcpy(dest, source))
249+
#define strcat_s(dest, num, source) (dest == strcat(dest, source))
201250
#define _vsnprintf vsnprintf
251+
#define vsprintf_s(dest, size, format, args) vsprintf(dest, format, args)
202252
#define _alloca alloca
203253
#define _snprintf snprintf
204254
#define sprintf_s(buffer, buffer_size, stringbuffer, ...) sprintf(buffer, stringbuffer, ##__VA_ARGS__)
@@ -241,7 +291,11 @@ inline int _filelength(int fd)
241291
#define __max(a, b) std::max(a, b)
242292
#define __min(a, b) std::min(a, b)
243293

244-
#define xr_itoa SDL_itoa
294+
#define itoa SDL_itoa
295+
#define _itoa_s(value, buffer, radix) SDL_itoa(value, buffer, radix)
296+
#define _locale_t locale_t
297+
#define _isalpha_l isalpha_l
298+
#define _create_locale(category, arg) newlocale(category, arg, (locale_t) 0)
245299

246300
#define ZeroMemory(p, sz) memset((p), 0, (sz))
247301
#define CopyMemory(d, s, n) memcpy(d, s, n)
@@ -256,4 +310,7 @@ inline int _filelength(int fd)
256310
#define _MAX_DRIVE 3
257311
#define _MAX_DIR 256
258312
#define _MAX_FNAME 256
259-
#define _MAX_EXT 256
313+
#define _MAX_EXT 256
314+
315+
#define SEM_FAILCRITICALERRORS 1
316+
#define SetErrorMode(x) {}

src/Common/PlatformWindows.inl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
22
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
33
#define IDIRECTPLAY2_OR_GREATER // ?
4-
#define DIRECTINPUT_VERSION 0x0800 //
54

65
#ifndef _WIN32_WINNT
76
// Request Windows 7 functionality

src/Include/editor/engine.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class engine_base
2525
virtual void pause(bool const& value) = 0;
2626
virtual void capture_input(bool const& value) = 0;
2727
virtual void disconnect() = 0;
28+
virtual bool quit_requested() const = 0;
2829
// shared_str support
2930
virtual void value(LPCSTR value, shared_str& result) = 0;
3031
virtual LPCSTR value(shared_str const& value) = 0;

src/Layers/xrRender/D3DXRenderBase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,11 @@ class D3DXRenderBase : public IRender, public pureFrame
186186
virtual void OnDeviceDestroy(bool bKeepTextures) override;
187187
virtual void ValidateHW() override;
188188
virtual void DestroyHW() override;
189-
virtual void Reset(HWND hWnd, u32& dwWidth, u32& dwHeight, float& fWidth_2, float& fHeight_2) override;
189+
virtual void Reset(SDL_Window* hWnd, u32& dwWidth, u32& dwHeight, float& fWidth_2, float& fHeight_2) override;
190190
// Init
191191
virtual void SetupStates() override;
192192
virtual void OnDeviceCreate(const char* shName) override;
193-
virtual void Create(HWND hWnd, u32& dwWidth, u32& dwHeight, float& fWidth_2, float& fHeight_2, bool) override;
193+
virtual void Create(SDL_Window* hWnd, u32& dwWidth, u32& dwHeight, float& fWidth_2, float& fHeight_2) override;
194194
virtual void SetupGPU(bool bForceGPU_SW, bool bForceGPU_NonPure, bool bForceGPU_REF) override;
195195
// Overdraw
196196
virtual void overdrawBegin() override;

0 commit comments

Comments
 (0)