From 7df45b4cf3e680a1e1e578b234db8214ebd46e25 Mon Sep 17 00:00:00 2001 From: Gregor Parzefall Date: Sat, 13 Jan 2024 14:07:10 +0100 Subject: [PATCH 01/17] SDL: Implement touchscreen support --- source/Irrlicht/CIrrDeviceSDL.cpp | 46 ++++++++++++++++++++++++++++++- source/Irrlicht/CIrrDeviceSDL.h | 2 ++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/source/Irrlicht/CIrrDeviceSDL.cpp b/source/Irrlicht/CIrrDeviceSDL.cpp index 50e4542..05f3888 100644 --- a/source/Irrlicht/CIrrDeviceSDL.cpp +++ b/source/Irrlicht/CIrrDeviceSDL.cpp @@ -229,7 +229,7 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) Window((SDL_Window*)param.WindowId), SDL_Flags(0), MouseX(0), MouseY(0), MouseXRel(0), MouseYRel(0), MouseButtonStates(0), Width(param.WindowSize.Width), Height(param.WindowSize.Height), - Resizable(param.WindowResizable == 1 ? true : false) + Resizable(param.WindowResizable == 1 ? true : false), CurrentTouchCount(0) { #ifdef _DEBUG setDebugName("CIrrDeviceSDL"); @@ -254,6 +254,11 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) } } + // Minetest has its own code to synthesize mouse events from touch events, + // so we prevent SDL from doing it. + SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0"); + SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0"); + // create keymap createKeyMap(); @@ -745,6 +750,45 @@ bool CIrrDeviceSDL::run() postEventFromUser(irrevent); break; + case SDL_FINGERDOWN: + irrevent.EventType = EET_TOUCH_INPUT_EVENT; + irrevent.TouchInput.Event = ETIE_PRESSED_DOWN; + irrevent.TouchInput.ID = SDL_event.tfinger.fingerId; + irrevent.TouchInput.X = SDL_event.tfinger.x * Width; + irrevent.TouchInput.Y = SDL_event.tfinger.y * Height; + CurrentTouchCount++; + irrevent.TouchInput.touchedCount = CurrentTouchCount; + + postEventFromUser(irrevent); + break; + + case SDL_FINGERMOTION: + irrevent.EventType = EET_TOUCH_INPUT_EVENT; + irrevent.TouchInput.Event = ETIE_MOVED; + irrevent.TouchInput.ID = SDL_event.tfinger.fingerId; + irrevent.TouchInput.X = SDL_event.tfinger.x * Width; + irrevent.TouchInput.Y = SDL_event.tfinger.y * Height; + irrevent.TouchInput.touchedCount = CurrentTouchCount; + + postEventFromUser(irrevent); + break; + + case SDL_FINGERUP: + irrevent.EventType = EET_TOUCH_INPUT_EVENT; + irrevent.TouchInput.Event = ETIE_LEFT_UP; + irrevent.TouchInput.ID = SDL_event.tfinger.fingerId; + irrevent.TouchInput.X = SDL_event.tfinger.x * Width; + irrevent.TouchInput.Y = SDL_event.tfinger.y * Height; + // To match Android behavior, still count the pointer that was + // just released. + irrevent.TouchInput.touchedCount = CurrentTouchCount; + if (CurrentTouchCount > 0) { + CurrentTouchCount--; + } + + postEventFromUser(irrevent); + break; + default: break; } // end switch diff --git a/source/Irrlicht/CIrrDeviceSDL.h b/source/Irrlicht/CIrrDeviceSDL.h index 51c88e1..30adfdb 100644 --- a/source/Irrlicht/CIrrDeviceSDL.h +++ b/source/Irrlicht/CIrrDeviceSDL.h @@ -318,6 +318,8 @@ namespace irr core::array KeyMap; SDL_SysWMinfo Info; + + s32 CurrentTouchCount; }; } // end namespace irr From a3ec3a88e8c87c97d21dfaba77b426f4ab498bd2 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Sat, 13 Jan 2024 17:55:41 +0100 Subject: [PATCH 02/17] Fix scene nodes not dropping meshes (memleak) --- source/Irrlicht/CAnimatedMeshSceneNode.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/Irrlicht/CAnimatedMeshSceneNode.cpp b/source/Irrlicht/CAnimatedMeshSceneNode.cpp index e08dd54..965e7f1 100644 --- a/source/Irrlicht/CAnimatedMeshSceneNode.cpp +++ b/source/Irrlicht/CAnimatedMeshSceneNode.cpp @@ -51,6 +51,8 @@ CAnimatedMeshSceneNode::~CAnimatedMeshSceneNode() { if (LoopCallBack) LoopCallBack->drop(); + if (Mesh) + Mesh->drop(); } From f86b9b93e83087c26070bf761b12bc3d50b898b2 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Tue, 16 Jan 2024 18:24:02 +0100 Subject: [PATCH 03/17] Fix crash when SDL context fails to create --- source/Irrlicht/CIrrDeviceSDL.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/Irrlicht/CIrrDeviceSDL.cpp b/source/Irrlicht/CIrrDeviceSDL.cpp index 05f3888..d56e2ca 100644 --- a/source/Irrlicht/CIrrDeviceSDL.cpp +++ b/source/Irrlicht/CIrrDeviceSDL.cpp @@ -265,8 +265,10 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) // create window if (CreationParams.DriverType != video::EDT_NULL) { - // create the window, only if we do not use the null device - createWindow(); + if (!createWindow()) { + Close = true; + return; + } } From 0faeea33c32b85d6bd37aab4351f66a4114ca398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20M=C3=BCller?= <34514239+appgurueu@users.noreply.github.com> Date: Tue, 16 Jan 2024 18:34:24 +0100 Subject: [PATCH 04/17] build.yml: Upgrade bionic/jammy -> focal (current oldest LTS) --- .github/workflows/build.yml | 47 ++++++++++++++----------------------- 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f821f5d..7fefa40 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,16 +8,13 @@ on: jobs: linux-gl: - runs-on: ubuntu-latest - container: - image: ubuntu:bionic - env: { LANG: "C.UTF-8" } + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 - name: Install deps run: | - apt-get update - apt-get install g++ cmake libxi-dev libgl1-mesa-dev libpng-dev libjpeg-dev zlib1g-dev -qyy + sudo apt-get update + sudo apt-get install g++ cmake libxi-dev libgl1-mesa-dev libpng-dev libjpeg-dev zlib1g-dev -qyy - name: Build run: | @@ -39,16 +36,14 @@ jobs: path: ./irrlicht-linux.tar.gz linux-gles: - runs-on: ubuntu-latest - container: - image: ubuntu:bionic - env: { LANG: "C.UTF-8" } + # Xvfb test is broken on 20.04 for unknown reasons (not our bug) + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - name: Install deps run: | - apt-get update - apt-get install g++ cmake libxi-dev libgles2-mesa-dev libpng-dev libjpeg-dev zlib1g-dev xvfb -qyy + sudo apt-get update + sudo apt-get install g++ cmake libxi-dev libgles2-mesa-dev libpng-dev libjpeg-dev zlib1g-dev xvfb -qyy - name: Build run: | @@ -66,16 +61,13 @@ jobs: LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest ogles2 linux-sdl: - runs-on: ubuntu-latest - container: - image: ubuntu:jammy - env: { LANG: "C.UTF-8" } + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 - name: Install deps run: | - apt-get update - apt-get install g++ cmake libsdl2-dev libpng-dev libjpeg-dev zlib1g-dev -qyy + sudo apt-get update + sudo apt-get install g++ cmake libsdl2-dev libpng-dev libjpeg-dev zlib1g-dev -qyy - name: Build run: | @@ -88,16 +80,14 @@ jobs: ./AutomatedTest null linux-sdl-gl3: - runs-on: ubuntu-latest - container: - image: ubuntu:jammy - env: { LANG: "C.UTF-8" } + # Xvfb test is broken on 20.04 for unknown reasons (not our bug) + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - name: Install deps run: | - apt-get update - apt-get install g++ cmake libsdl2-dev libpng-dev libjpeg-dev zlib1g-dev xvfb -qyy + sudo apt-get update + sudo apt-get install g++ cmake libsdl2-dev libpng-dev libjpeg-dev zlib1g-dev xvfb -qyy - name: Build run: | @@ -115,16 +105,13 @@ jobs: LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest opengl3 linux-sdl-gles2: - runs-on: ubuntu-latest - container: - image: ubuntu:jammy - env: { LANG: "C.UTF-8" } + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 - name: Install deps run: | - apt-get update - apt-get install g++ cmake libsdl2-dev libpng-dev libjpeg-dev zlib1g-dev xvfb -qyy + sudo apt-get update + sudo apt-get install g++ cmake libsdl2-dev libpng-dev libjpeg-dev zlib1g-dev xvfb -qyy - name: Build run: | From edc678f9954004a213a8a6a64703bee1b9be0fce Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Tue, 16 Jan 2024 12:48:30 -0500 Subject: [PATCH 05/17] Update minimum CMake version --- CMakeLists.txt | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c07876..053ca9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,4 @@ -cmake_minimum_required(VERSION 3.5) - -# >=3.9 enables IPO; >=3.11 prefers GLVND -if(${CMAKE_VERSION} VERSION_LESS 3.11) - cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) -else() - cmake_policy(VERSION 3.11) -endif() +cmake_minimum_required(VERSION 3.12) set(IRRLICHTMT_REVISION 13) From 8f44270e4afe47e5127981762f3a527c8bd3e709 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Tue, 16 Jan 2024 19:42:21 +0100 Subject: [PATCH 06/17] Rip out compressed color formats --- include/EDriverFeatures.h | 15 --- include/IImage.h | 103 +---------------- include/ITexture.h | 5 - include/SColor.h | 58 ---------- source/Irrlicht/CColorConverter.cpp | 15 --- source/Irrlicht/CImage.cpp | 8 -- source/Irrlicht/CNullDriver.cpp | 62 ----------- source/Irrlicht/COGLES2Driver.cpp | 86 --------------- source/Irrlicht/COGLES2ExtensionHandler.h | 10 -- source/Irrlicht/COGLESDriver.cpp | 98 ----------------- source/Irrlicht/COGLESExtensionHandler.h | 8 -- source/Irrlicht/COpenGLDriver.cpp | 25 +---- source/Irrlicht/COpenGLExtensionHandler.cpp | 2 - source/Irrlicht/CWebGL1Driver.cpp | 116 -------------------- 14 files changed, 5 insertions(+), 606 deletions(-) diff --git a/include/EDriverFeatures.h b/include/EDriverFeatures.h index 2157cd7..d9e70df 100644 --- a/include/EDriverFeatures.h +++ b/include/EDriverFeatures.h @@ -121,21 +121,6 @@ namespace video //! Support for texture coord transformation via texture matrix EVDF_TEXTURE_MATRIX, - //! Support for DXTn compressed textures. - EVDF_TEXTURE_COMPRESSED_DXT, - - //! Support for PVRTC compressed textures. - EVDF_TEXTURE_COMPRESSED_PVRTC, - - //! Support for PVRTC2 compressed textures. - EVDF_TEXTURE_COMPRESSED_PVRTC2, - - //! Support for ETC1 compressed textures. - EVDF_TEXTURE_COMPRESSED_ETC1, - - //! Support for ETC2 compressed textures. - EVDF_TEXTURE_COMPRESSED_ETC2, - //! Support for cube map textures. EVDF_TEXTURE_CUBEMAP, diff --git a/include/IImage.h b/include/IImage.h index b32fcfb..738d1e0 100644 --- a/include/IImage.h +++ b/include/IImage.h @@ -362,28 +362,6 @@ public: return 24; case ECF_A8R8G8B8: return 32; - case ECF_DXT1: - return 16; - case ECF_DXT2: - case ECF_DXT3: - case ECF_DXT4: - case ECF_DXT5: - return 32; - case ECF_PVRTC_RGB2: - return 12; - case ECF_PVRTC_ARGB2: - case ECF_PVRTC2_ARGB2: - return 16; - case ECF_PVRTC_RGB4: - return 24; - case ECF_PVRTC_ARGB4: - case ECF_PVRTC2_ARGB4: - return 32; - case ECF_ETC1: - case ECF_ETC2_RGB: - return 24; - case ECF_ETC2_ARGB: - return 32; case ECF_D16: return 16; case ECF_D32: @@ -418,74 +396,17 @@ public: //! calculate image data size in bytes for selected format, width and height. static u32 getDataSizeFromFormat(ECOLOR_FORMAT format, u32 width, u32 height) { - u32 imageSize = 0; - - switch (format) - { - case ECF_DXT1: - imageSize = ((width + 3) / 4) * ((height + 3) / 4) * 8; - break; - case ECF_DXT2: - case ECF_DXT3: - case ECF_DXT4: - case ECF_DXT5: - imageSize = ((width + 3) / 4) * ((height + 3) / 4) * 16; - break; - case ECF_PVRTC_RGB2: - case ECF_PVRTC_ARGB2: - imageSize = (core::max_(width, 16) * core::max_(height, 8) * 2 + 7) / 8; - break; - case ECF_PVRTC_RGB4: - case ECF_PVRTC_ARGB4: - imageSize = (core::max_(width, 8) * core::max_(height, 8) * 4 + 7) / 8; - break; - case ECF_PVRTC2_ARGB2: - imageSize = core::ceil32(width / 8.0f) * core::ceil32(height / 4.0f) * 8; - break; - case ECF_PVRTC2_ARGB4: - case ECF_ETC1: - case ECF_ETC2_RGB: - imageSize = core::ceil32(width / 4.0f) * core::ceil32(height / 4.0f) * 8; - break; - case ECF_ETC2_ARGB: - imageSize = core::ceil32(width / 4.0f) * core::ceil32(height / 4.0f) * 16; - break; - default: // uncompressed formats - imageSize = getBitsPerPixelFromFormat(format) / 8 * width; - imageSize *= height; - break; - } + // non-compressed formats + u32 imageSize = getBitsPerPixelFromFormat(format) / 8 * width; + imageSize *= height; return imageSize; } -// Define to check for all compressed image formats cases in a switch -#define IRR_CASE_IIMAGE_COMPRESSED_FORMAT\ - case ECF_DXT1:\ - case ECF_DXT2:\ - case ECF_DXT3:\ - case ECF_DXT4:\ - case ECF_DXT5:\ - case ECF_PVRTC_RGB2:\ - case ECF_PVRTC_ARGB2:\ - case ECF_PVRTC2_ARGB2:\ - case ECF_PVRTC_RGB4:\ - case ECF_PVRTC_ARGB4:\ - case ECF_PVRTC2_ARGB4:\ - case ECF_ETC1:\ - case ECF_ETC2_RGB:\ - case ECF_ETC2_ARGB: - //! check if this is compressed color format static bool isCompressedFormat(const ECOLOR_FORMAT format) { - switch(format) - { - IRR_CASE_IIMAGE_COMPRESSED_FORMAT - return true; - default: - return false; - } + return false; } //! check if the color format is only viable for depth/stencil textures @@ -523,22 +444,6 @@ public: return false; } -#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) - static bool isRenderTargetOnlyFormat(const ECOLOR_FORMAT format) - { - switch (format) - { - case ECF_A1R5G5B5: - case ECF_R5G6B5: - case ECF_R8G8B8: - case ECF_A8R8G8B8: - return false; - default: - return true; - } - } -#endif - protected: ECOLOR_FORMAT Format; core::dimension2d Size; diff --git a/include/ITexture.h b/include/ITexture.h index 458ed0f..baae29b 100644 --- a/include/ITexture.h +++ b/include/ITexture.h @@ -292,11 +292,6 @@ public: { case ECF_A8R8G8B8: case ECF_A1R5G5B5: - case ECF_DXT1: - case ECF_DXT2: - case ECF_DXT3: - case ECF_DXT4: - case ECF_DXT5: case ECF_A16B16G16R16F: case ECF_A32B32G32R32F: status = true; diff --git a/include/SColor.h b/include/SColor.h index e7cc28f..710421c 100644 --- a/include/SColor.h +++ b/include/SColor.h @@ -37,50 +37,6 @@ namespace video //! Warning: This tends to be BGRA in memory (it's ARGB on file, but with usual big-endian memory it's flipped) ECF_A8R8G8B8, - /** Compressed image formats. **/ - - //! DXT1 color format. - ECF_DXT1, - - //! DXT2 color format. - ECF_DXT2, - - //! DXT3 color format. - ECF_DXT3, - - //! DXT4 color format. - ECF_DXT4, - - //! DXT5 color format. - ECF_DXT5, - - //! PVRTC RGB 2bpp. - ECF_PVRTC_RGB2, - - //! PVRTC ARGB 2bpp. - ECF_PVRTC_ARGB2, - - //! PVRTC RGB 4bpp. - ECF_PVRTC_RGB4, - - //! PVRTC ARGB 4bpp. - ECF_PVRTC_ARGB4, - - //! PVRTC2 ARGB 2bpp. - ECF_PVRTC2_ARGB2, - - //! PVRTC2 ARGB 4bpp. - ECF_PVRTC2_ARGB4, - - //! ETC1 RGB. - ECF_ETC1, - - //! ETC2 RGB. - ECF_ETC2_RGB, - - //! ETC2 ARGB. - ECF_ETC2_ARGB, - /** The following formats may only be used for render target textures. */ /** Floating point formats. */ @@ -139,20 +95,6 @@ namespace video "R5G6B5", "R8G8B8", "A8R8G8B8", - "DXT1", - "DXT2", - "DXT3", - "DXT4", - "DXT5", - "PVRTC_RGB2", - "PVRTC_ARGB2", - "PVRTC_RGB4", - "PVRTC_ARGB4", - "PVRTC2_ARGB2", - "PVRTC2_ARGB4", - "ETC1", - "ETC2_RGB", - "ETC2_ARGB", "R16F", "G16R16F", "A16B16G16R16F", diff --git a/source/Irrlicht/CColorConverter.cpp b/source/Irrlicht/CColorConverter.cpp index 6e46324..0e87d6c 100644 --- a/source/Irrlicht/CColorConverter.cpp +++ b/source/Irrlicht/CColorConverter.cpp @@ -757,9 +757,6 @@ void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN case ECF_R8G8B8: convert_A1R5G5B5toR8G8B8(sP, sN, dP); break; - IRR_CASE_IIMAGE_COMPRESSED_FORMAT - os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING); - break; default: break; @@ -780,9 +777,6 @@ void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN case ECF_R8G8B8: convert_R5G6B5toR8G8B8(sP, sN, dP); break; - IRR_CASE_IIMAGE_COMPRESSED_FORMAT - os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING); - break; default: break; @@ -803,9 +797,6 @@ void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN case ECF_R8G8B8: convert_A8R8G8B8toR8G8B8(sP, sN, dP); break; - IRR_CASE_IIMAGE_COMPRESSED_FORMAT - os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING); - break; default: break; @@ -826,17 +817,11 @@ void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN case ECF_R8G8B8: convert_R8G8B8toR8G8B8(sP, sN, dP); break; - IRR_CASE_IIMAGE_COMPRESSED_FORMAT - os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING); - break; default: break; } break; - IRR_CASE_IIMAGE_COMPRESSED_FORMAT - os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING); - break; default: break; diff --git a/source/Irrlicht/CImage.cpp b/source/Irrlicht/CImage.cpp index 8b50c63..c4fd3a2 100644 --- a/source/Irrlicht/CImage.cpp +++ b/source/Irrlicht/CImage.cpp @@ -75,10 +75,6 @@ void CImage::setPixel(u32 x, u32 y, const SColor &color, bool blend) *dest = blend ? PixelBlend32 ( *dest, color.color ) : color.color; } break; - IRR_CASE_IIMAGE_COMPRESSED_FORMAT - os::Printer::log("IImage::setPixel method doesn't work with compressed images.", ELL_WARNING); - return; - case ECF_UNKNOWN: os::Printer::log("IImage::setPixel unknown format.", ELL_WARNING); return; @@ -109,10 +105,6 @@ SColor CImage::getPixel(u32 x, u32 y) const return SColor(255,p[0],p[1],p[2]); } - IRR_CASE_IIMAGE_COMPRESSED_FORMAT - os::Printer::log("IImage::getPixel method doesn't work with compressed images.", ELL_WARNING); - break; - case ECF_UNKNOWN: os::Printer::log("IImage::getPixel unknown format.", ELL_WARNING); break; diff --git a/source/Irrlicht/CNullDriver.cpp b/source/Irrlicht/CNullDriver.cpp index 90b88e0..bd6d17a 100644 --- a/source/Irrlicht/CNullDriver.cpp +++ b/source/Irrlicht/CNullDriver.cpp @@ -1001,68 +1001,6 @@ bool CNullDriver::checkPrimitiveCount(u32 prmCount) const bool CNullDriver::checkImage(IImage *image) const { - ECOLOR_FORMAT format = image->getColorFormat(); - core::dimension2d size = image->getDimension(); - - switch (format) - { - case ECF_DXT1: - case ECF_DXT2: - case ECF_DXT3: - case ECF_DXT4: - case ECF_DXT5: - if (!queryFeature(EVDF_TEXTURE_COMPRESSED_DXT)) - { - os::Printer::log("DXT texture compression not available.", ELL_ERROR); - return false; - } - else if (size.getOptimalSize(true, false) != size) - { - os::Printer::log("Invalid size of image for DXT texture, size of image must be power of two.", ELL_ERROR); - return false; - } - break; - case ECF_PVRTC_RGB2: - case ECF_PVRTC_ARGB2: - case ECF_PVRTC_RGB4: - case ECF_PVRTC_ARGB4: - if (!queryFeature(EVDF_TEXTURE_COMPRESSED_PVRTC)) - { - os::Printer::log("PVRTC texture compression not available.", ELL_ERROR); - return false; - } - else if (size.getOptimalSize(true, false) != size) - { - os::Printer::log("Invalid size of image for PVRTC compressed texture, size of image must be power of two and squared.", ELL_ERROR); - return false; - } - break; - case ECF_PVRTC2_ARGB2: - case ECF_PVRTC2_ARGB4: - if (!queryFeature(EVDF_TEXTURE_COMPRESSED_PVRTC2)) - { - os::Printer::log("PVRTC2 texture compression not available.", ELL_ERROR); - return false; - } - break; - case ECF_ETC1: - if (!queryFeature(EVDF_TEXTURE_COMPRESSED_ETC1)) - { - os::Printer::log("ETC1 texture compression not available.", ELL_ERROR); - return false; - } - break; - case ECF_ETC2_RGB: - case ECF_ETC2_ARGB: - if (!queryFeature(EVDF_TEXTURE_COMPRESSED_ETC2)) - { - os::Printer::log("ETC2 texture compression not available.", ELL_ERROR); - return false; - } - break; - default: - break; - } return true; } diff --git a/source/Irrlicht/COGLES2Driver.cpp b/source/Irrlicht/COGLES2Driver.cpp index c8d5d07..58d0860 100644 --- a/source/Irrlicht/COGLES2Driver.cpp +++ b/source/Irrlicht/COGLES2Driver.cpp @@ -2533,92 +2533,6 @@ COGLES2Driver::~COGLES2Driver() } pixelType = GL_UNSIGNED_BYTE; break; -#ifdef GL_EXT_texture_compression_s3tc - case ECF_DXT1: - supported = true; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; - break; -#endif -#ifdef GL_EXT_texture_compression_s3tc - case ECF_DXT2: - case ECF_DXT3: - supported = true; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - break; -#endif -#ifdef GL_EXT_texture_compression_s3tc - case ECF_DXT4: - case ECF_DXT5: - supported = true; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - break; -#endif -#ifdef GL_IMG_texture_compression_pvrtc - case ECF_PVRTC_RGB2: - supported = true; - pixelFormat = GL_RGB; - pixelType = GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG; - break; -#endif -#ifdef GL_IMG_texture_compression_pvrtc - case ECF_PVRTC_ARGB2: - supported = true; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; - break; -#endif -#ifdef GL_IMG_texture_compression_pvrtc - case ECF_PVRTC_RGB4: - supported = true; - pixelFormat = GL_RGB; - pixelType = GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG; - break; -#endif -#ifdef GL_IMG_texture_compression_pvrtc - case ECF_PVRTC_ARGB4: - supported = true; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; - break; -#endif -#ifdef GL_IMG_texture_compression_pvrtc2 - case ECF_PVRTC2_ARGB2: - supported = true; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG; - break; -#endif -#ifdef GL_IMG_texture_compression_pvrtc2 - case ECF_PVRTC2_ARGB4: - supported = true; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG; - break; -#endif -#ifdef GL_OES_compressed_ETC1_RGB8_texture - case ECF_ETC1: - supported = true; - pixelFormat = GL_RGB; - pixelType = GL_ETC1_RGB8_OES; - break; -#endif -#ifdef GL_ES_VERSION_3_0 // TO-DO - fix when extension name will be available - case ECF_ETC2_RGB: - supported = true; - pixelFormat = GL_RGB; - pixelType = GL_COMPRESSED_RGB8_ETC2; - break; -#endif -#ifdef GL_ES_VERSION_3_0 // TO-DO - fix when extension name will be available - case ECF_ETC2_ARGB: - supported = true; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA8_ETC2_EAC; - break; -#endif case ECF_D16: supported = true; pixelFormat = GL_DEPTH_COMPONENT; diff --git a/source/Irrlicht/COGLES2ExtensionHandler.h b/source/Irrlicht/COGLES2ExtensionHandler.h index d5752dc..5e108c4 100644 --- a/source/Irrlicht/COGLES2ExtensionHandler.h +++ b/source/Irrlicht/COGLES2ExtensionHandler.h @@ -64,16 +64,6 @@ namespace video case EVDF_MRT_BLEND_FUNC: case EVDF_OCCLUSION_QUERY: return false; - case EVDF_TEXTURE_COMPRESSED_DXT: - return false; // NV Tegra need improvements here - case EVDF_TEXTURE_COMPRESSED_PVRTC: - return FeatureAvailable[IRR_GL_IMG_texture_compression_pvrtc]; - case EVDF_TEXTURE_COMPRESSED_PVRTC2: - return FeatureAvailable[IRR_GL_IMG_texture_compression_pvrtc2]; - case EVDF_TEXTURE_COMPRESSED_ETC1: - return FeatureAvailable[IRR_GL_OES_compressed_ETC1_RGB8_texture]; - case EVDF_TEXTURE_COMPRESSED_ETC2: - return false; case EVDF_STENCIL_BUFFER: return StencilBuffer; default: diff --git a/source/Irrlicht/COGLESDriver.cpp b/source/Irrlicht/COGLESDriver.cpp index f6a2ced..677cc81 100644 --- a/source/Irrlicht/COGLESDriver.cpp +++ b/source/Irrlicht/COGLESDriver.cpp @@ -2888,104 +2888,6 @@ bool COGLES1Driver::getColorFormatParameters(ECOLOR_FORMAT format, GLint& intern } pixelType = GL_UNSIGNED_BYTE; break; -#ifdef GL_EXT_texture_compression_s3tc - case ECF_DXT1: - supported = true; - internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; - break; -#endif -#ifdef GL_EXT_texture_compression_s3tc - case ECF_DXT2: - case ECF_DXT3: - supported = true; - internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - break; -#endif -#ifdef GL_EXT_texture_compression_s3tc - case ECF_DXT4: - case ECF_DXT5: - supported = true; - internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - break; -#endif -#ifdef GL_IMG_texture_compression_pvrtc - case ECF_PVRTC_RGB2: - supported = true; - internalFormat = GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG; - pixelFormat = GL_RGB; - pixelType = GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG; - break; -#endif -#ifdef GL_IMG_texture_compression_pvrtc - case ECF_PVRTC_ARGB2: - supported = true; - internalFormat = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; - break; -#endif -#ifdef GL_IMG_texture_compression_pvrtc - case ECF_PVRTC_RGB4: - supported = true; - internalFormat = GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG; - pixelFormat = GL_RGB; - pixelType = GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG; - break; -#endif -#ifdef GL_IMG_texture_compression_pvrtc - case ECF_PVRTC_ARGB4: - supported = true; - internalFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; - break; -#endif -#ifdef GL_IMG_texture_compression_pvrtc2 - case ECF_PVRTC2_ARGB2: - supported = true; - internalFormat = GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG; - break; -#endif -#ifdef GL_IMG_texture_compression_pvrtc2 - case ECF_PVRTC2_ARGB4: - supported = true; - internalFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG; - break; -#endif -#ifdef GL_OES_compressed_ETC1_RGB8_texture - case ECF_ETC1: - supported = true; - internalFormat = GL_ETC1_RGB8_OES; - pixelFormat = GL_RGB; - pixelType = GL_ETC1_RGB8_OES; - break; -#endif -#ifdef GL_ES_VERSION_3_0 // TO-DO - fix when extension name will be available - case ECF_ETC2_RGB: - supported = true; - internalFormat = GL_COMPRESSED_RGB8_ETC2; - pixelFormat = GL_RGB; - pixelType = GL_COMPRESSED_RGB8_ETC2; - break; -#endif -#ifdef GL_ES_VERSION_3_0 // TO-DO - fix when extension name will be available - case ECF_ETC2_ARGB: - supported = true; - internalFormat = GL_COMPRESSED_RGBA8_ETC2_EAC; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA8_ETC2_EAC; - break; -#endif case ECF_D16: supported = true; internalFormat = GL_DEPTH_COMPONENT16; diff --git a/source/Irrlicht/COGLESExtensionHandler.h b/source/Irrlicht/COGLESExtensionHandler.h index 6ce2e8e..62e89de 100644 --- a/source/Irrlicht/COGLESExtensionHandler.h +++ b/source/Irrlicht/COGLESExtensionHandler.h @@ -55,14 +55,6 @@ namespace video return FeatureAvailable[IRR_GL_OES_framebuffer_object]; case EVDF_VERTEX_BUFFER_OBJECT: return Version>100; - case EVDF_TEXTURE_COMPRESSED_DXT: - return false; // NV Tegra need improvements here - case EVDF_TEXTURE_COMPRESSED_PVRTC: - return FeatureAvailable[IRR_GL_IMG_texture_compression_pvrtc]; - case EVDF_TEXTURE_COMPRESSED_ETC1: - return FeatureAvailable[IRR_GL_OES_compressed_ETC1_RGB8_texture]; - case EVDF_TEXTURE_CUBEMAP: - return FeatureAvailable[IRR_GL_OES_texture_cube_map]; default: return true; }; diff --git a/source/Irrlicht/COpenGLDriver.cpp b/source/Irrlicht/COpenGLDriver.cpp index 20ffaf0..435c2fb 100644 --- a/source/Irrlicht/COpenGLDriver.cpp +++ b/source/Irrlicht/COpenGLDriver.cpp @@ -48,7 +48,7 @@ bool COpenGLDriver::initDriver() genericDriverInit(); -#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_X11_DEVICE_) +#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_X11_DEVICE_) extGlSwapInterval(Params.Vsync ? 1 : 0); #endif @@ -3962,29 +3962,6 @@ bool COpenGLDriver::getColorFormatParameters(ECOLOR_FORMAT format, GLint& intern if (Version > 101) pixelType = GL_UNSIGNED_INT_8_8_8_8_REV; break; - case ECF_DXT1: - if (queryOpenGLFeature(COpenGLExtensionHandler::IRR_EXT_texture_compression_s3tc)) - { - supported = true; - internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; - pixelFormat = GL_BGRA_EXT; - pixelType = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; - } - break; - case ECF_DXT2: - case ECF_DXT3: - supported = true; - internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - pixelFormat = GL_BGRA_EXT; - pixelType = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - break; - case ECF_DXT4: - case ECF_DXT5: - supported = true; - internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - pixelFormat = GL_BGRA_EXT; - pixelType = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - break; case ECF_D16: supported = true; internalFormat = GL_DEPTH_COMPONENT16; diff --git a/source/Irrlicht/COpenGLExtensionHandler.cpp b/source/Irrlicht/COpenGLExtensionHandler.cpp index 8a374d0..d1c4a46 100644 --- a/source/Irrlicht/COpenGLExtensionHandler.cpp +++ b/source/Irrlicht/COpenGLExtensionHandler.cpp @@ -882,8 +882,6 @@ bool COpenGLExtensionHandler::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const return (Version>=104) || FeatureAvailable[IRR_EXT_blend_func_separate]; case EVDF_TEXTURE_MATRIX: return true; - case EVDF_TEXTURE_COMPRESSED_DXT: - return FeatureAvailable[IRR_EXT_texture_compression_s3tc]; case EVDF_TEXTURE_CUBEMAP: return (Version >= 103) || FeatureAvailable[IRR_ARB_texture_cube_map] || FeatureAvailable[IRR_EXT_texture_cube_map]; case EVDF_TEXTURE_CUBEMAP_SEAMLESS: diff --git a/source/Irrlicht/CWebGL1Driver.cpp b/source/Irrlicht/CWebGL1Driver.cpp index 519496c..045cd9f 100644 --- a/source/Irrlicht/CWebGL1Driver.cpp +++ b/source/Irrlicht/CWebGL1Driver.cpp @@ -782,122 +782,6 @@ bool CWebGL1Driver::getColorFormatParameters(ECOLOR_FORMAT format, GLint& intern *converter = CColorConverter::convert_A8R8G8B8toA8B8G8R8; pixelType = GL_UNSIGNED_BYTE; break; -#ifdef GL_EXT_texture_compression_dxt1 - case ECF_DXT1: - if ( WebGLExtensions.queryWebGLFeature(CWebGLExtensionHandler::IRR_WEBGL_compressed_texture_s3tc) ) - { - supported = true; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; - } - break; -#endif -#ifdef GL_EXT_texture_compression_s3tc - case ECF_DXT2: - case ECF_DXT3: - if ( WebGLExtensions.queryWebGLFeature(CWebGLExtensionHandler::IRR_WEBGL_compressed_texture_s3tc) ) - { - supported = true; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - } - break; -#endif -#ifdef GL_EXT_texture_compression_s3tc - case ECF_DXT4: - case ECF_DXT5: - if ( WebGLExtensions.queryWebGLFeature(CWebGLExtensionHandler::IRR_WEBGL_compressed_texture_s3tc) ) - { - supported = true; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - } - break; -#endif -#ifdef GL_IMG_texture_compression_pvrtc - case ECF_PVRTC_RGB2: - if ( WebGLExtensions.queryWebGLFeature(CWebGLExtensionHandler::IRR_WEBGL_compressed_texture_pvrtc) ) - { - supported = true; - pixelFormat = GL_RGB; - pixelType = GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG; - } - break; -#endif -#ifdef GL_IMG_texture_compression_pvrtc - case ECF_PVRTC_ARGB2: - if ( WebGLExtensions.queryWebGLFeature(CWebGLExtensionHandler::IRR_WEBGL_compressed_texture_pvrtc) ) - { - supported = true; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; - } - break; -#endif -#ifdef GL_IMG_texture_compression_pvrtc - case ECF_PVRTC_RGB4: - if ( WebGLExtensions.queryWebGLFeature(CWebGLExtensionHandler::IRR_WEBGL_compressed_texture_pvrtc) ) - { - supported = true; - pixelFormat = GL_RGB; - pixelType = GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG; - } - break; -#endif -#ifdef GL_IMG_texture_compression_pvrtc - case ECF_PVRTC_ARGB4: - if ( WebGLExtensions.queryWebGLFeature(CWebGLExtensionHandler::IRR_WEBGL_compressed_texture_pvrtc) ) - { - supported = true; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; - } - break; -#endif -#ifdef GL_IMG_texture_compression_pvrtc2 - case ECF_PVRTC2_ARGB2: - if ( WebGLExtensions.queryWebGLFeature(CWebGLExtensionHandler::IRR_WEBGL_compressed_texture_pvrtc) ) - { - supported = true; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG; - } - break; -#endif -#ifdef GL_IMG_texture_compression_pvrtc2 - case ECF_PVRTC2_ARGB4: - if ( WebGLExtensions.queryWebGLFeature(CWebGLExtensionHandler::IRR_WEBGL_compressed_texture_pvrtc) ) - { - supported = true; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG; - } - break; -#endif -#ifdef GL_OES_compressed_ETC1_RGB8_texture - case ECF_ETC1: - if ( WebGLExtensions.queryWebGLFeature(CWebGLExtensionHandler::IRR_WEBGL_compressed_texture_etc1) ) - { - supported = true; - pixelFormat = GL_RGB; - pixelType = GL_ETC1_RGB8_OES; - } - break; -#endif -#ifdef GL_ES_VERSION_3_0 // TO-DO - fix when extension name will be available - case ECF_ETC2_RGB: - supported = true; - pixelFormat = GL_RGB; - pixelType = GL_COMPRESSED_RGB8_ETC2; - break; -#endif -#ifdef GL_ES_VERSION_3_0 // TO-DO - fix when extension name will be available - case ECF_ETC2_ARGB: - supported = true; - pixelFormat = GL_RGBA; - pixelType = GL_COMPRESSED_RGBA8_ETC2_EAC; - break; -#endif case ECF_D16: if (WebGLExtensions.queryWebGLFeature(CWebGLExtensionHandler::IRR_WEBGL_depth_texture)) { From 88ca26c41856144752ca60e77804933d6157e90a Mon Sep 17 00:00:00 2001 From: sfan5 Date: Tue, 16 Jan 2024 19:56:59 +0100 Subject: [PATCH 07/17] Define extpointer for SDL + OGLES2 --- source/Irrlicht/CMakeLists.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/Irrlicht/CMakeLists.txt b/source/Irrlicht/CMakeLists.txt index a3abd1b..05744d9 100644 --- a/source/Irrlicht/CMakeLists.txt +++ b/source/Irrlicht/CMakeLists.txt @@ -184,6 +184,7 @@ endif() if(ENABLE_OPENGL) add_definitions(-D_IRR_COMPILE_WITH_OPENGL_) + set(OPENGL_DIRECT_LINK TRUE) # not yet possible to remove this if(DEVICE STREQUAL "WINDOWS") add_definitions(-D_IRR_COMPILE_WITH_WGL_MANAGER_ -D_IRR_OPENGL_USE_EXTPOINTER_) elseif(DEVICE STREQUAL "X11") @@ -199,6 +200,7 @@ if(ENABLE_OPENGL3) if (NOT USE_SDL2) message(FATAL_ERROR "OpenGL 3 driver requires SDL2") endif() + set(OPENGL_DIRECT_LINK TRUE) # TODO set(USE_SDLGL ON) set(USE_SDLGL3 ON) endif() @@ -208,6 +210,7 @@ if(ENABLE_GLES1) message(FATAL_ERROR "OpenGL ES 1 is not supported with SDL2") endif() add_definitions(-D_IRR_COMPILE_WITH_OGLES1_) + set(OPENGLES_DIRECT_LINK TRUE) if(DEVICE MATCHES "^(WINDOWS|X11|ANDROID)$") add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_ -D_IRR_OGLES1_USE_EXTPOINTER_) endif() @@ -215,9 +218,11 @@ endif() if(ENABLE_GLES2) add_definitions(-D_IRR_COMPILE_WITH_OGLES2_) + set(OPENGLES2_DIRECT_LINK TRUE) # not yet possible to remove this if(DEVICE MATCHES "^(WINDOWS|X11|ANDROID)$" OR EMSCRIPTEN) add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_ -D_IRR_OGLES2_USE_EXTPOINTER_) elseif(DEVICE STREQUAL "SDL") + add_definitions(-D_IRR_OGLES2_USE_EXTPOINTER_) set(USE_SDLGL ON) set(USE_SDLGLES2 ON) endif() @@ -315,9 +320,9 @@ set(link_libs "${PNG_LIBRARY}" "$<$:${SDL2_LIBRARIES}>" - ${OPENGL_LIBRARIES} - ${OPENGLES_LIBRARY} - ${OPENGLES2_LIBRARIES} + "$<$:${OPENGL_LIBRARIES}>" + "$<$:${OPENGLES_LIBRARIES}>" + "$<$:${OPENGLES2_LIBRARIES}>" ${EGL_LIBRARY} "$<$:-landroid -llog>" From ee2467d622400ac7535672adafe9d7c8228c9997 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Tue, 16 Jan 2024 23:59:33 +0100 Subject: [PATCH 08/17] Remove some dead code --- source/Irrlicht/COpenGLExtensionHandler.cpp | 214 -------------------- source/Irrlicht/COpenGLExtensionHandler.h | 2 - 2 files changed, 216 deletions(-) diff --git a/source/Irrlicht/COpenGLExtensionHandler.cpp b/source/Irrlicht/COpenGLExtensionHandler.cpp index d1c4a46..7c25a14 100644 --- a/source/Irrlicht/COpenGLExtensionHandler.cpp +++ b/source/Irrlicht/COpenGLExtensionHandler.cpp @@ -127,220 +127,6 @@ void COpenGLExtensionHandler::dump(ELOG_LEVEL logLevel) const } -void COpenGLExtensionHandler::dumpFramebufferFormats() const -{ -#ifdef _IRR_WINDOWS_API_ - HDC hdc=wglGetCurrentDC(); - core::stringc wglExtensions; -#ifdef WGL_ARB_extensions_string - PFNWGLGETEXTENSIONSSTRINGARBPROC irrGetExtensionsString = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB"); - if (irrGetExtensionsString) - wglExtensions = irrGetExtensionsString(hdc); -#elif defined(WGL_EXT_extensions_string) - PFNWGLGETEXTENSIONSSTRINGEXTPROC irrGetExtensionsString = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)wglGetProcAddress("wglGetExtensionsStringEXT"); - if (irrGetExtensionsString) - wglExtensions = irrGetExtensionsString(hdc); -#endif - const bool pixel_format_supported = (wglExtensions.find("WGL_ARB_pixel_format") != -1); - const bool multi_sample_supported = ((wglExtensions.find("WGL_ARB_multisample") != -1) || - (wglExtensions.find("WGL_EXT_multisample") != -1) || (wglExtensions.find("WGL_3DFX_multisample") != -1) ); -#ifdef _DEBUG - os::Printer::log("WGL_extensions", wglExtensions); -#endif - -#ifdef WGL_ARB_pixel_format - PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat_ARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); - if (pixel_format_supported && wglChoosePixelFormat_ARB) - { - // This value determines the number of samples used for antialiasing - // My experience is that 8 does not show a big - // improvement over 4, but 4 shows a big improvement - // over 2. - - PFNWGLGETPIXELFORMATATTRIBIVARBPROC wglGetPixelFormatAttribiv_ARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)wglGetProcAddress("wglGetPixelFormatAttribivARB"); - if (wglGetPixelFormatAttribiv_ARB) - { - int vals[128]; - int atts[] = { - WGL_NUMBER_PIXEL_FORMATS_ARB, - WGL_DRAW_TO_BITMAP_ARB, - WGL_ACCELERATION_ARB, - WGL_NEED_PALETTE_ARB, - WGL_NEED_SYSTEM_PALETTE_ARB, - WGL_SWAP_LAYER_BUFFERS_ARB, - WGL_SWAP_METHOD_ARB, - WGL_NUMBER_OVERLAYS_ARB, - WGL_NUMBER_UNDERLAYS_ARB, - WGL_TRANSPARENT_ARB, - WGL_TRANSPARENT_RED_VALUE_ARB, - WGL_TRANSPARENT_GREEN_VALUE_ARB, - WGL_TRANSPARENT_BLUE_VALUE_ARB, - WGL_TRANSPARENT_ALPHA_VALUE_ARB, - WGL_TRANSPARENT_INDEX_VALUE_ARB, - WGL_SHARE_DEPTH_ARB, - WGL_SHARE_STENCIL_ARB, - WGL_SHARE_ACCUM_ARB, - WGL_SUPPORT_GDI_ARB, - WGL_SUPPORT_OPENGL_ARB, - WGL_DOUBLE_BUFFER_ARB, - WGL_STEREO_ARB, - WGL_PIXEL_TYPE_ARB, - WGL_COLOR_BITS_ARB, - WGL_RED_BITS_ARB, - WGL_RED_SHIFT_ARB, - WGL_GREEN_BITS_ARB, - WGL_GREEN_SHIFT_ARB, - WGL_BLUE_BITS_ARB, - WGL_BLUE_SHIFT_ARB, - WGL_ALPHA_BITS_ARB, - WGL_ALPHA_SHIFT_ARB, - WGL_ACCUM_BITS_ARB, - WGL_ACCUM_RED_BITS_ARB, - WGL_ACCUM_GREEN_BITS_ARB, - WGL_ACCUM_BLUE_BITS_ARB, - WGL_ACCUM_ALPHA_BITS_ARB, - WGL_DEPTH_BITS_ARB, - WGL_STENCIL_BITS_ARB, - WGL_AUX_BUFFERS_ARB -#ifdef WGL_ARB_render_texture - ,WGL_BIND_TO_TEXTURE_RGB_ARB //40 - ,WGL_BIND_TO_TEXTURE_RGBA_ARB -#endif -#ifdef WGL_ARB_pbuffer - ,WGL_DRAW_TO_PBUFFER_ARB //42 - ,WGL_MAX_PBUFFER_PIXELS_ARB - ,WGL_MAX_PBUFFER_WIDTH_ARB - ,WGL_MAX_PBUFFER_HEIGHT_ARB -#endif -#ifdef WGL_ARB_framebuffer_sRGB - ,WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB //46 -#endif -#ifdef WGL_ARB_multisample - ,WGL_SAMPLES_ARB //47 - ,WGL_SAMPLE_BUFFERS_ARB -#endif -#ifdef WGL_EXT_depth_float - ,WGL_DEPTH_FLOAT_EXT //49 -#endif - ,0,0,0,0 - }; - size_t nums = sizeof(atts)/sizeof(int); - const bool depth_float_supported= (wglExtensions.find("WGL_EXT_depth_float") != -1); - if (!depth_float_supported) - { - memmove(&atts[49], &atts[50], (nums-50)*sizeof(int)); - nums -= 1; - } - if (!multi_sample_supported) - { - memmove(&atts[47], &atts[49], (nums-49)*sizeof(int)); - nums -= 2; - } - const bool framebuffer_sRGB_supported= (wglExtensions.find("WGL_ARB_framebuffer_sRGB") != -1); - if (!framebuffer_sRGB_supported) - { - memmove(&atts[46], &atts[47], (nums-47)*sizeof(int)); - nums -= 1; - } - const bool pbuffer_supported = (wglExtensions.find("WGL_ARB_pbuffer") != -1); - if (!pbuffer_supported) - { - memmove(&atts[42], &atts[46], (nums-46)*sizeof(int)); - nums -= 4; - } - const bool render_texture_supported = (wglExtensions.find("WGL_ARB_render_texture") != -1); - if (!render_texture_supported) - { - memmove(&atts[40], &atts[42], (nums-42)*sizeof(int)); - nums -= 2; - } - wglGetPixelFormatAttribiv_ARB(hdc,0,0,1,atts,vals); - const int count = vals[0]; - atts[0]=WGL_DRAW_TO_WINDOW_ARB; - for (int i=1; i(glGetString(GL_VERSION))); diff --git a/source/Irrlicht/COpenGLExtensionHandler.h b/source/Irrlicht/COpenGLExtensionHandler.h index 5f3c422..3b4147b 100644 --- a/source/Irrlicht/COpenGLExtensionHandler.h +++ b/source/Irrlicht/COpenGLExtensionHandler.h @@ -1010,8 +1010,6 @@ class COpenGLExtensionHandler //! show all features with availability void dump(ELOG_LEVEL logLevel) const; - void dumpFramebufferFormats() const; - // Some variables for properties bool StencilBuffer; bool TextureCompressionExtension; From b349266855cd15e120893f97ff2484966679d106 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Wed, 17 Jan 2024 00:05:13 +0100 Subject: [PATCH 09/17] Enable SDL to compile on macOS --- .github/workflows/build.yml | 14 ++++++++++++++ source/Irrlicht/COpenGLCommon.h | 7 +++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7fefa40..d665ed7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -177,6 +177,20 @@ jobs: run: | ./bin/OSX/AutomatedTest null + macos-sdl: + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + - name: Install deps + run: | + brew update + brew install cmake libpng jpeg sdl2 + + - name: Build + run: | + cmake . -DCMAKE_FIND_FRAMEWORK=LAST -DBUILD_EXAMPLES=1 -DUSE_SDL2=1 + make -j3 + msvc: name: VS 2019 ${{ matrix.config.arch }} ${{ matrix.sdl.label }} runs-on: windows-2019 diff --git a/source/Irrlicht/COpenGLCommon.h b/source/Irrlicht/COpenGLCommon.h index 66ad81d..5eb1295 100644 --- a/source/Irrlicht/COpenGLCommon.h +++ b/source/Irrlicht/COpenGLCommon.h @@ -23,7 +23,7 @@ #endif #include #if defined(_IRR_OPENGL_USE_EXTPOINTER_) - #include + #error glext.h missing on OSX #endif #elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_) && !defined(_IRR_COMPILE_WITH_X11_DEVICE_) #if defined(_IRR_OPENGL_USE_EXTPOINTER_) @@ -34,8 +34,11 @@ #include #include #if defined(_IRR_OPENGL_USE_EXTPOINTER_) - // The SDL2 header doesn't cut it for extensions + #ifdef __APPLE__ + #include + #else #include + #endif #endif #else #if defined(_IRR_OPENGL_USE_EXTPOINTER_) From dda9b23c3d5100451a66a5fd9e26a21b31364406 Mon Sep 17 00:00:00 2001 From: savilli <78875209+savilli@users.noreply.github.com> Date: Thu, 21 Dec 2023 02:14:54 +0100 Subject: [PATCH 10/17] Make equals method symmetric --- include/irrMath.h | 42 +++++++++++------------------------------- include/vector2d.h | 5 ++--- include/vector3d.h | 6 ++---- 3 files changed, 15 insertions(+), 38 deletions(-) diff --git a/include/irrMath.h b/include/irrMath.h index e3b75e0..0219bd4 100644 --- a/include/irrMath.h +++ b/include/irrMath.h @@ -9,6 +9,7 @@ #include #include // for abs() etc. #include // For INT_MAX / UINT_MAX +#include namespace irr { @@ -17,9 +18,6 @@ namespace core //! Rounding error constant often used when comparing f32 values. - const s32 ROUNDING_ERROR_S32 = 0; - - const s64 ROUNDING_ERROR_S64 = 0; const f32 ROUNDING_ERROR_f32 = 0.000001f; const f64 ROUNDING_ERROR_f64 = 0.00000001; @@ -170,30 +168,6 @@ namespace core return ROUNDING_ERROR_f64; } - template <> - inline s32 roundingError() - { - return ROUNDING_ERROR_S32; - } - - template <> - inline u32 roundingError() - { - return ROUNDING_ERROR_S32; - } - - template <> - inline s64 roundingError() - { - return ROUNDING_ERROR_S64; - } - - template <> - inline u64 roundingError() - { - return ROUNDING_ERROR_S64; - } - template inline T relativeErrorFactor() { @@ -212,13 +186,19 @@ namespace core return 8; } - //! returns if a equals b, taking possible rounding errors into account - template - inline bool equals(const T a, const T b, const T tolerance = roundingError()) + //! returns if a equals b, for types without rounding errors + template ::value, bool> = true> + inline bool equals(const T a, const T b) { - return (a + tolerance >= b) && (a - tolerance <= b); + return a == b; } + //! returns if a equals b, taking possible rounding errors into account + template ::value, bool> = true> + inline bool equals(const T a, const T b, const T tolerance = roundingError()) + { + return abs(a - b) <= tolerance; + } //! returns if a equals b, taking relative error in form of factor //! this particular function does not involve any division. diff --git a/include/vector2d.h b/include/vector2d.h index 75ca08b..549661a 100644 --- a/include/vector2d.h +++ b/include/vector2d.h @@ -111,11 +111,10 @@ public: //! Checks if this vector equals the other one. /** Takes floating point rounding errors into account. \param other Vector to compare with. - \param tolerance Epsilon value for both - comparing X and Y. \return True if the two vector are (almost) equal, else false. */ - bool equals(const vector2d& other, const T tolerance = (T)ROUNDING_ERROR_f32 ) const + bool equals(const vector2d& other) const { - return core::equals(X, other.X, tolerance) && core::equals(Y, other.Y, tolerance); + return core::equals(X, other.X) && core::equals(Y, other.Y); } vector2d& set(T nx, T ny) {X=nx; Y=ny; return *this; } diff --git a/include/vector3d.h b/include/vector3d.h index b89bfbc..7c6b98a 100644 --- a/include/vector3d.h +++ b/include/vector3d.h @@ -114,11 +114,9 @@ namespace core // functions //! returns if this vector equals the other one, taking floating point rounding errors into account - bool equals(const vector3d& other, const T tolerance = (T)ROUNDING_ERROR_f32 ) const + bool equals(const vector3d& other) const { - return core::equals(X, other.X, tolerance) && - core::equals(Y, other.Y, tolerance) && - core::equals(Z, other.Z, tolerance); + return core::equals(X, other.X) && core::equals(Y, other.Y) && core::equals(Z, other.Z); } vector3d& set(const T nx, const T ny, const T nz) {X=nx; Y=ny; Z=nz; return *this;} From 345285786fe5dc55d38506fde24b8c070e08fd13 Mon Sep 17 00:00:00 2001 From: savilli <78875209+savilli@users.noreply.github.com> Date: Mon, 8 Jan 2024 01:41:39 +0100 Subject: [PATCH 11/17] Make vector comparison operators transitive --- include/vector2d.h | 29 +++++++++++++++-------------- include/vector3d.h | 36 ++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 34 deletions(-) diff --git a/include/vector2d.h b/include/vector2d.h index 549661a..139ee7a 100644 --- a/include/vector2d.h +++ b/include/vector2d.h @@ -75,36 +75,37 @@ public: return *(&X+index); } - //! sort in order X, Y. Equality with rounding tolerance. + //! sort in order X, Y. bool operator<=(const vector2d&other) const { - return (X other); } - //! sort in order X, Y. Equality with rounding tolerance. + //! sort in order X, Y. bool operator>=(const vector2d&other) const { - return (X>other.X || core::equals(X, other.X)) || - (core::equals(X, other.X) && (Y>other.Y || core::equals(Y, other.Y))); + return !(*this < other); } - //! sort in order X, Y. Difference must be above rounding tolerance. + //! sort in order X, Y. bool operator<(const vector2d&other) const { - return (X(const vector2d&other) const { - return (X>other.X && !core::equals(X, other.X)) || - (core::equals(X, other.X) && Y>other.Y && !core::equals(Y, other.Y)); + return X > other.X || (X == other.X && Y > other.Y); } - bool operator==(const vector2d& other) const { return equals(other); } - bool operator!=(const vector2d& other) const { return !equals(other); } + bool operator==(const vector2d& other) const { + return X == other.X && Y == other.Y; + } + + bool operator!=(const vector2d& other) const { + return !(*this == other); + } // functions diff --git a/include/vector3d.h b/include/vector3d.h index 7c6b98a..2817287 100644 --- a/include/vector3d.h +++ b/include/vector3d.h @@ -68,52 +68,48 @@ namespace core return *(&X+index); } - //! sort in order X, Y, Z. Equality with rounding tolerance. + //! sort in order X, Y, Z. bool operator<=(const vector3d&other) const { - return (X other); } - //! sort in order X, Y, Z. Equality with rounding tolerance. + //! sort in order X, Y, Z. bool operator>=(const vector3d&other) const { - return (X>other.X || core::equals(X, other.X)) || - (core::equals(X, other.X) && (Y>other.Y || core::equals(Y, other.Y))) || - (core::equals(X, other.X) && core::equals(Y, other.Y) && (Z>other.Z || core::equals(Z, other.Z))); + return !(*this < other); } - //! sort in order X, Y, Z. Difference must be above rounding tolerance. + //! sort in order X, Y, Z. bool operator<(const vector3d&other) const { - return (X(const vector3d&other) const { - return (X>other.X && !core::equals(X, other.X)) || - (core::equals(X, other.X) && Y>other.Y && !core::equals(Y, other.Y)) || - (core::equals(X, other.X) && core::equals(Y, other.Y) && Z>other.Z && !core::equals(Z, other.Z)); + return X > other.X || (X == other.X && Y > other.Y) || + (X == other.X && Y == other.Y && Z > other.Z); } - //! use weak float compare bool operator==(const vector3d& other) const { - return this->equals(other); + return X == other.X && Y == other.Y && Z == other.Z; } bool operator!=(const vector3d& other) const { - return !this->equals(other); + return !(*this == other); } // functions - //! returns if this vector equals the other one, taking floating point rounding errors into account + //! Checks if this vector equals the other one. + /** Takes floating point rounding errors into account. + \param other Vector to compare with. + \return True if the two vector are (almost) equal, else false. */ bool equals(const vector3d& other) const { return core::equals(X, other.X) && core::equals(Y, other.Y) && core::equals(Z, other.Z); From bdcd27ab5b3583c8941ec069092aa82a80df4ae3 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Wed, 17 Jan 2024 17:19:03 +0100 Subject: [PATCH 12/17] Bump revision --- CMakeLists.txt | 2 +- include/IrrCompileConfig.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 053ca9b..64d63d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.12) -set(IRRLICHTMT_REVISION 13) +set(IRRLICHTMT_REVISION 14) project(Irrlicht VERSION 1.9.0.${IRRLICHTMT_REVISION} diff --git a/include/IrrCompileConfig.h b/include/IrrCompileConfig.h index 24972ca..50b61eb 100644 --- a/include/IrrCompileConfig.h +++ b/include/IrrCompileConfig.h @@ -5,8 +5,8 @@ #pragma once //! Identifies the IrrlichtMt fork customized for the Minetest engine -#define IRRLICHT_VERSION_MT_REVISION 13 -#define IRRLICHT_VERSION_MT "mt13" +#define IRRLICHT_VERSION_MT_REVISION 14 +#define IRRLICHT_VERSION_MT "mt14" //! Irrlicht SDK Version #define IRRLICHT_VERSION_MAJOR 1 From c3571261caf9e887371b2809635285f239bba312 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Wed, 17 Jan 2024 17:55:19 +0100 Subject: [PATCH 13/17] Fix build with OpenGL ES 1 --- source/Irrlicht/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Irrlicht/CMakeLists.txt b/source/Irrlicht/CMakeLists.txt index 05744d9..f90728b 100644 --- a/source/Irrlicht/CMakeLists.txt +++ b/source/Irrlicht/CMakeLists.txt @@ -321,7 +321,7 @@ set(link_libs "$<$:${SDL2_LIBRARIES}>" "$<$:${OPENGL_LIBRARIES}>" - "$<$:${OPENGLES_LIBRARIES}>" + "$<$:${OPENGLES_LIBRARY}>" "$<$:${OPENGLES2_LIBRARIES}>" ${EGL_LIBRARY} From 9df2f0b9446799f9e6c67909f4bdda5cb8cd07ad Mon Sep 17 00:00:00 2001 From: David Heidelberg Date: Tue, 16 Jan 2024 23:43:41 +0100 Subject: [PATCH 14/17] Undefine SDL2 DirectFB video driver 1. we don't need it 2. it's dropped in SDL 3 3. it breaks compilation on Alpine and postmarketOS with SDL2 enabled (and the bug never going to get fixed on SDL2 side) Signed-off-by: David Heidelberg --- source/Irrlicht/CIrrDeviceSDL.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/Irrlicht/CIrrDeviceSDL.h b/source/Irrlicht/CIrrDeviceSDL.h index 30adfdb..1713a3b 100644 --- a/source/Irrlicht/CIrrDeviceSDL.h +++ b/source/Irrlicht/CIrrDeviceSDL.h @@ -17,6 +17,10 @@ #endif #include +// DirectFB is removed in SDL3, thou distribution as Alpine currently ships SDL2 +// with enabled DirectFB, but requiring another fix at a top of SDL2. +// We don't need DirectFB in Irrlicht/Minetest, so simply disable it here to prevent issues. +#undef SDL_VIDEO_DRIVER_DIRECTFB #include #include From 66786d0059e9cf021c34c1de30540a45d928308c Mon Sep 17 00:00:00 2001 From: grorp Date: Fri, 19 Jan 2024 18:17:26 +0100 Subject: [PATCH 15/17] Make IrrlichtDevice::isWindowVisible do what it says on the tin (#279) --- include/IrrlichtDevice.h | 5 ++++- source/Irrlicht/Android/CIrrDeviceAndroid.cpp | 11 +++++++---- source/Irrlicht/Android/CIrrDeviceAndroid.h | 3 ++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/IrrlichtDevice.h b/include/IrrlichtDevice.h index c6d5298..048bc94 100644 --- a/include/IrrlichtDevice.h +++ b/include/IrrlichtDevice.h @@ -178,7 +178,10 @@ namespace irr virtual bool isFullscreen() const = 0; //! Checks if the window could possibly be visible. - //! Currently, this only returns false when the app is paused on Android. + //! Currently, this only returns false when the activity is stopped on + //! Android. Note that for Android activities, "stopped" means something + //! different than you might expect (and also something different than + //! "paused"). Read the Android lifecycle documentation. virtual bool isWindowVisible() const { return true; }; //! Get the current color format of the window diff --git a/source/Irrlicht/Android/CIrrDeviceAndroid.cpp b/source/Irrlicht/Android/CIrrDeviceAndroid.cpp index 4ad3773..52cc95d 100644 --- a/source/Irrlicht/Android/CIrrDeviceAndroid.cpp +++ b/source/Irrlicht/Android/CIrrDeviceAndroid.cpp @@ -31,7 +31,8 @@ namespace irr { CIrrDeviceAndroid::CIrrDeviceAndroid(const SIrrlichtCreationParameters& param) - : CIrrDeviceStub(param), Accelerometer(0), Gyroscope(0), Focused(false), Initialized(false), Paused(true), JNIEnvAttachedToVM(0) + : CIrrDeviceStub(param), Accelerometer(0), Gyroscope(0), Initialized(false), + Stopped(true), Paused(true), Focused(false), JNIEnvAttachedToVM(0) { #ifdef _DEBUG setDebugName("CIrrDeviceAndroid"); @@ -64,7 +65,7 @@ CIrrDeviceAndroid::CIrrDeviceAndroid(const SIrrlichtCreationParameters& param) s32 Events = 0; android_poll_source* Source = 0; - while ((ALooper_pollAll(((Focused && !Paused) || !Initialized) ? 0 : -1, 0, &Events, (void**)&Source)) >= 0) + while ((ALooper_pollAll((!Initialized || isWindowActive()) ? 0 : -1, 0, &Events, (void**)&Source)) >= 0) { if(Source) Source->process(Android, Source); @@ -180,7 +181,7 @@ void CIrrDeviceAndroid::setWindowCaption(const wchar_t* text) bool CIrrDeviceAndroid::isWindowActive() const { - return (Focused && !Paused); + return (Focused && !Paused && !Stopped); } bool CIrrDeviceAndroid::isWindowFocused() const @@ -195,7 +196,7 @@ bool CIrrDeviceAndroid::isWindowMinimized() const bool CIrrDeviceAndroid::isWindowVisible() const { - return !Paused; + return !Stopped; } void CIrrDeviceAndroid::closeDevice() @@ -265,6 +266,7 @@ void CIrrDeviceAndroid::handleAndroidCommand(android_app* app, int32_t cmd) break; case APP_CMD_START: os::Printer::log("Android command APP_CMD_START", ELL_DEBUG); + device->Stopped = false; break; case APP_CMD_INIT_WINDOW: os::Printer::log("Android command APP_CMD_INIT_WINDOW", ELL_DEBUG); @@ -322,6 +324,7 @@ void CIrrDeviceAndroid::handleAndroidCommand(android_app* app, int32_t cmd) break; case APP_CMD_STOP: os::Printer::log("Android command APP_CMD_STOP", ELL_DEBUG); + device->Stopped = true; break; case APP_CMD_RESUME: os::Printer::log("Android command APP_CMD_RESUME", ELL_DEBUG); diff --git a/source/Irrlicht/Android/CIrrDeviceAndroid.h b/source/Irrlicht/Android/CIrrDeviceAndroid.h index e771082..9192cf1 100644 --- a/source/Irrlicht/Android/CIrrDeviceAndroid.h +++ b/source/Irrlicht/Android/CIrrDeviceAndroid.h @@ -86,9 +86,10 @@ namespace irr const ASensor* Accelerometer; const ASensor* Gyroscope; - bool Focused; bool Initialized; + bool Stopped; bool Paused; + bool Focused; JNIEnv* JNIEnvAttachedToVM; From 5b81694b1d9a54801b5d6322c8b1f6daa946112e Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Sun, 21 Jan 2024 17:51:11 +0300 Subject: [PATCH 16/17] CI: Android support (#197) --- .github/workflows/build.yml | 43 +++++++++++++ scripts/ci-build-android.sh | 123 ++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100755 scripts/ci-build-android.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d665ed7..8bd6a4e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -258,3 +258,46 @@ jobs: with: name: msvc-${{ matrix.config.arch }} path: artifact/ + + android: + name: Android ${{ matrix.arch }} + runs-on: ubuntu-20.04 + env: + ndk_version: "r25c" + ANDROID_NDK: ${{ github.workspace }}/android-ndk + strategy: + matrix: + arch: [armeabi-v7a, arm64-v8a, x86, x86_64] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install deps + run: | + sudo rm /var/lib/man-db/auto-update + sudo apt-get update + sudo apt-get install -qyy wget unzip zip gcc-multilib make cmake + + - name: Cache NDK + id: cache-ndk + uses: actions/cache@v3 + with: + key: android-ndk-${{ env.ndk_version }}-linux + path: ${{ env.ANDROID_NDK }} + + - name: Install NDK + run: | + wget --progress=bar:force "http://dl.google.com/android/repository/android-ndk-${ndk_version}-linux.zip" + unzip -q "android-ndk-${ndk_version}-linux.zip" + rm "android-ndk-${ndk_version}-linux.zip" + mv "android-ndk-${ndk_version}" "${ANDROID_NDK}" + if: ${{ steps.cache-ndk.outputs.cache-hit != 'true' }} + + - name: Build + run: ./scripts/ci-build-android.sh ${{ matrix.arch }} + + #- name: Upload Artifact + # uses: actions/upload-artifact@v3 + # with: + # name: irrlicht-android-${{ matrix.arch }} + # path: ${{ runner.temp }}/pkg/${{ matrix.arch }} diff --git a/scripts/ci-build-android.sh b/scripts/ci-build-android.sh new file mode 100755 index 0000000..a865e56 --- /dev/null +++ b/scripts/ci-build-android.sh @@ -0,0 +1,123 @@ +#!/bin/bash -e + +# NOTE: this code is mostly copied from minetest_android_deps +# + +png_ver=1.6.40 +jpeg_ver=3.0.1 + +download () { + get_tar_archive libpng "https://download.sourceforge.net/libpng/libpng-${png_ver}.tar.gz" + get_tar_archive libjpeg "https://download.sourceforge.net/libjpeg-turbo/libjpeg-turbo-${jpeg_ver}.tar.gz" +} + +build () { + # Build libjpg and libpng first because Irrlicht needs them + mkdir -p libpng + pushd libpng + $srcdir/libpng/configure --host=$CROSS_PREFIX + make && make DESTDIR=$PWD install + popd + + mkdir -p libjpeg + pushd libjpeg + cmake $srcdir/libjpeg "${CMAKE_FLAGS[@]}" -DENABLE_SHARED=OFF + make && make DESTDIR=$PWD install + popd + + local libpng=$PWD/libpng/usr/local/lib/libpng.a + local libjpeg=$(echo $PWD/libjpeg/opt/libjpeg-turbo/lib*/libjpeg.a) + cmake $srcdir/irrlicht "${CMAKE_FLAGS[@]}" \ + -DBUILD_SHARED_LIBS=OFF \ + -DPNG_LIBRARY=$libpng \ + -DPNG_PNG_INCLUDE_DIR=$(dirname "$libpng")/../include \ + -DJPEG_LIBRARY=$libjpeg \ + -DJPEG_INCLUDE_DIR=$(dirname "$libjpeg")/../include + make + + cp -p lib/Android/libIrrlichtMt.a $libpng $libjpeg $pkgdir/ + cp -a $srcdir/irrlicht/include $pkgdir/include + cp -a $srcdir/irrlicht/media/Shaders $pkgdir/Shaders +} + +get_tar_archive () { + # $1: folder to extract to, $2: URL + local filename="${2##*/}" + [ -d "$1" ] && return 0 + wget -c "$2" -O "$filename" + mkdir -p "$1" + tar -xaf "$filename" -C "$1" --strip-components=1 + rm "$filename" +} + +_setup_toolchain () { + local toolchain=$(echo "$ANDROID_NDK"/toolchains/llvm/prebuilt/*) + if [ ! -d "$toolchain" ]; then + echo "Android NDK path not specified or incorrect"; return 1 + fi + export PATH="$toolchain/bin:$ANDROID_NDK:$PATH" + + unset CFLAGS CPPFLAGS CXXFLAGS + + TARGET_ABI="$1" + API=21 + if [ "$TARGET_ABI" == armeabi-v7a ]; then + CROSS_PREFIX=armv7a-linux-androideabi + CFLAGS="-mthumb" + CXXFLAGS="-mthumb" + elif [ "$TARGET_ABI" == arm64-v8a ]; then + CROSS_PREFIX=aarch64-linux-android + elif [ "$TARGET_ABI" == x86 ]; then + CROSS_PREFIX=i686-linux-android + CFLAGS="-mssse3 -mfpmath=sse" + CXXFLAGS="-mssse3 -mfpmath=sse" + elif [ "$TARGET_ABI" == x86_64 ]; then + CROSS_PREFIX=x86_64-linux-android + else + echo "Invalid ABI given"; return 1 + fi + export CC=$CROSS_PREFIX$API-clang + export CXX=$CROSS_PREFIX$API-clang++ + export AR=llvm-ar + export RANLIB=llvm-ranlib + export CFLAGS="-fPIC ${CFLAGS}" + export CXXFLAGS="-fPIC ${CXXFLAGS}" + + CMAKE_FLAGS=( + "-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake" + "-DANDROID_ABI=$TARGET_ABI" "-DANDROID_NATIVE_API_LEVEL=$API" + "-DCMAKE_BUILD_TYPE=Release" + ) + + # make sure pkg-config doesn't interfere + export PKG_CONFIG=/bin/false + + export MAKEFLAGS="-j$(nproc)" +} + +_run_build () { + local abi=$1 + irrdir=$PWD + + mkdir -p $RUNNER_TEMP/src + cd $RUNNER_TEMP/src + srcdir=$PWD + [ -d irrlicht ] || ln -s $irrdir irrlicht + download + + builddir=$RUNNER_TEMP/build/irrlicht-$abi + pkgdir=$RUNNER_TEMP/pkg/$abi/Irrlicht + rm -rf "$pkgdir" + mkdir -p "$builddir" "$pkgdir" + + cd "$builddir" + build +} + +if [ $# -lt 1 ]; then + echo "Usage: ci-build-android.sh " + exit 1 +fi + +_setup_toolchain $1 +_run_build $1 From 4299ee21d8c0e4fb361e1042bda1a0a9ddbeb60e Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Mon, 22 Jan 2024 09:50:29 +0100 Subject: [PATCH 17/17] CMake: Move generator conditional expressions (#281) --- source/Irrlicht/CMakeLists.txt | 42 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/source/Irrlicht/CMakeLists.txt b/source/Irrlicht/CMakeLists.txt index f90728b..1a0ce7a 100644 --- a/source/Irrlicht/CMakeLists.txt +++ b/source/Irrlicht/CMakeLists.txt @@ -314,26 +314,6 @@ set(link_includes "$<$:${X11_INCLUDE_DIR}>" ) -set(link_libs - "${ZLIB_LIBRARY}" - "${JPEG_LIBRARY}" - "${PNG_LIBRARY}" - "$<$:${SDL2_LIBRARIES}>" - - "$<$:${OPENGL_LIBRARIES}>" - "$<$:${OPENGLES_LIBRARY}>" - "$<$:${OPENGLES2_LIBRARIES}>" - ${EGL_LIBRARY} - - "$<$:-landroid -llog>" - ${COCOA_LIB} - ${IOKIT_LIB} - "$<$:gdi32>" - "$<$:winmm>" - "$<$:${X11_X11_LIB}>" - "$<$:${X11_Xi_LIB}>" -) - # Source files set(IRRMESHLOADER @@ -533,7 +513,27 @@ target_include_directories(IrrlichtMt ${link_includes} ) -target_link_libraries(IrrlichtMt PRIVATE ${link_libs}) +# this needs to be here and not in a variable (like link_includes) due to issues +# with the generator expressions on at least CMake 3.22, but not 3.28 or later +target_link_libraries(IrrlichtMt PRIVATE + ${ZLIB_LIBRARY} + ${JPEG_LIBRARY} + ${PNG_LIBRARY} + "$<$:${SDL2_LIBRARIES}>" + + "$<$:${OPENGL_LIBRARIES}>" + "$<$:${OPENGLES_LIBRARY}>" + "$<$:${OPENGLES2_LIBRARIES}>" + ${EGL_LIBRARY} + + "$<$:-landroid -llog>" + ${COCOA_LIB} + ${IOKIT_LIB} + "$<$:gdi32>" + "$<$:winmm>" + "$<$:${X11_X11_LIB}>" + "$<$:${X11_Xi_LIB}>" +) if(WIN32) target_compile_definitions(IrrlichtMt INTERFACE _IRR_WINDOWS_API_) # used in _IRR_DEBUG_BREAK_IF definition in a public header