Skip to content

Commit 8510ebf

Browse files
committed
Add iOSDevice and EAGLManager
1 parent c7308b8 commit 8510ebf

20 files changed

+1516
-196
lines changed

CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ if (IOS)
4747
ADD_DEFINITIONS(-DMOBILE_STK)
4848
ADD_DEFINITIONS(-DIOS_STK)
4949
option(USE_GLES2 "Use OpenGL ES2 renderer" ON)
50+
set(MACOSX_BUNDLE_ICON_FILE ${PROJECT_SOURCE_DIR}/data/supertuxkart.icns)
51+
set(MACOSX_BUNDLE_BUNDLE_NAME "SuperTuxKart")
52+
set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.supertuxkart.stk")
53+
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}")
54+
set(MACOSX_BUNDLE_BUNDLE_VERSION ${IOS_BUILD_VERSION})
5055
endif()
5156

5257
if((UNIX AND NOT APPLE) AND NOT SERVER_ONLY)
@@ -485,7 +490,13 @@ else()
485490
endif()
486491

487492
# Build the final executable
488-
add_executable(supertuxkart ${STK_SOURCES} ${STK_RESOURCES} ${STK_HEADERS})
493+
if (IOS)
494+
file(GLOB IOS_ASSETS_FILES ${IOS_ASSETS})
495+
set_source_files_properties(${IOS_ASSETS_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
496+
add_executable(supertuxkart ${STK_SOURCES} ${STK_RESOURCES} ${STK_HEADERS} ${IOS_ASSETS_FILES})
497+
else()
498+
add_executable(supertuxkart ${STK_SOURCES} ${STK_RESOURCES} ${STK_HEADERS})
499+
endif()
489500
target_link_libraries(supertuxkart ${PTHREAD_LIBRARY})
490501
endif()
491502

@@ -554,6 +565,8 @@ endif()
554565
if(NOT SERVER_ONLY)
555566
if(NOT USE_GLES2)
556567
target_link_libraries(supertuxkart ${OPENGL_gl_LIBRARY} ${GLEW_LIBRARIES})
568+
elseif (IOS)
569+
target_link_libraries(supertuxkart "-framework OpenGLES -framework UIKit -framework CoreMotion -framework Foundation -framework QuartzCore")
557570
else()
558571
target_link_libraries(supertuxkart GLESv2)
559572
endif()

lib/irrlicht/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,20 @@ if(APPLE AND NOT IOS)
604604
set_source_files_properties(source/Irrlicht/MacOSX/OSXClipboard.mm PROPERTIES LANGUAGE C)
605605
endif()
606606

607+
if(IOS)
608+
set(IRRLICHT_SOURCES
609+
${IRRLICHT_SOURCES}
610+
source/Irrlicht/CEAGLManager.mm
611+
source/Irrlicht/CIrrDeviceiOS.mm)
612+
613+
set_source_files_properties(source/Irrlicht/CEAGLManager.mm PROPERTIES COMPILE_FLAGS "-x objective-c++ -O3 -fno-rtti")
614+
set_source_files_properties(source/Irrlicht/CEAGLManager.mm PROPERTIES LANGUAGE C)
615+
616+
set_source_files_properties(source/Irrlicht/CIrrDeviceiOS.mm PROPERTIES COMPILE_FLAGS "-x objective-c++ -O3 -fno-rtti")
617+
set_source_files_properties(source/Irrlicht/CIrrDeviceiOS.mm PROPERTIES LANGUAGE C)
618+
endif()
619+
620+
607621
add_library(stkirrlicht STATIC ${IRRLICHT_SOURCES})
608622

609623
target_link_libraries(stkirrlicht ${ZLIB_LIBRARY})

lib/irrlicht/include/EDeviceTypes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ namespace irr
3232
/** This device uses Apple's Cocoa API and works in Mac OSX 10.2 and above. */
3333
EIDT_OSX,
3434

35-
//! A device native to the IPhone/IPod touch
35+
//! A device native to the iOS
3636
/** This device should be used with the OpenGL-ES driver. */
37-
EIDT_IPHONE,
37+
EIDT_IOS,
3838

3939
//! A device which uses Simple DirectMedia Layer
4040
/** The SDL device works under all platforms supported by SDL but first must be compiled
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright (C) 2013-2015 Patryk Nadrowski
2+
// This file is part of the "Irrlicht Engine".
3+
// For conditions of distribution and use, see copyright notice in irrlicht.h
4+
5+
#ifndef __IRR_I_CONTEXT_MANAGER_H_INCLUDED__
6+
#define __IRR_I_CONTEXT_MANAGER_H_INCLUDED__
7+
8+
#include "SExposedVideoData.h"
9+
#include "SIrrCreationParameters.h"
10+
11+
namespace irr
12+
{
13+
namespace video
14+
{
15+
// For system specific window contexts (used for OpenGL)
16+
class IContextManager : public virtual IReferenceCounted
17+
{
18+
public:
19+
//! Initialize manager with device creation parameters and device window (passed as exposed video data)
20+
virtual bool initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& data) =0;
21+
22+
//! Terminate manager, any cleanup that is left over. Manager needs a new initialize to be usable again
23+
virtual void terminate() =0;
24+
25+
//! Create surface based on current window set
26+
virtual bool generateSurface() =0;
27+
28+
//! Destroy current surface
29+
virtual void destroySurface() =0;
30+
31+
//! Create context based on current surface
32+
virtual bool generateContext() =0;
33+
34+
//! Destroy current context
35+
virtual void destroyContext() =0;
36+
37+
//! Get current context
38+
virtual const SExposedVideoData& getContext() const =0;
39+
40+
//! Change render context, disable old and activate new defined by videoData
41+
virtual bool activateContext(const SExposedVideoData& videoData) =0;
42+
43+
//! Swap buffers.
44+
virtual bool swapBuffers() =0;
45+
};
46+
47+
} // end namespace video
48+
} // end namespace irr
49+
50+
51+
#endif

lib/irrlicht/include/IrrCompileConfig.h

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
//! _IRR_LINUX_PLATFORM_ for Linux (it is defined here if no other os is defined)
2525
//! _IRR_SOLARIS_PLATFORM_ for Solaris
2626
//! _IRR_OSX_PLATFORM_ for Apple systems running OSX
27-
//! _IRR_IPHONE_PLATFORM_ for Apple devices running iOS
27+
//! _IRR_IOS_PLATFORM_ for Apple devices running iOS
2828
//! _IRR_ANDROID_PLATFORM_ for devices running Android
2929
//! _IRR_POSIX_API_ for Posix compatible systems
3030
//! Note: PLATFORM defines the OS specific layer, API can group several platforms
@@ -66,14 +66,14 @@
6666

6767
// XBox only suppots the native Window stuff
6868
#if defined(_XBOX)
69-
#undef _IRR_WINDOWS_
70-
#define _IRR_XBOX_PLATFORM_
71-
#define _IRR_WINDOWS_API_
72-
//#define _IRR_COMPILE_WITH_WINDOWS_DEVICE_
73-
#undef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
74-
//#define _IRR_COMPILE_WITH_SDL_DEVICE_
69+
#undef _IRR_WINDOWS_
70+
#define _IRR_XBOX_PLATFORM_
71+
#define _IRR_WINDOWS_API_
72+
//#define _IRR_COMPILE_WITH_WINDOWS_DEVICE_
73+
#undef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
74+
//#define _IRR_COMPILE_WITH_SDL_DEVICE_
7575

76-
#include <xtl.h>
76+
#include <xtl.h>
7777
#endif
7878

7979
#if defined(__APPLE__) || defined(MACOSX)
@@ -83,8 +83,8 @@
8383
#define _IRR_OSX_PLATFORM_ // we only support OSX on these systems
8484

8585
#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) || defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
86-
#define _IRR_IPHONE_PLATFORM_
87-
#define _IRR_COMPILE_WITH_IPHONE_DEVICE_
86+
#define _IRR_IOS_PLATFORM_
87+
#define _IRR_COMPILE_WITH_IOS_DEVICE_
8888
#define _IRR_COMPILE_WITH_OGLES2_
8989
#else
9090
#define _IRR_COMPILE_WITH_OSX_DEVICE_
@@ -107,7 +107,7 @@
107107
#define _IRR_COMPILE_ANDROID_ASSET_READER_
108108
#endif
109109

110-
#if defined(_IRR_COMPILE_WITH_OGLES2_) && !defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
110+
#if defined(_IRR_COMPILE_WITH_OGLES2_) && !defined(_IRR_COMPILE_WITH_IOS_DEVICE_)
111111
#define _IRR_COMPILE_WITH_EGL_
112112
#endif
113113

@@ -172,7 +172,7 @@ If not defined, Windows Multimedia library is used, which offers also broad supp
172172
//! Define _IRR_COMPILE_WITH_OPENGL_ to compile the Irrlicht engine with OpenGL.
173173
/** If you do not wish the engine to be compiled with OpenGL, comment this
174174
define out. */
175-
#if !defined(_IRR_IPHONE_PLATFORM_) && !defined(_IRR_ANDROID_PLATFORM_)
175+
#if !defined(_IRR_IOS_PLATFORM_) && !defined(_IRR_ANDROID_PLATFORM_)
176176
#define _IRR_COMPILE_WITH_OPENGL_
177177
#endif
178178
#ifdef NO_IRR_COMPILE_WITH_OPENGL_
@@ -191,7 +191,7 @@ define out. */
191191
#undef _IRR_COMPILE_WITH_OGLES2_
192192
#endif
193193
#ifndef IRR_OGLES2_SHADER_PATH
194-
#ifdef _IRR_COMPILE_WITH_IPHONE_DEVICE_
194+
#ifdef _IRR_COMPILE_WITH_IOS_DEVICE_
195195
#define IRR_OGLES2_SHADER_PATH ""
196196
#elif defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
197197
#define IRR_OGLES2_SHADER_PATH "media/Shaders/"
@@ -211,7 +211,7 @@ define out. */
211211

212212
//! Define _IRR_OPENGL_USE_EXTPOINTER_ if the OpenGL renderer should use OpenGL extensions via function pointers.
213213
/** On some systems there is no support for the dynamic extension of OpenGL
214-
via function pointers such that this has to be undef'ed. */
214+
via function pointers such that this has to be undef'ed. */
215215
#ifdef _IRR_COMPILE_WITH_OPENGL_
216216
#if !defined(_IRR_OSX_PLATFORM_) && !defined(_IRR_SOLARIS_PLATFORM_)
217217
#define _IRR_OPENGL_USE_EXTPOINTER_
@@ -223,7 +223,7 @@ define out. */
223223
architecture. You can simply uncomment the define and recompile.
224224
*/
225225
#ifdef _IRR_COMPILE_WITH_OGLES2_
226-
#if !defined(_IRR_IPHONE_PLATFORM_)
226+
#if !defined(_IRR_IOS_PLATFORM_)
227227
#define _IRR_OGLES2_USE_EXTPOINTER_
228228
#endif
229229
#endif
@@ -283,7 +283,7 @@ the engine will no longer read .jpeg images. */
283283

284284
//! Define _IRR_USE_NON_SYSTEM_JPEG_LIB_ to let irrlicht use the jpeglib which comes with irrlicht.
285285
/** If this is commented out, Irrlicht will try to compile using the jpeg lib installed in the system.
286-
This is only used when _IRR_COMPILE_WITH_LIBJPEG_ is defined. */
286+
This is only used when _IRR_COMPILE_WITH_LIBJPEG_ is defined. */
287287
//#define _IRR_USE_NON_SYSTEM_JPEG_LIB_
288288
#ifdef NO_IRR_USE_NON_SYSTEM_JPEG_LIB_
289289
#undef _IRR_USE_NON_SYSTEM_JPEG_LIB_
@@ -299,7 +299,7 @@ the engine will no longer read .png images. */
299299

300300
//! Define _IRR_USE_NON_SYSTEM_LIBPNG_ to let irrlicht use the libpng which comes with irrlicht.
301301
/** If this is commented out, Irrlicht will try to compile using the libpng installed in the system.
302-
This is only used when _IRR_COMPILE_WITH_LIBPNG_ is defined. */
302+
This is only used when _IRR_COMPILE_WITH_LIBPNG_ is defined. */
303303
//#define _IRR_USE_NON_SYSTEM_LIB_PNG_
304304
#ifdef NO_IRR_USE_NON_SYSTEM_LIB_PNG_
305305
#undef _IRR_USE_NON_SYSTEM_LIB_PNG_
@@ -327,7 +327,7 @@ B3D, MS3D or X meshes */
327327
#ifdef NO_IRR_COMPILE_WITH_B3D_LOADER_
328328
#undef _IRR_COMPILE_WITH_B3D_LOADER_
329329
#endif
330-
#endif // _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_
330+
#endif // _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_
331331

332332
//! Define _IRR_COMPILE_WITH_BMP_LOADER_ if you want to load .bmp files
333333
//! Disabling this loader will also disable the built-in font
@@ -408,10 +408,10 @@ defined. */
408408
precision will be lower but speed higher. currently X86 only
409409
*/
410410
#if !defined(_IRR_OSX_PLATFORM_) && !defined(_IRR_SOLARIS_PLATFORM_)
411-
//#define IRRLICHT_FAST_MATH
412-
#ifdef NO_IRRLICHT_FAST_MATH
413-
#undef IRRLICHT_FAST_MATH
414-
#endif
411+
//#define IRRLICHT_FAST_MATH
412+
#ifdef NO_IRRLICHT_FAST_MATH
413+
#undef IRRLICHT_FAST_MATH
414+
#endif
415415
#endif
416416

417417
// Some cleanup and standard stuff
@@ -462,15 +462,15 @@ precision will be lower but speed higher. currently X86 only
462462
#endif
463463

464464
#ifndef _IRR_WINDOWS_API_
465-
#undef _IRR_WCHAR_FILESYSTEM
465+
#undef _IRR_WCHAR_FILESYSTEM
466466
#endif
467467

468468
#if defined(__sparc__) || defined(__sun__)
469469
#define __BIG_ENDIAN__
470470
#endif
471471

472472
#if defined(_IRR_SOLARIS_PLATFORM_)
473-
#undef _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
473+
#undef _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
474474
#endif
475475

476476
//! Define __IRR_HAS_S64 if the irr::s64 type should be enable (needs long long, available on most platforms, but not part of ISO C++ 98)

0 commit comments

Comments
 (0)