36 Commits

Author SHA1 Message Date
bdcd27ab5b Bump revision 2024-01-17 17:19:03 +01:00
345285786f Make vector comparison operators transitive 2024-01-17 17:09:46 +01:00
dda9b23c3d Make equals method symmetric 2024-01-17 17:09:46 +01:00
b349266855 Enable SDL to compile on macOS 2024-01-17 11:00:40 +01:00
ee2467d622 Remove some dead code 2024-01-16 23:59:46 +01:00
88ca26c418 Define extpointer for SDL + OGLES2 2024-01-16 20:23:23 +01:00
8f44270e4a Rip out compressed color formats 2024-01-16 20:23:23 +01:00
edc678f995 Update minimum CMake version 2024-01-16 18:48:30 +01:00
0faeea33c3 build.yml: Upgrade bionic/jammy -> focal (current oldest LTS) 2024-01-16 18:34:24 +01:00
f86b9b93e8 Fix crash when SDL context fails to create 2024-01-16 18:24:02 +01:00
a3ec3a88e8 Fix scene nodes not dropping meshes (memleak) 2024-01-13 18:13:04 +01:00
7df45b4cf3 SDL: Implement touchscreen support 2024-01-13 14:08:13 +01:00
a2b6244f54 Fix build with older SDL2 2024-01-08 23:51:34 +01:00
3983c29645 Optimize scene node child removal to constant time (#275) 2024-01-08 18:43:24 +01:00
73e62f8676 Keep RTTI for Minetest IPO/LTO
Minetest using RTTI, so we cannot apply the flag here
if we want to start using IPO/LTO.

If we keep `-fno-rtti` here, compiler loses part of informations and
cannot do efficient optimizations.

The benefit of using RTTI on Irrlicht disappears with IPO/LTO on whole binary.

Signed-off-by: David Heidelberg <david@ixit.cz>
2024-01-06 21:30:15 +01:00
fb4ee6ac93 Fix mip map size calculation for non-square textures
The size of a mip map is `max{floor(width / 2 ^ level), 1} x max{floor(height / 2 ^ level), 1}`,
where `width x height` is the size of the full-resolution image,
`level` is the integer mip map level
and the smallest mip map has `1 x 1` resolution.
If `regenerateMipMapLevels` is called with custom mip map data,
the mip map sizes are calculated in this function and separately in `uploadTexture`.
`uploadTexture` calculates a size by `floor(width / 2 ^ level) x floor(height / 2 ^ level)`.

To support non-square textures, after this change,
`uploadTexture` sets the mip map width or height to `1` if it is `0`.
2024-01-05 14:09:50 +01:00
91e4129615 Windows: Return early if the clipboard data is not Unicode text 2024-01-04 21:24:50 +01:00
54b82aad26 Add IrrlichtDevice::isWindowVisible for Android 2024-01-04 16:48:35 +01:00
03dd8b0336 Update vendored khrplatform.h 2023-12-19 22:56:31 +01:00
6e6b4a6f3c Fix some minor issues with GL loader
fixes #258
2023-12-19 22:56:31 +01:00
0110826ce9 Resync mt_opengl_loader.cpp with BindingGenerator.lua
also add a warning that you can't edit it by hand
2023-12-19 22:56:31 +01:00
4e52d547b2 MinGW toolchain refresh 2023-12-17 20:47:29 +01:00
9a439a3646 Use SDL2 by default
Except on Android and macOS, for now
2023-12-17 18:46:08 +01:00
854e97f57c Add size_t to u32/s32 static_casts in irrArray
This fixes 5 narrowing cast warnings from Visual Studio 17 2022.
2023-12-17 17:02:22 +01:00
22f2c37322 Add size_t to u32 static_casts to irrString
The irrString implementation doesn't allow constructing a string with a
size that would exceed a u32, so it should be safe to narrow the size of
the underlying STL container back to a u32.

This fixes 5 narrowing cast warnings from Visual Studio 17 2022.
2023-12-17 17:02:22 +01:00
94cb0cc19d Use KHRONOS_APIENTRY to fix win32 crash 2023-12-17 17:00:41 +01:00
9b52d6fb0d Hash-check windows CI dependencies 2023-12-13 12:17:54 +01:00
16a99c2079 Add a file to gitignore 2023-12-13 12:17:04 +01:00
bb7c06d32a Initialize X11 thread safety 2023-12-10 16:29:22 +01:00
a2884e4000 Android: Make ALooper_pollAll call always non-blocking (#255) 2023-11-30 15:52:04 +01:00
b284ea076b Use newer vcpkg in Windows CI 2023-11-30 15:43:24 +01:00
85081d6fe0 Fix off-by-one error in the TGA RLE decompressor 2023-11-01 14:40:11 +01:00
eafc282efd Add unit tests for image loaders 2023-11-01 14:40:11 +01:00
8c2ad025b1 Add CTest 2023-11-01 14:40:11 +01:00
a07cfc0f7a Require C++17 at the top level 2023-11-01 14:40:11 +01:00
f725b68c57 Remove irrUString.h
now unused
2023-10-31 10:10:31 +01:00
67 changed files with 600 additions and 4663 deletions

View File

@ -8,22 +8,23 @@ on:
jobs: jobs:
linux-gl: linux-gl:
runs-on: ubuntu-latest runs-on: ubuntu-20.04
container:
image: ubuntu:bionic
env: { LANG: "C.UTF-8" }
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install deps - name: Install deps
run: | run: |
apt-get update sudo apt-get update
apt-get install g++ cmake libxi-dev libgl1-mesa-dev libpng-dev libjpeg-dev zlib1g-dev -qyy sudo apt-get install g++ cmake libxi-dev libgl1-mesa-dev libpng-dev libjpeg-dev zlib1g-dev -qyy
- name: Build - name: Build
run: | run: |
cmake . cmake . -DUSE_SDL2=OFF
make VERBOSE=1 -j2 make VERBOSE=1 -j2
- name: Test
run: |
ctest --output-on-failure
- name: Package - name: Package
run: | run: |
make DESTDIR=$PWD/_install install make DESTDIR=$PWD/_install install
@ -35,20 +36,18 @@ jobs:
path: ./irrlicht-linux.tar.gz path: ./irrlicht-linux.tar.gz
linux-gles: linux-gles:
runs-on: ubuntu-latest # Xvfb test is broken on 20.04 for unknown reasons (not our bug)
container: runs-on: ubuntu-22.04
image: ubuntu:bionic
env: { LANG: "C.UTF-8" }
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install deps - name: Install deps
run: | run: |
apt-get update sudo apt-get update
apt-get install g++ cmake libxi-dev libgles2-mesa-dev libpng-dev libjpeg-dev zlib1g-dev xvfb -qyy sudo apt-get install g++ cmake libxi-dev libgles2-mesa-dev libpng-dev libjpeg-dev zlib1g-dev xvfb -qyy
- name: Build - name: Build
run: | run: |
cmake . -DBUILD_EXAMPLES=1 -DENABLE_OPENGL=OFF -DENABLE_GLES2=ON cmake . -DBUILD_EXAMPLES=1 -DUSE_SDL2=OFF -DENABLE_OPENGL=OFF -DENABLE_GLES2=ON
make -j2 make -j2
- name: Test (headless) - name: Test (headless)
@ -62,16 +61,13 @@ jobs:
LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest ogles2 LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest ogles2
linux-sdl: linux-sdl:
runs-on: ubuntu-latest runs-on: ubuntu-20.04
container:
image: ubuntu:jammy
env: { LANG: "C.UTF-8" }
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install deps - name: Install deps
run: | run: |
apt-get update sudo apt-get update
apt-get install g++ cmake libsdl2-dev libpng-dev libjpeg-dev zlib1g-dev -qyy sudo apt-get install g++ cmake libsdl2-dev libpng-dev libjpeg-dev zlib1g-dev -qyy
- name: Build - name: Build
run: | run: |
@ -84,16 +80,14 @@ jobs:
./AutomatedTest null ./AutomatedTest null
linux-sdl-gl3: linux-sdl-gl3:
runs-on: ubuntu-latest # Xvfb test is broken on 20.04 for unknown reasons (not our bug)
container: runs-on: ubuntu-22.04
image: ubuntu:jammy
env: { LANG: "C.UTF-8" }
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install deps - name: Install deps
run: | run: |
apt-get update sudo apt-get update
apt-get install g++ cmake libsdl2-dev libpng-dev libjpeg-dev zlib1g-dev xvfb -qyy sudo apt-get install g++ cmake libsdl2-dev libpng-dev libjpeg-dev zlib1g-dev xvfb -qyy
- name: Build - name: Build
run: | run: |
@ -111,16 +105,13 @@ jobs:
LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest opengl3 LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest opengl3
linux-sdl-gles2: linux-sdl-gles2:
runs-on: ubuntu-latest runs-on: ubuntu-20.04
container:
image: ubuntu:jammy
env: { LANG: "C.UTF-8" }
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install deps - name: Install deps
run: | run: |
apt-get update sudo apt-get update
apt-get install g++ cmake libsdl2-dev libpng-dev libjpeg-dev zlib1g-dev xvfb -qyy sudo apt-get install g++ cmake libsdl2-dev libpng-dev libjpeg-dev zlib1g-dev xvfb -qyy
- name: Build - name: Build
run: | run: |
@ -139,7 +130,7 @@ jobs:
mingw: mingw:
name: "MinGW ${{matrix.config.variant}}${{matrix.config.extras}}" name: "MinGW ${{matrix.config.variant}}${{matrix.config.extras}}"
runs-on: ubuntu-20.04 runs-on: ubuntu-22.04
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -153,8 +144,7 @@ jobs:
- name: Install compiler - name: Install compiler
run: | run: |
sudo apt-get update && sudo apt-get install cmake -qyy sudo apt-get update && sudo apt-get install cmake -qyy
wget http://minetest.kitsunemimi.pw/mingw-w64-${{matrix.config.arch}}_11.2.0_ubuntu20.04.tar.xz -O mingw.tar.xz ./scripts/ci-get-mingw.sh ${{matrix.config.arch}}
sudo tar -xaf mingw.tar.xz -C /usr
- name: Build - name: Build
run: | run: |
@ -187,12 +177,26 @@ jobs:
run: | run: |
./bin/OSX/AutomatedTest null ./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: msvc:
name: VS 2019 ${{ matrix.config.arch }} ${{ matrix.sdl.label }} name: VS 2019 ${{ matrix.config.arch }} ${{ matrix.sdl.label }}
runs-on: windows-2019 runs-on: windows-2019
env: env:
VCPKG_VERSION: 14e7bb4ae24616ec54ff6b2f6ef4e8659434ea44 VCPKG_VERSION: 8eb57355a4ffb410a2e94c07b4dca2dffbee8e50
# 2022.05.10 # 2023.10.19
vcpkg_packages: zlib libpng libjpeg-turbo opengl-registry vcpkg_packages: zlib libpng libjpeg-turbo opengl-registry
strategy: strategy:
fail-fast: false fail-fast: false

1
.gitignore vendored
View File

@ -5,6 +5,7 @@ install_manifest.txt
IrrlichtMtConfig.cmake IrrlichtMtConfig.cmake
IrrlichtMtConfigVersion.cmake IrrlichtMtConfigVersion.cmake
IrrlichtMtTargets.cmake IrrlichtMtTargets.cmake
CTestTestfile.cmake
Makefile Makefile
libs/* libs/*
*.so* *.so*

View File

@ -1,13 +1,6 @@
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.12)
# >=3.9 enables IPO; >=3.11 prefers GLVND set(IRRLICHTMT_REVISION 14)
if(${CMAKE_VERSION} VERSION_LESS 3.11)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
else()
cmake_policy(VERSION 3.11)
endif()
set(IRRLICHTMT_REVISION 13)
project(Irrlicht project(Irrlicht
VERSION 1.9.0.${IRRLICHTMT_REVISION} VERSION 1.9.0.${IRRLICHTMT_REVISION}
@ -16,6 +9,9 @@ project(Irrlicht
message(STATUS "*** Building IrrlichtMt ${PROJECT_VERSION} ***") message(STATUS "*** Building IrrlichtMt ${PROJECT_VERSION} ***")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(GNUInstallDirs) include(GNUInstallDirs)
if(ANDROID) if(ANDROID)
@ -38,7 +34,9 @@ if(NOT CMAKE_BUILD_TYPE)
endif() endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
enable_testing()
add_subdirectory(source/Irrlicht) add_subdirectory(source/Irrlicht)
add_subdirectory(test)
option(BUILD_EXAMPLES "Build example applications" FALSE) option(BUILD_EXAMPLES "Build example applications" FALSE)
if(BUILD_EXAMPLES) if(BUILD_EXAMPLES)

View File

@ -1,6 +1,3 @@
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(IRREXAMPLES set(IRREXAMPLES
# removed # removed
) )

View File

@ -121,21 +121,6 @@ namespace video
//! Support for texture coord transformation via texture matrix //! Support for texture coord transformation via texture matrix
EVDF_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. //! Support for cube map textures.
EVDF_TEXTURE_CUBEMAP, EVDF_TEXTURE_CUBEMAP,

View File

@ -362,28 +362,6 @@ public:
return 24; return 24;
case ECF_A8R8G8B8: case ECF_A8R8G8B8:
return 32; 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: case ECF_D16:
return 16; return 16;
case ECF_D32: case ECF_D32:
@ -418,75 +396,18 @@ public:
//! calculate image data size in bytes for selected format, width and height. //! calculate image data size in bytes for selected format, width and height.
static u32 getDataSizeFromFormat(ECOLOR_FORMAT format, u32 width, u32 height) static u32 getDataSizeFromFormat(ECOLOR_FORMAT format, u32 width, u32 height)
{ {
u32 imageSize = 0; // non-compressed formats
u32 imageSize = getBitsPerPixelFromFormat(format) / 8 * width;
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_<u32>(width, 16) * core::max_<u32>(height, 8) * 2 + 7) / 8;
break;
case ECF_PVRTC_RGB4:
case ECF_PVRTC_ARGB4:
imageSize = (core::max_<u32>(width, 8) * core::max_<u32>(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; imageSize *= height;
break;
}
return imageSize; 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 //! check if this is compressed color format
static bool isCompressedFormat(const ECOLOR_FORMAT 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 //! check if the color format is only viable for depth/stencil textures
static bool isDepthFormat(const ECOLOR_FORMAT format) static bool isDepthFormat(const ECOLOR_FORMAT format)
@ -523,22 +444,6 @@ public:
return false; 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: protected:
ECOLOR_FORMAT Format; ECOLOR_FORMAT Format;
core::dimension2d<u32> Size; core::dimension2d<u32> Size;

View File

@ -15,6 +15,7 @@
#include "matrix4.h" #include "matrix4.h"
#include "IAttributes.h" #include "IAttributes.h"
#include <list> #include <list>
#include <optional>
namespace irr namespace irr
{ {
@ -275,33 +276,33 @@ namespace scene
child->grab(); child->grab();
child->remove(); // remove from old parent child->remove(); // remove from old parent
Children.push_back(child); // Note: This iterator is not invalidated until we erase it.
child->ThisIterator = Children.insert(Children.end(), child);
child->Parent = this; child->Parent = this;
} }
} }
//! Removes a child from this scene node. //! Removes a child from this scene node.
/** If found in the children list, the child pointer is also /**
dropped and might be deleted if no other grab exists.
\param child A pointer to the child which shall be removed. \param child A pointer to the child which shall be removed.
\return True if the child was removed, and false if not, \return True if the child was removed, and false if not,
e.g. because it couldn't be found in the children list. */ e.g. because it belongs to a different parent or no parent. */
virtual bool removeChild(ISceneNode* child) virtual bool removeChild(ISceneNode* child)
{ {
ISceneNodeList::iterator it = Children.begin(); if (child->Parent != this)
for (; it != Children.end(); ++it) return false;
if ((*it) == child)
{ // The iterator must be set since the parent is not null.
(*it)->Parent = 0; _IRR_DEBUG_BREAK_IF(!child->ThisIterator.has_value());
(*it)->drop(); auto it = *child->ThisIterator;
child->ThisIterator = std::nullopt;
child->Parent = nullptr;
child->drop();
Children.erase(it); Children.erase(it);
return true; return true;
} }
return false;
}
//! Removes all children of this scene node //! Removes all children of this scene node
/** The scene nodes found in the children list are also dropped /** The scene nodes found in the children list are also dropped
@ -309,13 +310,11 @@ namespace scene
*/ */
virtual void removeAll() virtual void removeAll()
{ {
ISceneNodeList::iterator it = Children.begin(); for (auto &child : Children) {
for (; it != Children.end(); ++it) child->Parent = nullptr;
{ child->ThisIterator = std::nullopt;
(*it)->Parent = 0; child->drop();
(*it)->drop();
} }
Children.clear(); Children.clear();
} }
@ -508,10 +507,8 @@ namespace scene
grab(); grab();
remove(); remove();
Parent = newParent; if (newParent)
newParent->addChild(this);
if (Parent)
Parent->addChild(this);
drop(); drop();
} }
@ -618,12 +615,15 @@ namespace scene
//! Relative scale of the scene node. //! Relative scale of the scene node.
core::vector3df RelativeScale; core::vector3df RelativeScale;
//! Pointer to the parent
ISceneNode* Parent;
//! List of all children of this node //! List of all children of this node
std::list<ISceneNode*> Children; std::list<ISceneNode*> Children;
//! Iterator pointing to this node in the parent's child list.
std::optional<ISceneNodeList::iterator> ThisIterator;
//! Pointer to the parent
ISceneNode* Parent;
//! Pointer to the scene manager //! Pointer to the scene manager
ISceneManager* SceneManager; ISceneManager* SceneManager;

View File

@ -292,11 +292,6 @@ public:
{ {
case ECF_A8R8G8B8: case ECF_A8R8G8B8:
case ECF_A1R5G5B5: case ECF_A1R5G5B5:
case ECF_DXT1:
case ECF_DXT2:
case ECF_DXT3:
case ECF_DXT4:
case ECF_DXT5:
case ECF_A16B16G16R16F: case ECF_A16B16G16R16F:
case ECF_A32B32G32R32F: case ECF_A32B32G32R32F:
status = true; status = true;

View File

@ -5,8 +5,8 @@
#pragma once #pragma once
//! Identifies the IrrlichtMt fork customized for the Minetest engine //! Identifies the IrrlichtMt fork customized for the Minetest engine
#define IRRLICHT_VERSION_MT_REVISION 13 #define IRRLICHT_VERSION_MT_REVISION 14
#define IRRLICHT_VERSION_MT "mt13" #define IRRLICHT_VERSION_MT "mt14"
//! Irrlicht SDK Version //! Irrlicht SDK Version
#define IRRLICHT_VERSION_MAJOR 1 #define IRRLICHT_VERSION_MAJOR 1

View File

@ -177,6 +177,10 @@ namespace irr
/** \return True if window is fullscreen. */ /** \return True if window is fullscreen. */
virtual bool isFullscreen() const = 0; 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.
virtual bool isWindowVisible() const { return true; };
//! Get the current color format of the window //! Get the current color format of the window
/** \return Color format of the window. */ /** \return Color format of the window. */
virtual video::ECOLOR_FORMAT getColorFormat() const = 0; virtual video::ECOLOR_FORMAT getColorFormat() const = 0;

View File

@ -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) //! Warning: This tends to be BGRA in memory (it's ARGB on file, but with usual big-endian memory it's flipped)
ECF_A8R8G8B8, 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. */ /** The following formats may only be used for render target textures. */
/** Floating point formats. */ /** Floating point formats. */
@ -139,20 +95,6 @@ namespace video
"R5G6B5", "R5G6B5",
"R8G8B8", "R8G8B8",
"A8R8G8B8", "A8R8G8B8",
"DXT1",
"DXT2",
"DXT3",
"DXT4",
"DXT5",
"PVRTC_RGB2",
"PVRTC_ARGB2",
"PVRTC_RGB4",
"PVRTC_ARGB4",
"PVRTC2_ARGB2",
"PVRTC2_ARGB4",
"ETC1",
"ETC2_RGB",
"ETC2_ARGB",
"R16F", "R16F",
"G16R16F", "G16R16F",
"A16B16G16R16F", "A16B16G16R16F",

View File

@ -241,7 +241,7 @@ public:
/** \return Size of elements in the array which are actually occupied. */ /** \return Size of elements in the array which are actually occupied. */
u32 size() const u32 size() const
{ {
return m_data.size(); return static_cast<u32>(m_data.size());
} }
@ -317,7 +317,7 @@ public:
// *it = first element in [first, last) that is >= element, or last if not found. // *it = first element in [first, last) that is >= element, or last if not found.
if (*it < element || element < *it) if (*it < element || element < *it)
return -1; return -1;
return it - m_data.begin(); return static_cast<u32>(it - m_data.begin());
} }
@ -335,8 +335,8 @@ public:
auto iters = std::equal_range(m_data.begin(), m_data.end(), element); auto iters = std::equal_range(m_data.begin(), m_data.end(), element);
if (iters.first == iters.second) if (iters.first == iters.second)
return -1; return -1;
last = (iters.second - m_data.begin()) - 1; last = static_cast<s32>((iters.second - m_data.begin()) - 1);
return iters.first - m_data.begin(); return static_cast<s32>(iters.first - m_data.begin());
} }
@ -351,7 +351,7 @@ public:
auto it = std::find(m_data.begin(), m_data.end(), element); auto it = std::find(m_data.begin(), m_data.end(), element);
if (it == m_data.end()) if (it == m_data.end())
return -1; return -1;
return it - m_data.begin(); return static_cast<u32>(it - m_data.begin());
} }

View File

@ -9,6 +9,7 @@
#include <float.h> #include <float.h>
#include <stdlib.h> // for abs() etc. #include <stdlib.h> // for abs() etc.
#include <limits.h> // For INT_MAX / UINT_MAX #include <limits.h> // For INT_MAX / UINT_MAX
#include <type_traits>
namespace irr namespace irr
{ {
@ -17,9 +18,6 @@ namespace core
//! Rounding error constant often used when comparing f32 values. //! 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 f32 ROUNDING_ERROR_f32 = 0.000001f;
const f64 ROUNDING_ERROR_f64 = 0.00000001; const f64 ROUNDING_ERROR_f64 = 0.00000001;
@ -170,30 +168,6 @@ namespace core
return ROUNDING_ERROR_f64; 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 <class T> template <class T>
inline T relativeErrorFactor() inline T relativeErrorFactor()
{ {
@ -212,13 +186,19 @@ namespace core
return 8; return 8;
} }
//! returns if a equals b, taking possible rounding errors into account //! returns if a equals b, for types without rounding errors
template <class T> template <class T, std::enable_if_t<std::is_integral<T>::value, bool> = true>
inline bool equals(const T a, const T b, const T tolerance = roundingError<T>()) 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 <class T, std::enable_if_t<std::is_floating_point<T>::value, bool> = true>
inline bool equals(const T a, const T b, const T tolerance = roundingError<T>())
{
return abs(a - b) <= tolerance;
}
//! returns if a equals b, taking relative error in form of factor //! returns if a equals b, taking relative error in form of factor
//! this particular function does not involve any division. //! this particular function does not involve any division.

View File

@ -266,7 +266,7 @@ public:
the trailing NUL. */ the trailing NUL. */
u32 size() const u32 size() const
{ {
return str.size(); return static_cast<u32>(str.size());
} }
//! Informs if the string is empty or not. //! Informs if the string is empty or not.
@ -834,7 +834,7 @@ public:
if (!delimiter) if (!delimiter)
return 0; return 0;
const u32 oldSize=ret.size(); const u32 oldSize=static_cast<u32>(ret.size());
u32 tokenStartIdx = 0; u32 tokenStartIdx = 0;
for (u32 i=0; i<size()+1; ++i) for (u32 i=0; i<size()+1; ++i)
@ -862,7 +862,7 @@ public:
else if (!ignoreEmptyTokens) else if (!ignoreEmptyTokens)
ret.push_back(string<T>()); ret.push_back(string<T>());
return ret.size()-oldSize; return static_cast<u32>(ret.size()-oldSize);
} }
// This function should not be used and is only kept for "CGUIFileOpenDialog::pathToStringW". // This function should not be used and is only kept for "CGUIFileOpenDialog::pathToStringW".
@ -888,10 +888,10 @@ private:
return len; return len;
} }
static inline u32 calclen(const char* p) { static inline u32 calclen(const char* p) {
return strlen(p); return static_cast<u32>(strlen(p));
} }
static inline u32 calclen(const wchar_t* p) { static inline u32 calclen(const wchar_t* p) {
return wcslen(p); return static_cast<u32>(wcslen(p));
} }
//! strcmp wrapper //! strcmp wrapper

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@
#include <KHR/khrplatform.h> #include <KHR/khrplatform.h>
#ifndef APIENTRY #ifndef APIENTRY
#define APIENTRY #define APIENTRY KHRONOS_APIENTRY
#endif #endif
#ifndef APIENTRYP #ifndef APIENTRYP
#define APIENTRYP APIENTRY * #define APIENTRYP APIENTRY *
@ -705,7 +705,6 @@ private:
typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC_MT) (GLenum mode, const void * indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC_MT) (GLenum mode, const void * indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride);
typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC_MT) (GLenum mode, GLenum type, const void * indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC_MT) (GLenum mode, GLenum type, const void * indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride);
typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPPROC_MT) (GLfloat factor, GLfloat units, GLfloat clamp); typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPPROC_MT) (GLfloat factor, GLfloat units, GLfloat clamp);
typedef void (APIENTRYP PFNGLGENPERFMONITORSEXPROC_MT) (GLsizei n, GLuint * monitors);
typedef void (APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXPROC_MT) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); typedef void (APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXPROC_MT) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW);
typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEPROC_MT) (GLuint texture); typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEPROC_MT) (GLuint texture);
typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEPROC_MT) (GLuint texture, GLuint sampler); typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEPROC_MT) (GLuint texture, GLuint sampler);
@ -781,9 +780,9 @@ public:
// Call this once after creating the context. // Call this once after creating the context.
void LoadAllProcedures(irr::video::IContextManager *cmgr); void LoadAllProcedures(irr::video::IContextManager *cmgr);
// Check if an extension is supported. // Check if an extension is supported.
inline bool IsExtensionPresent(const std::string &ext) inline bool IsExtensionPresent(const std::string &ext) const
{ {
return extensions.find(ext) != extensions.end(); return extensions.count(ext) > 0;
} }
PFNGLCULLFACEPROC_MT CullFace = NULL; PFNGLCULLFACEPROC_MT CullFace = NULL;
@ -1436,7 +1435,6 @@ public:
PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC_MT MultiDrawArraysIndirectCount = NULL; PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC_MT MultiDrawArraysIndirectCount = NULL;
PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC_MT MultiDrawElementsIndirectCount = NULL; PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC_MT MultiDrawElementsIndirectCount = NULL;
PFNGLPOLYGONOFFSETCLAMPPROC_MT PolygonOffsetClamp = NULL; PFNGLPOLYGONOFFSETCLAMPPROC_MT PolygonOffsetClamp = NULL;
PFNGLGENPERFMONITORSEXPROC_MT GenPerfMonitorsEX = NULL;
PFNGLPRIMITIVEBOUNDINGBOXPROC_MT PrimitiveBoundingBox = NULL; PFNGLPRIMITIVEBOUNDINGBOXPROC_MT PrimitiveBoundingBox = NULL;
PFNGLGETTEXTUREHANDLEPROC_MT GetTextureHandle = NULL; PFNGLGETTEXTUREHANDLEPROC_MT GetTextureHandle = NULL;
PFNGLGETTEXTURESAMPLERHANDLEPROC_MT GetTextureSamplerHandle = NULL; PFNGLGETTEXTURESAMPLERHANDLEPROC_MT GetTextureSamplerHandle = NULL;
@ -3020,6 +3018,16 @@ public:
static constexpr const GLenum TEXTURE_SRGB_DECODE = 0x8A48; static constexpr const GLenum TEXTURE_SRGB_DECODE = 0x8A48;
static constexpr const GLenum DECODE = 0x8A49; static constexpr const GLenum DECODE = 0x8A49;
static constexpr const GLenum SKIP_DECODE = 0x8A4A; static constexpr const GLenum SKIP_DECODE = 0x8A4A;
static constexpr const GLenum ALPHA8 = 0x803C;
static constexpr const GLenum LUMINANCE8 = 0x8040;
static constexpr const GLenum LUMINANCE8_ALPHA8 = 0x8045;
static constexpr const GLenum ALPHA32F = 0x8816;
static constexpr const GLenum LUMINANCE32F = 0x8818;
static constexpr const GLenum LUMINANCE_ALPHA32F = 0x8819;
static constexpr const GLenum ALPHA16F = 0x881C;
static constexpr const GLenum LUMINANCE16F = 0x881E;
static constexpr const GLenum LUMINANCE_ALPHA16F = 0x881F;
static constexpr const GLenum BGRA8 = 0x93A1;
static constexpr const GLenum INCLUSIVE = 0x8F10; static constexpr const GLenum INCLUSIVE = 0x8F10;
static constexpr const GLenum EXCLUSIVE = 0x8F11; static constexpr const GLenum EXCLUSIVE = 0x8F11;
static constexpr const GLenum WINDOW_RECTANGLE = 0x8F12; static constexpr const GLenum WINDOW_RECTANGLE = 0x8F12;
@ -3044,10 +3052,7 @@ public:
static constexpr const GLenum GEOMETRY_LINKED_VERTICES_OUT = 0x8916; static constexpr const GLenum GEOMETRY_LINKED_VERTICES_OUT = 0x8916;
static constexpr const GLenum GEOMETRY_LINKED_INPUT_TYPE = 0x8917; static constexpr const GLenum GEOMETRY_LINKED_INPUT_TYPE = 0x8917;
static constexpr const GLenum GEOMETRY_LINKED_OUTPUT_TYPE = 0x8918; static constexpr const GLenum GEOMETRY_LINKED_OUTPUT_TYPE = 0x8918;
static constexpr const GLenum ALPHA8 = 0x803C;
static constexpr const GLenum LUMINANCE4_ALPHA4 = 0x8043; static constexpr const GLenum LUMINANCE4_ALPHA4 = 0x8043;
static constexpr const GLenum LUMINANCE8_ALPHA8 = 0x8045;
static constexpr const GLenum LUMINANCE8 = 0x8040;
static constexpr const GLenum FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET = 0x8CD4; static constexpr const GLenum FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET = 0x8CD4;
static constexpr const GLenum COMPRESSED_RGBA_ASTC_3x3x3 = 0x93C0; static constexpr const GLenum COMPRESSED_RGBA_ASTC_3x3x3 = 0x93C0;
static constexpr const GLenum COMPRESSED_RGBA_ASTC_4x3x3 = 0x93C1; static constexpr const GLenum COMPRESSED_RGBA_ASTC_4x3x3 = 0x93C1;
@ -3070,7 +3075,6 @@ public:
static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5 = 0x93E8; static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5 = 0x93E8;
static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6 = 0x93E9; static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6 = 0x93E9;
static constexpr const GLenum INT_10_10_10_2 = 0x8DF7; static constexpr const GLenum INT_10_10_10_2 = 0x8DF7;
static constexpr const GLenum BGRA8 = 0x93A1;
static constexpr const GLenum MALI_PROGRAM_BINARY_ARM = 0x8F61; static constexpr const GLenum MALI_PROGRAM_BINARY_ARM = 0x8F61;
static constexpr const GLenum MALI_SHADER_BINARY_ARM = 0x8F60; static constexpr const GLenum MALI_SHADER_BINARY_ARM = 0x8F60;
static constexpr const GLenum FETCH_PER_SAMPLE_ARM = 0x8F65; static constexpr const GLenum FETCH_PER_SAMPLE_ARM = 0x8F65;
@ -3080,8 +3084,37 @@ public:
static constexpr const GLenum SMAPHS_PROGRAM_BINARY_DMP = 0x9252; static constexpr const GLenum SMAPHS_PROGRAM_BINARY_DMP = 0x9252;
static constexpr const GLenum DMP_PROGRAM_BINARY_DMP = 0x9253; static constexpr const GLenum DMP_PROGRAM_BINARY_DMP = 0x9253;
static constexpr const GLenum SHADER_BINARY_DMP = 0x9250; static constexpr const GLenum SHADER_BINARY_DMP = 0x9250;
static constexpr const GLenum SURFACE_COMPRESSION = 0x96C0;
static constexpr const GLenum SURFACE_COMPRESSION_FIXED_RATE_NONE = 0x96C1;
static constexpr const GLenum SURFACE_COMPRESSION_FIXED_RATE_DEFAULT = 0x96C2;
static constexpr const GLenum SAMPLER_EXTERNAL_2D_Y2Y = 0x8BE7; static constexpr const GLenum SAMPLER_EXTERNAL_2D_Y2Y = 0x8BE7;
static constexpr const GLenum GPU_DISJOINT = 0x8FBB; static constexpr const GLenum GPU_DISJOINT = 0x8FBB;
static constexpr const GLenum SHADING_RATE_1X1_PIXELS = 0x96A6;
static constexpr const GLenum SHADING_RATE_1X2_PIXELS = 0x96A7;
static constexpr const GLenum SHADING_RATE_2X1_PIXELS = 0x96A8;
static constexpr const GLenum SHADING_RATE_2X2_PIXELS = 0x96A9;
static constexpr const GLenum SHADING_RATE_1X4_PIXELS = 0x96AA;
static constexpr const GLenum SHADING_RATE_4X1_PIXELS = 0x96AB;
static constexpr const GLenum SHADING_RATE_4X2_PIXELS = 0x96AC;
static constexpr const GLenum SHADING_RATE_2X4_PIXELS = 0x96AD;
static constexpr const GLenum SHADING_RATE_4X4_PIXELS = 0x96AE;
static constexpr const GLenum SHADING_RATE = 0x96D0;
static constexpr const GLenum SHADING_RATE_ATTACHMENT = 0x96D1;
static constexpr const GLenum FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP = 0x96D2;
static constexpr const GLenum FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE = 0x96D3;
static constexpr const GLenum FRAGMENT_SHADING_RATE_COMBINER_OP_MIN = 0x96D4;
static constexpr const GLenum FRAGMENT_SHADING_RATE_COMBINER_OP_MAX = 0x96D5;
static constexpr const GLenum FRAGMENT_SHADING_RATE_COMBINER_OP_MUL = 0x96D6;
static constexpr const GLenum MIN_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_WIDTH = 0x96D7;
static constexpr const GLenum MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_WIDTH = 0x96D8;
static constexpr const GLenum MIN_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_HEIGHT = 0x96D9;
static constexpr const GLenum MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_HEIGHT = 0x96DA;
static constexpr const GLenum MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_ASPECT_RATIO = 0x96DB;
static constexpr const GLenum MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_LAYERS = 0x96DC;
static constexpr const GLenum FRAGMENT_SHADING_RATE_WITH_SHADER_DEPTH_STENCIL_WRITES_SUPPORTED = 0x96DD;
static constexpr const GLenum FRAGMENT_SHADING_RATE_WITH_SAMPLE_MASK_SUPPORTED = 0x96DE;
static constexpr const GLenum FRAGMENT_SHADING_RATE_ATTACHMENT_WITH_DEFAULT_FRAMEBUFFER_SUPPORTED = 0x96DF;
static constexpr const GLenum FRAGMENT_SHADING_RATE_NON_TRIVIAL_COMBINERS_SUPPORTED = 0x8F6F;
static constexpr const GLenum TEXTURE_TILING = 0x9580; static constexpr const GLenum TEXTURE_TILING = 0x9580;
static constexpr const GLenum DEDICATED_MEMORY_OBJECT = 0x9581; static constexpr const GLenum DEDICATED_MEMORY_OBJECT = 0x9581;
static constexpr const GLenum PROTECTED_MEMORY_OBJECT = 0x959B; static constexpr const GLenum PROTECTED_MEMORY_OBJECT = 0x959B;
@ -3136,12 +3169,19 @@ public:
static constexpr const GLenum COMPRESSED_SRGB_ALPHA_S3TC_DXT3 = 0x8C4E; static constexpr const GLenum COMPRESSED_SRGB_ALPHA_S3TC_DXT3 = 0x8C4E;
static constexpr const GLenum COMPRESSED_SRGB_ALPHA_S3TC_DXT5 = 0x8C4F; static constexpr const GLenum COMPRESSED_SRGB_ALPHA_S3TC_DXT5 = 0x8C4F;
static constexpr const GLenum TEXTURE_FORMAT_SRGB_OVERRIDE = 0x8FBF; static constexpr const GLenum TEXTURE_FORMAT_SRGB_OVERRIDE = 0x8FBF;
static constexpr const GLenum ALPHA32F = 0x8816; static constexpr const GLenum NUM_SURFACE_COMPRESSION_FIXED_RATES = 0x8F6E;
static constexpr const GLenum LUMINANCE32F = 0x8818; static constexpr const GLenum SURFACE_COMPRESSION_FIXED_RATE_1BPC = 0x96C4;
static constexpr const GLenum LUMINANCE_ALPHA32F = 0x8819; static constexpr const GLenum SURFACE_COMPRESSION_FIXED_RATE_2BPC = 0x96C5;
static constexpr const GLenum ALPHA16F = 0x881C; static constexpr const GLenum SURFACE_COMPRESSION_FIXED_RATE_3BPC = 0x96C6;
static constexpr const GLenum LUMINANCE16F = 0x881E; static constexpr const GLenum SURFACE_COMPRESSION_FIXED_RATE_4BPC = 0x96C7;
static constexpr const GLenum LUMINANCE_ALPHA16F = 0x881F; static constexpr const GLenum SURFACE_COMPRESSION_FIXED_RATE_5BPC = 0x96C8;
static constexpr const GLenum SURFACE_COMPRESSION_FIXED_RATE_6BPC = 0x96C9;
static constexpr const GLenum SURFACE_COMPRESSION_FIXED_RATE_7BPC = 0x96CA;
static constexpr const GLenum SURFACE_COMPRESSION_FIXED_RATE_8BPC = 0x96CB;
static constexpr const GLenum SURFACE_COMPRESSION_FIXED_RATE_9BPC = 0x96CC;
static constexpr const GLenum SURFACE_COMPRESSION_FIXED_RATE_10BPC = 0x96CD;
static constexpr const GLenum SURFACE_COMPRESSION_FIXED_RATE_11BPC = 0x96CE;
static constexpr const GLenum SURFACE_COMPRESSION_FIXED_RATE_12BPC = 0x96CF;
static constexpr const GLenum GCCSO_SHADER_BINARY_FJ = 0x9260; static constexpr const GLenum GCCSO_SHADER_BINARY_FJ = 0x9260;
static constexpr const GLenum STATE_RESTORE = 0x8BDC; static constexpr const GLenum STATE_RESTORE = 0x8BDC;
static constexpr const GLenum SHADER_BINARY_VIV = 0x8FC4; static constexpr const GLenum SHADER_BINARY_VIV = 0x8FC4;
@ -3151,5 +3191,5 @@ public:
static constexpr const GLenum NONE = 0; static constexpr const GLenum NONE = 0;
}; };
//Global GL procedures object. // Global GL procedures object.
IRRLICHT_API extern OpenGLProcedures GL; IRRLICHT_API extern OpenGLProcedures GL;

View File

@ -75,47 +75,47 @@ public:
return *(&X+index); return *(&X+index);
} }
//! sort in order X, Y. Equality with rounding tolerance. //! sort in order X, Y.
bool operator<=(const vector2d<T>&other) const bool operator<=(const vector2d<T>&other) const
{ {
return (X<other.X || core::equals(X, other.X)) || return !(*this > other);
(core::equals(X, other.X) && (Y<other.Y || core::equals(Y, other.Y)));
} }
//! sort in order X, Y. Equality with rounding tolerance. //! sort in order X, Y.
bool operator>=(const vector2d<T>&other) const bool operator>=(const vector2d<T>&other) const
{ {
return (X>other.X || core::equals(X, other.X)) || return !(*this < other);
(core::equals(X, other.X) && (Y>other.Y || core::equals(Y, other.Y)));
} }
//! sort in order X, Y. Difference must be above rounding tolerance. //! sort in order X, Y.
bool operator<(const vector2d<T>&other) const bool operator<(const vector2d<T>&other) const
{ {
return (X<other.X && !core::equals(X, other.X)) || return X < other.X || (X == other.X && Y < other.Y);
(core::equals(X, other.X) && Y<other.Y && !core::equals(Y, other.Y));
} }
//! sort in order X, Y. Difference must be above rounding tolerance. //! sort in order X, Y.
bool operator>(const vector2d<T>&other) const bool operator>(const vector2d<T>&other) const
{ {
return (X>other.X && !core::equals(X, other.X)) || return X > other.X || (X == other.X && Y > other.Y);
(core::equals(X, other.X) && Y>other.Y && !core::equals(Y, other.Y));
} }
bool operator==(const vector2d<T>& other) const { return equals(other); } bool operator==(const vector2d<T>& other) const {
bool operator!=(const vector2d<T>& other) const { return !equals(other); } return X == other.X && Y == other.Y;
}
bool operator!=(const vector2d<T>& other) const {
return !(*this == other);
}
// functions // functions
//! Checks if this vector equals the other one. //! Checks if this vector equals the other one.
/** Takes floating point rounding errors into account. /** Takes floating point rounding errors into account.
\param other Vector to compare with. \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. */ \return True if the two vector are (almost) equal, else false. */
bool equals(const vector2d<T>& other, const T tolerance = (T)ROUNDING_ERROR_f32 ) const bool equals(const vector2d<T>& 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<T>& set(T nx, T ny) {X=nx; Y=ny; return *this; } vector2d<T>& set(T nx, T ny) {X=nx; Y=ny; return *this; }

View File

@ -68,57 +68,51 @@ namespace core
return *(&X+index); return *(&X+index);
} }
//! sort in order X, Y, Z. Equality with rounding tolerance. //! sort in order X, Y, Z.
bool operator<=(const vector3d<T>&other) const bool operator<=(const vector3d<T>&other) const
{ {
return (X<other.X || core::equals(X, other.X)) || return !(*this > other);
(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)));
} }
//! sort in order X, Y, Z. Equality with rounding tolerance. //! sort in order X, Y, Z.
bool operator>=(const vector3d<T>&other) const bool operator>=(const vector3d<T>&other) const
{ {
return (X>other.X || core::equals(X, other.X)) || return !(*this < other);
(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)));
} }
//! sort in order X, Y, Z. Difference must be above rounding tolerance. //! sort in order X, Y, Z.
bool operator<(const vector3d<T>&other) const bool operator<(const vector3d<T>&other) const
{ {
return (X<other.X && !core::equals(X, other.X)) || return X < other.X || (X == other.X && Y < other.Y) ||
(core::equals(X, other.X) && Y<other.Y && !core::equals(Y, other.Y)) || (X == other.X && Y == other.Y && Z < other.Z);
(core::equals(X, other.X) && core::equals(Y, other.Y) && Z<other.Z && !core::equals(Z, other.Z));
} }
//! sort in order X, Y, Z. Difference must be above rounding tolerance. //! sort in order X, Y, Z.
bool operator>(const vector3d<T>&other) const bool operator>(const vector3d<T>&other) const
{ {
return (X>other.X && !core::equals(X, other.X)) || return X > other.X || (X == other.X && Y > other.Y) ||
(core::equals(X, other.X) && Y>other.Y && !core::equals(Y, other.Y)) || (X == other.X && Y == other.Y && Z > other.Z);
(core::equals(X, other.X) && core::equals(Y, other.Y) && Z>other.Z && !core::equals(Z, other.Z));
} }
//! use weak float compare
bool operator==(const vector3d<T>& other) const bool operator==(const vector3d<T>& other) const
{ {
return this->equals(other); return X == other.X && Y == other.Y && Z == other.Z;
} }
bool operator!=(const vector3d<T>& other) const bool operator!=(const vector3d<T>& other) const
{ {
return !this->equals(other); return !(*this == other);
} }
// functions // functions
//! returns if this vector equals the other one, taking floating point rounding errors into account //! Checks if this vector equals the other one.
bool equals(const vector3d<T>& other, const T tolerance = (T)ROUNDING_ERROR_f32 ) const /** 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<T>& other) const
{ {
return core::equals(X, other.X, tolerance) && return core::equals(X, other.X) && core::equals(Y, other.Y) && core::equals(Z, other.Z);
core::equals(Y, other.Y, tolerance) &&
core::equals(Z, other.Z, tolerance);
} }
vector3d<T>& set(const T nx, const T ny, const T nz) {X=nx; Y=ny; Z=nz; return *this;} vector3d<T>& set(const T nx, const T ny, const T nz) {X=nx; Y=ny; Z=nz; return *this;}

View File

@ -355,7 +355,7 @@ f:write[[
#include <KHR/khrplatform.h> #include <KHR/khrplatform.h>
#ifndef APIENTRY #ifndef APIENTRY
#define APIENTRY #define APIENTRY KHRONOS_APIENTRY
#endif #endif
#ifndef APIENTRYP #ifndef APIENTRYP
#define APIENTRYP APIENTRY * #define APIENTRYP APIENTRY *
@ -387,9 +387,9 @@ public:
// Call this once after creating the context. // Call this once after creating the context.
void LoadAllProcedures(irr::video::IContextManager *cmgr); void LoadAllProcedures(irr::video::IContextManager *cmgr);
// Check if an extension is supported. // Check if an extension is supported.
inline bool IsExtensionPresent(const std::string &ext) inline bool IsExtensionPresent(const std::string &ext) const
{ {
return extensions.find(ext) != extensions.end(); return extensions.count(ext) > 0;
} }
]]; ]];
@ -403,13 +403,16 @@ f:write[[
static constexpr const GLenum NONE = 0; static constexpr const GLenum NONE = 0;
]]; ]];
f:write( "};\n" ); f:write( "};\n" );
f:write( "\n//Global GL procedures object.\n" ); f:write( "\n// Global GL procedures object.\n" );
f:write( "IRRLICHT_API extern OpenGLProcedures GL;\n" ); f:write( "IRRLICHT_API extern OpenGLProcedures GL;\n" );
f:close(); f:close();
-- Write loader implementation -- Write loader implementation
f = io.open( sourceTreePath .. "/source/Irrlicht/mt_opengl_loader.cpp", "wb" ); f = io.open( sourceTreePath .. "/source/Irrlicht/mt_opengl_loader.cpp", "wb" );
f:write[[ f:write[[
// This code was generated by scripts/BindingGenerator.lua
// Do not modify it, modify and run the generator instead.
#include "mt_opengl.h" #include "mt_opengl.h"
#include <string> #include <string>
#include <sstream> #include <sstream>
@ -423,9 +426,24 @@ void OpenGLProcedures::LoadAllProcedures(irr::video::IContextManager *cmgr)
f:write( loader:Concat() ); f:write( loader:Concat() );
f:write[[ f:write[[
// OpenGL 3 way to enumerate extensions
GLint ext_count = 0;
GetIntegerv(NUM_EXTENSIONS, &ext_count);
extensions.reserve(ext_count);
for (GLint k = 0; k < ext_count; k++) {
auto tmp = GetStringi(EXTENSIONS, k);
if (tmp)
extensions.emplace((char*)tmp);
}
if (!extensions.empty())
return;
// OpenGL 2 / ES 2 way to enumerate extensions
auto ext_str = GetString(EXTENSIONS);
if (!ext_str)
return;
// get the extension string, chop it up // get the extension string, chop it up
std::string ext_string = std::string((char*)GetString(EXTENSIONS)); std::stringstream ext_ss((char*)ext_str);
std::stringstream ext_ss(ext_string);
std::string tmp; std::string tmp;
while (std::getline(ext_ss, tmp, ' ')) while (std::getline(ext_ss, tmp, ' '))
extensions.emplace(tmp); extensions.emplace(tmp);

View File

@ -1,7 +1,7 @@
#!/bin/bash -e #!/bin/bash -e
topdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
[[ -z "$CC" || -z "$CXX" ]] && exit 255 [[ -z "$CC" || -z "$CXX" ]] && exit 255
variant=win32 variant=win32
[[ "$(basename "$CXX")" == "x86_64-"* ]] && variant=win64 [[ "$(basename "$CXX")" == "x86_64-"* ]] && variant=win64
with_sdl=0 with_sdl=0
@ -9,26 +9,29 @@ with_sdl=0
#with_gl3=0 #with_gl3=0
#[[ "$extras" == *"-gl3"* ]] && with_gl3=1 #[[ "$extras" == *"-gl3"* ]] && with_gl3=1
libjpeg_version=2.1.5.1 libjpeg_version=3.0.1
libpng_version=1.6.39 libpng_version=1.6.40
sdl2_version=2.28.1 sdl2_version=2.28.5
zlib_version=1.2.13 zlib_version=1.3
download () {
local url=$1
local filename=${url##*/}
local foldername=${filename%%[.-]*}
[ -d "./$foldername" ] && return 0
[ -e "$filename" ] || wget "$url" -O "$filename"
sha256sum -w -c <(grep -F "$filename" "$topdir/sha256sums.txt")
unzip -o "$filename" -d "$foldername"
}
mkdir -p libs mkdir -p libs
pushd libs pushd libs
libs=$PWD libs=$PWD
[ -e libjpeg.zip ] || \ download "http://minetest.kitsunemimi.pw/libjpeg-$libjpeg_version-$variant.zip"
wget "http://minetest.kitsunemimi.pw/libjpeg-$libjpeg_version-$variant.zip" -O libjpeg.zip download "http://minetest.kitsunemimi.pw/libpng-$libpng_version-$variant.zip"
[ -e libpng.zip ] || \ [ $with_sdl -eq 1 ] && download "http://minetest.kitsunemimi.pw/sdl2-$sdl2_version-$variant.zip"
wget "http://minetest.kitsunemimi.pw/libpng-$libpng_version-$variant.zip" -O libpng.zip download "http://minetest.kitsunemimi.pw/zlib-$zlib_version-$variant.zip"
[[ $with_sdl -eq 0 || -e sdl2.zip ]] || \
wget "http://minetest.kitsunemimi.pw/sdl2-$sdl2_version-$variant.zip" -O sdl2.zip
[ -e zlib.zip ] || \
wget "http://minetest.kitsunemimi.pw/zlib-$zlib_version-$variant.zip" -O zlib.zip
[ -d libjpeg ] || unzip -o libjpeg.zip -d libjpeg
[ -d libpng ] || unzip -o libpng.zip -d libpng
[[ $with_sdl -eq 0 || -d sdl2 ]] || unzip -o sdl2.zip -d sdl2
[ -d zlib ] || unzip -o zlib.zip -d zlib
popd popd
tmp=( tmp=(
@ -40,10 +43,14 @@ tmp=(
-DZLIB_LIBRARY=$libs/zlib/lib/libz.dll.a \ -DZLIB_LIBRARY=$libs/zlib/lib/libz.dll.a \
-DZLIB_INCLUDE_DIR=$libs/zlib/include -DZLIB_INCLUDE_DIR=$libs/zlib/include
) )
[ $with_sdl -eq 1 ] && tmp+=( if [ $with_sdl -eq 1 ]; then
tmp+=(
-DUSE_SDL2=ON -DUSE_SDL2=ON
-DCMAKE_PREFIX_PATH=$libs/sdl2/lib/cmake -DCMAKE_PREFIX_PATH=$libs/sdl2/lib/cmake
) )
else
tmp+=(-DUSE_SDL2=OFF)
fi
#[ $with_gl3 -eq 1 ] && tmp+=(-DENABLE_OPENGL=OFF -DENABLE_OPENGL3=ON) #[ $with_gl3 -eq 1 ] && tmp+=(-DENABLE_OPENGL=OFF -DENABLE_OPENGL3=ON)
cmake . "${tmp[@]}" cmake . "${tmp[@]}"

12
scripts/ci-get-mingw.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
set -e
topdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
[ -z "$1" ] && exit 255
ver=13.2.0
os=ubuntu22.04
name="mingw-w64-${1}_${ver}_${os}.tar.xz"
wget "http://minetest.kitsunemimi.pw/$name" -O "$name"
sha256sum -w -c <(grep -F "$name" "$topdir/sha256sums.txt")
sudo tar -xaf "$name" -C /usr
rm -f "$name"

10
scripts/sha256sums.txt Normal file
View File

@ -0,0 +1,10 @@
a7dc54d5fb9f841eae26ee17f6146c0b7a0e5d99a914866a394b723dffc83316 libjpeg-3.0.1-win32.zip
cd1f667ed2d24d96e1d61fcf91ba6d7b11270a4903e36f08e640971884caaccd libjpeg-3.0.1-win64.zip
72a624fbaef15909f80976c9c569717e9438bd34c3209071378f05487e859f8a libpng-1.6.40-win32.zip
8e2552f6965c385f7e2467018d583fd206744db18e36656ddf1c07c8663ea23f libpng-1.6.40-win64.zip
9f0cfab8ca089d48be7a59f85d5fd5648f18f54c91d7ac6c31b281ba5e90852a mingw-w64-i686_13.2.0_ubuntu22.04.tar.xz
93bc9f04d43a023358d1ae2b76dec42d3d79baecd452402ee9fb3ee21945fdfe mingw-w64-x86_64_13.2.0_ubuntu22.04.tar.xz
2abdc82b4cac710bab0b3e9f9a9c38cc242abcca443c1e1f7af51d29a5eb5457 sdl2-2.28.5-win32.zip
949a3de77d1c97240ee4b35e15495962b5effb816f7f03efe5c6edd8975a8b19 sdl2-2.28.5-win64.zip
3c5abd40e9492c834651d995db6bbf0f57a7579d091d2d03110293b95e9b039a zlib-1.3-win32.zip
f63d9a38c2ee56fa1e95a486224c274412cb5b3275734c1da53b0a68a7e8c654 zlib-1.3-win64.zip

View File

@ -106,7 +106,7 @@ bool CIrrDeviceAndroid::run()
s32 Events = 0; s32 Events = 0;
android_poll_source* Source = 0; android_poll_source* Source = 0;
while ((id = ALooper_pollAll(((Focused && !Paused) || !Initialized) ? 0 : -1, 0, &Events, (void**)&Source)) >= 0) while ((id = ALooper_pollAll(0, 0, &Events, (void**)&Source)) >= 0)
{ {
if(Source) if(Source)
Source->process(Android, Source); Source->process(Android, Source);
@ -193,6 +193,11 @@ bool CIrrDeviceAndroid::isWindowMinimized() const
return !Focused; return !Focused;
} }
bool CIrrDeviceAndroid::isWindowVisible() const
{
return !Paused;
}
void CIrrDeviceAndroid::closeDevice() void CIrrDeviceAndroid::closeDevice()
{ {
ANativeActivity_finish(Android->activity); ANativeActivity_finish(Android->activity);

View File

@ -36,6 +36,8 @@ namespace irr
virtual bool isWindowMinimized() const; virtual bool isWindowMinimized() const;
virtual bool isWindowVisible() const;
virtual void closeDevice(); virtual void closeDevice();
virtual void setResizable(bool resize = false); virtual void setResizable(bool resize = false);

View File

@ -51,6 +51,8 @@ CAnimatedMeshSceneNode::~CAnimatedMeshSceneNode()
{ {
if (LoopCallBack) if (LoopCallBack)
LoopCallBack->drop(); LoopCallBack->drop();
if (Mesh)
Mesh->drop();
} }

View File

@ -757,9 +757,6 @@ void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN
case ECF_R8G8B8: case ECF_R8G8B8:
convert_A1R5G5B5toR8G8B8(sP, sN, dP); convert_A1R5G5B5toR8G8B8(sP, sN, dP);
break; break;
IRR_CASE_IIMAGE_COMPRESSED_FORMAT
os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING);
break;
default: default:
break; break;
@ -780,9 +777,6 @@ void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN
case ECF_R8G8B8: case ECF_R8G8B8:
convert_R5G6B5toR8G8B8(sP, sN, dP); convert_R5G6B5toR8G8B8(sP, sN, dP);
break; break;
IRR_CASE_IIMAGE_COMPRESSED_FORMAT
os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING);
break;
default: default:
break; break;
@ -803,9 +797,6 @@ void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN
case ECF_R8G8B8: case ECF_R8G8B8:
convert_A8R8G8B8toR8G8B8(sP, sN, dP); convert_A8R8G8B8toR8G8B8(sP, sN, dP);
break; break;
IRR_CASE_IIMAGE_COMPRESSED_FORMAT
os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING);
break;
default: default:
break; break;
@ -826,17 +817,11 @@ void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN
case ECF_R8G8B8: case ECF_R8G8B8:
convert_R8G8B8toR8G8B8(sP, sN, dP); convert_R8G8B8toR8G8B8(sP, sN, dP);
break; break;
IRR_CASE_IIMAGE_COMPRESSED_FORMAT
os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING);
break;
default: default:
break; break;
} }
break; break;
IRR_CASE_IIMAGE_COMPRESSED_FORMAT
os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING);
break;
default: default:
break; break;

View File

@ -75,10 +75,6 @@ void CImage::setPixel(u32 x, u32 y, const SColor &color, bool blend)
*dest = blend ? PixelBlend32 ( *dest, color.color ) : color.color; *dest = blend ? PixelBlend32 ( *dest, color.color ) : color.color;
} break; } break;
IRR_CASE_IIMAGE_COMPRESSED_FORMAT
os::Printer::log("IImage::setPixel method doesn't work with compressed images.", ELL_WARNING);
return;
case ECF_UNKNOWN: case ECF_UNKNOWN:
os::Printer::log("IImage::setPixel unknown format.", ELL_WARNING); os::Printer::log("IImage::setPixel unknown format.", ELL_WARNING);
return; return;
@ -109,10 +105,6 @@ SColor CImage::getPixel(u32 x, u32 y) const
return SColor(255,p[0],p[1],p[2]); 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: case ECF_UNKNOWN:
os::Printer::log("IImage::getPixel unknown format.", ELL_WARNING); os::Printer::log("IImage::getPixel unknown format.", ELL_WARNING);
break; break;

View File

@ -46,7 +46,7 @@ u8 *CImageLoaderTGA::loadCompressedImage(io::IReadFile *file, const STGAHeader&
chunkheader++; // Add 1 To The Value To Get Total Number Of Raw Pixels chunkheader++; // Add 1 To The Value To Get Total Number Of Raw Pixels
const u32 bytesToRead = bytesPerPixel * chunkheader; const u32 bytesToRead = bytesPerPixel * chunkheader;
if ( currentByte+bytesToRead < imageSize ) if ( currentByte+bytesToRead <= imageSize )
{ {
file->read(&data[currentByte], bytesToRead); file->read(&data[currentByte], bytesToRead);
currentByte += bytesToRead; currentByte += bytesToRead;

View File

@ -147,6 +147,11 @@ CIrrDeviceLinux::CIrrDeviceLinux(const SIrrlichtCreationParameters& param)
// create keymap // create keymap
createKeyMap(); createKeyMap();
// initialize X11 thread safety
// libX11 1.8+ has this on by default
// without it, multi-threaded GL drivers may crash
XInitThreads();
// create window // create window
if (CreationParams.DriverType != video::EDT_NULL) if (CreationParams.DriverType != video::EDT_NULL)
{ {

View File

@ -229,7 +229,7 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
Window((SDL_Window*)param.WindowId), SDL_Flags(0), Window((SDL_Window*)param.WindowId), SDL_Flags(0),
MouseX(0), MouseY(0), MouseXRel(0), MouseYRel(0), MouseButtonStates(0), MouseX(0), MouseY(0), MouseXRel(0), MouseYRel(0), MouseButtonStates(0),
Width(param.WindowSize.Width), Height(param.WindowSize.Height), Width(param.WindowSize.Width), Height(param.WindowSize.Height),
Resizable(param.WindowResizable == 1 ? true : false) Resizable(param.WindowResizable == 1 ? true : false), CurrentTouchCount(0)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CIrrDeviceSDL"); setDebugName("CIrrDeviceSDL");
@ -254,14 +254,21 @@ 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 // create keymap
createKeyMap(); createKeyMap();
// create window // create window
if (CreationParams.DriverType != video::EDT_NULL) if (CreationParams.DriverType != video::EDT_NULL)
{ {
// create the window, only if we do not use the null device if (!createWindow()) {
createWindow(); Close = true;
return;
}
} }
@ -555,7 +562,11 @@ bool CIrrDeviceSDL::run()
irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT; irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL; irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL;
#if SDL_VERSION_ATLEAST(2, 0, 18)
irrevent.MouseInput.Wheel = SDL_event.wheel.preciseY; irrevent.MouseInput.Wheel = SDL_event.wheel.preciseY;
#else
irrevent.MouseInput.Wheel = SDL_event.wheel.y;
#endif
irrevent.MouseInput.Shift = (keymod & KMOD_SHIFT) != 0; irrevent.MouseInput.Shift = (keymod & KMOD_SHIFT) != 0;
irrevent.MouseInput.Control = (keymod & KMOD_CTRL) != 0; irrevent.MouseInput.Control = (keymod & KMOD_CTRL) != 0;
irrevent.MouseInput.X = MouseX; irrevent.MouseInput.X = MouseX;
@ -741,6 +752,45 @@ bool CIrrDeviceSDL::run()
postEventFromUser(irrevent); postEventFromUser(irrevent);
break; 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: default:
break; break;
} // end switch } // end switch

View File

@ -318,6 +318,8 @@ namespace irr
core::array<SKeyMap> KeyMap; core::array<SKeyMap> KeyMap;
SDL_SysWMinfo Info; SDL_SysWMinfo Info;
s32 CurrentTouchCount;
}; };
} // end namespace irr } // end namespace irr

View File

@ -1,5 +1,9 @@
if(NOT ANDROID AND NOT APPLE)
set(DEFAULT_SDL2 ON)
endif()
option(BUILD_SHARED_LIBS "Build shared library" TRUE) option(BUILD_SHARED_LIBS "Build shared library" TRUE)
option(USE_SDL2 "Use the SDL2 backend" FALSE) option(USE_SDL2 "Use the SDL2 backend" ${DEFAULT_SDL2})
# Compiler flags # Compiler flags
@ -20,14 +24,12 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-D_DEBUG) add_definitions(-D_DEBUG)
endif() endif()
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$") if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$")
set(CMAKE_CXX_FLAGS_RELEASE "-O3") set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(CMAKE_CXX_FLAGS_DEBUG "-g") set(CMAKE_CXX_FLAGS_DEBUG "-g")
add_compile_options(-Wall -pipe -fno-exceptions -fno-rtti) add_compile_options(-Wall -pipe -fno-exceptions)
# Enable SSE for floating point math on 32-bit x86 by default # Enable SSE for floating point math on 32-bit x86 by default
# reasoning see minetest issue #11810 and https://gcc.gnu.org/wiki/FloatingPointMath # reasoning see minetest issue #11810 and https://gcc.gnu.org/wiki/FloatingPointMath
@ -182,6 +184,7 @@ endif()
if(ENABLE_OPENGL) if(ENABLE_OPENGL)
add_definitions(-D_IRR_COMPILE_WITH_OPENGL_) add_definitions(-D_IRR_COMPILE_WITH_OPENGL_)
set(OPENGL_DIRECT_LINK TRUE) # not yet possible to remove this
if(DEVICE STREQUAL "WINDOWS") if(DEVICE STREQUAL "WINDOWS")
add_definitions(-D_IRR_COMPILE_WITH_WGL_MANAGER_ -D_IRR_OPENGL_USE_EXTPOINTER_) add_definitions(-D_IRR_COMPILE_WITH_WGL_MANAGER_ -D_IRR_OPENGL_USE_EXTPOINTER_)
elseif(DEVICE STREQUAL "X11") elseif(DEVICE STREQUAL "X11")
@ -197,6 +200,7 @@ if(ENABLE_OPENGL3)
if (NOT USE_SDL2) if (NOT USE_SDL2)
message(FATAL_ERROR "OpenGL 3 driver requires SDL2") message(FATAL_ERROR "OpenGL 3 driver requires SDL2")
endif() endif()
set(OPENGL_DIRECT_LINK TRUE) # TODO
set(USE_SDLGL ON) set(USE_SDLGL ON)
set(USE_SDLGL3 ON) set(USE_SDLGL3 ON)
endif() endif()
@ -206,6 +210,7 @@ if(ENABLE_GLES1)
message(FATAL_ERROR "OpenGL ES 1 is not supported with SDL2") message(FATAL_ERROR "OpenGL ES 1 is not supported with SDL2")
endif() endif()
add_definitions(-D_IRR_COMPILE_WITH_OGLES1_) add_definitions(-D_IRR_COMPILE_WITH_OGLES1_)
set(OPENGLES_DIRECT_LINK TRUE)
if(DEVICE MATCHES "^(WINDOWS|X11|ANDROID)$") if(DEVICE MATCHES "^(WINDOWS|X11|ANDROID)$")
add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_ -D_IRR_OGLES1_USE_EXTPOINTER_) add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_ -D_IRR_OGLES1_USE_EXTPOINTER_)
endif() endif()
@ -213,9 +218,11 @@ endif()
if(ENABLE_GLES2) if(ENABLE_GLES2)
add_definitions(-D_IRR_COMPILE_WITH_OGLES2_) 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) if(DEVICE MATCHES "^(WINDOWS|X11|ANDROID)$" OR EMSCRIPTEN)
add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_ -D_IRR_OGLES2_USE_EXTPOINTER_) add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_ -D_IRR_OGLES2_USE_EXTPOINTER_)
elseif(DEVICE STREQUAL "SDL") elseif(DEVICE STREQUAL "SDL")
add_definitions(-D_IRR_OGLES2_USE_EXTPOINTER_)
set(USE_SDLGL ON) set(USE_SDLGL ON)
set(USE_SDLGLES2 ON) set(USE_SDLGLES2 ON)
endif() endif()
@ -313,9 +320,9 @@ set(link_libs
"${PNG_LIBRARY}" "${PNG_LIBRARY}"
"$<$<BOOL:${USE_SDL2}>:${SDL2_LIBRARIES}>" "$<$<BOOL:${USE_SDL2}>:${SDL2_LIBRARIES}>"
${OPENGL_LIBRARIES} "$<$<BOOL:${OPENGL_DIRECT_LINK}>:${OPENGL_LIBRARIES}>"
${OPENGLES_LIBRARY} "$<$<BOOL:${OPENGLES_DIRECT_LINK}>:${OPENGLES_LIBRARIES}>"
${OPENGLES2_LIBRARIES} "$<$<BOOL:${OPENGLES2_DIRECT_LINK}>:${OPENGLES2_LIBRARIES}>"
${EGL_LIBRARY} ${EGL_LIBRARY}
"$<$<PLATFORM_ID:Android>:-landroid -llog>" "$<$<PLATFORM_ID:Android>:-landroid -llog>"

View File

@ -1001,68 +1001,6 @@ bool CNullDriver::checkPrimitiveCount(u32 prmCount) const
bool CNullDriver::checkImage(IImage *image) const bool CNullDriver::checkImage(IImage *image) const
{ {
ECOLOR_FORMAT format = image->getColorFormat();
core::dimension2d<u32> 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; return true;
} }

View File

@ -2533,92 +2533,6 @@ COGLES2Driver::~COGLES2Driver()
} }
pixelType = GL_UNSIGNED_BYTE; pixelType = GL_UNSIGNED_BYTE;
break; 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: case ECF_D16:
supported = true; supported = true;
pixelFormat = GL_DEPTH_COMPONENT; pixelFormat = GL_DEPTH_COMPONENT;

View File

@ -64,16 +64,6 @@ namespace video
case EVDF_MRT_BLEND_FUNC: case EVDF_MRT_BLEND_FUNC:
case EVDF_OCCLUSION_QUERY: case EVDF_OCCLUSION_QUERY:
return false; 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: case EVDF_STENCIL_BUFFER:
return StencilBuffer; return StencilBuffer;
default: default:

View File

@ -2888,104 +2888,6 @@ bool COGLES1Driver::getColorFormatParameters(ECOLOR_FORMAT format, GLint& intern
} }
pixelType = GL_UNSIGNED_BYTE; pixelType = GL_UNSIGNED_BYTE;
break; 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: case ECF_D16:
supported = true; supported = true;
internalFormat = GL_DEPTH_COMPONENT16; internalFormat = GL_DEPTH_COMPONENT16;

View File

@ -55,14 +55,6 @@ namespace video
return FeatureAvailable[IRR_GL_OES_framebuffer_object]; return FeatureAvailable[IRR_GL_OES_framebuffer_object];
case EVDF_VERTEX_BUFFER_OBJECT: case EVDF_VERTEX_BUFFER_OBJECT:
return Version>100; 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: default:
return true; return true;
}; };

View File

@ -159,10 +159,11 @@ const c8* COSOperator::getTextFromClipboard() const
if (!OpenClipboard(NULL)) if (!OpenClipboard(NULL))
return 0; return 0;
wchar_t * buffer = 0;
HANDLE hData = GetClipboardData( CF_UNICODETEXT ); HANDLE hData = GetClipboardData( CF_UNICODETEXT );
buffer = (wchar_t*) GlobalLock( hData ); if (hData == NULL) // Probably not in Unicode text format
return 0;
wchar_t * buffer = (wchar_t*) GlobalLock( hData );
core::wStringToUTF8(ClipboardBuf, buffer); core::wStringToUTF8(ClipboardBuf, buffer);

View File

@ -23,7 +23,7 @@
#endif #endif
#include <OpenGL/gl.h> #include <OpenGL/gl.h>
#if defined(_IRR_OPENGL_USE_EXTPOINTER_) #if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#include <GL/glext.h> #error glext.h missing on OSX
#endif #endif
#elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_) && !defined(_IRR_COMPILE_WITH_X11_DEVICE_) #elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_) && !defined(_IRR_COMPILE_WITH_X11_DEVICE_)
#if defined(_IRR_OPENGL_USE_EXTPOINTER_) #if defined(_IRR_OPENGL_USE_EXTPOINTER_)
@ -34,9 +34,12 @@
#include <SDL_video.h> #include <SDL_video.h>
#include <SDL_opengl.h> #include <SDL_opengl.h>
#if defined(_IRR_OPENGL_USE_EXTPOINTER_) #if defined(_IRR_OPENGL_USE_EXTPOINTER_)
// The SDL2 header doesn't cut it for extensions #ifdef __APPLE__
#include <SDL_opengl_glext.h>
#else
#include <GL/glext.h> #include <GL/glext.h>
#endif #endif
#endif
#else #else
#if defined(_IRR_OPENGL_USE_EXTPOINTER_) #if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#define GL_GLEXT_LEGACY 1 #define GL_GLEXT_LEGACY 1

View File

@ -561,6 +561,10 @@ protected:
u32 width = Size.Width >> level; u32 width = Size.Width >> level;
u32 height = Size.Height >> level; u32 height = Size.Height >> level;
if (width < 1)
width = 1;
if (height < 1)
height = 1;
GLenum tmpTextureType = TextureType; GLenum tmpTextureType = TextureType;

View File

@ -3962,29 +3962,6 @@ bool COpenGLDriver::getColorFormatParameters(ECOLOR_FORMAT format, GLint& intern
if (Version > 101) if (Version > 101)
pixelType = GL_UNSIGNED_INT_8_8_8_8_REV; pixelType = GL_UNSIGNED_INT_8_8_8_8_REV;
break; 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: case ECF_D16:
supported = true; supported = true;
internalFormat = GL_DEPTH_COMPONENT16; internalFormat = GL_DEPTH_COMPONENT16;

View File

@ -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<count; ++i)
{
memset(vals,0,sizeof(vals));
#define tmplog(x,y) os::Printer::log(x, core::stringc(y).c_str())
const BOOL res = wglGetPixelFormatAttribiv_ARB(hdc,i,0,(UINT)nums,atts,vals);
if (FALSE==res)
continue;
tmplog("Pixel format ",i);
u32 j=0;
tmplog("Draw to window " , vals[j]);
tmplog("Draw to bitmap " , vals[++j]);
++j;
tmplog("Acceleration " , (vals[j]==WGL_NO_ACCELERATION_ARB?"No":
vals[j]==WGL_GENERIC_ACCELERATION_ARB?"Generic":vals[j]==WGL_FULL_ACCELERATION_ARB?"Full":"ERROR"));
tmplog("Need palette " , vals[++j]);
tmplog("Need system palette " , vals[++j]);
tmplog("Swap layer buffers " , vals[++j]);
++j;
tmplog("Swap method " , (vals[j]==WGL_SWAP_EXCHANGE_ARB?"Exchange":
vals[j]==WGL_SWAP_COPY_ARB?"Copy":vals[j]==WGL_SWAP_UNDEFINED_ARB?"Undefined":"ERROR"));
tmplog("Number of overlays " , vals[++j]);
tmplog("Number of underlays " , vals[++j]);
tmplog("Transparent " , vals[++j]);
tmplog("Transparent red value " , vals[++j]);
tmplog("Transparent green value " , vals[++j]);
tmplog("Transparent blue value " , vals[++j]);
tmplog("Transparent alpha value " , vals[++j]);
tmplog("Transparent index value " , vals[++j]);
tmplog("Share depth " , vals[++j]);
tmplog("Share stencil " , vals[++j]);
tmplog("Share accum " , vals[++j]);
tmplog("Support GDI " , vals[++j]);
tmplog("Support OpenGL " , vals[++j]);
tmplog("Double Buffer " , vals[++j]);
tmplog("Stereo Buffer " , vals[++j]);
tmplog("Pixel type " , vals[++j]);
tmplog("Color bits" , vals[++j]);
tmplog("Red bits " , vals[++j]);
tmplog("Red shift " , vals[++j]);
tmplog("Green bits " , vals[++j]);
tmplog("Green shift " , vals[++j]);
tmplog("Blue bits " , vals[++j]);
tmplog("Blue shift " , vals[++j]);
tmplog("Alpha bits " , vals[++j]);
tmplog("Alpha Shift " , vals[++j]);
tmplog("Accum bits " , vals[++j]);
tmplog("Accum red bits " , vals[++j]);
tmplog("Accum green bits " , vals[++j]);
tmplog("Accum blue bits " , vals[++j]);
tmplog("Accum alpha bits " , vals[++j]);
tmplog("Depth bits " , vals[++j]);
tmplog("Stencil bits " , vals[++j]);
tmplog("Aux buffers " , vals[++j]);
if (render_texture_supported)
{
tmplog("Bind to texture RGB" , vals[++j]);
tmplog("Bind to texture RGBA" , vals[++j]);
}
if (pbuffer_supported)
{
tmplog("Draw to pbuffer" , vals[++j]);
tmplog("Max pbuffer pixels " , vals[++j]);
tmplog("Max pbuffer width" , vals[++j]);
tmplog("Max pbuffer height" , vals[++j]);
}
if (framebuffer_sRGB_supported)
tmplog("Framebuffer sRBG capable" , vals[++j]);
if (multi_sample_supported)
{
tmplog("Samples " , vals[++j]);
tmplog("Sample buffers " , vals[++j]);
}
if (depth_float_supported)
tmplog("Depth float" , vals[++j]);
#undef tmplog
}
}
}
#endif
#elif defined(IRR_LINUX_DEVICE)
#endif
}
void COpenGLExtensionHandler::initExtensions(bool stencilBuffer) void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
{ {
const f32 ogl_ver = core::fast_atof(reinterpret_cast<const c8*>(glGetString(GL_VERSION))); const f32 ogl_ver = core::fast_atof(reinterpret_cast<const c8*>(glGetString(GL_VERSION)));
@ -882,8 +668,6 @@ bool COpenGLExtensionHandler::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
return (Version>=104) || FeatureAvailable[IRR_EXT_blend_func_separate]; return (Version>=104) || FeatureAvailable[IRR_EXT_blend_func_separate];
case EVDF_TEXTURE_MATRIX: case EVDF_TEXTURE_MATRIX:
return true; return true;
case EVDF_TEXTURE_COMPRESSED_DXT:
return FeatureAvailable[IRR_EXT_texture_compression_s3tc];
case EVDF_TEXTURE_CUBEMAP: case EVDF_TEXTURE_CUBEMAP:
return (Version >= 103) || FeatureAvailable[IRR_ARB_texture_cube_map] || FeatureAvailable[IRR_EXT_texture_cube_map]; return (Version >= 103) || FeatureAvailable[IRR_ARB_texture_cube_map] || FeatureAvailable[IRR_EXT_texture_cube_map];
case EVDF_TEXTURE_CUBEMAP_SEAMLESS: case EVDF_TEXTURE_CUBEMAP_SEAMLESS:

View File

@ -1010,8 +1010,6 @@ class COpenGLExtensionHandler
//! show all features with availability //! show all features with availability
void dump(ELOG_LEVEL logLevel) const; void dump(ELOG_LEVEL logLevel) const;
void dumpFramebufferFormats() const;
// Some variables for properties // Some variables for properties
bool StencilBuffer; bool StencilBuffer;
bool TextureCompressionExtension; bool TextureCompressionExtension;

View File

@ -782,122 +782,6 @@ bool CWebGL1Driver::getColorFormatParameters(ECOLOR_FORMAT format, GLint& intern
*converter = CColorConverter::convert_A8R8G8B8toA8B8G8R8; *converter = CColorConverter::convert_A8R8G8B8toA8B8G8R8;
pixelType = GL_UNSIGNED_BYTE; pixelType = GL_UNSIGNED_BYTE;
break; 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: case ECF_D16:
if (WebGLExtensions.queryWebGLFeature(CWebGLExtensionHandler::IRR_WEBGL_depth_texture)) if (WebGLExtensions.queryWebGLFeature(CWebGLExtensionHandler::IRR_WEBGL_depth_texture))
{ {

View File

@ -119,7 +119,7 @@
* This follows the return type of the function and precedes the function * This follows the return type of the function and precedes the function
* name in the function prototype. * name in the function prototype.
*/ */
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(KHRONOS_STATIC) #if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
/* Win32 but not WinCE */ /* Win32 but not WinCE */
# define KHRONOS_APIENTRY __stdcall # define KHRONOS_APIENTRY __stdcall
#else #else
@ -153,6 +153,20 @@ typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t; typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1 #define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1 #define KHRONOS_SUPPORT_FLOAT 1
/*
* To support platform where unsigned long cannot be used interchangeably with
* inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t.
* Ideally, we could just use (u)intptr_t everywhere, but this could result in
* ABI breakage if khronos_uintptr_t is changed from unsigned long to
* unsigned long long or similar (this results in different C++ name mangling).
* To avoid changes for existing platforms, we restrict usage of intptr_t to
* platforms where the size of a pointer is larger than the size of long.
*/
#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__)
#if __SIZEOF_POINTER__ > __SIZEOF_LONG__
#define KHRONOS_USE_INTPTR_T
#endif
#endif
#elif defined(__VMS ) || defined(__sgi) #elif defined(__VMS ) || defined(__sgi)
@ -235,14 +249,21 @@ typedef unsigned short int khronos_uint16_t;
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
* to be the only LLP64 architecture in current use. * to be the only LLP64 architecture in current use.
*/ */
#ifdef _WIN64 #ifdef KHRONOS_USE_INTPTR_T
typedef intptr_t khronos_intptr_t;
typedef uintptr_t khronos_uintptr_t;
#elif defined(_WIN64)
typedef signed long long int khronos_intptr_t; typedef signed long long int khronos_intptr_t;
typedef unsigned long long int khronos_uintptr_t; typedef unsigned long long int khronos_uintptr_t;
typedef signed long long int khronos_ssize_t;
typedef unsigned long long int khronos_usize_t;
#else #else
typedef signed long int khronos_intptr_t; typedef signed long int khronos_intptr_t;
typedef unsigned long int khronos_uintptr_t; typedef unsigned long int khronos_uintptr_t;
#endif
#if defined(_WIN64)
typedef signed long long int khronos_ssize_t;
typedef unsigned long long int khronos_usize_t;
#else
typedef signed long int khronos_ssize_t; typedef signed long int khronos_ssize_t;
typedef unsigned long int khronos_usize_t; typedef unsigned long int khronos_usize_t;
#endif #endif

View File

@ -1,3 +1,6 @@
// This code was generated by scripts/BindingGenerator.lua
// Do not modify it, modify and run the generator instead.
#include "mt_opengl.h" #include "mt_opengl.h"
#include <string> #include <string>
#include <sstream> #include <sstream>
@ -684,7 +687,6 @@ void OpenGLProcedures::LoadAllProcedures(irr::video::IContextManager *cmgr)
if (!MultiDrawElementsIndirectCount) MultiDrawElementsIndirectCount = (PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC_MT)cmgr->getProcAddress("glMultiDrawElementsIndirectCount"); if (!MultiDrawElementsIndirectCount) MultiDrawElementsIndirectCount = (PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC_MT)cmgr->getProcAddress("glMultiDrawElementsIndirectCount");
if (!MultiDrawElementsIndirectCount) MultiDrawElementsIndirectCount = (PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC_MT)cmgr->getProcAddress("glMultiDrawElementsIndirectCountARB"); if (!MultiDrawElementsIndirectCount) MultiDrawElementsIndirectCount = (PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC_MT)cmgr->getProcAddress("glMultiDrawElementsIndirectCountARB");
if (!PolygonOffsetClamp) PolygonOffsetClamp = (PFNGLPOLYGONOFFSETCLAMPPROC_MT)cmgr->getProcAddress("glPolygonOffsetClamp"); if (!PolygonOffsetClamp) PolygonOffsetClamp = (PFNGLPOLYGONOFFSETCLAMPPROC_MT)cmgr->getProcAddress("glPolygonOffsetClamp");
if (!GenPerfMonitorsEX) GenPerfMonitorsEX = (PFNGLGENPERFMONITORSEXPROC_MT)cmgr->getProcAddress("glGenPerfMonitorsEX");
if (!PrimitiveBoundingBox) PrimitiveBoundingBox = (PFNGLPRIMITIVEBOUNDINGBOXPROC_MT)cmgr->getProcAddress("glPrimitiveBoundingBoxARB"); if (!PrimitiveBoundingBox) PrimitiveBoundingBox = (PFNGLPRIMITIVEBOUNDINGBOXPROC_MT)cmgr->getProcAddress("glPrimitiveBoundingBoxARB");
if (!GetTextureHandle) GetTextureHandle = (PFNGLGETTEXTUREHANDLEPROC_MT)cmgr->getProcAddress("glGetTextureHandleARB"); if (!GetTextureHandle) GetTextureHandle = (PFNGLGETTEXTUREHANDLEPROC_MT)cmgr->getProcAddress("glGetTextureHandleARB");
if (!GetTextureSamplerHandle) GetTextureSamplerHandle = (PFNGLGETTEXTURESAMPLERHANDLEPROC_MT)cmgr->getProcAddress("glGetTextureSamplerHandleARB"); if (!GetTextureSamplerHandle) GetTextureSamplerHandle = (PFNGLGETTEXTURESAMPLERHANDLEPROC_MT)cmgr->getProcAddress("glGetTextureSamplerHandleARB");
@ -757,12 +759,15 @@ void OpenGLProcedures::LoadAllProcedures(irr::video::IContextManager *cmgr)
if (!TexPageCommitment) TexPageCommitment = (PFNGLTEXPAGECOMMITMENTPROC_MT)cmgr->getProcAddress("glTexPageCommitmentARB"); if (!TexPageCommitment) TexPageCommitment = (PFNGLTEXPAGECOMMITMENTPROC_MT)cmgr->getProcAddress("glTexPageCommitmentARB");
// OpenGL 3 way to enumerate extensions // OpenGL 3 way to enumerate extensions
int ext_count = 0; GLint ext_count = 0;
GetIntegerv(NUM_EXTENSIONS, &ext_count); GetIntegerv(NUM_EXTENSIONS, &ext_count);
extensions.reserve(ext_count); extensions.reserve(ext_count);
for (int k = 0; k < ext_count; k++) for (GLint k = 0; k < ext_count; k++) {
extensions.emplace((char *)GetStringi(EXTENSIONS, k)); auto tmp = GetStringi(EXTENSIONS, k);
if (ext_count) if (tmp)
extensions.emplace((char*)tmp);
}
if (!extensions.empty())
return; return;
// OpenGL 2 / ES 2 way to enumerate extensions // OpenGL 2 / ES 2 way to enumerate extensions
@ -774,4 +779,5 @@ void OpenGLProcedures::LoadAllProcedures(irr::video::IContextManager *cmgr)
std::string tmp; std::string tmp;
while (std::getline(ext_ss, tmp, ' ')) while (std::getline(ext_ss, tmp, ' '))
extensions.emplace(tmp); extensions.emplace(tmp);
} }

32
test/CMakeLists.txt Normal file
View File

@ -0,0 +1,32 @@
link_libraries(IrrlichtMt::IrrlichtMt)
add_executable(image_loader_test image_loader_test.cpp)
function(test_image_loader format expected input)
string(TOLOWER ${format} suffix)
add_test(NAME ImageLoader${format}-${input} COMMAND image_loader_test ${expected} data/sample_${input}.${suffix} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endfunction()
test_image_loader(BMP 16color-16bpp 4bpp_v3)
# test_image_loader(BMP 16color-16bpp 4bpp_v7)
# test_image_loader(BMP 16color-16bpp 4bpp_v3_rle)
# test_image_loader(BMP 16color-16bpp 4bpp_v7_rle)
test_image_loader(BMP 30color-16bpp 8bpp_v3)
# test_image_loader(BMP 30color-16bpp 8bpp_v7)
test_image_loader(BMP 30color-16bpp 8bpp_v3_rle)
# test_image_loader(BMP 30color-16bpp 8bpp_v7_rle)
# test_image_loader(BMP 30color-16bpp 16bpp_v3)
# test_image_loader(BMP 30color-16bpp 16bpp_v7)
test_image_loader(BMP 30color-24bpp 24bpp_v3)
test_image_loader(BMP 30color-24bpp 24bpp_v7)
test_image_loader(PNG 30color-24bpp 8bpp)
test_image_loader(PNG 30color-24bpp 24bpp)
test_image_loader(TGA 30color-32bpp 8bpp_up)
test_image_loader(TGA 30color-32bpp 8bpp_down)
# test_image_loader(TGA 30color-16bpp 8bpp_rle_up)
# test_image_loader(TGA 30color-16bpp 8bpp_rle_down)
test_image_loader(TGA 30color-24bpp 24bpp_up)
test_image_loader(TGA 30color-24bpp 24bpp_down)
test_image_loader(TGA 30color-24bpp 24bpp_rle_up)
test_image_loader(TGA 30color-24bpp 24bpp_rle_down)

Binary file not shown.

After

Width:  |  Height:  |  Size: 654 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 738 B

BIN
test/data/sample_24bpp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 899 B

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 899 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 954 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 B

BIN
test/data/sample_8bpp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 608 B

160
test/image_loader_test.cpp Normal file
View File

@ -0,0 +1,160 @@
#include <cstdio>
#include <initializer_list>
#include <stdexcept>
#include <vector>
#include <irrlicht.h>
using namespace irr;
struct ImageDesc {
const char *name;
video::ECOLOR_FORMAT format;
std::vector<u8> data;
};
template <typename T>
std::vector<u8> to_byte_array(std::initializer_list<T> in_data) {
std::vector<u8> data;
data.resize(sizeof(T) * in_data.size());
memcpy(data.data(), in_data.begin(), data.size());
return data;
}
static const ImageDesc test_images[] = {
{"16color-16bpp", video::ECF_A1R5G5B5, to_byte_array<u16>({
0xb6df, 0xb6df, 0xb6df, 0xb6df, 0xc23f, 0xc23f, 0xd61f, 0xd61f, 0xea3f, 0xea3f, 0xfe5e, 0xfe5e, 0xfe7c, 0xfe7a, 0xfe7a, 0xfe97, 0xfeb5, 0xfeb5, 0xff16,
0xb6df, 0xb6df, 0xff3f, 0xff3f, 0xc23f, 0xf2df, 0xf2df, 0xf2df, 0xea3f, 0xda7f, 0xda7f, 0xfe5e, 0xfe7a, 0xc23f, 0xbe7f, 0xbe7f, 0xfeb5, 0xfeb5, 0xfb76,
0xb6df, 0xff9e, 0xc23f, 0xc23f, 0xc23f, 0xf2df, 0xd61f, 0xf2df, 0xea3f, 0xda7f, 0xfe5e, 0xda7f, 0xfe7a, 0xc23f, 0xfe97, 0xfeb5, 0xfeb5, 0xff16, 0xfb76,
0xb6df, 0xff9e, 0xbe7f, 0xc23f, 0xd61f, 0xfe7c, 0xd61f, 0xf2df, 0xfe5e, 0xf2df, 0xfe7c, 0xda7f, 0xfe7a, 0xda7f, 0xbe7f, 0xfeb5, 0xff16, 0xff16, 0xfb76,
0xb6df, 0xff9e, 0xc23f, 0xc23f, 0xd61f, 0xff3f, 0xd61f, 0xf2df, 0xfe5e, 0xda7f, 0xfe7c, 0xda7f, 0xfe7a, 0xc23f, 0xfeb5, 0xfeb5, 0xff16, 0xff16, 0xfb76,
0xb6df, 0xbe7f, 0xff9e, 0xff3f, 0xd61f, 0xff3f, 0xf2df, 0xf2df, 0xfe5e, 0xf2df, 0xda7f, 0xfe97, 0xfe97, 0xda7f, 0xc23f, 0xda7f, 0xfb76, 0xfb76, 0xfb76,
0xbe7f, 0xc23f, 0xc23f, 0xd61f, 0xd61f, 0xea3f, 0xea3f, 0xfe5e, 0xfe5e, 0xfe7c, 0xfe7c, 0xfe7a, 0xfe97, 0xfeb5, 0xfeb5, 0xfeb5, 0xfb76, 0xfb76, 0xfb76,
0xbe7f, 0xc23f, 0xd61f, 0xd61f, 0xd61f, 0xea3f, 0xea3f, 0xfe5e, 0xfe5e, 0xfe7c, 0xfe97, 0xfe97, 0xfe97, 0xfeb5, 0xff16, 0xff16, 0xfb76, 0xfb76, 0xfb76,
0xc23f, 0xff9e, 0xc23f, 0xd61f, 0xff3f, 0xea3f, 0xfe5e, 0xff3f, 0xfe7c, 0xfe7c, 0xf2df, 0xfe97, 0xfeb5, 0xfeb5, 0xda7f, 0xff16, 0xc23f, 0xc23f, 0xbe7f,
0xc23f, 0xff9e, 0xff9e, 0xd61f, 0xff9e, 0xea3f, 0xff3f, 0xfe5e, 0xff3f, 0xfe7a, 0xf2df, 0xf2df, 0xfeb5, 0xf2df, 0xda7f, 0xfb76, 0xc23f, 0xfb76, 0xfb76,
0xc23f, 0xff9e, 0xd61f, 0xff9e, 0xff9e, 0xfe5e, 0xff3f, 0xff3f, 0xff3f, 0xfe7a, 0xff3f, 0xfeb5, 0xf2df, 0xff16, 0xda7f, 0xfb76, 0xda7f, 0xda7f, 0xfb76,
0xc23f, 0xff9e, 0xea3f, 0xea3f, 0xff9e, 0xfe5e, 0xff9e, 0xfe7c, 0xff3f, 0xfe97, 0xf2df, 0xfeb5, 0xfeb5, 0xff16, 0xf2df, 0xfb76, 0xda7f, 0xfb76, 0xfb76,
0xd61f, 0xff9e, 0xd61f, 0xea3f, 0xff9e, 0xfe5e, 0xff9e, 0xfe7c, 0xff3f, 0xfe97, 0xff3f, 0xfeb5, 0xff16, 0xfb76, 0xda7f, 0xfb76, 0xda7f, 0xda7f, 0xc23f,
0xd61f, 0xd61f, 0xea3f, 0xea3f, 0xea3f, 0xfe5e, 0xfe7c, 0xfe7a, 0xfe7a, 0xfe97, 0xfeb5, 0xff16, 0xff16, 0xfb76, 0xfb76, 0xfb76, 0xfb76, 0xfb76, 0xfb76,
0xd61f, 0xd61f, 0xea3f, 0xfe5e, 0xfe5e, 0xfe7c, 0xfe7a, 0xfe7a, 0xfe97, 0xfeb5, 0xfeb5, 0xff16, 0xff16, 0xfb76, 0xfb76, 0xfb76, 0xfb76, 0xfb76, 0xfb76,
})},
{"30color-16bpp", video::ECF_A1R5G5B5, to_byte_array<u16>({
0xbabf, 0xbabf, 0xbabf, 0xbabf, 0xbe3f, 0xbdff, 0xc9ff, 0xda1f, 0xee3f, 0xee3f, 0xfa5f, 0xfe5e, 0xfe7c, 0xfe7b, 0xfe79, 0xfe97, 0xfeb5, 0xfed5, 0xff16,
0xbabf, 0xbabf, 0xff1f, 0xff1f, 0xbdff, 0xfaff, 0xf2df, 0xeabf, 0xee3f, 0xe27f, 0xda7f, 0xfe5e, 0xfe7b, 0xc25f, 0xbe7f, 0xbe7f, 0xfeb5, 0xfed5, 0xff56,
0xbabf, 0xff7e, 0xbe7f, 0xc25f, 0xbdff, 0xfaff, 0xda1f, 0xf2df, 0xee3f, 0xda7f, 0xfe5e, 0xce5f, 0xfe79, 0xce5f, 0xfe97, 0xfeb5, 0xfed5, 0xff16, 0xff56,
0xbabf, 0xff7e, 0xbe7f, 0xbdff, 0xc9ff, 0xfaff, 0xda1f, 0xf2df, 0xfa5f, 0xeabf, 0xfe5e, 0xda7f, 0xfe79, 0xce5f, 0xc25f, 0xfeb5, 0xff16, 0xff16, 0xff76,
0xbabf, 0xff7e, 0xc25f, 0xbdff, 0xc9ff, 0xff1f, 0xda1f, 0xf2df, 0xfa5f, 0xeabf, 0xfe7c, 0xda7f, 0xfe79, 0xce5f, 0xfeb5, 0xfed5, 0xff16, 0xff56, 0xff97,
0xbabf, 0xbe7f, 0xff7e, 0xff5e, 0xda1f, 0xff1f, 0xfaff, 0xfaff, 0xfa5f, 0xf2df, 0xeabf, 0xfe79, 0xfe97, 0xda7f, 0xce5f, 0xce5f, 0xff56, 0xff76, 0xff97,
0xbe7f, 0xc25f, 0xbdff, 0xc9ff, 0xda1f, 0xda1f, 0xee3f, 0xfa5f, 0xfa5f, 0xfe7c, 0xfe7b, 0xfe79, 0xfe97, 0xfeb5, 0xfed5, 0xfed5, 0xff76, 0xff76, 0xff97,
0xbe7f, 0xbe3f, 0xc9ff, 0xc9ff, 0xda1f, 0xee3f, 0xee3f, 0xfa5f, 0xfe5e, 0xfe7c, 0xfe79, 0xfe97, 0xfe97, 0xfeb5, 0xff16, 0xff16, 0xff76, 0xff97, 0xff97,
0xbe3f, 0xffbe, 0xc9ff, 0xda1f, 0xff5e, 0xee3f, 0xfa5f, 0xff1f, 0xfe7c, 0xfe7b, 0xf2df, 0xfe97, 0xfeb5, 0xfeb5, 0xda7f, 0xff76, 0xce5f, 0xbe3f, 0xc25f,
0xbe3f, 0xffbe, 0xffbe, 0xda1f, 0xff7e, 0xfa5f, 0xff5e, 0xfe5e, 0xff1f, 0xfe79, 0xf2df, 0xf2df, 0xfeb5, 0xeabf, 0xda7f, 0xff76, 0xce5f, 0xff97, 0xff97,
0xbdff, 0xffbe, 0xda1f, 0xff7e, 0xff7e, 0xfa5f, 0xff5e, 0xff1f, 0xff1f, 0xfe79, 0xfaff, 0xfeb5, 0xf2df, 0xff16, 0xe27f, 0xff97, 0xda7f, 0xce5f, 0xff97,
0xbdff, 0xffbe, 0xda1f, 0xee3f, 0xffbe, 0xfa5f, 0xff7e, 0xfe7b, 0xff1f, 0xfe97, 0xfaff, 0xfeb5, 0xfed5, 0xff56, 0xeabf, 0xff97, 0xda7f, 0xff97, 0xff97,
0xc9ff, 0xffbe, 0xda1f, 0xee3f, 0xff7e, 0xfa5f, 0xff7e, 0xfe7c, 0xff5e, 0xfe97, 0xfaff, 0xfed5, 0xff16, 0xff56, 0xeabf, 0xff97, 0xda7f, 0xda7f, 0xce5f,
0xda1f, 0xda1f, 0xee3f, 0xee3f, 0xfa5f, 0xfe5e, 0xfe7c, 0xfe79, 0xfe79, 0xfe97, 0xfeb5, 0xfed5, 0xff16, 0xff56, 0xff97, 0xff97, 0xff97, 0xff97, 0xff97,
0xda1f, 0xda1f, 0xee3f, 0xfa5f, 0xfe5e, 0xfe7c, 0xfe7b, 0xfe79, 0xfe97, 0xfeb5, 0xfed5, 0xff16, 0xff56, 0xff97, 0xff97, 0xff97, 0xff97, 0xff97, 0xff97,
})},
{"30color-24bpp", video::ECF_R8G8B8, {
0x71, 0xaf, 0xff, 0x71, 0xaf, 0xff, 0x71, 0xaf, 0xff, 0x71, 0xaf, 0xff, 0x7b, 0x8b, 0xff, 0x7a, 0x7f, 0xff, 0x90, 0x7f, 0xff, 0xb6, 0x85, 0xff, 0xd9, 0x8c, 0xff, 0xd9, 0x8c, 0xff, 0xf4, 0x92, 0xfe, 0xfe, 0x96, 0xf0, 0xfd, 0x99, 0xe3, 0xfd, 0x9b, 0xda, 0xfc, 0x9f, 0xca, 0xfc, 0xa4, 0xbc, 0xfb, 0xa9, 0xab, 0xfa, 0xb6, 0xad, 0xf9, 0xc6, 0xb1,
0x71, 0xaf, 0xff, 0x71, 0xaf, 0xff, 0xff, 0xc6, 0xfc, 0xff, 0xc6, 0xfc, 0x7a, 0x7f, 0xff, 0xf7, 0xbe, 0xff, 0xe4, 0xb2, 0xfe, 0xd4, 0xa9, 0xff, 0xd9, 0x8c, 0xff, 0xc3, 0x98, 0xff, 0xb2, 0x9a, 0xff, 0xfe, 0x96, 0xf0, 0xfd, 0x9b, 0xda, 0x86, 0x93, 0xfe, 0x78, 0x9b, 0xff, 0x78, 0x9b, 0xff, 0xfb, 0xa9, 0xab, 0xfa, 0xb6, 0xad, 0xf8, 0xd2, 0xb3,
0x71, 0xaf, 0xff, 0xfe, 0xdc, 0xf3, 0x78, 0x9b, 0xff, 0x86, 0x93, 0xfe, 0x7a, 0x7f, 0xff, 0xf7, 0xbe, 0xff, 0xb6, 0x85, 0xff, 0xe4, 0xb2, 0xfe, 0xd9, 0x8c, 0xff, 0xb2, 0x9a, 0xff, 0xfe, 0x96, 0xf0, 0x9a, 0x91, 0xff, 0xfc, 0x9f, 0xca, 0x9a, 0x91, 0xff, 0xfc, 0xa4, 0xbc, 0xfb, 0xa9, 0xab, 0xfa, 0xb6, 0xad, 0xf9, 0xc6, 0xb1, 0xf8, 0xd2, 0xb3,
0x71, 0xaf, 0xff, 0xfe, 0xdc, 0xf3, 0x78, 0x9b, 0xff, 0x7a, 0x7f, 0xff, 0x90, 0x7f, 0xff, 0xf7, 0xbe, 0xff, 0xb6, 0x85, 0xff, 0xe4, 0xb2, 0xfe, 0xf4, 0x92, 0xfe, 0xd4, 0xa9, 0xff, 0xfe, 0x96, 0xf0, 0xb2, 0x9a, 0xff, 0xfc, 0x9f, 0xca, 0x9a, 0x91, 0xff, 0x86, 0x93, 0xfe, 0xfb, 0xa9, 0xab, 0xf9, 0xc6, 0xb1, 0xf9, 0xc6, 0xb1, 0xf8, 0xd8, 0xb5,
0x71, 0xaf, 0xff, 0xfe, 0xdc, 0xf3, 0x86, 0x93, 0xfe, 0x7a, 0x7f, 0xff, 0x90, 0x7f, 0xff, 0xff, 0xc6, 0xfc, 0xb6, 0x85, 0xff, 0xe4, 0xb2, 0xfe, 0xf4, 0x92, 0xfe, 0xd4, 0xa9, 0xff, 0xfd, 0x99, 0xe3, 0xb2, 0x9a, 0xff, 0xfc, 0x9f, 0xca, 0x9a, 0x91, 0xff, 0xfb, 0xa9, 0xab, 0xfa, 0xb6, 0xad, 0xf9, 0xc6, 0xb1, 0xf8, 0xd2, 0xb3, 0xf8, 0xe4, 0xb9,
0x71, 0xaf, 0xff, 0x78, 0x9b, 0xff, 0xfe, 0xdc, 0xf3, 0xff, 0xd0, 0xf7, 0xb6, 0x85, 0xff, 0xff, 0xc6, 0xfc, 0xf7, 0xbe, 0xff, 0xf7, 0xbe, 0xff, 0xf4, 0x92, 0xfe, 0xe4, 0xb2, 0xfe, 0xd4, 0xa9, 0xff, 0xfc, 0x9f, 0xca, 0xfc, 0xa4, 0xbc, 0xb2, 0x9a, 0xff, 0x9a, 0x91, 0xff, 0x9a, 0x91, 0xff, 0xf8, 0xd2, 0xb3, 0xf8, 0xd8, 0xb5, 0xf8, 0xe4, 0xb9,
0x78, 0x9b, 0xff, 0x86, 0x93, 0xfe, 0x7a, 0x7f, 0xff, 0x90, 0x7f, 0xff, 0xb6, 0x85, 0xff, 0xb6, 0x85, 0xff, 0xd9, 0x8c, 0xff, 0xf4, 0x92, 0xfe, 0xf4, 0x92, 0xfe, 0xfd, 0x99, 0xe3, 0xfd, 0x9b, 0xda, 0xfc, 0x9f, 0xca, 0xfc, 0xa4, 0xbc, 0xfb, 0xa9, 0xab, 0xfa, 0xb6, 0xad, 0xfa, 0xb6, 0xad, 0xf8, 0xd8, 0xb5, 0xf8, 0xd8, 0xb5, 0xf8, 0xe4, 0xb9,
0x78, 0x9b, 0xff, 0x7b, 0x8b, 0xff, 0x90, 0x7f, 0xff, 0x90, 0x7f, 0xff, 0xb6, 0x85, 0xff, 0xd9, 0x8c, 0xff, 0xd9, 0x8c, 0xff, 0xf4, 0x92, 0xfe, 0xfe, 0x96, 0xf0, 0xfd, 0x99, 0xe3, 0xfc, 0x9f, 0xca, 0xfc, 0xa4, 0xbc, 0xfc, 0xa4, 0xbc, 0xfb, 0xa9, 0xab, 0xf9, 0xc6, 0xb1, 0xf9, 0xc6, 0xb1, 0xf8, 0xd8, 0xb5, 0xf8, 0xe4, 0xb9, 0xf8, 0xe4, 0xb9,
0x7b, 0x8b, 0xff, 0xff, 0xeb, 0xf2, 0x90, 0x7f, 0xff, 0xb6, 0x85, 0xff, 0xff, 0xd0, 0xf7, 0xd9, 0x8c, 0xff, 0xf4, 0x92, 0xfe, 0xff, 0xc6, 0xfc, 0xfd, 0x99, 0xe3, 0xfd, 0x9b, 0xda, 0xe4, 0xb2, 0xfe, 0xfc, 0xa4, 0xbc, 0xfb, 0xa9, 0xab, 0xfb, 0xa9, 0xab, 0xb2, 0x9a, 0xff, 0xf8, 0xd8, 0xb5, 0x9a, 0x91, 0xff, 0x7b, 0x8b, 0xff, 0x86, 0x93, 0xfe,
0x7b, 0x8b, 0xff, 0xff, 0xeb, 0xf2, 0xff, 0xeb, 0xf2, 0xb6, 0x85, 0xff, 0xfe, 0xdc, 0xf3, 0xf4, 0x92, 0xfe, 0xff, 0xd0, 0xf7, 0xfe, 0x96, 0xf0, 0xff, 0xc6, 0xfc, 0xfc, 0x9f, 0xca, 0xe4, 0xb2, 0xfe, 0xe4, 0xb2, 0xfe, 0xfb, 0xa9, 0xab, 0xd4, 0xa9, 0xff, 0xb2, 0x9a, 0xff, 0xf8, 0xd8, 0xb5, 0x9a, 0x91, 0xff, 0xf8, 0xe4, 0xb9, 0xf8, 0xe4, 0xb9,
0x7a, 0x7f, 0xff, 0xff, 0xeb, 0xf2, 0xb6, 0x85, 0xff, 0xfe, 0xdc, 0xf3, 0xfe, 0xdc, 0xf3, 0xf4, 0x92, 0xfe, 0xff, 0xd0, 0xf7, 0xff, 0xc6, 0xfc, 0xff, 0xc6, 0xfc, 0xfc, 0x9f, 0xca, 0xf7, 0xbe, 0xff, 0xfb, 0xa9, 0xab, 0xe4, 0xb2, 0xfe, 0xf9, 0xc6, 0xb1, 0xc3, 0x98, 0xff, 0xf8, 0xe4, 0xb9, 0xb2, 0x9a, 0xff, 0x9a, 0x91, 0xff, 0xf8, 0xe4, 0xb9,
0x7a, 0x7f, 0xff, 0xff, 0xeb, 0xf2, 0xb6, 0x85, 0xff, 0xd9, 0x8c, 0xff, 0xff, 0xeb, 0xf2, 0xf4, 0x92, 0xfe, 0xfe, 0xdc, 0xf3, 0xfd, 0x9b, 0xda, 0xff, 0xc6, 0xfc, 0xfc, 0xa4, 0xbc, 0xf7, 0xbe, 0xff, 0xfb, 0xa9, 0xab, 0xfa, 0xb6, 0xad, 0xf8, 0xd2, 0xb3, 0xd4, 0xa9, 0xff, 0xf8, 0xe4, 0xb9, 0xb2, 0x9a, 0xff, 0xf8, 0xe4, 0xb9, 0xf8, 0xe4, 0xb9,
0x90, 0x7f, 0xff, 0xff, 0xeb, 0xf2, 0xb6, 0x85, 0xff, 0xd9, 0x8c, 0xff, 0xfe, 0xdc, 0xf3, 0xf4, 0x92, 0xfe, 0xfe, 0xdc, 0xf3, 0xfd, 0x99, 0xe3, 0xff, 0xd0, 0xf7, 0xfc, 0xa4, 0xbc, 0xf7, 0xbe, 0xff, 0xfa, 0xb6, 0xad, 0xf9, 0xc6, 0xb1, 0xf8, 0xd2, 0xb3, 0xd4, 0xa9, 0xff, 0xf8, 0xe4, 0xb9, 0xb2, 0x9a, 0xff, 0xb2, 0x9a, 0xff, 0x9a, 0x91, 0xff,
0xb6, 0x85, 0xff, 0xb6, 0x85, 0xff, 0xd9, 0x8c, 0xff, 0xd9, 0x8c, 0xff, 0xf4, 0x92, 0xfe, 0xfe, 0x96, 0xf0, 0xfd, 0x99, 0xe3, 0xfc, 0x9f, 0xca, 0xfc, 0x9f, 0xca, 0xfc, 0xa4, 0xbc, 0xfb, 0xa9, 0xab, 0xfa, 0xb6, 0xad, 0xf9, 0xc6, 0xb1, 0xf8, 0xd2, 0xb3, 0xf8, 0xe4, 0xb9, 0xf8, 0xe4, 0xb9, 0xf8, 0xe4, 0xb9, 0xf8, 0xe4, 0xb9, 0xf8, 0xe4, 0xb9,
0xb6, 0x85, 0xff, 0xb6, 0x85, 0xff, 0xd9, 0x8c, 0xff, 0xf4, 0x92, 0xfe, 0xfe, 0x96, 0xf0, 0xfd, 0x99, 0xe3, 0xfd, 0x9b, 0xda, 0xfc, 0x9f, 0xca, 0xfc, 0xa4, 0xbc, 0xfb, 0xa9, 0xab, 0xfa, 0xb6, 0xad, 0xf9, 0xc6, 0xb1, 0xf8, 0xd2, 0xb3, 0xf8, 0xe4, 0xb9, 0xf8, 0xe4, 0xb9, 0xf8, 0xe4, 0xb9, 0xf8, 0xe4, 0xb9, 0xf8, 0xe4, 0xb9, 0xf8, 0xe4, 0xb9,
}},
{"30color-32bpp", video::ECF_A8R8G8B8, to_byte_array<u32>({
0xff71afff, 0xff71afff, 0xff71afff, 0xff71afff, 0xff7b8bff, 0xff7a7fff, 0xff907fff, 0xffb685ff, 0xffd98cff, 0xffd98cff, 0xfff492fe, 0xfffe96f0, 0xfffd99e3, 0xfffd9bda, 0xfffc9fca, 0xfffca4bc, 0xfffba9ab, 0xfffab6ad, 0xfff9c6b1,
0xff71afff, 0xff71afff, 0xffffc6fc, 0xffffc6fc, 0xff7a7fff, 0xfff7beff, 0xffe4b2fe, 0xffd4a9ff, 0xffd98cff, 0xffc398ff, 0xffb29aff, 0xfffe96f0, 0xfffd9bda, 0xff8693fe, 0xff789bff, 0xff789bff, 0xfffba9ab, 0xfffab6ad, 0xfff8d2b3,
0xff71afff, 0xfffedcf3, 0xff789bff, 0xff8693fe, 0xff7a7fff, 0xfff7beff, 0xffb685ff, 0xffe4b2fe, 0xffd98cff, 0xffb29aff, 0xfffe96f0, 0xff9a91ff, 0xfffc9fca, 0xff9a91ff, 0xfffca4bc, 0xfffba9ab, 0xfffab6ad, 0xfff9c6b1, 0xfff8d2b3,
0xff71afff, 0xfffedcf3, 0xff789bff, 0xff7a7fff, 0xff907fff, 0xfff7beff, 0xffb685ff, 0xffe4b2fe, 0xfff492fe, 0xffd4a9ff, 0xfffe96f0, 0xffb29aff, 0xfffc9fca, 0xff9a91ff, 0xff8693fe, 0xfffba9ab, 0xfff9c6b1, 0xfff9c6b1, 0xfff8d8b5,
0xff71afff, 0xfffedcf3, 0xff8693fe, 0xff7a7fff, 0xff907fff, 0xffffc6fc, 0xffb685ff, 0xffe4b2fe, 0xfff492fe, 0xffd4a9ff, 0xfffd99e3, 0xffb29aff, 0xfffc9fca, 0xff9a91ff, 0xfffba9ab, 0xfffab6ad, 0xfff9c6b1, 0xfff8d2b3, 0xfff8e4b9,
0xff71afff, 0xff789bff, 0xfffedcf3, 0xffffd0f7, 0xffb685ff, 0xffffc6fc, 0xfff7beff, 0xfff7beff, 0xfff492fe, 0xffe4b2fe, 0xffd4a9ff, 0xfffc9fca, 0xfffca4bc, 0xffb29aff, 0xff9a91ff, 0xff9a91ff, 0xfff8d2b3, 0xfff8d8b5, 0xfff8e4b9,
0xff789bff, 0xff8693fe, 0xff7a7fff, 0xff907fff, 0xffb685ff, 0xffb685ff, 0xffd98cff, 0xfff492fe, 0xfff492fe, 0xfffd99e3, 0xfffd9bda, 0xfffc9fca, 0xfffca4bc, 0xfffba9ab, 0xfffab6ad, 0xfffab6ad, 0xfff8d8b5, 0xfff8d8b5, 0xfff8e4b9,
0xff789bff, 0xff7b8bff, 0xff907fff, 0xff907fff, 0xffb685ff, 0xffd98cff, 0xffd98cff, 0xfff492fe, 0xfffe96f0, 0xfffd99e3, 0xfffc9fca, 0xfffca4bc, 0xfffca4bc, 0xfffba9ab, 0xfff9c6b1, 0xfff9c6b1, 0xfff8d8b5, 0xfff8e4b9, 0xfff8e4b9,
0xff7b8bff, 0xffffebf2, 0xff907fff, 0xffb685ff, 0xffffd0f7, 0xffd98cff, 0xfff492fe, 0xffffc6fc, 0xfffd99e3, 0xfffd9bda, 0xffe4b2fe, 0xfffca4bc, 0xfffba9ab, 0xfffba9ab, 0xffb29aff, 0xfff8d8b5, 0xff9a91ff, 0xff7b8bff, 0xff8693fe,
0xff7b8bff, 0xffffebf2, 0xffffebf2, 0xffb685ff, 0xfffedcf3, 0xfff492fe, 0xffffd0f7, 0xfffe96f0, 0xffffc6fc, 0xfffc9fca, 0xffe4b2fe, 0xffe4b2fe, 0xfffba9ab, 0xffd4a9ff, 0xffb29aff, 0xfff8d8b5, 0xff9a91ff, 0xfff8e4b9, 0xfff8e4b9,
0xff7a7fff, 0xffffebf2, 0xffb685ff, 0xfffedcf3, 0xfffedcf3, 0xfff492fe, 0xffffd0f7, 0xffffc6fc, 0xffffc6fc, 0xfffc9fca, 0xfff7beff, 0xfffba9ab, 0xffe4b2fe, 0xfff9c6b1, 0xffc398ff, 0xfff8e4b9, 0xffb29aff, 0xff9a91ff, 0xfff8e4b9,
0xff7a7fff, 0xffffebf2, 0xffb685ff, 0xffd98cff, 0xffffebf2, 0xfff492fe, 0xfffedcf3, 0xfffd9bda, 0xffffc6fc, 0xfffca4bc, 0xfff7beff, 0xfffba9ab, 0xfffab6ad, 0xfff8d2b3, 0xffd4a9ff, 0xfff8e4b9, 0xffb29aff, 0xfff8e4b9, 0xfff8e4b9,
0xff907fff, 0xffffebf2, 0xffb685ff, 0xffd98cff, 0xfffedcf3, 0xfff492fe, 0xfffedcf3, 0xfffd99e3, 0xffffd0f7, 0xfffca4bc, 0xfff7beff, 0xfffab6ad, 0xfff9c6b1, 0xfff8d2b3, 0xffd4a9ff, 0xfff8e4b9, 0xffb29aff, 0xffb29aff, 0xff9a91ff,
0xffb685ff, 0xffb685ff, 0xffd98cff, 0xffd98cff, 0xfff492fe, 0xfffe96f0, 0xfffd99e3, 0xfffc9fca, 0xfffc9fca, 0xfffca4bc, 0xfffba9ab, 0xfffab6ad, 0xfff9c6b1, 0xfff8d2b3, 0xfff8e4b9, 0xfff8e4b9, 0xfff8e4b9, 0xfff8e4b9, 0xfff8e4b9,
0xffb685ff, 0xffb685ff, 0xffd98cff, 0xfff492fe, 0xfffe96f0, 0xfffd99e3, 0xfffd9bda, 0xfffc9fca, 0xfffca4bc, 0xfffba9ab, 0xfffab6ad, 0xfff9c6b1, 0xfff8d2b3, 0xfff8e4b9, 0xfff8e4b9, 0xfff8e4b9, 0xfff8e4b9, 0xfff8e4b9, 0xfff8e4b9,
})},
};
void printImageBytes(const video::IImage *img)
{
const auto *data = (u8 *)img->getData();
const auto w = img->getPitch();
const auto h = img->getDimension().Height;
for (int y = 0; y < h; y++) {
for (int k = 0; k < w; k++) {
std::printf("0x%02x, ", *data++);
}
std::printf("\n");
}
}
int main(int argc, char *argv[])
try {
if (argc != 3)
throw std::runtime_error("Invalid arguments. Expected sample ID and image file name");
const ImageDesc *sample = nullptr;
for (auto &&image: test_images) {
if (strcmp(argv[1], image.name) == 0)
sample = &image;
}
if (!sample)
throw std::runtime_error("Sample not found");
SIrrlichtCreationParameters p;
p.DriverType = video::EDT_NULL;
p.WindowSize = core::dimension2du(640, 480);
p.LoggingLevel = ELL_DEBUG;
auto *device = createDeviceEx(p);
if (!device)
throw std::runtime_error("Failed to create device");
auto *driver = device->getVideoDriver();
auto *img = driver->createImageFromFile(argv[2]);
if (!img)
throw std::runtime_error("Failed to load image");
if (img->getDimension() != core::dimension2du{19, 15})
throw std::runtime_error("Wrong image dimensions");
if (img->getColorFormat() != sample->format)
throw std::runtime_error("Wrong image format");
if (img->getImageDataSizeInBytes() != sample->data.size())
throw std::logic_error("Image data size not equal to sample size");
if (memcmp(img->getData(), sample->data.data(), sample->data.size()) != 0) {
printImageBytes(img);
throw std::runtime_error("Wrong image contents");
}
img->drop();
device->drop();
return 0;
} catch (const std::exception &e) {
std::printf("Test failed: %s\n", e.what());
return 1;
}