- name: Build
run: |
- sed '/#define _IRR_COMPILE_WITH_OGLES2_/ s|^//||g' -i include/IrrCompileConfig.h
- sed '/#define _IRR_COMPILE_WITH_OPENGL_/ s|^|//|g' -i include/IrrCompileConfig.h
- cmake . -DBUILD_EXAMPLES=1
+ cmake . -DBUILD_EXAMPLES=1 -DENABLE_OPENGL=OFF -DENABLE_GLES2=ON
make -j2
- name: Test (headless)
- name: Test (Xvfb)
run: |
cd bin/Linux
- LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest
+ LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest ogles2
linux-sdl:
runs-on: ubuntu-latest
- name: Build
run: |
- sed '/#define _IRR_COMPILE_WITH_SDL_DEVICE_/ s|^//||g' -i include/IrrCompileConfig.h
- cmake . -DBUILD_EXAMPLES=1
+ cmake . -DBUILD_EXAMPLES=1 -DUSE_SDL2=ON
make -j2
- name: Test (headless)
void test_irr_array();\r
void test_irr_string();\r
\r
-static video::E_DRIVER_TYPE chooseDriver(const char *arg_)\r
+static video::E_DRIVER_TYPE chooseDriver(core::stringc arg_)\r
{\r
- if (core::stringc(arg_) == "null")\r
+ if (arg_ == "null")\r
return video::EDT_NULL;\r
-\r
- if (IrrlichtDevice::isDriverSupported(video::EDT_OGLES1))\r
+ if (arg_ == "ogles1")\r
return video::EDT_OGLES1;\r
- if (IrrlichtDevice::isDriverSupported(video::EDT_OGLES2))\r
+ if (arg_ == "ogles2")\r
return video::EDT_OGLES2;\r
+ if (arg_ == "opengl")\r
+ return video::EDT_OPENGL;\r
+ std::cerr << "Unknown driver type: " << arg_.c_str() << ". Trying OpenGL." << std::endl;\r
return video::EDT_OPENGL;\r
}\r
\r
\r
//! A device which uses Simple DirectMedia Layer\r
/** The SDL device works under all platforms supported by SDL but first must be compiled\r
- in by defining the _IRR_COMPILE_WITH_SDL_DEVICE_ macro in IrrCompileConfig.h */\r
+ in by setting the USE_SDL2 CMake option to ON */\r
EIDT_SDL,\r
\r
//! This selection allows Irrlicht to choose the best device from the ones available.\r
/** Unlike other events, joystick events represent the result of polling\r
* each connected joystick once per run() of the device. Joystick events will\r
* not be generated by default. If joystick support is available for the\r
- * active device, _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ is defined, and\r
- * @ref irr::IrrlichtDevice::activateJoysticks() has been called, an event of\r
- * this type will be generated once per joystick per @ref IrrlichtDevice::run()\r
- * regardless of whether the state of the joystick has actually changed. */\r
+ * active device, and @ref irr::IrrlichtDevice::activateJoysticks() has been\r
+ * called, an event of this type will be generated once per joystick per\r
+ * @ref IrrlichtDevice::run() regardless of whether the state of the joystick\r
+ * has actually changed. */\r
struct SJoystickEvent\r
{\r
enum\r
\r
#include <stdio.h> // TODO: Although included elsewhere this is required at least for mingw\r
\r
-//! The defines for different operating system are:\r
-//! _IRR_WINDOWS_ for all irrlicht supported Windows versions\r
-//! _IRR_WINDOWS_API_ for Windows or XBox\r
-//! _IRR_LINUX_PLATFORM_ for Linux (it is defined here if no other os is defined)\r
-//! _IRR_SOLARIS_PLATFORM_ for Solaris\r
-//! _IRR_OSX_PLATFORM_ for Apple systems running OSX\r
-//! _IRR_IOS_PLATFORM_ for Apple devices running iOS\r
-//! _IRR_ANDROID_PLATFORM_ for devices running Android\r
-//! _IRR_POSIX_API_ for Posix compatible systems\r
-//! Note: PLATFORM defines the OS specific layer, API can group several platforms\r
-\r
-//! DEVICE is the windowing system used, several PLATFORMs support more than one DEVICE\r
-//! Irrlicht can be compiled with more than one device\r
-//! _IRR_COMPILE_WITH_WINDOWS_DEVICE_ for Windows API based device\r
-//! _IRR_COMPILE_WITH_OSX_DEVICE_ for Cocoa native windowing on OSX\r
-//! _IRR_COMPILE_WITH_X11_DEVICE_ for Linux X11 based device\r
-//! _IRR_COMPILE_WITH_SDL_DEVICE_ for platform independent SDL framework\r
-\r
-//! Passing defines to the compiler which have NO in front of the _IRR definename is an alternative\r
-//! way which can be used to disable defines (instead of outcommenting them in this header).\r
-//! So defines can be controlled from Makefiles or Projectfiles which allows building\r
-//! different library versions without having to change the sources.\r
-//! Example: NO_IRR_COMPILE_WITH_X11_ would disable X11\r
-\r
-//! Uncomment this line to compile with the SDL device\r
-//#define _IRR_COMPILE_WITH_SDL_DEVICE_\r
-#ifdef NO_IRR_COMPILE_WITH_SDL_DEVICE_\r
-#undef _IRR_COMPILE_WITH_SDL_DEVICE_\r
-#endif\r
-\r
-//! WIN32 for Windows32\r
-//! WIN64 for Windows64\r
-// The windows platform and API support SDL and WINDOW device\r
-#if defined(_WIN32) || defined(_WIN64)\r
-#define _IRR_WINDOWS_\r
-#define _IRR_WINDOWS_API_\r
-#ifndef _IRR_COMPILE_WITH_SDL_DEVICE_\r
-#define _IRR_COMPILE_WITH_WINDOWS_DEVICE_\r
-#endif\r
-#endif\r
-\r
-#if defined(__APPLE__)\r
-#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) || defined(__IPHONE_OS_VERSION_MIN_REQUIRED)\r
-#define _IRR_IOS_PLATFORM_\r
-#define _IRR_COMPILE_WITH_IOS_DEVICE_\r
-#define NO_IRR_COMPILE_WITH_OPENGL_\r
-// The application state events and following methods: IrrlichtDevice::isWindowActive, IrrlichtDevice::isWindowFocused,\r
-// IrrlichtDevice::isWindowMinimized works out of box only if you'll use built-in CIrrDelegateiOS,\r
-// so _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ must be enabled in this case. If you need a custom UIApplicationDelegate\r
-// you must disable _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ definition and handle all application events yourself.\r
-#define _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_\r
-#else\r
-#define _IRR_OSX_PLATFORM_\r
-#ifndef _IRR_COMPILE_WITH_SDL_DEVICE_\r
-#define _IRR_COMPILE_WITH_OSX_DEVICE_\r
-#endif\r
-#define NO_IRR_COMPILE_WITH_OGLES1_\r
-#define NO_IRR_COMPILE_WITH_OGLES2_\r
-#define NO_IRR_COMPILE_WITH_WEBGL1_\r
-#endif\r
-#endif\r
-\r
-#if defined(__EMSCRIPTEN__)\r
-#define _IRR_EMSCRIPTEN_PLATFORM_\r
-#define NO_IRR_COMPILE_WITH_JOYSTICK_EVENTS_\r
-#define NO_IRR_COMPILE_WITH_OPENGL_\r
-#define NO_IRR_COMPILE_WITH_OGLES1_\r
-#define _IRR_COMPILE_WITH_OGLES2_\r
-#define _IRR_COMPILE_WITH_WEBGL1_\r
-#define _IRR_COMPILE_WITH_EGL_MANAGER_\r
-#define _IRR_COMPILE_WITH_SDL_DEVICE_\r
-#define NO_IRR_COMPILE_WITH_X11_DEVICE_\r
-#define _IRR_LINUX_PLATFORM_ // emscripten basically working like a unix\r
-#endif // __EMSCRIPTEN__\r
-\r
-#if defined(__ANDROID__)\r
-#define _IRR_ANDROID_PLATFORM_\r
-#define _IRR_COMPILE_WITH_ANDROID_DEVICE_\r
-#define _IRR_COMPILE_ANDROID_ASSET_READER_\r
-#define NO_IRR_COMPILE_WITH_OPENGL_\r
-#endif\r
-\r
-#if defined(__SVR4) && defined(__sun)\r
-#define _IRR_SOLARIS_PLATFORM_\r
-#if defined(__sparc)\r
- #define __BIG_ENDIAN__\r
-#endif\r
-#endif\r
-\r
-#if !defined(_IRR_WINDOWS_API_) && !defined(_IRR_OSX_PLATFORM_) && !defined(_IRR_IOS_PLATFORM_) && !defined(_IRR_ANDROID_PLATFORM_) && !defined(_IRR_EMSCRIPTEN_PLATFORM_)\r
-#ifndef _IRR_SOLARIS_PLATFORM_\r
-#define _IRR_LINUX_PLATFORM_\r
-#endif\r
-#define _IRR_POSIX_API_\r
-#ifndef _IRR_COMPILE_WITH_SDL_DEVICE_\r
-#define _IRR_COMPILE_WITH_X11_DEVICE_\r
-#endif\r
-#endif\r
-\r
-\r
-//! Define _IRR_COMPILE_WITH_JOYSTICK_SUPPORT_ if you want joystick events.\r
-#if !(defined(__FreeBSD__) || defined(__OpenBSD__))\r
-#define _IRR_COMPILE_WITH_JOYSTICK_EVENTS_\r
-#endif\r
-#ifdef NO_IRR_COMPILE_WITH_JOYSTICK_EVENTS_\r
-#undef _IRR_COMPILE_WITH_JOYSTICK_EVENTS_\r
-#endif\r
-\r
\r
//! Maximum number of texture an SMaterial can have, up to 8 are supported by Irrlicht.\r
#define _IRR_MATERIAL_MAX_TEXTURES_ 4\r
\r
-//! Define _IRR_COMPILE_WITH_OPENGL_ to compile the Irrlicht engine with OpenGL.\r
-/** If you do not wish the engine to be compiled with OpenGL, comment this\r
-define out. */\r
-#define _IRR_COMPILE_WITH_OPENGL_\r
-#ifdef NO_IRR_COMPILE_WITH_OPENGL_\r
-#undef _IRR_COMPILE_WITH_OPENGL_\r
-#endif\r
-\r
-//! Define required options for OpenGL drivers.\r
-#if defined(_IRR_COMPILE_WITH_OPENGL_)\r
- #if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)\r
- #define _IRR_OPENGL_USE_EXTPOINTER_\r
- #define _IRR_COMPILE_WITH_WGL_MANAGER_\r
- #elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)\r
- #define _IRR_OPENGL_USE_EXTPOINTER_\r
- #define _IRR_COMPILE_WITH_GLX_MANAGER_\r
- #elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_)\r
- #define _IRR_COMPILE_WITH_NSOGL_MANAGER_\r
- #elif defined(_IRR_SOLARIS_PLATFORM_)\r
- #define _IRR_COMPILE_WITH_GLX_MANAGER_\r
- #elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_)\r
- #define _IRR_OPENGL_USE_EXTPOINTER_\r
- #endif\r
-#endif\r
-\r
-//! Define _IRR_COMPILE_WITH_OGLES1_ to compile the Irrlicht engine with OpenGL ES 1.1.\r
-/** If you do not wish the engine to be compiled with OpenGL ES 1.1, comment this\r
-define out.\r
-Depending on platform you may have to enable _IRR_OGLES1_USE_KHRONOS_API_HEADERS_ as well when using it.\r
-*/\r
-#if defined(_IRR_ANDROID_PLATFORM_) || defined(_IRR_IOS_PLATFORM_)\r
-#define _IRR_COMPILE_WITH_OGLES1_\r
-#endif\r
-#ifdef NO_IRR_COMPILE_WITH_OGLES1_\r
-#undef _IRR_COMPILE_WITH_OGLES1_\r
-#endif\r
-\r
-#ifdef _IRR_COMPILE_WITH_OGLES1_\r
-//! Define _IRR_OGLES1_USE_KHRONOS_API_HEADERS_ to use the OpenGL ES headers from the Debian Khronos-api package\r
-//#define _IRR_OGLES1_USE_KHRONOS_API_HEADERS_\r
-#endif\r
-\r
-//! Define required options for OpenGL ES 1.1 drivers.\r
-#if defined(_IRR_COMPILE_WITH_OGLES1_)\r
-#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)\r
-#define _IRR_OGLES1_USE_EXTPOINTER_\r
-#ifndef _IRR_COMPILE_WITH_EGL_MANAGER_\r
-#define _IRR_COMPILE_WITH_EGL_MANAGER_\r
-#endif\r
-#elif defined(_IRR_COMPILE_WITH_IOS_DEVICE_)\r
-#ifndef _IRR_COMPILE_WITH_EAGL_MANAGER_\r
-#define _IRR_COMPILE_WITH_EAGL_MANAGER_\r
-#endif\r
-#endif\r
-#endif\r
-\r
-//! Define _IRR_COMPILE_WITH_OGLES2_ to compile the Irrlicht engine with OpenGL ES 2.0.\r
-/** If you do not wish the engine to be compiled with OpenGL ES 2.0, comment this\r
-define out. */\r
-#if defined(_IRR_ANDROID_PLATFORM_) || defined(_IRR_IOS_PLATFORM_)\r
-#define _IRR_COMPILE_WITH_OGLES2_\r
-#else\r
-//#define _IRR_COMPILE_WITH_OGLES2_\r
-#endif\r
-#ifdef NO_IRR_COMPILE_WITH_OGLES2_\r
-#undef _IRR_COMPILE_WITH_OGLES2_\r
-#endif\r
-\r
-//! Define _IRR_COMPILE_WITH_WEBGL1_ to compile Irrlicht engine with a WebGL friendly\r
-//! subset of the OpenGL ES 2.0 driver.\r
-//#define _IRR_COMPILE_WITH_WEBGL1_\r
-#ifdef NO_IRR_COMPILE_WITH_WEBGL1_\r
-#undef _IRR_COMPILE_WITH_WEBGL1_\r
-#endif\r
-#ifdef _IRR_COMPILE_WITH_WEBGL1_\r
-#define _IRR_COMPILE_WITH_OGLES2_ // it's a subset of OGL ES2, so always needed when using WebGL\r
-#endif\r
-\r
-//! Define required options for OpenGL ES 2.0 drivers.\r
-#if defined(_IRR_COMPILE_WITH_OGLES2_)\r
-#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_) || defined(__EMSCRIPTEN__)\r
-#define _IRR_OGLES2_USE_EXTPOINTER_\r
-#ifndef _IRR_COMPILE_WITH_EGL_MANAGER_\r
-#define _IRR_COMPILE_WITH_EGL_MANAGER_\r
-#endif\r
-#elif defined(_IRR_COMPILE_WITH_IOS_DEVICE_)\r
-#ifndef _IRR_COMPILE_WITH_EAGL_MANAGER_\r
-#define _IRR_COMPILE_WITH_EAGL_MANAGER_\r
-#endif\r
-#endif\r
-#endif\r
-\r
-\r
-\r
-//! Define _IRR_COMPILE_WITH_X11_ to compile the Irrlicht engine with X11 support.\r
-/** If you do not wish the engine to be compiled with X11, comment this\r
-define out. */\r
-// Only used in LinuxDevice.\r
-#define _IRR_COMPILE_WITH_X11_\r
-#ifdef NO_IRR_COMPILE_WITH_X11_\r
-#undef _IRR_COMPILE_WITH_X11_\r
-#endif\r
-\r
-#if defined(_IRR_LINUX_PLATFORM_) && defined(_IRR_COMPILE_WITH_X11_)\r
-//! XInput2 (library called Xi) is currently only used to support touch-input.\r
-#define _IRR_LINUX_X11_XINPUT2_\r
-#ifdef NO_IRR_LINUX_X11_XINPUT2_\r
-#undef _IRR_LINUX_X11_XINPUT2_\r
-#endif\r
-\r
-//! X11 has by default only monochrome cursors, but using the Xcursor library we can also get color cursor support.\r
-//! If you have the need for custom color cursors on X11 then enable this and make sure you also link\r
-//! to the Xcursor library in your Makefile/Projectfile.\r
-//#define _IRR_LINUX_XCURSOR_\r
-#ifdef NO_IRR_LINUX_XCURSOR_\r
-#undef _IRR_LINUX_XCURSOR_\r
-#endif\r
-\r
-#endif\r
-\r
-\r
-#if defined(_IRR_SOLARIS_PLATFORM_)\r
- #undef _IRR_COMPILE_WITH_JOYSTICK_EVENTS_\r
-#endif\r
-\r
\r
#ifdef _IRR_WINDOWS_API_\r
\r
as this would consume joystick info that 3rd party libraries might rely on. Call this method to\r
activate joystick support in Irrlicht and to receive irr::SJoystickEvent events.\r
\param joystickInfo On return, this will contain an array of each joystick that was found and activated.\r
- \return true if joysticks are supported on this device and _IRR_COMPILE_WITH_JOYSTICK_EVENTS_\r
- is defined, false if joysticks are not supported or support is compiled out.\r
+ \return true if joysticks are supported on this device, false if joysticks are not\r
+ supported or support is compiled out.\r
*/\r
virtual bool activateJoysticks(core::array<SJoystickInfo>& joystickInfo) =0;\r
\r
for a configuration requested when creating the device. */\r
static bool isDriverSupported(video::E_DRIVER_TYPE driver)\r
{\r
- switch (driver)\r
- {\r
- case video::EDT_NULL:\r
- return true;\r
- case video::EDT_OPENGL:\r
-#ifdef _IRR_COMPILE_WITH_OPENGL_\r
- return true;\r
-#else\r
- return false;\r
-#endif\r
- case video::EDT_OGLES1:\r
-#ifdef _IRR_COMPILE_WITH_OGLES1_\r
- return true;\r
-#else\r
- return false;\r
-#endif\r
- case video::EDT_OGLES2:\r
-#ifdef _IRR_COMPILE_WITH_OGLES2_\r
- return true;\r
-#else\r
- return false;\r
-#endif\r
- case video::EDT_WEBGL1:\r
-#ifdef _IRR_COMPILE_WITH_WEBGL1_\r
- return true;\r
-#else\r
- return false;\r
-#endif\r
- default:\r
- return false;\r
- }\r
+ return true;\r
}\r
};\r
\r
UsePerformanceTimer(true),\r
SDK_version_do_not_use(IRRLICHT_SDK_VERSION),\r
PrivateData(0),\r
-#if defined(_IRR_COMPILE_WITH_IOS_DEVICE_) || defined(_IRR_ANDROID_PLATFORM_) || defined(_IRR_EMSCRIPTEN_PLATFORM_)\r
+#ifdef IRR_MOBILE_PATHS\r
OGLES2ShaderPath("media/Shaders/")\r
#else\r
OGLES2ShaderPath("../../media/Shaders/")\r
\r
static io::path getExampleMediaPath()\r
{\r
-#if defined (_IRR_IOS_PLATFORM_) || defined (_IRR_ANDROID_PLATFORM_) || defined (_IRR_OSX_PLATFORM_) || defined (_IRR_EMSCRIPTEN_PLATFORM_)\r
+#ifdef IRR_MOBILE_PATHS\r
return io::path("media/");\r
#else\r
return io::path("../../media/");\r
COPY_ARRAY(BOM_ENCODE_UTF8, BOM_ENCODE_UTF8_LEN);
break;
case EUTFE_UTF16:
- #ifdef __BIG_ENDIAN__
+ #if __BYTE_ORDER == __BIG_ENDIAN
COPY_ARRAY(BOM_ENCODE_UTF16_BE, BOM_ENCODE_UTF16_LEN);
#else
COPY_ARRAY(BOM_ENCODE_UTF16_LE, BOM_ENCODE_UTF16_LEN);
COPY_ARRAY(BOM_ENCODE_UTF16_LE, BOM_ENCODE_UTF16_LEN);
break;
case EUTFE_UTF32:
- #ifdef __BIG_ENDIAN__
+ #if __BYTE_ORDER == __BIG_ENDIAN
COPY_ARRAY(BOM_ENCODE_UTF32_BE, BOM_ENCODE_UTF32_LEN);
#else
COPY_ARRAY(BOM_ENCODE_UTF32_LE, BOM_ENCODE_UTF32_LEN);
option(BUILD_SHARED_LIBS "Build shared library" TRUE)
+option(USE_SDL2 "Use the SDL2 backend" FALSE)
# Compiler flags
message(FATAL_ERROR "IrrlichtMt revision number mismatches between CMake and headers.")
endif()
+# Platform-specific configuration
+
+if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+ set(SOLARIS TRUE)
+endif()
+if(APPLE AND NOT IOS)
+ set(OSX TRUE)
+endif()
+
+# Device
+
+if(WIN32)
+ add_definitions(-D_IRR_WINDOWS_ -D_IRR_WINDOWS_API_)
+ set(DEVICE "WINDOWS")
+elseif(IOS)
+ add_definitions(-D_IRR_IOS_PLATFORM_ -D_IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_)
+ if(USE_SDL2)
+ message(WARNING "SDL2 backend is not supported on iOS")
+ set(USE_SDL2 FALSE)
+ endif()
+ set(DEVICE "IOS")
+elseif(OSX)
+ add_definitions(-D_IRR_OSX_PLATFORM_)
+ set(DEVICE "OSX")
+elseif(ANDROID)
+ add_definitions(-D_IRR_ANDROID_PLATFORM_ -D_IRR_COMPILE_ANDROID_ASSET_READER_)
+ if(USE_SDL2)
+ message(WARNING "SDL2 backend is not supported on Android")
+ set(USE_SDL2 FALSE)
+ endif()
+ set(DEVICE "Android")
+elseif(EMSCRIPTEN)
+ add_definitions(-D_IRR_EMSCRIPTEN_PLATFORM_ -D_IRR_COMPILE_WITH_EGL_MANAGER_)
+ set(LINUX_PLATFORM TRUE)
+ set(DEVICE "SDL")
+elseif(SOLARIS)
+ add_definitions(-D_IRR_SOLARIS_PLATFORM_ -D_IRR_POSIX_API_)
+ set(DEVICE "X11")
+else()
+ add_definitions(-D_IRR_POSIX_API_)
+ set(LINUX_PLATFORM TRUE)
+ set(DEVICE "X11")
+endif()
+
+if(USE_SDL2)
+ set(DEVICE "SDL")
+endif()
+
+option(USE_X11 "Use X11" TRUE)
+if(USE_X11)
+ add_definitions(-D_IRR_COMPILE_WITH_X11_)
+endif()
+
+if(LINUX_PLATFORM)
+ add_definitions(-D_IRR_LINUX_PLATFORM_)
+endif()
+
+if(LINUX_PLATFORM AND USE_X11)
+ add_definitions(-D_IRR_COMPILE_WITH_X11_)
+
+ option(USE_XINPUT2 "Use XInput2" TRUE)
+ if(USE_XINPUT2)
+ add_definitions(-D_IRR_LINUX_X11_XINPUT2_)
+ endif()
+
+ option(USE_XCURSOR "Use XCursor" FALSE)
+ if(USE_XCURSOR)
+ add_definitions(-D_IRR_LINUX_XCURSOR_)
+ endif()
+else()
+ set(USE_XINPUT2 FALSE)
+ set(USE_XCURSOR FALSE)
+endif()
+
+add_definitions("-D_IRR_COMPILE_WITH_${DEVICE}_DEVICE_")
+
+# Joystick
+
+if(NOT (BSD OR SOLARIS OR EMSCRIPTEN))
+ add_definitions(-D_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
+endif()
+
+# OpenGL
+
+if(IOS OR ANDROID OR EMSCRIPTEN)
+ set(ENABLE_OPENGL FALSE)
+else()
+ option(ENABLE_OPENGL "Enable OpenGL" TRUE)
+endif()
+
+if(EMSCRIPTEN OR OSX)
+ set(ENABLE_GLES1 FALSE)
+else()
+ if(ANDROID OR IOS)
+ set(DEFAULT_GLES1 TRUE)
+ endif()
+ option(ENABLE_GLES1 "Enable OpenGL ES" ${DEFAULT_GLES1})
+endif()
+
+if(OSX)
+ set(ENABLE_GLES2 FALSE)
+ set(ENABLE_WEBGL1 FALSE)
+else()
+ if(ANDROID OR IOS OR EMSCRIPTEN)
+ set(DEFAULT_GLES2 TRUE)
+ endif()
+ if(EMSCRIPTEN)
+ set(DEFAULT_WEBGL1 TRUE)
+ endif()
+ option(ENABLE_GLES2 "Enable OpenGL ES 2+" ${DEFAULT_GLES2})
+ option(ENABLE_WEBGL1 "Enable WebGL (requires GLES2)" ${DEFAULT_WEBGL1})
+ if(ENABLE_WEBGL1)
+ set(ENABLE_GLES2 TRUE)
+ endif()
+endif()
+
+if(ENABLE_OPENGL)
+ add_definitions(-D_IRR_COMPILE_WITH_OPENGL_)
+ if(DEVICE STREQUAL "WINDOWS")
+ add_definitions(-D_IRR_COMPILE_WITH_WGL_MANAGER_ -D_IRR_OPENGL_USE_EXTPOINTER_)
+ elseif(DEVICE STREQUAL "X11")
+ add_definitions(-D_IRR_COMPILE_WITH_GLX_MANAGER_ -D_IRR_OPENGL_USE_EXTPOINTER_)
+ elseif(DEVICE STREQUAL "OSX")
+ add_definitions(-D_IRR_COMPILE_WITH_NSOGL_MANAGER_)
+ elseif(DEVICE STREQUAL "SDL")
+ add_definitions(-D_IRR_OPENGL_USE_EXTPOINTER_)
+ endif()
+endif()
+
+if(ENABLE_GLES1)
+ add_definitions(-D_IRR_COMPILE_WITH_OGLES1_)
+ if(DEVICE MATCHES "^WINDOWS|X11|ANDROID$")
+ add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_ -D_IRR_OGLES1_USE_EXTPOINTER_)
+ elseif(DEVICE STREQUAL "IOS")
+ add_definitions(-D_IRR_COMPILE_WITH_EAGL_MANAGER_)
+ endif()
+endif()
+
+if(ENABLE_GLES2)
+ add_definitions(-D_IRR_COMPILE_WITH_OGLES2_)
+ if(DEVICE MATCHES "^WINDOWS|X11|ANDROID$" OR EMSCRIPTEN)
+ add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_ -D_IRR_OGLES2_USE_EXTPOINTER_)
+ elseif(DEVICE STREQUAL "IOS")
+ add_definitions(-D_IRR_COMPILE_WITH_EAGL_MANAGER_)
+ endif()
+endif()
+
+if(ENABLE_WEBGL1)
+ add_definitions(-D_IRR_COMPILE_WITH_WEBGL1_)
+endif()
+
+# Misc
+
+include(TestBigEndian)
+TEST_BIG_ENDIAN(BIG_ENDIAN)
+if(BIG_ENDIAN)
+ add_definitions(-D__BIG_ENDIAN__)
+endif()
+
+# Configuration report
+
+message(STATUS "Device: ${DEVICE}")
+message(STATUS "OpenGL: ${ENABLE_OPENGL}")
+message(STATUS "OpenGL ES: ${ENABLE_GLES1}")
+message(STATUS "OpenGL ES 2: ${ENABLE_GLES2}")
+message(STATUS "WebGL: ${ENABLE_WEBGL1}")
+
# Required libs
find_package(ZLIB REQUIRED)
find_package(JPEG REQUIRED)
find_package(PNG REQUIRED)
-# To configure the features available in this Irrlicht build please edit include/IrrCompileConfig.h.
-include(CheckSymbolExists)
-set(CMAKE_REQUIRED_INCLUDES ${PROJECT_SOURCE_DIR}/include)
-unset(OGLES1_ENABLED CACHE)
-unset(OGLES2_ENABLED CACHE)
-unset(OGL_ENABLED CACHE)
-unset(XINPUT2_ENABLED CACHE)
-unset(SDL_ENABLED CACHE)
-
-# tell cmake about the dependency
-set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_REQUIRED_INCLUDES}/IrrCompileConfig.h)
-check_symbol_exists(_IRR_COMPILE_WITH_OGLES1_ "IrrCompileConfig.h" OGLES1_ENABLED)
-if(OGLES1_ENABLED)
+if(ENABLE_GLES1)
# only tested on Android, probably works on Linux (is this needed anywhere else?)
find_library(OPENGLES_LIBRARY NAMES GLESv1_CM REQUIRED)
find_library(EGL_LIBRARY NAMES EGL REQUIRED)
message(STATUS "Found OpenGLES: ${OPENGLES_LIBRARY}")
endif()
-check_symbol_exists(_IRR_COMPILE_WITH_OGLES2_ "IrrCompileConfig.h" OGLES2_ENABLED)
-if(OGLES2_ENABLED)
+if(ENABLE_GLES2)
find_package(OpenGLES2 REQUIRED)
endif()
-check_symbol_exists(_IRR_COMPILE_WITH_OPENGL_ "IrrCompileConfig.h" OGL_ENABLED)
-if(OGL_ENABLED)
+if(ENABLE_OPENGL)
set(OpenGL_GL_PREFERENCE "LEGACY")
find_package(OpenGL REQUIRED)
endif()
-if(UNIX AND NOT ANDROID AND NOT APPLE)
- check_symbol_exists(_IRR_LINUX_X11_XINPUT2_ "IrrCompileConfig.h" XINPUT2_ENABLED)
-endif()
-check_symbol_exists(_IRR_COMPILE_WITH_SDL_DEVICE_ "IrrCompileConfig.h" SDL_ENABLED)
-if(SDL_ENABLED)
+if(USE_SDL2)
find_package(SDL2 CONFIG REQUIRED)
message(STATUS "Found SDL2: ${SDL2_LIBRARIES}")
endif()
else()
# Unix probably
find_package(X11 REQUIRED)
- if(XINPUT2_ENABLED AND NOT X11_Xi_FOUND)
+ if(${USE_XINPUT2} AND NOT X11_Xi_FOUND)
message(FATAL_ERROR "XInput not found")
endif()
endif()
if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(IrrlichtMt INTERFACE _IRR_STATIC_LIB_)
endif()
+if(WIN32)
+ target_compile_definitions(IrrlichtMt INTERFACE _IRR_WINDOWS_API_)
+endif()
+if(APPLE OR ANDROID OR EMSCRIPTEN)
+ target_compile_definitions(IrrlichtMt PUBLIC IRR_MOBILE_PATHS)
+endif()
set_target_properties(IrrlichtMt PROPERTIES
VERSION ${PROJECT_VERSION}