diff --git a/irr/.editorconfig b/irr/.editorconfig new file mode 100755 index 000000000..080ba5b54 --- /dev/null +++ b/irr/.editorconfig @@ -0,0 +1,10 @@ +root = true + +[*] +charset = utf-8 + +[*.{cpp,h,txt,cmake,fsh,vsh}] +indent_size = 4 +indent_style = tab +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/irr/.github/workflows/build.yml b/irr/.github/workflows/build.yml new file mode 100644 index 000000000..f31521bd2 --- /dev/null +++ b/irr/.github/workflows/build.yml @@ -0,0 +1,310 @@ +name: build + +# build on c/cpp changes or workflow changes +on: + - push + - pull_request + +jobs: + + linux-gl: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4 + - name: Install deps + run: | + sudo apt-get update + sudo apt-get install g++ cmake libxi-dev libgl1-mesa-dev libpng-dev libjpeg-dev zlib1g-dev -qyy + + - name: Build + run: | + cmake . -DUSE_SDL2=OFF + make VERBOSE=1 -j2 + + - name: Test + run: | + ctest --output-on-failure + + - name: Package + run: | + make DESTDIR=$PWD/_install install + tar -c -I "gzip -9" -f irrlicht-linux.tar.gz -C ./_install/usr/local . + + - uses: actions/upload-artifact@v4 + with: + name: irrlicht-linux + path: ./irrlicht-linux.tar.gz + + linux-gles: + # Xvfb test is broken on 20.04 for unknown reasons (not our bug) + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: Install deps + run: | + sudo apt-get update + sudo apt-get install g++ cmake libxi-dev libgles2-mesa-dev libpng-dev libjpeg-dev zlib1g-dev xvfb -qyy + + - name: Build + run: | + cmake . -DBUILD_EXAMPLES=1 -DUSE_SDL2=OFF -DENABLE_OPENGL=OFF -DENABLE_GLES2=ON + make -j2 + + - name: Test (headless) + run: | + cd bin/Linux + ./AutomatedTest null + + - name: Test (Xvfb) + run: | + cd bin/Linux + LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest ogles2 + + linux-sdl: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4 + - name: Install deps + run: | + sudo apt-get update + sudo apt-get install g++ cmake libsdl2-dev libpng-dev libjpeg-dev zlib1g-dev -qyy + + - name: Build + run: | + cmake . -DBUILD_EXAMPLES=1 -DUSE_SDL2=ON -DCMAKE_BUILD_TYPE=Debug + make -j2 + + - name: Test (headless) + run: | + cd bin/Linux + ./AutomatedTest null + + linux-sdl-gl3: + # Xvfb test is broken on 20.04 for unknown reasons (not our bug) + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: Install deps + run: | + sudo apt-get update + sudo apt-get install g++ cmake libsdl2-dev libpng-dev libjpeg-dev zlib1g-dev xvfb -qyy + + - name: Build + run: | + cmake . -DBUILD_EXAMPLES=1 -DUSE_SDL2=ON -DENABLE_OPENGL=OFF -DENABLE_OPENGL3=ON + make -j2 + + - name: Test (headless) + run: | + cd bin/Linux + ./AutomatedTest null + + - name: Test (Xvfb) + run: | + cd bin/Linux + LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest opengl3 + + linux-sdl-gles2: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4 + - name: Install deps + run: | + sudo apt-get update + sudo apt-get install g++ cmake libsdl2-dev libpng-dev libjpeg-dev zlib1g-dev xvfb -qyy + + - name: Build + run: | + cmake . -DBUILD_EXAMPLES=1 -DUSE_SDL2=ON -DENABLE_OPENGL=OFF -DENABLE_GLES2=ON + make -j2 + + - name: Test (headless) + run: | + cd bin/Linux + ./AutomatedTest null + + - name: Test (Xvfb) + run: | + cd bin/Linux + LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest ogles2 + + mingw: + name: "MinGW ${{matrix.config.variant}}${{matrix.config.extras}}" + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + config: + - {variant: win32, arch: i686} + - {variant: win64, arch: x86_64} + - {variant: win32, arch: i686, extras: "-sdl"} + - {variant: win64, arch: x86_64, extras: "-sdl"} + steps: + - uses: actions/checkout@v4 + - name: Install compiler + run: | + sudo apt-get update && sudo apt-get install cmake -qyy + ./scripts/ci-get-mingw.sh + + - name: Build + run: | + ./scripts/ci-build-mingw.sh package + env: + CC: ${{matrix.config.arch}}-w64-mingw32-clang + CXX: ${{matrix.config.arch}}-w64-mingw32-clang++ + extras: ${{matrix.config.extras}} + + - uses: actions/upload-artifact@v4 + with: + name: irrlicht-${{matrix.config.variant}}${{matrix.config.extras}} + path: ./irrlicht-${{matrix.config.variant}}${{matrix.config.extras}}.zip + + macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - name: Install deps + run: | + brew update --auto-update + brew install cmake libpng jpeg + env: + HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 + HOMEBREW_NO_INSTALL_CLEANUP: 1 + + - name: Build + run: | + cmake . -DCMAKE_FIND_FRAMEWORK=LAST -DBUILD_EXAMPLES=1 + make -j3 + + - name: Test (headless) + run: | + ./bin/OSX/AutomatedTest null + + macos-sdl: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - name: Install deps + run: | + brew update --auto-update + brew install cmake libpng jpeg sdl2 + env: + HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 + HOMEBREW_NO_INSTALL_CLEANUP: 1 + + - name: Build + run: | + cmake . -DCMAKE_FIND_FRAMEWORK=LAST -DBUILD_EXAMPLES=1 -DUSE_SDL2=1 + make -j3 + + msvc: + name: VS 2019 ${{ matrix.config.arch }} ${{ matrix.sdl.label }} + runs-on: windows-2019 + env: + VCPKG_VERSION: 8eb57355a4ffb410a2e94c07b4dca2dffbee8e50 + # 2023.10.19 + vcpkg_packages: zlib libpng libjpeg-turbo + strategy: + fail-fast: false + matrix: + config: + - + arch: x86 + generator: "-G'Visual Studio 16 2019' -A Win32" + vcpkg_triplet: x86-windows + - + arch: x64 + generator: "-G'Visual Studio 16 2019' -A x64" + vcpkg_triplet: x64-windows + sdl: + - + use: FALSE + label: '(no SDL)' + vcpkg_packages: opengl-registry + - + use: TRUE + label: '(with SDL)' + vcpkg_packages: sdl2 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Restore from cache and run vcpkg + uses: lukka/run-vcpkg@v7 + with: + vcpkgArguments: ${{env.vcpkg_packages}} ${{matrix.sdl.vcpkg_packages}} + vcpkgDirectory: '${{ github.workspace }}\vcpkg' + appendedCacheKey: ${{ matrix.config.vcpkg_triplet }} + vcpkgGitCommitId: ${{ env.VCPKG_VERSION }} + vcpkgTriplet: ${{ matrix.config.vcpkg_triplet }} + + - name: CMake + run: | + cmake ${{matrix.config.generator}} ` + -DUSE_SDL2=${{matrix.sdl.use}} ` + -DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}\vcpkg\scripts\buildsystems\vcpkg.cmake" ` + -DCMAKE_BUILD_TYPE=Release . + + - name: Build + run: cmake --build . --config Release + + - name: Create artifact folder + run: | + mkdir artifact/ + mkdir artifact/lib/ + + - name: Move dlls into artifact folder + run: move bin\Win32-VisualStudio\Release\* artifact\lib\ + + - name: Move includes into artifact folder + run: move include artifact/ + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: msvc-${{ matrix.config.arch }}-${{matrix.sdl.use}} + path: artifact/ + + android: + name: Android ${{ matrix.arch }} + runs-on: ubuntu-20.04 + env: + ndk_version: "r25c" + ANDROID_NDK: ${{ github.workspace }}/android-ndk + strategy: + matrix: + arch: [armeabi-v7a, arm64-v8a, x86, x86_64] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install deps + run: | + sudo rm /var/lib/man-db/auto-update + sudo apt-get update + sudo apt-get install -qyy wget unzip zip gcc-multilib make cmake + + - name: Cache NDK + id: cache-ndk + uses: actions/cache@v4 + with: + key: android-ndk-${{ env.ndk_version }}-linux + path: ${{ env.ANDROID_NDK }} + + - name: Install NDK + run: | + wget --progress=bar:force "http://dl.google.com/android/repository/android-ndk-${ndk_version}-linux.zip" + unzip -q "android-ndk-${ndk_version}-linux.zip" + rm "android-ndk-${ndk_version}-linux.zip" + mv "android-ndk-${ndk_version}" "${ANDROID_NDK}" + if: ${{ steps.cache-ndk.outputs.cache-hit != 'true' }} + + - name: Build + run: ./scripts/ci-build-android.sh ${{ matrix.arch }} + + #- name: Upload Artifact + # uses: actions/upload-artifact@v4 + # with: + # name: irrlicht-android-${{ matrix.arch }} + # path: ${{ runner.temp }}/pkg/${{ matrix.arch }} diff --git a/irr/.gitignore b/irr/.gitignore new file mode 100644 index 000000000..8bced59d8 --- /dev/null +++ b/irr/.gitignore @@ -0,0 +1,25 @@ +CMakeFiles +CMakeCache.txt +cmake_install.cmake +install_manifest.txt +IrrlichtMtConfig.cmake +IrrlichtMtConfigVersion.cmake +IrrlichtMtTargets.cmake +CTestTestfile.cmake +Makefile +libs/* +*.so* +*.a +*.exe +*.dll +bin/Linux +scripts/gl2ext.h +scripts/glcorearb.h +scripts/glext.h +*.vcxproj* +*.dir/ +*.sln +*visualstudio/ + +# vscode cmake plugin +build/* diff --git a/irr/CMakeLists.txt b/irr/CMakeLists.txt new file mode 100644 index 000000000..113a8bfa6 --- /dev/null +++ b/irr/CMakeLists.txt @@ -0,0 +1,82 @@ +cmake_minimum_required(VERSION 3.12) + +set(IRRLICHTMT_REVISION 15) + +project(Irrlicht + VERSION 1.9.0.${IRRLICHTMT_REVISION} + LANGUAGES CXX +) + +message(STATUS "*** Building IrrlichtMt ${PROJECT_VERSION} ***") + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +include(GNUInstallDirs) + +if(ANDROID) + set(sysname Android) +elseif(APPLE) + set(sysname OSX) +elseif(MSVC) + set(sysname Win32-VisualStudio) +elseif(WIN32) + set(sysname Win32-gcc) +else() + set(sysname Linux) +endif() +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib/${sysname}) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin/${sysname}) + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE) +endif() + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +enable_testing() +add_subdirectory(src) +add_subdirectory(test) + +option(BUILD_EXAMPLES "Build example applications" FALSE) +if(BUILD_EXAMPLES) + add_subdirectory(examples) +endif() + +# Export a file that describes the targets that IrrlichtMt creates. +# The file is placed in the location FILE points to, where CMake can easily +# locate it by pointing CMAKE_PREFIX_PATH to this project root. +export(EXPORT IrrlichtMt-export + FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/IrrlichtMtTargets.cmake" + NAMESPACE IrrlichtMt:: +) + +# Installation of headers. +install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/irrlichtmt" +) + +# Installation of CMake target and configuration files. +install(EXPORT IrrlichtMt-export + FILE IrrlichtMtTargets.cmake + NAMESPACE IrrlichtMt:: + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/IrrlichtMt" +) + +include(CMakePackageConfigHelpers) +configure_package_config_file("${PROJECT_SOURCE_DIR}/Config.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake/IrrlichtMtConfig.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/IrrlichtMt" + NO_SET_AND_CHECK_MACRO + NO_CHECK_REQUIRED_COMPONENTS_MACRO +) +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/cmake/IrrlichtMtConfigVersion.cmake" + COMPATIBILITY AnyNewerVersion +) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/cmake/IrrlichtMtConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/cmake/IrrlichtMtConfigVersion.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/IrrlichtMt" +) diff --git a/irr/Config.cmake.in b/irr/Config.cmake.in new file mode 100644 index 000000000..6a55a6f67 --- /dev/null +++ b/irr/Config.cmake.in @@ -0,0 +1,11 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +if(NOT TARGET IrrlichtMt::IrrlichtMt) + # private dependency only explicitly needed with static libs + if(@USE_SDL2@ AND NOT @BUILD_SHARED_LIBS@) + find_dependency(SDL2) + endif() + include("${CMAKE_CURRENT_LIST_DIR}/IrrlichtMtTargets.cmake") +endif() diff --git a/irr/LICENSE b/irr/LICENSE new file mode 100644 index 000000000..8ad1f24ca --- /dev/null +++ b/irr/LICENSE @@ -0,0 +1,26 @@ +Copyright (C) 2002-2012 Nikolaus Gebhardt + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Please note that the Irrlicht Engine is based in part on the work of the + Independent JPEG Group, the zlib, libPng and aesGladman. This means that if you use + the Irrlicht Engine in your product, you must acknowledge somewhere in your + documentation that you've used the IJPG code. It would also be nice to mention + that you use the Irrlicht Engine, the zlib, libPng and aesGladman. See the + corresponding license files for further informations. It is also possible to disable + usage of those additional libraries by defines in the IrrCompileConfig.h header and + recompiling the engine. diff --git a/irr/README.md b/irr/README.md new file mode 100644 index 000000000..8335019b6 --- /dev/null +++ b/irr/README.md @@ -0,0 +1,88 @@ +IrrlichtMt version 1.9 +====================== + +IrrlichtMt is the 3D engine of [Minetest](https://github.com/minetest). +It is based on the [Irrlicht Engine](https://irrlicht.sourceforge.io/) but is now developed independently. +It is intentionally not compatible to upstream and is planned to be eventually absorbed into Minetest. + +Build +----- + +The build system is CMake. + +The following libraries are required to be installed: +* zlib, libPNG, libJPEG +* OpenGL + * or on mobile: OpenGL ES (can be optionally enabled on desktop too) +* on Unix: X11 +* SDL2 (see below) + +Aside from standard search options (`ZLIB_INCLUDE_DIR`, `ZLIB_LIBRARY`, ...) the following options are available: +* `BUILD_SHARED_LIBS` (default: `ON`) - Build IrrlichtMt as a shared library +* `BUILD_EXAMPLES` (default: `OFF`) - Build example applications +* `ENABLE_OPENGL` - Enable OpenGL driver +* `ENABLE_OPENGL3` (default: `OFF`) - Enable OpenGL 3+ driver +* `ENABLE_GLES1` - Enable OpenGL ES driver, legacy +* `ENABLE_GLES2` - Enable OpenGL ES 2+ driver +* `USE_SDL2` (default: platform-dependent, usually `ON`) - Use SDL2 instead of older native device code + +e.g. on a Linux system you might want to build for local use like this: + + git clone https://github.com/minetest/irrlicht + cd irrlicht + cmake . -DBUILD_SHARED_LIBS=OFF + make -j$(nproc) + +This will put an IrrlichtMtTargets.cmake file into the cmake directory in the current build directory, and it can then be imported from another project by pointing `find_package()` to the build directory, or by setting the `CMAKE_PREFIX_PATH` variable to that same path. + +on Windows system: + +It is highly recommended to use vcpkg as package manager. + +After you successfully built vcpkg you can easily install the required libraries: + + vcpkg install zlib libjpeg-turbo libpng sdl2 --triplet x64-windows + +Run the following script in PowerShell: + + git clone https://github.com/minetest/irrlicht + cd irrlicht + cmake -B build -G "Visual Studio 17 2022" -A "Win64" -DCMAKE_TOOLCHAIN_FILE=[vcpkg-root]/scripts/buildsystems/vcpkg.cmake -DBUILD_SHARED_LIBS=OFF + cmake --build build --config Release + +Platforms +--------- + +We aim to support these platforms: +* Windows via MinGW +* Linux (GL or GLES) +* macOS +* Android + +This doesn't mean other platforms don't work or won't be supported, if you find something that doesn't work contributions are welcome. + +License +------- + +The license of the Irrlicht Engine is based on the zlib/libpng license and applies to this fork, too. + + The Irrlicht Engine License + =========================== + + Copyright (C) 2002-2012 Nikolaus Gebhardt + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgement in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be clearly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. diff --git a/irr/cmake/FindOpenGLES2.cmake b/irr/cmake/FindOpenGLES2.cmake new file mode 100644 index 000000000..9be6ce8e6 --- /dev/null +++ b/irr/cmake/FindOpenGLES2.cmake @@ -0,0 +1,38 @@ +#------------------------------------------------------------------- +# The contents of this file are placed in the public domain. Feel +# free to make use of it in any way you like. +#------------------------------------------------------------------- + +# Try to find OpenGL ES 2 and EGL + +if(WIN32) + find_path(OPENGLES2_INCLUDE_DIR GLES2/gl2.h) + find_library(OPENGLES2_LIBRARY libGLESv2) +elseif(APPLE) + find_library(OPENGLES2_LIBRARY OpenGLES REQUIRED) # framework +else() + # Unix + find_path(OPENGLES2_INCLUDE_DIR GLES2/gl2.h + PATHS /usr/X11R6/include /usr/include + ) + find_library(OPENGLES2_LIBRARY + NAMES GLESv2 + PATHS /usr/X11R6/lib /usr/lib + ) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(OpenGLES2 DEFAULT_MSG OPENGLES2_LIBRARY OPENGLES2_INCLUDE_DIR) + + find_path(EGL_INCLUDE_DIR EGL/egl.h + PATHS /usr/X11R6/include /usr/include + ) + find_library(EGL_LIBRARY + NAMES EGL + PATHS /usr/X11R6/lib /usr/lib + ) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(EGL REQUIRED_VARS EGL_LIBRARY EGL_INCLUDE_DIR NAME_MISMATCHED) +endif() + +set(OPENGLES2_LIBRARIES ${OPENGLES2_LIBRARY} ${EGL_LIBRARY}) diff --git a/irr/examples/AutomatedTest/main.cpp b/irr/examples/AutomatedTest/main.cpp new file mode 100644 index 000000000..c9e5bab68 --- /dev/null +++ b/irr/examples/AutomatedTest/main.cpp @@ -0,0 +1,154 @@ +#include +#include +#include "exampleHelper.h" + +using namespace irr; + +static IrrlichtDevice *device = nullptr; +static int test_fail = 0; + +void test_irr_array(); +void test_irr_string(); + +static video::E_DRIVER_TYPE chooseDriver(core::stringc arg_) +{ + if (arg_ == "null") + return video::EDT_NULL; + if (arg_ == "ogles1") + return video::EDT_OGLES1; + if (arg_ == "ogles2") + return video::EDT_OGLES2; + if (arg_ == "opengl") + return video::EDT_OPENGL; + if (arg_ == "opengl3") + return video::EDT_OPENGL3; + std::cerr << "Unknown driver type: " << arg_.c_str() << ". Trying OpenGL." << std::endl; + return video::EDT_OPENGL; +} + +static inline void check(bool ok, const char *msg) +{ + if (!ok) { + test_fail++; + device->getLogger()->log((core::stringc("FAILED TEST: ") + msg).c_str(), ELL_ERROR); + } +} + +void run_unit_tests() +{ + std::cout << "Running unit tests:" << std::endl; + try { + test_irr_array(); + test_irr_string(); + } catch (const std::exception &e) { + std::cerr << e.what() << std::endl; + test_fail++; + } + std::cout << std::endl; +} + +int main(int argc, char *argv[]) +{ + run_unit_tests(); + + SIrrlichtCreationParameters p; + p.DriverType = chooseDriver(argc > 1 ? argv[1] : ""); + p.WindowSize = core::dimension2du(640, 480); + p.Vsync = true; + p.LoggingLevel = ELL_DEBUG; + + device = createDeviceEx(p); + if (!device) + return 1; + + { + u32 total = 0; + device->getOSOperator()->getSystemMemory(&total, nullptr); + core::stringc message = core::stringc("Total RAM in MiB: ") + core::stringc(total >> 10); + device->getLogger()->log(message.c_str(), ELL_INFORMATION); + check(total > 130 * 1024, "RAM amount"); + } + + device->setWindowCaption(L"Hello World!"); + device->setResizable(true); + + video::IVideoDriver *driver = device->getVideoDriver(); + scene::ISceneManager *smgr = device->getSceneManager(); + gui::IGUIEnvironment *guienv = device->getGUIEnvironment(); + + guienv->addStaticText(L"sample text", core::rect(10, 10, 110, 22), false); + + gui::IGUIButton *button = guienv->addButton( + core::rect(10, 30, 110, 30 + 32), 0, -1, L"sample button", + L"sample tooltip"); + + gui::IGUIEditBox *editbox = guienv->addEditBox(L"", + core::rect(10, 70, 60, 70 + 16)); + + const io::path mediaPath = getExampleMediaPath(); + + auto mesh_file = device->getFileSystem()->createAndOpenFile(mediaPath + "coolguy_opt.x"); + check(mesh_file, "mesh file loading"); + scene::IAnimatedMesh *mesh = smgr->getMesh(mesh_file); + check(mesh, "mesh loading"); + if (mesh_file) + mesh_file->drop(); + if (mesh) { + video::ITexture *tex = driver->getTexture(mediaPath + "cooltexture.png"); + check(tex, "texture loading"); + scene::IAnimatedMeshSceneNode *node = smgr->addAnimatedMeshSceneNode(mesh); + if (node) { + node->forEachMaterial([tex](video::SMaterial &mat) { + mat.Lighting = false; + mat.setTexture(0, tex); + }); + node->setFrameLoop(0, 29); + node->setAnimationSpeed(30); + } + } + + smgr->addCameraSceneNode(0, core::vector3df(0, 4, 5), core::vector3df(0, 2, 0)); + + s32 n = 0; + SEvent event; + device->getTimer()->start(); + + while (device->run()) { + if (device->getTimer()->getTime() >= 1000) { + device->getTimer()->setTime(0); + ++n; + if (n == 1) { // Tooltip display + bzero(&event, sizeof(SEvent)); + event.EventType = irr::EET_MOUSE_INPUT_EVENT; + event.MouseInput.Event = irr::EMIE_MOUSE_MOVED; + event.MouseInput.X = button->getAbsolutePosition().getCenter().X; + event.MouseInput.Y = button->getAbsolutePosition().getCenter().Y; + device->postEventFromUser(event); + } else if (n == 2) // Text input focus + guienv->setFocus(editbox); + else if (n == 3) { // Keypress for Text input + bzero(&event, sizeof(SEvent)); + event.EventType = irr::EET_KEY_INPUT_EVENT; + event.KeyInput.Char = L'a'; + event.KeyInput.Key = KEY_KEY_A; + event.KeyInput.PressedDown = true; + device->postEventFromUser(event); + event.KeyInput.PressedDown = false; + device->postEventFromUser(event); + } else + device->closeDevice(); + } + + driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, + video::SColor(255, 100, 100, 150)); + smgr->drawAll(); + guienv->drawAll(); + driver->endScene(); + } + + check(core::stringw(L"a") == editbox->getText(), "EditBox text"); + + device->getLogger()->log("Done.", ELL_INFORMATION); + device->drop(); + return test_fail > 0 ? 1 : 0; +} diff --git a/irr/examples/AutomatedTest/test_array.cpp b/irr/examples/AutomatedTest/test_array.cpp new file mode 100644 index 000000000..42959e913 --- /dev/null +++ b/irr/examples/AutomatedTest/test_array.cpp @@ -0,0 +1,138 @@ +#include +#include "test_helper.h" + +using namespace irr; +using core::array; + +static void test_basics() +{ + array v; + v.push_back(1); // 1 + v.push_front(2); // 2, 1 + v.insert(4, 0); // 4, 2, 1 + v.insert(3, 1); // 4, 3, 2, 1 + v.insert(0, 4); // 4, 3, 2, 1, 0 + UASSERTEQ(v.size(), 5); + UASSERTEQ(v[0], 4); + UASSERTEQ(v[1], 3); + UASSERTEQ(v[2], 2); + UASSERTEQ(v[3], 1); + UASSERTEQ(v[4], 0); + array w = v; + UASSERTEQ(w.size(), 5); + UASSERT(w == v); + w.clear(); + UASSERTEQ(w.size(), 0); + UASSERTEQ(w.allocated_size(), 0); + UASSERT(w.empty()); + w = v; + UASSERTEQ(w.size(), 5); + w.set_used(3); + UASSERTEQ(w.size(), 3); + UASSERTEQ(w[0], 4); + UASSERTEQ(w[1], 3); + UASSERTEQ(w[2], 2); + UASSERTEQ(w.getLast(), 2); + w.set_used(20); + UASSERTEQ(w.size(), 20); + w = v; + w.sort(); + UASSERTEQ(w.size(), 5); + UASSERTEQ(w[0], 0); + UASSERTEQ(w[1], 1); + UASSERTEQ(w[2], 2); + UASSERTEQ(w[3], 3); + UASSERTEQ(w[4], 4); + w.erase(0); + UASSERTEQ(w.size(), 4); + UASSERTEQ(w[0], 1); + UASSERTEQ(w[1], 2); + UASSERTEQ(w[2], 3); + UASSERTEQ(w[3], 4); + w.erase(1, 2); + UASSERTEQ(w.size(), 2); + UASSERTEQ(w[0], 1); + UASSERTEQ(w[1], 4); + w.swap(v); + UASSERTEQ(w.size(), 5); + UASSERTEQ(v.size(), 2); +} + +static void test_linear_searches() +{ + // Populate the array with 0, 1, 2, ..., 100, 100, 99, 98, 97, ..., 0 + array arr; + for (int i = 0; i <= 100; i++) + arr.push_back(i); + for (int i = 100; i >= 0; i--) + arr.push_back(i); + s32 end = arr.size() - 1; + for (int i = 0; i <= 100; i++) { + s32 index = arr.linear_reverse_search(i); + UASSERTEQ(index, end - i); + } + for (int i = 0; i <= 100; i++) { + s32 index = arr.linear_search(i); + UASSERTEQ(index, i); + } +} + +static void test_binary_searches() +{ + const auto &values = {3, 5, 1, 2, 5, 10, 19, 9, 7, 1, 2, 5, 8, 15}; + array arr; + for (int value : values) { + arr.push_back(value); + } + // Test the const form first, it uses a linear search without sorting + const array &carr = arr; + UASSERTEQ(carr.binary_search(20), -1); + UASSERTEQ(carr.binary_search(0), -1); + UASSERTEQ(carr.binary_search(1), 2); + + // Sorted: 1, 1, 2, 2, 3, 5, 5, 5, 7, 8, 9, 10, 15, 19 + UASSERTEQ(arr.binary_search(20), -1); + UASSERTEQ(arr.binary_search(0), -1); + + for (int value : values) { + s32 i = arr.binary_search(value); + UASSERTNE(i, -1); + UASSERTEQ(arr[i], value); + } + + s32 first, last; + first = arr.binary_search_multi(1, last); + UASSERTEQ(first, 0); + UASSERTEQ(last, 1); + + first = arr.binary_search_multi(2, last); + UASSERTEQ(first, 2); + UASSERTEQ(last, 3); + + first = arr.binary_search_multi(3, last); + UASSERTEQ(first, 4); + UASSERTEQ(last, 4); + + first = arr.binary_search_multi(4, last); + UASSERTEQ(first, -1); + + first = arr.binary_search_multi(5, last); + UASSERTEQ(first, 5); + UASSERTEQ(last, 7); + + first = arr.binary_search_multi(7, last); + UASSERTEQ(first, 8); + UASSERTEQ(last, 8); + + first = arr.binary_search_multi(19, last); + UASSERTEQ(first, 13); + UASSERTEQ(last, 13); +} + +void test_irr_array() +{ + test_basics(); + test_linear_searches(); + test_binary_searches(); + std::cout << " test_irr_array PASSED" << std::endl; +} diff --git a/irr/examples/AutomatedTest/test_helper.h b/irr/examples/AutomatedTest/test_helper.h new file mode 100644 index 000000000..5229eff29 --- /dev/null +++ b/irr/examples/AutomatedTest/test_helper.h @@ -0,0 +1,33 @@ +#pragma once + +#include +#include + +class TestFailedException : public std::exception +{ +}; + +// Asserts the comparison specified by CMP is true, or fails the current unit test +#define UASSERTCMP(CMP, actual, expected) \ + do { \ + const auto &a = (actual); \ + const auto &e = (expected); \ + if (!CMP(a, e)) { \ + std::cout \ + << "Test assertion failed: " << #actual << " " << #CMP << " " \ + << #expected << std::endl \ + << " at " << __FILE__ << ":" << __LINE__ << std::endl \ + << " actual: " << a << std::endl \ + << " expected: " \ + << e << std::endl; \ + throw TestFailedException(); \ + } \ + } while (0) + +#define CMPEQ(a, e) (a == e) +#define CMPTRUE(a, e) (a) +#define CMPNE(a, e) (a != e) + +#define UASSERTEQ(actual, expected) UASSERTCMP(CMPEQ, actual, expected) +#define UASSERTNE(actual, nexpected) UASSERTCMP(CMPNE, actual, nexpected) +#define UASSERT(actual) UASSERTCMP(CMPTRUE, actual, true) diff --git a/irr/examples/AutomatedTest/test_string.cpp b/irr/examples/AutomatedTest/test_string.cpp new file mode 100644 index 000000000..4d1291f18 --- /dev/null +++ b/irr/examples/AutomatedTest/test_string.cpp @@ -0,0 +1,205 @@ +#include +#include +#include +#include +#include "test_helper.h" + +using namespace irr; +using namespace irr::core; + +#define CMPSTR(a, b) (!strcmp(a, b)) +#define UASSERTSTR(actual, expected) UASSERTCMP(CMPSTR, actual.c_str(), expected) + +static void test_basics() +{ + // ctor + stringc s; + UASSERTEQ(s.c_str()[0], '\0'); + s = stringc(0.1234567); + UASSERTSTR(s, "0.123457"); + s = stringc(0x1p+53); + UASSERTSTR(s, "9007199254740992.000000"); + s = stringc(static_cast(-102400)); + UASSERTSTR(s, "-102400"); + s = stringc(static_cast(102400)); + UASSERTSTR(s, "102400"); + s = stringc(static_cast(-1024000)); + UASSERTSTR(s, "-1024000"); + s = stringc(static_cast(1024000)); + UASSERTSTR(s, "1024000"); + s = stringc("YESno", 3); + UASSERTSTR(s, "YES"); + s = stringc(L"test", 4); + UASSERTSTR(s, "test"); + s = stringc("Hello World!"); + UASSERTSTR(s, "Hello World!"); + // operator= + s = stringw(L"abcdef"); + UASSERTSTR(s, "abcdef"); + s = L"abcdef"; + UASSERTSTR(s, "abcdef"); + s = static_cast(nullptr); + UASSERTSTR(s, ""); + // operator+ + s = s + stringc("foo"); + UASSERTSTR(s, "foo"); + s = s + L"bar"; + UASSERTSTR(s, "foobar"); + // the rest + s = "f"; + UASSERTEQ(s[0], 'f'); + const auto &sref = s; + UASSERTEQ(sref[0], 'f'); + UASSERT(sref == "f"); + UASSERT(sref == stringc("f")); + s = "a"; + UASSERT(sref < stringc("aa")); + UASSERT(sref < stringc("b")); + UASSERT(stringc("Z") < sref); + UASSERT(!(sref < stringc("a"))); + UASSERT(sref.lower_ignore_case("AA")); + UASSERT(sref.lower_ignore_case("B")); + UASSERT(!sref.lower_ignore_case("A")); + s = "dog"; + UASSERT(sref != "cat"); + UASSERT(sref != stringc("cat")); +} + +static void test_methods() +{ + stringc s; + const auto &sref = s; + s = "irrlicht"; + UASSERTEQ(sref.size(), 8); + UASSERT(!sref.empty()); + s.clear(); + UASSERTEQ(sref.size(), 0); + UASSERT(sref.empty()); + UASSERT(sref[0] == 0); + s = "\tAz#`"; + s.make_lower(); + UASSERTSTR(s, "\taz#`"); + s.make_upper(); + UASSERTSTR(s, "\tAZ#`"); + UASSERT(sref.equals_ignore_case("\taz#`")); + UASSERT(sref.equals_substring_ignore_case("Z#`", 2)); + s = "irrlicht"; + UASSERT(sref.equalsn(stringc("irr"), 3)); + UASSERT(sref.equalsn("irr", 3)); + s = "fo"; + s.append('o'); + UASSERTSTR(s, "foo"); + s.append("bar", 1); + UASSERTSTR(s, "foob"); + s.append("ar", 999999); + UASSERTSTR(s, "foobar"); + s = "nyan"; + s.append(stringc("cat")); + UASSERTSTR(s, "nyancat"); + s.append(stringc("sam"), 1); + UASSERTSTR(s, "nyancats"); + s = "fbar"; + s.insert(1, "ooXX", 2); + UASSERTSTR(s, "foobar"); + UASSERTEQ(sref.findFirst('o'), 1); + UASSERTEQ(sref.findFirst('X'), -1); + UASSERTEQ(sref.findFirstChar("abff", 2), 3); + UASSERTEQ(sref.findFirstCharNotInList("fobb", 2), 3); + UASSERTEQ(sref.findLast('o'), 2); + UASSERTEQ(sref.findLast('X'), -1); + UASSERTEQ(sref.findLastChar("abrr", 2), 4); + UASSERTEQ(sref.findLastCharNotInList("rabb", 2), 3); + UASSERTEQ(sref.findNext('o', 2), 2); + UASSERTEQ(sref.findLast('o', 1), 1); + s = "ob-oob"; + UASSERTEQ(sref.find("ob", 1), 4); + UASSERTEQ(sref.find("ob"), 0); + UASSERTEQ(sref.find("?"), -1); + s = "HOMEOWNER"; + stringc s2 = sref.subString(2, 4); + UASSERTSTR(s2, "MEOW"); + s2 = sref.subString(2, 4, true); + UASSERTSTR(s2, "meow"); + s = "land"; + s.replace('l', 's'); + UASSERTSTR(s, "sand"); + s = ">dog<"; + s.replace("dog", "cat"); + UASSERTSTR(s, ">cat<"); + s.replace("cat", "horse"); + UASSERTSTR(s, ">horse<"); + s.replace("horse", "gnu"); + UASSERTSTR(s, ">gnu<"); + s = " h e l p "; + s.remove(' '); + UASSERTSTR(s, "help"); + s.remove("el"); + UASSERTSTR(s, "hp"); + s = "irrlicht"; + s.removeChars("it"); + UASSERTSTR(s, "rrlch"); + s = "\r\nfoo bar "; + s.trim(); + UASSERTSTR(s, "foo bar"); + s = "foxo"; + s.erase(2); + UASSERTSTR(s, "foo"); + s = "a"; + s.append('\0'); + s.append('b'); + UASSERTEQ(s.size(), 3); + s.validate(); + UASSERTEQ(s.size(), 1); + UASSERTEQ(s.lastChar(), 'a'); + std::vector res; + s = "a,,b,c"; + s.split(res, ",aa", 1, true, false); + UASSERTEQ(res.size(), 3); + UASSERTSTR(res[0], "a"); + UASSERTSTR(res[2], "c"); + res.clear(); + s.split(res, ",", 1, false, true); + UASSERTEQ(res.size(), 7); + UASSERTSTR(res[0], "a"); + UASSERTSTR(res[2], ""); + for (int i = 0; i < 3; i++) + UASSERTSTR(res[2 * i + 1], ","); +} + +static void test_conv() +{ + // locale-independent + + stringw out; + utf8ToWString(out, "†††"); + UASSERTEQ(out.size(), 3); + for (int i = 0; i < 3; i++) + UASSERTEQ(static_cast(out[i]), 0x2020); + + stringc out2; + wStringToUTF8(out2, L"†††"); + UASSERTEQ(out2.size(), 9); + for (int i = 0; i < 3; i++) { + UASSERTEQ(static_cast(out2[3 * i]), 0xe2); + UASSERTEQ(static_cast(out2[3 * i + 1]), 0x80); + UASSERTEQ(static_cast(out2[3 * i + 2]), 0xa0); + } + + // locale-dependent + if (!setlocale(LC_CTYPE, "C.UTF-8")) + setlocale(LC_CTYPE, "UTF-8"); // macOS + + stringw out3; + multibyteToWString(out3, "†††"); + UASSERTEQ(out3.size(), 3); + for (int i = 0; i < 3; i++) + UASSERTEQ(static_cast(out3[i]), 0x2020); +} + +void test_irr_string() +{ + test_basics(); + test_methods(); + test_conv(); + std::cout << " test_irr_string PASSED" << std::endl; +} diff --git a/irr/examples/CMakeLists.txt b/irr/examples/CMakeLists.txt new file mode 100644 index 000000000..03553048e --- /dev/null +++ b/irr/examples/CMakeLists.txt @@ -0,0 +1,17 @@ +set(IRREXAMPLES + # removed +) +if(UNIX) + list(APPEND IRREXAMPLES AutomatedTest) +endif() + +foreach(exname IN ITEMS ${IRREXAMPLES}) + file(GLOB sources "${CMAKE_CURRENT_SOURCE_DIR}/${exname}/*.cpp") + add_executable(${exname} ${sources}) + + target_include_directories(${exname} PRIVATE + ${CMAKE_SOURCE_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/${exname} + ) + target_link_libraries(${exname} IrrlichtMt) +endforeach() diff --git a/irr/include/CMeshBuffer.h b/irr/include/CMeshBuffer.h new file mode 100644 index 000000000..8f8158ff1 --- /dev/null +++ b/irr/include/CMeshBuffer.h @@ -0,0 +1,274 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrArray.h" +#include "IMeshBuffer.h" + +namespace irr +{ +namespace scene +{ +//! Template implementation of the IMeshBuffer interface +template +class CMeshBuffer : public IMeshBuffer +{ +public: + //! Default constructor for empty meshbuffer + CMeshBuffer() : + ChangedID_Vertex(1), ChangedID_Index(1), MappingHint_Vertex(EHM_NEVER), MappingHint_Index(EHM_NEVER), HWBuffer(NULL), PrimitiveType(EPT_TRIANGLES) + { +#ifdef _DEBUG + setDebugName("CMeshBuffer"); +#endif + } + + //! Get material of this meshbuffer + /** \return Material of this buffer */ + const video::SMaterial &getMaterial() const override + { + return Material; + } + + //! Get material of this meshbuffer + /** \return Material of this buffer */ + video::SMaterial &getMaterial() override + { + return Material; + } + + //! Get pointer to vertices + /** \return Pointer to vertices. */ + const void *getVertices() const override + { + return Vertices.const_pointer(); + } + + //! Get pointer to vertices + /** \return Pointer to vertices. */ + void *getVertices() override + { + return Vertices.pointer(); + } + + //! Get number of vertices + /** \return Number of vertices. */ + u32 getVertexCount() const override + { + return Vertices.size(); + } + + //! Get type of index data which is stored in this meshbuffer. + /** \return Index type of this buffer. */ + video::E_INDEX_TYPE getIndexType() const override + { + return video::EIT_16BIT; + } + + //! Get pointer to indices + /** \return Pointer to indices. */ + const u16 *getIndices() const override + { + return Indices.const_pointer(); + } + + //! Get pointer to indices + /** \return Pointer to indices. */ + u16 *getIndices() override + { + return Indices.pointer(); + } + + //! Get number of indices + /** \return Number of indices. */ + u32 getIndexCount() const override + { + return Indices.size(); + } + + //! Get the axis aligned bounding box + /** \return Axis aligned bounding box of this buffer. */ + const core::aabbox3d &getBoundingBox() const override + { + return BoundingBox; + } + + //! Set the axis aligned bounding box + /** \param box New axis aligned bounding box for this buffer. */ + //! set user axis aligned bounding box + void setBoundingBox(const core::aabbox3df &box) override + { + BoundingBox = box; + } + + //! Recalculate the bounding box. + /** should be called if the mesh changed. */ + void recalculateBoundingBox() override + { + if (!Vertices.empty()) { + BoundingBox.reset(Vertices[0].Pos); + const irr::u32 vsize = Vertices.size(); + for (u32 i = 1; i < vsize; ++i) + BoundingBox.addInternalPoint(Vertices[i].Pos); + } else + BoundingBox.reset(0, 0, 0); + } + + //! Get type of vertex data stored in this buffer. + /** \return Type of vertex data. */ + video::E_VERTEX_TYPE getVertexType() const override + { + return T::getType(); + } + + //! returns position of vertex i + const core::vector3df &getPosition(u32 i) const override + { + return Vertices[i].Pos; + } + + //! returns position of vertex i + core::vector3df &getPosition(u32 i) override + { + return Vertices[i].Pos; + } + + //! returns normal of vertex i + const core::vector3df &getNormal(u32 i) const override + { + return Vertices[i].Normal; + } + + //! returns normal of vertex i + core::vector3df &getNormal(u32 i) override + { + return Vertices[i].Normal; + } + + //! returns texture coord of vertex i + const core::vector2df &getTCoords(u32 i) const override + { + return Vertices[i].TCoords; + } + + //! returns texture coord of vertex i + core::vector2df &getTCoords(u32 i) override + { + return Vertices[i].TCoords; + } + + //! Append the vertices and indices to the current buffer + /** Only works for compatible types, i.e. either the same type + or the main buffer is of standard type. Otherwise, behavior is + undefined. + */ + void append(const void *const vertices, u32 numVertices, const u16 *const indices, u32 numIndices) override + { + if (vertices == getVertices()) + return; + + const u32 vertexCount = getVertexCount(); + u32 i; + + Vertices.reallocate(vertexCount + numVertices); + for (i = 0; i < numVertices; ++i) { + Vertices.push_back(static_cast(vertices)[i]); + BoundingBox.addInternalPoint(static_cast(vertices)[i].Pos); + } + + Indices.reallocate(getIndexCount() + numIndices); + for (i = 0; i < numIndices; ++i) { + Indices.push_back(indices[i] + vertexCount); + } + } + + //! get the current hardware mapping hint + E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const override + { + return MappingHint_Vertex; + } + + //! get the current hardware mapping hint + E_HARDWARE_MAPPING getHardwareMappingHint_Index() const override + { + return MappingHint_Index; + } + + //! set the hardware mapping hint, for driver + void setHardwareMappingHint(E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer = EBT_VERTEX_AND_INDEX) override + { + if (Buffer == EBT_VERTEX_AND_INDEX || Buffer == EBT_VERTEX) + MappingHint_Vertex = NewMappingHint; + if (Buffer == EBT_VERTEX_AND_INDEX || Buffer == EBT_INDEX) + MappingHint_Index = NewMappingHint; + } + + //! Describe what kind of primitive geometry is used by the meshbuffer + void setPrimitiveType(E_PRIMITIVE_TYPE type) override + { + PrimitiveType = type; + } + + //! Get the kind of primitive geometry which is used by the meshbuffer + E_PRIMITIVE_TYPE getPrimitiveType() const override + { + return PrimitiveType; + } + + //! flags the mesh as changed, reloads hardware buffers + void setDirty(E_BUFFER_TYPE Buffer = EBT_VERTEX_AND_INDEX) override + { + if (Buffer == EBT_VERTEX_AND_INDEX || Buffer == EBT_VERTEX) + ++ChangedID_Vertex; + if (Buffer == EBT_VERTEX_AND_INDEX || Buffer == EBT_INDEX) + ++ChangedID_Index; + } + + //! Get the currently used ID for identification of changes. + /** This shouldn't be used for anything outside the VideoDriver. */ + u32 getChangedID_Vertex() const override { return ChangedID_Vertex; } + + //! Get the currently used ID for identification of changes. + /** This shouldn't be used for anything outside the VideoDriver. */ + u32 getChangedID_Index() const override { return ChangedID_Index; } + + void setHWBuffer(void *ptr) const override + { + HWBuffer = ptr; + } + + void *getHWBuffer() const override + { + return HWBuffer; + } + + u32 ChangedID_Vertex; + u32 ChangedID_Index; + + //! hardware mapping hint + E_HARDWARE_MAPPING MappingHint_Vertex; + E_HARDWARE_MAPPING MappingHint_Index; + mutable void *HWBuffer; + + //! Material for this meshbuffer. + video::SMaterial Material; + //! Vertices of this buffer + core::array Vertices; + //! Indices into the vertices of this buffer. + core::array Indices; + //! Bounding box of this meshbuffer. + core::aabbox3d BoundingBox; + //! Primitive type used for rendering (triangles, lines, ...) + E_PRIMITIVE_TYPE PrimitiveType; +}; + +//! Standard meshbuffer +typedef CMeshBuffer SMeshBuffer; +//! Meshbuffer with two texture coords per vertex, e.g. for lightmaps +typedef CMeshBuffer SMeshBufferLightMap; +//! Meshbuffer with vertices having tangents stored, e.g. for normal mapping +typedef CMeshBuffer SMeshBufferTangents; +} // end namespace scene +} // end namespace irr diff --git a/irr/include/EAttributes.h b/irr/include/EAttributes.h new file mode 100644 index 000000000..54954ca41 --- /dev/null +++ b/irr/include/EAttributes.h @@ -0,0 +1,32 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +namespace irr +{ +namespace io +{ + +//! Types of attributes available for IAttributes +enum E_ATTRIBUTE_TYPE +{ + // integer attribute + EAT_INT = 0, + + // float attribute + EAT_FLOAT, + + // boolean attribute + EAT_BOOL, + + // known attribute type count + EAT_COUNT, + + // unknown attribute + EAT_UNKNOWN +}; + +} // end namespace io +} // end namespace irr diff --git a/irr/include/ECullingTypes.h b/irr/include/ECullingTypes.h new file mode 100644 index 000000000..95979bef4 --- /dev/null +++ b/irr/include/ECullingTypes.h @@ -0,0 +1,35 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" + +namespace irr +{ +namespace scene +{ + +//! An enumeration for all types of automatic culling for built-in scene nodes +enum E_CULLING_TYPE +{ + EAC_OFF = 0, + EAC_BOX = 1, + EAC_FRUSTUM_BOX = 2, + EAC_FRUSTUM_SPHERE = 4, + EAC_OCC_QUERY = 8 +}; + +//! Names for culling type +const c8 *const AutomaticCullingNames[] = { + "false", + "box", // camera box against node box + "frustum_box", // camera frustum against node box + "frustum_sphere", // camera frustum against node sphere + "occ_query", // occlusion query + 0, + }; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/EDebugSceneTypes.h b/irr/include/EDebugSceneTypes.h new file mode 100644 index 000000000..29ca8ad0e --- /dev/null +++ b/irr/include/EDebugSceneTypes.h @@ -0,0 +1,41 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +namespace irr +{ +namespace scene +{ + +//! An enumeration for all types of debug data for built-in scene nodes (flags) +enum E_DEBUG_SCENE_TYPE +{ + //! No Debug Data ( Default ) + EDS_OFF = 0, + + //! Show Bounding Boxes of SceneNode + EDS_BBOX = 1, + + //! Show Vertex Normals + EDS_NORMALS = 2, + + //! Shows Skeleton/Tags + EDS_SKELETON = 4, + + //! Overlays Mesh Wireframe + EDS_MESH_WIRE_OVERLAY = 8, + + //! Show Bounding Boxes of all MeshBuffers + EDS_BBOX_BUFFERS = 32, + + //! EDS_BBOX | EDS_BBOX_BUFFERS + EDS_BBOX_ALL = EDS_BBOX | EDS_BBOX_BUFFERS, + + //! Show all debug infos + EDS_FULL = 0xffffffff +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/EDeviceTypes.h b/irr/include/EDeviceTypes.h new file mode 100644 index 000000000..1eff4f615 --- /dev/null +++ b/irr/include/EDeviceTypes.h @@ -0,0 +1,46 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +namespace irr +{ + +//! An enum for the different device types supported by the Irrlicht Engine. +enum E_DEVICE_TYPE +{ + + //! A device native to Microsoft Windows + /** This device uses the Win32 API and works in all versions of Windows. */ + EIDT_WIN32, + + //! A device native to Unix style operating systems. + /** This device uses the X11 windowing system and works in Linux, Solaris, FreeBSD, OSX and + other operating systems which support X11. */ + EIDT_X11, + + //! A device native to Mac OSX + /** This device uses Apple's Cocoa API and works in Mac OSX 10.2 and above. */ + EIDT_OSX, + + //! A device which uses Simple DirectMedia Layer + /** The SDL device works under all platforms supported by SDL but first must be compiled + in by setting the USE_SDL2 CMake option to ON */ + EIDT_SDL, + + //! This selection allows Irrlicht to choose the best device from the ones available. + /** If this selection is chosen then Irrlicht will try to use the IrrlichtDevice native + to your operating system. If this is unavailable then the X11, SDL and then console device + will be tried. This ensures that Irrlicht will run even if your platform is unsupported, + although it may not be able to render anything. */ + EIDT_BEST, + + //! A device for Android platforms + /** Best used with embedded devices and mobile systems. + Does not need X11 or other graphical subsystems. + May support hw-acceleration via OpenGL-ES */ + EIDT_ANDROID, +}; + +} // end namespace irr diff --git a/irr/include/EDriverFeatures.h b/irr/include/EDriverFeatures.h new file mode 100644 index 000000000..bde2c7698 --- /dev/null +++ b/irr/include/EDriverFeatures.h @@ -0,0 +1,137 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +namespace irr +{ +namespace video +{ + +//! enumeration for querying features of the video driver. +enum E_VIDEO_DRIVER_FEATURE +{ + //! Is driver able to render to a surface? + EVDF_RENDER_TO_TARGET = 0, + + //! Is hardware transform and lighting supported? + EVDF_HARDWARE_TL, + + //! Are multiple textures per material possible? + EVDF_MULTITEXTURE, + + //! Is driver able to render with a bilinear filter applied? + EVDF_BILINEAR_FILTER, + + //! Can the driver handle mip maps? + EVDF_MIP_MAP, + + //! Can the driver update mip maps automatically? + EVDF_MIP_MAP_AUTO_UPDATE, + + //! Are stencilbuffers switched on and does the device support stencil buffers? + EVDF_STENCIL_BUFFER, + + //! Is Vertex Shader 1.1 supported? + EVDF_VERTEX_SHADER_1_1, + + //! Is Vertex Shader 2.0 supported? + EVDF_VERTEX_SHADER_2_0, + + //! Is Vertex Shader 3.0 supported? + EVDF_VERTEX_SHADER_3_0, + + //! Is Pixel Shader 1.1 supported? + EVDF_PIXEL_SHADER_1_1, + + //! Is Pixel Shader 1.2 supported? + EVDF_PIXEL_SHADER_1_2, + + //! Is Pixel Shader 1.3 supported? + EVDF_PIXEL_SHADER_1_3, + + //! Is Pixel Shader 1.4 supported? + EVDF_PIXEL_SHADER_1_4, + + //! Is Pixel Shader 2.0 supported? + EVDF_PIXEL_SHADER_2_0, + + //! Is Pixel Shader 3.0 supported? + EVDF_PIXEL_SHADER_3_0, + + //! Are ARB vertex programs v1.0 supported? + EVDF_ARB_VERTEX_PROGRAM_1, + + //! Are ARB fragment programs v1.0 supported? + EVDF_ARB_FRAGMENT_PROGRAM_1, + + //! Is GLSL supported? + EVDF_ARB_GLSL, + + //! Is HLSL supported? + EVDF_HLSL, + + //! Are non-square textures supported? + EVDF_TEXTURE_NSQUARE, + + //! Are non-power-of-two textures supported? + EVDF_TEXTURE_NPOT, + + //! Are framebuffer objects supported? + EVDF_FRAMEBUFFER_OBJECT, + + //! Are vertex buffer objects supported? + EVDF_VERTEX_BUFFER_OBJECT, + + //! Supports Alpha To Coverage + EVDF_ALPHA_TO_COVERAGE, + + //! Supports Color masks (disabling color planes in output) + EVDF_COLOR_MASK, + + //! Supports multiple render targets at once + EVDF_MULTIPLE_RENDER_TARGETS, + + //! Supports separate blend settings for multiple render targets + EVDF_MRT_BLEND, + + //! Supports separate color masks for multiple render targets + EVDF_MRT_COLOR_MASK, + + //! Supports separate blend functions for multiple render targets + EVDF_MRT_BLEND_FUNC, + + //! Supports geometry shaders + EVDF_GEOMETRY_SHADER, + + //! Supports occlusion queries + EVDF_OCCLUSION_QUERY, + + //! Supports polygon offset/depth bias for avoiding z-fighting + EVDF_POLYGON_OFFSET, + + //! Support for different blend functions. Without, only ADD is available + EVDF_BLEND_OPERATIONS, + + //! Support for separate blending for RGB and Alpha. + EVDF_BLEND_SEPARATE, + + //! Support for texture coord transformation via texture matrix + EVDF_TEXTURE_MATRIX, + + //! Support for cube map textures. + EVDF_TEXTURE_CUBEMAP, + + //! Support for filtering across different faces of the cubemap + EVDF_TEXTURE_CUBEMAP_SEAMLESS, + + //! Support for clamping vertices beyond far-plane to depth instead of capping them. + EVDF_DEPTH_CLAMP, + + //! Only used for counting the elements of this enum + EVDF_COUNT +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/include/EDriverTypes.h b/irr/include/EDriverTypes.h new file mode 100644 index 000000000..33f987889 --- /dev/null +++ b/irr/include/EDriverTypes.h @@ -0,0 +1,44 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" + +namespace irr +{ +namespace video +{ + +//! An enum for all types of drivers the Irrlicht Engine supports. +enum E_DRIVER_TYPE +{ + //! Null driver, useful for applications to run the engine without visualization. + /** The null device is able to load textures, but does not + render and display any graphics. */ + EDT_NULL, + + //! OpenGL device, available on most platforms. + /** Performs hardware accelerated rendering of 3D and 2D + primitives. */ + EDT_OPENGL, + + //! OpenGL-ES 1.x driver, for embedded and mobile systems + EDT_OGLES1, + + //! OpenGL-ES 2.x driver, for embedded and mobile systems + /** Supports shaders etc. */ + EDT_OGLES2, + + //! WebGL1 friendly subset of OpenGL-ES 2.x driver for Emscripten + EDT_WEBGL1, + + EDT_OPENGL3, + + //! No driver, just for counting the elements + EDT_COUNT +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/include/EFocusFlags.h b/irr/include/EFocusFlags.h new file mode 100644 index 000000000..2c229472d --- /dev/null +++ b/irr/include/EFocusFlags.h @@ -0,0 +1,34 @@ +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +namespace irr +{ +namespace gui +{ + +//! Bitflags for defining the the focus behavior of the gui +// (all names start with SET as we might add REMOVE flags later to control that behavior as well) +enum EFOCUS_FLAG +{ + //! When set the focus changes when the left mouse-button got clicked while over an element + EFF_SET_ON_LMOUSE_DOWN = 0x1, + + //! When set the focus changes when the right mouse-button got clicked while over an element + //! Note that elements usually don't care about right-click and that won't change with this flag + //! This is mostly to allow taking away focus from elements with right-mouse additionally. + EFF_SET_ON_RMOUSE_DOWN = 0x2, + + //! When set the focus changes when the mouse-cursor is over an element + EFF_SET_ON_MOUSE_OVER = 0x4, + + //! When set the focus can be changed with TAB-key combinations. + EFF_SET_ON_TAB = 0x8, + + //! When set it's possible to set the focus to disabled elements. + EFF_CAN_FOCUS_DISABLED = 0x16 +}; + +} // namespace gui +} // namespace irr diff --git a/irr/include/EGUIAlignment.h b/irr/include/EGUIAlignment.h new file mode 100644 index 000000000..80be1c189 --- /dev/null +++ b/irr/include/EGUIAlignment.h @@ -0,0 +1,35 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" + +namespace irr +{ +namespace gui +{ +enum EGUI_ALIGNMENT +{ + //! Aligned to parent's top or left side (default) + EGUIA_UPPERLEFT = 0, + //! Aligned to parent's bottom or right side + EGUIA_LOWERRIGHT, + //! Aligned to the center of parent + EGUIA_CENTER, + //! Stretched to fit parent + EGUIA_SCALE +}; + +//! Names for alignments +const c8 *const GUIAlignmentNames[] = { + "upperLeft", + "lowerRight", + "center", + "scale", + 0, + }; + +} // namespace gui +} // namespace irr diff --git a/irr/include/EGUIElementTypes.h b/irr/include/EGUIElementTypes.h new file mode 100644 index 000000000..557969e44 --- /dev/null +++ b/irr/include/EGUIElementTypes.h @@ -0,0 +1,133 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" + +namespace irr +{ +namespace gui +{ + +//! List of all basic Irrlicht GUI elements. +/** An IGUIElement returns this when calling IGUIElement::getType(); */ +enum EGUI_ELEMENT_TYPE +{ + //! A button (IGUIButton) + EGUIET_BUTTON = 0, + + //! A check box (IGUICheckBox) + EGUIET_CHECK_BOX, + + //! A combo box (IGUIComboBox) + EGUIET_COMBO_BOX, + + //! A context menu (IGUIContextMenu) + EGUIET_CONTEXT_MENU, + + //! A menu (IGUIMenu) + EGUIET_MENU, + + //! An edit box (IGUIEditBox) + EGUIET_EDIT_BOX, + + //! A file open dialog (IGUIFileOpenDialog) + EGUIET_FILE_OPEN_DIALOG, + + //! A color select open dialog (IGUIColorSelectDialog) + EGUIET_COLOR_SELECT_DIALOG, + + //! A in/out fader (IGUIInOutFader) + EGUIET_IN_OUT_FADER, + + //! An image (IGUIImage) + EGUIET_IMAGE, + + //! A list box (IGUIListBox) + EGUIET_LIST_BOX, + + //! A mesh viewer (IGUIMeshViewer) + EGUIET_MESH_VIEWER, + + //! A message box (IGUIWindow) + EGUIET_MESSAGE_BOX, + + //! A modal screen + EGUIET_MODAL_SCREEN, + + //! A scroll bar (IGUIScrollBar) + EGUIET_SCROLL_BAR, + + //! A spin box (IGUISpinBox) + EGUIET_SPIN_BOX, + + //! A static text (IGUIStaticText) + EGUIET_STATIC_TEXT, + + //! A tab (IGUITab) + EGUIET_TAB, + + //! A tab control + EGUIET_TAB_CONTROL, + + //! A Table + EGUIET_TABLE, + + //! A tool bar (IGUIToolBar) + EGUIET_TOOL_BAR, + + //! A Tree View + EGUIET_TREE_VIEW, + + //! A window + EGUIET_WINDOW, + + //! Unknown type. + EGUIET_ELEMENT, + + //! The root of the GUI + EGUIET_ROOT, + + //! Not an element, amount of elements in there + EGUIET_COUNT, + + //! This enum is never used, it only forces the compiler to compile this enumeration to 32 bit. + EGUIET_FORCE_32_BIT = 0x7fffffff + +}; + +//! Names for built-in element types +const c8 *const GUIElementTypeNames[] = { + "button", + "checkBox", + "comboBox", + "contextMenu", + "menu", + "editBox", + "fileOpenDialog", + "colorSelectDialog", + "inOutFader", + "image", + "listBox", + "meshViewer", + "messageBox", + "modalScreen", + "scrollBar", + "spinBox", + "staticText", + "tab", + "tabControl", + "table", + "toolBar", + "treeview", + "window", + "element", + "root", + "profiler", + 0, + }; + +} // end namespace gui +} // end namespace irr diff --git a/irr/include/EHardwareBufferFlags.h b/irr/include/EHardwareBufferFlags.h new file mode 100644 index 000000000..ae1b602e3 --- /dev/null +++ b/irr/include/EHardwareBufferFlags.h @@ -0,0 +1,40 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +namespace irr +{ +namespace scene +{ + +enum E_HARDWARE_MAPPING +{ + //! Don't store on the hardware + EHM_NEVER = 0, + + //! Rarely changed, usually stored completely on the hardware + EHM_STATIC, + + //! Sometimes changed, driver optimized placement + EHM_DYNAMIC, + + //! Always changed, cache optimizing on the GPU + EHM_STREAM +}; + +enum E_BUFFER_TYPE +{ + //! Does not change anything + EBT_NONE = 0, + //! Change the vertex mapping + EBT_VERTEX, + //! Change the index mapping + EBT_INDEX, + //! Change both vertex and index mapping to the same value + EBT_VERTEX_AND_INDEX +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/EMaterialProps.h b/irr/include/EMaterialProps.h new file mode 100644 index 000000000..6f37c95b8 --- /dev/null +++ b/irr/include/EMaterialProps.h @@ -0,0 +1,82 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +namespace irr +{ +namespace video +{ + +//! Material properties +enum E_MATERIAL_PROP +{ + //! Corresponds to SMaterial::Wireframe. + EMP_WIREFRAME = 0x1, + + //! Corresponds to SMaterial::PointCloud. + EMP_POINTCLOUD = 0x2, + + //! Corresponds to SMaterial::GouraudShading. + EMP_GOURAUD_SHADING = 0x4, + + //! Corresponds to SMaterial::Lighting. + EMP_LIGHTING = 0x8, + + //! Corresponds to SMaterial::ZBuffer. + EMP_ZBUFFER = 0x10, + + //! Corresponds to SMaterial::ZWriteEnable. + EMP_ZWRITE_ENABLE = 0x20, + + //! Corresponds to SMaterial::BackfaceCulling. + EMP_BACK_FACE_CULLING = 0x40, + + //! Corresponds to SMaterial::FrontfaceCulling. + EMP_FRONT_FACE_CULLING = 0x80, + + //! Corresponds to SMaterialLayer::MinFilter. + EMP_MIN_FILTER = 0x100, + + //! Corresponds to SMaterialLayer::MagFilter. + EMP_MAG_FILTER = 0x200, + + //! Corresponds to SMaterialLayer::AnisotropicFilter. + EMP_ANISOTROPIC_FILTER = 0x400, + + //! Corresponds to SMaterial::FogEnable. + EMP_FOG_ENABLE = 0x800, + + //! Corresponds to SMaterial::NormalizeNormals. + EMP_NORMALIZE_NORMALS = 0x1000, + + //! Corresponds to SMaterialLayer::TextureWrapU, TextureWrapV and + //! TextureWrapW. + EMP_TEXTURE_WRAP = 0x2000, + + //! Corresponds to SMaterial::AntiAliasing. + EMP_ANTI_ALIASING = 0x4000, + + //! Corresponds to SMaterial::ColorMask. + EMP_COLOR_MASK = 0x8000, + + //! Corresponds to SMaterial::ColorMaterial. + EMP_COLOR_MATERIAL = 0x10000, + + //! Corresponds to SMaterial::UseMipMaps. + EMP_USE_MIP_MAPS = 0x20000, + + //! Corresponds to SMaterial::BlendOperation. + EMP_BLEND_OPERATION = 0x40000, + + //! Corresponds to SMaterial::PolygonOffsetFactor, PolygonOffsetDirection, + //! PolygonOffsetDepthBias and PolygonOffsetSlopeScale. + EMP_POLYGON_OFFSET = 0x80000, + + //! Corresponds to SMaterial::BlendFactor. + EMP_BLEND_FACTOR = 0x100000, +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/include/EMaterialTypes.h b/irr/include/EMaterialTypes.h new file mode 100644 index 000000000..cac8233fe --- /dev/null +++ b/irr/include/EMaterialTypes.h @@ -0,0 +1,74 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" + +namespace irr +{ +namespace video +{ + +//! Abstracted and easy to use fixed function/programmable pipeline material modes. +enum E_MATERIAL_TYPE +{ + //! Standard solid material. + /** Only first texture is used, which is supposed to be the + diffuse material. */ + EMT_SOLID = 0, + + //! Makes the material transparent based on the texture alpha channel. + /** The final color is blended together from the destination + color and the texture color, using the alpha channel value as + blend factor. Only first texture is used. If you are using + this material with small textures, it is a good idea to load + the texture in 32 bit mode + (video::IVideoDriver::setTextureCreationFlag()). Also, an alpha + ref is used, which can be manipulated using + SMaterial::MaterialTypeParam. This value controls how sharp the + edges become when going from a transparent to a solid spot on + the texture. */ + EMT_TRANSPARENT_ALPHA_CHANNEL, + + //! Makes the material transparent based on the texture alpha channel. + /** If the alpha channel value is greater than 127, a + pixel is written to the target, otherwise not. This + material does not use alpha blending and is a lot faster + than EMT_TRANSPARENT_ALPHA_CHANNEL. It is ideal for drawing + stuff like leaves of plants, because the borders are not + blurry but sharp. Only first texture is used. If you are + using this material with small textures and 3d object, it + is a good idea to load the texture in 32 bit mode + (video::IVideoDriver::setTextureCreationFlag()). */ + EMT_TRANSPARENT_ALPHA_CHANNEL_REF, + + //! Makes the material transparent based on the vertex alpha value. + EMT_TRANSPARENT_VERTEX_ALPHA, + + //! BlendFunc = source * sourceFactor + dest * destFactor ( E_BLEND_FUNC ) + /** Using only first texture. Generic blending method. + The blend function is set to SMaterial::MaterialTypeParam with + pack_textureBlendFunc (for 2D) or pack_textureBlendFuncSeparate (for 3D). */ + EMT_ONETEXTURE_BLEND, + + //! This value is not used. It only forces this enumeration to compile to 32 bit. + EMT_FORCE_32BIT = 0x7fffffff +}; + +//! Array holding the built in material type names +const char *const sBuiltInMaterialTypeNames[] = { + "solid", + "trans_alphach", + "trans_alphach_ref", + "trans_vertex_alpha", + "onetexture_blend", + 0, + }; + +constexpr u32 numBuiltInMaterials = + sizeof(sBuiltInMaterialTypeNames) / sizeof(char *) - 1; + +} // end namespace video +} // end namespace irr diff --git a/irr/include/EPrimitiveTypes.h b/irr/include/EPrimitiveTypes.h new file mode 100644 index 000000000..d4e5f73f4 --- /dev/null +++ b/irr/include/EPrimitiveTypes.h @@ -0,0 +1,43 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +namespace irr +{ +namespace scene +{ + +//! Enumeration for all primitive types there are. +enum E_PRIMITIVE_TYPE +{ + //! All vertices are non-connected points. + EPT_POINTS = 0, + + //! All vertices form a single connected line. + EPT_LINE_STRIP, + + //! Just as LINE_STRIP, but the last and the first vertex is also connected. + EPT_LINE_LOOP, + + //! Every two vertices are connected creating n/2 lines. + EPT_LINES, + + //! After the first two vertices each vertex defines a new triangle. + //! Always the two last and the new one form a new triangle. + EPT_TRIANGLE_STRIP, + + //! After the first two vertices each vertex defines a new triangle. + //! All around the common first vertex. + EPT_TRIANGLE_FAN, + + //! Explicitly set all vertices for each triangle. + EPT_TRIANGLES, + + //! The single vertices are expanded to quad billboards on the GPU. + EPT_POINT_SPRITES +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/EReadFileType.h b/irr/include/EReadFileType.h new file mode 100644 index 000000000..2241b70bf --- /dev/null +++ b/irr/include/EReadFileType.h @@ -0,0 +1,30 @@ +// Copyright (C) Michael Zeilfelder +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" + +namespace irr +{ +namespace io +{ + +//! An enumeration for different class types implementing IReadFile +enum EREAD_FILE_TYPE +{ + //! CReadFile + ERFT_READ_FILE = MAKE_IRR_ID('r', 'e', 'a', 'd'), + + //! CMemoryReadFile + ERFT_MEMORY_READ_FILE = MAKE_IRR_ID('r', 'm', 'e', 'm'), + + //! CLimitReadFile + ERFT_LIMIT_READ_FILE = MAKE_IRR_ID('r', 'l', 'i', 'm'), + + //! Unknown type + EFIT_UNKNOWN = MAKE_IRR_ID('u', 'n', 'k', 'n') +}; +} // end namespace io +} // end namespace irr diff --git a/irr/include/ESceneNodeTypes.h b/irr/include/ESceneNodeTypes.h new file mode 100644 index 000000000..b8251d965 --- /dev/null +++ b/irr/include/ESceneNodeTypes.h @@ -0,0 +1,49 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" + +namespace irr +{ +namespace scene +{ + +//! An enumeration for all types of built-in scene nodes +/** A scene node type is represented by a four character code +such as 'cube' or 'mesh' instead of simple numbers, to avoid +name clashes with external scene nodes.*/ +enum ESCENE_NODE_TYPE +{ + //! of type CSceneManager (note that ISceneManager is not(!) an ISceneNode) + ESNT_SCENE_MANAGER = MAKE_IRR_ID('s', 'm', 'n', 'g'), + + //! Mesh Scene Node + ESNT_MESH = MAKE_IRR_ID('m', 'e', 's', 'h'), + + //! Empty Scene Node + ESNT_EMPTY = MAKE_IRR_ID('e', 'm', 't', 'y'), + + //! Dummy Transformation Scene Node + ESNT_DUMMY_TRANSFORMATION = MAKE_IRR_ID('d', 'm', 'm', 'y'), + + //! Camera Scene Node + ESNT_CAMERA = MAKE_IRR_ID('c', 'a', 'm', '_'), + + //! Billboard Scene Node + ESNT_BILLBOARD = MAKE_IRR_ID('b', 'i', 'l', 'l'), + + //! Animated Mesh Scene Node + ESNT_ANIMATED_MESH = MAKE_IRR_ID('a', 'm', 's', 'h'), + + //! Unknown scene node + ESNT_UNKNOWN = MAKE_IRR_ID('u', 'n', 'k', 'n'), + + //! Will match with any scene node when checking types + ESNT_ANY = MAKE_IRR_ID('a', 'n', 'y', '_') +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/EShaderTypes.h b/irr/include/EShaderTypes.h new file mode 100644 index 000000000..8d0b3a5e1 --- /dev/null +++ b/irr/include/EShaderTypes.h @@ -0,0 +1,85 @@ +#pragma once + +#include "irrTypes.h" + +namespace irr +{ +namespace video +{ + +//! Compile target enumeration for the addHighLevelShaderMaterial() method. +enum E_VERTEX_SHADER_TYPE +{ + EVST_VS_1_1 = 0, + EVST_VS_2_0, + EVST_VS_2_a, + EVST_VS_3_0, + EVST_VS_4_0, + EVST_VS_4_1, + EVST_VS_5_0, + + //! This is not a type, but a value indicating how much types there are. + EVST_COUNT +}; + +//! Names for all vertex shader types, each entry corresponds to a E_VERTEX_SHADER_TYPE entry. +const c8 *const VERTEX_SHADER_TYPE_NAMES[] = { + "vs_1_1", + "vs_2_0", + "vs_2_a", + "vs_3_0", + "vs_4_0", + "vs_4_1", + "vs_5_0", + 0}; + +//! Compile target enumeration for the addHighLevelShaderMaterial() method. +enum E_PIXEL_SHADER_TYPE +{ + EPST_PS_1_1 = 0, + EPST_PS_1_2, + EPST_PS_1_3, + EPST_PS_1_4, + EPST_PS_2_0, + EPST_PS_2_a, + EPST_PS_2_b, + EPST_PS_3_0, + EPST_PS_4_0, + EPST_PS_4_1, + EPST_PS_5_0, + + //! This is not a type, but a value indicating how much types there are. + EPST_COUNT +}; + +//! Names for all pixel shader types, each entry corresponds to a E_PIXEL_SHADER_TYPE entry. +const c8 *const PIXEL_SHADER_TYPE_NAMES[] = { + "ps_1_1", + "ps_1_2", + "ps_1_3", + "ps_1_4", + "ps_2_0", + "ps_2_a", + "ps_2_b", + "ps_3_0", + "ps_4_0", + "ps_4_1", + "ps_5_0", + 0}; + +//! Enum for supported geometry shader types +enum E_GEOMETRY_SHADER_TYPE +{ + EGST_GS_4_0 = 0, + + //! This is not a type, but a value indicating how much types there are. + EGST_COUNT +}; + +//! String names for supported geometry shader types +const c8 *const GEOMETRY_SHADER_TYPE_NAMES[] = { + "gs_4_0", + 0}; + +} // end namespace video +} // end namespace irr diff --git a/irr/include/EVertexAttributes.h b/irr/include/EVertexAttributes.h new file mode 100644 index 000000000..75d039fec --- /dev/null +++ b/irr/include/EVertexAttributes.h @@ -0,0 +1,34 @@ +#pragma once + +namespace irr +{ +namespace video +{ + +//! Enumeration for all vertex attributes there are. +enum E_VERTEX_ATTRIBUTES +{ + EVA_POSITION = 0, + EVA_NORMAL, + EVA_COLOR, + EVA_TCOORD0, + EVA_TCOORD1, + EVA_TANGENT, + EVA_BINORMAL, + EVA_COUNT +}; + +//! Array holding the built in vertex attribute names +const char *const sBuiltInVertexAttributeNames[] = { + "inVertexPosition", + "inVertexNormal", + "inVertexColor", + "inTexCoord0", + "inTexCoord1", + "inVertexTangent", + "inVertexBinormal", + 0, + }; + +} // end namespace video +} // end namespace irr diff --git a/irr/include/IAnimatedMesh.h b/irr/include/IAnimatedMesh.h new file mode 100644 index 000000000..80b3bc3ca --- /dev/null +++ b/irr/include/IAnimatedMesh.h @@ -0,0 +1,69 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "aabbox3d.h" +#include "IMesh.h" + +namespace irr +{ +namespace scene +{ +//! Interface for an animated mesh. +/** There are already simple implementations of this interface available so +you don't have to implement this interface on your own if you need to: +You might want to use irr::scene::SAnimatedMesh, irr::scene::SMesh, +irr::scene::SMeshBuffer etc. */ +class IAnimatedMesh : public IMesh +{ +public: + //! Gets the frame count of the animated mesh. + /** Note that the play-time is usually getFrameCount()-1 as it stops as soon as the last frame-key is reached. + \return The amount of frames. If the amount is 1, + it is a static, non animated mesh. */ + virtual u32 getFrameCount() const = 0; + + //! Gets the animation speed of the animated mesh. + /** \return The number of frames per second to play the + animation with by default. If the amount is 0, + it is a static, non animated mesh. */ + virtual f32 getAnimationSpeed() const = 0; + + //! Sets the animation speed of the animated mesh. + /** \param fps Number of frames per second to play the + animation with by default. If the amount is 0, + it is not animated. The actual speed is set in the + scene node the mesh is instantiated in.*/ + virtual void setAnimationSpeed(f32 fps) = 0; + + //! Returns the IMesh interface for a frame. + /** \param frame: Frame number as zero based index. The maximum + frame number is getFrameCount() - 1; + \param detailLevel: Level of detail. 0 is the lowest, 255 the + highest level of detail. Most meshes will ignore the detail level. + \param startFrameLoop: Because some animated meshes (.MD2) are + blended between 2 static frames, and maybe animated in a loop, + the startFrameLoop and the endFrameLoop have to be defined, to + prevent the animation to be blended between frames which are + outside of this loop. + If startFrameLoop and endFrameLoop are both -1, they are ignored. + \param endFrameLoop: see startFrameLoop. + \return Returns the animated mesh based on a detail level. */ + virtual IMesh *getMesh(s32 frame, s32 detailLevel = 255, s32 startFrameLoop = -1, s32 endFrameLoop = -1) = 0; + + //! Returns the type of the animated mesh. + /** In most cases it is not necessary to use this method. + This is useful for making a safe downcast. For example, + if getMeshType() returns EAMT_MD2 it's safe to cast the + IAnimatedMesh to IAnimatedMeshMD2. + \returns Type of the mesh. */ + E_ANIMATED_MESH_TYPE getMeshType() const override + { + return EAMT_UNKNOWN; + } +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/IAnimatedMeshSceneNode.h b/irr/include/IAnimatedMeshSceneNode.h new file mode 100644 index 000000000..65fdaaadf --- /dev/null +++ b/irr/include/IAnimatedMeshSceneNode.h @@ -0,0 +1,169 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "ISceneNode.h" +#include "IBoneSceneNode.h" +#include "IAnimatedMesh.h" + +namespace irr +{ +namespace scene +{ +enum E_JOINT_UPDATE_ON_RENDER +{ + //! do nothing + EJUOR_NONE = 0, + + //! get joints positions from the mesh (for attached nodes, etc) + EJUOR_READ, + + //! control joint positions in the mesh (eg. ragdolls, or set the animation from animateJoints() ) + EJUOR_CONTROL +}; + +class IAnimatedMeshSceneNode; + +//! Callback interface for catching events of ended animations. +/** Implement this interface and use +IAnimatedMeshSceneNode::setAnimationEndCallback to be able to +be notified if an animation playback has ended. +**/ +class IAnimationEndCallBack : public virtual IReferenceCounted +{ +public: + //! Will be called when the animation playback has ended. + /** See IAnimatedMeshSceneNode::setAnimationEndCallback for + more information. + \param node: Node of which the animation has ended. */ + virtual void OnAnimationEnd(IAnimatedMeshSceneNode *node) = 0; +}; + +//! Scene node capable of displaying an animated mesh. +class IAnimatedMeshSceneNode : public ISceneNode +{ +public: + //! Constructor + IAnimatedMeshSceneNode(ISceneNode *parent, ISceneManager *mgr, s32 id, + const core::vector3df &position = core::vector3df(0, 0, 0), + const core::vector3df &rotation = core::vector3df(0, 0, 0), + const core::vector3df &scale = core::vector3df(1.0f, 1.0f, 1.0f)) : + ISceneNode(parent, mgr, id, position, rotation, scale) {} + + //! Destructor + virtual ~IAnimatedMeshSceneNode() {} + + //! Sets the current frame number. + /** From now on the animation is played from this frame. + \param frame: Number of the frame to let the animation be started from. + The frame number must be a valid frame number of the IMesh used by this + scene node. Set IAnimatedMesh::getMesh() for details. */ + virtual void setCurrentFrame(f32 frame) = 0; + + //! Sets the frame numbers between the animation is looped. + /** The default is 0 to getFrameCount()-1 of the mesh. + Number of played frames is end-start. + It interpolates toward the last frame but stops when it is reached. + It does not interpolate back to start even when looping. + Looping animations should ensure last and first frame-key are identical. + \param begin: Start frame number of the loop. + \param end: End frame number of the loop. + \return True if successful, false if not. */ + virtual bool setFrameLoop(s32 begin, s32 end) = 0; + + //! Sets the speed with which the animation is played. + /** \param framesPerSecond: Frames per second played. */ + virtual void setAnimationSpeed(f32 framesPerSecond) = 0; + + //! Gets the speed with which the animation is played. + /** \return Frames per second played. */ + virtual f32 getAnimationSpeed() const = 0; + + //! Get a pointer to a joint in the mesh (if the mesh is a bone based mesh). + /** With this method it is possible to attach scene nodes to + joints for example possible to attach a weapon to the left hand + of an animated model. This example shows how: + \code + ISceneNode* hand = + yourAnimatedMeshSceneNode->getJointNode("LeftHand"); + hand->addChild(weaponSceneNode); + \endcode + Please note that the joint returned by this method may not exist + before this call and the joints in the node were created by it. + \param jointName: Name of the joint. + \return Pointer to the scene node which represents the joint + with the specified name. Returns 0 if the contained mesh is not + an skinned mesh or the name of the joint could not be found. */ + virtual IBoneSceneNode *getJointNode(const c8 *jointName) = 0; + + //! same as getJointNode(const c8* jointName), but based on id + virtual IBoneSceneNode *getJointNode(u32 jointID) = 0; + + //! Gets joint count. + /** \return Amount of joints in the mesh. */ + virtual u32 getJointCount() const = 0; + + //! Returns the currently displayed frame number. + virtual f32 getFrameNr() const = 0; + //! Returns the current start frame number. + virtual s32 getStartFrame() const = 0; + //! Returns the current end frame number. + virtual s32 getEndFrame() const = 0; + + //! Sets looping mode which is on by default. + /** If set to false, animations will not be played looped. */ + virtual void setLoopMode(bool playAnimationLooped) = 0; + + //! returns the current loop mode + /** When true the animations are played looped */ + virtual bool getLoopMode() const = 0; + + //! Sets a callback interface which will be called if an animation playback has ended. + /** Set this to 0 to disable the callback again. + Please note that this will only be called when in non looped + mode, see IAnimatedMeshSceneNode::setLoopMode(). */ + virtual void setAnimationEndCallback(IAnimationEndCallBack *callback = 0) = 0; + + //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. + /** In this way it is possible to change the materials a mesh + causing all mesh scene nodes referencing this mesh to change + too. */ + virtual void setReadOnlyMaterials(bool readonly) = 0; + + //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style + virtual bool isReadOnlyMaterials() const = 0; + + //! Sets a new mesh + virtual void setMesh(IAnimatedMesh *mesh) = 0; + + //! Returns the current mesh + virtual IAnimatedMesh *getMesh(void) = 0; + + //! Set how the joints should be updated on render + virtual void setJointMode(E_JOINT_UPDATE_ON_RENDER mode) = 0; + + //! Sets the transition time in seconds + /** Note: This needs to enable joints, and setJointmode set to + EJUOR_CONTROL. You must call animateJoints(), or the mesh will + not animate. */ + virtual void setTransitionTime(f32 Time) = 0; + + //! animates the joints in the mesh based on the current frame. + /** Also takes in to account transitions. */ + virtual void animateJoints(bool CalculateAbsolutePositions = true) = 0; + + //! render mesh ignoring its transformation. + /** Culling is unaffected. */ + virtual void setRenderFromIdentity(bool On) = 0; + + //! Creates a clone of this scene node and its children. + /** \param newParent An optional new parent. + \param newManager An optional new scene manager. + \return The newly created clone of this node. */ + virtual ISceneNode *clone(ISceneNode *newParent = 0, ISceneManager *newManager = 0) = 0; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/IAttributes.h b/irr/include/IAttributes.h new file mode 100644 index 000000000..906d334a2 --- /dev/null +++ b/irr/include/IAttributes.h @@ -0,0 +1,125 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "EAttributes.h" + +// not needed here but I can't be bothered to clean the transitive includes up. +#include "quaternion.h" + +namespace irr +{ +namespace video +{ +class ITexture; +} // end namespace video +namespace io +{ + +//! Provides a generic interface for attributes and their values and the possibility to serialize them +class IAttributes : public virtual IReferenceCounted +{ +public: + //! Returns amount of attributes in this collection of attributes. + virtual u32 getAttributeCount() const = 0; + + //! Returns attribute name by index. + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual const c8 *getAttributeName(s32 index) const = 0; + + //! Returns the type of an attribute + //! \param attributeName: Name for the attribute + virtual E_ATTRIBUTE_TYPE getAttributeType(const c8 *attributeName) const = 0; + + //! Returns attribute type by index. + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual E_ATTRIBUTE_TYPE getAttributeType(s32 index) const = 0; + + //! Returns if an attribute with a name exists + virtual bool existsAttribute(const c8 *attributeName) const = 0; + + //! Returns attribute index from name, -1 if not found + virtual s32 findAttribute(const c8 *attributeName) const = 0; + + //! Removes all attributes + virtual void clear() = 0; + + /* + + Integer Attribute + + */ + + //! Adds an attribute as integer + virtual void addInt(const c8 *attributeName, s32 value) = 0; + + //! Sets an attribute as integer value + virtual void setAttribute(const c8 *attributeName, s32 value) = 0; + + //! Gets an attribute as integer value + //! \param attributeName: Name of the attribute to get. + //! \param defaultNotFound Value returned when attributeName was not found + //! \return Returns value of the attribute previously set by setAttribute() + virtual s32 getAttributeAsInt(const c8 *attributeName, irr::s32 defaultNotFound = 0) const = 0; + + //! Gets an attribute as integer value + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual s32 getAttributeAsInt(s32 index) const = 0; + + //! Sets an attribute as integer value + virtual void setAttribute(s32 index, s32 value) = 0; + + /* + + Float Attribute + + */ + + //! Adds an attribute as float + virtual void addFloat(const c8 *attributeName, f32 value) = 0; + + //! Sets a attribute as float value + virtual void setAttribute(const c8 *attributeName, f32 value) = 0; + + //! Gets an attribute as float value + //! \param attributeName: Name of the attribute to get. + //! \param defaultNotFound Value returned when attributeName was not found + //! \return Returns value of the attribute previously set by setAttribute() + virtual f32 getAttributeAsFloat(const c8 *attributeName, irr::f32 defaultNotFound = 0.f) const = 0; + + //! Gets an attribute as float value + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual f32 getAttributeAsFloat(s32 index) const = 0; + + //! Sets an attribute as float value + virtual void setAttribute(s32 index, f32 value) = 0; + + /* + Bool Attribute + */ + + //! Adds an attribute as bool + virtual void addBool(const c8 *attributeName, bool value) = 0; + + //! Sets an attribute as boolean value + virtual void setAttribute(const c8 *attributeName, bool value) = 0; + + //! Gets an attribute as boolean value + //! \param attributeName: Name of the attribute to get. + //! \param defaultNotFound Value returned when attributeName was not found + //! \return Returns value of the attribute previously set by setAttribute() + virtual bool getAttributeAsBool(const c8 *attributeName, bool defaultNotFound = false) const = 0; + + //! Gets an attribute as boolean value + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + virtual bool getAttributeAsBool(s32 index) const = 0; + + //! Sets an attribute as boolean value + virtual void setAttribute(s32 index, bool value) = 0; +}; + +} // end namespace io +} // end namespace irr diff --git a/irr/include/IBillboardSceneNode.h b/irr/include/IBillboardSceneNode.h new file mode 100644 index 000000000..3e7026ac3 --- /dev/null +++ b/irr/include/IBillboardSceneNode.h @@ -0,0 +1,90 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "ISceneNode.h" + +namespace irr +{ +namespace scene +{ +class ICameraSceneNode; +class IMeshBuffer; + +//! A billboard scene node. +/** A billboard is like a 3d sprite: A 2d element, +which always looks to the camera. It is usually used for explosions, fire, +lensflares, particles and things like that. +*/ +class IBillboardSceneNode : public ISceneNode +{ +public: + //! Constructor + IBillboardSceneNode(ISceneNode *parent, ISceneManager *mgr, s32 id, + const core::vector3df &position = core::vector3df(0, 0, 0)) : + ISceneNode(parent, mgr, id, position) {} + + //! Sets the size of the billboard, making it rectangular. + virtual void setSize(const core::dimension2d &size) = 0; + + //! Sets the size of the billboard with independent widths of the bottom and top edges. + /** \param[in] height The height of the billboard. + \param[in] bottomEdgeWidth The width of the bottom edge of the billboard. + \param[in] topEdgeWidth The width of the top edge of the billboard. + */ + virtual void setSize(f32 height, f32 bottomEdgeWidth, f32 topEdgeWidth) = 0; + + //! Returns the size of the billboard. + /** This will return the width of the bottom edge of the billboard. + Use getWidths() to retrieve the bottom and top edges independently. + \return Size of the billboard. + */ + virtual const core::dimension2d &getSize() const = 0; + + //! Gets the size of the the billboard and handles independent top and bottom edge widths correctly. + /** \param[out] height The height of the billboard. + \param[out] bottomEdgeWidth The width of the bottom edge of the billboard. + \param[out] topEdgeWidth The width of the top edge of the billboard. + */ + virtual void getSize(f32 &height, f32 &bottomEdgeWidth, f32 &topEdgeWidth) const = 0; + + //! Set the color of all vertices of the billboard + /** \param[in] overallColor Color to set */ + virtual void setColor(const video::SColor &overallColor) = 0; + + //! Set the color of the top and bottom vertices of the billboard + /** \param[in] topColor Color to set the top vertices + \param[in] bottomColor Color to set the bottom vertices */ + virtual void setColor(const video::SColor &topColor, + const video::SColor &bottomColor) = 0; + + //! Gets the color of the top and bottom vertices of the billboard + /** \param[out] topColor Stores the color of the top vertices + \param[out] bottomColor Stores the color of the bottom vertices */ + virtual void getColor(video::SColor &topColor, + video::SColor &bottomColor) const = 0; + + //! Get the real boundingbox used by the billboard, which can depend on the active camera. + /** The boundingbox returned will use absolute coordinates. + The billboard orients itself toward the camera and some only update in render(). + So we don't know the real boundingboxes before that. Which would be too late for culling. + That is why the usual getBoundingBox will return a "safe" boundingbox which is guaranteed + to contain the billboard. While this function can return the real one. */ + virtual const core::aabbox3d &getTransformedBillboardBoundingBox(const irr::scene::ICameraSceneNode *camera) = 0; + + //! Get the amount of mesh buffers. + /** \return Amount of mesh buffers (IMeshBuffer) in this mesh. */ + virtual u32 getMeshBufferCount() const = 0; + + //! Get pointer to a mesh buffer. + /** NOTE: Positions and normals of this meshbuffers are re-calculated before rendering. + So this is mainly useful to access/modify the uv-coordinates. + \param nr: Zero based index of the mesh buffer. + \return Pointer to the mesh buffer or 0 if there is no such mesh buffer. */ + virtual IMeshBuffer *getMeshBuffer(u32 nr) const = 0; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/IBoneSceneNode.h b/irr/include/IBoneSceneNode.h new file mode 100644 index 000000000..668289271 --- /dev/null +++ b/irr/include/IBoneSceneNode.h @@ -0,0 +1,96 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "ISceneNode.h" + +namespace irr +{ +namespace scene +{ + +//! Enumeration for different bone animation modes +enum E_BONE_ANIMATION_MODE +{ + //! The bone is usually animated, unless it's parent is not animated + EBAM_AUTOMATIC = 0, + + //! The bone is animated by the skin, if it's parent is not animated then animation will resume from this bone onward + EBAM_ANIMATED, + + //! The bone is not animated by the skin + EBAM_UNANIMATED, + + //! Not an animation mode, just here to count the available modes + EBAM_COUNT + +}; + +enum E_BONE_SKINNING_SPACE +{ + //! local skinning, standard + EBSS_LOCAL = 0, + + //! global skinning + EBSS_GLOBAL, + + EBSS_COUNT +}; + +//! Names for bone animation modes +const c8 *const BoneAnimationModeNames[] = { + "automatic", + "animated", + "unanimated", + 0, + }; + +//! Interface for bones used for skeletal animation. +/** Used with ISkinnedMesh and IAnimatedMeshSceneNode. */ +class IBoneSceneNode : public ISceneNode +{ +public: + IBoneSceneNode(ISceneNode *parent, ISceneManager *mgr, s32 id = -1) : + ISceneNode(parent, mgr, id), positionHint(-1), scaleHint(-1), rotationHint(-1) {} + + //! Get the index of the bone + virtual u32 getBoneIndex() const = 0; + + //! Sets the animation mode of the bone. + /** \return True if successful. (Unused) */ + virtual bool setAnimationMode(E_BONE_ANIMATION_MODE mode) = 0; + + //! Gets the current animation mode of the bone + virtual E_BONE_ANIMATION_MODE getAnimationMode() const = 0; + + //! Get the axis aligned bounding box of this node + const core::aabbox3d &getBoundingBox() const override = 0; + + //! Returns the relative transformation of the scene node. + // virtual core::matrix4 getRelativeTransformation() const = 0; + + //! The animation method. + void OnAnimate(u32 timeMs) override = 0; + + //! The render method. + /** Does nothing as bones are not visible. */ + void render() override {} + + //! How the relative transformation of the bone is used + virtual void setSkinningSpace(E_BONE_SKINNING_SPACE space) = 0; + + //! How the relative transformation of the bone is used + virtual E_BONE_SKINNING_SPACE getSkinningSpace() const = 0; + + //! Updates the absolute position based on the relative and the parents position + virtual void updateAbsolutePositionOfAllChildren() = 0; + + s32 positionHint; + s32 scaleHint; + s32 rotationHint; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/ICameraSceneNode.h b/irr/include/ICameraSceneNode.h new file mode 100644 index 000000000..a7c72428d --- /dev/null +++ b/irr/include/ICameraSceneNode.h @@ -0,0 +1,184 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "ISceneNode.h" +#include "IEventReceiver.h" + +namespace irr +{ +namespace scene +{ +struct SViewFrustum; + +//! Scene Node which is a (controllable) camera. +/** The whole scene will be rendered from the cameras point of view. +Because the ICameraSceneNode is a SceneNode, it can be attached to any +other scene node, and will follow its parents movement, rotation and so +on. +*/ +class ICameraSceneNode : public ISceneNode, public IEventReceiver +{ +public: + //! Constructor + ICameraSceneNode(ISceneNode *parent, ISceneManager *mgr, s32 id, + const core::vector3df &position = core::vector3df(0, 0, 0), + const core::vector3df &rotation = core::vector3df(0, 0, 0), + const core::vector3df &scale = core::vector3df(1.0f, 1.0f, 1.0f)) : + ISceneNode(parent, mgr, id, position, rotation, scale), + IsOrthogonal(false) {} + + //! Sets the projection matrix of the camera. + /** The core::matrix4 class has some methods to build a + projection matrix. e.g: + core::matrix4::buildProjectionMatrixPerspectiveFovLH. + Note that the matrix will only stay as set by this method until + one of the following Methods are called: setNearValue, + setFarValue, setAspectRatio, setFOV. + NOTE: The frustum is not updated before render() is called + unless you explicitly call updateMatrices() + \param projection The new projection matrix of the camera. + \param isOrthogonal Set this to true if the matrix is an + orthogonal one (e.g. from matrix4::buildProjectionMatrixOrtho). + */ + virtual void setProjectionMatrix(const core::matrix4 &projection, bool isOrthogonal = false) = 0; + + //! Gets the current projection matrix of the camera. + /** \return The current projection matrix of the camera. */ + virtual const core::matrix4 &getProjectionMatrix() const = 0; + + //! Gets the current view matrix of the camera. + /** \return The current view matrix of the camera. */ + virtual const core::matrix4 &getViewMatrix() const = 0; + + //! Sets a custom view matrix affector. + /** The matrix passed here, will be multiplied with the view + matrix when it gets updated. This allows for custom camera + setups like, for example, a reflection camera. + \param affector The affector matrix. */ + virtual void setViewMatrixAffector(const core::matrix4 &affector) = 0; + + //! Get the custom view matrix affector. + /** \return The affector matrix. */ + virtual const core::matrix4 &getViewMatrixAffector() const = 0; + + //! It is possible to send mouse and key events to the camera. + /** Most cameras may ignore this input, but camera scene nodes + which are created for example with + ISceneManager::addCameraSceneNodeMaya or + ISceneManager::addCameraSceneNodeFPS, may want to get + this input for changing their position, look at target or + whatever. */ + bool OnEvent(const SEvent &event) override = 0; + + //! Sets the look at target of the camera + /** If the camera's target and rotation are bound ( @see + bindTargetAndRotation() ) then calling this will also change + the camera's scene node rotation to match the target. + Note that setTarget uses the current absolute position + internally, so if you changed setPosition since last rendering you must + call updateAbsolutePosition before using this function. + \param pos Look at target of the camera, in world co-ordinates. */ + virtual void setTarget(const core::vector3df &pos) = 0; + + //! Sets the rotation of the node. + /** This only modifies the relative rotation of the node. + If the camera's target and rotation are bound ( @see + bindTargetAndRotation() ) then calling this will also change + the camera's target to match the rotation. + \param rotation New rotation of the node in degrees. */ + void setRotation(const core::vector3df &rotation) override = 0; + + //! Gets the current look at target of the camera + /** \return The current look at target of the camera, in world co-ordinates */ + virtual const core::vector3df &getTarget() const = 0; + + //! Sets the up vector of the camera. + /** \param pos: New upvector of the camera. */ + virtual void setUpVector(const core::vector3df &pos) = 0; + + //! Gets the up vector of the camera. + /** \return The up vector of the camera, in world space. */ + virtual const core::vector3df &getUpVector() const = 0; + + //! Gets the value of the near plane of the camera. + /** \return The value of the near plane of the camera. */ + virtual f32 getNearValue() const = 0; + + //! Gets the value of the far plane of the camera. + /** \return The value of the far plane of the camera. */ + virtual f32 getFarValue() const = 0; + + //! Gets the aspect ratio of the camera. + /** \return The aspect ratio of the camera. */ + virtual f32 getAspectRatio() const = 0; + + //! Gets the field of view of the camera. + /** \return The field of view of the camera in radians. */ + virtual f32 getFOV() const = 0; + + //! Sets the value of the near clipping plane. (default: 1.0f) + /** \param zn: New z near value. */ + virtual void setNearValue(f32 zn) = 0; + + //! Sets the value of the far clipping plane (default: 2000.0f) + /** \param zf: New z far value. */ + virtual void setFarValue(f32 zf) = 0; + + //! Sets the aspect ratio (default: 4.0f / 3.0f) + /** \param aspect: New aspect ratio. */ + virtual void setAspectRatio(f32 aspect) = 0; + + //! Sets the field of view (Default: PI / 2.5f) + /** \param fovy: New field of view in radians. */ + virtual void setFOV(f32 fovy) = 0; + + //! Get the view frustum. + /** \return The current view frustum. */ + virtual const SViewFrustum *getViewFrustum() const = 0; + + //! Disables or enables the camera to get key or mouse inputs. + /** If this is set to true, the camera will respond to key + inputs otherwise not. */ + virtual void setInputReceiverEnabled(bool enabled) = 0; + + //! Checks if the input receiver of the camera is currently enabled. + virtual bool isInputReceiverEnabled() const = 0; + + //! Checks if a camera is orthogonal. + virtual bool isOrthogonal() const + { + return IsOrthogonal; + } + + //! Binds the camera scene node's rotation to its target position and vice versa, or unbinds them. + /** When bound, calling setRotation() will update the camera's + target position to be along its +Z axis, and likewise calling + setTarget() will update its rotation so that its +Z axis will + point at the target point. FPS camera use this binding by + default; other cameras do not. + \param bound True to bind the camera's scene node rotation + and targeting, false to unbind them. + @see getTargetAndRotationBinding() */ + virtual void bindTargetAndRotation(bool bound) = 0; + + //! Updates the matrices without uploading them to the driver + virtual void updateMatrices() = 0; + + //! Queries if the camera scene node's rotation and its target position are bound together. + /** @see bindTargetAndRotation() */ + virtual bool getTargetAndRotationBinding(void) const = 0; + +protected: + void cloneMembers(const ICameraSceneNode *toCopyFrom) + { + IsOrthogonal = toCopyFrom->IsOrthogonal; + } + + bool IsOrthogonal; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/IContextManager.h b/irr/include/IContextManager.h new file mode 100644 index 000000000..85177dc43 --- /dev/null +++ b/irr/include/IContextManager.h @@ -0,0 +1,59 @@ +// Copyright (C) 2013-2015 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "SExposedVideoData.h" +#include "SIrrCreationParameters.h" +#include + +namespace irr +{ +namespace video +{ +// For system specific window contexts (used for OpenGL) +class IContextManager : public virtual IReferenceCounted +{ +public: + //! Initialize manager with device creation parameters and device window (passed as exposed video data) + virtual bool initialize(const SIrrlichtCreationParameters ¶ms, const SExposedVideoData &data) = 0; + + //! Terminate manager, any cleanup that is left over. Manager needs a new initialize to be usable again + virtual void terminate() = 0; + + //! Create surface based on current window set + virtual bool generateSurface() = 0; + + //! Destroy current surface + virtual void destroySurface() = 0; + + //! Create context based on current surface + virtual bool generateContext() = 0; + + //! Destroy current context + virtual void destroyContext() = 0; + + //! Get current context + virtual const SExposedVideoData &getContext() const = 0; + + //! Change render context, disable old and activate new defined by videoData + //\param restorePrimaryOnZero When true: restore original driver context when videoData is set to 0 values. + // When false: resets the context when videoData is set to 0 values. + /** This is mostly used internally by IVideoDriver::beginScene(). + But if you want to switch threads which access your OpenGL driver you will have to + call this function as follows: + Old thread gives up context with: activateContext(irr::video::SExposedVideoData()); + New thread takes over context with: activateContext(videoDriver->getExposedVideoData()); + Note that only 1 thread at a time may access an OpenGL context. */ + virtual bool activateContext(const SExposedVideoData &videoData, bool restorePrimaryOnZero = false) = 0; + + //! Get the address of any OpenGL procedure (including core procedures). + virtual void *getProcAddress(const std::string &procName) = 0; + + //! Swap buffers. + virtual bool swapBuffers() = 0; +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/include/ICursorControl.h b/irr/include/ICursorControl.h new file mode 100644 index 000000000..65b8efb7e --- /dev/null +++ b/irr/include/ICursorControl.h @@ -0,0 +1,195 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "position2d.h" +#include "rect.h" + +namespace irr +{ +namespace gui +{ + +class IGUISpriteBank; + +//! Default icons for cursors +enum ECURSOR_ICON +{ + // Following cursors might be system specific, or might use an Irrlicht icon-set. No guarantees so far. + ECI_NORMAL, // arrow + ECI_CROSS, // Crosshair + ECI_HAND, // Hand + ECI_HELP, // Arrow and question mark + ECI_IBEAM, // typical text-selection cursor + ECI_NO, // should not click icon + ECI_WAIT, // hourglass + ECI_SIZEALL, // arrow in all directions + ECI_SIZENESW, // resizes in direction north-east or south-west + ECI_SIZENWSE, // resizes in direction north-west or south-east + ECI_SIZENS, // resizes in direction north or south + ECI_SIZEWE, // resizes in direction west or east + ECI_UP, // up-arrow + + // Implementer note: Should we add system specific cursors, which use guaranteed the system icons, + // then I would recommend using a naming scheme like ECI_W32_CROSS, ECI_X11_CROSSHAIR and adding those + // additionally. + + ECI_COUNT // maximal of defined cursors. Note that higher values can be created at runtime +}; + +//! Names for ECURSOR_ICON +const c8 *const GUICursorIconNames[ECI_COUNT + 1] = { + "normal", + "cross", + "hand", + "help", + "ibeam", + "no", + "wait", + "sizeall", + "sizenesw", + "sizenwse", + "sizens", + "sizewe", + "sizeup", + 0, + }; + +//! structure used to set sprites as cursors. +struct SCursorSprite +{ + SCursorSprite() : + SpriteBank(0), SpriteId(-1) + { + } + + SCursorSprite(gui::IGUISpriteBank *spriteBank, s32 spriteId, const core::position2d &hotspot = (core::position2d(0, 0))) : + SpriteBank(spriteBank), SpriteId(spriteId), HotSpot(hotspot) + { + } + + IGUISpriteBank *SpriteBank; + s32 SpriteId; + core::position2d HotSpot; +}; + +//! platform specific behavior flags for the cursor +enum ECURSOR_PLATFORM_BEHAVIOR +{ + //! default - no platform specific behavior + ECPB_NONE = 0, + + //! On X11 try caching cursor updates as XQueryPointer calls can be expensive. + /** Update cursor positions only when the irrlicht timer has been updated or the timer is stopped. + This means you usually get one cursor update per device->run() which will be fine in most cases. + See this forum-thread for a more detailed explanation: + http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=45525 + */ + ECPB_X11_CACHE_UPDATES = 1 +}; + +//! Interface to manipulate the mouse cursor. +class ICursorControl : public virtual IReferenceCounted +{ +public: + //! Changes the visible state of the mouse cursor. + /** \param visible: The new visible state. If true, the cursor will be visible, + if false, it will be invisible. */ + virtual void setVisible(bool visible) = 0; + + //! Returns if the cursor is currently visible. + /** \return True if the cursor flag is set to visible, false if not. */ + virtual bool isVisible() const = 0; + + //! Sets the new position of the cursor. + /** The position must be + between (0.0f, 0.0f) and (1.0f, 1.0f), where (0.0f, 0.0f) is + the top left corner and (1.0f, 1.0f) is the bottom right corner of the + render window. + \param pos New position of the cursor. */ + virtual void setPosition(const core::position2d &pos) = 0; + + //! Sets the new position of the cursor. + /** The position must be + between (0.0f, 0.0f) and (1.0f, 1.0f), where (0.0f, 0.0f) is + the top left corner and (1.0f, 1.0f) is the bottom right corner of the + render window. + \param x New x-coord of the cursor. + \param y New x-coord of the cursor. */ + virtual void setPosition(f32 x, f32 y) = 0; + + //! Sets the new position of the cursor. + /** \param pos: New position of the cursor. The coordinates are pixel units. */ + virtual void setPosition(const core::position2d &pos) = 0; + + //! Sets the new position of the cursor. + /** \param x New x-coord of the cursor. The coordinates are pixel units. + \param y New y-coord of the cursor. The coordinates are pixel units. */ + virtual void setPosition(s32 x, s32 y) = 0; + + //! Returns the current position of the mouse cursor. + /** \param updateCursor When true ask system/OS for current cursor position. + When false return the last known (buffered) position ( this is useful to + check what has become of a setPosition call with float numbers). + \return Returns the current position of the cursor. The returned position + is the position of the mouse cursor in pixel units. */ + virtual const core::position2d &getPosition(bool updateCursor = true) = 0; + + //! Returns the current position of the mouse cursor. + /** \param updateCursor When true ask system/OS for current cursor position. + When false return the last known (buffered) position (this is + useful to check what has become of a setPosition call with float numbers + and is often different from the values you passed in setPosition). + \return Returns the current position of the cursor. The returned position + is a value between (0.0f, 0.0f) and (1.0f, 1.0f), where (0.0f, 0.0f) is + the top left corner and (1.0f, 1.0f) is the bottom right corner of the + render window. */ + virtual core::position2d getRelativePosition(bool updateCursor = true) = 0; + + //! Sets an absolute reference rect for setting and retrieving the cursor position. + /** If this rect is set, the cursor position is not being calculated relative to + the rendering window but to this rect. You can set the rect pointer to 0 to disable + this feature again. This feature is useful when rendering into parts of foreign windows + for example in an editor. + \param rect: A pointer to an reference rectangle or 0 to disable the reference rectangle.*/ + virtual void setReferenceRect(core::rect *rect = 0) = 0; + + //! Internally fixes the mouse position, and reports relative mouse movement compared to the old position + /** Specific to SDL */ + virtual void setRelativeMode(bool relative){}; + + //! Sets the active cursor icon + /** Setting cursor icons is so far only supported on Win32 and Linux */ + virtual void setActiveIcon(ECURSOR_ICON iconId) {} + + //! Gets the currently active icon + virtual ECURSOR_ICON getActiveIcon() const { return gui::ECI_NORMAL; } + + //! Add a custom sprite as cursor icon. + /** \return Identification for the icon */ + virtual ECURSOR_ICON addIcon(const gui::SCursorSprite &icon) { return gui::ECI_NORMAL; } + + //! replace a cursor icon. + /** Changing cursor icons is so far only supported on Win32 and Linux + Note that this only changes the icons within your application, system cursors outside your + application will not be affected. + */ + virtual void changeIcon(ECURSOR_ICON iconId, const gui::SCursorSprite &sprite) {} + + //! Return a system-specific size which is supported for cursors. Larger icons will fail, smaller icons might work. + virtual core::dimension2di getSupportedIconSize() const { return core::dimension2di(0, 0); } + + //! Set platform specific behavior flags. + virtual void setPlatformBehavior(ECURSOR_PLATFORM_BEHAVIOR behavior) {} + + //! Return platform specific behavior. + /** \return Behavior set by setPlatformBehavior or ECPB_NONE for platforms not implementing specific behaviors. + */ + virtual ECURSOR_PLATFORM_BEHAVIOR getPlatformBehavior() const { return ECPB_NONE; } +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/include/IDummyTransformationSceneNode.h b/irr/include/IDummyTransformationSceneNode.h new file mode 100644 index 000000000..88bc37c78 --- /dev/null +++ b/irr/include/IDummyTransformationSceneNode.h @@ -0,0 +1,36 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "ISceneNode.h" + +namespace irr +{ +namespace scene +{ + +//! Dummy scene node for adding additional transformations to the scene graph. +/** This scene node does not render itself, and does not respond to set/getPosition, +set/getRotation and set/getScale. Its just a simple scene node that takes a +matrix as relative transformation, making it possible to insert any transformation +anywhere into the scene graph. +This scene node is for example used by the IAnimatedMeshSceneNode for emulating +joint scene nodes when playing skeletal animations. +*/ +class IDummyTransformationSceneNode : public ISceneNode +{ +public: + //! Constructor + IDummyTransformationSceneNode(ISceneNode *parent, ISceneManager *mgr, s32 id) : + ISceneNode(parent, mgr, id) {} + + //! Returns a reference to the current relative transformation matrix. + /** This is the matrix, this scene node uses instead of scale, translation + and rotation. */ + virtual core::matrix4 &getRelativeTransformationMatrix() = 0; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/IEventReceiver.h b/irr/include/IEventReceiver.h new file mode 100644 index 000000000..6134b79f5 --- /dev/null +++ b/irr/include/IEventReceiver.h @@ -0,0 +1,632 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "ILogger.h" +#include "Keycodes.h" +#include "irrString.h" + +namespace irr +{ +//! Enumeration for all event types there are. +enum EEVENT_TYPE +{ + //! An event of the graphical user interface. + /** GUI events are created by the GUI environment or the GUI elements in response + to mouse or keyboard events. When a GUI element receives an event it will either + process it and return true, or pass the event to its parent. If an event is not absorbed + before it reaches the root element then it will then be passed to the user receiver. */ + EET_GUI_EVENT = 0, + + //! A mouse input event. + /** Mouse events are created by the device and passed to IrrlichtDevice::postEventFromUser + in response to mouse input received from the operating system. + Mouse events are first passed to the user receiver, then to the GUI environment and its elements, + then finally the input receiving scene manager where it is passed to the active camera. + */ + EET_MOUSE_INPUT_EVENT, + + //! A key input event. + /** Like mouse events, keyboard events are created by the device and passed to + IrrlichtDevice::postEventFromUser. They take the same path as mouse events. */ + EET_KEY_INPUT_EVENT, + + //! A string input event. + /** This event is created when multiple characters are sent at a time (e.g. using an IME). */ + EET_STRING_INPUT_EVENT, + + //! A touch input event. + EET_TOUCH_INPUT_EVENT, + + //! A accelerometer event. + EET_ACCELEROMETER_EVENT, + + //! A gyroscope event. + EET_GYROSCOPE_EVENT, + + //! A device motion event. + EET_DEVICE_MOTION_EVENT, + + //! A joystick (joypad, gamepad) input event. + /** Joystick events are created by polling all connected joysticks once per + device run() and then passing the events to IrrlichtDevice::postEventFromUser. + They take the same path as mouse events. + Windows, SDL: Implemented. + Linux: Implemented, with POV hat issues. + MacOS / Other: Not yet implemented. + */ + EET_JOYSTICK_INPUT_EVENT, + + //! A log event + /** Log events are only passed to the user receiver if there is one. If they are absorbed by the + user receiver then no text will be sent to the console. */ + EET_LOG_TEXT_EVENT, + + //! A user event with user data. + /** This is not used by Irrlicht and can be used to send user + specific data though the system. The Irrlicht 'window handle' + can be obtained from IrrlichtDevice::getExposedVideoData() + The usage and behavior depends on the operating system: + Windows: send a WM_USER message to the Irrlicht Window; the + wParam and lParam will be used to populate the + UserData1 and UserData2 members of the SUserEvent. + Linux: send a ClientMessage via XSendEvent to the Irrlicht + Window; the data.l[0] and data.l[1] members will be + cast to s32 and used as UserData1 and UserData2. + MacOS: Not yet implemented + */ + EET_USER_EVENT, + + //! Pass on raw events from the OS + EET_SYSTEM_EVENT, + + //! Application state events like a resume, pause etc. + EET_APPLICATION_EVENT, + + //! This enum is never used, it only forces the compiler to + //! compile these enumeration values to 32 bit. + EGUIET_FORCE_32_BIT = 0x7fffffff + +}; + +//! Enumeration for all mouse input events +enum EMOUSE_INPUT_EVENT +{ + //! Left mouse button was pressed down. + EMIE_LMOUSE_PRESSED_DOWN = 0, + + //! Right mouse button was pressed down. + EMIE_RMOUSE_PRESSED_DOWN, + + //! Middle mouse button was pressed down. + EMIE_MMOUSE_PRESSED_DOWN, + + //! Left mouse button was left up. + EMIE_LMOUSE_LEFT_UP, + + //! Right mouse button was left up. + EMIE_RMOUSE_LEFT_UP, + + //! Middle mouse button was left up. + EMIE_MMOUSE_LEFT_UP, + + //! The mouse cursor changed its position. + EMIE_MOUSE_MOVED, + + //! The mouse wheel was moved. Use Wheel value in event data to find out + //! in what direction and how fast. + EMIE_MOUSE_WHEEL, + + //! Left mouse button double click. + //! This event is generated after the second EMIE_LMOUSE_PRESSED_DOWN event. + EMIE_LMOUSE_DOUBLE_CLICK, + + //! Right mouse button double click. + //! This event is generated after the second EMIE_RMOUSE_PRESSED_DOWN event. + EMIE_RMOUSE_DOUBLE_CLICK, + + //! Middle mouse button double click. + //! This event is generated after the second EMIE_MMOUSE_PRESSED_DOWN event. + EMIE_MMOUSE_DOUBLE_CLICK, + + //! Left mouse button triple click. + //! This event is generated after the third EMIE_LMOUSE_PRESSED_DOWN event. + EMIE_LMOUSE_TRIPLE_CLICK, + + //! Right mouse button triple click. + //! This event is generated after the third EMIE_RMOUSE_PRESSED_DOWN event. + EMIE_RMOUSE_TRIPLE_CLICK, + + //! Middle mouse button triple click. + //! This event is generated after the third EMIE_MMOUSE_PRESSED_DOWN event. + EMIE_MMOUSE_TRIPLE_CLICK, + + //! Mouse enters canvas used for rendering. + //! Only generated on emscripten + EMIE_MOUSE_ENTER_CANVAS, + + //! Mouse leaves canvas used for rendering. + //! Only generated on emscripten + EMIE_MOUSE_LEAVE_CANVAS, + + //! No real event. Just for convenience to get number of events + EMIE_COUNT +}; + +//! Masks for mouse button states +enum E_MOUSE_BUTTON_STATE_MASK +{ + EMBSM_LEFT = 0x01, + EMBSM_RIGHT = 0x02, + EMBSM_MIDDLE = 0x04, + + //! currently only on windows + EMBSM_EXTRA1 = 0x08, + + //! currently only on windows + EMBSM_EXTRA2 = 0x10, + + EMBSM_FORCE_32_BIT = 0x7fffffff +}; + +//! Enumeration for all touch input events +enum ETOUCH_INPUT_EVENT +{ + //! Touch was pressed down. + ETIE_PRESSED_DOWN = 0, + + //! Touch was left up. + ETIE_LEFT_UP, + + //! The touch changed its position. + ETIE_MOVED, + + //! No real event. Just for convenience to get number of events + ETIE_COUNT +}; + +enum ESYSTEM_EVENT_TYPE +{ + //! From Android command handler for native activity messages + ESET_ANDROID_CMD = 0, + + // TODO: for example ESET_WINDOWS_MESSAGE for win32 message loop events + + //! No real event, but to get number of event types + ESET_COUNT +}; + +//! Enumeration for a commonly used application state events (it's useful mainly for mobile devices) +enum EAPPLICATION_EVENT_TYPE +{ + //! The application will be resumed. + EAET_WILL_RESUME = 0, + + //! The application has been resumed. + EAET_DID_RESUME, + + //! The application will be paused. + EAET_WILL_PAUSE, + + //! The application has been paused. + EAET_DID_PAUSE, + + //! The application will be terminated. + EAET_WILL_TERMINATE, + + //! The application received a memory warning. + EAET_MEMORY_WARNING, + + //! No real event, but to get number of event types. + EAET_COUNT +}; + +namespace gui +{ + +class IGUIElement; + +//! Enumeration for all events which are sendable by the gui system +enum EGUI_EVENT_TYPE +{ + //! A gui element has lost its focus. + /** GUIEvent.Caller is losing the focus to GUIEvent.Element. + If the event is absorbed then the focus will not be changed. */ + EGET_ELEMENT_FOCUS_LOST = 0, + + //! A gui element has got the focus. + /** If the event is absorbed then the focus will not be changed. */ + EGET_ELEMENT_FOCUSED, + + //! The mouse cursor hovered over a gui element. + /** If an element has sub-elements you also get this message for the subelements */ + EGET_ELEMENT_HOVERED, + + //! The mouse cursor left the hovered element. + /** If an element has sub-elements you also get this message for the subelements */ + EGET_ELEMENT_LEFT, + + //! An element would like to close. + /** Windows and context menus use this event when they would like to close, + this can be canceled by absorbing the event. */ + EGET_ELEMENT_CLOSED, + + //! A button was clicked. + EGET_BUTTON_CLICKED, + + //! A scrollbar has changed its position. + EGET_SCROLL_BAR_CHANGED, + + //! A checkbox has changed its check state. + EGET_CHECKBOX_CHANGED, + + //! A listbox would like to open. + /** You can prevent the listbox from opening by absorbing the event. */ + EGET_LISTBOX_OPENED, + + //! A new item in a listbox was selected. + /** NOTE: You also get this event currently when the same item was clicked again after more than 500 ms. */ + EGET_LISTBOX_CHANGED, + + //! An item in the listbox was selected, which was already selected. + /** NOTE: You get the event currently only if the item was clicked again within 500 ms or selected by "enter" or "space". */ + EGET_LISTBOX_SELECTED_AGAIN, + + //! A file has been selected in the file dialog + EGET_FILE_SELECTED, + + //! A directory has been selected in the file dialog + EGET_DIRECTORY_SELECTED, + + //! A file open dialog has been closed without choosing a file + EGET_FILE_CHOOSE_DIALOG_CANCELLED, + + //! In an editbox 'ENTER' was pressed + EGET_EDITBOX_ENTER, + + //! The text in an editbox was changed. This does not include automatic changes in text-breaking. + EGET_EDITBOX_CHANGED, + + //! The marked area in an editbox was changed. + EGET_EDITBOX_MARKING_CHANGED, + + //! The tab was changed in an tab control + EGET_TAB_CHANGED, + + //! The selection in a combo box has been changed + EGET_COMBO_BOX_CHANGED, + + //! A table has changed + EGET_TABLE_CHANGED, + EGET_TABLE_HEADER_CHANGED, + EGET_TABLE_SELECTED_AGAIN, + + //! No real event. Just for convenience to get number of events + EGET_COUNT +}; +} // end namespace gui + +//! SEvents hold information about an event. See irr::IEventReceiver for details on event handling. +struct SEvent +{ + //! Any kind of GUI event. + struct SGUIEvent + { + //! IGUIElement who called the event + gui::IGUIElement *Caller; + + //! If the event has something to do with another element, it will be held here. + gui::IGUIElement *Element; + + //! Type of GUI Event + gui::EGUI_EVENT_TYPE EventType; + }; + + //! Any kind of mouse event. + struct SMouseInput + { + //! X position of mouse cursor + s32 X; + + //! Y position of mouse cursor + s32 Y; + + //! mouse wheel delta, often 1.0 or -1.0, but can have other values < 0.f or > 0.f; + /** Only valid if event was EMIE_MOUSE_WHEEL */ + f32 Wheel; + + //! True if shift was also pressed + bool Shift : 1; + + //! True if ctrl was also pressed + bool Control : 1; + + //! A bitmap of button states. You can use isButtonPressed() to determine + //! if a button is pressed or not. + //! Currently only valid if the event was EMIE_MOUSE_MOVED + u32 ButtonStates; + + //! Is the left button pressed down? + bool isLeftPressed() const { return 0 != (ButtonStates & EMBSM_LEFT); } + + //! Is the right button pressed down? + bool isRightPressed() const { return 0 != (ButtonStates & EMBSM_RIGHT); } + + //! Is the middle button pressed down? + bool isMiddlePressed() const { return 0 != (ButtonStates & EMBSM_MIDDLE); } + + //! Type of mouse event + EMOUSE_INPUT_EVENT Event; + }; + + //! Any kind of keyboard event. + struct SKeyInput + { + //! Character corresponding to the key (0, if not a character, value undefined in key releases) + wchar_t Char; + + //! Key which has been pressed or released + EKEY_CODE Key; + + //! System dependent code. Only set for systems which are described below, otherwise undefined. + //! Android: int32_t with physical key as returned by AKeyEvent_getKeyCode + u32 SystemKeyCode; + + //! If not true, then the key was left up + bool PressedDown : 1; + + //! True if shift was also pressed + bool Shift : 1; + + //! True if ctrl was also pressed + bool Control : 1; + }; + + //! String input event. + struct SStringInput + { + //! The string that is entered + core::stringw *Str; + }; + + //! Any kind of touch event. + struct STouchInput + { + // Touch ID. + size_t ID; + + // X position of simple touch. + s32 X; + + // Y position of simple touch. + s32 Y; + + // number of current touches + s32 touchedCount; + + //! Type of touch event. + ETOUCH_INPUT_EVENT Event; + }; + + //! Any kind of accelerometer event. + struct SAccelerometerEvent + { + // X acceleration. + f64 X; + + // Y acceleration. + f64 Y; + + // Z acceleration. + f64 Z; + }; + + //! Any kind of gyroscope event. + struct SGyroscopeEvent + { + // X rotation. + f64 X; + + // Y rotation. + f64 Y; + + // Z rotation. + f64 Z; + }; + + //! Any kind of device motion event. + struct SDeviceMotionEvent + { + // X angle - roll. + f64 X; + + // Y angle - pitch. + f64 Y; + + // Z angle - yaw. + f64 Z; + }; + + //! A joystick event. + /** Unlike other events, joystick events represent the result of polling + * each connected joystick once per run() of the device. Joystick events will + * not be generated by default. If joystick support is available for the + * active device, and @ref irr::IrrlichtDevice::activateJoysticks() has been + * called, an event of this type will be generated once per joystick per + * @ref IrrlichtDevice::run() regardless of whether the state of the joystick + * has actually changed. */ + struct SJoystickEvent + { + enum + { + NUMBER_OF_BUTTONS = 32, + + AXIS_X = 0, // e.g. analog stick 1 left to right + AXIS_Y, // e.g. analog stick 1 top to bottom + AXIS_Z, // e.g. throttle, or analog 2 stick 2 left to right + AXIS_R, // e.g. rudder, or analog 2 stick 2 top to bottom + AXIS_U, + AXIS_V, + NUMBER_OF_AXES = 18 // (please tell Irrlicht maintainers if you absolutely need more axes) + }; + + /** A bitmap of button states. You can use IsButtonPressed() to + ( check the state of each button from 0 to (NUMBER_OF_BUTTONS - 1) */ + u32 ButtonStates; + + /** For AXIS_X, AXIS_Y, AXIS_Z, AXIS_R, AXIS_U and AXIS_V + * Values are in the range -32768 to 32767, with 0 representing + * the center position. You will receive the raw value from the + * joystick, and so will usually want to implement a dead zone around + * the center of the range. Axes not supported by this joystick will + * always have a value of 0. On Linux, POV hats are represented as axes, + * usually the last two active axis. + */ + s16 Axis[NUMBER_OF_AXES]; + + /** The POV represents the angle of the POV hat in degrees * 100, + * from 0 to 35,900. A value of 65535 indicates that the POV hat + * is centered (or not present). + * This value is only supported on Windows. On Linux, the POV hat + * will be sent as 2 axes instead. */ + u16 POV; + + //! The ID of the joystick which generated this event. + /** This is an internal Irrlicht index; it does not map directly + * to any particular hardware joystick. */ + u8 Joystick; + + //! A helper function to check if a button is pressed. + bool IsButtonPressed(u32 button) const + { + if (button >= (u32)NUMBER_OF_BUTTONS) + return false; + + return (ButtonStates & (1 << button)) ? true : false; + } + }; + + //! Any kind of log event. + struct SLogEvent + { + //! Pointer to text which has been logged + const c8 *Text; + + //! Log level in which the text has been logged + ELOG_LEVEL Level; + }; + + //! Any kind of user event. + struct SUserEvent + { + //! Some user specified data as int + size_t UserData1; + + //! Another user specified data as int + size_t UserData2; + }; + + // Raw events from the OS + struct SSystemEvent + { + //! Android command handler native activity messages. + struct SAndroidCmd + { + //! APP_CMD_ enums defined in android_native_app_glue.h from the Android NDK + s32 Cmd; + }; + + // TOOD: more structs for iphone, Windows, X11, etc. + + ESYSTEM_EVENT_TYPE EventType; + union + { + struct SAndroidCmd AndroidCmd; + }; + }; + + // Application state event + struct SApplicationEvent + { + EAPPLICATION_EVENT_TYPE EventType; + }; + + EEVENT_TYPE EventType; + union + { + struct SGUIEvent GUIEvent; + struct SMouseInput MouseInput; + struct SKeyInput KeyInput; + struct SStringInput StringInput; + struct STouchInput TouchInput; + struct SAccelerometerEvent AccelerometerEvent; + struct SGyroscopeEvent GyroscopeEvent; + struct SDeviceMotionEvent DeviceMotionEvent; + struct SJoystickEvent JoystickEvent; + struct SLogEvent LogEvent; + struct SUserEvent UserEvent; + struct SSystemEvent SystemEvent; + struct SApplicationEvent ApplicationEvent; + }; +}; + +//! Interface of an object which can receive events. +/** Many of the engine's classes inherit IEventReceiver so they are able to +process events. Events usually start at a postEventFromUser function and are +passed down through a chain of event receivers until OnEvent returns true. See +irr::EEVENT_TYPE for a description of where each type of event starts, and the +path it takes through the system. */ +class IEventReceiver +{ +public: + //! Destructor + virtual ~IEventReceiver() {} + + //! Called if an event happened. + /** Please take care that you should only return 'true' when you want to _prevent_ Irrlicht + * from processing the event any further. So 'true' does mean that an event is completely done. + * Therefore your return value for all unprocessed events should be 'false'. + \return True if the event was processed. + */ + virtual bool OnEvent(const SEvent &event) = 0; +}; + +//! Information on a joystick, returned from @ref irr::IrrlichtDevice::activateJoysticks() +struct SJoystickInfo +{ + //! The ID of the joystick + /** This is an internal Irrlicht index; it does not map directly + * to any particular hardware joystick. It corresponds to the + * irr::SJoystickEvent Joystick ID. */ + u8 Joystick; + + //! The name that the joystick uses to identify itself. + core::stringc Name; + + //! The number of buttons that the joystick has. + u32 Buttons; + + //! The number of axes that the joystick has, i.e. X, Y, Z, R, U, V. + /** Note: with a Linux device, the POV hat (if any) will use two axes. These + * will be included in this count. */ + u32 Axes; + + //! An indication of whether the joystick has a POV hat. + /** A Windows device will identify the presence or absence of the POV hat. + * A Linux device cannot, and will always return POV_HAT_UNKNOWN. */ + enum + { + //! A hat is definitely present. + POV_HAT_PRESENT, + + //! A hat is definitely not present. + POV_HAT_ABSENT, + + //! The presence or absence of a hat cannot be determined. + POV_HAT_UNKNOWN + } PovHat; +}; // struct SJoystickInfo + +} // end namespace irr diff --git a/irr/include/IFileArchive.h b/irr/include/IFileArchive.h new file mode 100644 index 000000000..fb77b48c4 --- /dev/null +++ b/irr/include/IFileArchive.h @@ -0,0 +1,127 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt/ Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReadFile.h" +#include "IFileList.h" + +namespace irr +{ + +namespace io +{ + +//! FileSystemType: which filesystem should be used for e.g. browsing +enum EFileSystemType +{ + FILESYSTEM_NATIVE = 0, // Native OS FileSystem + FILESYSTEM_VIRTUAL // Virtual FileSystem +}; + +//! Contains the different types of archives +enum E_FILE_ARCHIVE_TYPE +{ + //! A PKZIP archive + EFAT_ZIP = MAKE_IRR_ID('Z', 'I', 'P', 0), + + //! A gzip archive + EFAT_GZIP = MAKE_IRR_ID('g', 'z', 'i', 'p'), + + //! An Android asset file archive + EFAT_ANDROID_ASSET = MAKE_IRR_ID('A', 'S', 'S', 'E'), + + //! The type of this archive is unknown + EFAT_UNKNOWN = MAKE_IRR_ID('u', 'n', 'k', 'n') +}; + +//! The FileArchive manages archives and provides access to files inside them. +class IFileArchive : public virtual IReferenceCounted +{ +public: + //! Opens a file based on its name + /** Creates and returns a new IReadFile for a file in the archive. + \param filename The file to open + \return Returns A pointer to the created file on success, + or 0 on failure. */ + virtual IReadFile *createAndOpenFile(const path &filename) = 0; + + //! Opens a file based on its position in the file list. + /** Creates and returns + \param index The zero based index of the file. + \return Returns a pointer to the created file on success, or 0 on failure. */ + virtual IReadFile *createAndOpenFile(u32 index) = 0; + + //! Returns the complete file tree + /** \return Returns the complete directory tree for the archive, + including all files and folders */ + virtual const IFileList *getFileList() const = 0; + + //! get the archive type + virtual E_FILE_ARCHIVE_TYPE getType() const { return EFAT_UNKNOWN; } + + //! return the name (id) of the file Archive + virtual const io::path &getArchiveName() const = 0; + + //! Add a directory in the archive and all it's files to the FileList + /** Only needed for file-archives which have no information about their own + directory structure. In that case the user must add directories manually. + Currently this is necessary for archives of type EFAT_ANDROID_ASSET. + The root-path itself is already set by the engine. + If directories are not added manually opening files might still work, + but checks if file exists will fail. + */ + virtual void addDirectoryToFileList(const io::path &filename) {} + + //! An optionally used password string + /** This variable is publicly accessible from the interface in order to + avoid single access patterns to this place, and hence allow some more + obscurity. + */ + core::stringc Password; +}; + +//! Class which is able to create an archive from a file. +/** If you want the Irrlicht Engine be able to load archives of +currently unsupported file formats (e.g .wad), then implement +this and add your new Archive loader with +IFileSystem::addArchiveLoader() to the engine. */ +class IArchiveLoader : public virtual IReferenceCounted +{ +public: + //! Check if the file might be loaded by this class + /** Check based on the file extension (e.g. ".zip") + \param filename Name of file to check. + \return True if file seems to be loadable. */ + virtual bool isALoadableFileFormat(const path &filename) const = 0; + + //! Check if the file might be loaded by this class + /** This check may look into the file. + \param file File handle to check. + \return True if file seems to be loadable. */ + virtual bool isALoadableFileFormat(io::IReadFile *file) const = 0; + + //! Check to see if the loader can create archives of this type. + /** Check based on the archive type. + \param fileType The archive type to check. + \return True if the archive loader supports this type, false if not */ + virtual bool isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const = 0; + + //! Creates an archive from the filename + /** \param filename File to use. + \param ignoreCase Searching is performed without regarding the case + \param ignorePaths Files are searched for without checking for the directories + \return Pointer to newly created archive, or 0 upon error. */ + virtual IFileArchive *createArchive(const path &filename, bool ignoreCase, bool ignorePaths) const = 0; + + //! Creates an archive from the file + /** \param file File handle to use. + \param ignoreCase Searching is performed without regarding the case + \param ignorePaths Files are searched for without checking for the directories + \return Pointer to newly created archive, or 0 upon error. */ + virtual IFileArchive *createArchive(io::IReadFile *file, bool ignoreCase, bool ignorePaths) const = 0; +}; + +} // end namespace io +} // end namespace irr diff --git a/irr/include/IFileList.h b/irr/include/IFileList.h new file mode 100644 index 000000000..f33b1628f --- /dev/null +++ b/irr/include/IFileList.h @@ -0,0 +1,89 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "path.h" + +namespace irr +{ +namespace io +{ + +//! Provides a list of files and folders. +/** File lists usually contain a list of all files in a given folder, +but can also contain a complete directory structure. */ +class IFileList : public virtual IReferenceCounted +{ +public: + //! Get the number of files in the filelist. + /** \return Amount of files and directories in the file list. */ + virtual u32 getFileCount() const = 0; + + //! Gets the name of a file in the list, based on an index. + /** The path is not included in this name. Use getFullFileName for this. + \param index is the zero based index of the file which name should + be returned. The index must be less than the amount getFileCount() returns. + \return File name of the file. Returns 0, if an error occurred. */ + virtual const io::path &getFileName(u32 index) const = 0; + + //! Gets the full name of a file in the list including the path, based on an index. + /** \param index is the zero based index of the file which name should + be returned. The index must be less than the amount getFileCount() returns. + \return File name of the file. Returns 0 if an error occurred. */ + virtual const io::path &getFullFileName(u32 index) const = 0; + + //! Returns the size of a file in the file list, based on an index. + /** \param index is the zero based index of the file which should be returned. + The index must be less than the amount getFileCount() returns. + \return The size of the file in bytes. */ + virtual u32 getFileSize(u32 index) const = 0; + + //! Returns the file offset of a file in the file list, based on an index. + /** \param index is the zero based index of the file which should be returned. + The index must be less than the amount getFileCount() returns. + \return The offset of the file in bytes. */ + virtual u32 getFileOffset(u32 index) const = 0; + + //! Returns the ID of a file in the file list, based on an index. + /** This optional ID can be used to link the file list entry to information held + elsewhere. For example this could be an index in an IFileArchive, linking the entry + to its data offset, uncompressed size and CRC. + \param index is the zero based index of the file which should be returned. + The index must be less than the amount getFileCount() returns. + \return The ID of the file. */ + virtual u32 getID(u32 index) const = 0; + + //! Check if the file is a directory + /** \param index The zero based index which will be checked. The index + must be less than the amount getFileCount() returns. + \return True if the file is a directory, else false. */ + virtual bool isDirectory(u32 index) const = 0; + + //! Searches for a file or folder in the list + /** Searches for a file by name + \param filename The name of the file to search for. + \param isFolder True if you are searching for a directory path, false if you are searching for a file + \return Returns the index of the file in the file list, or -1 if + no matching name name was found. */ + virtual s32 findFile(const io::path &filename, bool isFolder = false) const = 0; + + //! Returns the base path of the file list + virtual const io::path &getPath() const = 0; + + //! Add as a file or folder to the list + /** \param fullPath The file name including path, from the root of the file list. + \param isDirectory True if this is a directory rather than a file. + \param offset The file offset inside an archive + \param size The size of the file in bytes. + \param id The ID of the file in the archive which owns it */ + virtual u32 addItem(const io::path &fullPath, u32 offset, u32 size, bool isDirectory, u32 id = 0) = 0; + + //! Sorts the file list. You should call this after adding any items to the file list + virtual void sort() = 0; +}; + +} // end namespace irr +} // end namespace io diff --git a/irr/include/IFileSystem.h b/irr/include/IFileSystem.h new file mode 100644 index 000000000..1fe9fe6f2 --- /dev/null +++ b/irr/include/IFileSystem.h @@ -0,0 +1,265 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "IFileArchive.h" + +namespace irr +{ +namespace video +{ +class IVideoDriver; +} // end namespace video +namespace io +{ + +class IReadFile; +class IWriteFile; +class IFileList; +class IAttributes; + +//! The FileSystem manages files and archives and provides access to them. +/** It manages where files are, so that modules which use the the IO do not +need to know where every file is located. A file could be in a .zip-Archive or +as file on disk, using the IFileSystem makes no difference to this. */ +class IFileSystem : public virtual IReferenceCounted +{ +public: + //! Opens a file for read access. + /** \param filename: Name of file to open. + \return Pointer to the created file interface. + The returned pointer should be dropped when no longer needed. + See IReferenceCounted::drop() for more information. */ + virtual IReadFile *createAndOpenFile(const path &filename) = 0; + + //! Creates an IReadFile interface for accessing memory like a file. + /** This allows you to use a pointer to memory where an IReadFile is requested. + \param memory: A pointer to the start of the file in memory + \param len: The length of the memory in bytes + \param fileName: The name given to this file + \param deleteMemoryWhenDropped: True if the memory should be deleted + along with the IReadFile when it is dropped. + \return Pointer to the created file interface. + The returned pointer should be dropped when no longer needed. + See IReferenceCounted::drop() for more information. + */ + virtual IReadFile *createMemoryReadFile(const void *memory, s32 len, const path &fileName, bool deleteMemoryWhenDropped = false) = 0; + + //! Creates an IReadFile interface for accessing files inside files. + /** This is useful e.g. for archives. + \param fileName: The name given to this file + \param alreadyOpenedFile: Pointer to the enclosing file + \param pos: Start of the file inside alreadyOpenedFile + \param areaSize: The length of the file + \return A pointer to the created file interface. + The returned pointer should be dropped when no longer needed. + See IReferenceCounted::drop() for more information. + */ + virtual IReadFile *createLimitReadFile(const path &fileName, + IReadFile *alreadyOpenedFile, long pos, long areaSize) = 0; + + //! Creates an IWriteFile interface for accessing memory like a file. + /** This allows you to use a pointer to memory where an IWriteFile is requested. + You are responsible for allocating enough memory. + \param memory: A pointer to the start of the file in memory (allocated by you) + \param len: The length of the memory in bytes + \param fileName: The name given to this file + \param deleteMemoryWhenDropped: True if the memory should be deleted + along with the IWriteFile when it is dropped. + \return Pointer to the created file interface. + The returned pointer should be dropped when no longer needed. + See IReferenceCounted::drop() for more information. + */ + virtual IWriteFile *createMemoryWriteFile(void *memory, s32 len, const path &fileName, bool deleteMemoryWhenDropped = false) = 0; + + //! Opens a file for write access. + /** \param filename: Name of file to open. + \param append: If the file already exist, all write operations are + appended to the file. + \return Pointer to the created file interface. 0 is returned, if the + file could not created or opened for writing. + The returned pointer should be dropped when no longer needed. + See IReferenceCounted::drop() for more information. */ + virtual IWriteFile *createAndWriteFile(const path &filename, bool append = false) = 0; + + //! Adds an archive to the file system. + /** After calling this, the Irrlicht Engine will also search and open + files directly from this archive. This is useful for hiding data from + the end user, speeding up file access and making it possible to access + for example Quake3 .pk3 files, which are just renamed .zip files. By + default Irrlicht supports ZIP, PAK, TAR, PNK, and directories as + archives. You can provide your own archive types by implementing + IArchiveLoader and passing an instance to addArchiveLoader. + Irrlicht supports AES-encrypted zip files, and the advanced compression + techniques lzma and bzip2. + \param filename: Filename of the archive to add to the file system. + \param ignoreCase: If set to true, files in the archive can be accessed without + writing all letters in the right case. + \param ignorePaths: If set to true, files in the added archive can be accessed + without its complete path. + \param archiveType: If no specific E_FILE_ARCHIVE_TYPE is selected then + the type of archive will depend on the extension of the file name. If + you use a different extension then you can use this parameter to force + a specific type of archive. + \param password An optional password, which is used in case of encrypted archives. + \param retArchive A pointer that will be set to the archive that is added. + \return True if the archive was added successfully, false if not. */ + virtual bool addFileArchive(const path &filename, bool ignoreCase = true, + bool ignorePaths = true, + E_FILE_ARCHIVE_TYPE archiveType = EFAT_UNKNOWN, + const core::stringc &password = "", + IFileArchive **retArchive = 0) = 0; + + //! Adds an archive to the file system. + /** After calling this, the Irrlicht Engine will also search and open + files directly from this archive. This is useful for hiding data from + the end user, speeding up file access and making it possible to access + for example Quake3 .pk3 files, which are just renamed .zip files. By + default Irrlicht supports ZIP, PAK, TAR, PNK, and directories as + archives. You can provide your own archive types by implementing + IArchiveLoader and passing an instance to addArchiveLoader. + Irrlicht supports AES-encrypted zip files, and the advanced compression + techniques lzma and bzip2. + If you want to add a directory as an archive, prefix its name with a + slash in order to let Irrlicht recognize it as a folder mount (mypath/). + Using this technique one can build up a search order, because archives + are read first, and can be used more easily with relative filenames. + \param file: Archive to add to the file system. + \param ignoreCase: If set to true, files in the archive can be accessed without + writing all letters in the right case. + \param ignorePaths: If set to true, files in the added archive can be accessed + without its complete path. + \param archiveType: If no specific E_FILE_ARCHIVE_TYPE is selected then + the type of archive will depend on the extension of the file name. If + you use a different extension then you can use this parameter to force + a specific type of archive. + \param password An optional password, which is used in case of encrypted archives. + \param retArchive A pointer that will be set to the archive that is added. + \return True if the archive was added successfully, false if not. */ + virtual bool addFileArchive(IReadFile *file, bool ignoreCase = true, + bool ignorePaths = true, + E_FILE_ARCHIVE_TYPE archiveType = EFAT_UNKNOWN, + const core::stringc &password = "", + IFileArchive **retArchive = 0) = 0; + + //! Adds an archive to the file system. + /** \param archive: The archive to add to the file system. + \return True if the archive was added successfully, false if not. */ + virtual bool addFileArchive(IFileArchive *archive) = 0; + + //! Get the number of archives currently attached to the file system + virtual u32 getFileArchiveCount() const = 0; + + //! Removes an archive from the file system. + /** This will close the archive and free any file handles, but will not + close resources which have already been loaded and are now cached, for + example textures and meshes. + \param index: The index of the archive to remove + \return True on success, false on failure */ + virtual bool removeFileArchive(u32 index) = 0; + + //! Removes an archive from the file system. + /** This will close the archive and free any file handles, but will not + close resources which have already been loaded and are now cached, for + example textures and meshes. Note that a relative filename might be + interpreted differently on each call, depending on the current working + directory. In case you want to remove an archive that was added using + a relative path name, you have to change to the same working directory + again. This means, that the filename given on creation is not an + identifier for the archive, but just a usual filename that is used for + locating the archive to work with. + \param filename The archive pointed to by the name will be removed + \return True on success, false on failure */ + virtual bool removeFileArchive(const path &filename) = 0; + + //! Removes an archive from the file system. + /** This will close the archive and free any file handles, but will not + close resources which have already been loaded and are now cached, for + example textures and meshes. + \param archive The archive to remove. + \return True on success, false on failure */ + virtual bool removeFileArchive(const IFileArchive *archive) = 0; + + //! Changes the search order of attached archives. + /** + \param sourceIndex: The index of the archive to change + \param relative: The relative change in position, archives with a lower index are searched first */ + virtual bool moveFileArchive(u32 sourceIndex, s32 relative) = 0; + + //! Get the archive at a given index. + virtual IFileArchive *getFileArchive(u32 index) = 0; + + //! Adds an external archive loader to the engine. + /** Use this function to add support for new archive types to the + engine, for example proprietary or encrypted file storage. */ + virtual void addArchiveLoader(IArchiveLoader *loader) = 0; + + //! Gets the number of archive loaders currently added + virtual u32 getArchiveLoaderCount() const = 0; + + //! Retrieve the given archive loader + /** \param index The index of the loader to retrieve. This parameter is an 0-based + array index. + \return A pointer to the specified loader, 0 if the index is incorrect. */ + virtual IArchiveLoader *getArchiveLoader(u32 index) const = 0; + + //! Get the current working directory. + /** \return Current working directory as a string. */ + virtual const path &getWorkingDirectory() = 0; + + //! Changes the current working directory. + /** \param newDirectory: A string specifying the new working directory. + The string is operating system dependent. Under Windows it has + the form ":\\\<..>". An example would be: "C:\Windows\" + \return True if successful, otherwise false. */ + virtual bool changeWorkingDirectoryTo(const path &newDirectory) = 0; + + //! Converts a relative path to an absolute (unique) path, resolving symbolic links if required + /** \param filename Possibly relative file or directory name to query. + \result Absolute filename which points to the same file. */ + virtual path getAbsolutePath(const path &filename) const = 0; + + //! Get the directory a file is located in. + /** \param filename: The file to get the directory from. + \return String containing the directory of the file. */ + virtual path getFileDir(const path &filename) const = 0; + + //! Get the base part of a filename, i.e. the name without the directory part. + /** If no directory is prefixed, the full name is returned. + \param filename: The file to get the basename from + \param keepExtension True if filename with extension is returned otherwise everything + after the final '.' is removed as well. */ + virtual path getFileBasename(const path &filename, bool keepExtension = true) const = 0; + + //! flatten a path and file name for example: "/you/me/../." becomes "/you" + virtual path &flattenFilename(path &directory, const path &root = "/") const = 0; + + //! Get the relative filename, relative to the given directory + virtual path getRelativeFilename(const path &filename, const path &directory) const = 0; + + //! Creates a list of files and directories in the current working directory and returns it. + /** \return a Pointer to the created IFileList is returned. After the list has been used + it has to be deleted using its IFileList::drop() method. + See IReferenceCounted::drop() for more information. */ + virtual IFileList *createFileList() = 0; + + //! Creates an empty filelist + /** \return a Pointer to the created IFileList is returned. After the list has been used + it has to be deleted using its IFileList::drop() method. + See IReferenceCounted::drop() for more information. */ + virtual IFileList *createEmptyFileList(const io::path &path, bool ignoreCase, bool ignorePaths) = 0; + + //! Set the active type of file system. + virtual EFileSystemType setFileListSystem(EFileSystemType listType) = 0; + + //! Determines if a file exists and could be opened. + /** \param filename is the string identifying the file which should be tested for existence. + \return True if file exists, and false if it does not exist or an error occurred. */ + virtual bool existFile(const path &filename) const = 0; +}; + +} // end namespace io +} // end namespace irr diff --git a/irr/include/IGPUProgrammingServices.h b/irr/include/IGPUProgrammingServices.h new file mode 100644 index 000000000..de24a912d --- /dev/null +++ b/irr/include/IGPUProgrammingServices.h @@ -0,0 +1,369 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "EShaderTypes.h" +#include "EMaterialTypes.h" +#include "EPrimitiveTypes.h" +#include "path.h" + +namespace irr +{ + +namespace io +{ +class IReadFile; +} // end namespace io + +namespace video +{ + +class IVideoDriver; +class IShaderConstantSetCallBack; + +//! Interface making it possible to create and use programs running on the GPU. +class IGPUProgrammingServices +{ +public: + //! Destructor + virtual ~IGPUProgrammingServices() {} + + //! Adds a new high-level shading material renderer to the VideoDriver. + /** Currently only HLSL/D3D9 and GLSL/OpenGL are supported. + \param vertexShaderProgram String containing the source of the vertex + shader program. This can be 0 if no vertex program shall be used. + \param vertexShaderEntryPointName Name of the entry function of the + vertexShaderProgram (p.e. "main") + \param vsCompileTarget Vertex shader version the high level shader + shall be compiled to. + \param pixelShaderProgram String containing the source of the pixel + shader program. This can be 0 if no pixel shader shall be used. + \param pixelShaderEntryPointName Entry name of the function of the + pixelShaderProgram (p.e. "main") + \param psCompileTarget Pixel shader version the high level shader + shall be compiled to. + \param geometryShaderProgram String containing the source of the + geometry shader program. This can be 0 if no geometry shader shall be + used. + \param geometryShaderEntryPointName Entry name of the function of the + geometryShaderProgram (p.e. "main") + \param gsCompileTarget Geometry shader version the high level shader + shall be compiled to. + \param inType Type of vertices passed to geometry shader + \param outType Type of vertices created by geometry shader + \param verticesOut Maximal number of vertices created by geometry + shader. If 0, maximal number supported is assumed. + \param callback Pointer to an implementation of + IShaderConstantSetCallBack in which you can set the needed vertex, + pixel, and geometry shader program constants. Set this to 0 if you + don't need this. + \param baseMaterial Base material which renderstates will be used to + shade the material. + \param userData a user data int. This int can be set to any value and + will be set as parameter in the callback method when calling + OnSetConstants(). In this way it is easily possible to use the same + callback method for multiple materials and distinguish between them + during the call. + \return Number of the material type which can be set in + SMaterial::MaterialType to use the renderer. -1 is returned if an error + occurred, e.g. if a shader program could not be compiled or a compile + target is not reachable. The error strings are then printed to the + error log and can be caught with a custom event receiver. */ + virtual s32 addHighLevelShaderMaterial( + const c8 *vertexShaderProgram, + const c8 *vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, + const c8 *pixelShaderProgram, + const c8 *pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, + const c8 *geometryShaderProgram, + const c8 *geometryShaderEntryPointName = "main", + E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0, + scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES, + scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP, + u32 verticesOut = 0, + IShaderConstantSetCallBack *callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0) = 0; + + //! convenience function for use without geometry shaders + s32 addHighLevelShaderMaterial( + const c8 *vertexShaderProgram, + const c8 *vertexShaderEntryPointName = "main", + E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, + const c8 *pixelShaderProgram = 0, + const c8 *pixelShaderEntryPointName = "main", + E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, + IShaderConstantSetCallBack *callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0) + { + return addHighLevelShaderMaterial( + vertexShaderProgram, vertexShaderEntryPointName, + vsCompileTarget, pixelShaderProgram, + pixelShaderEntryPointName, psCompileTarget, + 0, "main", EGST_GS_4_0, + scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, + callback, baseMaterial, userData); + } + + //! convenience function for use with many defaults, without geometry shader + /** All shader names are set to "main" and compile targets are shader + type 1.1. + */ + s32 addHighLevelShaderMaterial( + const c8 *vertexShaderProgram, + const c8 *pixelShaderProgram = 0, + IShaderConstantSetCallBack *callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0) + { + return addHighLevelShaderMaterial( + vertexShaderProgram, "main", + EVST_VS_1_1, pixelShaderProgram, + "main", EPST_PS_1_1, + 0, "main", EGST_GS_4_0, + scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, + callback, baseMaterial, userData); + } + + //! convenience function for use with many defaults, with geometry shader + /** All shader names are set to "main" and compile targets are shader + type 1.1 and geometry shader 4.0. + */ + s32 addHighLevelShaderMaterial( + const c8 *vertexShaderProgram, + const c8 *pixelShaderProgram = 0, + const c8 *geometryShaderProgram = 0, + scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES, + scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP, + u32 verticesOut = 0, + IShaderConstantSetCallBack *callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0) + { + return addHighLevelShaderMaterial( + vertexShaderProgram, "main", + EVST_VS_1_1, pixelShaderProgram, + "main", EPST_PS_1_1, + geometryShaderProgram, "main", EGST_GS_4_0, + inType, outType, verticesOut, + callback, baseMaterial, userData); + } + + //! Like addHighLevelShaderMaterial(), but loads from files. + /** \param vertexShaderProgramFileName Text file containing the source + of the vertex shader program. Set to empty string if no vertex shader + shall be created. + \param vertexShaderEntryPointName Name of the entry function of the + vertexShaderProgram (p.e. "main") + \param vsCompileTarget Vertex shader version the high level shader + shall be compiled to. + \param pixelShaderProgramFileName Text file containing the source of + the pixel shader program. Set to empty string if no pixel shader shall + be created. + \param pixelShaderEntryPointName Entry name of the function of the + pixelShaderProgram (p.e. "main") + \param psCompileTarget Pixel shader version the high level shader + shall be compiled to. + \param geometryShaderProgramFileName Name of the source of + the geometry shader program. Set to empty string if no geometry shader + shall be created. + \param geometryShaderEntryPointName Entry name of the function of the + geometryShaderProgram (p.e. "main") + \param gsCompileTarget Geometry shader version the high level shader + shall be compiled to. + \param inType Type of vertices passed to geometry shader + \param outType Type of vertices created by geometry shader + \param verticesOut Maximal number of vertices created by geometry + shader. If 0, maximal number supported is assumed. + \param callback Pointer to an implementation of + IShaderConstantSetCallBack in which you can set the needed vertex, + pixel, and geometry shader program constants. Set this to 0 if you + don't need this. + \param baseMaterial Base material which renderstates will be used to + shade the material. + \param userData a user data int. This int can be set to any value and + will be set as parameter in the callback method when calling + OnSetConstants(). In this way it is easily possible to use the same + callback method for multiple materials and distinguish between them + during the call. + \return Number of the material type which can be set in + SMaterial::MaterialType to use the renderer. -1 is returned if an error + occurred, e.g. if a shader program could not be compiled or a compile + target is not reachable. The error strings are then printed to the + error log and can be caught with a custom event receiver. */ + virtual s32 addHighLevelShaderMaterialFromFiles( + const io::path &vertexShaderProgramFileName, + const c8 *vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, + const io::path &pixelShaderProgramFileName, + const c8 *pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, + const io::path &geometryShaderProgramFileName, + const c8 *geometryShaderEntryPointName = "main", + E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0, + scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES, + scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP, + u32 verticesOut = 0, + IShaderConstantSetCallBack *callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0) = 0; + + //! convenience function for use without geometry shaders + s32 addHighLevelShaderMaterialFromFiles( + const io::path &vertexShaderProgramFileName, + const c8 *vertexShaderEntryPointName = "main", + E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, + const io::path &pixelShaderProgramFileName = "", + const c8 *pixelShaderEntryPointName = "main", + E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, + IShaderConstantSetCallBack *callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0) + { + return addHighLevelShaderMaterialFromFiles( + vertexShaderProgramFileName, vertexShaderEntryPointName, + vsCompileTarget, pixelShaderProgramFileName, + pixelShaderEntryPointName, psCompileTarget, + "", "main", EGST_GS_4_0, + scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, + callback, baseMaterial, userData); + } + + //! convenience function for use with many defaults, without geometry shader + /** All shader names are set to "main" and compile targets are shader + type 1.1. + */ + s32 addHighLevelShaderMaterialFromFiles( + const io::path &vertexShaderProgramFileName, + const io::path &pixelShaderProgramFileName = "", + IShaderConstantSetCallBack *callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0) + { + return addHighLevelShaderMaterialFromFiles( + vertexShaderProgramFileName, "main", + EVST_VS_1_1, pixelShaderProgramFileName, + "main", EPST_PS_1_1, + "", "main", EGST_GS_4_0, + scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, + callback, baseMaterial, userData); + } + + //! convenience function for use with many defaults, with geometry shader + /** All shader names are set to "main" and compile targets are shader + type 1.1 and geometry shader 4.0. + */ + s32 addHighLevelShaderMaterialFromFiles( + const io::path &vertexShaderProgramFileName, + const io::path &pixelShaderProgramFileName = "", + const io::path &geometryShaderProgramFileName = "", + scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES, + scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP, + u32 verticesOut = 0, + IShaderConstantSetCallBack *callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0) + { + return addHighLevelShaderMaterialFromFiles( + vertexShaderProgramFileName, "main", + EVST_VS_1_1, pixelShaderProgramFileName, + "main", EPST_PS_1_1, + geometryShaderProgramFileName, "main", EGST_GS_4_0, + inType, outType, verticesOut, + callback, baseMaterial, userData); + } + + //! Like addHighLevelShaderMaterial(), but loads from files. + /** \param vertexShaderProgram Text file handle containing the source + of the vertex shader program. Set to 0 if no vertex shader shall be + created. + \param vertexShaderEntryPointName Name of the entry function of the + vertexShaderProgram + \param vsCompileTarget Vertex shader version the high level shader + shall be compiled to. + \param pixelShaderProgram Text file handle containing the source of + the pixel shader program. Set to 0 if no pixel shader shall be created. + \param pixelShaderEntryPointName Entry name of the function of the + pixelShaderProgram (p.e. "main") + \param psCompileTarget Pixel shader version the high level shader + shall be compiled to. + \param geometryShaderProgram Text file handle containing the source of + the geometry shader program. Set to 0 if no geometry shader shall be + created. + \param geometryShaderEntryPointName Entry name of the function of the + geometryShaderProgram (p.e. "main") + \param gsCompileTarget Geometry shader version the high level shader + shall be compiled to. + \param inType Type of vertices passed to geometry shader + \param outType Type of vertices created by geometry shader + \param verticesOut Maximal number of vertices created by geometry + shader. If 0, maximal number supported is assumed. + \param callback Pointer to an implementation of + IShaderConstantSetCallBack in which you can set the needed vertex and + pixel shader program constants. Set this to 0 if you don't need this. + \param baseMaterial Base material which renderstates will be used to + shade the material. + \param userData a user data int. This int can be set to any value and + will be set as parameter in the callback method when calling + OnSetConstants(). In this way it is easily possible to use the same + callback method for multiple materials and distinguish between them + during the call. + \return Number of the material type which can be set in + SMaterial::MaterialType to use the renderer. -1 is returned if an + error occurred, e.g. if a shader program could not be compiled or a + compile target is not reachable. The error strings are then printed to + the error log and can be caught with a custom event receiver. */ + virtual s32 addHighLevelShaderMaterialFromFiles( + io::IReadFile *vertexShaderProgram, + const c8 *vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, + io::IReadFile *pixelShaderProgram, + const c8 *pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, + io::IReadFile *geometryShaderProgram, + const c8 *geometryShaderEntryPointName = "main", + E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0, + scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES, + scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP, + u32 verticesOut = 0, + IShaderConstantSetCallBack *callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0) = 0; + + //! convenience function for use without geometry shaders + s32 addHighLevelShaderMaterialFromFiles( + io::IReadFile *vertexShaderProgram, + const c8 *vertexShaderEntryPointName = "main", + E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, + io::IReadFile *pixelShaderProgram = 0, + const c8 *pixelShaderEntryPointName = "main", + E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, + IShaderConstantSetCallBack *callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0) + { + return addHighLevelShaderMaterialFromFiles( + vertexShaderProgram, vertexShaderEntryPointName, + vsCompileTarget, pixelShaderProgram, + pixelShaderEntryPointName, psCompileTarget, + 0, "main", EGST_GS_4_0, + scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, + callback, baseMaterial, userData); + } + + //! Delete a shader material and associated data. + /** + After you have deleted a material it is invalid to still use and doing + so might result in a crash. The ID may be reused in the future when new + materials are added. + \param material Number of the material type. Must not be a built-in + material. */ + virtual void deleteShaderMaterial(s32 material) = 0; +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/include/IGUIButton.h b/irr/include/IGUIButton.h new file mode 100644 index 000000000..0fbf866ac --- /dev/null +++ b/irr/include/IGUIButton.h @@ -0,0 +1,259 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIElement.h" + +namespace irr +{ + +namespace video +{ +class ITexture; +} // end namespace video + +namespace gui +{ +class IGUIFont; +class IGUISpriteBank; + +//! Current state of buttons used for drawing sprites. +//! Note that up to 3 states can be active at the same time: +//! EGBS_BUTTON_UP or EGBS_BUTTON_DOWN +//! EGBS_BUTTON_MOUSE_OVER or EGBS_BUTTON_MOUSE_OFF +//! EGBS_BUTTON_FOCUSED or EGBS_BUTTON_NOT_FOCUSED +enum EGUI_BUTTON_STATE +{ + //! The button is not pressed. + EGBS_BUTTON_UP = 0, + //! The button is currently pressed down. + EGBS_BUTTON_DOWN, + //! The mouse cursor is over the button + EGBS_BUTTON_MOUSE_OVER, + //! The mouse cursor is not over the button + EGBS_BUTTON_MOUSE_OFF, + //! The button has the focus + EGBS_BUTTON_FOCUSED, + //! The button doesn't have the focus + EGBS_BUTTON_NOT_FOCUSED, + //! The button is disabled All other states are ignored in that case. + EGBS_BUTTON_DISABLED, + //! not used, counts the number of enumerated items + EGBS_COUNT +}; + +//! Names for gui button state icons +const c8 *const GUIButtonStateNames[EGBS_COUNT + 1] = { + "buttonUp", + "buttonDown", + "buttonMouseOver", + "buttonMouseOff", + "buttonFocused", + "buttonNotFocused", + "buttonDisabled", + 0, // count + }; + +//! State of buttons used for drawing texture images. +//! Note that only a single state is active at a time +//! Also when no image is defined for a state it will use images from another state +//! and if that state is not set from the replacement for that,etc. +//! So in many cases setting EGBIS_IMAGE_UP and EGBIS_IMAGE_DOWN is sufficient. +enum EGUI_BUTTON_IMAGE_STATE +{ + //! When no other states have images they will all use this one. + EGBIS_IMAGE_UP, + //! When not set EGBIS_IMAGE_UP is used. + EGBIS_IMAGE_UP_MOUSEOVER, + //! When not set EGBIS_IMAGE_UP_MOUSEOVER is used. + EGBIS_IMAGE_UP_FOCUSED, + //! When not set EGBIS_IMAGE_UP_FOCUSED is used. + EGBIS_IMAGE_UP_FOCUSED_MOUSEOVER, + //! When not set EGBIS_IMAGE_UP is used. + EGBIS_IMAGE_DOWN, + //! When not set EGBIS_IMAGE_DOWN is used. + EGBIS_IMAGE_DOWN_MOUSEOVER, + //! When not set EGBIS_IMAGE_DOWN_MOUSEOVER is used. + EGBIS_IMAGE_DOWN_FOCUSED, + //! When not set EGBIS_IMAGE_DOWN_FOCUSED is used. + EGBIS_IMAGE_DOWN_FOCUSED_MOUSEOVER, + //! When not set EGBIS_IMAGE_UP or EGBIS_IMAGE_DOWN are used (depending on button state). + EGBIS_IMAGE_DISABLED, + //! not used, counts the number of enumerated items + EGBIS_COUNT +}; + +//! Names for gui button image states +const c8 *const GUIButtonImageStateNames[EGBIS_COUNT + 1] = { + "Image", // not "ImageUp" as it otherwise breaks serialization of old files + "ImageUpOver", + "ImageUpFocused", + "ImageUpFocusedOver", + "PressedImage", // not "ImageDown" as it otherwise breaks serialization of old files + "ImageDownOver", + "ImageDownFocused", + "ImageDownFocusedOver", + "ImageDisabled", + 0, // count + }; + +//! GUI Button interface. +/** \par This element can create the following events of type EGUI_EVENT_TYPE: +\li EGET_BUTTON_CLICKED +*/ +class IGUIButton : public IGUIElement +{ +public: + //! constructor + IGUIButton(IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect rectangle) : + IGUIElement(EGUIET_BUTTON, environment, parent, id, rectangle) {} + + //! Sets another skin independent font. + /** If this is set to zero, the button uses the font of the skin. + \param font: New font to set. */ + virtual void setOverrideFont(IGUIFont *font = 0) = 0; + + //! Gets the override font (if any) + /** \return The override font (may be 0) */ + virtual IGUIFont *getOverrideFont(void) const = 0; + + //! Get the font which is used right now for drawing + /** Currently this is the override font when one is set and the + font of the active skin otherwise */ + virtual IGUIFont *getActiveFont() const = 0; + + //! Sets another color for the button text. + /** When set, this color is used instead of EGDC_BUTTON_TEXT/EGDC_GRAY_TEXT. + You don't need to call enableOverrideColor(true), that's done by this function. + If you want the the color of the skin back, call enableOverrideColor(false); + \param color: New color of the text. */ + virtual void setOverrideColor(video::SColor color) = 0; + + //! Gets the override color + /** \return: The override color */ + virtual video::SColor getOverrideColor(void) const = 0; + + //! Gets the currently used text color + /** Either a skin-color for the current state or the override color */ + virtual video::SColor getActiveColor() const = 0; + + //! Sets if the button text should use the override color or the color in the gui skin. + /** \param enable: If set to true, the override color, which can be set + with IGUIStaticText::setOverrideColor is used, otherwise the + EGDC_BUTTON_TEXT or EGDC_GRAY_TEXT color of the skin. */ + virtual void enableOverrideColor(bool enable) = 0; + + //! Checks if an override color is enabled + /** \return true if the override color is enabled, false otherwise */ + virtual bool isOverrideColorEnabled(void) const = 0; + + //! Sets an image which should be displayed on the button when it is in the given state. + /** Only one image-state can be active at a time. Images are drawn below sprites. + If a state is without image it will try to use images from other states as described + in ::EGUI_BUTTON_IMAGE_STATE. + Images are a little less flexible than sprites, but easier to use. + \param state: One of ::EGUI_BUTTON_IMAGE_STATE + \param image: Image to be displayed or NULL to remove the image + \param sourceRect: Source rectangle on the image texture. When width or height are 0 then the full texture-size is used (default). */ + virtual void setImage(EGUI_BUTTON_IMAGE_STATE state, video::ITexture *image = 0, const core::rect &sourceRect = core::rect(0, 0, 0, 0)) = 0; + + //! Sets an image which should be displayed on the button when it is in normal state. + /** This is identical to calling setImage(EGBIS_IMAGE_UP, image); and might be deprecated in future revisions. + \param image: Image to be displayed */ + virtual void setImage(video::ITexture *image = 0) = 0; + + //! Sets a background image for the button when it is in normal state. + /** This is identical to calling setImage(EGBIS_IMAGE_UP, image, sourceRect); and might be deprecated in future revisions. + \param image: Texture containing the image to be displayed + \param sourceRect: Position in the texture, where the image is located. + When width or height are 0 then the full texture-size is used */ + virtual void setImage(video::ITexture *image, const core::rect &sourceRect) = 0; + + //! Sets a background image for the button when it is in pressed state. + /** This is identical to calling setImage(EGBIS_IMAGE_DOWN, image); and might be deprecated in future revisions. + If no images is specified for the pressed state via + setPressedImage(), this image is also drawn in pressed state. + \param image: Image to be displayed */ + virtual void setPressedImage(video::ITexture *image = 0) = 0; + + //! Sets an image which should be displayed on the button when it is in pressed state. + /** This is identical to calling setImage(EGBIS_IMAGE_DOWN, image, sourceRect); and might be deprecated in future revisions. + \param image: Texture containing the image to be displayed + \param sourceRect: Position in the texture, where the image is located */ + virtual void setPressedImage(video::ITexture *image, const core::rect &sourceRect) = 0; + + //! Sets the sprite bank used by the button + /** NOTE: The spritebank itself is _not_ serialized so far. The sprites are serialized. + Which means after loading the gui you still have to set the spritebank manually. */ + virtual void setSpriteBank(IGUISpriteBank *bank = 0) = 0; + + //! Sets the animated sprite for a specific button state + /** Several sprites can be drawn at the same time. + Sprites can be animated. + Sprites are drawn above the images. + \param index: Number of the sprite within the sprite bank, use -1 for no sprite + \param state: State of the button to set the sprite for + \param index: The sprite number from the current sprite bank + \param color: The color of the sprite + \param loop: True if the animation should loop, false if not + \param scale: True if the sprite should scale to button size, false if not */ + virtual void setSprite(EGUI_BUTTON_STATE state, s32 index, + video::SColor color = video::SColor(255, 255, 255, 255), bool loop = false, bool scale = false) = 0; + + //! Get the sprite-index for the given state or -1 when no sprite is set + virtual s32 getSpriteIndex(EGUI_BUTTON_STATE state) const = 0; + + //! Get the sprite color for the given state. Color is only used when a sprite is set. + virtual video::SColor getSpriteColor(EGUI_BUTTON_STATE state) const = 0; + + //! Returns if the sprite in the given state does loop + virtual bool getSpriteLoop(EGUI_BUTTON_STATE state) const = 0; + + //! Returns if the sprite in the given state is scaled + virtual bool getSpriteScale(EGUI_BUTTON_STATE state) const = 0; + + //! Sets if the button should behave like a push button. + /** Which means it can be in two states: Normal or Pressed. With a click on the button, + the user can change the state of the button. */ + virtual void setIsPushButton(bool isPushButton = true) = 0; + + //! Sets the pressed state of the button if this is a pushbutton + virtual void setPressed(bool pressed = true) = 0; + + //! Returns if the button is currently pressed + virtual bool isPressed() const = 0; + + //! Sets if the alpha channel should be used for drawing background images on the button (default is false) + virtual void setUseAlphaChannel(bool useAlphaChannel = true) = 0; + + //! Returns if the alpha channel should be used for drawing background images on the button + virtual bool isAlphaChannelUsed() const = 0; + + //! Returns whether the button is a push button + virtual bool isPushButton() const = 0; + + //! Sets if the button should use the skin to draw its border and button face (default is true) + virtual void setDrawBorder(bool border = true) = 0; + + //! Returns if the border and button face are being drawn using the skin + virtual bool isDrawingBorder() const = 0; + + //! Sets if the button should scale the button images to fit + virtual void setScaleImage(bool scaleImage = true) = 0; + + //! Checks whether the button scales the used images + virtual bool isScalingImage() const = 0; + + //! Get if the shift key was pressed in last EGET_BUTTON_CLICKED event + /** Generated together with event, so info is available in the event-receiver. */ + virtual bool getClickShiftState() const = 0; + + //! Get if the control key was pressed in last EGET_BUTTON_CLICKED event + /** Generated together with event, so info is available in the event-receiver. */ + virtual bool getClickControlState() const = 0; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/include/IGUICheckBox.h b/irr/include/IGUICheckBox.h new file mode 100644 index 000000000..0e71510b8 --- /dev/null +++ b/irr/include/IGUICheckBox.h @@ -0,0 +1,47 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIElement.h" + +namespace irr +{ +namespace gui +{ + +//! GUI Check box interface. +/** \par This element can create the following events of type EGUI_EVENT_TYPE: +\li EGET_CHECKBOX_CHANGED +*/ +class IGUICheckBox : public IGUIElement +{ +public: + //! constructor + IGUICheckBox(IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect rectangle) : + IGUIElement(EGUIET_CHECK_BOX, environment, parent, id, rectangle) {} + + //! Set if box is checked. + virtual void setChecked(bool checked) = 0; + + //! Returns true if box is checked. + virtual bool isChecked() const = 0; + + //! Sets whether to draw the background + virtual void setDrawBackground(bool draw) = 0; + + //! Checks if background drawing is enabled + /** \return true if background drawing is enabled, false otherwise */ + virtual bool isDrawBackgroundEnabled() const = 0; + + //! Sets whether to draw the border + virtual void setDrawBorder(bool draw) = 0; + + //! Checks if border drawing is enabled + /** \return true if border drawing is enabled, false otherwise */ + virtual bool isDrawBorderEnabled() const = 0; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/include/IGUIComboBox.h b/irr/include/IGUIComboBox.h new file mode 100644 index 000000000..deeaad2b5 --- /dev/null +++ b/irr/include/IGUIComboBox.h @@ -0,0 +1,72 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIElement.h" + +namespace irr +{ +namespace gui +{ + +//! Combobox widget +/** \par This element can create the following events of type EGUI_EVENT_TYPE: +\li EGET_COMBO_BOX_CHANGED +*/ +class IGUIComboBox : public IGUIElement +{ +public: + //! constructor + IGUIComboBox(IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect rectangle) : + IGUIElement(EGUIET_COMBO_BOX, environment, parent, id, rectangle) {} + + //! Returns amount of items in box + virtual u32 getItemCount() const = 0; + + //! Returns string of an item. the idx may be a value from 0 to itemCount-1 + virtual const wchar_t *getItem(u32 idx) const = 0; + + //! Returns item data of an item. the idx may be a value from 0 to itemCount-1 + virtual u32 getItemData(u32 idx) const = 0; + + //! Returns index based on item data + virtual s32 getIndexForItemData(u32 data) const = 0; + + //! Adds an item and returns the index of it + virtual u32 addItem(const wchar_t *text, u32 data = 0) = 0; + + //! Removes an item from the combo box. + /** Warning. This will change the index of all following items */ + virtual void removeItem(u32 idx) = 0; + + //! Deletes all items in the combo box + virtual void clear() = 0; + + //! Returns id of selected item. returns -1 if no item is selected. + virtual s32 getSelected() const = 0; + + //! Sets the selected item. Set this to -1 if no item should be selected + virtual void setSelected(s32 idx) = 0; + + //! Sets the selected item and emits a change event. + /** Set this to -1 if no item should be selected */ + virtual void setAndSendSelected(s32 idx) = 0; + + //! Sets text justification of the text area + /** \param horizontal: EGUIA_UPPERLEFT for left justified (default), + EGUIA_LOWERRIGHT for right justified, or EGUIA_CENTER for centered text. + \param vertical: EGUIA_UPPERLEFT to align with top edge, + EGUIA_LOWERRIGHT for bottom edge, or EGUIA_CENTER for centered text (default). */ + virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) = 0; + + //! Set the maximal number of rows for the selection listbox + virtual void setMaxSelectionRows(u32 max) = 0; + + //! Get the maximal number of rows for the selection listbox + virtual u32 getMaxSelectionRows() const = 0; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/include/IGUIEditBox.h b/irr/include/IGUIEditBox.h new file mode 100644 index 000000000..c63a905db --- /dev/null +++ b/irr/include/IGUIEditBox.h @@ -0,0 +1,151 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIElement.h" +#include "SColor.h" + +namespace irr +{ +namespace gui +{ +class IGUIFont; + +//! Single line edit box for editing simple text. +/** \par This element can create the following events of type EGUI_EVENT_TYPE: +\li EGET_EDITBOX_ENTER +\li EGET_EDITBOX_CHANGED +\li EGET_EDITBOX_MARKING_CHANGED +*/ +class IGUIEditBox : public IGUIElement +{ +public: + //! constructor + IGUIEditBox(IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect rectangle) : + IGUIElement(EGUIET_EDIT_BOX, environment, parent, id, rectangle) {} + + //! Sets another skin independent font. + /** If this is set to zero, the button uses the font of the skin. + \param font: New font to set. */ + virtual void setOverrideFont(IGUIFont *font = 0) = 0; + + //! Gets the override font (if any) + /** \return The override font (may be 0) */ + virtual IGUIFont *getOverrideFont() const = 0; + + //! Get the font which is used right now for drawing + /** Currently this is the override font when one is set and the + font of the active skin otherwise */ + virtual IGUIFont *getActiveFont() const = 0; + + //! Sets another color for the text. + /** If set, the edit box does not use the EGDC_BUTTON_TEXT color defined + in the skin, but the set color instead. You don't need to call + IGUIEditBox::enableOverrrideColor(true) after this, this is done + by this function. + If you set a color, and you want the text displayed with the color + of the skin again, call IGUIEditBox::enableOverrideColor(false); + \param color: New color of the text. */ + virtual void setOverrideColor(video::SColor color) = 0; + + //! Gets the override color + virtual video::SColor getOverrideColor() const = 0; + + //! Sets if the text should use the override color or the color in the gui skin. + /** \param enable: If set to true, the override color, which can be set + with IGUIEditBox::setOverrideColor is used, otherwise the + EGDC_BUTTON_TEXT color of the skin. */ + virtual void enableOverrideColor(bool enable) = 0; + + //! Checks if an override color is enabled + /** \return true if the override color is enabled, false otherwise */ + virtual bool isOverrideColorEnabled(void) const = 0; + + //! Sets whether to draw the background + virtual void setDrawBackground(bool draw) = 0; + + //! Checks if background drawing is enabled + /** \return true if background drawing is enabled, false otherwise */ + virtual bool isDrawBackgroundEnabled() const = 0; + + //! Turns the border on or off + /** \param border: true if you want the border to be drawn, false if not */ + virtual void setDrawBorder(bool border) = 0; + + //! Checks if border drawing is enabled + /** \return true if border drawing is enabled, false otherwise */ + virtual bool isDrawBorderEnabled() const = 0; + + //! Sets text justification mode + /** \param horizontal: EGUIA_UPPERLEFT for left justified (default), + EGUIA_LOWERRIGHT for right justified, or EGUIA_CENTER for centered text. + \param vertical: EGUIA_UPPERLEFT to align with top edge, + EGUIA_LOWERRIGHT for bottom edge, or EGUIA_CENTER for centered text (default). */ + virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) = 0; + + //! Enables or disables word wrap. + /** \param enable: If set to true, words going over one line are + broken to the next line. */ + virtual void setWordWrap(bool enable) = 0; + + //! Checks if word wrap is enabled + /** \return true if word wrap is enabled, false otherwise */ + virtual bool isWordWrapEnabled() const = 0; + + //! Enables or disables newlines. + /** \param enable: If set to true, the EGET_EDITBOX_ENTER event will not be fired, + instead a newline character will be inserted. */ + virtual void setMultiLine(bool enable) = 0; + + //! Checks if multi line editing is enabled + /** \return true if multi-line is enabled, false otherwise */ + virtual bool isMultiLineEnabled() const = 0; + + //! Enables or disables automatic scrolling with cursor position + /** \param enable: If set to true, the text will move around with the cursor position */ + virtual void setAutoScroll(bool enable) = 0; + + //! Checks to see if automatic scrolling is enabled + /** \return true if automatic scrolling is enabled, false if not */ + virtual bool isAutoScrollEnabled() const = 0; + + //! Sets whether the edit box is a password box. Setting this to true will + /** disable MultiLine, WordWrap and the ability to copy with ctrl+c or ctrl+x + \param passwordBox: true to enable password, false to disable + \param passwordChar: the character that is displayed instead of letters */ + virtual void setPasswordBox(bool passwordBox, wchar_t passwordChar = L'*') = 0; + + //! Returns true if the edit box is currently a password box. + virtual bool isPasswordBox() const = 0; + + //! Gets the size area of the text in the edit box + /** \return The size in pixels of the text */ + virtual core::dimension2du getTextDimension() = 0; + + //! Sets the maximum amount of characters which may be entered in the box. + /** \param max: Maximum amount of characters. If 0, the character amount is + infinity. */ + virtual void setMax(u32 max) = 0; + + //! Returns maximum amount of characters, previously set by setMax(); + virtual u32 getMax() const = 0; + + //! Set the character used for the cursor. + /** By default it's "_" */ + virtual void setCursorChar(const wchar_t cursorChar) = 0; + + //! Get the character used for the cursor. + virtual wchar_t getCursorChar() const = 0; + + //! Set the blinktime for the cursor. 2x blinktime is one full cycle. + //** \param timeMs Blinktime in milliseconds. When set to 0 the cursor is constantly on without blinking */ + virtual void setCursorBlinkTime(irr::u32 timeMs) = 0; + + //! Get the cursor blinktime + virtual irr::u32 getCursorBlinkTime() const = 0; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/include/IGUIElement.h b/irr/include/IGUIElement.h new file mode 100644 index 000000000..866ca282d --- /dev/null +++ b/irr/include/IGUIElement.h @@ -0,0 +1,941 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "rect.h" +#include "irrString.h" +#include "IEventReceiver.h" +#include "EGUIElementTypes.h" +#include "EGUIAlignment.h" +#include "IAttributes.h" +#include "IGUIEnvironment.h" +#include +#include +#include +#include + +namespace irr +{ +namespace gui +{ +//! Base class of all GUI elements. +class IGUIElement : virtual public IReferenceCounted, public IEventReceiver +{ +public: + //! Constructor + IGUIElement(EGUI_ELEMENT_TYPE type, IGUIEnvironment *environment, IGUIElement *parent, + s32 id, const core::rect &rectangle) : + Parent(0), + RelativeRect(rectangle), AbsoluteRect(rectangle), + AbsoluteClippingRect(rectangle), DesiredRect(rectangle), + MaxSize(0, 0), MinSize(1, 1), IsVisible(true), IsEnabled(true), + IsSubElement(false), NoClip(false), ID(id), IsTabStop(false), TabOrder(-1), IsTabGroup(false), + AlignLeft(EGUIA_UPPERLEFT), AlignRight(EGUIA_UPPERLEFT), AlignTop(EGUIA_UPPERLEFT), AlignBottom(EGUIA_UPPERLEFT), + Environment(environment), Type(type) + { +#ifdef _DEBUG + setDebugName("IGUIElement"); +#endif + + // if we were given a parent to attach to + if (parent) { + parent->addChildToEnd(this); + recalculateAbsolutePosition(true); + } + } + + //! Destructor + virtual ~IGUIElement() + { + for (auto child : Children) { + child->Parent = nullptr; + child->drop(); + } + } + + //! Returns parent of this element. + IGUIElement *getParent() const + { + return Parent; + } + + //! Returns the relative rectangle of this element. + core::rect getRelativePosition() const + { + return RelativeRect; + } + + //! Sets the relative rectangle of this element. + /** \param r The absolute position to set */ + void setRelativePosition(const core::rect &r) + { + if (Parent) { + const core::rect &r2 = Parent->getAbsolutePosition(); + + core::dimension2df d((f32)(r2.getSize().Width), (f32)(r2.getSize().Height)); + + if (AlignLeft == EGUIA_SCALE) + ScaleRect.UpperLeftCorner.X = (f32)r.UpperLeftCorner.X / d.Width; + if (AlignRight == EGUIA_SCALE) + ScaleRect.LowerRightCorner.X = (f32)r.LowerRightCorner.X / d.Width; + if (AlignTop == EGUIA_SCALE) + ScaleRect.UpperLeftCorner.Y = (f32)r.UpperLeftCorner.Y / d.Height; + if (AlignBottom == EGUIA_SCALE) + ScaleRect.LowerRightCorner.Y = (f32)r.LowerRightCorner.Y / d.Height; + } + + DesiredRect = r; + updateAbsolutePosition(); + } + + //! Sets the relative rectangle of this element, maintaining its current width and height + /** \param position The new relative position to set. Width and height will not be changed. */ + void setRelativePosition(const core::position2di &position) + { + const core::dimension2di mySize = RelativeRect.getSize(); + const core::rect rectangle(position.X, position.Y, + position.X + mySize.Width, position.Y + mySize.Height); + setRelativePosition(rectangle); + } + + //! Sets the relative rectangle of this element as a proportion of its parent's area. + /** \note This method used to be 'void setRelativePosition(const core::rect& r)' + \param r The rectangle to set, interpreted as a proportion of the parent's area. + Meaningful values are in the range [0...1], unless you intend this element to spill + outside its parent. */ + void setRelativePositionProportional(const core::rect &r) + { + if (!Parent) + return; + + const core::dimension2di &d = Parent->getAbsolutePosition().getSize(); + + DesiredRect = core::rect( + core::floor32((f32)d.Width * r.UpperLeftCorner.X), + core::floor32((f32)d.Height * r.UpperLeftCorner.Y), + core::floor32((f32)d.Width * r.LowerRightCorner.X), + core::floor32((f32)d.Height * r.LowerRightCorner.Y)); + + ScaleRect = r; + + updateAbsolutePosition(); + } + + //! Gets the absolute rectangle of this element + core::rect getAbsolutePosition() const + { + return AbsoluteRect; + } + + //! Returns the visible area of the element. + core::rect getAbsoluteClippingRect() const + { + return AbsoluteClippingRect; + } + + //! Sets whether the element will ignore its parent's clipping rectangle + /** \param noClip If true, the element will not be clipped by its parent's clipping rectangle. */ + void setNotClipped(bool noClip) + { + NoClip = noClip; + updateAbsolutePosition(); + } + + //! Gets whether the element will ignore its parent's clipping rectangle + /** \return true if the element is not clipped by its parent's clipping rectangle. */ + bool isNotClipped() const + { + return NoClip; + } + + //! Sets the maximum size allowed for this element + /** If set to 0,0, there is no maximum size */ + void setMaxSize(core::dimension2du size) + { + MaxSize = size; + updateAbsolutePosition(); + } + + //! Sets the minimum size allowed for this element + void setMinSize(core::dimension2du size) + { + MinSize = size; + if (MinSize.Width < 1) + MinSize.Width = 1; + if (MinSize.Height < 1) + MinSize.Height = 1; + updateAbsolutePosition(); + } + + //! The alignment defines how the borders of this element will be positioned when the parent element is resized. + void setAlignment(EGUI_ALIGNMENT left, EGUI_ALIGNMENT right, EGUI_ALIGNMENT top, EGUI_ALIGNMENT bottom) + { + AlignLeft = left; + AlignRight = right; + AlignTop = top; + AlignBottom = bottom; + + if (Parent) { + core::rect r(Parent->getAbsolutePosition()); + + core::dimension2df d((f32)r.getSize().Width, (f32)r.getSize().Height); + + if (AlignLeft == EGUIA_SCALE) + ScaleRect.UpperLeftCorner.X = (f32)DesiredRect.UpperLeftCorner.X / d.Width; + if (AlignRight == EGUIA_SCALE) + ScaleRect.LowerRightCorner.X = (f32)DesiredRect.LowerRightCorner.X / d.Width; + if (AlignTop == EGUIA_SCALE) + ScaleRect.UpperLeftCorner.Y = (f32)DesiredRect.UpperLeftCorner.Y / d.Height; + if (AlignBottom == EGUIA_SCALE) + ScaleRect.LowerRightCorner.Y = (f32)DesiredRect.LowerRightCorner.Y / d.Height; + } + } + + //! How left element border is aligned when parent is resized + EGUI_ALIGNMENT getAlignLeft() const + { + return AlignLeft; + } + + //! How right element border is aligned when parent is resized + EGUI_ALIGNMENT getAlignRight() const + { + return AlignRight; + } + + //! How top element border is aligned when parent is resized + EGUI_ALIGNMENT getAlignTop() const + { + return AlignTop; + } + + //! How bottom element border is aligned when parent is resized + EGUI_ALIGNMENT getAlignBottom() const + { + return AlignBottom; + } + + //! Updates the absolute position. + virtual void updateAbsolutePosition() + { + recalculateAbsolutePosition(false); + + // update all children + for (auto child : Children) { + child->updateAbsolutePosition(); + } + } + + //! Returns the topmost GUI element at the specific position. + /** + This will check this GUI element and all of its descendants, so it + may return this GUI element. To check all GUI elements, call this + function on device->getGUIEnvironment()->getRootGUIElement(). Note + that the root element is the size of the screen, so doing so (with + an on-screen point) will always return the root element if no other + element is above it at that point. + \param point: The point at which to find a GUI element. + \return The topmost GUI element at that point, or 0 if there are + no candidate elements at this point. + */ + virtual IGUIElement *getElementFromPoint(const core::position2d &point) + { + IGUIElement *target = 0; + + if (isVisible()) { + // we have to search from back to front, because later children + // might be drawn over the top of earlier ones. + auto it = Children.rbegin(); + auto ie = Children.rend(); + while (it != ie) { + target = (*it)->getElementFromPoint(point); + if (target) + return target; + + ++it; + } + } + + if (isVisible() && isPointInside(point)) + target = this; + + return target; + } + + //! Returns true if a point is within this element. + /** Elements with a shape other than a rectangle should override this method */ + virtual bool isPointInside(const core::position2d &point) const + { + return AbsoluteClippingRect.isPointInside(point); + } + + //! Adds a GUI element as new child of this element. + virtual void addChild(IGUIElement *child) + { + if (child && child != this) { + addChildToEnd(child); + child->updateAbsolutePosition(); + } + } + + //! Removes a child. + virtual void removeChild(IGUIElement *child) + { + assert(child->Parent == this); + Children.erase(child->ParentPos); + child->Parent = nullptr; + child->drop(); + } + + //! Removes all children. + virtual void removeAllChildren() + { + while (!Children.empty()) { + auto child = Children.back(); + child->remove(); + } + } + + //! Removes this element from its parent. + virtual void remove() + { + if (Parent) + Parent->removeChild(this); + } + + //! Draws the element and its children. + virtual void draw() + { + if (isVisible()) { + for (auto child : Children) + child->draw(); + } + } + + //! animate the element and its children. + virtual void OnPostRender(u32 timeMs) + { + if (isVisible()) { + for (auto child : Children) + child->OnPostRender(timeMs); + } + } + + //! Moves this element. + virtual void move(core::position2d absoluteMovement) + { + setRelativePosition(DesiredRect + absoluteMovement); + } + + //! Returns true if element is visible. + virtual bool isVisible() const + { + return IsVisible; + } + + //! Check whether the element is truly visible, taking into accounts its parents' visibility + /** \return true if the element and all its parents are visible, + false if this or any parent element is invisible. */ + virtual bool isTrulyVisible() const + { + if (!IsVisible) + return false; + + if (!Parent) + return true; + + return Parent->isTrulyVisible(); + } + + //! Sets the visible state of this element. + virtual void setVisible(bool visible) + { + IsVisible = visible; + } + + //! Returns true if this element was created as part of its parent control + virtual bool isSubElement() const + { + return IsSubElement; + } + + //! Sets whether this control was created as part of its parent. + /** For example, it is true when a scrollbar is part of a listbox. + SubElements are not saved to disk when calling guiEnvironment->saveGUI() */ + virtual void setSubElement(bool subElement) + { + IsSubElement = subElement; + } + + //! If set to true, the focus will visit this element when using the tab key to cycle through elements. + /** If this element is a tab group (see isTabGroup/setTabGroup) then + ctrl+tab will be used instead. */ + void setTabStop(bool enable) + { + IsTabStop = enable; + } + + //! Returns true if this element can be focused by navigating with the tab key + bool isTabStop() const + { + return IsTabStop; + } + + //! Sets the priority of focus when using the tab key to navigate between a group of elements. + /** See setTabGroup, isTabGroup and getTabGroup for information on tab groups. + Elements with a lower number are focused first */ + void setTabOrder(s32 index) + { + // negative = autonumber + if (index < 0) { + TabOrder = 0; + IGUIElement *el = getTabGroup(); + while (IsTabGroup && el && el->Parent) + el = el->Parent; + + IGUIElement *first = 0, *closest = 0; + if (el) { + // find the highest element number + el->getNextElement(-1, true, IsTabGroup, first, closest, true, true); + if (first) { + TabOrder = first->getTabOrder() + 1; + } + } + + } else + TabOrder = index; + } + + //! Returns the number in the tab order sequence + s32 getTabOrder() const + { + return TabOrder; + } + + //! Sets whether this element is a container for a group of elements which can be navigated using the tab key. + /** For example, windows are tab groups. + Groups can be navigated using ctrl+tab, providing isTabStop is true. */ + void setTabGroup(bool isGroup) + { + IsTabGroup = isGroup; + } + + //! Returns true if this element is a tab group. + bool isTabGroup() const + { + return IsTabGroup; + } + + //! Returns the container element which holds all elements in this element's tab group. + IGUIElement *getTabGroup() + { + IGUIElement *ret = this; + + while (ret && !ret->isTabGroup()) + ret = ret->getParent(); + + return ret; + } + + //! Returns true if element is enabled + /** Currently elements do _not_ care about parent-states. + So if you want to affect children you have to enable/disable them all. + The only exception to this are sub-elements which also check their parent. + */ + virtual bool isEnabled() const + { + if (isSubElement() && IsEnabled && getParent()) + return getParent()->isEnabled(); + + return IsEnabled; + } + + //! Sets the enabled state of this element. + virtual void setEnabled(bool enabled) + { + IsEnabled = enabled; + } + + //! Sets the new caption of this element. + virtual void setText(const wchar_t *text) + { + Text = text; + } + + //! Returns caption of this element. + virtual const wchar_t *getText() const + { + return Text.c_str(); + } + + //! Sets the new caption of this element. + virtual void setToolTipText(const wchar_t *text) + { + ToolTipText = text; + } + + //! Returns caption of this element. + virtual const core::stringw &getToolTipText() const + { + return ToolTipText; + } + + //! Returns id. Can be used to identify the element. + virtual s32 getID() const + { + return ID; + } + + //! Sets the id of this element + virtual void setID(s32 id) + { + ID = id; + } + + //! Called if an event happened. + bool OnEvent(const SEvent &event) override + { + return Parent ? Parent->OnEvent(event) : false; + } + + //! Brings a child to front + /** \return True if successful, false if not. */ + virtual bool bringToFront(IGUIElement *child) + { + if (child->Parent != this) + return false; + if (std::next(child->ParentPos) == Children.end()) // already there + return true; + Children.erase(child->ParentPos); + child->ParentPos = Children.insert(Children.end(), child); + return true; + } + + //! Moves a child to the back, so it's siblings are drawn on top of it + /** \return True if successful, false if not. */ + virtual bool sendToBack(IGUIElement *child) + { + if (child->Parent != this) + return false; + if (child->ParentPos == Children.begin()) // already there + return true; + Children.erase(child->ParentPos); + child->ParentPos = Children.insert(Children.begin(), child); + return true; + } + + //! Returns list with children of this element + virtual const std::list &getChildren() const + { + return Children; + } + + //! Finds the first element with the given id. + /** \param id: Id to search for. + \param searchchildren: Set this to true, if also children of this + element may contain the element with the searched id and they + should be searched too. + \return Returns the first element with the given id. If no element + with this id was found, 0 is returned. */ + virtual IGUIElement *getElementFromId(s32 id, bool searchchildren = false) const + { + IGUIElement *e = 0; + + for (auto child : Children) { + if (child->getID() == id) + return child; + + if (searchchildren) + e = child->getElementFromId(id, true); + + if (e) + return e; + } + + return e; + } + + //! returns true if the given element is a child of this one. + //! \param child: The child element to check + bool isMyChild(IGUIElement *child) const + { + if (!child) + return false; + do { + if (child->Parent) + child = child->Parent; + + } while (child->Parent && child != this); + + return child == this; + } + + //! searches elements to find the closest next element to tab to + /** \param startOrder: The TabOrder of the current element, -1 if none + \param reverse: true if searching for a lower number + \param group: true if searching for a higher one + \param first: element with the highest/lowest known tab order depending on search direction + \param closest: the closest match, depending on tab order and direction + \param includeInvisible: includes invisible elements in the search (default=false) + \param includeDisabled: includes disabled elements in the search (default=false) + \return true if successfully found an element, false to continue searching/fail */ + bool getNextElement(s32 startOrder, bool reverse, bool group, + IGUIElement *&first, IGUIElement *&closest, bool includeInvisible = false, + bool includeDisabled = false) const + { + // we'll stop searching if we find this number + s32 wanted = startOrder + (reverse ? -1 : 1); + if (wanted == -2) + wanted = 1073741824; // maximum s32 + + auto it = Children.begin(); + + s32 closestOrder, currentOrder; + + while (it != Children.end()) { + // ignore invisible elements and their children + if (((*it)->isVisible() || includeInvisible) && + (group == true || (*it)->isTabGroup() == false)) { + // ignore disabled, but children are checked (disabled is currently per element ignoring parent states) + if ((*it)->isEnabled() || includeDisabled) { + // only check tab stops and those with the same group status + if ((*it)->isTabStop() && ((*it)->isTabGroup() == group)) { + currentOrder = (*it)->getTabOrder(); + + // is this what we're looking for? + if (currentOrder == wanted) { + closest = *it; + return true; + } + + // is it closer than the current closest? + if (closest) { + closestOrder = closest->getTabOrder(); + if ((reverse && currentOrder > closestOrder && currentOrder < startOrder) || (!reverse && currentOrder < closestOrder && currentOrder > startOrder)) { + closest = *it; + } + } else if ((reverse && currentOrder < startOrder) || (!reverse && currentOrder > startOrder)) { + closest = *it; + } + + // is it before the current first? + if (first) { + closestOrder = first->getTabOrder(); + + if ((reverse && closestOrder < currentOrder) || (!reverse && closestOrder > currentOrder)) { + first = *it; + } + } else { + first = *it; + } + } + } + // search within children + if ((*it)->getNextElement(startOrder, reverse, group, first, closest, includeInvisible, includeDisabled)) { + return true; + } + } + ++it; + } + return false; + } + + //! Returns the type of the gui element. + /** This is needed for the .NET wrapper but will be used + later for serializing and deserializing. + If you wrote your own GUIElements, you need to set the type for your element as first parameter + in the constructor of IGUIElement. For own (=unknown) elements, simply use EGUIET_ELEMENT as type */ + EGUI_ELEMENT_TYPE getType() const + { + return Type; + } + + //! Returns true if the gui element supports the given type. + /** This is mostly used to check if you can cast a gui element to the class that goes with the type. + Most gui elements will only support their own type, but if you derive your own classes from interfaces + you can overload this function and add a check for the type of the base-class additionally. + This allows for checks comparable to the dynamic_cast of c++ with enabled rtti. + Note that you can't do that by calling BaseClass::hasType(type), but you have to do an explicit + comparison check, because otherwise the base class usually just checks for the member variable + Type which contains the type of your derived class. + */ + virtual bool hasType(EGUI_ELEMENT_TYPE type) const + { + return type == Type; + } + + //! Returns the type name of the gui element. + /** This is needed serializing elements. */ + virtual const c8 *getTypeName() const + { + return GUIElementTypeNames[Type]; + } + + //! Returns the name of the element. + /** \return Name as character string. */ + virtual const c8 *getName() const + { + return Name.c_str(); + } + + //! Sets the name of the element. + /** \param name New name of the gui element. */ + virtual void setName(const c8 *name) + { + Name = name; + } + + //! Sets the name of the element. + /** \param name New name of the gui element. */ + virtual void setName(const core::stringc &name) + { + Name = name; + } + + //! Returns whether the element takes input from the IME + virtual bool acceptsIME() + { + return false; + } + +protected: + // not virtual because needed in constructor + void addChildToEnd(IGUIElement *child) + { + if (child) { + child->grab(); // prevent destruction when removed + child->remove(); // remove from old parent + child->LastParentRect = getAbsolutePosition(); + child->Parent = this; + child->ParentPos = Children.insert(Children.end(), child); + } + } + +#ifndef NDEBUG + template + static size_t _fastSetChecksum(Iterator begin, Iterator end) + { + std::hash hasher; + size_t checksum = 0; + for (Iterator it = begin; it != end; ++it) { + size_t h = hasher(*it); + checksum ^= 966073049 + (h * 3432918353) + ((h >> 16) * 461845907); + } + return checksum; + } +#endif + + // Reorder children [from, to) to the order given by `neworder` + void reorderChildren( + std::list::iterator from, + std::list::iterator to, + const std::vector &neworder) + { + assert(_fastSetChecksum(from, to) == _fastSetChecksum(neworder.begin(), neworder.end())); + for (auto e : neworder) { + *from = e; + e->ParentPos = from; + ++from; + } + assert(from == to); + } + + // not virtual because needed in constructor + void recalculateAbsolutePosition(bool recursive) + { + core::rect parentAbsolute(0, 0, 0, 0); + core::rect parentAbsoluteClip; + f32 fw = 0.f, fh = 0.f; + + if (Parent) { + parentAbsolute = Parent->AbsoluteRect; + + if (NoClip) { + IGUIElement *p = this; + while (p->Parent) + p = p->Parent; + parentAbsoluteClip = p->AbsoluteClippingRect; + } else + parentAbsoluteClip = Parent->AbsoluteClippingRect; + } + + const s32 diffx = parentAbsolute.getWidth() - LastParentRect.getWidth(); + const s32 diffy = parentAbsolute.getHeight() - LastParentRect.getHeight(); + + if (AlignLeft == EGUIA_SCALE || AlignRight == EGUIA_SCALE) + fw = (f32)parentAbsolute.getWidth(); + + if (AlignTop == EGUIA_SCALE || AlignBottom == EGUIA_SCALE) + fh = (f32)parentAbsolute.getHeight(); + + switch (AlignLeft) { + case EGUIA_UPPERLEFT: + break; + case EGUIA_LOWERRIGHT: + DesiredRect.UpperLeftCorner.X += diffx; + break; + case EGUIA_CENTER: + DesiredRect.UpperLeftCorner.X += diffx / 2; + break; + case EGUIA_SCALE: + DesiredRect.UpperLeftCorner.X = core::round32(ScaleRect.UpperLeftCorner.X * fw); + break; + } + + switch (AlignRight) { + case EGUIA_UPPERLEFT: + break; + case EGUIA_LOWERRIGHT: + DesiredRect.LowerRightCorner.X += diffx; + break; + case EGUIA_CENTER: + DesiredRect.LowerRightCorner.X += diffx / 2; + break; + case EGUIA_SCALE: + DesiredRect.LowerRightCorner.X = core::round32(ScaleRect.LowerRightCorner.X * fw); + break; + } + + switch (AlignTop) { + case EGUIA_UPPERLEFT: + break; + case EGUIA_LOWERRIGHT: + DesiredRect.UpperLeftCorner.Y += diffy; + break; + case EGUIA_CENTER: + DesiredRect.UpperLeftCorner.Y += diffy / 2; + break; + case EGUIA_SCALE: + DesiredRect.UpperLeftCorner.Y = core::round32(ScaleRect.UpperLeftCorner.Y * fh); + break; + } + + switch (AlignBottom) { + case EGUIA_UPPERLEFT: + break; + case EGUIA_LOWERRIGHT: + DesiredRect.LowerRightCorner.Y += diffy; + break; + case EGUIA_CENTER: + DesiredRect.LowerRightCorner.Y += diffy / 2; + break; + case EGUIA_SCALE: + DesiredRect.LowerRightCorner.Y = core::round32(ScaleRect.LowerRightCorner.Y * fh); + break; + } + + RelativeRect = DesiredRect; + + const s32 w = RelativeRect.getWidth(); + const s32 h = RelativeRect.getHeight(); + + // make sure the desired rectangle is allowed + if (w < (s32)MinSize.Width) + RelativeRect.LowerRightCorner.X = RelativeRect.UpperLeftCorner.X + MinSize.Width; + if (h < (s32)MinSize.Height) + RelativeRect.LowerRightCorner.Y = RelativeRect.UpperLeftCorner.Y + MinSize.Height; + if (MaxSize.Width && w > (s32)MaxSize.Width) + RelativeRect.LowerRightCorner.X = RelativeRect.UpperLeftCorner.X + MaxSize.Width; + if (MaxSize.Height && h > (s32)MaxSize.Height) + RelativeRect.LowerRightCorner.Y = RelativeRect.UpperLeftCorner.Y + MaxSize.Height; + + RelativeRect.repair(); + + AbsoluteRect = RelativeRect + parentAbsolute.UpperLeftCorner; + + if (!Parent) + parentAbsoluteClip = AbsoluteRect; + + AbsoluteClippingRect = AbsoluteRect; + AbsoluteClippingRect.clipAgainst(parentAbsoluteClip); + + LastParentRect = parentAbsolute; + + if (recursive) { + // update all children + for (auto child : Children) { + child->recalculateAbsolutePosition(recursive); + } + } + } + +protected: + //! List of all children of this element + std::list Children; + + //! Pointer to the parent + IGUIElement *Parent; + + //! Our position in the parent list. Only valid when Parent != nullptr + std::list::iterator ParentPos; + + //! relative rect of element + core::rect RelativeRect; + + //! absolute rect of element + core::rect AbsoluteRect; + + //! absolute clipping rect of element + core::rect AbsoluteClippingRect; + + //! the rectangle the element would prefer to be, + //! if it was not constrained by parent or max/min size + core::rect DesiredRect; + + //! for calculating the difference when resizing parent + core::rect LastParentRect; + + //! relative scale of the element inside its parent + core::rect ScaleRect; + + //! maximum and minimum size of the element + core::dimension2du MaxSize, MinSize; + + //! is visible? + bool IsVisible; + + //! is enabled? + bool IsEnabled; + + //! is a part of a larger whole and should not be serialized? + bool IsSubElement; + + //! does this element ignore its parent's clipping rectangle? + bool NoClip; + + //! caption + core::stringw Text; + + //! tooltip + core::stringw ToolTipText; + + //! users can set this for identifying the element by string + core::stringc Name; + + //! users can set this for identifying the element by integer + s32 ID; + + //! tab stop like in windows + bool IsTabStop; + + //! tab order + s32 TabOrder; + + //! tab groups are containers like windows, use ctrl+tab to navigate + bool IsTabGroup; + + //! tells the element how to act when its parent is resized + EGUI_ALIGNMENT AlignLeft, AlignRight, AlignTop, AlignBottom; + + //! GUI Environment + IGUIEnvironment *Environment; + + //! type of element + EGUI_ELEMENT_TYPE Type; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/include/IGUIEnvironment.h b/irr/include/IGUIEnvironment.h new file mode 100644 index 000000000..b9905252d --- /dev/null +++ b/irr/include/IGUIEnvironment.h @@ -0,0 +1,414 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "IGUISkin.h" +#include "rect.h" +#include "EFocusFlags.h" +#include "IEventReceiver.h" +#include "path.h" + +namespace irr +{ +class IOSOperator; +class IEventReceiver; + +namespace io +{ +class IReadFile; +class IWriteFile; +class IFileSystem; +} // end namespace io +namespace video +{ +class IVideoDriver; +class ITexture; +} // end namespace video + +namespace gui +{ + +class IGUIElement; +class IGUIFont; +class IGUISpriteBank; +class IGUIScrollBar; +class IGUIImage; +class IGUICheckBox; +class IGUIListBox; +class IGUIImageList; +class IGUIFileOpenDialog; +class IGUIStaticText; +class IGUIEditBox; +class IGUITabControl; +class IGUITab; +class IGUIComboBox; +class IGUIButton; +class IGUIWindow; + +//! GUI Environment. Used as factory and manager of all other GUI elements. +/** \par This element can create the following events of type EGUI_EVENT_TYPE (which are passed on to focused sub-elements): +\li EGET_ELEMENT_FOCUS_LOST +\li EGET_ELEMENT_FOCUSED +\li EGET_ELEMENT_LEFT +\li EGET_ELEMENT_HOVERED +*/ +class IGUIEnvironment : public virtual IReferenceCounted +{ +public: + //! Draws all gui elements by traversing the GUI environment starting at the root node. + /** \param When true ensure the GuiEnvironment (aka the RootGUIElement) has the same size as the current driver screensize. + Can be set to false to control that size yourself, p.E when not the full size should be used for UI. */ + virtual void drawAll(bool useScreenSize = true) = 0; + + //! Sets the focus to an element. + /** Causes a EGET_ELEMENT_FOCUS_LOST event followed by a + EGET_ELEMENT_FOCUSED event. If someone absorbed either of the events, + then the focus will not be changed. + \param element Pointer to the element which shall get the focus. + \return True on success, false on failure */ + virtual bool setFocus(IGUIElement *element) = 0; + + //! Returns the element which holds the focus. + /** \return Pointer to the element with focus. */ + virtual IGUIElement *getFocus() const = 0; + + //! Returns the element which was last under the mouse cursor + /** NOTE: This information is updated _after_ the user-eventreceiver + received it's mouse-events. To find the hovered element while catching + mouse events you have to use instead: + IGUIEnvironment::getRootGUIElement()->getElementFromPoint(mousePos); + \return Pointer to the element under the mouse. */ + virtual IGUIElement *getHovered() const = 0; + + //! Removes the focus from an element. + /** Causes a EGET_ELEMENT_FOCUS_LOST event. If the event is absorbed + then the focus will not be changed. + \param element Pointer to the element which shall lose the focus. + \return True on success, false on failure */ + virtual bool removeFocus(IGUIElement *element) = 0; + + //! Returns whether the element has focus + /** \param element Pointer to the element which is tested. + \param checkSubElements When true and focus is on a sub-element of element then it will still count as focused and return true + \return True if the element has focus, else false. */ + virtual bool hasFocus(const IGUIElement *element, bool checkSubElements = false) const = 0; + + //! Returns the current video driver. + /** \return Pointer to the video driver. */ + virtual video::IVideoDriver *getVideoDriver() const = 0; + + //! Returns the file system. + /** \return Pointer to the file system. */ + virtual io::IFileSystem *getFileSystem() const = 0; + + //! returns a pointer to the OS operator + /** \return Pointer to the OS operator. */ + virtual IOSOperator *getOSOperator() const = 0; + + //! Removes all elements from the environment. + virtual void clear() = 0; + + //! Posts an input event to the environment. + /** Usually you do not have to + use this method, it is used by the engine internally. + \param event The event to post. + \return True if succeeded, else false. */ + virtual bool postEventFromUser(const SEvent &event) = 0; + + //! This sets a new event receiver for gui events. + /** Usually you do not have to + use this method, it is used by the engine internally. + \param evr Pointer to the new receiver. */ + virtual void setUserEventReceiver(IEventReceiver *evr) = 0; + + //! Returns pointer to the current gui skin. + /** \return Pointer to the GUI skin. */ + virtual IGUISkin *getSkin() const = 0; + + //! Sets a new GUI Skin + /** You can use this to change the appearance of the whole GUI + Environment. You can set one of the built-in skins or implement your + own class derived from IGUISkin and enable it using this method. + To set for example the built-in Windows classic skin, use the following + code: + \code + gui::IGUISkin* newskin = environment->createSkin(gui::EGST_WINDOWS_CLASSIC); + environment->setSkin(newskin); + newskin->drop(); + \endcode + \param skin New skin to use. + */ + virtual void setSkin(IGUISkin *skin) = 0; + + //! Creates a new GUI Skin based on a template. + /** Use setSkin() to set the created skin. + \param type The type of the new skin. + \return Pointer to the created skin. + If you no longer need it, you should call IGUISkin::drop(). + See IReferenceCounted::drop() for more information. */ + virtual IGUISkin *createSkin(EGUI_SKIN_TYPE type) = 0; + + //! Creates the image list from the given texture. + /** \param texture Texture to split into images + \param imageSize Dimension of each image + \param useAlphaChannel Flag whether alpha channel of the texture should be honored. + \return Pointer to the font. Returns 0 if the font could not be loaded. + This pointer should not be dropped. See IReferenceCounted::drop() for + more information. */ + virtual IGUIImageList *createImageList(video::ITexture *texture, + core::dimension2d imageSize, + bool useAlphaChannel) = 0; + + //! Returns pointer to the font with the specified filename. + /** Loads the font if it was not loaded before. + \param filename Filename of the Font. + \return Pointer to the font. Returns 0 if the font could not be loaded. + This pointer should not be dropped. See IReferenceCounted::drop() for + more information. */ + virtual IGUIFont *getFont(const io::path &filename) = 0; + + //! Adds an externally loaded font to the font list. + /** This method allows to attach an already loaded font to the list of + existing fonts. The font is grabbed if non-null and adding was successful. + \param name Name the font should be stored as. + \param font Pointer to font to add. + \return Pointer to the font stored. This can differ from given parameter if the name previously existed. */ + virtual IGUIFont *addFont(const io::path &name, IGUIFont *font) = 0; + + //! remove loaded font + virtual void removeFont(IGUIFont *font) = 0; + + //! Returns the default built-in font. + /** \return Pointer to the default built-in font. + This pointer should not be dropped. See IReferenceCounted::drop() for + more information. */ + virtual IGUIFont *getBuiltInFont() const = 0; + + //! Returns pointer to the sprite bank which was added with addEmptySpriteBank + /** TODO: This should load files in the future, but not implemented so far. + \param filename Name of a spritebank added with addEmptySpriteBank + \return Pointer to the sprite bank. Returns 0 if it could not be loaded. + This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ + virtual IGUISpriteBank *getSpriteBank(const io::path &filename) = 0; + + //! Adds an empty sprite bank to the manager + /** \param name Name of the new sprite bank. + \return Pointer to the sprite bank. + This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ + virtual IGUISpriteBank *addEmptySpriteBank(const io::path &name) = 0; + + //! Returns the root gui element. + /** This is the first gui element, the (direct or indirect) parent of all + other gui elements. It is a valid IGUIElement, with dimensions the same + size as the screen. + \return Pointer to the root element of the GUI. The returned pointer + should not be dropped. See IReferenceCounted::drop() for more + information. */ + virtual IGUIElement *getRootGUIElement() = 0; + + //! Adds a button element. + /** \param rectangle Rectangle specifying the borders of the button. + \param parent Parent gui element of the button. + \param id Id with which the gui element can be identified. + \param text Text displayed on the button. + \param tooltiptext Text displayed in the tooltip. + \return Pointer to the created button. Returns 0 if an error occurred. + This pointer should not be dropped. See IReferenceCounted::drop() for + more information. */ + virtual IGUIButton *addButton(const core::rect &rectangle, + IGUIElement *parent = 0, s32 id = -1, const wchar_t *text = 0, const wchar_t *tooltiptext = 0) = 0; + + //! Adds a scrollbar. + /** \param horizontal Specifies if the scroll bar is drawn horizontal + or vertical. + \param rectangle Rectangle specifying the borders of the scrollbar. + \param parent Parent gui element of the scroll bar. + \param id Id to identify the gui element. + \return Pointer to the created scrollbar. Returns 0 if an error + occurred. This pointer should not be dropped. See + IReferenceCounted::drop() for more information. */ + virtual IGUIScrollBar *addScrollBar(bool horizontal, const core::rect &rectangle, + IGUIElement *parent = 0, s32 id = -1) = 0; + + //! Adds an image element. + /** \param image Image to be displayed. + \param pos Position of the image. The width and height of the image is + taken from the image. + \param useAlphaChannel Sets if the image should use the alpha channel + of the texture to draw itself. + \param parent Parent gui element of the image. + \param id Id to identify the gui element. + \param text Title text of the image (not displayed). + \return Pointer to the created image element. Returns 0 if an error + occurred. This pointer should not be dropped. See + IReferenceCounted::drop() for more information. */ + virtual IGUIImage *addImage(video::ITexture *image, core::position2d pos, + bool useAlphaChannel = true, IGUIElement *parent = 0, s32 id = -1, const wchar_t *text = 0) = 0; + + //! Adds an image element. + /** Use IGUIImage::setImage later to set the image to be displayed. + \param rectangle Rectangle specifying the borders of the image. + \param parent Parent gui element of the image. + \param id Id to identify the gui element. + \param text Title text of the image (not displayed). + \param useAlphaChannel Sets if the image should use the alpha channel + of the texture to draw itself. + \return Pointer to the created image element. Returns 0 if an error + occurred. This pointer should not be dropped. See + IReferenceCounted::drop() for more information. */ + virtual IGUIImage *addImage(const core::rect &rectangle, + IGUIElement *parent = 0, s32 id = -1, const wchar_t *text = 0, bool useAlphaChannel = true) = 0; + + //! Adds a checkbox element. + /** \param checked Define the initial state of the check box. + \param rectangle Rectangle specifying the borders of the check box. + \param parent Parent gui element of the check box. + \param id Id to identify the gui element. + \param text Title text of the check box. + \return Pointer to the created check box. Returns 0 if an error + occurred. This pointer should not be dropped. See + IReferenceCounted::drop() for more information. */ + virtual IGUICheckBox *addCheckBox(bool checked, const core::rect &rectangle, + IGUIElement *parent = 0, s32 id = -1, const wchar_t *text = 0) = 0; + + //! Adds a list box element. + /** \param rectangle Rectangle specifying the borders of the list box. + \param parent Parent gui element of the list box. + \param id Id to identify the gui element. + \param drawBackground Flag whether the background should be drawn. + \return Pointer to the created list box. Returns 0 if an error occurred. + This pointer should not be dropped. See IReferenceCounted::drop() for + more information. */ + virtual IGUIListBox *addListBox(const core::rect &rectangle, + IGUIElement *parent = 0, s32 id = -1, bool drawBackground = false) = 0; + + //! Adds a file open dialog. + /** \param title Text to be displayed as the title of the dialog. + \param modal Defines if the dialog is modal. This means, that all other + gui elements which were created before the message box cannot be used + until this messagebox is removed. + \param parent Parent gui element of the dialog. + \param id Id to identify the gui element. + \param restoreCWD If set to true, the current working directory will be + restored after the dialog is closed in some way. Otherwise the working + directory will be the one that the file dialog was last showing. + \param startDir Optional path for which the file dialog will be opened. + \return Pointer to the created file open dialog. Returns 0 if an error + occurred. This pointer should not be dropped. See + IReferenceCounted::drop() for more information. */ + virtual IGUIFileOpenDialog *addFileOpenDialog(const wchar_t *title = 0, + bool modal = true, IGUIElement *parent = 0, s32 id = -1, + bool restoreCWD = false, io::path::char_type *startDir = 0) = 0; + + //! Adds a static text. + /** \param text Text to be displayed. Can be altered after creation by SetText(). + \param rectangle Rectangle specifying the borders of the static text + \param border Set to true if the static text should have a 3d border. + \param wordWrap Enable if the text should wrap into multiple lines. + \param parent Parent item of the element, e.g. a window. + \param id The ID of the element. + \param fillBackground Enable if the background shall be filled. + Defaults to false. + \return Pointer to the created static text. Returns 0 if an error + occurred. This pointer should not be dropped. See + IReferenceCounted::drop() for more information. */ + virtual IGUIStaticText *addStaticText(const wchar_t *text, const core::rect &rectangle, + bool border = false, bool wordWrap = true, IGUIElement *parent = 0, s32 id = -1, + bool fillBackground = false) = 0; + + //! Adds an edit box. + /** Supports Unicode input from every keyboard around the world, + scrolling, copying and pasting (exchanging data with the clipboard + directly), maximum character amount, marking, and all shortcuts like + ctrl+X, ctrl+V, ctrl+C, shift+Left, shift+Right, Home, End, and so on. + \param text Text to be displayed. Can be altered after creation + by setText(). + \param rectangle Rectangle specifying the borders of the edit box. + \param border Set to true if the edit box should have a 3d border. + \param parent Parent item of the element, e.g. a window. + Set it to 0 to place the edit box directly in the environment. + \param id The ID of the element. + \return Pointer to the created edit box. Returns 0 if an error occurred. + This pointer should not be dropped. See IReferenceCounted::drop() for + more information. */ + virtual IGUIEditBox *addEditBox(const wchar_t *text, const core::rect &rectangle, + bool border = true, IGUIElement *parent = 0, s32 id = -1) = 0; + + //! Adds a tab control to the environment. + /** \param rectangle Rectangle specifying the borders of the tab control. + \param parent Parent item of the element, e.g. a window. + Set it to 0 to place the tab control directly in the environment. + \param fillbackground Specifies if the background of the tab control + should be drawn. + \param border Specifies if a flat 3d border should be drawn. This is + usually not necessary unless you place the control directly into + the environment without a window as parent. + \param id An identifier for the tab control. + \return Pointer to the created tab control element. Returns 0 if an + error occurred. This pointer should not be dropped. See + IReferenceCounted::drop() for more information. */ + virtual IGUITabControl *addTabControl(const core::rect &rectangle, + IGUIElement *parent = 0, bool fillbackground = false, + bool border = true, s32 id = -1) = 0; + + //! Adds tab to the environment. + /** You can use this element to group other elements. This is not used + for creating tabs on tab controls, please use IGUITabControl::addTab() + for this instead. + \param rectangle Rectangle specifying the borders of the tab. + \param parent Parent item of the element, e.g. a window. + Set it to 0 to place the tab directly in the environment. + \param id An identifier for the tab. + \return Pointer to the created tab. Returns 0 if an + error occurred. This pointer should not be dropped. See + IReferenceCounted::drop() for more information. */ + virtual IGUITab *addTab(const core::rect &rectangle, + IGUIElement *parent = 0, s32 id = -1) = 0; + + //! Adds a combo box to the environment. + /** \param rectangle Rectangle specifying the borders of the combo box. + \param parent Parent item of the element, e.g. a window. + Set it to 0 to place the combo box directly in the environment. + \param id An identifier for the combo box. + \return Pointer to the created combo box. Returns 0 if an + error occurred. This pointer should not be dropped. See + IReferenceCounted::drop() for more information. */ + virtual IGUIComboBox *addComboBox(const core::rect &rectangle, + IGUIElement *parent = 0, s32 id = -1) = 0; + + //! Find the next element which would be selected when pressing the tab-key + /** If you set the focus for the result you can manually force focus-changes like they + would happen otherwise by the tab-keys. + \param reverse When true it will search backward (toward lower TabOrder numbers, like shift+tab) + \param group When true it will search for the next tab-group (like ctrl+tab) + */ + virtual IGUIElement *getNextElement(bool reverse = false, bool group = false) = 0; + + //! Set the way the gui will handle automatic focus changes + /** The default is (EFF_SET_ON_LMOUSE_DOWN | EFF_SET_ON_TAB). + with the left mouse button. + This does not affect the setFocus function itself - users can still call that whenever they want on any element. + \param flags A bitmask which is a combination of ::EFOCUS_FLAG flags.*/ + virtual void setFocusBehavior(u32 flags) = 0; + + //! Get the way the gui does handle focus changes + /** \returns A bitmask which is a combination of ::EFOCUS_FLAG flags.*/ + virtual u32 getFocusBehavior() const = 0; + + //! Adds a IGUIElement to deletion queue. + /** Queued elements will be removed at the end of each drawAll call. + Or latest in the destructor of the GUIEnvironment. + This can be used to allow an element removing itself safely in a function + iterating over gui elements, like an overloaded IGUIElement::draw or + IGUIElement::OnPostRender function. + Note that in general just calling IGUIElement::remove() is enough. + Unless you create your own GUI elements removing themselves you won't need it. + \param element: Element to remove */ + virtual void addToDeletionQueue(IGUIElement *element) = 0; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/include/IGUIFileOpenDialog.h b/irr/include/IGUIFileOpenDialog.h new file mode 100644 index 000000000..04a51ccb4 --- /dev/null +++ b/irr/include/IGUIFileOpenDialog.h @@ -0,0 +1,44 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIElement.h" +#include "path.h" + +namespace irr +{ +namespace gui +{ + +//! Standard file chooser dialog. +/** \warning When the user selects a folder this does change the current working directory + +\par This element can create the following events of type EGUI_EVENT_TYPE: +\li EGET_DIRECTORY_SELECTED +\li EGET_FILE_SELECTED +\li EGET_FILE_CHOOSE_DIALOG_CANCELLED +*/ +class IGUIFileOpenDialog : public IGUIElement +{ +public: + //! constructor + IGUIFileOpenDialog(IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect rectangle) : + IGUIElement(EGUIET_FILE_OPEN_DIALOG, environment, parent, id, rectangle) {} + + //! Returns the filename of the selected file converted to wide characters. Returns NULL if no file was selected. + virtual const wchar_t *getFileName() const = 0; + + //! Returns the filename of the selected file. Is empty if no file was selected. + virtual const io::path &getFileNameP() const = 0; + + //! Returns the directory of the selected file. Empty if no directory was selected. + virtual const io::path &getDirectoryName() const = 0; + + //! Returns the directory of the selected file converted to wide characters. Returns NULL if no directory was selected. + virtual const wchar_t *getDirectoryNameW() const = 0; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/include/IGUIFont.h b/irr/include/IGUIFont.h new file mode 100644 index 000000000..c18354c79 --- /dev/null +++ b/irr/include/IGUIFont.h @@ -0,0 +1,99 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "SColor.h" +#include "rect.h" +#include "irrString.h" + +namespace irr +{ +namespace gui +{ + +//! An enum for the different types of GUI font. +enum EGUI_FONT_TYPE +{ + //! Bitmap fonts loaded from an XML file or a texture. + EGFT_BITMAP = 0, + + //! Scalable vector fonts loaded from an XML file. + /** These fonts reside in system memory and use no video memory + until they are displayed. These are slower than bitmap fonts + but can be easily scaled and rotated. */ + EGFT_VECTOR, + + //! A font which uses a the native API provided by the operating system. + /** Currently not used. */ + EGFT_OS, + + //! An external font type provided by the user. + EGFT_CUSTOM +}; + +//! Font interface. +class IGUIFont : public virtual IReferenceCounted +{ +public: + //! Draws some text and clips it to the specified rectangle if wanted. + /** \param text: Text to draw + \param position: Rectangle specifying position where to draw the text. + \param color: Color of the text + \param hcenter: Specifies if the text should be centered horizontally into the rectangle. + \param vcenter: Specifies if the text should be centered vertically into the rectangle. + \param clip: Optional pointer to a rectangle against which the text will be clipped. + If the pointer is null, no clipping will be done. */ + virtual void draw(const core::stringw &text, const core::rect &position, + video::SColor color, bool hcenter = false, bool vcenter = false, + const core::rect *clip = 0) = 0; + + //! Calculates the width and height of a given string of text. + /** \return Returns width and height of the area covered by the text if + it would be drawn. */ + virtual core::dimension2d getDimension(const wchar_t *text) const = 0; + + //! Calculates the index of the character in the text which is on a specific position. + /** \param text: Text string. + \param pixel_x: X pixel position of which the index of the character will be returned. + \return Returns zero based index of the character in the text, and -1 if no no character + is on this position. (=the text is too short). */ + virtual s32 getCharacterFromPos(const wchar_t *text, s32 pixel_x) const = 0; + + //! Returns the type of this font + virtual EGUI_FONT_TYPE getType() const { return EGFT_CUSTOM; } + + //! Sets global kerning width for the font. + virtual void setKerningWidth(s32 kerning) = 0; + + //! Sets global kerning height for the font. + virtual void setKerningHeight(s32 kerning) = 0; + + //! Gets kerning values (distance between letters) for the font. If no parameters are provided, + /** the global kerning distance is returned. + \param thisLetter: If this parameter is provided, the left side kerning + for this letter is added to the global kerning value. For example, a + space might only be one pixel wide, but it may be displayed as several + pixels. + \param previousLetter: If provided, kerning is calculated for both + letters and added to the global kerning value. For example, in a font + which supports kerning pairs a string such as 'Wo' may have the 'o' + tucked neatly under the 'W'. + */ + virtual s32 getKerningWidth(const wchar_t *thisLetter = 0, const wchar_t *previousLetter = 0) const = 0; + + //! Returns the distance between letters + virtual s32 getKerningHeight() const = 0; + + //! Define which characters should not be drawn by the font. + /** For example " " would not draw any space which is usually blank in + most fonts. + \param s String of symbols which are not send down to the videodriver + */ + virtual void setInvisibleCharacters(const wchar_t *s) = 0; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/include/IGUIFontBitmap.h b/irr/include/IGUIFontBitmap.h new file mode 100644 index 000000000..b86dbe2bf --- /dev/null +++ b/irr/include/IGUIFontBitmap.h @@ -0,0 +1,41 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIFont.h" + +namespace irr +{ +namespace gui +{ +class IGUISpriteBank; + +//! Font interface. +class IGUIFontBitmap : public IGUIFont +{ +public: + //! Returns the type of this font + EGUI_FONT_TYPE getType() const override { return EGFT_BITMAP; } + + //! returns the parsed Symbol Information + virtual IGUISpriteBank *getSpriteBank() const = 0; + + //! returns the sprite number from a given character + virtual u32 getSpriteNoFromChar(const wchar_t *c) const = 0; + + //! Gets kerning values (distance between letters) for the font. If no parameters are provided, + /** the global kerning distance is returned. + \param thisLetter: If this parameter is provided, the left side kerning for this letter is added + to the global kerning value. For example, a space might only be one pixel wide, but it may + be displayed as several pixels. + \param previousLetter: If provided, kerning is calculated for both letters and added to the global + kerning value. For example, EGFT_BITMAP will add the right kerning value of previousLetter to the + left side kerning value of thisLetter, then add the global value. + */ + s32 getKerningWidth(const wchar_t *thisLetter = 0, const wchar_t *previousLetter = 0) const override = 0; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/include/IGUIImage.h b/irr/include/IGUIImage.h new file mode 100644 index 000000000..33453a3cd --- /dev/null +++ b/irr/include/IGUIImage.h @@ -0,0 +1,82 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIElement.h" + +namespace irr +{ +namespace video +{ +class ITexture; +} +namespace gui +{ +//! GUI element displaying an image. +class IGUIImage : public IGUIElement +{ +public: + //! constructor + IGUIImage(IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect rectangle) : + IGUIElement(EGUIET_IMAGE, environment, parent, id, rectangle) {} + + //! Sets an image texture + virtual void setImage(video::ITexture *image) = 0; + + //! Gets the image texture + virtual video::ITexture *getImage() const = 0; + + //! Sets the color of the image + /** \param color Color with which the image is drawn. If the color + equals Color(255,255,255,255) it is ignored. */ + virtual void setColor(video::SColor color) = 0; + + //! Sets if the image should scale to fit the element + virtual void setScaleImage(bool scale) = 0; + + //! Sets if the image should use its alpha channel to draw itself + virtual void setUseAlphaChannel(bool use) = 0; + + //! Gets the color of the image + virtual video::SColor getColor() const = 0; + + //! Returns true if the image is scaled to fit, false if not + virtual bool isImageScaled() const = 0; + + //! Returns true if the image is using the alpha channel, false if not + virtual bool isAlphaChannelUsed() const = 0; + + //! Sets the source rectangle of the image. By default the full image is used. + /** \param sourceRect coordinates inside the image or an area with size 0 for using the full image (default). */ + virtual void setSourceRect(const core::rect &sourceRect) = 0; + + //! Returns the customized source rectangle of the image to be used. + /** By default an empty rectangle of width and height 0 is returned which means the full image is used. */ + virtual core::rect getSourceRect() const = 0; + + //! Restrict drawing-area. + /** This allows for example to use the image as a progress bar. + Base for area is the image, which means: + - The original clipping area when the texture is scaled or there is no texture. + - The source-rect for an unscaled texture (but still restricted afterward by the clipping area) + Unlike normal clipping this does not affect the gui-children. + \param drawBoundUVs: Coordinates between 0 and 1 where 0 are for left+top and 1 for right+bottom + */ + virtual void setDrawBounds(const core::rect &drawBoundUVs = core::rect(0.f, 0.f, 1.f, 1.f)) = 0; + + //! Get drawing-area restrictions. + virtual core::rect getDrawBounds() const = 0; + + //! Sets whether to draw a background color (EGDC_3D_DARK_SHADOW) when no texture is set + /** By default it's enabled */ + virtual void setDrawBackground(bool draw) = 0; + + //! Checks if a background is drawn when no texture is set + /** \return true if background drawing is enabled, false otherwise */ + virtual bool isDrawBackgroundEnabled() const = 0; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/include/IGUIImageList.h b/irr/include/IGUIImageList.h new file mode 100644 index 000000000..6b23c5469 --- /dev/null +++ b/irr/include/IGUIImageList.h @@ -0,0 +1,40 @@ +// This file is part of the "Irrlicht Engine". +// written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de + +#pragma once + +#include "IGUIElement.h" +#include "rect.h" +#include "irrTypes.h" + +namespace irr +{ +namespace gui +{ + +//! Font interface. +class IGUIImageList : public virtual IReferenceCounted +{ +public: + //! Destructor + virtual ~IGUIImageList(){}; + + //! Draws an image and clips it to the specified rectangle if wanted + //! \param index: Index of the image + //! \param destPos: Position of the image to draw + //! \param clip: Optional pointer to a rectangle against which the text will be clipped. + //! If the pointer is null, no clipping will be done. + virtual void draw(s32 index, const core::position2d &destPos, + const core::rect *clip = 0) = 0; + + //! Returns the count of Images in the list. + //! \return Returns the count of Images in the list. + virtual s32 getImageCount() const = 0; + + //! Returns the size of the images in the list. + //! \return Returns the size of the images in the list. + virtual core::dimension2d getImageSize() const = 0; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/include/IGUIListBox.h b/irr/include/IGUIListBox.h new file mode 100644 index 000000000..6271eb560 --- /dev/null +++ b/irr/include/IGUIListBox.h @@ -0,0 +1,136 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIElement.h" +#include "SColor.h" + +namespace irr +{ +namespace gui +{ +class IGUISpriteBank; +class IGUIScrollBar; + +//! Enumeration for listbox colors +enum EGUI_LISTBOX_COLOR +{ + //! Color of text + EGUI_LBC_TEXT = 0, + //! Color of selected text + EGUI_LBC_TEXT_HIGHLIGHT, + //! Color of icon + EGUI_LBC_ICON, + //! Color of selected icon + EGUI_LBC_ICON_HIGHLIGHT, + //! Not used, just counts the number of available colors + EGUI_LBC_COUNT +}; + +//! Default list box GUI element. +/** \par This element can create the following events of type EGUI_EVENT_TYPE: +\li EGET_LISTBOX_CHANGED +\li EGET_LISTBOX_SELECTED_AGAIN +*/ +class IGUIListBox : public IGUIElement +{ +public: + //! constructor + IGUIListBox(IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect rectangle) : + IGUIElement(EGUIET_LIST_BOX, environment, parent, id, rectangle) {} + + //! returns amount of list items + virtual u32 getItemCount() const = 0; + + //! returns string of a list item. the may id be a value from 0 to itemCount-1 + virtual const wchar_t *getListItem(u32 id) const = 0; + + //! adds an list item, returns id of item + virtual u32 addItem(const wchar_t *text) = 0; + + //! adds an list item with an icon + /** \param text Text of list entry + \param icon Sprite index of the Icon within the current sprite bank. Set it to -1 if you want no icon + \return The id of the new created item */ + virtual u32 addItem(const wchar_t *text, s32 icon) = 0; + + //! Removes an item from the list + virtual void removeItem(u32 index) = 0; + + //! get the the id of the item at the given absolute coordinates + /** \return The id of the list item or -1 when no item is at those coordinates*/ + virtual s32 getItemAt(s32 xpos, s32 ypos) const = 0; + + //! Returns the icon of an item + virtual s32 getIcon(u32 index) const = 0; + + //! Sets the sprite bank which should be used to draw list icons. + /** This font is set to the sprite bank of the built-in-font by + default. A sprite can be displayed in front of every list item. + An icon is an index within the icon sprite bank. Several + default icons are available in the skin through getIcon. */ + virtual void setSpriteBank(IGUISpriteBank *bank) = 0; + + //! clears the list, deletes all items in the listbox + virtual void clear() = 0; + + //! returns id of selected item. returns -1 if no item is selected. + virtual s32 getSelected() const = 0; + + //! sets the selected item. Set this to -1 if no item should be selected + virtual void setSelected(s32 index) = 0; + + //! sets the selected item. Set this to 0 if no item should be selected + virtual void setSelected(const wchar_t *item) = 0; + + //! set whether the listbox should scroll to newly selected items + virtual void setAutoScrollEnabled(bool scroll) = 0; + + //! returns true if automatic scrolling is enabled, false if not. + virtual bool isAutoScrollEnabled() const = 0; + + //! set all item colors at given index to color + virtual void setItemOverrideColor(u32 index, video::SColor color) = 0; + + //! set all item colors of specified type at given index to color + virtual void setItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType, video::SColor color) = 0; + + //! clear all item colors at index + virtual void clearItemOverrideColor(u32 index) = 0; + + //! clear item color at index for given colortype + virtual void clearItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) = 0; + + //! has the item at index its color overwritten? + virtual bool hasItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const = 0; + + //! return the overwrite color at given item index. + virtual video::SColor getItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const = 0; + + //! return the default color which is used for the given colorType + virtual video::SColor getItemDefaultColor(EGUI_LISTBOX_COLOR colorType) const = 0; + + //! set the item at the given index + virtual void setItem(u32 index, const wchar_t *text, s32 icon) = 0; + + //! Insert the item at the given index + /** \return The index on success or -1 on failure. */ + virtual s32 insertItem(u32 index, const wchar_t *text, s32 icon) = 0; + + //! Swap the items at the given indices + virtual void swapItems(u32 index1, u32 index2) = 0; + + //! set global itemHeight + virtual void setItemHeight(s32 height) = 0; + + //! Sets whether to draw the background + virtual void setDrawBackground(bool draw) = 0; + + //! Access the vertical scrollbar + virtual IGUIScrollBar *getVerticalScrollBar() const = 0; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/include/IGUIScrollBar.h b/irr/include/IGUIScrollBar.h new file mode 100644 index 000000000..c7eb4b1b8 --- /dev/null +++ b/irr/include/IGUIScrollBar.h @@ -0,0 +1,59 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIElement.h" + +namespace irr +{ +namespace gui +{ + +//! Default scroll bar GUI element. +/** \par This element can create the following events of type EGUI_EVENT_TYPE: +\li EGET_SCROLL_BAR_CHANGED +*/ +class IGUIScrollBar : public IGUIElement +{ +public: + //! constructor + IGUIScrollBar(IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect rectangle) : + IGUIElement(EGUIET_SCROLL_BAR, environment, parent, id, rectangle) {} + + //! sets the maximum value of the scrollbar. + virtual void setMax(s32 max) = 0; + //! gets the maximum value of the scrollbar. + virtual s32 getMax() const = 0; + + //! sets the minimum value of the scrollbar. + virtual void setMin(s32 min) = 0; + //! gets the minimum value of the scrollbar. + virtual s32 getMin() const = 0; + + //! gets the small step value + virtual s32 getSmallStep() const = 0; + + //! Sets the small step + /** That is the amount that the value changes by when clicking + on the buttons or using the cursor keys. */ + virtual void setSmallStep(s32 step) = 0; + + //! gets the large step value + virtual s32 getLargeStep() const = 0; + + //! Sets the large step + /** That is the amount that the value changes by when clicking + in the tray, or using the page up and page down keys. */ + virtual void setLargeStep(s32 step) = 0; + + //! gets the current position of the scrollbar + virtual s32 getPos() const = 0; + + //! sets the current position of the scrollbar + virtual void setPos(s32 pos) = 0; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/include/IGUISkin.h b/irr/include/IGUISkin.h new file mode 100644 index 000000000..6ec456472 --- /dev/null +++ b/irr/include/IGUISkin.h @@ -0,0 +1,565 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "EGUIAlignment.h" +#include "SColor.h" +#include "rect.h" + +namespace irr +{ +namespace gui +{ +class IGUIFont; +class IGUISpriteBank; +class IGUIElement; + +//! Enumeration of available default skins. +/** To set one of the skins, use the following code, for example to set +the Windows classic skin: +\code +gui::IGUISkin* newskin = environment->createSkin(gui::EGST_WINDOWS_CLASSIC); +environment->setSkin(newskin); +newskin->drop(); +\endcode +*/ +enum EGUI_SKIN_TYPE +{ + //! Default windows look and feel + EGST_WINDOWS_CLASSIC = 0, + + //! Like EGST_WINDOWS_CLASSIC, but with metallic shaded windows and buttons + EGST_WINDOWS_METALLIC, + + //! Burning's skin + EGST_BURNING_SKIN, + + //! An unknown skin, not serializable at present + EGST_UNKNOWN, + + //! this value is not used, it only specifies the number of skin types + EGST_COUNT +}; + +//! Names for gui element types +const c8 *const GUISkinTypeNames[EGST_COUNT + 1] = { + "windowsClassic", + "windowsMetallic", + "burning", + "unknown", + 0, + }; + +//! Enumeration for skin colors +enum EGUI_DEFAULT_COLOR +{ + //! Dark shadow for three-dimensional display elements. + EGDC_3D_DARK_SHADOW = 0, + //! Shadow color for three-dimensional display elements (for edges facing away from the light source). + EGDC_3D_SHADOW, + //! Face color for three-dimensional display elements and for dialog box backgrounds. + EGDC_3D_FACE, + //! Highlight color for three-dimensional display elements (for edges facing the light source.) + EGDC_3D_HIGH_LIGHT, + //! Light color for three-dimensional display elements (for edges facing the light source.) + EGDC_3D_LIGHT, + //! Active window border. + EGDC_ACTIVE_BORDER, + //! Active window title bar text. + EGDC_ACTIVE_CAPTION, + //! Background color of multiple document interface (MDI) applications. + EGDC_APP_WORKSPACE, + //! Text on a button + EGDC_BUTTON_TEXT, + //! Grayed (disabled) text. + EGDC_GRAY_TEXT, + //! Item(s) selected in a control. + EGDC_HIGH_LIGHT, + //! Text of item(s) selected in a control. + EGDC_HIGH_LIGHT_TEXT, + //! Inactive window border. + EGDC_INACTIVE_BORDER, + //! Inactive window caption. + EGDC_INACTIVE_CAPTION, + //! Tool tip text color + EGDC_TOOLTIP, + //! Tool tip background color + EGDC_TOOLTIP_BACKGROUND, + //! Scrollbar gray area + EGDC_SCROLLBAR, + //! Window background + EGDC_WINDOW, + //! Window symbols like on close buttons, scroll bars and check boxes + EGDC_WINDOW_SYMBOL, + //! Icons in a list or tree + EGDC_ICON, + //! Selected icons in a list or tree + EGDC_ICON_HIGH_LIGHT, + //! Grayed (disabled) window symbols like on close buttons, scroll bars and check boxes + EGDC_GRAY_WINDOW_SYMBOL, + //! Window background for editable field (editbox, checkbox-field) + EGDC_EDITABLE, + //! Grayed (disabled) window background for editable field (editbox, checkbox-field) + EGDC_GRAY_EDITABLE, + //! Show focus of window background for editable field (editbox or when checkbox-field is pressed) + EGDC_FOCUSED_EDITABLE, + + //! this value is not used, it only specifies the amount of default colors + //! available. + EGDC_COUNT +}; + +//! Names for default skin colors +const c8 *const GUISkinColorNames[EGDC_COUNT + 1] = { + "3DDarkShadow", + "3DShadow", + "3DFace", + "3DHighlight", + "3DLight", + "ActiveBorder", + "ActiveCaption", + "AppWorkspace", + "ButtonText", + "GrayText", + "Highlight", + "HighlightText", + "InactiveBorder", + "InactiveCaption", + "ToolTip", + "ToolTipBackground", + "ScrollBar", + "Window", + "WindowSymbol", + "Icon", + "IconHighlight", + "GrayWindowSymbol", + "Editable", + "GrayEditable", + "FocusedEditable", + 0, + }; + +//! Enumeration for default sizes. +enum EGUI_DEFAULT_SIZE +{ + //! default with / height of scrollbar. Also width of drop-down button in comboboxes. + EGDS_SCROLLBAR_SIZE = 0, + //! height of menu + EGDS_MENU_HEIGHT, + //! width and height of a window titlebar button (like minimize/maximize/close buttons). The titlebar height is also calculated from that. + EGDS_WINDOW_BUTTON_WIDTH, + //! width of a checkbox check + EGDS_CHECK_BOX_WIDTH, + //! \deprecated This may be removed by Irrlicht 1.9 + EGDS_MESSAGE_BOX_WIDTH, + //! \deprecated This may be removed by Irrlicht 1.9 + EGDS_MESSAGE_BOX_HEIGHT, + //! width of a default button + EGDS_BUTTON_WIDTH, + //! height of a default button (OK and cancel buttons) + EGDS_BUTTON_HEIGHT, + //! distance for text from background + EGDS_TEXT_DISTANCE_X, + //! distance for text from background + EGDS_TEXT_DISTANCE_Y, + //! distance for text in the title bar, from the left of the window rect + EGDS_TITLEBARTEXT_DISTANCE_X, + //! distance for text in the title bar, from the top of the window rect + EGDS_TITLEBARTEXT_DISTANCE_Y, + //! free space in a messagebox between borders and contents on all sides + EGDS_MESSAGE_BOX_GAP_SPACE, + //! minimal space to reserve for messagebox text-width + EGDS_MESSAGE_BOX_MIN_TEXT_WIDTH, + //! maximal space to reserve for messagebox text-width + EGDS_MESSAGE_BOX_MAX_TEXT_WIDTH, + //! minimal space to reserve for messagebox text-height + EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT, + //! maximal space to reserve for messagebox text-height + EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT, + //! pixels to move an unscaled button image to the right when a button is pressed and the unpressed image looks identical + EGDS_BUTTON_PRESSED_IMAGE_OFFSET_X, + //! pixels to move an unscaled button image down when a button is pressed and the unpressed image looks identical + EGDS_BUTTON_PRESSED_IMAGE_OFFSET_Y, + //! pixels to move the button text to the right when a button is pressed + EGDS_BUTTON_PRESSED_TEXT_OFFSET_X, + //! pixels to move the button text down when a button is pressed + EGDS_BUTTON_PRESSED_TEXT_OFFSET_Y, + //! pixels to move an unscaled button sprite to the right when a button is pressed + EGDS_BUTTON_PRESSED_SPRITE_OFFSET_X, + //! pixels to move an unscaled button sprite down when a button is pressed + EGDS_BUTTON_PRESSED_SPRITE_OFFSET_Y, + + //! this value is not used, it only specifies the amount of default sizes + //! available. + EGDS_COUNT +}; + +//! Names for default skin sizes +const c8 *const GUISkinSizeNames[EGDS_COUNT + 1] = { + "ScrollBarSize", + "MenuHeight", + "WindowButtonWidth", + "CheckBoxWidth", + "MessageBoxWidth", + "MessageBoxHeight", + "ButtonWidth", + "ButtonHeight", + "TextDistanceX", + "TextDistanceY", + "TitleBarTextX", + "TitleBarTextY", + "MessageBoxGapSpace", + "MessageBoxMinTextWidth", + "MessageBoxMaxTextWidth", + "MessageBoxMinTextHeight", + "MessageBoxMaxTextHeight", + "ButtonPressedImageOffsetX", + "ButtonPressedImageOffsetY", + "ButtonPressedTextOffsetX", + "ButtonPressedTextOffsetY", + "ButtonPressedSpriteOffsetX", + "ButtonPressedSpriteOffsetY", + 0, + }; + +enum EGUI_DEFAULT_TEXT +{ + //! Text for the OK button on a message box + EGDT_MSG_BOX_OK = 0, + //! Text for the Cancel button on a message box + EGDT_MSG_BOX_CANCEL, + //! Text for the Yes button on a message box + EGDT_MSG_BOX_YES, + //! Text for the No button on a message box + EGDT_MSG_BOX_NO, + //! Tooltip text for window close button + EGDT_WINDOW_CLOSE, + //! Tooltip text for window maximize button + EGDT_WINDOW_MAXIMIZE, + //! Tooltip text for window minimize button + EGDT_WINDOW_MINIMIZE, + //! Tooltip text for window restore button + EGDT_WINDOW_RESTORE, + + //! this value is not used, it only specifies the number of default texts + EGDT_COUNT +}; + +//! Names for default skin sizes +const c8 *const GUISkinTextNames[EGDT_COUNT + 1] = { + "MessageBoxOkay", + "MessageBoxCancel", + "MessageBoxYes", + "MessageBoxNo", + "WindowButtonClose", + "WindowButtonMaximize", + "WindowButtonMinimize", + "WindowButtonRestore", + 0, + }; + +//! Customizable symbols for GUI +enum EGUI_DEFAULT_ICON +{ + //! maximize window button + EGDI_WINDOW_MAXIMIZE = 0, + //! restore window button + EGDI_WINDOW_RESTORE, + //! close window button + EGDI_WINDOW_CLOSE, + //! minimize window button + EGDI_WINDOW_MINIMIZE, + //! resize icon for bottom right corner of a window + EGDI_WINDOW_RESIZE, + //! scroll bar up button + EGDI_CURSOR_UP, + //! scroll bar down button + EGDI_CURSOR_DOWN, + //! scroll bar left button + EGDI_CURSOR_LEFT, + //! scroll bar right button + EGDI_CURSOR_RIGHT, + //! icon for menu children + EGDI_MENU_MORE, + //! tick for checkbox + EGDI_CHECK_BOX_CHECKED, + //! down arrow for dropdown menus + EGDI_DROP_DOWN, + //! smaller up arrow + EGDI_SMALL_CURSOR_UP, + //! smaller down arrow + EGDI_SMALL_CURSOR_DOWN, + //! selection dot in a radio button + EGDI_RADIO_BUTTON_CHECKED, + //! << icon indicating there is more content to the left + EGDI_MORE_LEFT, + //! >> icon indicating that there is more content to the right + EGDI_MORE_RIGHT, + //! icon indicating that there is more content above + EGDI_MORE_UP, + //! icon indicating that there is more content below + EGDI_MORE_DOWN, + //! plus icon for trees + EGDI_EXPAND, + + //! minus icon for trees + EGDI_COLLAPSE, + //! file icon for file selection + EGDI_FILE, + //! folder icon for file selection + EGDI_DIRECTORY, + + //! value not used, it only specifies the number of icons + EGDI_COUNT +}; + +const c8 *const GUISkinIconNames[EGDI_COUNT + 1] = { + "windowMaximize", + "windowRestore", + "windowClose", + "windowMinimize", + "windowResize", + "cursorUp", + "cursorDown", + "cursorLeft", + "cursorRight", + "menuMore", + "checkBoxChecked", + "dropDown", + "smallCursorUp", + "smallCursorDown", + "radioButtonChecked", + "moreLeft", + "moreRight", + "moreUp", + "moreDown", + "expand", + "collapse", + "file", + "directory", + 0, + }; + +// Customizable fonts +enum EGUI_DEFAULT_FONT +{ + //! For static text, edit boxes, lists and most other places + EGDF_DEFAULT = 0, + //! Font for buttons + EGDF_BUTTON, + //! Font for window title bars + EGDF_WINDOW, + //! Font for menu items + EGDF_MENU, + //! Font for tooltips + EGDF_TOOLTIP, + //! this value is not used, it only specifies the amount of default fonts + //! available. + EGDF_COUNT +}; + +const c8 *const GUISkinFontNames[EGDF_COUNT + 1] = { + "defaultFont", + "buttonFont", + "windowFont", + "menuFont", + "tooltipFont", + 0, + }; + +//! A skin modifies the look of the GUI elements. +class IGUISkin : virtual public IReferenceCounted +{ +public: + //! returns default color + virtual video::SColor getColor(EGUI_DEFAULT_COLOR color) const = 0; + + //! sets a default color + virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor) = 0; + + //! returns size for the given size type + virtual s32 getSize(EGUI_DEFAULT_SIZE size) const = 0; + + //! Returns a default text. + /** For example for Message box button captions: + "OK", "Cancel", "Yes", "No" and so on. */ + virtual const wchar_t *getDefaultText(EGUI_DEFAULT_TEXT text) const = 0; + + //! Sets a default text. + /** For example for Message box button captions: + "OK", "Cancel", "Yes", "No" and so on. */ + virtual void setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t *newText) = 0; + + //! sets a default size + virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size) = 0; + + //! returns the default font + virtual IGUIFont *getFont(EGUI_DEFAULT_FONT which = EGDF_DEFAULT) const = 0; + + //! sets a default font + virtual void setFont(IGUIFont *font, EGUI_DEFAULT_FONT which = EGDF_DEFAULT) = 0; + + //! returns the sprite bank + virtual IGUISpriteBank *getSpriteBank() const = 0; + + //! sets the sprite bank + virtual void setSpriteBank(IGUISpriteBank *bank) = 0; + + //! Returns a default icon + /** Returns the sprite index within the sprite bank */ + virtual u32 getIcon(EGUI_DEFAULT_ICON icon) const = 0; + + //! Sets a default icon + /** Sets the sprite index used for drawing icons like arrows, + close buttons and ticks in checkboxes + \param icon: Enum specifying which icon to change + \param index: The sprite index used to draw this icon */ + virtual void setIcon(EGUI_DEFAULT_ICON icon, u32 index) = 0; + + //! draws a standard 3d button pane + /** Used for drawing for example buttons in normal state. + It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and + EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by IGUISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DButtonPaneStandard(IGUIElement *element, + const core::rect &rect, + const core::rect *clip = 0) = 0; + + //! draws a pressed 3d button pane + /** Used for drawing for example buttons in pressed state. + It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and + EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by IGUISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DButtonPanePressed(IGUIElement *element, + const core::rect &rect, + const core::rect *clip = 0) = 0; + + //! draws a sunken 3d pane + /** Used for drawing the background of edit, combo or check boxes. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by IGUISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param bgcolor: Background color. + \param flat: Specifies if the sunken pane should be flat or displayed as sunken + deep into the ground. + \param fillBackGround: Specifies if the background should be filled with the background + color or not be drawn at all. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DSunkenPane(IGUIElement *element, + video::SColor bgcolor, bool flat, bool fillBackGround, + const core::rect &rect, + const core::rect *clip = 0) = 0; + + //! draws a window background + /** Used for drawing the background of dialogs and windows. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by IGUISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param titleBarColor: Title color. + \param drawTitleBar: True to enable title drawing. + \param rect: Defining area where to draw. + \param clip: Clip area. + \param checkClientArea: When set to non-null the function will not draw anything, + but will instead return the clientArea which can be used for drawing by the calling window. + That is the area without borders and without titlebar. + \return Returns rect where it would be good to draw title bar text. This will + work even when checkClientArea is set to a non-null value.*/ + virtual core::rect draw3DWindowBackground(IGUIElement *element, + bool drawTitleBar, video::SColor titleBarColor, + const core::rect &rect, + const core::rect *clip = 0, + core::rect *checkClientArea = 0) = 0; + + //! draws a standard 3d menu pane + /** Used for drawing for menus and context menus. + It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and + EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by IGUISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DMenuPane(IGUIElement *element, + const core::rect &rect, + const core::rect *clip = 0) = 0; + + //! draws a standard 3d tool bar + /** Used for drawing for toolbars and menus. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by IGUISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DToolBar(IGUIElement *element, + const core::rect &rect, + const core::rect *clip = 0) = 0; + + //! draws a tab button + /** Used for drawing for tab buttons on top of tabs. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by IGUISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param active: Specifies if the tab is currently active. + \param rect: Defining area where to draw. + \param clip: Clip area. + \param alignment Alignment of GUI element. */ + virtual void draw3DTabButton(IGUIElement *element, bool active, + const core::rect &rect, const core::rect *clip = 0, gui::EGUI_ALIGNMENT alignment = EGUIA_UPPERLEFT) = 0; + + //! draws a tab control body + /** \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by IGUISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param border: Specifies if the border should be drawn. + \param background: Specifies if the background should be drawn. + \param rect: Defining area where to draw. + \param clip: Clip area. + \param tabHeight Height of tab. + \param alignment Alignment of GUI element. */ + virtual void draw3DTabBody(IGUIElement *element, bool border, bool background, + const core::rect &rect, const core::rect *clip = 0, s32 tabHeight = -1, gui::EGUI_ALIGNMENT alignment = EGUIA_UPPERLEFT) = 0; + + //! draws an icon, usually from the skin's sprite bank + /** \param element: Pointer to the element which wishes to draw this icon. + This parameter is usually not used by IGUISkin, but can be used for example + by more complex implementations to find out how to draw the part exactly. + \param icon: Specifies the icon to be drawn. + \param position: The position to draw the icon + \param starttime: The time at the start of the animation + \param currenttime: The present time, used to calculate the frame number + \param loop: Whether the animation should loop or not + \param clip: Clip area. */ + virtual void drawIcon(IGUIElement *element, EGUI_DEFAULT_ICON icon, + const core::position2di position, u32 starttime = 0, u32 currenttime = 0, + bool loop = false, const core::rect *clip = 0) = 0; + + //! draws a 2d rectangle. + /** \param element: Pointer to the element which wishes to draw this icon. + This parameter is usually not used by IGUISkin, but can be used for example + by more complex implementations to find out how to draw the part exactly. + \param color: Color of the rectangle to draw. The alpha component specifies how + transparent the rectangle will be. + \param pos: Position of the rectangle. + \param clip: Pointer to rectangle against which the rectangle will be clipped. + If the pointer is null, no clipping will be performed. */ + virtual void draw2DRectangle(IGUIElement *element, const video::SColor &color, + const core::rect &pos, const core::rect *clip = 0) = 0; + + //! get the type of this skin + virtual EGUI_SKIN_TYPE getType() const { return EGST_UNKNOWN; } +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/include/IGUISpriteBank.h b/irr/include/IGUISpriteBank.h new file mode 100644 index 000000000..70d8fd1b9 --- /dev/null +++ b/irr/include/IGUISpriteBank.h @@ -0,0 +1,138 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "irrArray.h" +#include "SColor.h" +#include "rect.h" + +namespace irr +{ + +namespace video +{ +class ITexture; +} // end namespace video + +namespace gui +{ + +//! A single sprite frame. +// Note for implementer: Can't fix variable names to uppercase as this is a public interface used since a while +struct SGUISpriteFrame +{ + SGUISpriteFrame() : + textureNumber(0), rectNumber(0) + { + } + + SGUISpriteFrame(u32 textureIndex, u32 positionIndex) : + textureNumber(textureIndex), rectNumber(positionIndex) + { + } + + //! Texture index in IGUISpriteBank + u32 textureNumber; + + //! Index in IGUISpriteBank::getPositions() + u32 rectNumber; +}; + +//! A sprite composed of several frames. +// Note for implementer: Can't fix variable names to uppercase as this is a public interface used since a while +struct SGUISprite +{ + SGUISprite() : + frameTime(0) {} + SGUISprite(const SGUISpriteFrame &firstFrame) : + frameTime(0) + { + Frames.push_back(firstFrame); + } + + core::array Frames; + u32 frameTime; +}; + +//! Sprite bank interface. +/** See http://http://irrlicht.sourceforge.net/forum//viewtopic.php?f=9&t=25742 + * for more information how to use the spritebank. + */ +class IGUISpriteBank : public virtual IReferenceCounted +{ +public: + //! Returns the list of rectangles held by the sprite bank + virtual core::array> &getPositions() = 0; + + //! Returns the array of animated sprites within the sprite bank + virtual core::array &getSprites() = 0; + + //! Returns the number of textures held by the sprite bank + virtual u32 getTextureCount() const = 0; + + //! Gets the texture with the specified index + virtual video::ITexture *getTexture(u32 index) const = 0; + + //! Adds a texture to the sprite bank + virtual void addTexture(video::ITexture *texture) = 0; + + //! Changes one of the textures in the sprite bank + virtual void setTexture(u32 index, video::ITexture *texture) = 0; + + //! Add the texture and use it for a single non-animated sprite. + /** The texture and the corresponding rectangle and sprite will all be added to the end of each array. + \returns The index of the sprite or -1 on failure */ + virtual s32 addTextureAsSprite(video::ITexture *texture) = 0; + + //! Clears sprites, rectangles and textures + virtual void clear() = 0; + + //! Draws a sprite in 2d with position and color + /** + \param index Index of SGUISprite to draw + \param pos Target position - depending on center value either the left-top or the sprite center is used as pivot + \param clip Clipping rectangle, can be 0 when clipping is not wanted. + \param color Color with which the image is drawn. + Note that the alpha component is used. If alpha is other than + 255, the image will be transparent. + \param starttime Tick when the first frame was drawn (only difference currenttime-starttime matters). + \param currenttime To calculate the frame of animated sprites + \param loop When true animations are looped + \param center When true pivot is set to the sprite-center. So it affects pos. + */ + virtual void draw2DSprite(u32 index, const core::position2di &pos, + const core::rect *clip = 0, + const video::SColor &color = video::SColor(255, 255, 255, 255), + u32 starttime = 0, u32 currenttime = 0, + bool loop = true, bool center = false) = 0; + + //! Draws a sprite in 2d with destination rectangle and colors + /** + \param index Index of SGUISprite to draw + \param destRect The sprite will be scaled to fit this target rectangle + \param clip Clipping rectangle, can be 0 when clipping is not wanted. + \param colors Array of 4 colors denoting the color values of + the corners of the destRect + \param timeTicks Current frame for animated sprites + (same as currenttime-starttime in other draw2DSprite function) + \param loop When true animations are looped + */ + virtual void draw2DSprite(u32 index, const core::rect &destRect, + const core::rect *clip = 0, + const video::SColor *const colors = 0, + u32 timeTicks = 0, + bool loop = true) = 0; + + //! Draws a sprite batch in 2d using an array of positions and a color + virtual void draw2DSpriteBatch(const core::array &indices, const core::array &pos, + const core::rect *clip = 0, + const video::SColor &color = video::SColor(255, 255, 255, 255), + u32 starttime = 0, u32 currenttime = 0, + bool loop = true, bool center = false) = 0; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/include/IGUIStaticText.h b/irr/include/IGUIStaticText.h new file mode 100644 index 000000000..02af9b573 --- /dev/null +++ b/irr/include/IGUIStaticText.h @@ -0,0 +1,133 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIElement.h" +#include "SColor.h" + +namespace irr +{ +namespace gui +{ +class IGUIFont; + +//! Multi or single line text label. +class IGUIStaticText : public IGUIElement +{ +public: + //! constructor + IGUIStaticText(IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect rectangle) : + IGUIElement(EGUIET_STATIC_TEXT, environment, parent, id, rectangle) {} + + //! Sets another skin independent font. + /** If this is set to zero, the button uses the font of the skin. + \param font: New font to set. */ + virtual void setOverrideFont(IGUIFont *font = 0) = 0; + + //! Gets the override font (if any) + /** \return The override font (may be 0) */ + virtual IGUIFont *getOverrideFont(void) const = 0; + + //! Get the font which is used right now for drawing + /** Currently this is the override font when one is set and the + font of the active skin otherwise */ + virtual IGUIFont *getActiveFont() const = 0; + + //! Sets another color for the text. + /** If set, the static text does not use the EGDC_BUTTON_TEXT color defined + in the skin, but the set color instead. You don't need to call + IGUIStaticText::enableOverrrideColor(true) after this, this is done + by this function. + If you set a color, and you want the text displayed with the color + of the skin again, call IGUIStaticText::enableOverrideColor(false); + \param color: New color of the text. */ + virtual void setOverrideColor(video::SColor color) = 0; + + //! Gets the override color + /** \return: The override color */ + virtual video::SColor getOverrideColor(void) const = 0; + + //! Gets the currently used text color + /** Either a skin-color for the current state or the override color */ + virtual video::SColor getActiveColor() const = 0; + + //! Sets if the static text should use the override color or the color in the gui skin. + /** \param enable: If set to true, the override color, which can be set + with IGUIStaticText::setOverrideColor is used, otherwise the + EGDC_BUTTON_TEXT color of the skin. */ + virtual void enableOverrideColor(bool enable) = 0; + + //! Checks if an override color is enabled + /** \return true if the override color is enabled, false otherwise */ + virtual bool isOverrideColorEnabled(void) const = 0; + + //! Sets another color for the background. + virtual void setBackgroundColor(video::SColor color) = 0; + + //! Sets whether to draw the background + virtual void setDrawBackground(bool draw) = 0; + + //! Checks if background drawing is enabled + /** \return true if background drawing is enabled, false otherwise */ + virtual bool isDrawBackgroundEnabled() const = 0; + + //! Gets the background color + /** \return: The background color */ + virtual video::SColor getBackgroundColor() const = 0; + + //! Sets whether to draw the border + virtual void setDrawBorder(bool draw) = 0; + + //! Checks if border drawing is enabled + /** \return true if border drawing is enabled, false otherwise */ + virtual bool isDrawBorderEnabled() const = 0; + + //! Sets text justification mode + /** \param horizontal: EGUIA_UPPERLEFT for left justified (default), + EGUIA_LOWERRIGHT for right justified, or EGUIA_CENTER for centered text. + \param vertical: EGUIA_UPPERLEFT to align with top edge (default), + EGUIA_LOWERRIGHT for bottom edge, or EGUIA_CENTER for centered text. */ + virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) = 0; + + //! Enables or disables word wrap for using the static text as multiline text control. + /** \param enable: If set to true, words going over one line are + broken on to the next line. */ + virtual void setWordWrap(bool enable) = 0; + + //! Checks if word wrap is enabled + /** \return true if word wrap is enabled, false otherwise */ + virtual bool isWordWrapEnabled(void) const = 0; + + //! Returns the height of the text in pixels when it is drawn. + /** This is useful for adjusting the layout of gui elements based on the height + of the multiline text in this element. + \return Height of text in pixels. */ + virtual s32 getTextHeight() const = 0; + + //! Returns the width of the current text, in the current font + /** If the text is broken, this returns the width of the widest line + \return The width of the text, or the widest broken line. */ + virtual s32 getTextWidth(void) const = 0; + + //! Set whether the text in this label should be clipped if it goes outside bounds + virtual void setTextRestrainedInside(bool restrainedInside) = 0; + + //! Checks if the text in this label should be clipped if it goes outside bounds + virtual bool isTextRestrainedInside() const = 0; + + //! Set whether the string should be interpreted as right-to-left (RTL) text + /** \note This component does not implement the Unicode bidi standard, the + text of the component should be already RTL if you call this. The + main difference when RTL is enabled is that the linebreaks for multiline + elements are performed starting from the end. + */ + virtual void setRightToLeft(bool rtl) = 0; + + //! Checks whether the text in this element should be interpreted as right-to-left + virtual bool isRightToLeft() const = 0; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/include/IGUITabControl.h b/irr/include/IGUITabControl.h new file mode 100644 index 000000000..f1d2183ae --- /dev/null +++ b/irr/include/IGUITabControl.h @@ -0,0 +1,149 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIElement.h" +#include "SColor.h" +#include "IGUISkin.h" + +namespace irr +{ +namespace gui +{ +class IGUITab; + +//! A standard tab control +/** \par This element can create the following events of type EGUI_EVENT_TYPE: +\li EGET_TAB_CHANGED +*/ +class IGUITabControl : public IGUIElement +{ +public: + //! constructor + IGUITabControl(IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect rectangle) : + IGUIElement(EGUIET_TAB_CONTROL, environment, parent, id, rectangle) {} + + //! Adds a tab + virtual IGUITab *addTab(const wchar_t *caption, s32 id = -1) = 0; + + //! Adds an existing tab + /** Note that it will also add the tab as a child of this TabControl. + \return Index of added tab or -1 for failure*/ + virtual s32 addTab(IGUITab *tab) = 0; + + //! Insert the tab at the given index + /** \return The tab on success or NULL on failure. */ + virtual IGUITab *insertTab(s32 idx, const wchar_t *caption, s32 id = -1) = 0; + + //! Insert an existing tab + /** Note that it will also add the tab as a child of this TabControl. + \param idx Index at which tab will be inserted. Later tabs will be moved. + Previous active tab will stay active unless this is the first + element to be inserted in which case it becomes active. + \param tab New tab to insert. + \param serializationMode Internally used for serialization. You should not need this. + When true it reserves space for the index, doesn't move but replaces tabs + and it doesn't change the active tab. + \return Index of added tab (should be same as the one passed) or -1 for failure*/ + virtual s32 insertTab(s32 idx, IGUITab *tab, bool serializationMode = false) = 0; + + //! Removes a tab from the tabcontrol + virtual void removeTab(s32 idx) = 0; + + //! Clears the tabcontrol removing all tabs + virtual void clear() = 0; + + //! Returns amount of tabs in the tabcontrol + virtual s32 getTabCount() const = 0; + + //! Returns a tab based on zero based index + /** \param idx: zero based index of tab. Is a value between 0 and getTabcount()-1; + \return Returns pointer to the Tab. Returns 0 if no tab + is corresponding to this tab. */ + virtual IGUITab *getTab(s32 idx) const = 0; + + //! For given element find if it's a tab and return it's zero-based index (or -1 for not found) + /** \param tab Tab for which we are looking (usually you will look for an IGUITab* type as only + those can be tabs, but we allow looking for any kind of IGUIElement* as there are some + use-cases for that even if it just returns 0. For example this way you can check for + all children of this gui-element if they are tabs or some non-tab children.*/ + virtual s32 getTabIndex(const IGUIElement *tab) const = 0; + + //! Brings a tab to front. + /** \param idx: number of the tab. + \return Returns true if successful. */ + virtual bool setActiveTab(s32 idx) = 0; + + //! Brings a tab to front. + /** \param tab: pointer to the tab. + \return Returns true if successful. */ + virtual bool setActiveTab(IGUITab *tab) = 0; + + //! Returns which tab is currently active + virtual s32 getActiveTab() const = 0; + + //! get the the id of the tab at the given absolute coordinates + /** \return The id of the tab or -1 when no tab is at those coordinates*/ + virtual s32 getTabAt(s32 xpos, s32 ypos) const = 0; + + //! Set the height of the tabs + virtual void setTabHeight(s32 height) = 0; + + //! Get the height of the tabs + /** return Returns the height of the tabs */ + virtual s32 getTabHeight() const = 0; + + //! set the maximal width of a tab. Per default width is 0 which means "no width restriction". + virtual void setTabMaxWidth(s32 width) = 0; + + //! get the maximal width of a tab + virtual s32 getTabMaxWidth() const = 0; + + //! Set the alignment of the tabs + /** Use EGUIA_UPPERLEFT or EGUIA_LOWERRIGHT */ + virtual void setTabVerticalAlignment(gui::EGUI_ALIGNMENT alignment) = 0; + + //! Get the alignment of the tabs + /** return Returns the alignment of the tabs */ + virtual gui::EGUI_ALIGNMENT getTabVerticalAlignment() const = 0; + + //! Set the extra width added to tabs on each side of the text + virtual void setTabExtraWidth(s32 extraWidth) = 0; + + //! Get the extra width added to tabs on each side of the text + /** return Returns the extra width of the tabs */ + virtual s32 getTabExtraWidth() const = 0; +}; + +//! A tab-page, onto which other gui elements could be added. +/** IGUITab refers mostly to the page itself, but also carries some data about the tab in the tabbar of an IGUITabControl. */ +class IGUITab : public IGUIElement +{ +public: + //! constructor + IGUITab(IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect rectangle) : + IGUIElement(EGUIET_TAB, environment, parent, id, rectangle) {} + + //! sets if the tab should draw its background + virtual void setDrawBackground(bool draw = true) = 0; + + //! sets the color of the background, if it should be drawn. + virtual void setBackgroundColor(video::SColor c) = 0; + + //! returns true if the tab is drawing its background, false if not + virtual bool isDrawingBackground() const = 0; + + //! returns the color of the background + virtual video::SColor getBackgroundColor() const = 0; + + //! sets the color of it's text in the tab-bar + virtual void setTextColor(video::SColor c) = 0; + + //! gets the color of the text + virtual video::SColor getTextColor() const = 0; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/include/IGUIToolbar.h b/irr/include/IGUIToolbar.h new file mode 100644 index 000000000..2011f09a1 --- /dev/null +++ b/irr/include/IGUIToolbar.h @@ -0,0 +1,34 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIElement.h" + +namespace irr +{ +namespace video +{ +class ITexture; +} // end namespace video +namespace gui +{ +class IGUIButton; + +//! Stays at the top of its parent like the menu bar and contains tool buttons +class IGUIToolBar : public IGUIElement +{ +public: + //! constructor + IGUIToolBar(IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect rectangle) : + IGUIElement(EGUIET_TOOL_BAR, environment, parent, id, rectangle) {} + + //! Adds a button to the tool bar + virtual IGUIButton *addButton(s32 id = -1, const wchar_t *text = 0, const wchar_t *tooltiptext = 0, + video::ITexture *img = 0, video::ITexture *pressedimg = 0, + bool isPushButton = false, bool useAlphaChannel = false) = 0; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/include/IImage.h b/irr/include/IImage.h new file mode 100644 index 000000000..f3c29b71d --- /dev/null +++ b/irr/include/IImage.h @@ -0,0 +1,424 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "position2d.h" +#include "rect.h" +#include "SColor.h" +#include + +namespace irr +{ +namespace video +{ + +//! Interface for software image data. +/** Image loaders create these images from files. IVideoDrivers convert +these images into their (hardware) textures. +NOTE: Floating point formats are not well supported yet. Basically only getData() works for them. +*/ +class IImage : public virtual IReferenceCounted +{ +public: + //! constructor + IImage(ECOLOR_FORMAT format, const core::dimension2d &size, bool deleteMemory) : + Format(format), Size(size), Data(0), MipMapsData(0), BytesPerPixel(0), Pitch(0), DeleteMemory(deleteMemory), DeleteMipMapsMemory(false) + { + BytesPerPixel = getBitsPerPixelFromFormat(Format) / 8; + Pitch = BytesPerPixel * Size.Width; + } + + //! destructor + virtual ~IImage() + { + if (DeleteMemory) + delete[] Data; + + if (DeleteMipMapsMemory) + delete[] MipMapsData; + } + + //! Returns the color format + ECOLOR_FORMAT getColorFormat() const + { + return Format; + } + + //! Returns width and height of image data. + const core::dimension2d &getDimension() const + { + return Size; + } + + //! Returns bits per pixel. + u32 getBitsPerPixel() const + { + + return getBitsPerPixelFromFormat(Format); + } + + //! Returns bytes per pixel + u32 getBytesPerPixel() const + { + return BytesPerPixel; + } + + //! Returns image data size in bytes + u32 getImageDataSizeInBytes() const + { + return getDataSizeFromFormat(Format, Size.Width, Size.Height); + } + + //! Returns image data size in pixels + u32 getImageDataSizeInPixels() const + { + return Size.Width * Size.Height; + } + + //! Returns pitch of image + u32 getPitch() const + { + return Pitch; + } + + //! Returns mask for red value of a pixel + u32 getRedMask() const + { + switch (Format) { + case ECF_A1R5G5B5: + return 0x1F << 10; + case ECF_R5G6B5: + return 0x1F << 11; + case ECF_R8G8B8: + return 0x00FF0000; + case ECF_A8R8G8B8: + return 0x00FF0000; + default: + return 0x0; + } + } + + //! Returns mask for green value of a pixel + u32 getGreenMask() const + { + switch (Format) { + case ECF_A1R5G5B5: + return 0x1F << 5; + case ECF_R5G6B5: + return 0x3F << 5; + case ECF_R8G8B8: + return 0x0000FF00; + case ECF_A8R8G8B8: + return 0x0000FF00; + default: + return 0x0; + } + } + + //! Returns mask for blue value of a pixel + u32 getBlueMask() const + { + switch (Format) { + case ECF_A1R5G5B5: + return 0x1F; + case ECF_R5G6B5: + return 0x1F; + case ECF_R8G8B8: + return 0x000000FF; + case ECF_A8R8G8B8: + return 0x000000FF; + default: + return 0x0; + } + } + + //! Returns mask for alpha value of a pixel + u32 getAlphaMask() const + { + switch (Format) { + case ECF_A1R5G5B5: + return 0x1 << 15; + case ECF_R5G6B5: + return 0x0; + case ECF_R8G8B8: + return 0x0; + case ECF_A8R8G8B8: + return 0xFF000000; + default: + return 0x0; + } + } + + //! Use this to get a pointer to the image data. + /** + \return Pointer to the image data. What type of data is pointed to + depends on the color format of the image. For example if the color + format is ECF_A8R8G8B8, it is of u32. */ + void *getData() const + { + return Data; + } + + //! Get the mipmap size for this image for a certain mipmap level + /** level 0 will be full image size. Every further level is half the size. + Doesn't care if the image actually has mipmaps, just which size would be needed. */ + core::dimension2du getMipMapsSize(u32 mipmapLevel) const + { + return getMipMapsSize(Size, mipmapLevel); + } + + //! Calculate mipmap size for a certain level + /** level 0 will be full image size. Every further level is half the size. */ + static core::dimension2du getMipMapsSize(const core::dimension2du &sizeLevel0, u32 mipmapLevel) + { + core::dimension2du result(sizeLevel0); + u32 i = 0; + while (i != mipmapLevel) { + if (result.Width > 1) + result.Width >>= 1; + if (result.Height > 1) + result.Height >>= 1; + ++i; + + if (result.Width == 1 && result.Height == 1 && i < mipmapLevel) + return core::dimension2du(0, 0); + } + return result; + } + + //! Get mipmaps data. + /** Note that different mip levels are just behind each other in memory block. + So if you just get level 1 you also have the data for all other levels. + There is no level 0 - use getData to get the original image data. + */ + void *getMipMapsData(irr::u32 mipLevel = 1) const + { + if (MipMapsData && mipLevel > 0) { + size_t dataSize = 0; + core::dimension2du mipSize(Size); + u32 i = 1; // We want the start of data for this level, not end. + + while (i != mipLevel) { + if (mipSize.Width > 1) + mipSize.Width >>= 1; + + if (mipSize.Height > 1) + mipSize.Height >>= 1; + + dataSize += getDataSizeFromFormat(Format, mipSize.Width, mipSize.Height); + + ++i; + if (mipSize.Width == 1 && mipSize.Height == 1 && i < mipLevel) + return 0; + } + + return MipMapsData + dataSize; + } + + return 0; + } + + //! Set mipmaps data. + /** This method allows you to put custom mipmaps data for + image. + \param data A byte array with pixel color information + \param ownForeignMemory If true, the image will use the data + pointer directly and own it afterward. If false, the memory + will by copied internally. + \param deleteMemory Whether the memory is deallocated upon + destruction. */ + void setMipMapsData(void *data, bool ownForeignMemory) + { + if (data != MipMapsData) { + if (DeleteMipMapsMemory) { + delete[] MipMapsData; + + DeleteMipMapsMemory = false; + } + + if (data) { + if (ownForeignMemory) { + MipMapsData = static_cast(data); + + DeleteMipMapsMemory = false; + } else { + u32 dataSize = 0; + u32 width = Size.Width; + u32 height = Size.Height; + + do { + if (width > 1) + width >>= 1; + + if (height > 1) + height >>= 1; + + dataSize += getDataSizeFromFormat(Format, width, height); + } while (width != 1 || height != 1); + + MipMapsData = new u8[dataSize]; + memcpy(MipMapsData, data, dataSize); + + DeleteMipMapsMemory = true; + } + } else { + MipMapsData = 0; + } + } + } + + //! Returns a pixel + virtual SColor getPixel(u32 x, u32 y) const = 0; + + //! Sets a pixel + virtual void setPixel(u32 x, u32 y, const SColor &color, bool blend = false) = 0; + + //! Copies this surface into another, if it has the exact same size and format. + /** NOTE: mipmaps are ignored + \return True if it was copied, false otherwise. + */ + virtual bool copyToNoScaling(void *target, u32 width, u32 height, ECOLOR_FORMAT format = ECF_A8R8G8B8, u32 pitch = 0) const = 0; + + //! Copies the image into the target, scaling the image to fit + /** NOTE: mipmaps are ignored */ + virtual void copyToScaling(void *target, u32 width, u32 height, ECOLOR_FORMAT format = ECF_A8R8G8B8, u32 pitch = 0) = 0; + + //! Copies the image into the target, scaling the image to fit + /** NOTE: mipmaps are ignored */ + virtual void copyToScaling(IImage *target) = 0; + + //! copies this surface into another + /** NOTE: mipmaps are ignored */ + virtual void copyTo(IImage *target, const core::position2d &pos = core::position2d(0, 0)) = 0; + + //! copies this surface into another + /** NOTE: mipmaps are ignored */ + virtual void copyTo(IImage *target, const core::position2d &pos, const core::rect &sourceRect, const core::rect *clipRect = 0) = 0; + + //! copies this surface into another, using the alpha mask and cliprect and a color to add with + /** NOTE: mipmaps are ignored + \param combineAlpha - When true then combine alpha channels. When false replace target image alpha with source image alpha. + */ + virtual void copyToWithAlpha(IImage *target, const core::position2d &pos, + const core::rect &sourceRect, const SColor &color, + const core::rect *clipRect = 0, + bool combineAlpha = false) = 0; + + //! copies this surface into another, scaling it to fit, applying a box filter + /** NOTE: mipmaps are ignored */ + virtual void copyToScalingBoxFilter(IImage *target, s32 bias = 0, bool blend = false) = 0; + + //! fills the surface with given color + virtual void fill(const SColor &color) = 0; + + //! get the amount of Bits per Pixel of the given color format + static u32 getBitsPerPixelFromFormat(const ECOLOR_FORMAT format) + { + switch (format) { + case ECF_A1R5G5B5: + return 16; + case ECF_R5G6B5: + return 16; + case ECF_R8G8B8: + return 24; + case ECF_A8R8G8B8: + return 32; + case ECF_D16: + return 16; + case ECF_D32: + return 32; + case ECF_D24S8: + return 32; + case ECF_R8: + return 8; + case ECF_R8G8: + return 16; + case ECF_R16: + return 16; + case ECF_R16G16: + return 32; + case ECF_R16F: + return 16; + case ECF_G16R16F: + return 32; + case ECF_A16B16G16R16F: + return 64; + case ECF_R32F: + return 32; + case ECF_G32R32F: + return 64; + case ECF_A32B32G32R32F: + return 128; + default: + return 0; + } + } + + //! calculate image data size in bytes for selected format, width and height. + static u32 getDataSizeFromFormat(ECOLOR_FORMAT format, u32 width, u32 height) + { + // non-compressed formats + u32 imageSize = getBitsPerPixelFromFormat(format) / 8 * width; + imageSize *= height; + + return imageSize; + } + + //! check if this is compressed color format + static bool isCompressedFormat(const ECOLOR_FORMAT format) + { + return false; + } + + //! check if the color format is only viable for depth/stencil textures + static bool isDepthFormat(const ECOLOR_FORMAT format) + { + switch (format) { + case ECF_D16: + case ECF_D32: + case ECF_D24S8: + return true; + default: + return false; + } + } + + //! Check if the color format uses floating point values for pixels + static bool isFloatingPointFormat(const ECOLOR_FORMAT format) + { + if (isCompressedFormat(format)) + return false; + + switch (format) { + case ECF_R16F: + case ECF_G16R16F: + case ECF_A16B16G16R16F: + case ECF_R32F: + case ECF_G32R32F: + case ECF_A32B32G32R32F: + return true; + default: + break; + } + return false; + } + +protected: + ECOLOR_FORMAT Format; + core::dimension2d Size; + + u8 *Data; + u8 *MipMapsData; + + u32 BytesPerPixel; + u32 Pitch; + + bool DeleteMemory; + bool DeleteMipMapsMemory; +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/include/IImageLoader.h b/irr/include/IImageLoader.h new file mode 100644 index 000000000..a521be15f --- /dev/null +++ b/irr/include/IImageLoader.h @@ -0,0 +1,49 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "IImage.h" +#include "ITexture.h" +#include "path.h" +#include "irrArray.h" + +namespace irr +{ +namespace io +{ +class IReadFile; +} // end namespace io +namespace video +{ + +//! Class which is able to create a image from a file. +/** If you want the Irrlicht Engine be able to load textures of +currently unsupported file formats (e.g .gif), then implement +this and add your new Surface loader with +IVideoDriver::addExternalImageLoader() to the engine. */ +class IImageLoader : public virtual IReferenceCounted +{ +public: + //! Check if the file might be loaded by this class + /** Check is based on the file extension (e.g. ".tga") + \param filename Name of file to check. + \return True if file seems to be loadable. */ + virtual bool isALoadableFileExtension(const io::path &filename) const = 0; + + //! Check if the file might be loaded by this class + /** Check might look into the file. + \param file File handle to check. + \return True if file seems to be loadable. */ + virtual bool isALoadableFileFormat(io::IReadFile *file) const = 0; + + //! Creates a surface from the file + /** \param file File handle to check. + \return Pointer to newly created image, or 0 upon error. */ + virtual IImage *loadImage(io::IReadFile *file) const = 0; +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/include/IImageWriter.h b/irr/include/IImageWriter.h new file mode 100644 index 000000000..b8defc75f --- /dev/null +++ b/irr/include/IImageWriter.h @@ -0,0 +1,40 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "irrString.h" +#include "coreutil.h" + +namespace irr +{ +namespace io +{ +class IWriteFile; +} // end namespace io + +namespace video +{ +class IImage; + +//! Interface for writing software image data. +class IImageWriter : public IReferenceCounted +{ +public: + //! Check if this writer can write a file with the given extension + /** \param filename Name of the file to check. + \return True if file extension specifies a writable type. */ + virtual bool isAWriteableFileExtension(const io::path &filename) const = 0; + + //! Write image to file + /** \param file File handle to write to. + \param image Image to write into file. + \param param Writer specific parameter, influencing e.g. quality. + \return True if image was successfully written. */ + virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param = 0) const = 0; +}; + +} // namespace video +} // namespace irr diff --git a/irr/include/IIndexBuffer.h b/irr/include/IIndexBuffer.h new file mode 100644 index 000000000..3d5b8e76a --- /dev/null +++ b/irr/include/IIndexBuffer.h @@ -0,0 +1,59 @@ +// Copyright (C) 2008-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "irrArray.h" +#include "EHardwareBufferFlags.h" +#include "SVertexIndex.h" + +namespace irr +{ + +namespace video +{ + +} + +namespace scene +{ + +class IIndexBuffer : public virtual IReferenceCounted +{ +public: + virtual void *getData() = 0; + + virtual video::E_INDEX_TYPE getType() const = 0; + virtual void setType(video::E_INDEX_TYPE IndexType) = 0; + + virtual u32 stride() const = 0; + + virtual u32 size() const = 0; + virtual void push_back(const u32 &element) = 0; + virtual u32 operator[](u32 index) const = 0; + virtual u32 getLast() = 0; + virtual void setValue(u32 index, u32 value) = 0; + virtual void set_used(u32 usedNow) = 0; + virtual void reallocate(u32 new_size) = 0; + virtual u32 allocated_size() const = 0; + + virtual void *pointer() = 0; + + //! get the current hardware mapping hint + virtual E_HARDWARE_MAPPING getHardwareMappingHint() const = 0; + + //! set the hardware mapping hint, for driver + virtual void setHardwareMappingHint(E_HARDWARE_MAPPING NewMappingHint) = 0; + + //! flags the meshbuffer as changed, reloads hardware buffers + virtual void setDirty() = 0; + + //! Get the currently used ID for identification of changes. + /** This shouldn't be used for anything outside the VideoDriver. */ + virtual u32 getChangedID() const = 0; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/ILogger.h b/irr/include/ILogger.h new file mode 100644 index 000000000..2642f3398 --- /dev/null +++ b/irr/include/ILogger.h @@ -0,0 +1,75 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" + +namespace irr +{ + +//! Possible log levels. +//! When used has filter ELL_DEBUG means => log everything and ELL_NONE means => log (nearly) nothing. +//! When used to print logging information ELL_DEBUG will have lowest priority while ELL_NONE +//! messages are never filtered and always printed. +enum ELOG_LEVEL +{ + //! Used for printing information helpful in debugging + ELL_DEBUG, + + //! Useful information to print. For example hardware info or something started/stopped. + ELL_INFORMATION, + + //! Warnings that something isn't as expected and can cause oddities + ELL_WARNING, + + //! Something did go wrong. + ELL_ERROR, + + //! Logs with ELL_NONE will never be filtered. + //! And used as filter it will remove all logging except ELL_NONE messages. + ELL_NONE +}; + +//! Interface for logging messages, warnings and errors +class ILogger : public virtual IReferenceCounted +{ +public: + //! Destructor + virtual ~ILogger() {} + + //! Returns the current set log level. + virtual ELOG_LEVEL getLogLevel() const = 0; + + //! Sets a new log level. + /** With this value, texts which are sent to the logger are filtered + out. For example setting this value to ELL_WARNING, only warnings and + errors are printed out. Setting it to ELL_INFORMATION, which is the + default setting, warnings, errors and informational texts are printed + out. + \param ll: new log level filter value. */ + virtual void setLogLevel(ELOG_LEVEL ll) = 0; + + //! Prints out a text into the log + /** \param text: Text to print out. + \param ll: Log level of the text. If the text is an error, set + it to ELL_ERROR, if it is warning set it to ELL_WARNING, and if it + is just an informational text, set it to ELL_INFORMATION. Texts are + filtered with these levels. If you want to be a text displayed, + independent on what level filter is set, use ELL_NONE. */ + virtual void log(const c8 *text, ELOG_LEVEL ll = ELL_INFORMATION) = 0; + + //! Prints out a text into the log + /** \param text: Text to print out. + \param hint: Additional info. This string is added after a " :" to the + string. + \param ll: Log level of the text. If the text is an error, set + it to ELL_ERROR, if it is warning set it to ELL_WARNING, and if it + is just an informational text, set it to ELL_INFORMATION. Texts are + filtered with these levels. If you want to be a text displayed, + independent on what level filter is set, use ELL_NONE. */ + virtual void log(const c8 *text, const c8 *hint, ELOG_LEVEL ll = ELL_INFORMATION) = 0; +}; + +} // end namespace diff --git a/irr/include/IMaterialRenderer.h b/irr/include/IMaterialRenderer.h new file mode 100644 index 000000000..ba9c4b74f --- /dev/null +++ b/irr/include/IMaterialRenderer.h @@ -0,0 +1,101 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "SMaterial.h" +#include "S3DVertex.h" + +namespace irr +{ +namespace video +{ + +class IVideoDriver; +class IMaterialRendererServices; +class IShaderConstantSetCallBack; + +//! Interface for material rendering. +/** Can be used to extend the engine with new materials. Refer to +IVideoDriver::addMaterialRenderer() for more information on how to extend the +engine with new materials. */ +class IMaterialRenderer : public virtual IReferenceCounted +{ +public: + //! Called by the IVideoDriver implementation the let the renderer set its needed render states. + /** This is called during the IVideoDriver::setMaterial() call. + When overriding this, you can set some renderstates or for example a + vertex or pixel shader if you like. + \param material: The new material parameters to be set. The renderer + may change the material flags in this material. For example if this + material does not accept the zbuffer = true, it can set it to false. + This is useful, because in the next lastMaterial will be just the + material in this call. + \param lastMaterial: The material parameters which have been set before + this material. + \param resetAllRenderstates: True if all renderstates should really be + reset. This is usually true if the last rendering mode was not a usual + 3d rendering mode, but for example a 2d rendering mode. + You should reset really all renderstates if this is true, no matter if + the lastMaterial had some similar settings. This is used because in + most cases, some common renderstates are not changed if they are + already there, for example bilinear filtering, wireframe, + gouraudshading, lighting, zbuffer, zwriteenable, backfaceculling and + fogenable. + \param services: Interface providing some methods for changing + advanced, internal states of a IVideoDriver. */ + virtual void OnSetMaterial(const SMaterial &material, const SMaterial &lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices *services) {} + + //! Called every time before a new bunch of geometry is being drawn using this material with for example drawIndexedTriangleList() call. + /** OnSetMaterial should normally only be called if the renderer decides + that the renderstates should be changed, it won't be called if for + example two drawIndexedTriangleList() will be called with the same + material set. This method will be called every time. This is useful for + example for materials with shaders, which don't only set new + renderstates but also shader constants. + \param service: Pointer to interface providing methods for setting + constants and other things. + \param vtxtype: Vertex type with which the next rendering will be done. + This can be used by the material renderer to set some specific + optimized shaders or if this is an incompatible vertex type for this + renderer, to refuse rendering for example. + \return Returns true if everything is OK, and false if nothing should + be rendered. The material renderer can choose to return false for + example if he doesn't support the specified vertex type. This is + actually done in D3D9 when using a normal mapped material with + a vertex type other than EVT_TANGENTS. */ + virtual bool OnRender(IMaterialRendererServices *service, E_VERTEX_TYPE vtxtype) { return true; } + + //! Called by the IVideoDriver to unset this material. + /** Called during the IVideoDriver::setMaterial() call before the new + material will get the OnSetMaterial() call. */ + virtual void OnUnsetMaterial() {} + + //! Returns if the material is transparent. + /** The scene management needs to know this + for being able to sort the materials by opaque and transparent. */ + virtual bool isTransparent() const { return false; } + + //! Returns the render capability of the material. + /** Because some more complex materials + are implemented in multiple ways and need special hardware capabilities, it is possible + to query how the current material renderer is performing on the current hardware with this + function. + \return Returns 0 if everything is running fine. Any other value is material renderer + specific and means for example that the renderer switched back to a fall back material because + it cannot use the latest shaders. More specific examples: + Fixed function pipeline materials should return 0 in most cases, parallax mapped + material will only return 0 when at least pixel shader 1.4 is available on that machine. */ + virtual s32 getRenderCapability() const { return 0; } + + //! Access the callback provided by the users when creating shader materials + /** \returns Returns either the users provided callback or 0 when no such + callback exists. Non-shader materials will always return 0. */ + virtual IShaderConstantSetCallBack *getShaderConstantSetCallBack() const { return 0; } +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/include/IMaterialRendererServices.h b/irr/include/IMaterialRendererServices.h new file mode 100644 index 000000000..81a195d8c --- /dev/null +++ b/irr/include/IMaterialRendererServices.h @@ -0,0 +1,80 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "SMaterial.h" +#include "S3DVertex.h" + +namespace irr +{ +namespace video +{ + +class IVideoDriver; + +//! Interface providing some methods for changing advanced, internal states of a IVideoDriver. +class IMaterialRendererServices +{ +public: + //! Destructor + virtual ~IMaterialRendererServices() {} + + //! Can be called by an IMaterialRenderer to make its work easier. + /** Sets all basic renderstates if needed. + Basic render states are diffuse, ambient, specular, and emissive color, + specular power, bilinear and trilinear filtering, wireframe mode, + grouraudshading, lighting, zbuffer, zwriteenable, backfaceculling and + fog enabling. + \param material The new material to be used. + \param lastMaterial The material used until now. + \param resetAllRenderstates Set to true if all renderstates should be + set, regardless of their current state. */ + virtual void setBasicRenderStates(const SMaterial &material, + const SMaterial &lastMaterial, + bool resetAllRenderstates) = 0; + + //! Return an index constant for the vertex shader based on a uniform variable name. + virtual s32 getVertexShaderConstantID(const c8 *name) = 0; + + //! Sets a value for a vertex shader uniform variable. + /** \param index Index of the variable (as received from getVertexShaderConstantID) + \param floats Pointer to array of floats + \param count Amount of floats in array. + \return True if successful. + */ + virtual bool setVertexShaderConstant(s32 index, const f32 *floats, int count) = 0; + + //! Int interface for the above. + virtual bool setVertexShaderConstant(s32 index, const s32 *ints, int count) = 0; + + //! Uint interface for the above. + virtual bool setVertexShaderConstant(s32 index, const u32 *ints, int count) = 0; + + //! Return an index constant for the pixel shader for the given uniform variable name + virtual s32 getPixelShaderConstantID(const c8 *name) = 0; + + //! Sets a value for the given pixel shader uniform variable + /** This can be used if you used a high level shader language like GLSL + or HLSL to create a shader. See setVertexShaderConstant() for an + example on how to use this. + \param index Index of the variable (as received from getPixelShaderConstantID) + \param floats Pointer to array of floats + \param count Amount of floats in array. + \return True if successful. */ + virtual bool setPixelShaderConstant(s32 index, const f32 *floats, int count) = 0; + + //! Int interface for the above. + virtual bool setPixelShaderConstant(s32 index, const s32 *ints, int count) = 0; + + //! Uint interface for the above. + virtual bool setPixelShaderConstant(s32 index, const u32 *ints, int count) = 0; + + //! Get pointer to the IVideoDriver interface + /** \return Pointer to the IVideoDriver interface */ + virtual IVideoDriver *getVideoDriver() = 0; +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/include/IMemoryReadFile.h b/irr/include/IMemoryReadFile.h new file mode 100644 index 000000000..982b09af3 --- /dev/null +++ b/irr/include/IMemoryReadFile.h @@ -0,0 +1,27 @@ +// Copyright Michael Zeilfelder +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReadFile.h" + +namespace irr +{ +namespace io +{ + +//! Interface providing read access to a memory read file. +class IMemoryReadFile : public IReadFile +{ +public: + //! Get direct access to internal buffer of memory block used as file. + /** It's usually better to use the IReadFile functions to access + the file content. But as that buffer exist over the full life-time + of a CMemoryReadFile, it's sometimes nice to avoid the additional + data-copy which read() needs. + */ + virtual const void *getBuffer() const = 0; +}; +} // end namespace io +} // end namespace irr diff --git a/irr/include/IMesh.h b/irr/include/IMesh.h new file mode 100644 index 000000000..6d06eb762 --- /dev/null +++ b/irr/include/IMesh.h @@ -0,0 +1,123 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "SMaterial.h" +#include "EHardwareBufferFlags.h" + +namespace irr +{ +namespace scene +{ +//! Possible types of meshes. +// Note: Was previously only used in IAnimatedMesh so it still has the "animated" in the name. +// But can now be used for all mesh-types as we need those casts as well. +enum E_ANIMATED_MESH_TYPE +{ + //! Unknown animated mesh type. + EAMT_UNKNOWN = 0, + + //! Quake 2 MD2 model file + EAMT_MD2, + + //! Quake 3 MD3 model file + EAMT_MD3, + + //! Maya .obj static model + EAMT_OBJ, + + //! Quake 3 .bsp static Map + EAMT_BSP, + + //! 3D Studio .3ds file + EAMT_3DS, + + //! My3D Mesh, the file format by Zhuck Dimitry + EAMT_MY3D, + + //! Pulsar LMTools .lmts file. This Irrlicht loader was written by Jonas Petersen + EAMT_LMTS, + + //! Cartography Shop .csm file. This loader was created by Saurav Mohapatra. + EAMT_CSM, + + //! .oct file for Paul Nette's FSRad or from Murphy McCauley's Blender .oct exporter. + /** The oct file format contains 3D geometry and lightmaps and + can be loaded directly by Irrlicht */ + EAMT_OCT, + + //! Halflife MDL model file + EAMT_MDL_HALFLIFE, + + //! generic skinned mesh + EAMT_SKINNED, + + //! generic non-animated mesh + EAMT_STATIC +}; + +class IMeshBuffer; + +//! Class which holds the geometry of an object. +/** An IMesh is nothing more than a collection of some mesh buffers +(IMeshBuffer). SMesh is a simple implementation of an IMesh. +A mesh is usually added to an IMeshSceneNode in order to be rendered. +*/ +class IMesh : public virtual IReferenceCounted +{ +public: + //! Get the amount of mesh buffers. + /** \return Amount of mesh buffers (IMeshBuffer) in this mesh. */ + virtual u32 getMeshBufferCount() const = 0; + + //! Get pointer to a mesh buffer. + /** \param nr: Zero based index of the mesh buffer. The maximum value is + getMeshBufferCount() - 1; + \return Pointer to the mesh buffer or 0 if there is no such + mesh buffer. */ + virtual IMeshBuffer *getMeshBuffer(u32 nr) const = 0; + + //! Get pointer to a mesh buffer which fits a material + /** \param material: material to search for + \return Pointer to the mesh buffer or 0 if there is no such + mesh buffer. */ + virtual IMeshBuffer *getMeshBuffer(const video::SMaterial &material) const = 0; + + //! Get an axis aligned bounding box of the mesh. + /** \return Bounding box of this mesh. */ + virtual const core::aabbox3d &getBoundingBox() const = 0; + + //! Set user-defined axis aligned bounding box + /** \param box New bounding box to use for the mesh. */ + virtual void setBoundingBox(const core::aabbox3df &box) = 0; + + //! Set the hardware mapping hint + /** This methods allows to define optimization hints for the + hardware. This enables, e.g., the use of hardware buffers on + platforms that support this feature. This can lead to noticeable + performance gains. */ + virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer = EBT_VERTEX_AND_INDEX) = 0; + + //! Flag the meshbuffer as changed, reloads hardware buffers + /** This method has to be called every time the vertices or + indices have changed. Otherwise, changes won't be updated + on the GPU in the next render cycle. */ + virtual void setDirty(E_BUFFER_TYPE buffer = EBT_VERTEX_AND_INDEX) = 0; + + //! Returns the type of the meshes. + /** This is useful for making a safe downcast. For example, + if getMeshType() returns EAMT_MD2 it's safe to cast the + IMesh to IAnimatedMeshMD2. + Note: It's no longer just about animated meshes, that name has just historical reasons. + \returns Type of the mesh */ + virtual E_ANIMATED_MESH_TYPE getMeshType() const + { + return EAMT_STATIC; + } +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/IMeshBuffer.h b/irr/include/IMeshBuffer.h new file mode 100644 index 000000000..3e2e3d74e --- /dev/null +++ b/irr/include/IMeshBuffer.h @@ -0,0 +1,182 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "SMaterial.h" +#include "aabbox3d.h" +#include "S3DVertex.h" +#include "SVertexIndex.h" +#include "EHardwareBufferFlags.h" +#include "EPrimitiveTypes.h" + +namespace irr +{ +namespace scene +{ +//! Struct for holding a mesh with a single material. +/** A part of an IMesh which has the same material on each face of that +group. Logical groups of an IMesh need not be put into separate mesh +buffers, but can be. Separately animated parts of the mesh must be put +into separate mesh buffers. +Some mesh buffer implementations have limitations on the number of +vertices the buffer can hold. In that case, logical grouping can help. +Moreover, the number of vertices should be optimized for the GPU upload, +which often depends on the type of gfx card. Typical figures are +1000-10000 vertices per buffer. +SMeshBuffer is a simple implementation of a MeshBuffer, which supports +up to 65535 vertices. + +Since meshbuffers are used for drawing, and hence will be exposed +to the driver, chances are high that they are grab()'ed from somewhere. +It's therefore required to dynamically allocate meshbuffers which are +passed to a video driver and only drop the buffer once it's not used in +the current code block anymore. +*/ +class IMeshBuffer : public virtual IReferenceCounted +{ +public: + //! Get the material of this meshbuffer + /** \return Material of this buffer. */ + virtual video::SMaterial &getMaterial() = 0; + + //! Get the material of this meshbuffer + /** \return Material of this buffer. */ + virtual const video::SMaterial &getMaterial() const = 0; + + //! Get type of vertex data which is stored in this meshbuffer. + /** \return Vertex type of this buffer. */ + virtual video::E_VERTEX_TYPE getVertexType() const = 0; + + //! Get access to vertex data. The data is an array of vertices. + /** Which vertex type is used can be determined by getVertexType(). + \return Pointer to array of vertices. */ + virtual const void *getVertices() const = 0; + + //! Get access to vertex data. The data is an array of vertices. + /** Which vertex type is used can be determined by getVertexType(). + \return Pointer to array of vertices. */ + virtual void *getVertices() = 0; + + //! Get amount of vertices in meshbuffer. + /** \return Number of vertices in this buffer. */ + virtual u32 getVertexCount() const = 0; + + //! Get type of index data which is stored in this meshbuffer. + /** \return Index type of this buffer. */ + virtual video::E_INDEX_TYPE getIndexType() const = 0; + + //! Get access to indices. + /** \return Pointer to indices array. */ + virtual const u16 *getIndices() const = 0; + + //! Get access to indices. + /** \return Pointer to indices array. */ + virtual u16 *getIndices() = 0; + + //! Get amount of indices in this meshbuffer. + /** \return Number of indices in this buffer. */ + virtual u32 getIndexCount() const = 0; + + //! Get the axis aligned bounding box of this meshbuffer. + /** \return Axis aligned bounding box of this buffer. */ + virtual const core::aabbox3df &getBoundingBox() const = 0; + + //! Set axis aligned bounding box + /** \param box User defined axis aligned bounding box to use + for this buffer. */ + virtual void setBoundingBox(const core::aabbox3df &box) = 0; + + //! Recalculates the bounding box. Should be called if the mesh changed. + virtual void recalculateBoundingBox() = 0; + + //! returns position of vertex i + virtual const core::vector3df &getPosition(u32 i) const = 0; + + //! returns position of vertex i + virtual core::vector3df &getPosition(u32 i) = 0; + + //! returns normal of vertex i + virtual const core::vector3df &getNormal(u32 i) const = 0; + + //! returns normal of vertex i + virtual core::vector3df &getNormal(u32 i) = 0; + + //! returns texture coord of vertex i + virtual const core::vector2df &getTCoords(u32 i) const = 0; + + //! returns texture coord of vertex i + virtual core::vector2df &getTCoords(u32 i) = 0; + + //! Append the vertices and indices to the current buffer + /** Only works for compatible vertex types. + \param vertices Pointer to a vertex array. + \param numVertices Number of vertices in the array. + \param indices Pointer to index array. + \param numIndices Number of indices in array. */ + virtual void append(const void *const vertices, u32 numVertices, const u16 *const indices, u32 numIndices) = 0; + + //! get the current hardware mapping hint + virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const = 0; + + //! get the current hardware mapping hint + virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const = 0; + + //! set the hardware mapping hint, for driver + virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer = EBT_VERTEX_AND_INDEX) = 0; + + //! flags the meshbuffer as changed, reloads hardware buffers + virtual void setDirty(E_BUFFER_TYPE buffer = EBT_VERTEX_AND_INDEX) = 0; + + //! Get the currently used ID for identification of changes. + /** This shouldn't be used for anything outside the VideoDriver. */ + virtual u32 getChangedID_Vertex() const = 0; + + //! Get the currently used ID for identification of changes. + /** This shouldn't be used for anything outside the VideoDriver. */ + virtual u32 getChangedID_Index() const = 0; + + //! Used by the VideoDriver to remember the buffer link. + virtual void setHWBuffer(void *ptr) const = 0; + virtual void *getHWBuffer() const = 0; + + //! Describe what kind of primitive geometry is used by the meshbuffer + /** Note: Default is EPT_TRIANGLES. Using other types is fine for rendering. + But meshbuffer manipulation functions might expect type EPT_TRIANGLES + to work correctly. Also mesh writers will generally fail (badly!) with other + types than EPT_TRIANGLES. */ + virtual void setPrimitiveType(E_PRIMITIVE_TYPE type) = 0; + + //! Get the kind of primitive geometry which is used by the meshbuffer + virtual E_PRIMITIVE_TYPE getPrimitiveType() const = 0; + + //! Calculate how many geometric primitives are used by this meshbuffer + virtual u32 getPrimitiveCount() const + { + const u32 indexCount = getIndexCount(); + switch (getPrimitiveType()) { + case scene::EPT_POINTS: + return indexCount; + case scene::EPT_LINE_STRIP: + return indexCount - 1; + case scene::EPT_LINE_LOOP: + return indexCount; + case scene::EPT_LINES: + return indexCount / 2; + case scene::EPT_TRIANGLE_STRIP: + return (indexCount - 2); + case scene::EPT_TRIANGLE_FAN: + return (indexCount - 2); + case scene::EPT_TRIANGLES: + return indexCount / 3; + case scene::EPT_POINT_SPRITES: + return indexCount; + } + return 0; + } +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/IMeshCache.h b/irr/include/IMeshCache.h new file mode 100644 index 000000000..66052bfac --- /dev/null +++ b/irr/include/IMeshCache.h @@ -0,0 +1,131 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "path.h" + +namespace irr +{ + +namespace scene +{ +class IMesh; +class IAnimatedMesh; +class IAnimatedMeshSceneNode; +class IMeshLoader; + +//! The mesh cache stores already loaded meshes and provides an interface to them. +/** You can access it using ISceneManager::getMeshCache(). All existing +scene managers will return a pointer to the same mesh cache, because it +is shared between them. With this interface, it is possible to manually +add new loaded meshes (if ISceneManager::getMesh() is not sufficient), +to remove them and to iterate through already loaded meshes. */ +class IMeshCache : public virtual IReferenceCounted +{ +public: + //! Destructor + virtual ~IMeshCache() {} + + //! Adds a mesh to the internal list of loaded meshes. + /** Usually, ISceneManager::getMesh() is called to load a mesh + from a file. That method searches the list of loaded meshes if + a mesh has already been loaded and returns a pointer to if it + is in that list and already in memory. Otherwise it loads the + mesh. With IMeshCache::addMesh(), it is possible to pretend + that a mesh already has been loaded. This method can be used + for example by mesh loaders who need to load more than one mesh + with one call. They can add additional meshes with this method + to the scene manager. The COLLADA loader for example uses this + method. + \param name Name of the mesh. When calling + ISceneManager::getMesh() with this name it will return the mesh + set by this method. + \param mesh Pointer to a mesh which will now be referenced by + this name. */ + virtual void addMesh(const io::path &name, IAnimatedMesh *mesh) = 0; + + //! Removes the mesh from the cache. + /** After loading a mesh with getMesh(), the mesh can be + removed from the cache using this method, freeing a lot of + memory. + \param mesh Pointer to the mesh which shall be removed. */ + virtual void removeMesh(const IMesh *const mesh) = 0; + + //! Returns amount of loaded meshes in the cache. + /** You can load new meshes into the cache using getMesh() and + addMesh(). If you ever need to access the internal mesh cache, + you can do this using removeMesh(), getMeshNumber(), + getMeshByIndex() and getMeshName(). + \return Number of meshes in cache. */ + virtual u32 getMeshCount() const = 0; + + //! Returns current index number of the mesh or -1 when not found. + /** \param mesh Pointer to the mesh to search for. + \return Index of the mesh in the cache, or -1 if not found. */ + virtual s32 getMeshIndex(const IMesh *const mesh) const = 0; + + //! Returns a mesh based on its index number. + /** \param index: Index of the mesh, number between 0 and + getMeshCount()-1. + Note that this number is only valid until a new mesh is loaded + or removed. + \return Pointer to the mesh or 0 if there is none with this + number. */ + virtual IAnimatedMesh *getMeshByIndex(u32 index) = 0; + + //! Returns a mesh based on its name. + /** \param name Name of the mesh. Usually a filename. + \return Pointer to the mesh or 0 if there is none with this number. */ + virtual IAnimatedMesh *getMeshByName(const io::path &name) = 0; + + //! Get the name of a loaded mesh, based on its index. + /** \param index: Index of the mesh, number between 0 and getMeshCount()-1. + \return The name if mesh was found and has a name, else the path is empty. */ + virtual const io::SNamedPath &getMeshName(u32 index) const = 0; + + //! Get the name of the loaded mesh if there is any. + /** \param mesh Pointer to mesh to query. + \return The name if mesh was found and has a name, else the path is empty. */ + virtual const io::SNamedPath &getMeshName(const IMesh *const mesh) const = 0; + + //! Renames a loaded mesh. + /** Note that renaming meshes might change the ordering of the + meshes, and so the index of the meshes as returned by + getMeshIndex() or taken by some methods will change. + \param index The index of the mesh in the cache. + \param name New name for the mesh. + \return True if mesh was renamed. */ + virtual bool renameMesh(u32 index, const io::path &name) = 0; + + //! Renames the loaded mesh + /** Note that renaming meshes might change the ordering of the + meshes, and so the index of the meshes as returned by + getMeshIndex() or taken by some methods will change. + \param mesh Mesh to be renamed. + \param name New name for the mesh. + \return True if mesh was renamed. */ + virtual bool renameMesh(const IMesh *const mesh, const io::path &name) = 0; + + //! Check if a mesh was already loaded. + /** \param name Name of the mesh. Usually a filename. + \return True if the mesh has been loaded, else false. */ + virtual bool isMeshLoaded(const io::path &name) = 0; + + //! Clears the whole mesh cache, removing all meshes. + /** All meshes will be reloaded completely when using ISceneManager::getMesh() + after calling this method. + Warning: If you have pointers to meshes that were loaded with ISceneManager::getMesh() + and you did not grab them, then they may become invalid. */ + virtual void clear() = 0; + + //! Clears all meshes that are held in the mesh cache but not used anywhere else. + /** Warning: If you have pointers to meshes that were loaded with ISceneManager::getMesh() + and you did not grab them, then they may become invalid. */ + virtual void clearUnusedMeshes() = 0; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/IMeshLoader.h b/irr/include/IMeshLoader.h new file mode 100644 index 000000000..d1f2675e9 --- /dev/null +++ b/irr/include/IMeshLoader.h @@ -0,0 +1,50 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "path.h" + +namespace irr +{ +namespace io +{ +class IReadFile; +} // end namespace io +namespace scene +{ +class IAnimatedMesh; + +//! Class which is able to load an animated mesh from a file. +/** If you want Irrlicht be able to load meshes of +currently unsupported file formats (e.g. .cob), then implement +this and add your new Meshloader with +ISceneManager::addExternalMeshLoader() to the engine. */ +class IMeshLoader : public virtual IReferenceCounted +{ +public: + //! Constructor + IMeshLoader() {} + + //! Destructor + virtual ~IMeshLoader() {} + + //! Returns true if the file might be loaded by this class. + /** This decision should be based on the file extension (e.g. ".cob") + only. + \param filename Name of the file to test. + \return True if the file might be loaded by this class. */ + virtual bool isALoadableFileExtension(const io::path &filename) const = 0; + + //! Creates/loads an animated mesh from the file. + /** \param file File handler to load the file from. + \return Pointer to the created mesh. Returns 0 if loading failed. + If you no longer need the mesh, you should call IAnimatedMesh::drop(). + See IReferenceCounted::drop() for more information. */ + virtual IAnimatedMesh *createMesh(io::IReadFile *file) = 0; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/IMeshManipulator.h b/irr/include/IMeshManipulator.h new file mode 100644 index 000000000..de3d84416 --- /dev/null +++ b/irr/include/IMeshManipulator.h @@ -0,0 +1,170 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "vector3d.h" +#include "aabbox3d.h" +#include "matrix4.h" +#include "IAnimatedMesh.h" +#include "IMeshBuffer.h" +#include "SVertexManipulator.h" + +namespace irr +{ +namespace scene +{ + +struct SMesh; + +//! An interface for easy manipulation of meshes. +/** Scale, set alpha value, flip surfaces, and so on. This exists for +fixing problems with wrong imported or exported meshes quickly after +loading. It is not intended for doing mesh modifications and/or +animations during runtime. +*/ +class IMeshManipulator : public virtual IReferenceCounted +{ +public: + //! Recalculates all normals of the mesh. + /** \param mesh: Mesh on which the operation is performed. + \param smooth: If the normals shall be smoothed. + \param angleWeighted: If the normals shall be smoothed in relation to their angles. More expensive, but also higher precision. */ + virtual void recalculateNormals(IMesh *mesh, bool smooth = false, + bool angleWeighted = false) const = 0; + + //! Recalculates all normals of the mesh buffer. + /** \param buffer: Mesh buffer on which the operation is performed. + \param smooth: If the normals shall be smoothed. + \param angleWeighted: If the normals shall be smoothed in relation to their angles. More expensive, but also higher precision. */ + virtual void recalculateNormals(IMeshBuffer *buffer, + bool smooth = false, bool angleWeighted = false) const = 0; + + //! Scales the actual mesh, not a scene node. + /** \param mesh Mesh on which the operation is performed. + \param factor Scale factor for each axis. */ + void scale(IMesh *mesh, const core::vector3df &factor) const + { + apply(SVertexPositionScaleManipulator(factor), mesh, true); + } + + //! Scales the actual meshbuffer, not a scene node. + /** \param buffer Meshbuffer on which the operation is performed. + \param factor Scale factor for each axis. */ + void scale(IMeshBuffer *buffer, const core::vector3df &factor) const + { + apply(SVertexPositionScaleManipulator(factor), buffer, true); + } + + //! Clones a static IMesh into a modifiable SMesh. + /** All meshbuffers in the returned SMesh + are of type SMeshBuffer or SMeshBufferLightMap. + \param mesh Mesh to copy. + \return Cloned mesh. If you no longer need the + cloned mesh, you should call SMesh::drop(). See + IReferenceCounted::drop() for more information. */ + virtual SMesh *createMeshCopy(IMesh *mesh) const = 0; + + //! Get amount of polygons in mesh. + /** \param mesh Input mesh + \return Number of polygons in mesh. */ + virtual s32 getPolyCount(IMesh *mesh) const = 0; + + //! Get amount of polygons in mesh. + /** \param mesh Input mesh + \return Number of polygons in mesh. */ + virtual s32 getPolyCount(IAnimatedMesh *mesh) const = 0; + + //! Create a new AnimatedMesh and adds the mesh to it + /** \param mesh Input mesh + \param type The type of the animated mesh to create. + \return Newly created animated mesh with mesh as its only + content. When you don't need the animated mesh anymore, you + should call IAnimatedMesh::drop(). See + IReferenceCounted::drop() for more information. */ + virtual IAnimatedMesh *createAnimatedMesh(IMesh *mesh, + scene::E_ANIMATED_MESH_TYPE type = scene::EAMT_UNKNOWN) const = 0; + + //! Apply a manipulator on the Meshbuffer + /** \param func A functor defining the mesh manipulation. + \param buffer The Meshbuffer to apply the manipulator to. + \param boundingBoxUpdate Specifies if the bounding box should be updated during manipulation. + \return True if the functor was successfully applied, else false. */ + template + bool apply(const Functor &func, IMeshBuffer *buffer, bool boundingBoxUpdate = false) const + { + return apply_(func, buffer, boundingBoxUpdate, func); + } + + //! Apply a manipulator on the Mesh + /** \param func A functor defining the mesh manipulation. + \param mesh The Mesh to apply the manipulator to. + \param boundingBoxUpdate Specifies if the bounding box should be updated during manipulation. + \return True if the functor was successfully applied, else false. */ + template + bool apply(const Functor &func, IMesh *mesh, bool boundingBoxUpdate = false) const + { + if (!mesh) + return true; + bool result = true; + core::aabbox3df bufferbox; + for (u32 i = 0; i < mesh->getMeshBufferCount(); ++i) { + result &= apply(func, mesh->getMeshBuffer(i), boundingBoxUpdate); + if (boundingBoxUpdate) { + if (0 == i) + bufferbox.reset(mesh->getMeshBuffer(i)->getBoundingBox()); + else + bufferbox.addInternalBox(mesh->getMeshBuffer(i)->getBoundingBox()); + } + } + if (boundingBoxUpdate) + mesh->setBoundingBox(bufferbox); + return result; + } + +protected: + //! Apply a manipulator based on the type of the functor + /** \param func A functor defining the mesh manipulation. + \param buffer The Meshbuffer to apply the manipulator to. + \param boundingBoxUpdate Specifies if the bounding box should be updated during manipulation. + \param typeTest Unused parameter, which handles the proper call selection based on the type of the Functor which is passed in two times. + \return True if the functor was successfully applied, else false. */ + template + bool apply_(const Functor &func, IMeshBuffer *buffer, bool boundingBoxUpdate, const IVertexManipulator &typeTest) const + { + if (!buffer) + return true; + + core::aabbox3df bufferbox; + for (u32 i = 0; i < buffer->getVertexCount(); ++i) { + switch (buffer->getVertexType()) { + case video::EVT_STANDARD: { + video::S3DVertex *verts = (video::S3DVertex *)buffer->getVertices(); + func(verts[i]); + } break; + case video::EVT_2TCOORDS: { + video::S3DVertex2TCoords *verts = (video::S3DVertex2TCoords *)buffer->getVertices(); + func(verts[i]); + } break; + case video::EVT_TANGENTS: { + video::S3DVertexTangents *verts = (video::S3DVertexTangents *)buffer->getVertices(); + func(verts[i]); + } break; + } + if (boundingBoxUpdate) { + if (0 == i) + bufferbox.reset(buffer->getPosition(0)); + else + bufferbox.addInternalPoint(buffer->getPosition(i)); + } + } + if (boundingBoxUpdate) + buffer->setBoundingBox(bufferbox); + return true; + } +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/IMeshSceneNode.h b/irr/include/IMeshSceneNode.h new file mode 100644 index 000000000..89b26dce1 --- /dev/null +++ b/irr/include/IMeshSceneNode.h @@ -0,0 +1,50 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "ISceneNode.h" + +namespace irr +{ +namespace scene +{ + +class IMesh; + +//! A scene node displaying a static mesh +class IMeshSceneNode : public ISceneNode +{ +public: + //! Constructor + /** Use setMesh() to set the mesh to display. + */ + IMeshSceneNode(ISceneNode *parent, ISceneManager *mgr, s32 id, + const core::vector3df &position = core::vector3df(0, 0, 0), + const core::vector3df &rotation = core::vector3df(0, 0, 0), + const core::vector3df &scale = core::vector3df(1, 1, 1)) : + ISceneNode(parent, mgr, id, position, rotation, scale) {} + + //! Sets a new mesh to display + /** \param mesh Mesh to display. */ + virtual void setMesh(IMesh *mesh) = 0; + + //! Get the currently defined mesh for display. + /** \return Pointer to mesh which is displayed by this node. */ + virtual IMesh *getMesh(void) = 0; + + //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. + /** In this way it is possible to change the materials of a mesh + causing all mesh scene nodes referencing this mesh to change, too. + \param readonly Flag if the materials shall be read-only. */ + virtual void setReadOnlyMaterials(bool readonly) = 0; + + //! Check if the scene node should not copy the materials of the mesh but use them in a read only style + /** This flag can be set by setReadOnlyMaterials(). + \return Whether the materials are read-only. */ + virtual bool isReadOnlyMaterials() const = 0; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/IOSOperator.h b/irr/include/IOSOperator.h new file mode 100644 index 000000000..6164af5c9 --- /dev/null +++ b/irr/include/IOSOperator.h @@ -0,0 +1,45 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "irrString.h" + +namespace irr +{ + +//! The OSOperator provides OS-specific methods and information. +class IOSOperator : public virtual IReferenceCounted +{ +public: + //! Get the current OS version as string. + virtual const core::stringc &getOperatingSystemVersion() const = 0; + + //! Copies text to the clipboard + //! \param text: text in utf-8 + virtual void copyToClipboard(const c8 *text) const = 0; + + //! Copies text to the primary selection + //! This is a no-op on some platforms. + //! \param text: text in utf-8 + virtual void copyToPrimarySelection(const c8 *text) const = 0; + + //! Get text from the clipboard + //! \return Returns 0 if no string is in there, otherwise an utf-8 string. + virtual const c8 *getTextFromClipboard() const = 0; + + //! Get text from the primary selection + //! This is a no-op on some platforms. + //! \return Returns 0 if no string is in there, otherwise an utf-8 string. + virtual const c8 *getTextFromPrimarySelection() const = 0; + + //! Get the total and available system RAM + /** \param totalBytes: will contain the total system memory in Kilobytes (1024 B) + \param availableBytes: will contain the available memory in Kilobytes (1024 B) + \return True if successful, false if not */ + virtual bool getSystemMemory(u32 *totalBytes, u32 *availableBytes) const = 0; +}; + +} // end namespace diff --git a/irr/include/IReadFile.h b/irr/include/IReadFile.h new file mode 100644 index 000000000..d3d973069 --- /dev/null +++ b/irr/include/IReadFile.h @@ -0,0 +1,57 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "coreutil.h" +#include "EReadFileType.h" + +namespace irr +{ +namespace io +{ + +//! Interface providing read access to a file. +class IReadFile : public virtual IReferenceCounted +{ +public: + //! Reads an amount of bytes from the file. + /** \param buffer Pointer to buffer where read bytes are written to. + \param sizeToRead Amount of bytes to read from the file. + \return How many bytes were read. */ + virtual size_t read(void *buffer, size_t sizeToRead) = 0; + + //! Changes position in file + /** \param finalPos Destination position in the file. + \param relativeMovement If set to true, the position in the file is + changed relative to current position. Otherwise the position is changed + from beginning of file. + \return True if successful, otherwise false. */ + virtual bool seek(long finalPos, bool relativeMovement = false) = 0; + + //! Get size of file. + /** \return Size of the file in bytes. */ + virtual long getSize() const = 0; + + //! Get the current position in the file. + /** \return Current position in the file in bytes on success or -1L on failure. */ + virtual long getPos() const = 0; + + //! Get name of file. + /** \return File name as zero terminated character string. */ + virtual const io::path &getFileName() const = 0; + + //! Get the type of the class implementing this interface + virtual EREAD_FILE_TYPE getType() const + { + return EFIT_UNKNOWN; + } +}; + +//! Internal function, please do not use. +IReadFile *createLimitReadFile(const io::path &fileName, IReadFile *alreadyOpenedFile, long pos, long areaSize); + +} // end namespace io +} // end namespace irr diff --git a/irr/include/IReferenceCounted.h b/irr/include/IReferenceCounted.h new file mode 100644 index 000000000..6f85bb904 --- /dev/null +++ b/irr/include/IReferenceCounted.h @@ -0,0 +1,162 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" + +namespace irr +{ + +//! Base class of most objects of the Irrlicht Engine. +/** This class provides reference counting through the methods grab() and drop(). +It also is able to store a debug string for every instance of an object. +Most objects of the Irrlicht +Engine are derived from IReferenceCounted, and so they are reference counted. + +When you create an object in the Irrlicht engine, calling a method +which starts with 'create', an object is created, and you get a pointer +to the new object. If you no longer need the object, you have +to call drop(). This will destroy the object, if grab() was not called +in another part of you program, because this part still needs the object. +Note, that you only need to call drop() to the object, if you created it, +and the method had a 'create' in it. + +A simple example: + +If you want to create a texture, you may want to call an imaginable method +IDriver::createTexture. You call +ITexture* texture = driver->createTexture(dimension2d(128, 128)); +If you no longer need the texture, call texture->drop(). + +If you want to load a texture, you may want to call imaginable method +IDriver::loadTexture. You do this like +ITexture* texture = driver->loadTexture("example.jpg"); +You will not have to drop the pointer to the loaded texture, because +the name of the method does not start with 'create'. The texture +is stored somewhere by the driver. +*/ +class IReferenceCounted +{ +public: + //! Constructor. + IReferenceCounted() : + DebugName(0), ReferenceCounter(1) + { + } + + //! Destructor. + virtual ~IReferenceCounted() + { + } + + //! Grabs the object. Increments the reference counter by one. + /** Someone who calls grab() to an object, should later also + call drop() to it. If an object never gets as much drop() as + grab() calls, it will never be destroyed. The + IReferenceCounted class provides a basic reference counting + mechanism with its methods grab() and drop(). Most objects of + the Irrlicht Engine are derived from IReferenceCounted, and so + they are reference counted. + + When you create an object in the Irrlicht engine, calling a + method which starts with 'create', an object is created, and + you get a pointer to the new object. If you no longer need the + object, you have to call drop(). This will destroy the object, + if grab() was not called in another part of you program, + because this part still needs the object. Note, that you only + need to call drop() to the object, if you created it, and the + method had a 'create' in it. + + A simple example: + + If you want to create a texture, you may want to call an + imaginable method IDriver::createTexture. You call + ITexture* texture = driver->createTexture(dimension2d(128, 128)); + If you no longer need the texture, call texture->drop(). + If you want to load a texture, you may want to call imaginable + method IDriver::loadTexture. You do this like + ITexture* texture = driver->loadTexture("example.jpg"); + You will not have to drop the pointer to the loaded texture, + because the name of the method does not start with 'create'. + The texture is stored somewhere by the driver. */ + void grab() const { ++ReferenceCounter; } + + //! Drops the object. Decrements the reference counter by one. + /** The IReferenceCounted class provides a basic reference + counting mechanism with its methods grab() and drop(). Most + objects of the Irrlicht Engine are derived from + IReferenceCounted, and so they are reference counted. + + When you create an object in the Irrlicht engine, calling a + method which starts with 'create', an object is created, and + you get a pointer to the new object. If you no longer need the + object, you have to call drop(). This will destroy the object, + if grab() was not called in another part of you program, + because this part still needs the object. Note, that you only + need to call drop() to the object, if you created it, and the + method had a 'create' in it. + + A simple example: + + If you want to create a texture, you may want to call an + imaginable method IDriver::createTexture. You call + ITexture* texture = driver->createTexture(dimension2d(128, 128)); + If you no longer need the texture, call texture->drop(). + If you want to load a texture, you may want to call imaginable + method IDriver::loadTexture. You do this like + ITexture* texture = driver->loadTexture("example.jpg"); + You will not have to drop the pointer to the loaded texture, + because the name of the method does not start with 'create'. + The texture is stored somewhere by the driver. + \return True, if the object was deleted. */ + bool drop() const + { + // someone is doing bad reference counting. + _IRR_DEBUG_BREAK_IF(ReferenceCounter <= 0) + + --ReferenceCounter; + if (!ReferenceCounter) { + delete this; + return true; + } + + return false; + } + + //! Get the reference count. + /** \return Current value of the reference counter. */ + s32 getReferenceCount() const + { + return ReferenceCounter; + } + + //! Returns the debug name of the object. + /** The Debugname may only be set and changed by the object + itself. This method should only be used in Debug mode. + \return Returns a string, previously set by setDebugName(); */ + const c8 *getDebugName() const + { + return DebugName; + } + +protected: + //! Sets the debug name of the object. + /** The Debugname may only be set and changed by the object + itself. This method should only be used in Debug mode. + \param newName: New debug name to set. */ + void setDebugName(const c8 *newName) + { + DebugName = newName; + } + +private: + //! The debug name. + const c8 *DebugName; + + //! The reference counter. Mutable to do reference counting on const objects. + mutable s32 ReferenceCounter; +}; + +} // end namespace irr diff --git a/irr/include/IRenderTarget.h b/irr/include/IRenderTarget.h new file mode 100644 index 000000000..1e70c1e06 --- /dev/null +++ b/irr/include/IRenderTarget.h @@ -0,0 +1,119 @@ +// Copyright (C) 2015 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "EDriverTypes.h" +#include "irrArray.h" + +namespace irr +{ +namespace video +{ +class ITexture; + +//! Enumeration of cube texture surfaces +enum E_CUBE_SURFACE +{ + ECS_POSX = 0, + ECS_NEGX, + ECS_POSY, + ECS_NEGY, + ECS_POSZ, + ECS_NEGZ +}; + +//! Interface of a Render Target. +class IRenderTarget : public virtual IReferenceCounted +{ +public: + //! constructor + IRenderTarget() : + DepthStencil(0), DriverType(EDT_NULL) + { + } + + //! Returns an array of previously set textures. + const core::array &getTexture() const + { + return Textures; + } + + //! Returns a of previously set depth / depth-stencil texture. + ITexture *getDepthStencil() const + { + return DepthStencil; + } + + //! Returns an array of active surface for cube textures + const core::array &getCubeSurfaces() const + { + return CubeSurfaces; + } + + //! Set multiple textures. + /** Set multiple textures for the render target. + \param texture Array of texture objects. These textures are used for a color outputs. + \param depthStencil Depth or packed depth-stencil texture. This texture is used as depth + or depth-stencil buffer. You can pass getDepthStencil() if you don't want to change it. + \param cubeSurfaces When rendering to cube textures, set the surface to be used for each texture. Can be empty otherwise. + */ + void setTexture(const core::array &texture, ITexture *depthStencil, const core::array &cubeSurfaces = core::array()) + { + setTextures(texture.const_pointer(), texture.size(), depthStencil, cubeSurfaces.const_pointer(), cubeSurfaces.size()); + } + + //! Sets one texture + depthStencil + //! You can pass getDepthStencil() for depthStencil if you don't want to change that one + void setTexture(ITexture *texture, ITexture *depthStencil) + { + if (texture) { + setTextures(&texture, 1, depthStencil); + } else { + setTextures(0, 0, depthStencil); + } + } + + //! Set one cube surface texture. + void setTexture(ITexture *texture, ITexture *depthStencil, E_CUBE_SURFACE cubeSurface) + { + if (texture) { + setTextures(&texture, 1, depthStencil, &cubeSurface, 1); + } else { + setTextures(0, 0, depthStencil, &cubeSurface, 1); + } + } + + //! Get driver type of render target. + E_DRIVER_TYPE getDriverType() const + { + return DriverType; + } + +protected: + //! Set multiple textures. + // NOTE: working with pointers instead of arrays to avoid unnecessary memory allocations for the single textures case + virtual void setTextures(ITexture *const *textures, u32 numTextures, ITexture *depthStencil, const E_CUBE_SURFACE *cubeSurfaces = 0, u32 numCubeSurfaces = 0) = 0; + + //! Textures assigned to render target. + core::array Textures; + + //! Depth or packed depth-stencil texture assigned to render target. + ITexture *DepthStencil; + + //! Active surface of cube textures + core::array CubeSurfaces; + + //! Driver type of render target. + E_DRIVER_TYPE DriverType; + +private: + // no copying (IReferenceCounted still allows that for reasons which take some time to work around) + IRenderTarget(const IRenderTarget &); + IRenderTarget &operator=(const IRenderTarget &); +}; + +} +} diff --git a/irr/include/ISceneCollisionManager.h b/irr/include/ISceneCollisionManager.h new file mode 100644 index 000000000..3307dc6bb --- /dev/null +++ b/irr/include/ISceneCollisionManager.h @@ -0,0 +1,33 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "position2d.h" +#include "line3d.h" + +namespace irr +{ + +namespace scene +{ +class ICameraSceneNode; + +class ISceneCollisionManager : public virtual IReferenceCounted +{ +public: + //! Returns a 3d ray which would go through the 2d screen coordinates. + /** \param pos: Screen coordinates in pixels. + \param camera: Camera from which the ray starts. If null, the + active camera is used. + \return Ray starting from the position of the camera and ending + at a length of the far value of the camera at a position which + would be behind the 2d screen coordinates. */ + virtual core::line3d getRayFromScreenCoordinates( + const core::position2d &pos, const ICameraSceneNode *camera = 0) = 0; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/ISceneManager.h b/irr/include/ISceneManager.h new file mode 100644 index 000000000..c247c4b99 --- /dev/null +++ b/irr/include/ISceneManager.h @@ -0,0 +1,632 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "irrArray.h" +#include "irrString.h" +#include "path.h" +#include "vector3d.h" +#include "dimension2d.h" +#include "SColor.h" +#include "ESceneNodeTypes.h" +#include "SceneParameters.h" +#include "ISkinnedMesh.h" + +namespace irr +{ +struct SKeyMap; +struct SEvent; + +namespace io +{ +class IReadFile; +class IAttributes; +class IWriteFile; +class IFileSystem; +} // end namespace io + +namespace gui +{ +class IGUIFont; +class IGUIEnvironment; +} // end namespace gui + +namespace video +{ +class IVideoDriver; +class SMaterial; +class IImage; +class ITexture; +} // end namespace video + +namespace scene +{ +//! Enumeration for render passes. +/** A parameter passed to the registerNodeForRendering() method of the ISceneManager, +specifying when the node wants to be drawn in relation to the other nodes. +Note: Despite the numbering this is not used as bit-field. +*/ +enum E_SCENE_NODE_RENDER_PASS +{ + //! No pass currently active + ESNRP_NONE = 0, + + //! Camera pass. The active view is set up here. The very first pass. + ESNRP_CAMERA = 1, + + //! In this pass, lights are transformed into camera space and added to the driver + ESNRP_LIGHT = 2, + + //! This is used for sky boxes. + ESNRP_SKY_BOX = 4, + + //! All normal objects can use this for registering themselves. + /** This value will never be returned by + ISceneManager::getSceneNodeRenderPass(). The scene manager + will determine by itself if an object is transparent or solid + and register the object as ESNRT_TRANSPARENT or ESNRP_SOLID + automatically if you call registerNodeForRendering with this + value (which is default). Note that it will register the node + only as ONE type. If your scene node has both solid and + transparent material types register it twice (one time as + ESNRP_SOLID, the other time as ESNRT_TRANSPARENT) and in the + render() method call getSceneNodeRenderPass() to find out the + current render pass and render only the corresponding parts of + the node. */ + ESNRP_AUTOMATIC = 24, + + //! Solid scene nodes or special scene nodes without materials. + ESNRP_SOLID = 8, + + //! Transparent scene nodes, drawn after solid nodes. They are sorted from back to front and drawn in that order. + ESNRP_TRANSPARENT = 16, + + //! Transparent effect scene nodes, drawn after Transparent nodes. They are sorted from back to front and drawn in that order. + ESNRP_TRANSPARENT_EFFECT = 32, + + //! Drawn after the solid nodes, before the transparent nodes, the time for drawing shadow volumes + ESNRP_SHADOW = 64, + + //! Drawn after transparent effect nodes. For custom gui's. Unsorted (in order nodes registered themselves). + ESNRP_GUI = 128 + +}; + +class IAnimatedMesh; +class IAnimatedMeshSceneNode; +class IBillboardSceneNode; +class ICameraSceneNode; +class IDummyTransformationSceneNode; +class IMesh; +class IMeshBuffer; +class IMeshCache; +class ISceneCollisionManager; +class IMeshLoader; +class IMeshManipulator; +class IMeshSceneNode; +class ISceneNode; +class ISceneNodeFactory; + +//! The Scene Manager manages scene nodes, mesh resources, cameras and all the other stuff. +/** All Scene nodes can be created only here. +A scene node is a node in the hierarchical scene graph. Every scene node +may have children, which are other scene nodes. Children move relative +the their parents position. If the parent of a node is not visible, its +children won't be visible, too. In this way, it is for example easily +possible to attach a light to a moving car or to place a walking +character on a moving platform on a moving ship. +The SceneManager is also able to load 3d mesh files of different +formats. Take a look at getMesh() to find out what formats are +supported. If these formats are not enough, use +addExternalMeshLoader() to add new formats to the engine. +*/ +class ISceneManager : public virtual IReferenceCounted +{ +public: + //! Get pointer to an animatable mesh. Loads the file if not loaded already. + /** + * If you want to remove a loaded mesh from the cache again, use removeMesh(). + * Currently there are the following mesh formats supported: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
FormatDescription
3D Studio (.3ds)Loader for 3D-Studio files which lots of 3D packages + * are able to export. Only static meshes are currently + * supported by this importer.
3D World Studio (.smf)Loader for Leadwerks SMF mesh files, a simple mesh format + * containing static geometry for games. The proprietary .STF texture format + * is not supported yet. This loader was originally written by Joseph Ellis.
Bliz Basic B3D (.b3d)Loader for blitz basic files, developed by Mark + * Sibly. This is the ideal animated mesh format for game + * characters as it is both rigidly defined and widely + * supported by modeling and animation software. + * As this format supports skeletal animations, an + * ISkinnedMesh will be returned by this importer.
Cartography shop 4 (.csm)Cartography Shop is a modeling program for creating + * architecture and calculating lighting. Irrlicht can + * directly import .csm files thanks to the IrrCSM library + * created by Saurav Mohapatra which is now integrated + * directly in Irrlicht. + *
Delgine DeleD (.dmf)DeleD (delgine.com) is a 3D editor and level-editor + * combined into one and is specifically designed for 3D + * game-development. With this loader, it is possible to + * directly load all geometry is as well as textures and + * lightmaps from .dmf files. To set texture and + * material paths, see scene::DMF_USE_MATERIALS_DIRS. + * It is also possible to flip the alpha texture by setting + * scene::DMF_FLIP_ALPHA_TEXTURES to true and to set the + * material transparent reference value by setting + * scene::DMF_ALPHA_CHANNEL_REF to a float between 0 and + * 1. The loader is based on Salvatore Russo's .dmf + * loader, I just changed some parts of it. Thanks to + * Salvatore for his work and for allowing me to use his + * code in Irrlicht and put it under Irrlicht's license. + * For newer and more enhanced versions of the loader, + * take a look at delgine.com. + *
DirectX (.x)Platform independent importer (so not D3D-only) for + * .x files. Most 3D packages can export these natively + * and there are several tools for them available, e.g. + * the Maya exporter included in the DX SDK. + * .x files can include skeletal animations and Irrlicht + * is able to play and display them, users can manipulate + * the joints via the ISkinnedMesh interface. Currently, + * Irrlicht only supports uncompressed .x files.
Half-Life model (.mdl)This loader opens Half-life 1 models, it was contributed + * by Fabio Concas and adapted by Thomas Alten.
LightWave (.lwo)Native to NewTek's LightWave 3D, the LWO format is well + * known and supported by many exporters. This loader will + * import LWO2 models including lightmaps, bumpmaps and + * reflection textures.
Maya (.obj)Most 3D software can create .obj files which contain + * static geometry without material data. The material + * files .mtl are also supported. This importer for + * Irrlicht can load them directly.
Milkshape (.ms3d).MS3D files contain models and sometimes skeletal + * animations from the Milkshape 3D modeling and animation + * software. Like the other skeletal mesh loaders, joints + * are exposed via the ISkinnedMesh animated mesh type.
My3D (.my3d).my3D is a flexible 3D file format. The My3DTools + * contains plug-ins to export .my3D files from several + * 3D packages. With this built-in importer, Irrlicht + * can read and display those files directly. This + * loader was written by Zhuck Dimitry who also created + * the whole My3DTools package. + *
OCT (.oct)The oct file format contains 3D geometry and + * lightmaps and can be loaded directly by Irrlicht. OCT + * files
can be created by FSRad, Paul Nette's + * radiosity processor or exported from Blender using + * OCTTools which can be found in the exporters/OCTTools + * directory of the SDK. Thanks to Murphy McCauley for + * creating all this.
OGRE Meshes (.mesh)Ogre .mesh files contain 3D data for the OGRE 3D + * engine. Irrlicht can read and display them directly + * with this importer. To define materials for the mesh, + * copy a .material file named like the corresponding + * .mesh file where the .mesh file is. (For example + * ogrehead.material for ogrehead.mesh). Thanks to + * Christian Stehno who wrote and contributed this + * loader.
Pulsar LMTools (.lmts)LMTools is a set of tools (Windows & Linux) for + * creating lightmaps. Irrlicht can directly read .lmts + * files thanks to
the importer created by Jonas + * Petersen. + * Notes for
this version of the loader:
+ * - It does not recognize/support user data in the + * *.lmts files.
+ * - The TGAs generated by LMTools don't work in + * Irrlicht for some reason (the textures are upside + * down). Opening and resaving them in a graphics app + * will solve the problem.
Quake 3 levels (.bsp)Quake 3 is a popular game by IDSoftware, and .pk3 + * files contain .bsp files and textures/lightmaps + * describing huge prelighted levels. Irrlicht can read + * .pk3 and .bsp files directly and thus render Quake 3 + * levels directly. Written by Nikolaus Gebhardt + * enhanced by Dean P. Macri with the curved surfaces + * feature.
Quake 2 models (.md2)Quake 2 models are characters with morph target + * animation. Irrlicht can read, display and animate + * them directly with this importer.
Quake 3 models (.md3)Quake 3 models are characters with morph target + * animation, they contain mount points for weapons and body + * parts and are typically made of several sections which are + * manually joined together.
Stanford Triangle (.ply)Invented by Stanford University and known as the native + * format of the infamous "Stanford Bunny" model, this is a + * popular static mesh format used by 3D scanning hardware + * and software. This loader supports extremely large models + * in both ASCII and binary format, but only has rudimentary + * material support in the form of vertex colors and texture + * coordinates.
Stereolithography (.stl)The STL format is used for rapid prototyping and + * computer-aided manufacturing, thus has no support for + * materials.
+ * + * To load and display a mesh quickly, just do this: + * \code + * SceneManager->addAnimatedMeshSceneNode( + * SceneManager->getMesh("yourmesh.3ds")); + * \endcode + * If you would like to implement and add your own file format loader to Irrlicht, + * see addExternalMeshLoader(). + * \param file File handle of the mesh to load. + * \return Null if failed, otherwise pointer to the mesh. + * This pointer should not be dropped. See IReferenceCounted::drop() for more information. + **/ + virtual IAnimatedMesh *getMesh(io::IReadFile *file) = 0; + + //! Get interface to the mesh cache which is shared between all existing scene managers. + /** With this interface, it is possible to manually add new loaded + meshes (if ISceneManager::getMesh() is not sufficient), to remove them and to iterate + through already loaded meshes. */ + virtual IMeshCache *getMeshCache() = 0; + + //! Get the video driver. + /** \return Pointer to the video Driver. + This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ + virtual video::IVideoDriver *getVideoDriver() = 0; + + //! Adds a scene node for rendering an animated mesh model. + /** \param mesh: Pointer to the loaded animated mesh to be displayed. + \param parent: Parent of the scene node. Can be NULL if no parent. + \param id: Id of the node. This id can be used to identify the scene node. + \param position: Position of the space relative to its parent where the + scene node will be placed. + \param rotation: Initial rotation of the scene node. + \param scale: Initial scale of the scene node. + \param alsoAddIfMeshPointerZero: Add the scene node even if a 0 pointer is passed. + \return Pointer to the created scene node. + This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ + virtual IAnimatedMeshSceneNode *addAnimatedMeshSceneNode(IAnimatedMesh *mesh, + ISceneNode *parent = 0, s32 id = -1, + const core::vector3df &position = core::vector3df(0, 0, 0), + const core::vector3df &rotation = core::vector3df(0, 0, 0), + const core::vector3df &scale = core::vector3df(1.0f, 1.0f, 1.0f), + bool alsoAddIfMeshPointerZero = false) = 0; + + //! Adds a scene node for rendering a static mesh. + /** \param mesh: Pointer to the loaded static mesh to be displayed. + \param parent: Parent of the scene node. Can be NULL if no parent. + \param id: Id of the node. This id can be used to identify the scene node. + \param position: Position of the space relative to its parent where the + scene node will be placed. + \param rotation: Initial rotation of the scene node. + \param scale: Initial scale of the scene node. + \param alsoAddIfMeshPointerZero: Add the scene node even if a 0 pointer is passed. + \return Pointer to the created scene node. + This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ + virtual IMeshSceneNode *addMeshSceneNode(IMesh *mesh, ISceneNode *parent = 0, s32 id = -1, + const core::vector3df &position = core::vector3df(0, 0, 0), + const core::vector3df &rotation = core::vector3df(0, 0, 0), + const core::vector3df &scale = core::vector3df(1.0f, 1.0f, 1.0f), + bool alsoAddIfMeshPointerZero = false) = 0; + + //! Adds a camera scene node to the scene graph and sets it as active camera. + /** This camera does not react on user input. + If you want to move or animate it, use ISceneNode::setPosition(), + ICameraSceneNode::setTarget() etc methods. + By default, a camera's look at position (set with setTarget()) and its scene node + rotation (set with setRotation()) are independent. If you want to be able to + control the direction that the camera looks by using setRotation() then call + ICameraSceneNode::bindTargetAndRotation(true) on it. + \param position: Position of the space relative to its parent where the camera will be placed. + \param lookat: Position where the camera will look at. Also known as target. + \param parent: Parent scene node of the camera. Can be null. If the parent moves, + the camera will move too. + \param id: id of the camera. This id can be used to identify the camera. + \param makeActive Flag whether this camera should become the active one. + Make sure you always have one active camera. + \return Pointer to interface to camera if successful, otherwise 0. + This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ + virtual ICameraSceneNode *addCameraSceneNode(ISceneNode *parent = 0, + const core::vector3df &position = core::vector3df(0, 0, 0), + const core::vector3df &lookat = core::vector3df(0, 0, 100), + s32 id = -1, bool makeActive = true) = 0; + + //! Adds a billboard scene node to the scene graph. + /** A billboard is like a 3d sprite: A 2d element, + which always looks to the camera. It is usually used for things + like explosions, fire, lensflares and things like that. + \param parent Parent scene node of the billboard. Can be null. + If the parent moves, the billboard will move too. + \param size Size of the billboard. This size is 2 dimensional + because a billboard only has width and height. + \param position Position of the space relative to its parent + where the billboard will be placed. + \param id An id of the node. This id can be used to identify + the node. + \param colorTop The color of the vertices at the top of the + billboard (default: white). + \param colorBottom The color of the vertices at the bottom of + the billboard (default: white). + \return Pointer to the billboard if successful, otherwise NULL. + This pointer should not be dropped. See + IReferenceCounted::drop() for more information. */ + virtual IBillboardSceneNode *addBillboardSceneNode(ISceneNode *parent = 0, + const core::dimension2d &size = core::dimension2d(10.0f, 10.0f), + const core::vector3df &position = core::vector3df(0, 0, 0), s32 id = -1, + video::SColor colorTop = 0xFFFFFFFF, video::SColor colorBottom = 0xFFFFFFFF) = 0; + + //! Adds an empty scene node to the scene graph. + /** Can be used for doing advanced transformations + or structuring the scene graph. + \return Pointer to the created scene node. + This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ + virtual ISceneNode *addEmptySceneNode(ISceneNode *parent = 0, s32 id = -1) = 0; + + //! Adds a dummy transformation scene node to the scene graph. + /** This scene node does not render itself, and does not respond to set/getPosition, + set/getRotation and set/getScale. Its just a simple scene node that takes a + matrix as relative transformation, making it possible to insert any transformation + anywhere into the scene graph. + \return Pointer to the created scene node. + This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ + virtual IDummyTransformationSceneNode *addDummyTransformationSceneNode( + ISceneNode *parent = 0, s32 id = -1) = 0; + + //! Gets the root scene node. + /** This is the scene node which is parent + of all scene nodes. The root scene node is a special scene node which + only exists to manage all scene nodes. It will not be rendered and cannot + be removed from the scene. + \return Pointer to the root scene node. + This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ + virtual ISceneNode *getRootSceneNode() = 0; + + //! Get the first scene node with the specified id. + /** \param id: The id to search for + \param start: Scene node to start from. All children of this scene + node are searched. If null is specified, the root scene node is + taken. + \return Pointer to the first scene node with this id, + and null if no scene node could be found. + This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ + virtual ISceneNode *getSceneNodeFromId(s32 id, ISceneNode *start = 0) = 0; + + //! Get the first scene node with the specified name. + /** \param name: The name to search for + \param start: Scene node to start from. All children of this scene + node are searched. If null is specified, the root scene node is + taken. + \return Pointer to the first scene node with this id, + and null if no scene node could be found. + This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ + virtual ISceneNode *getSceneNodeFromName(const c8 *name, ISceneNode *start = 0) = 0; + + //! Get the first scene node with the specified type. + /** \param type: The type to search for + \param start: Scene node to start from. All children of this scene + node are searched. If null is specified, the root scene node is + taken. + \return Pointer to the first scene node with this type, + and null if no scene node could be found. + This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ + virtual ISceneNode *getSceneNodeFromType(scene::ESCENE_NODE_TYPE type, ISceneNode *start = 0) = 0; + + //! Get scene nodes by type. + /** \param type: Type of scene node to find (ESNT_ANY will return all child nodes). + \param outNodes: results will be added to this array (outNodes is not cleared). + \param start: Scene node to start from. This node and all children of this scene + node are checked (recursively, so also children of children, etc). If null is specified, + the root scene node is taken as start-node. */ + virtual void getSceneNodesFromType(ESCENE_NODE_TYPE type, + core::array &outNodes, + ISceneNode *start = 0) = 0; + + //! Get the current active camera. + /** \return The active camera is returned. Note that this can + be NULL, if there was no camera created yet. + This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ + virtual ICameraSceneNode *getActiveCamera() const = 0; + + //! Sets the currently active camera. + /** The previous active camera will be deactivated. + \param camera: The new camera which should be active. */ + virtual void setActiveCamera(ICameraSceneNode *camera) = 0; + + //! Registers a node for rendering it at a specific time. + /** This method should only be used by SceneNodes when they get a + ISceneNode::OnRegisterSceneNode() call. + \param node: Node to register for drawing. Usually scene nodes would set 'this' + as parameter here because they want to be drawn. + \param pass: Specifies when the node wants to be drawn in relation to the other nodes. + For example, if the node is a shadow, it usually wants to be drawn after all other nodes + and will use ESNRP_SHADOW for this. See scene::E_SCENE_NODE_RENDER_PASS for details. + Note: This is _not_ a bitfield. If you want to register a note for several render passes, then + call this function once for each pass. + \return scene will be rendered ( passed culling ) */ + virtual u32 registerNodeForRendering(ISceneNode *node, + E_SCENE_NODE_RENDER_PASS pass = ESNRP_AUTOMATIC) = 0; + + //! Clear all nodes which are currently registered for rendering + /** Usually you don't have to care about this as drawAll will clear nodes + after rendering them. But sometimes you might have to manually reset this. + For example when you deleted nodes between registering and rendering. */ + virtual void clearAllRegisteredNodesForRendering() = 0; + + //! Draws all the scene nodes. + /** This can only be invoked between + IVideoDriver::beginScene() and IVideoDriver::endScene(). Please note that + the scene is not only drawn when calling this, but also animated + by existing scene node animators, culling of scene nodes is done, etc. */ + virtual void drawAll() = 0; + + //! Adds an external mesh loader for extending the engine with new file formats. + /** If you want the engine to be extended with + file formats it currently is not able to load (e.g. .cob), just implement + the IMeshLoader interface in your loading class and add it with this method. + Using this method it is also possible to override built-in mesh loaders with + newer or updated versions without the need to recompile the engine. + \param externalLoader: Implementation of a new mesh loader. */ + virtual void addExternalMeshLoader(IMeshLoader *externalLoader) = 0; + + //! Returns the number of mesh loaders supported by Irrlicht at this time + virtual u32 getMeshLoaderCount() const = 0; + + //! Retrieve the given mesh loader + /** \param index The index of the loader to retrieve. This parameter is an 0-based + array index. + \return A pointer to the specified loader, 0 if the index is incorrect. */ + virtual IMeshLoader *getMeshLoader(u32 index) const = 0; + + //! Get pointer to the scene collision manager. + /** \return Pointer to the collision manager + This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ + virtual ISceneCollisionManager *getSceneCollisionManager() = 0; + + //! Get pointer to the mesh manipulator. + /** \return Pointer to the mesh manipulator + This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ + virtual IMeshManipulator *getMeshManipulator() = 0; + + //! Adds a scene node to the deletion queue. + /** The scene node is immediately + deleted when it's secure. Which means when the scene node does not + execute animators and things like that. This method is for example + used for deleting scene nodes by their scene node animators. In + most other cases, a ISceneNode::remove() call is enough, using this + deletion queue is not necessary. + See ISceneManager::createDeleteAnimator() for details. + \param node: Node to delete. */ + virtual void addToDeletionQueue(ISceneNode *node) = 0; + + //! Posts an input event to the environment. + /** Usually you do not have to + use this method, it is used by the internal engine. */ + virtual bool postEventFromUser(const SEvent &event) = 0; + + //! Clears the whole scene. + /** All scene nodes are removed. */ + virtual void clear() = 0; + + //! Get interface to the parameters set in this scene. + /** String parameters can be used by plugins and mesh loaders. + See COLLADA_CREATE_SCENE_INSTANCES and DMF_USE_MATERIALS_DIRS */ + virtual io::IAttributes *getParameters() = 0; + + //! Get current render pass. + /** All scene nodes are being rendered in a specific order. + First lights, cameras, sky boxes, solid geometry, and then transparent + stuff. During the rendering process, scene nodes may want to know what the scene + manager is rendering currently, because for example they registered for rendering + twice, once for transparent geometry and once for solid. When knowing what rendering + pass currently is active they can render the correct part of their geometry. */ + virtual E_SCENE_NODE_RENDER_PASS getSceneNodeRenderPass() const = 0; + + //! Creates a new scene manager. + /** This can be used to easily draw and/or store two + independent scenes at the same time. The mesh cache will be + shared between all existing scene managers, which means if you + load a mesh in the original scene manager using for example + getMesh(), the mesh will be available in all other scene + managers too, without loading. + The original/main scene manager will still be there and + accessible via IrrlichtDevice::getSceneManager(). If you need + input event in this new scene manager, for example for FPS + cameras, you'll need to forward input to this manually: Just + implement an IEventReceiver and call + yourNewSceneManager->postEventFromUser(), and return true so + that the original scene manager doesn't get the event. + Otherwise, all input will go to the main scene manager + automatically. + If you no longer need the new scene manager, you should call + ISceneManager::drop(). + See IReferenceCounted::drop() for more information. */ + virtual ISceneManager *createNewSceneManager(bool cloneContent = false) = 0; + + //! Get a skinned mesh, which is not available as header-only code + /** Note: You need to drop() the pointer after use again, see IReferenceCounted::drop() + for details. */ + virtual ISkinnedMesh *createSkinnedMesh() = 0; + + //! Sets ambient color of the scene + virtual void setAmbientLight(const video::SColorf &ambientColor) = 0; + + //! Get ambient color of the scene + virtual const video::SColorf &getAmbientLight() const = 0; + + //! Get current render pass. + virtual E_SCENE_NODE_RENDER_PASS getCurrentRenderPass() const = 0; + + //! Set current render pass. + virtual void setCurrentRenderPass(E_SCENE_NODE_RENDER_PASS nextPass) = 0; + + //! Check if node is culled in current view frustum + /** Please note that depending on the used culling method this + check can be rather coarse, or slow. A positive result is + correct, though, i.e. if this method returns true the node is + positively not visible. The node might still be invisible even + if this method returns false. + \param node The scene node which is checked for culling. + \return True if node is not visible in the current scene, else + false. */ + virtual bool isCulled(const ISceneNode *node) const = 0; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/ISceneNode.h b/irr/include/ISceneNode.h new file mode 100644 index 000000000..7a03a2256 --- /dev/null +++ b/irr/include/ISceneNode.h @@ -0,0 +1,597 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "ESceneNodeTypes.h" +#include "ECullingTypes.h" +#include "EDebugSceneTypes.h" +#include "SMaterial.h" +#include "irrString.h" +#include "aabbox3d.h" +#include "matrix4.h" +#include "IAttributes.h" + +#include +#include + +namespace irr +{ +namespace scene +{ +class ISceneNode; +class ISceneManager; + +//! Typedef for list of scene nodes +typedef std::list ISceneNodeList; + +//! Scene node interface. +/** A scene node is a node in the hierarchical scene graph. Every scene +node may have children, which are also scene nodes. Children move +relative to their parent's position. If the parent of a node is not +visible, its children won't be visible either. In this way, it is for +example easily possible to attach a light to a moving car, or to place +a walking character on a moving platform on a moving ship. +*/ +class ISceneNode : virtual public IReferenceCounted +{ +public: + //! Constructor + ISceneNode(ISceneNode *parent, ISceneManager *mgr, s32 id = -1, + const core::vector3df &position = core::vector3df(0, 0, 0), + const core::vector3df &rotation = core::vector3df(0, 0, 0), + const core::vector3df &scale = core::vector3df(1.0f, 1.0f, 1.0f)) : + RelativeTranslation(position), + RelativeRotation(rotation), RelativeScale(scale), + Parent(0), SceneManager(mgr), ID(id), + AutomaticCullingState(EAC_BOX), DebugDataVisible(EDS_OFF), + IsVisible(true), IsDebugObject(false) + { + if (parent) + parent->addChild(this); + + updateAbsolutePosition(); + } + + //! Destructor + virtual ~ISceneNode() + { + // delete all children + removeAll(); + } + + //! This method is called just before the rendering process of the whole scene. + /** Nodes may register themselves in the render pipeline during this call, + precalculate the geometry which should be rendered, and prevent their + children from being able to register themselves if they are clipped by simply + not calling their OnRegisterSceneNode method. + If you are implementing your own scene node, you should overwrite this method + with an implementation code looking like this: + \code + if (IsVisible) + SceneManager->registerNodeForRendering(this); + + ISceneNode::OnRegisterSceneNode(); + \endcode + */ + virtual void OnRegisterSceneNode() + { + if (IsVisible) { + ISceneNodeList::iterator it = Children.begin(); + for (; it != Children.end(); ++it) + (*it)->OnRegisterSceneNode(); + } + } + + //! OnAnimate() is called just before rendering the whole scene. + /** Nodes may calculate or store animations here, and may do other useful things, + depending on what they are. Also, OnAnimate() should be called for all + child scene nodes here. This method will be called once per frame, independent + of whether the scene node is visible or not. + \param timeMs Current time in milliseconds. */ + virtual void OnAnimate(u32 timeMs) + { + if (IsVisible) { + // update absolute position + updateAbsolutePosition(); + + // perform the post render process on all children + + ISceneNodeList::iterator it = Children.begin(); + for (; it != Children.end(); ++it) + (*it)->OnAnimate(timeMs); + } + } + + //! Renders the node. + virtual void render() = 0; + + //! Returns the name of the node. + /** \return Name as character string. */ + virtual const std::optional &getName() const + { + return Name; + } + + //! Sets the name of the node. + /** \param name New name of the scene node. */ + virtual void setName(const std::optional &name) + { + Name = name; + } + + //! Get the axis aligned, not transformed bounding box of this node. + /** This means that if this node is an animated 3d character, + moving in a room, the bounding box will always be around the + origin. To get the box in real world coordinates, just + transform it with the matrix you receive with + getAbsoluteTransformation() or simply use + getTransformedBoundingBox(), which does the same. + \return The non-transformed bounding box. */ + virtual const core::aabbox3d &getBoundingBox() const = 0; + + //! Get the axis aligned, transformed and animated absolute bounding box of this node. + /** Note: The result is still an axis-aligned bounding box, so it's size + changes with rotation. + \return The transformed bounding box. */ + virtual const core::aabbox3d getTransformedBoundingBox() const + { + core::aabbox3d box = getBoundingBox(); + AbsoluteTransformation.transformBoxEx(box); + return box; + } + + //! Get a the 8 corners of the original bounding box transformed and + //! animated by the absolute transformation. + /** Note: The result is _not_ identical to getTransformedBoundingBox().getEdges(), + but getting an aabbox3d of these edges would then be identical. + \param edges Receives an array with the transformed edges */ + virtual void getTransformedBoundingBoxEdges(core::array> &edges) const + { + edges.set_used(8); + getBoundingBox().getEdges(edges.pointer()); + for (u32 i = 0; i < 8; ++i) + AbsoluteTransformation.transformVect(edges[i]); + } + + //! Get the absolute transformation of the node. Is recalculated every OnAnimate()-call. + /** NOTE: For speed reasons the absolute transformation is not + automatically recalculated on each change of the relative + transformation or by a transformation change of an parent. Instead the + update usually happens once per frame in OnAnimate. You can enforce + an update with updateAbsolutePosition(). + \return The absolute transformation matrix. */ + virtual const core::matrix4 &getAbsoluteTransformation() const + { + return AbsoluteTransformation; + } + + //! Returns the relative transformation of the scene node. + /** The relative transformation is stored internally as 3 + vectors: translation, rotation and scale. To get the relative + transformation matrix, it is calculated from these values. + \return The relative transformation matrix. */ + virtual core::matrix4 getRelativeTransformation() const + { + core::matrix4 mat; + mat.setRotationDegrees(RelativeRotation); + mat.setTranslation(RelativeTranslation); + + if (RelativeScale != core::vector3df(1.f, 1.f, 1.f)) { + core::matrix4 smat; + smat.setScale(RelativeScale); + mat *= smat; + } + + return mat; + } + + //! Returns whether the node should be visible (if all of its parents are visible). + /** This is only an option set by the user, but has nothing to + do with geometry culling + \return The requested visibility of the node, true means + visible (if all parents are also visible). */ + virtual bool isVisible() const + { + return IsVisible; + } + + //! Check whether the node is truly visible, taking into accounts its parents' visibility + /** \return true if the node and all its parents are visible, + false if this or any parent node is invisible. */ + virtual bool isTrulyVisible() const + { + if (!IsVisible) + return false; + + if (!Parent) + return true; + + return Parent->isTrulyVisible(); + } + + //! Sets if the node should be visible or not. + /** All children of this node won't be visible either, when set + to false. Invisible nodes are not valid candidates for selection by + collision manager bounding box methods. + \param isVisible If the node shall be visible. */ + virtual void setVisible(bool isVisible) + { + IsVisible = isVisible; + } + + //! Get the id of the scene node. + /** This id can be used to identify the node. + \return The id. */ + virtual s32 getID() const + { + return ID; + } + + //! Sets the id of the scene node. + /** This id can be used to identify the node. + \param id The new id. */ + virtual void setID(s32 id) + { + ID = id; + } + + //! Adds a child to this scene node. + /** If the scene node already has a parent it is first removed + from the other parent. + \param child A pointer to the new child. */ + virtual void addChild(ISceneNode *child) + { + if (child && (child != this)) { + // Change scene manager? + if (SceneManager != child->SceneManager) + child->setSceneManager(SceneManager); + + child->grab(); + child->remove(); // remove from old parent + // Note: This iterator is not invalidated until we erase it. + child->ThisIterator = Children.insert(Children.end(), child); + child->Parent = this; + } + } + + //! Removes a child from this scene node. + /** + \param child A pointer to the child which shall be removed. + \return True if the child was removed, and false if not, + e.g. because it belongs to a different parent or no parent. */ + virtual bool removeChild(ISceneNode *child) + { + if (child->Parent != this) + return false; + + // The iterator must be set since the parent is not null. + _IRR_DEBUG_BREAK_IF(!child->ThisIterator.has_value()); + auto it = *child->ThisIterator; + child->ThisIterator = std::nullopt; + child->Parent = nullptr; + child->drop(); + Children.erase(it); + return true; + } + + //! Removes all children of this scene node + /** The scene nodes found in the children list are also dropped + and might be deleted if no other grab exists on them. + */ + virtual void removeAll() + { + for (auto &child : Children) { + child->Parent = nullptr; + child->ThisIterator = std::nullopt; + child->drop(); + } + Children.clear(); + } + + //! Removes this scene node from the scene + /** If no other grab exists for this node, it will be deleted. + */ + virtual void remove() + { + if (Parent) + Parent->removeChild(this); + } + + //! Returns the material based on the zero based index i. + /** To get the amount of materials used by this scene node, use + getMaterialCount(). This function is needed for inserting the + node into the scene hierarchy at an optimal position for + minimizing renderstate changes, but can also be used to + directly modify the material of a scene node. + \param num Zero based index. The maximal value is getMaterialCount() - 1. + \return The material at that index. */ + virtual video::SMaterial &getMaterial(u32 num) + { + return video::IdentityMaterial; + } + + //! Get amount of materials used by this scene node. + /** \return Current amount of materials of this scene node. */ + virtual u32 getMaterialCount() const + { + return 0; + } + + //! Execute a function on all materials of this scene node. + /** Useful for setting material properties, e.g. if you want the whole + mesh to be affected by light. */ + template + void forEachMaterial(F &&fn) + { + for (u32 i = 0; i < getMaterialCount(); i++) { + fn(getMaterial(i)); + } + } + + //! Gets the scale of the scene node relative to its parent. + /** This is the scale of this node relative to its parent. + If you want the absolute scale, use + getAbsoluteTransformation().getScale() + \return The scale of the scene node. */ + virtual const core::vector3df &getScale() const + { + return RelativeScale; + } + + //! Sets the relative scale of the scene node. + /** \param scale New scale of the node, relative to its parent. */ + virtual void setScale(const core::vector3df &scale) + { + RelativeScale = scale; + } + + //! Gets the rotation of the node relative to its parent. + /** Note that this is the relative rotation of the node. + If you want the absolute rotation, use + getAbsoluteTransformation().getRotation() + \return Current relative rotation of the scene node. */ + virtual const core::vector3df &getRotation() const + { + return RelativeRotation; + } + + //! Sets the rotation of the node relative to its parent. + /** This only modifies the relative rotation of the node. + \param rotation New rotation of the node in degrees. */ + virtual void setRotation(const core::vector3df &rotation) + { + RelativeRotation = rotation; + } + + //! Gets the position of the node relative to its parent. + /** Note that the position is relative to the parent. If you want + the position in world coordinates, use getAbsolutePosition() instead. + \return The current position of the node relative to the parent. */ + virtual const core::vector3df &getPosition() const + { + return RelativeTranslation; + } + + //! Sets the position of the node relative to its parent. + /** Note that the position is relative to the parent. + \param newpos New relative position of the scene node. */ + virtual void setPosition(const core::vector3df &newpos) + { + RelativeTranslation = newpos; + } + + //! Gets the absolute position of the node in world coordinates. + /** If you want the position of the node relative to its parent, + use getPosition() instead. + NOTE: For speed reasons the absolute position is not + automatically recalculated on each change of the relative + position or by a position change of an parent. Instead the + update usually happens once per frame in OnAnimate. You can enforce + an update with updateAbsolutePosition(). + \return The current absolute position of the scene node (updated on last call of updateAbsolutePosition). */ + virtual core::vector3df getAbsolutePosition() const + { + return AbsoluteTransformation.getTranslation(); + } + + //! Set a culling style or disable culling completely. + /** Box cullling (EAC_BOX) is set by default. Note that not + all SceneNodes support culling and that some nodes always cull + their geometry because it is their only reason for existence, + for example the OctreeSceneNode. + \param state The culling state to be used. Check E_CULLING_TYPE for possible values.*/ + void setAutomaticCulling(u32 state) + { + AutomaticCullingState = state; + } + + //! Gets the automatic culling state. + /** \return The automatic culling state. */ + u32 getAutomaticCulling() const + { + return AutomaticCullingState; + } + + //! Sets if debug data like bounding boxes should be drawn. + /** A bitwise OR of the types from @ref irr::scene::E_DEBUG_SCENE_TYPE. + Please note that not all scene nodes support all debug data types. + \param state The debug data visibility state to be used. */ + virtual void setDebugDataVisible(u32 state) + { + DebugDataVisible = state; + } + + //! Returns if debug data like bounding boxes are drawn. + /** \return A bitwise OR of the debug data values from + @ref irr::scene::E_DEBUG_SCENE_TYPE that are currently visible. */ + u32 isDebugDataVisible() const + { + return DebugDataVisible; + } + + //! Sets if this scene node is a debug object. + /** Debug objects have some special properties, for example they can be easily + excluded from collision detection or from serialization, etc. */ + void setIsDebugObject(bool debugObject) + { + IsDebugObject = debugObject; + } + + //! Returns if this scene node is a debug object. + /** Debug objects have some special properties, for example they can be easily + excluded from collision detection or from serialization, etc. + \return If this node is a debug object, true is returned. */ + bool isDebugObject() const + { + return IsDebugObject; + } + + //! Returns a const reference to the list of all children. + /** \return The list of all children of this node. */ + const std::list &getChildren() const + { + return Children; + } + + //! Changes the parent of the scene node. + /** \param newParent The new parent to be used. */ + virtual void setParent(ISceneNode *newParent) + { + grab(); + remove(); + + if (newParent) + newParent->addChild(this); + + drop(); + } + + //! Updates the absolute position based on the relative and the parents position + /** Note: This does not recursively update the parents absolute positions, so if you have a deeper + hierarchy you might want to update the parents first.*/ + virtual void updateAbsolutePosition() + { + if (Parent) { + AbsoluteTransformation = + Parent->getAbsoluteTransformation() * getRelativeTransformation(); + } else + AbsoluteTransformation = getRelativeTransformation(); + } + + //! Returns the parent of this scene node + /** \return A pointer to the parent. */ + scene::ISceneNode *getParent() const + { + return Parent; + } + + //! Returns type of the scene node + /** \return The type of this node. */ + virtual ESCENE_NODE_TYPE getType() const + { + return ESNT_UNKNOWN; + } + + //! Creates a clone of this scene node and its children. + /** \param newParent An optional new parent. + \param newManager An optional new scene manager. + \return The newly created clone of this node. */ + virtual ISceneNode *clone(ISceneNode *newParent = 0, ISceneManager *newManager = 0) + { + return 0; // to be implemented by derived classes + } + + //! Retrieve the scene manager for this node. + /** \return The node's scene manager. */ + virtual ISceneManager *getSceneManager(void) const { return SceneManager; } + +protected: + //! A clone function for the ISceneNode members. + /** This method can be used by clone() implementations of + derived classes + \param toCopyFrom The node from which the values are copied + \param newManager The new scene manager. */ + void cloneMembers(ISceneNode *toCopyFrom, ISceneManager *newManager) + { + Name = toCopyFrom->Name; + AbsoluteTransformation = toCopyFrom->AbsoluteTransformation; + RelativeTranslation = toCopyFrom->RelativeTranslation; + RelativeRotation = toCopyFrom->RelativeRotation; + RelativeScale = toCopyFrom->RelativeScale; + ID = toCopyFrom->ID; + AutomaticCullingState = toCopyFrom->AutomaticCullingState; + DebugDataVisible = toCopyFrom->DebugDataVisible; + IsVisible = toCopyFrom->IsVisible; + IsDebugObject = toCopyFrom->IsDebugObject; + + if (newManager) + SceneManager = newManager; + else + SceneManager = toCopyFrom->SceneManager; + + // clone children + + ISceneNodeList::iterator it = toCopyFrom->Children.begin(); + for (; it != toCopyFrom->Children.end(); ++it) + (*it)->clone(this, newManager); + } + + //! Sets the new scene manager for this node and all children. + //! Called by addChild when moving nodes between scene managers + void setSceneManager(ISceneManager *newManager) + { + SceneManager = newManager; + + ISceneNodeList::iterator it = Children.begin(); + for (; it != Children.end(); ++it) + (*it)->setSceneManager(newManager); + } + + //! Name of the scene node. + std::optional Name; + + //! Absolute transformation of the node. + core::matrix4 AbsoluteTransformation; + + //! Relative translation of the scene node. + core::vector3df RelativeTranslation; + + //! Relative rotation of the scene node. + core::vector3df RelativeRotation; + + //! Relative scale of the scene node. + core::vector3df RelativeScale; + + //! List of all children of this node + std::list Children; + + //! Iterator pointing to this node in the parent's child list. + std::optional ThisIterator; + + //! Pointer to the parent + ISceneNode *Parent; + + //! Pointer to the scene manager + ISceneManager *SceneManager; + + //! ID of the node. + s32 ID; + + //! Automatic culling state + u32 AutomaticCullingState; + + //! Flag if debug data should be drawn, such as Bounding Boxes. + u32 DebugDataVisible; + + //! Is the node visible? + bool IsVisible; + + //! Is debug object? + bool IsDebugObject; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/IShaderConstantSetCallBack.h b/irr/include/IShaderConstantSetCallBack.h new file mode 100644 index 000000000..2e37a34ae --- /dev/null +++ b/irr/include/IShaderConstantSetCallBack.h @@ -0,0 +1,79 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" + +namespace irr +{ +namespace video +{ +class IMaterialRendererServices; +class SMaterial; + +//! Interface making it possible to set constants for gpu programs every frame. +/** Implement this interface in an own class and pass a pointer to it to one of +the methods in IGPUProgrammingServices when creating a shader. The +OnSetConstants method will be called every frame now. */ +class IShaderConstantSetCallBack : public virtual IReferenceCounted +{ +public: + //! Called to let the callBack know the used material (optional method) + /** + \code + class MyCallBack : public IShaderConstantSetCallBack + { + const video::SMaterial *UsedMaterial; + + OnSetMaterial(const video::SMaterial& material) + { + UsedMaterial=&material; + } + + OnSetConstants(IMaterialRendererServices* services, s32 userData) + { + services->setVertexShaderConstant("myColor", reinterpret_cast(&UsedMaterial->color), 4); + } + } + \endcode + */ + virtual void OnSetMaterial(const SMaterial &material) {} + + //! Called by the engine when the vertex and/or pixel shader constants for an material renderer should be set. + /** + Implement the IShaderConstantSetCallBack in an own class and implement your own + OnSetConstants method using the given IMaterialRendererServices interface. + Pass a pointer to this class to one of the methods in IGPUProgrammingServices + when creating a shader. The OnSetConstants method will now be called every time + before geometry is being drawn using your shader material. A sample implementation + would look like this: + \code + virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData) + { + video::IVideoDriver* driver = services->getVideoDriver(); + + // set clip matrix at register 4 + core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION)); + worldViewProj *= driver->getTransform(video::ETS_VIEW); + worldViewProj *= driver->getTransform(video::ETS_WORLD); + services->setVertexShaderConstant(&worldViewProj.M[0], 4, 4); + // for high level shading languages, this would be another solution: + //services->setVertexShaderConstant("mWorldViewProj", worldViewProj.M, 16); + + // set some light color at register 9 + video::SColorf col(0.0f,1.0f,1.0f,0.0f); + services->setVertexShaderConstant(reinterpret_cast(&col), 9, 1); + // for high level shading languages, this would be another solution: + //services->setVertexShaderConstant("myColor", reinterpret_cast(&col), 4); + } + \endcode + \param services: Pointer to an interface providing methods to set the constants for the shader. + \param userData: Userdata int which can be specified when creating the shader. + */ + virtual void OnSetConstants(IMaterialRendererServices *services, s32 userData) = 0; +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/include/ISkinnedMesh.h b/irr/include/ISkinnedMesh.h new file mode 100644 index 000000000..9cc7469cb --- /dev/null +++ b/irr/include/ISkinnedMesh.h @@ -0,0 +1,220 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrArray.h" +#include "IBoneSceneNode.h" +#include "IAnimatedMesh.h" +#include "SSkinMeshBuffer.h" + +#include + +namespace irr +{ +namespace scene +{ + +enum E_INTERPOLATION_MODE +{ + // constant does use the current key-values without interpolation + EIM_CONSTANT = 0, + + // linear interpolation + EIM_LINEAR, + + //! count of all available interpolation modes + EIM_COUNT +}; + +//! Interface for using some special functions of Skinned meshes +class ISkinnedMesh : public IAnimatedMesh +{ +public: + //! Gets joint count. + /** \return Amount of joints in the skeletal animated mesh. */ + virtual u32 getJointCount() const = 0; + + //! Gets the name of a joint. + /** \param number: Zero based index of joint. The last joint + has the number getJointCount()-1; + \return Name of joint and null if an error happened. */ + virtual const std::optional &getJointName(u32 number) const = 0; + + //! Gets a joint number from its name + /** \param name: Name of the joint. + \return Number of the joint or std::nullopt if not found. */ + virtual std::optional getJointNumber(const std::string &name) const = 0; + + //! Use animation from another mesh + /** The animation is linked (not copied) based on joint names + so make sure they are unique. + \return True if all joints in this mesh were + matched up (empty names will not be matched, and it's case + sensitive). Unmatched joints will not be animated. */ + virtual bool useAnimationFrom(const ISkinnedMesh *mesh) = 0; + + //! Update Normals when Animating + /** \param on If false don't animate, which is faster. + Else update normals, which allows for proper lighting of + animated meshes. */ + virtual void updateNormalsWhenAnimating(bool on) = 0; + + //! Sets Interpolation Mode + virtual void setInterpolationMode(E_INTERPOLATION_MODE mode) = 0; + + //! Animates this mesh's joints based on frame input + virtual void animateMesh(f32 frame, f32 blend) = 0; + + //! Preforms a software skin on this mesh based of joint positions + virtual void skinMesh() = 0; + + //! converts the vertex type of all meshbuffers to tangents. + /** E.g. used for bump mapping. */ + virtual void convertMeshToTangents() = 0; + + //! Allows to enable hardware skinning. + /* This feature is not implemented in Irrlicht yet */ + virtual bool setHardwareSkinning(bool on) = 0; + + //! Refreshes vertex data cached in joints such as positions and normals + virtual void refreshJointCache() = 0; + + //! Moves the mesh into static position. + virtual void resetAnimation() = 0; + + //! A vertex weight + struct SWeight + { + //! Index of the mesh buffer + u16 buffer_id; // I doubt 32bits is needed + + //! Index of the vertex + u32 vertex_id; // Store global ID here + + //! Weight Strength/Percentage (0-1) + f32 strength; + + private: + //! Internal members used by CSkinnedMesh + friend class CSkinnedMesh; + char *Moved; + core::vector3df StaticPos; + core::vector3df StaticNormal; + }; + + //! Animation keyframe which describes a new position + struct SPositionKey + { + f32 frame; + core::vector3df position; + }; + + //! Animation keyframe which describes a new scale + struct SScaleKey + { + f32 frame; + core::vector3df scale; + }; + + //! Animation keyframe which describes a new rotation + struct SRotationKey + { + f32 frame; + core::quaternion rotation; + }; + + //! Joints + struct SJoint + { + SJoint() : + UseAnimationFrom(0), GlobalSkinningSpace(false), + positionHint(-1), scaleHint(-1), rotationHint(-1) + { + } + + //! The name of this joint + std::optional Name; + + //! Local matrix of this joint + core::matrix4 LocalMatrix; + + //! List of child joints + core::array Children; + + //! List of attached meshes + core::array AttachedMeshes; + + //! Animation keys causing translation change + core::array PositionKeys; + + //! Animation keys causing scale change + core::array ScaleKeys; + + //! Animation keys causing rotation change + core::array RotationKeys; + + //! Skin weights + core::array Weights; + + //! Unnecessary for loaders, will be overwritten on finalize + core::matrix4 GlobalMatrix; + core::matrix4 GlobalAnimatedMatrix; + core::matrix4 LocalAnimatedMatrix; + core::vector3df Animatedposition; + core::vector3df Animatedscale; + core::quaternion Animatedrotation; + + core::matrix4 GlobalInversedMatrix; // the x format pre-calculates this + + private: + //! Internal members used by CSkinnedMesh + friend class CSkinnedMesh; + + SJoint *UseAnimationFrom; + bool GlobalSkinningSpace; + + s32 positionHint; + s32 scaleHint; + s32 rotationHint; + }; + + // Interface for the mesh loaders (finalize should lock these functions, and they should have some prefix like loader_ + + // these functions will use the needed arrays, set values, etc to help the loaders + + //! exposed for loaders: to add mesh buffers + virtual core::array &getMeshBuffers() = 0; + + //! exposed for loaders: joints list + virtual core::array &getAllJoints() = 0; + + //! exposed for loaders: joints list + virtual const core::array &getAllJoints() const = 0; + + //! loaders should call this after populating the mesh + virtual void finalize() = 0; + + //! Adds a new meshbuffer to the mesh, access it as last one + virtual SSkinMeshBuffer *addMeshBuffer() = 0; + + //! Adds a new joint to the mesh, access it as last one + virtual SJoint *addJoint(SJoint *parent = 0) = 0; + + //! Adds a new weight to the mesh, access it as last one + virtual SWeight *addWeight(SJoint *joint) = 0; + + //! Adds a new position key to the mesh, access it as last one + virtual SPositionKey *addPositionKey(SJoint *joint) = 0; + //! Adds a new scale key to the mesh, access it as last one + virtual SScaleKey *addScaleKey(SJoint *joint) = 0; + //! Adds a new rotation key to the mesh, access it as last one + virtual SRotationKey *addRotationKey(SJoint *joint) = 0; + + //! Check if the mesh is non-animated + virtual bool isStatic() = 0; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/ITexture.h b/irr/include/ITexture.h new file mode 100644 index 000000000..adca90e7b --- /dev/null +++ b/irr/include/ITexture.h @@ -0,0 +1,337 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "IImage.h" +#include "dimension2d.h" +#include "EDriverTypes.h" +#include "path.h" +#include "matrix4.h" + +namespace irr +{ +namespace video +{ + +//! Enumeration flags used to tell the video driver with setTextureCreationFlag in which format textures should be created. +enum E_TEXTURE_CREATION_FLAG +{ + /** Forces the driver to create 16 bit textures always, independent of + which format the file on disk has. When choosing this you may lose + some color detail, but gain much speed and memory. 16 bit textures can + be transferred twice as fast as 32 bit textures and only use half of + the space in memory. + When using this flag, it does not make sense to use the flags + ETCF_ALWAYS_32_BIT, ETCF_OPTIMIZED_FOR_QUALITY, or + ETCF_OPTIMIZED_FOR_SPEED at the same time. + Not all texture formats are affected (usually those up to ECF_A8R8G8B8). */ + ETCF_ALWAYS_16_BIT = 0x00000001, + + /** Forces the driver to create 32 bit textures always, independent of + which format the file on disk has. Please note that some drivers (like + the software device) will ignore this, because they are only able to + create and use 16 bit textures. + Default is true. + When using this flag, it does not make sense to use the flags + ETCF_ALWAYS_16_BIT, ETCF_OPTIMIZED_FOR_QUALITY, or + ETCF_OPTIMIZED_FOR_SPEED at the same time. + Not all texture formats are affected (usually those up to ECF_A8R8G8B8). */ + ETCF_ALWAYS_32_BIT = 0x00000002, + + /** Lets the driver decide in which format the textures are created and + tries to make the textures look as good as possible. Usually it simply + chooses the format in which the texture was stored on disk. + When using this flag, it does not make sense to use the flags + ETCF_ALWAYS_16_BIT, ETCF_ALWAYS_32_BIT, or ETCF_OPTIMIZED_FOR_SPEED at + the same time. + Not all texture formats are affected (usually those up to ECF_A8R8G8B8). */ + ETCF_OPTIMIZED_FOR_QUALITY = 0x00000004, + + /** Lets the driver decide in which format the textures are created and + tries to create them maximizing render speed. + When using this flag, it does not make sense to use the flags + ETCF_ALWAYS_16_BIT, ETCF_ALWAYS_32_BIT, or ETCF_OPTIMIZED_FOR_QUALITY, + at the same time. + Not all texture formats are affected (usually those up to ECF_A8R8G8B8). */ + ETCF_OPTIMIZED_FOR_SPEED = 0x00000008, + + /** Creates textures with mipmap levels. + If disabled textures can not have mipmaps. + Default is true. */ + ETCF_CREATE_MIP_MAPS = 0x00000010, + + /** Discard any alpha layer and use non-alpha color format. + Warning: This may lead to getting 24-bit texture formats which + are often badly supported by drivers. So it's generally + not recommended to enable this flag. */ + ETCF_NO_ALPHA_CHANNEL = 0x00000020, + + //! Allow the Driver to use Non-Power-2-Textures + /** BurningVideo can handle Non-Power-2 Textures in 2D (GUI), but not in 3D. */ + ETCF_ALLOW_NON_POWER_2 = 0x00000040, + + //! Allow the driver to keep a copy of the texture in memory + /** Enabling this makes calls to ITexture::lock a lot faster, but costs main memory. + Currently only used in combination with OpenGL drivers. + NOTE: Disabling this does not yet work correctly with alpha-textures. + So the default is on for now (but might change with Irrlicht 1.9 if we get the alpha-troubles fixed). + */ + ETCF_ALLOW_MEMORY_COPY = 0x00000080, + + //! Enable automatic updating mip maps when the base texture changes. + /** Default is true. + This flag is only used when ETCF_CREATE_MIP_MAPS is also enabled and if the driver supports it. + Please note: + - On D3D (and maybe older OGL?) you can no longer manually set mipmap data when enabled + (for example mips from image loading will be ignored). + - On D3D (and maybe older OGL?) texture locking for mipmap levels usually won't work anymore. + - On new OGL this flag is ignored. + - When disabled you do _not_ get hardware mipmaps on D3D, so mipmap generation can be slower. + - When disabled you can still update your mipmaps when the texture changed by manually calling regenerateMipMapLevels. + - You can still call regenerateMipMapLevels when this flag is enabled (it will be a hint on d3d to update mips immediately) + */ + ETCF_AUTO_GENERATE_MIP_MAPS = 0x00000100, + + /** This flag is never used, it only forces the compiler to compile + these enumeration values to 32 bit. */ + ETCF_FORCE_32_BIT_DO_NOT_USE = 0x7fffffff +}; + +//! Enum for the mode for texture locking. Read-Only, write-only or read/write. +enum E_TEXTURE_LOCK_MODE +{ + //! The default mode. Texture can be read and written to. + ETLM_READ_WRITE = 0, + + //! Read only. The texture is downloaded, but not uploaded again. + /** Often used to read back shader generated textures. */ + ETLM_READ_ONLY, + + //! Write only. The texture is not downloaded and might be uninitialized. + /** The updated texture is uploaded to the GPU. + Used for initializing the shader from the CPU. */ + ETLM_WRITE_ONLY +}; + +//! Additional bitflags for ITexture::lock() call +enum E_TEXTURE_LOCK_FLAGS +{ + ETLF_NONE = 0, + + //! Flip left-bottom origin rendertarget textures upside-down + /** Irrlicht usually has all textures with left-top as origin. + And for drivers with a left-bottom origin coordinate system (OpenGL) + Irrlicht modifies the texture-matrix in the fixed function pipeline to make + the textures show up correctly (shader coders have to handle upside down + textures themselves). + But rendertarget textures (RTT's) are written by drivers the way the + coordinate system of that driver works. So on OpenGL images tend to look + upside down (aka Y coordinate going up) on lock() when this flag isn't set. + When the flag is set it will flip such textures on lock() to make them look + like non-rtt textures (origin left-top). Note that this also means the texture + will be uploaded flipped on unlock. So mostly you want to have this flag set + when you want to look at the texture or save it, but unset if you want to + upload it again to the card. + If you disable this flag you get the memory just as it is on the graphic card. + For backward compatibility reasons this flag is enabled by default. */ + ETLF_FLIP_Y_UP_RTT = 1 +}; + +//! Where did the last IVideoDriver::getTexture call find this texture +enum E_TEXTURE_SOURCE +{ + //! IVideoDriver::getTexture was never called (texture created otherwise) + ETS_UNKNOWN, + + //! Texture has been found in cache + ETS_FROM_CACHE, + + //! Texture had to be loaded + ETS_FROM_FILE +}; + +//! Enumeration describing the type of ITexture. +enum E_TEXTURE_TYPE +{ + //! 2D texture. + ETT_2D, + + //! Cubemap texture. + ETT_CUBEMAP +}; + +//! Interface of a Video Driver dependent Texture. +/** An ITexture is created by an IVideoDriver by using IVideoDriver::addTexture +or IVideoDriver::getTexture. After that, the texture may only be used by this +VideoDriver. As you can imagine, textures of the DirectX and the OpenGL device +will, e.g., not be compatible. An exception is the Software device and the +NULL device, their textures are compatible. If you try to use a texture +created by one device with an other device, the device will refuse to do that +and write a warning or an error message to the output buffer. +*/ +class ITexture : public virtual IReferenceCounted +{ +public: + //! constructor + ITexture(const io::path &name, E_TEXTURE_TYPE type) : + NamedPath(name), DriverType(EDT_NULL), OriginalColorFormat(ECF_UNKNOWN), + ColorFormat(ECF_UNKNOWN), Pitch(0), HasMipMaps(false), IsRenderTarget(false), Source(ETS_UNKNOWN), Type(type) + { + } + + //! Lock function. + /** Locks the Texture and returns a pointer to access the + pixels. After lock() has been called and all operations on the pixels + are done, you must call unlock(). + Locks are not accumulating, hence one unlock will do for an arbitrary + number of previous locks. You should avoid locking different levels without + unlocking in between, though, because only the last level locked will be + unlocked. + The size of the i-th mipmap level is defined as max(getSize().Width>>i,1) + and max(getSize().Height>>i,1) + \param mode Specifies what kind of changes to the locked texture are + allowed. Unspecified behavior will arise if texture is written in read + only mode or read from in write only mode. + Support for this feature depends on the driver, so don't rely on the + texture being write-protected when locking with read-only, etc. + \param mipmapLevel NOTE: Currently broken, sorry, we try if we can repair it for 1.9 release. + Number of the mipmapLevel to lock. 0 is main texture. + Non-existing levels will silently fail and return 0. + \param layer It determines which cubemap face or texture array layer should be locked. + \param lockFlags See E_TEXTURE_LOCK_FLAGS documentation. + \return Returns a pointer to the pixel data. The format of the pixel can + be determined by using getColorFormat(). 0 is returned, if + the texture cannot be locked. */ + virtual void *lock(E_TEXTURE_LOCK_MODE mode = ETLM_READ_WRITE, u32 mipmapLevel = 0, u32 layer = 0, E_TEXTURE_LOCK_FLAGS lockFlags = ETLF_FLIP_Y_UP_RTT) = 0; + + //! Unlock function. Must be called after a lock() to the texture. + /** One should avoid to call unlock more than once before another lock. + The last locked mip level will be unlocked. + You may want to call regenerateMipMapLevels() after this when you changed any data. */ + virtual void unlock() = 0; + + //! Regenerates the mip map levels of the texture. + /** Required after modifying the texture, usually after calling unlock(). + \param data Optional parameter to pass in image data which will be + used instead of the previously stored or automatically generated mipmap + data. The data has to be a continuous pixel data for all mipmaps until + 1x1 pixel. Each mipmap has to be half the width and height of the previous + level. At least one pixel will be always kept. + \param layer It informs a texture about which cubemap or texture array layer + needs mipmap regeneration. */ + virtual void regenerateMipMapLevels(void *data = 0, u32 layer = 0) = 0; + + //! Get original size of the texture. + /** The texture is usually scaled, if it was created with an unoptimal + size. For example if the size was not a power of two. This method + returns the size of the texture it had before it was scaled. Can be + useful when drawing 2d images on the screen, which should have the + exact size of the original texture. Use ITexture::getSize() if you want + to know the real size it has now stored in the system. + \return The original size of the texture. */ + const core::dimension2d &getOriginalSize() const { return OriginalSize; }; + + //! Get dimension (=size) of the texture. + /** \return The size of the texture. */ + const core::dimension2d &getSize() const { return Size; }; + + //! Get driver type of texture. + /** This is the driver, which created the texture. This method is used + internally by the video devices, to check, if they may use a texture + because textures may be incompatible between different devices. + \return Driver type of texture. */ + E_DRIVER_TYPE getDriverType() const { return DriverType; }; + + //! Get the color format of texture. + /** \return The color format of texture. */ + ECOLOR_FORMAT getColorFormat() const { return ColorFormat; }; + + //! Get the original color format + /** When create textures from image data we will often use different color formats. + For example depending on driver TextureCreationFlag's. + This can give you the original format which the image used to create the texture had */ + ECOLOR_FORMAT getOriginalColorFormat() const { return OriginalColorFormat; }; + + //! Get pitch of the main texture (in bytes). + /** The pitch is the amount of bytes used for a row of pixels in a + texture. + \return Pitch of texture in bytes. */ + u32 getPitch() const { return Pitch; }; + + //! Check whether the texture has MipMaps + /** \return True if texture has MipMaps, else false. */ + bool hasMipMaps() const { return HasMipMaps; } + + //! Check whether the texture is a render target + /** Render targets can be set as such in the video driver, in order to + render a scene into the texture. Once unbound as render target, they can + be used just as usual textures again. + \return True if this is a render target, otherwise false. */ + bool isRenderTarget() const { return IsRenderTarget; } + + //! Get name of texture (in most cases this is the filename) + const io::SNamedPath &getName() const { return NamedPath; } + + //! Check where the last IVideoDriver::getTexture found this texture + E_TEXTURE_SOURCE getSource() const { return Source; } + + //! Used internally by the engine to update Source status on IVideoDriver::getTexture calls. + void updateSource(E_TEXTURE_SOURCE source) { Source = source; } + + //! Returns if the texture has an alpha channel + bool hasAlpha() const + { + bool status = false; + + switch (ColorFormat) { + case ECF_A8R8G8B8: + case ECF_A1R5G5B5: + case ECF_A16B16G16R16F: + case ECF_A32B32G32R32F: + status = true; + break; + default: + break; + } + + return status; + } + + //! Returns the type of texture + E_TEXTURE_TYPE getType() const { return Type; } + +protected: + //! Helper function, helps to get the desired texture creation format from the flags. + /** \return Either ETCF_ALWAYS_32_BIT, ETCF_ALWAYS_16_BIT, + ETCF_OPTIMIZED_FOR_QUALITY, or ETCF_OPTIMIZED_FOR_SPEED. */ + inline E_TEXTURE_CREATION_FLAG getTextureFormatFromFlags(u32 flags) + { + if (flags & ETCF_OPTIMIZED_FOR_SPEED) + return ETCF_OPTIMIZED_FOR_SPEED; + if (flags & ETCF_ALWAYS_16_BIT) + return ETCF_ALWAYS_16_BIT; + if (flags & ETCF_ALWAYS_32_BIT) + return ETCF_ALWAYS_32_BIT; + if (flags & ETCF_OPTIMIZED_FOR_QUALITY) + return ETCF_OPTIMIZED_FOR_QUALITY; + return ETCF_OPTIMIZED_FOR_SPEED; + } + + io::SNamedPath NamedPath; + core::dimension2d OriginalSize; + core::dimension2d Size; + E_DRIVER_TYPE DriverType; + ECOLOR_FORMAT OriginalColorFormat; + ECOLOR_FORMAT ColorFormat; + u32 Pitch; + bool HasMipMaps; + bool IsRenderTarget; + E_TEXTURE_SOURCE Source; + E_TEXTURE_TYPE Type; +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/include/ITimer.h b/irr/include/ITimer.h new file mode 100644 index 000000000..22c79f603 --- /dev/null +++ b/irr/include/ITimer.h @@ -0,0 +1,65 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" + +namespace irr +{ + +//! Interface for getting and manipulating the virtual time +class ITimer : public virtual IReferenceCounted +{ +public: + //! Returns current real time in milliseconds of the system. + /** This value does not start with 0 when the application starts. + For example in one implementation the value returned could be the + amount of milliseconds which have elapsed since the system was started. + */ + virtual u32 getRealTime() const = 0; + + //! Returns current virtual time in milliseconds. + /** This value starts with 0 and can be manipulated using setTime(), + stopTimer(), startTimer(), etc. This value depends on the set speed of + the timer if the timer is stopped, etc. If you need the system time, + use getRealTime() */ + virtual u32 getTime() const = 0; + + //! sets current virtual time + virtual void setTime(u32 time) = 0; + + //! Stops the virtual timer. + /** The timer is reference counted, which means everything which calls + stop() will also have to call start(), otherwise the timer may not + start/stop correctly again. */ + virtual void stop() = 0; + + //! Starts the virtual timer. + /** The timer is reference counted, which means everything which calls + stop() will also have to call start(), otherwise the timer may not + start/stop correctly again. */ + virtual void start() = 0; + + //! Sets the speed of the timer + /** The speed is the factor with which the time is running faster or + slower then the real system time. */ + virtual void setSpeed(f32 speed = 1.0f) = 0; + + //! Returns current speed of the timer + /** The speed is the factor with which the time is running faster or + slower then the real system time. */ + virtual f32 getSpeed() const = 0; + + //! Returns if the virtual timer is currently stopped + virtual bool isStopped() const = 0; + + //! Advances the virtual time + /** Makes the virtual timer update the time value based on the real + time. This is called automatically when calling IrrlichtDevice::run(), + but you can call it manually if you don't use this method. */ + virtual void tick() = 0; +}; + +} // end namespace irr diff --git a/irr/include/IVertexBuffer.h b/irr/include/IVertexBuffer.h new file mode 100644 index 000000000..a4ec5efd9 --- /dev/null +++ b/irr/include/IVertexBuffer.h @@ -0,0 +1,48 @@ +// Copyright (C) 2008-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "irrArray.h" +#include "EHardwareBufferFlags.h" +#include "S3DVertex.h" + +namespace irr +{ +namespace scene +{ + +class IVertexBuffer : public virtual IReferenceCounted +{ +public: + virtual void *getData() = 0; + virtual video::E_VERTEX_TYPE getType() const = 0; + virtual void setType(video::E_VERTEX_TYPE vertexType) = 0; + virtual u32 stride() const = 0; + virtual u32 size() const = 0; + virtual void push_back(const video::S3DVertex &element) = 0; + virtual video::S3DVertex &operator[](const u32 index) const = 0; + virtual video::S3DVertex &getLast() = 0; + virtual void set_used(u32 usedNow) = 0; + virtual void reallocate(u32 new_size) = 0; + virtual u32 allocated_size() const = 0; + virtual video::S3DVertex *pointer() = 0; + + //! get the current hardware mapping hint + virtual E_HARDWARE_MAPPING getHardwareMappingHint() const = 0; + + //! set the hardware mapping hint, for driver + virtual void setHardwareMappingHint(E_HARDWARE_MAPPING NewMappingHint) = 0; + + //! flags the meshbuffer as changed, reloads hardware buffers + virtual void setDirty() = 0; + + //! Get the currently used ID for identification of changes. + /** This shouldn't be used for anything outside the VideoDriver. */ + virtual u32 getChangedID() const = 0; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/IVideoDriver.h b/irr/include/IVideoDriver.h new file mode 100644 index 000000000..2d651c6bf --- /dev/null +++ b/irr/include/IVideoDriver.h @@ -0,0 +1,1207 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "rect.h" +#include "SColor.h" +#include "ITexture.h" +#include "irrArray.h" +#include "matrix4.h" +#include "plane3d.h" +#include "dimension2d.h" +#include "position2d.h" +#include "IMeshBuffer.h" +#include "EDriverTypes.h" +#include "EDriverFeatures.h" +#include "SExposedVideoData.h" +#include "SOverrideMaterial.h" + +namespace irr +{ +namespace io +{ +class IAttributes; +class IReadFile; +class IWriteFile; +} // end namespace io +namespace scene +{ +class IMeshBuffer; +class IMesh; +class IMeshManipulator; +class ISceneNode; +} // end namespace scene + +namespace video +{ +struct S3DVertex; +struct S3DVertex2TCoords; +struct S3DVertexTangents; +class IImageLoader; +class IImageWriter; +class IMaterialRenderer; +class IGPUProgrammingServices; +class IRenderTarget; + +//! enumeration for geometry transformation states +enum E_TRANSFORMATION_STATE +{ + //! View transformation + ETS_VIEW = 0, + //! World transformation + ETS_WORLD, + //! Projection transformation + ETS_PROJECTION, + //! Texture 0 transformation + //! Use E_TRANSFORMATION_STATE(ETS_TEXTURE_0 + texture_number) to access other texture transformations + ETS_TEXTURE_0, + //! Only used internally + ETS_COUNT = ETS_TEXTURE_0 + MATERIAL_MAX_TEXTURES +}; + +//! Special render targets, which usually map to dedicated hardware +/** These render targets (besides 0 and 1) need not be supported by gfx cards */ +enum E_RENDER_TARGET +{ + //! Render target is the main color frame buffer + ERT_FRAME_BUFFER = 0, + //! Render target is a render texture + ERT_RENDER_TEXTURE, + //! Multi-Render target textures + ERT_MULTI_RENDER_TEXTURES, + //! Render target is the main color frame buffer + ERT_STEREO_LEFT_BUFFER, + //! Render target is the right color buffer (left is the main buffer) + ERT_STEREO_RIGHT_BUFFER, + //! Render to both stereo buffers at once + ERT_STEREO_BOTH_BUFFERS, + //! Auxiliary buffer 0 + ERT_AUX_BUFFER0, + //! Auxiliary buffer 1 + ERT_AUX_BUFFER1, + //! Auxiliary buffer 2 + ERT_AUX_BUFFER2, + //! Auxiliary buffer 3 + ERT_AUX_BUFFER3, + //! Auxiliary buffer 4 + ERT_AUX_BUFFER4 +}; + +//! Enum for the flags of clear buffer +enum E_CLEAR_BUFFER_FLAG +{ + ECBF_NONE = 0, + ECBF_COLOR = 1, + ECBF_DEPTH = 2, + ECBF_STENCIL = 4, + ECBF_ALL = ECBF_COLOR | ECBF_DEPTH | ECBF_STENCIL +}; + +//! Enum for the types of fog distributions to choose from +enum E_FOG_TYPE +{ + EFT_FOG_EXP = 0, + EFT_FOG_LINEAR, + EFT_FOG_EXP2 +}; + +const c8 *const FogTypeNames[] = { + "FogExp", + "FogLinear", + "FogExp2", + 0, + }; + +//! Interface to driver which is able to perform 2d and 3d graphics functions. +/** This interface is one of the most important interfaces of +the Irrlicht Engine: All rendering and texture manipulation is done with +this interface. You are able to use the Irrlicht Engine by only +invoking methods of this interface if you like to, although the +irr::scene::ISceneManager interface provides a lot of powerful classes +and methods to make the programmer's life easier. +*/ +class IVideoDriver : public virtual IReferenceCounted +{ +public: + //! Applications must call this method before performing any rendering. + /** This method can clear the back- and the z-buffer. + \param clearFlag A combination of the E_CLEAR_BUFFER_FLAG bit-flags. + \param clearColor The clear color for the color buffer. + \param clearDepth The clear value for the depth buffer. + \param clearStencil The clear value for the stencil buffer. + \param videoData Handle of another window, if you want the + bitmap to be displayed on another window. If this is an empty + element, everything will be displayed in the default window. + Note: This feature is not fully implemented for all devices. + \param sourceRect Pointer to a rectangle defining the source + rectangle of the area to be presented. Set to null to present + everything. Note: not implemented in all devices. + \return False if failed. */ + virtual bool beginScene(u16 clearFlag = (u16)(ECBF_COLOR | ECBF_DEPTH), SColor clearColor = SColor(255, 0, 0, 0), f32 clearDepth = 1.f, u8 clearStencil = 0, + const SExposedVideoData &videoData = SExposedVideoData(), core::rect *sourceRect = 0) = 0; + + //! Alternative beginScene implementation. Can't clear stencil buffer, but otherwise identical to other beginScene + bool beginScene(bool backBuffer, bool zBuffer, SColor color = SColor(255, 0, 0, 0), + const SExposedVideoData &videoData = SExposedVideoData(), core::rect *sourceRect = 0) + { + u16 flag = 0; + + if (backBuffer) + flag |= ECBF_COLOR; + + if (zBuffer) + flag |= ECBF_DEPTH; + + return beginScene(flag, color, 1.f, 0, videoData, sourceRect); + } + + //! Presents the rendered image to the screen. + /** Applications must call this method after performing any + rendering. + \return False if failed and true if succeeded. */ + virtual bool endScene() = 0; + + //! Queries the features of the driver. + /** Returns true if a feature is available + \param feature Feature to query. + \return True if the feature is available, false if not. */ + virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const = 0; + + //! Disable a feature of the driver. + /** Can also be used to enable the features again. It is not + possible to enable unsupported features this way, though. + \param feature Feature to disable. + \param flag When true the feature is disabled, otherwise it is enabled. */ + virtual void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag = true) = 0; + + //! Get attributes of the actual video driver + /** The following names can be queried for the given types: + MaxTextures (int) The maximum number of simultaneous textures supported by the driver. This can be less than the supported number of textures of the driver. Use _IRR_MATERIAL_MAX_TEXTURES_ to adapt the number. + MaxSupportedTextures (int) The maximum number of simultaneous textures supported by the fixed function pipeline of the (hw) driver. The actual supported number of textures supported by the engine can be lower. + MaxLights (int) Number of hardware lights supported in the fixed function pipeline of the driver, typically 6-8. Use light manager or deferred shading for more. + MaxAnisotropy (int) Number of anisotropy levels supported for filtering. At least 1, max is typically at 16 or 32. + MaxUserClipPlanes (int) Number of additional clip planes, which can be set by the user via dedicated driver methods. + MaxAuxBuffers (int) Special render buffers, which are currently not really usable inside Irrlicht. Only supported by OpenGL + MaxMultipleRenderTargets (int) Number of render targets which can be bound simultaneously. Rendering to MRTs is done via shaders. + MaxIndices (int) Number of indices which can be used in one render call (i.e. one mesh buffer). + MaxTextureSize (int) Dimension that a texture may have, both in width and height. + MaxGeometryVerticesOut (int) Number of vertices the geometry shader can output in one pass. Only OpenGL so far. + MaxTextureLODBias (float) Maximum value for LOD bias. Is usually at around 16, but can be lower on some systems. + Version (int) Version of the driver. Should be Major*100+Minor + ShaderLanguageVersion (int) Version of the high level shader language. Should be Major*100+Minor. + AntiAlias (int) Number of Samples the driver uses for each pixel. 0 and 1 means anti aliasing is off, typical values are 2,4,8,16,32 + */ + virtual const io::IAttributes &getDriverAttributes() const = 0; + + //! Check if the driver was recently reset. + /** For d3d devices you will need to recreate the RTTs if the + driver was reset. Should be queried right after beginScene(). + */ + virtual bool checkDriverReset() = 0; + + //! Sets transformation matrices. + /** \param state Transformation type to be set, e.g. view, + world, or projection. + \param mat Matrix describing the transformation. */ + virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4 &mat) = 0; + + //! Returns the transformation set by setTransform + /** \param state Transformation type to query + \return Matrix describing the transformation. */ + virtual const core::matrix4 &getTransform(E_TRANSFORMATION_STATE state) const = 0; + + //! Retrieve the number of image loaders + /** \return Number of image loaders */ + virtual u32 getImageLoaderCount() const = 0; + + //! Retrieve the given image loader + /** \param n The index of the loader to retrieve. This parameter is an 0-based + array index. + \return A pointer to the specified loader, 0 if the index is incorrect. */ + virtual IImageLoader *getImageLoader(u32 n) = 0; + + //! Retrieve the number of image writers + /** \return Number of image writers */ + virtual u32 getImageWriterCount() const = 0; + + //! Retrieve the given image writer + /** \param n The index of the writer to retrieve. This parameter is an 0-based + array index. + \return A pointer to the specified writer, 0 if the index is incorrect. */ + virtual IImageWriter *getImageWriter(u32 n) = 0; + + //! Sets a material. + /** All 3d drawing functions will draw geometry using this material thereafter. + \param material: Material to be used from now on. */ + virtual void setMaterial(const SMaterial &material) = 0; + + //! Get access to a named texture. + /** Loads the texture from disk if it is not + already loaded and generates mipmap levels if desired. + Texture loading can be influenced using the + setTextureCreationFlag() method. The texture can be in several + imageformats, such as BMP, JPG, TGA, PCX, PNG, and PSD. + \param filename Filename of the texture to be loaded. + \return Pointer to the texture, or 0 if the texture + could not be loaded. This pointer should not be dropped. See + IReferenceCounted::drop() for more information. */ + virtual ITexture *getTexture(const io::path &filename) = 0; + + //! Get access to a named texture. + /** Loads the texture from disk if it is not + already loaded and generates mipmap levels if desired. + Texture loading can be influenced using the + setTextureCreationFlag() method. The texture can be in several + imageformats, such as BMP, JPG, TGA, PCX, PNG, and PSD. + \param file Pointer to an already opened file. + \return Pointer to the texture, or 0 if the texture + could not be loaded. This pointer should not be dropped. See + IReferenceCounted::drop() for more information. */ + virtual ITexture *getTexture(io::IReadFile *file) = 0; + + //! Returns amount of textures currently loaded + /** \return Amount of textures currently loaded */ + virtual u32 getTextureCount() const = 0; + + //! Creates an empty texture of specified size. + /** \param size: Size of the texture. + \param name A name for the texture. Later calls to + getTexture() with this name will return this texture. + The name can _not_ be empty. + \param format Desired color format of the texture. Please note + that the driver may choose to create the texture in another + color format. + \return Pointer to the newly created texture. This pointer + should not be dropped. See IReferenceCounted::drop() for more + information. */ + virtual ITexture *addTexture(const core::dimension2d &size, + const io::path &name, ECOLOR_FORMAT format = ECF_A8R8G8B8) = 0; + + //! Creates a texture from an IImage. + /** \param name A name for the texture. Later calls of + getTexture() with this name will return this texture. + The name can _not_ be empty. + \param image Image the texture is created from. + \return Pointer to the newly created texture. This pointer + should not be dropped. See IReferenceCounted::drop() for more + information. */ + virtual ITexture *addTexture(const io::path &name, IImage *image) = 0; + + //! Creates a cubemap texture from loaded IImages. + /** \param name A name for the texture. Later calls of getTexture() with this name will return this texture. + The name can _not_ be empty. + \param imagePosX Image (positive X) the texture is created from. + \param imageNegX Image (negative X) the texture is created from. + \param imagePosY Image (positive Y) the texture is created from. + \param imageNegY Image (negative Y) the texture is created from. + \param imagePosZ Image (positive Z) the texture is created from. + \param imageNegZ Image (negative Z) the texture is created from. + \return Pointer to the newly created texture. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ + virtual ITexture *addTextureCubemap(const io::path &name, IImage *imagePosX, IImage *imageNegX, IImage *imagePosY, + IImage *imageNegY, IImage *imagePosZ, IImage *imageNegZ) = 0; + + //! Creates an empty cubemap texture of specified size. + /** \param sideLen diameter of one side of the cube + \param name A name for the texture. Later calls of + getTexture() with this name will return this texture. + The name can _not_ be empty. + \param format Desired color format of the texture. Please note + that the driver may choose to create the texture in another + color format. + \return Pointer to the newly created texture. */ + virtual ITexture *addTextureCubemap(const irr::u32 sideLen, const io::path &name, ECOLOR_FORMAT format = ECF_A8R8G8B8) = 0; + + //! Adds a new render target texture to the texture cache. + /** \param size Size of the texture, in pixels. Width and + height should be a power of two (e.g. 64, 128, 256, 512, ...) + and it should not be bigger than the backbuffer, because it + shares the zbuffer with the screen buffer. + \param name A name for the texture. Later calls of getTexture() with this name will return this texture. + The name can _not_ be empty. + \param format The color format of the render target. Floating point formats are supported. + \return Pointer to the created texture or 0 if the texture + could not be created. This pointer should not be dropped. See + IReferenceCounted::drop() for more information. + You may want to remove it from driver texture cache with removeTexture if you no longer need it. + */ + virtual ITexture *addRenderTargetTexture(const core::dimension2d &size, + const io::path &name = "rt", const ECOLOR_FORMAT format = ECF_UNKNOWN) = 0; + + //! Adds a new render target texture with 6 sides for a cubemap map to the texture cache. + /** \param sideLen Length of one cubemap side. + \param name A name for the texture. Later calls of getTexture() with this name will return this texture. + The name can _not_ be empty. + \param format The color format of the render target. Floating point formats are supported. + \return Pointer to the created texture or 0 if the texture + could not be created. This pointer should not be dropped. See + IReferenceCounted::drop() for more information. */ + virtual ITexture *addRenderTargetTextureCubemap(const irr::u32 sideLen, + const io::path &name = "rt", const ECOLOR_FORMAT format = ECF_UNKNOWN) = 0; + + //! Removes a texture from the texture cache and deletes it. + /** This method can free a lot of memory! + Please note that after calling this, the pointer to the + ITexture may no longer be valid, if it was not grabbed before + by other parts of the engine for storing it longer. So it is a + good idea to set all materials which are using this texture to + 0 or another texture first. + \param texture Texture to delete from the engine cache. */ + virtual void removeTexture(ITexture *texture) = 0; + + //! Removes all textures from the texture cache and deletes them. + /** This method can free a lot of memory! + Please note that after calling this, the pointer to the + ITexture may no longer be valid, if it was not grabbed before + by other parts of the engine for storing it longer. So it is a + good idea to set all materials which are using this texture to + 0 or another texture first. */ + virtual void removeAllTextures() = 0; + + //! Remove hardware buffer + virtual void removeHardwareBuffer(const scene::IMeshBuffer *mb) = 0; + + //! Remove all hardware buffers + virtual void removeAllHardwareBuffers() = 0; + + //! Create occlusion query. + /** Use node for identification and mesh for occlusion test. */ + virtual void addOcclusionQuery(scene::ISceneNode *node, + const scene::IMesh *mesh = 0) = 0; + + //! Remove occlusion query. + virtual void removeOcclusionQuery(scene::ISceneNode *node) = 0; + + //! Remove all occlusion queries. + virtual void removeAllOcclusionQueries() = 0; + + //! Run occlusion query. Draws mesh stored in query. + /** If the mesh shall not be rendered visible, use + overrideMaterial to disable the color and depth buffer. */ + virtual void runOcclusionQuery(scene::ISceneNode *node, bool visible = false) = 0; + + //! Run all occlusion queries. Draws all meshes stored in queries. + /** If the meshes shall not be rendered visible, use + overrideMaterial to disable the color and depth buffer. */ + virtual void runAllOcclusionQueries(bool visible = false) = 0; + + //! Update occlusion query. Retrieves results from GPU. + /** If the query shall not block, set the flag to false. + Update might not occur in this case, though */ + virtual void updateOcclusionQuery(scene::ISceneNode *node, bool block = true) = 0; + + //! Update all occlusion queries. Retrieves results from GPU. + /** If the query shall not block, set the flag to false. + Update might not occur in this case, though */ + virtual void updateAllOcclusionQueries(bool block = true) = 0; + + //! Return query result. + /** Return value is the number of visible pixels/fragments. + The value is a safe approximation, i.e. can be larger than the + actual value of pixels. */ + virtual u32 getOcclusionQueryResult(scene::ISceneNode *node) const = 0; + + //! Create render target. + virtual IRenderTarget *addRenderTarget() = 0; + + //! Remove render target. + virtual void removeRenderTarget(IRenderTarget *renderTarget) = 0; + + //! Remove all render targets. + virtual void removeAllRenderTargets() = 0; + + //! Sets a boolean alpha channel on the texture based on a color key. + /** This makes the texture fully transparent at the texels where + this color key can be found when using for example draw2DImage + with useAlphachannel==true. The alpha of other texels is not modified. + \param texture Texture whose alpha channel is modified. + \param color Color key color. Every texel with this color will + become fully transparent as described above. Please note that the + colors of a texture may be converted when loading it, so the + color values may not be exactly the same in the engine and for + example in picture edit programs. To avoid this problem, you + could use the makeColorKeyTexture method, which takes the + position of a pixel instead a color value. */ + virtual void makeColorKeyTexture(video::ITexture *texture, + video::SColor color) const = 0; + + //! Sets a boolean alpha channel on the texture based on the color at a position. + /** This makes the texture fully transparent at the texels where + the color key can be found when using for example draw2DImage + with useAlphachannel==true. The alpha of other texels is not modified. + \param texture Texture whose alpha channel is modified. + \param colorKeyPixelPos Position of a pixel with the color key + color. Every texel with this color will become fully transparent as + described above. */ + virtual void makeColorKeyTexture(video::ITexture *texture, + core::position2d colorKeyPixelPos) const = 0; + + //! Set a render target. + /** This will only work if the driver supports the + EVDF_RENDER_TO_TARGET feature, which can be queried with + queryFeature(). Please note that you cannot render 3D or 2D + geometry with a render target as texture on it when you are rendering + the scene into this render target at the same time. It is usually only + possible to render into a texture between the + IVideoDriver::beginScene() and endScene() method calls. If you need the + best performance use this method instead of setRenderTarget. + \param target Render target object. If set to nullptr, it makes the + window the current render target. + \param clearFlag A combination of the E_CLEAR_BUFFER_FLAG bit-flags. + \param clearColor The clear color for the color buffer. + \param clearDepth The clear value for the depth buffer. + \param clearStencil The clear value for the stencil buffer. + \return True if successful and false if not. */ + virtual bool setRenderTargetEx(IRenderTarget *target, u16 clearFlag, SColor clearColor = SColor(255, 0, 0, 0), + f32 clearDepth = 1.f, u8 clearStencil = 0) = 0; + + //! Sets a new render target. + /** This will only work if the driver supports the + EVDF_RENDER_TO_TARGET feature, which can be queried with + queryFeature(). Usually, rendering to textures is done in this + way: + \code + // create render target + ITexture* target = driver->addRenderTargetTexture(core::dimension2d(128,128), "rtt1"); + + // ... + + driver->setRenderTarget(target); // set render target + // .. draw stuff here + driver->setRenderTarget(0); // set previous render target + \endcode + Please note that you cannot render 3D or 2D geometry with a + render target as texture on it when you are rendering the scene + into this render target at the same time. It is usually only + possible to render into a texture between the + IVideoDriver::beginScene() and endScene() method calls. + \param texture New render target. Must be a texture created with + IVideoDriver::addRenderTargetTexture(). If set to nullptr, it makes + the window the current render target. + \param clearFlag A combination of the E_CLEAR_BUFFER_FLAG bit-flags. + \param clearColor The clear color for the color buffer. + \param clearDepth The clear value for the depth buffer. + \param clearStencil The clear value for the stencil buffer. + \return True if successful and false if not. */ + virtual bool setRenderTarget(ITexture *texture, u16 clearFlag = ECBF_COLOR | ECBF_DEPTH, SColor clearColor = SColor(255, 0, 0, 0), + f32 clearDepth = 1.f, u8 clearStencil = 0) = 0; + + //! Sets a new render target. + //! Prefer to use the setRenderTarget function taking flags as parameter as this one can't clear the stencil buffer. + //! It's still offered for backward compatibility. + bool setRenderTarget(ITexture *texture, bool clearBackBuffer, bool clearZBuffer, SColor color = SColor(255, 0, 0, 0)) + { + u16 flag = 0; + + if (clearBackBuffer) + flag |= ECBF_COLOR; + + if (clearZBuffer) + flag |= ECBF_DEPTH; + + return setRenderTarget(texture, flag, color); + } + + //! Sets a new viewport. + /** Every rendering operation is done into this new area. + \param area: Rectangle defining the new area of rendering + operations. */ + virtual void setViewPort(const core::rect &area) = 0; + + //! Gets the area of the current viewport. + /** \return Rectangle of the current viewport. */ + virtual const core::rect &getViewPort() const = 0; + + //! Draws a vertex primitive list + /** Note that, depending on the index type, some vertices might be not + accessible through the index list. The limit is at 65535 vertices for 16bit + indices. Please note that currently not all primitives are available for + all drivers, and some might be emulated via triangle renders. + \param vertices Pointer to array of vertices. + \param vertexCount Amount of vertices in the array. + \param indexList Pointer to array of indices. These define the vertices used + for each primitive. Depending on the pType, indices are interpreted as single + objects (for point like primitives), pairs (for lines), triplets (for + triangles), or quads. + \param primCount Amount of Primitives + \param vType Vertex type, e.g. video::EVT_STANDARD for S3DVertex. + \param pType Primitive type, e.g. scene::EPT_TRIANGLE_FAN for a triangle fan. + \param iType Index type, e.g. video::EIT_16BIT for 16bit indices. */ + virtual void drawVertexPrimitiveList(const void *vertices, u32 vertexCount, + const void *indexList, u32 primCount, + E_VERTEX_TYPE vType = EVT_STANDARD, + scene::E_PRIMITIVE_TYPE pType = scene::EPT_TRIANGLES, + E_INDEX_TYPE iType = EIT_16BIT) = 0; + + //! Draws a vertex primitive list in 2d + /** Compared to the general (3d) version of this method, this + one sets up a 2d render mode, and uses only x and y of vectors. + Note that, depending on the index type, some vertices might be + not accessible through the index list. The limit is at 65535 + vertices for 16bit indices. Please note that currently not all + primitives are available for all drivers, and some might be + emulated via triangle renders. This function is not available + for the sw drivers. + \param vertices Pointer to array of vertices. + \param vertexCount Amount of vertices in the array. + \param indexList Pointer to array of indices. These define the + vertices used for each primitive. Depending on the pType, + indices are interpreted as single objects (for point like + primitives), pairs (for lines), triplets (for triangles), or + quads. + \param primCount Amount of Primitives + \param vType Vertex type, e.g. video::EVT_STANDARD for S3DVertex. + \param pType Primitive type, e.g. scene::EPT_TRIANGLE_FAN for a triangle fan. + \param iType Index type, e.g. video::EIT_16BIT for 16bit indices. */ + virtual void draw2DVertexPrimitiveList(const void *vertices, u32 vertexCount, + const void *indexList, u32 primCount, + E_VERTEX_TYPE vType = EVT_STANDARD, + scene::E_PRIMITIVE_TYPE pType = scene::EPT_TRIANGLES, + E_INDEX_TYPE iType = EIT_16BIT) = 0; + + //! Draws an indexed triangle list. + /** Note that there may be at maximum 65536 vertices, because + the index list is an array of 16 bit values each with a maximum + value of 65536. If there are more than 65536 vertices in the + list, results of this operation are not defined. + \param vertices Pointer to array of vertices. + \param vertexCount Amount of vertices in the array. + \param indexList Pointer to array of indices. + \param triangleCount Amount of Triangles. Usually amount of indices / 3. */ + void drawIndexedTriangleList(const S3DVertex *vertices, + u32 vertexCount, const u16 *indexList, u32 triangleCount) + { + drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLES, EIT_16BIT); + } + + //! Draws an indexed triangle list. + /** Note that there may be at maximum 65536 vertices, because + the index list is an array of 16 bit values each with a maximum + value of 65536. If there are more than 65536 vertices in the + list, results of this operation are not defined. + \param vertices Pointer to array of vertices. + \param vertexCount Amount of vertices in the array. + \param indexList Pointer to array of indices. + \param triangleCount Amount of Triangles. Usually amount of indices / 3. */ + void drawIndexedTriangleList(const S3DVertex2TCoords *vertices, + u32 vertexCount, const u16 *indexList, u32 triangleCount) + { + drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLES, EIT_16BIT); + } + + //! Draws an indexed triangle list. + /** Note that there may be at maximum 65536 vertices, because + the index list is an array of 16 bit values each with a maximum + value of 65536. If there are more than 65536 vertices in the + list, results of this operation are not defined. + \param vertices Pointer to array of vertices. + \param vertexCount Amount of vertices in the array. + \param indexList Pointer to array of indices. + \param triangleCount Amount of Triangles. Usually amount of indices / 3. */ + void drawIndexedTriangleList(const S3DVertexTangents *vertices, + u32 vertexCount, const u16 *indexList, u32 triangleCount) + { + drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLES, EIT_16BIT); + } + + //! Draws an indexed triangle fan. + /** Note that there may be at maximum 65536 vertices, because + the index list is an array of 16 bit values each with a maximum + value of 65536. If there are more than 65536 vertices in the + list, results of this operation are not defined. + \param vertices Pointer to array of vertices. + \param vertexCount Amount of vertices in the array. + \param indexList Pointer to array of indices. + \param triangleCount Amount of Triangles. Usually amount of indices - 2. */ + void drawIndexedTriangleFan(const S3DVertex *vertices, + u32 vertexCount, const u16 *indexList, u32 triangleCount) + { + drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLE_FAN, EIT_16BIT); + } + + //! Draws an indexed triangle fan. + /** Note that there may be at maximum 65536 vertices, because + the index list is an array of 16 bit values each with a maximum + value of 65536. If there are more than 65536 vertices in the + list, results of this operation are not defined. + \param vertices Pointer to array of vertices. + \param vertexCount Amount of vertices in the array. + \param indexList Pointer to array of indices. + \param triangleCount Amount of Triangles. Usually amount of indices - 2. */ + void drawIndexedTriangleFan(const S3DVertex2TCoords *vertices, + u32 vertexCount, const u16 *indexList, u32 triangleCount) + { + drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLE_FAN, EIT_16BIT); + } + + //! Draws an indexed triangle fan. + /** Note that there may be at maximum 65536 vertices, because + the index list is an array of 16 bit values each with a maximum + value of 65536. If there are more than 65536 vertices in the + list, results of this operation are not defined. + \param vertices Pointer to array of vertices. + \param vertexCount Amount of vertices in the array. + \param indexList Pointer to array of indices. + \param triangleCount Amount of Triangles. Usually amount of indices - 2. */ + void drawIndexedTriangleFan(const S3DVertexTangents *vertices, + u32 vertexCount, const u16 *indexList, u32 triangleCount) + { + drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLE_FAN, EIT_16BIT); + } + + //! Draws a 3d line. + /** For some implementations, this method simply calls + drawVertexPrimitiveList for some triangles. + Note that the line is drawn using the current transformation + matrix and material. So if you need to draw the 3D line + independently of the current transformation, use + \code + driver->setMaterial(someMaterial); + driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); + \endcode + for some properly set up material before drawing the line. + Some drivers support line thickness set in the material. + \param start Start of the 3d line. + \param end End of the 3d line. + \param color Color of the line. */ + virtual void draw3DLine(const core::vector3df &start, + const core::vector3df &end, SColor color = SColor(255, 255, 255, 255)) = 0; + + //! Draws a 3d axis aligned box. + /** This method simply calls draw3DLine for the edges of the + box. Note that the box is drawn using the current transformation + matrix and material. So if you need to draw it independently of + the current transformation, use + \code + driver->setMaterial(someMaterial); + driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); + \endcode + for some properly set up material before drawing the box. + \param box The axis aligned box to draw + \param color Color to use while drawing the box. */ + virtual void draw3DBox(const core::aabbox3d &box, + SColor color = SColor(255, 255, 255, 255)) = 0; + + //! Draws a 2d image without any special effects + /** \param texture Pointer to texture to use. + \param destPos Upper left 2d destination position where the + image will be drawn. + \param useAlphaChannelOfTexture: If true, the alpha channel of + the texture is used to draw the image.*/ + virtual void draw2DImage(const video::ITexture *texture, + const core::position2d &destPos, bool useAlphaChannelOfTexture = false) = 0; + + //! Draws a 2d image using a color + /** (if color is other than + Color(255,255,255,255)) and the alpha channel of the texture. + \param texture Texture to be drawn. + \param destPos Upper left 2d destination position where the + image will be drawn. + \param sourceRect Source rectangle in the texture (based on it's OriginalSize) + \param clipRect Pointer to rectangle on the screen where the + image is clipped to. + If this pointer is NULL the image is not clipped. + \param color Color with which the image is drawn. If the color + equals Color(255,255,255,255) it is ignored. Note that the + alpha component is used: If alpha is other than 255, the image + will be transparent. + \param useAlphaChannelOfTexture: If true, the alpha channel of + the texture is used to draw the image.*/ + virtual void draw2DImage(const video::ITexture *texture, const core::position2d &destPos, + const core::rect &sourceRect, const core::rect *clipRect = 0, + SColor color = SColor(255, 255, 255, 255), bool useAlphaChannelOfTexture = false) = 0; + + //! Draws a set of 2d images, using a color and the alpha channel of the texture. + /** All drawings are clipped against clipRect (if != 0). + The subtextures are defined by the array of sourceRects and are + positioned using the array of positions. + \param texture Texture to be drawn. + \param positions Array of upper left 2d destinations where the + images will be drawn. + \param sourceRects Source rectangles of the texture (based on it's OriginalSize) + \param clipRect Pointer to rectangle on the screen where the + images are clipped to. + If this pointer is 0 then the image is not clipped. + \param color Color with which the image is drawn. + Note that the alpha component is used. If alpha is other than + 255, the image will be transparent. + \param useAlphaChannelOfTexture: If true, the alpha channel of + the texture is used to draw the image. */ + virtual void draw2DImageBatch(const video::ITexture *texture, + const core::array> &positions, + const core::array> &sourceRects, + const core::rect *clipRect = 0, + SColor color = SColor(255, 255, 255, 255), + bool useAlphaChannelOfTexture = false) = 0; + + //! Draws a part of the texture into the rectangle. Note that colors must be an array of 4 colors if used. + /** Suggested and first implemented by zola. + \param texture The texture to draw from + \param destRect The rectangle to draw into + \param sourceRect The rectangle denoting a part of the texture (based on it's OriginalSize) + \param clipRect Clips the destination rectangle (may be 0) + \param colors Array of 4 colors denoting the color values of + the corners of the destRect + \param useAlphaChannelOfTexture True if alpha channel will be + blended. */ + virtual void draw2DImage(const video::ITexture *texture, const core::rect &destRect, + const core::rect &sourceRect, const core::rect *clipRect = 0, + const video::SColor *const colors = 0, bool useAlphaChannelOfTexture = false) = 0; + + //! Draws a 2d rectangle. + /** \param color Color of the rectangle to draw. The alpha + component will not be ignored and specifies how transparent the + rectangle will be. + \param pos Position of the rectangle. + \param clip Pointer to rectangle against which the rectangle + will be clipped. If the pointer is null, no clipping will be + performed. */ + virtual void draw2DRectangle(SColor color, const core::rect &pos, + const core::rect *clip = 0) = 0; + + //! Draws a 2d rectangle with a gradient. + /** \param colorLeftUp Color of the upper left corner to draw. + The alpha component will not be ignored and specifies how + transparent the rectangle will be. + \param colorRightUp Color of the upper right corner to draw. + The alpha component will not be ignored and specifies how + transparent the rectangle will be. + \param colorLeftDown Color of the lower left corner to draw. + The alpha component will not be ignored and specifies how + transparent the rectangle will be. + \param colorRightDown Color of the lower right corner to draw. + The alpha component will not be ignored and specifies how + transparent the rectangle will be. + \param pos Position of the rectangle. + \param clip Pointer to rectangle against which the rectangle + will be clipped. If the pointer is null, no clipping will be + performed. */ + virtual void draw2DRectangle(const core::rect &pos, + SColor colorLeftUp, SColor colorRightUp, + SColor colorLeftDown, SColor colorRightDown, + const core::rect *clip = 0) = 0; + + //! Draws a 2d line. + /** In theory both start and end will be included in coloring. + BUG: Currently d3d ignores the last pixel + (it uses the so called "diamond exit rule" for drawing lines). + \param start Screen coordinates of the start of the line + in pixels. + \param end Screen coordinates of the start of the line in + pixels. + \param color Color of the line to draw. */ + virtual void draw2DLine(const core::position2d &start, + const core::position2d &end, + SColor color = SColor(255, 255, 255, 255)) = 0; + + //! Draws a mesh buffer + /** \param mb Buffer to draw */ + virtual void drawMeshBuffer(const scene::IMeshBuffer *mb) = 0; + + //! Draws normals of a mesh buffer + /** \param mb Buffer to draw the normals of + \param length length scale factor of the normals + \param color Color the normals are rendered with + */ + virtual void drawMeshBufferNormals(const scene::IMeshBuffer *mb, f32 length = 10.f, SColor color = 0xffffffff) = 0; + + //! Sets the fog mode. + /** These are global values attached to each 3d object rendered, + which has the fog flag enabled in its material. + \param color Color of the fog + \param fogType Type of fog used + \param start Only used in linear fog mode (linearFog=true). + Specifies where fog starts. + \param end Only used in linear fog mode (linearFog=true). + Specifies where fog ends. + \param density Only used in exponential fog mode + (linearFog=false). Must be a value between 0 and 1. + \param pixelFog Set this to false for vertex fog, and true if + you want per-pixel fog. + \param rangeFog Set this to true to enable range-based vertex + fog. The distance from the viewer is used to compute the fog, + not the z-coordinate. This is better, but slower. This might not + be available with all drivers and fog settings. */ + virtual void setFog(SColor color = SColor(0, 255, 255, 255), + E_FOG_TYPE fogType = EFT_FOG_LINEAR, + f32 start = 50.0f, f32 end = 100.0f, f32 density = 0.01f, + bool pixelFog = false, bool rangeFog = false) = 0; + + //! Gets the fog mode. + virtual void getFog(SColor &color, E_FOG_TYPE &fogType, + f32 &start, f32 &end, f32 &density, + bool &pixelFog, bool &rangeFog) = 0; + + //! Get the current color format of the color buffer + /** \return Color format of the color buffer. */ + virtual ECOLOR_FORMAT getColorFormat() const = 0; + + //! Get the size of the screen or render window. + /** \return Size of screen or render window. */ + virtual const core::dimension2d &getScreenSize() const = 0; + + //! Get the size of the current render target + /** This method will return the screen size if the driver + doesn't support render to texture, or if the current render + target is the screen. + \return Size of render target or screen/window */ + virtual const core::dimension2d &getCurrentRenderTargetSize() const = 0; + + //! Returns current frames per second value. + /** This value is updated approximately every 1.5 seconds and + is only intended to provide a rough guide to the average frame + rate. It is not suitable for use in performing timing + calculations or framerate independent movement. + \return Approximate amount of frames per second drawn. */ + virtual s32 getFPS() const = 0; + + //! Returns amount of primitives (mostly triangles) which were drawn in the last frame. + /** Together with getFPS() very useful method for statistics. + \param mode Defines if the primitives drawn are accumulated or + counted per frame. + \return Amount of primitives drawn in the last frame. */ + virtual u32 getPrimitiveCountDrawn(u32 mode = 0) const = 0; + + //! Gets name of this video driver. + /** \return Returns the name of the video driver, e.g. in case + of the Direct3D8 driver, it would return "Direct3D 8.1". */ + virtual const char *getName() const = 0; + + //! Adds an external image loader to the engine. + /** This is useful if the Irrlicht Engine should be able to load + textures of currently unsupported file formats (e.g. gif). The + IImageLoader only needs to be implemented for loading this file + format. A pointer to the implementation can be passed to the + engine using this method. + \param loader Pointer to the external loader created. */ + virtual void addExternalImageLoader(IImageLoader *loader) = 0; + + //! Adds an external image writer to the engine. + /** This is useful if the Irrlicht Engine should be able to + write textures of currently unsupported file formats (e.g + .gif). The IImageWriter only needs to be implemented for + writing this file format. A pointer to the implementation can + be passed to the engine using this method. + \param writer: Pointer to the external writer created. */ + virtual void addExternalImageWriter(IImageWriter *writer) = 0; + + //! Returns the maximum amount of primitives + /** (mostly vertices) which the device is able to render with + one drawVertexPrimitiveList call. + \return Maximum amount of primitives. */ + virtual u32 getMaximalPrimitiveCount() const = 0; + + //! Enables or disables a texture creation flag. + /** These flags define how textures should be created. By + changing this value, you can influence for example the speed of + rendering a lot. But please note that the video drivers take + this value only as recommendation. It could happen that you + enable the ETCF_ALWAYS_16_BIT mode, but the driver still creates + 32 bit textures. + \param flag Texture creation flag. + \param enabled Specifies if the given flag should be enabled or + disabled. */ + virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled = true) = 0; + + //! Returns if a texture creation flag is enabled or disabled. + /** You can change this value using setTextureCreationFlag(). + \param flag Texture creation flag. + \return The current texture creation flag enabled mode. */ + virtual bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const = 0; + + //! Creates a software image from a file. + /** No hardware texture will be created for this image. This + method is useful for example if you want to read a heightmap + for a terrain renderer. + \param filename Name of the file from which the image is + created. + \return The created image. + If you no longer need the image, you should call IImage::drop(). + See IReferenceCounted::drop() for more information. */ + virtual IImage *createImageFromFile(const io::path &filename) = 0; + + //! Creates a software image from a file. + /** No hardware texture will be created for this image. This + method is useful for example if you want to read a heightmap + for a terrain renderer. + \param file File from which the image is created. + \return The created image. + If you no longer need the image, you should call IImage::drop(). + See IReferenceCounted::drop() for more information. */ + virtual IImage *createImageFromFile(io::IReadFile *file) = 0; + + //! Writes the provided image to a file. + /** Requires that there is a suitable image writer registered + for writing the image. + \param image Image to write. + \param filename Name of the file to write. + \param param Control parameter for the backend (e.g. compression + level). + \return True on successful write. */ + virtual bool writeImageToFile(IImage *image, const io::path &filename, u32 param = 0) = 0; + + //! Writes the provided image to a file. + /** Requires that there is a suitable image writer registered + for writing the image. + \param image Image to write. + \param file An already open io::IWriteFile object. The name + will be used to determine the appropriate image writer to use. + \param param Control parameter for the backend (e.g. compression + level). + \return True on successful write. */ + virtual bool writeImageToFile(IImage *image, io::IWriteFile *file, u32 param = 0) = 0; + + //! Creates a software image from a byte array. + /** No hardware texture will be created for this image. This + method is useful for example if you want to read a heightmap + for a terrain renderer. + \param format Desired color format of the texture + \param size Desired size of the image + \param data A byte array with pixel color information + \param ownForeignMemory If true, the image will use the data + pointer directly and own it afterward. If false, the memory + will by copied internally. + WARNING: Setting this to 'true' will not work across dll boundaries. + So unless you link Irrlicht statically you should keep this to 'false'. + The parameter is mainly for internal usage. + \param deleteMemory Whether the memory is deallocated upon + destruction. + \return The created image. + If you no longer need the image, you should call IImage::drop(). + See IReferenceCounted::drop() for more information. */ + virtual IImage *createImageFromData(ECOLOR_FORMAT format, + const core::dimension2d &size, void *data, bool ownForeignMemory = false, + bool deleteMemory = true) = 0; + + //! Creates an empty software image. + /** + \param format Desired color format of the image. + \param size Size of the image to create. + \return The created image. + If you no longer need the image, you should call IImage::drop(). + See IReferenceCounted::drop() for more information. */ + virtual IImage *createImage(ECOLOR_FORMAT format, const core::dimension2d &size) = 0; + + //! Creates a software image from a part of a texture. + /** + \param texture Texture to copy to the new image in part. + \param pos Position of rectangle to copy. + \param size Extents of rectangle to copy. + \return The created image. + If you no longer need the image, you should call IImage::drop(). + See IReferenceCounted::drop() for more information. */ + virtual IImage *createImage(ITexture *texture, + const core::position2d &pos, + const core::dimension2d &size) = 0; + + //! Event handler for resize events. Only used by the engine internally. + /** Used to notify the driver that the window was resized. + Usually, there is no need to call this method. */ + virtual void OnResize(const core::dimension2d &size) = 0; + + //! Adds a new material renderer to the video device. + /** Use this method to extend the VideoDriver with new material + types. To extend the engine using this method do the following: + Derive a class from IMaterialRenderer and override the methods + you need. For setting the right renderstates, you can try to + get a pointer to the real rendering device using + IVideoDriver::getExposedVideoData(). Add your class with + IVideoDriver::addMaterialRenderer(). To use an object being + displayed with your new material, set the MaterialType member of + the SMaterial struct to the value returned by this method. + If you simply want to create a new material using vertex and/or + pixel shaders it would be easier to use the + video::IGPUProgrammingServices interface which you can get + using the getGPUProgrammingServices() method. + \param renderer A pointer to the new renderer. + \param name Optional name for the material renderer entry. + \return The number of the material type which can be set in + SMaterial::MaterialType to use the renderer. -1 is returned if + an error occurred. For example if you tried to add an material + renderer to the software renderer or the null device, which do + not accept material renderers. */ + virtual s32 addMaterialRenderer(IMaterialRenderer *renderer, const c8 *name = 0) = 0; + + //! Get access to a material renderer by index. + /** \param idx Id of the material renderer. Can be a value of + the E_MATERIAL_TYPE enum or a value which was returned by + addMaterialRenderer(). + \return Pointer to material renderer or null if not existing. */ + virtual IMaterialRenderer *getMaterialRenderer(u32 idx) const = 0; + + //! Get amount of currently available material renderers. + /** \return Amount of currently available material renderers. */ + virtual u32 getMaterialRendererCount() const = 0; + + //! Get name of a material renderer + /** This string can, e.g., be used to test if a specific + renderer already has been registered/created, or use this + string to store data about materials: This returned name will + be also used when serializing materials. + \param idx Id of the material renderer. Can be a value of the + E_MATERIAL_TYPE enum or a value which was returned by + addMaterialRenderer(). + \return String with the name of the renderer, or 0 if not + existing */ + virtual const c8 *getMaterialRendererName(u32 idx) const = 0; + + //! Sets the name of a material renderer. + /** Will have no effect on built-in material renderers. + \param idx: Id of the material renderer. Can be a value of the + E_MATERIAL_TYPE enum or a value which was returned by + addMaterialRenderer(). + \param name: New name of the material renderer. */ + virtual void setMaterialRendererName(u32 idx, const c8 *name) = 0; + + //! Swap the material renderers used for certain id's + /** Swap the IMaterialRenderers responsible for rendering specific + material-id's. This means every SMaterial using a MaterialType + with one of the indices involved here will now render differently. + \param idx1 First material index to swap. It must already exist or nothing happens. + \param idx2 Second material index to swap. It must already exist or nothing happens. + \param swapNames When true the renderer names also swap + When false the names will stay at the original index */ + virtual void swapMaterialRenderers(u32 idx1, u32 idx2, bool swapNames = true) = 0; + + //! Returns driver and operating system specific data about the IVideoDriver. + /** This method should only be used if the engine should be + extended without having to modify the source of the engine. + \return Collection of device dependent pointers. */ + virtual const SExposedVideoData &getExposedVideoData() = 0; + + //! Get type of video driver + /** \return Type of driver. */ + virtual E_DRIVER_TYPE getDriverType() const = 0; + + //! Gets the IGPUProgrammingServices interface. + /** \return Pointer to the IGPUProgrammingServices. Returns 0 + if the video driver does not support this. For example the + Software driver and the Null driver will always return 0. */ + virtual IGPUProgrammingServices *getGPUProgrammingServices() = 0; + + //! Returns a pointer to the mesh manipulator. + virtual scene::IMeshManipulator *getMeshManipulator() = 0; + + //! Clear the color, depth and/or stencil buffers. + virtual void clearBuffers(u16 flag, SColor color = SColor(255, 0, 0, 0), f32 depth = 1.f, u8 stencil = 0) = 0; + + //! Clears the ZBuffer. + /** Note that you usually need not to call this method, as it + is automatically done in IVideoDriver::beginScene() or + IVideoDriver::setRenderTarget() if you enable zBuffer. But if + you have to render some special things, you can clear the + zbuffer during the rendering process with this method any time. + */ + void clearZBuffer() + { + clearBuffers(ECBF_DEPTH, SColor(255, 0, 0, 0), 1.f, 0); + } + + //! Make a screenshot of the last rendered frame. + /** \return An image created from the last rendered frame. */ + virtual IImage *createScreenShot(video::ECOLOR_FORMAT format = video::ECF_UNKNOWN, video::E_RENDER_TARGET target = video::ERT_FRAME_BUFFER) = 0; + + //! Check if the image is already loaded. + /** Works similar to getTexture(), but does not load the texture + if it is not currently loaded. + \param filename Name of the texture. + \return Pointer to loaded texture, or 0 if not found. */ + virtual video::ITexture *findTexture(const io::path &filename) = 0; + + //! Set or unset a clipping plane. + /** There are at least 6 clipping planes available for the user + to set at will. + \param index The plane index. Must be between 0 and + MaxUserClipPlanes. + \param plane The plane itself. + \param enable If true, enable the clipping plane else disable + it. + \return True if the clipping plane is usable. */ + virtual bool setClipPlane(u32 index, const core::plane3df &plane, bool enable = false) = 0; + + //! Enable or disable a clipping plane. + /** There are at least 6 clipping planes available for the user + to set at will. + \param index The plane index. Must be between 0 and + MaxUserClipPlanes. + \param enable If true, enable the clipping plane else disable + it. */ + virtual void enableClipPlane(u32 index, bool enable) = 0; + + //! Set the minimum number of vertices for which a hw buffer will be created + /** \param count Number of vertices to set as minimum. */ + virtual void setMinHardwareBufferVertexCount(u32 count) = 0; + + //! Get the global Material, which might override local materials. + /** Depending on the enable flags, values from this Material + are used to override those of local materials of some + meshbuffer being rendered. + \return Reference to the Override Material. */ + virtual SOverrideMaterial &getOverrideMaterial() = 0; + + //! Get the 2d override material for altering its values + /** The 2d override material allows to alter certain render + states of the 2d methods. Not all members of SMaterial are + honored, especially not MaterialType and Textures. Moreover, + the zbuffer is always ignored, and lighting is always off. All + other flags can be changed, though some might have to effect + in most cases. + Please note that you have to enable/disable this effect with + enableMaterial2D(). This effect is costly, as it increases + the number of state changes considerably. Always reset the + values when done. + \return Material reference which should be altered to reflect + the new settings. + */ + virtual SMaterial &getMaterial2D() = 0; + + //! Enable the 2d override material + /** \param enable Flag which tells whether the material shall be + enabled or disabled. */ + virtual void enableMaterial2D(bool enable = true) = 0; + + //! Get the graphics card vendor name. + virtual core::stringc getVendorInfo() = 0; + + //! Only used by the engine internally. + /** The ambient color is set in the scene manager, see + scene::ISceneManager::setAmbientLight(). + \param color New color of the ambient light. */ + virtual void setAmbientLight(const SColorf &color) = 0; + + //! Get the global ambient light currently used by the driver + virtual const SColorf &getAmbientLight() const = 0; + + //! Only used by the engine internally. + /** Passes the global material flag AllowZWriteOnTransparent. + Use the SceneManager attribute to set this value from your app. + \param flag Default behavior is to disable ZWrite, i.e. false. */ + virtual void setAllowZWriteOnTransparent(bool flag) = 0; + + //! Get the maximum texture size supported. + virtual core::dimension2du getMaxTextureSize() const = 0; + + //! Color conversion convenience function + /** Convert an image (as array of pixels) from source to destination + array, thereby converting the color format. The pixel size is + determined by the color formats. + \param sP Pointer to source + \param sF Color format of source + \param sN Number of pixels to convert, both array must be large enough + \param dP Pointer to destination + \param dF Color format of destination + */ + virtual void convertColor(const void *sP, ECOLOR_FORMAT sF, s32 sN, + void *dP, ECOLOR_FORMAT dF) const = 0; + + //! Check if the driver supports creating textures with the given color format + /** \return True if the format is available, false if not. */ + virtual bool queryTextureFormat(ECOLOR_FORMAT format) const = 0; + + //! Used by some SceneNodes to check if a material should be rendered in the transparent render pass + virtual bool needsTransparentRenderPass(const irr::video::SMaterial &material) const = 0; +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/include/IWriteFile.h b/irr/include/IWriteFile.h new file mode 100644 index 000000000..cc27e5903 --- /dev/null +++ b/irr/include/IWriteFile.h @@ -0,0 +1,47 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "path.h" + +namespace irr +{ +namespace io +{ + +//! Interface providing write access to a file. +class IWriteFile : public virtual IReferenceCounted +{ +public: + //! Writes an amount of bytes to the file. + /** \param buffer Pointer to buffer of bytes to write. + \param sizeToWrite Amount of bytes to write to the file. + \return How much bytes were written. */ + virtual size_t write(const void *buffer, size_t sizeToWrite) = 0; + + //! Changes position in file + /** \param finalPos Destination position in the file. + \param relativeMovement If set to true, the position in the file is + changed relative to current position. Otherwise the position is changed + from begin of file. + \return True if successful, otherwise false. */ + virtual bool seek(long finalPos, bool relativeMovement = false) = 0; + + //! Get the current position in the file. + /** \return Current position in the file in bytes on success or -1L on failure */ + virtual long getPos() const = 0; + + //! Get name of file. + /** \return File name as zero terminated character string. */ + virtual const path &getFileName() const = 0; + + //! Flush the content of the buffer in the file + /** \return True if successful, otherwise false. */ + virtual bool flush() = 0; +}; + +} // end namespace io +} // end namespace irr diff --git a/irr/include/IrrCompileConfig.h b/irr/include/IrrCompileConfig.h new file mode 100644 index 000000000..3e248cbc0 --- /dev/null +++ b/irr/include/IrrCompileConfig.h @@ -0,0 +1,28 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +//! Identifies the IrrlichtMt fork customized for the Minetest engine +#define IRRLICHT_VERSION_MT_REVISION 15 +#define IRRLICHT_VERSION_MT "mt15" + +//! Irrlicht SDK Version +#define IRRLICHT_VERSION_MAJOR 1 +#define IRRLICHT_VERSION_MINOR 9 +#define IRRLICHT_VERSION_REVISION 0 +// This flag will be defined only in SVN, the official release code will have +// it undefined +#define IRRLICHT_VERSION_SVN alpha +#define IRRLICHT_SDK_VERSION "1.9.0" IRRLICHT_VERSION_MT + +#ifdef _WIN32 +#define IRRCALLCONV __stdcall +#else +#define IRRCALLCONV +#endif + +#ifndef IRRLICHT_API +#define IRRLICHT_API +#endif diff --git a/irr/include/IrrlichtDevice.h b/irr/include/IrrlichtDevice.h new file mode 100644 index 000000000..8f4105a4f --- /dev/null +++ b/irr/include/IrrlichtDevice.h @@ -0,0 +1,341 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "dimension2d.h" +#include "IVideoDriver.h" +#include "EDriverTypes.h" +#include "EDeviceTypes.h" +#include "IEventReceiver.h" +#include "ICursorControl.h" +#include "ITimer.h" +#include "IOSOperator.h" +#include "IrrCompileConfig.h" + +namespace irr +{ +class ILogger; +class IEventReceiver; + +namespace io +{ +class IFileSystem; +} // end namespace io + +namespace gui +{ +class IGUIEnvironment; +} // end namespace gui + +namespace scene +{ +class ISceneManager; +} // end namespace scene + +namespace video +{ +class IContextManager; +extern "C" IRRLICHT_API bool IRRCALLCONV isDriverSupported(E_DRIVER_TYPE driver); +} // end namespace video + +//! The Irrlicht device. You can create it with createDevice() or createDeviceEx(). +/** This is the most important class of the Irrlicht Engine. You can +access everything in the engine if you have a pointer to an instance of +this class. There should be only one instance of this class at any +time. +*/ +class IrrlichtDevice : public virtual IReferenceCounted +{ +public: + //! Runs the device. + /** Also increments the virtual timer by calling + ITimer::tick();. You can prevent this + by calling ITimer::stop(); before and ITimer::start() after + calling IrrlichtDevice::run(). Returns false if device wants + to be deleted. Use it in this way: + \code + while(device->run()) + { + // draw everything here + } + \endcode + If you want the device to do nothing if the window is inactive + (recommended), use the slightly enhanced code shown at isWindowActive(). + + Note if you are running Irrlicht inside an external, custom + created window: Calling Device->run() will cause Irrlicht to + dispatch windows messages internally. + If you are running Irrlicht in your own custom window, you can + also simply use your own message loop using GetMessage, + DispatchMessage and whatever and simply don't use this method. + But note that Irrlicht will not be able to fetch user input + then. See irr::SIrrlichtCreationParameters::WindowId for more + information and example code. + */ + virtual bool run() = 0; + + //! Cause the device to temporarily pause execution and let other processes run. + /** This should bring down processor usage without major performance loss for Irrlicht. + But this is system dependent, so there's a chance your thread won't get control back quickly. + */ + virtual void yield() = 0; + + //! Pause execution and let other processes to run for a specified amount of time. + /** It may not wait the full given time, as sleep may be interrupted and also may wait longer on some OS. + \param timeMs: Time to sleep for in milliseconds. Note that the OS can round up this number. + On Windows you usually get at least 15ms sleep time minium for any value > 0. + So if you call this in your main loop you can't get more than 65 FPS anymore in your game. + On most Linux systems it's relatively exact, but also no guarantee. + \param pauseTimer: If true, pauses the device timer while sleeping + */ + virtual void sleep(u32 timeMs, bool pauseTimer = false) = 0; + + //! Provides access to the video driver for drawing 3d and 2d geometry. + /** \return Pointer the video driver. */ + virtual video::IVideoDriver *getVideoDriver() = 0; + + //! Provides access to the virtual file system. + /** \return Pointer to the file system. */ + virtual io::IFileSystem *getFileSystem() = 0; + + //! Provides access to the 2d user interface environment. + /** \return Pointer to the gui environment. */ + virtual gui::IGUIEnvironment *getGUIEnvironment() = 0; + + //! Provides access to the scene manager. + /** \return Pointer to the scene manager. */ + virtual scene::ISceneManager *getSceneManager() = 0; + + //! Provides access to the cursor control. + /** \return Pointer to the mouse cursor control interface. */ + virtual gui::ICursorControl *getCursorControl() = 0; + + //! Provides access to the message logger. + /** \return Pointer to the logger. */ + virtual ILogger *getLogger() = 0; + + //! Get context manager + virtual video::IContextManager *getContextManager() = 0; + + //! Provides access to the operation system operator object. + /** The OS operator provides methods for + getting system specific information and doing system + specific operations, such as exchanging data with the clipboard + or reading the operation system version. + \return Pointer to the OS operator. */ + virtual IOSOperator *getOSOperator() = 0; + + //! Provides access to the engine's timer. + /** The system time can be retrieved by it as + well as the virtual time, which also can be manipulated. + \return Pointer to the ITimer object. */ + virtual ITimer *getTimer() = 0; + + //! Sets the caption of the window. + /** \param text: New text of the window caption. */ + virtual void setWindowCaption(const wchar_t *text) = 0; + + //! Sets the window icon. + /** \param img The icon texture. + \return False if no icon was set. */ + virtual bool setWindowIcon(const video::IImage *img) = 0; + + //! Returns if the window is active. + /** If the window is inactive, + nothing needs to be drawn. So if you don't want to draw anything + when the window is inactive, create your drawing loop this way: + \code + while(device->run()) + { + if (device->isWindowActive()) + { + // draw everything here + } + else + device->yield(); + } + \endcode + \return True if window is active. */ + virtual bool isWindowActive() const = 0; + + //! Checks if the Irrlicht window has the input focus + /** \return True if window has focus. */ + virtual bool isWindowFocused() const = 0; + + //! Checks if the Irrlicht window is minimized + /** \return True if window is minimized. */ + virtual bool isWindowMinimized() const = 0; + + //! Checks if the Irrlicht window is maximized + //! Only fully works on SDL. Returns false, or the last value set via + //! maximizeWindow() and restoreWindow(), on other backends. + /** \return True if window is maximized. */ + virtual bool isWindowMaximized() const = 0; + + //! Checks if the Irrlicht window is running in fullscreen mode + /** \return True if window is fullscreen. */ + virtual bool isFullscreen() const = 0; + + //! Checks if the window could possibly be visible. + //! Currently, this only returns false when the activity is stopped on + //! Android. Note that for Android activities, "stopped" means something + //! different than you might expect (and also something different than + //! "paused"). Read the Android lifecycle documentation. + virtual bool isWindowVisible() const { return true; }; + + //! Get the current color format of the window + /** \return Color format of the window. */ + virtual video::ECOLOR_FORMAT getColorFormat() const = 0; + + //! Notifies the device that it should close itself. + /** IrrlichtDevice::run() will always return false after closeDevice() was called. */ + virtual void closeDevice() = 0; + + //! Get the version of the engine. + /** The returned string + will look like this: "1.2.3" or this: "1.2". + \return String which contains the version. */ + virtual const c8 *getVersion() const = 0; + + //! Sets a new user event receiver which will receive events from the engine. + /** Return true in IEventReceiver::OnEvent to prevent the event from continuing along + the chain of event receivers. The path that an event takes through the system depends + on its type. See irr::EEVENT_TYPE for details. + \param receiver New receiver to be used. */ + virtual void setEventReceiver(IEventReceiver *receiver) = 0; + + //! Provides access to the current event receiver. + /** \return Pointer to the current event receiver. Returns 0 if there is none. */ + virtual IEventReceiver *getEventReceiver() = 0; + + //! Sends a user created event to the engine. + /** Is is usually not necessary to use this. However, if you + are using an own input library for example for doing joystick + input, you can use this to post key or mouse input events to + the engine. Internally, this method only delegates the events + further to the scene manager and the GUI environment. */ + virtual bool postEventFromUser(const SEvent &event) = 0; + + //! Sets the input receiving scene manager. + /** If set to null, the main scene manager (returned by + GetSceneManager()) will receive the input + \param sceneManager New scene manager to be used. */ + virtual void setInputReceivingSceneManager(scene::ISceneManager *sceneManager) = 0; + + //! Sets if the window should be resizable in windowed mode. + /** The default is false. This method only works in windowed + mode. + \param resize Flag whether the window should be resizable. */ + virtual void setResizable(bool resize = false) = 0; + + //! Resize the render window. + /** This will only work in windowed mode and is not yet supported on all systems. + It does set the drawing/clientDC size of the window, the window decorations are added to that. + You get the current window size with IVideoDriver::getScreenSize() (might be unified in future) + */ + virtual void setWindowSize(const irr::core::dimension2d &size) = 0; + + //! Minimizes the window if possible. + virtual void minimizeWindow() = 0; + + //! Maximizes the window if possible. + virtual void maximizeWindow() = 0; + + //! Restore the window to normal size if possible. + virtual void restoreWindow() = 0; + + //! Get the position of the frame on-screen + virtual core::position2di getWindowPosition() = 0; + + //! Activate any joysticks, and generate events for them. + /** Irrlicht contains support for joysticks, but does not generate joystick events by default, + as this would consume joystick info that 3rd party libraries might rely on. Call this method to + activate joystick support in Irrlicht and to receive irr::SJoystickEvent events. + \param joystickInfo On return, this will contain an array of each joystick that was found and activated. + \return true if joysticks are supported on this device, false if joysticks are not + supported or support is compiled out. + */ + virtual bool activateJoysticks(core::array &joystickInfo) = 0; + + //! Activate accelerometer. + virtual bool activateAccelerometer(float updateInterval = 0.016666f) = 0; + + //! Deactivate accelerometer. + virtual bool deactivateAccelerometer() = 0; + + //! Is accelerometer active. + virtual bool isAccelerometerActive() = 0; + + //! Is accelerometer available. + virtual bool isAccelerometerAvailable() = 0; + + //! Activate gyroscope. + virtual bool activateGyroscope(float updateInterval = 0.016666f) = 0; + + //! Deactivate gyroscope. + virtual bool deactivateGyroscope() = 0; + + //! Is gyroscope active. + virtual bool isGyroscopeActive() = 0; + + //! Is gyroscope available. + virtual bool isGyroscopeAvailable() = 0; + + //! Activate device motion. + virtual bool activateDeviceMotion(float updateInterval = 0.016666f) = 0; + + //! Deactivate device motion. + virtual bool deactivateDeviceMotion() = 0; + + //! Is device motion active. + virtual bool isDeviceMotionActive() = 0; + + //! Is device motion available. + virtual bool isDeviceMotionAvailable() = 0; + + //! Set the maximal elapsed time between 2 clicks to generate doubleclicks for the mouse. It also affects tripleclick behavior. + /** When set to 0 no double- and tripleclicks will be generated. + \param timeMs maximal time in milliseconds for two consecutive clicks to be recognized as double click + */ + virtual void setDoubleClickTime(u32 timeMs) = 0; + + //! Get the maximal elapsed time between 2 clicks to generate double- and tripleclicks for the mouse. + /** When return value is 0 no double- and tripleclicks will be generated. + \return maximal time in milliseconds for two consecutive clicks to be recognized as double click + */ + virtual u32 getDoubleClickTime() const = 0; + + //! Remove messages pending in the system message loop + /** This function is usually used after messages have been buffered for a longer time, for example + when loading a large scene. Clearing the message loop prevents that mouse- or buttonclicks which users + have pressed in the meantime will now trigger unexpected actions in the gui.
+ So far the following messages are cleared:
+ Win32: All keyboard and mouse messages
+ Linux: All keyboard and mouse messages
+ All other devices are not yet supported here.
+ The function is still somewhat experimental, as the kind of messages we clear is based on just a few use-cases. + If you think further messages should be cleared, or some messages should not be cleared here, then please tell us. */ + virtual void clearSystemMessages() = 0; + + //! Get the type of the device. + /** This allows the user to check which windowing system is currently being + used. */ + virtual E_DEVICE_TYPE getType() const = 0; + + //! Get the display density in dots per inch. + //! Returns 0.0f on failure. + virtual float getDisplayDensity() const = 0; + + //! Check if a driver type is supported by the engine. + /** Even if true is returned the driver may not be available + for a configuration requested when creating the device. */ + static bool isDriverSupported(video::E_DRIVER_TYPE driver) + { + return video::isDriverSupported(driver); + } +}; + +} // end namespace irr diff --git a/irr/include/Keycodes.h b/irr/include/Keycodes.h new file mode 100644 index 000000000..cdc90d198 --- /dev/null +++ b/irr/include/Keycodes.h @@ -0,0 +1,185 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +namespace irr +{ + +enum EKEY_CODE +{ + KEY_UNKNOWN = 0x0, + KEY_LBUTTON = 0x01, // Left mouse button + KEY_RBUTTON = 0x02, // Right mouse button + KEY_CANCEL = 0x03, // Control-break processing + KEY_MBUTTON = 0x04, // Middle mouse button (three-button mouse) + KEY_XBUTTON1 = 0x05, // Windows 2000/XP: X1 mouse button + KEY_XBUTTON2 = 0x06, // Windows 2000/XP: X2 mouse button + KEY_BACK = 0x08, // BACKSPACE key + KEY_TAB = 0x09, // TAB key + KEY_CLEAR = 0x0C, // CLEAR key + KEY_RETURN = 0x0D, // ENTER key + KEY_SHIFT = 0x10, // SHIFT key + KEY_CONTROL = 0x11, // CTRL key + KEY_MENU = 0x12, // ALT key + KEY_PAUSE = 0x13, // PAUSE key + KEY_CAPITAL = 0x14, // CAPS LOCK key + KEY_KANA = 0x15, // IME Kana mode + KEY_HANGUEL = 0x15, // IME Hanguel mode (maintained for compatibility use KEY_HANGUL) + KEY_HANGUL = 0x15, // IME Hangul mode + KEY_JUNJA = 0x17, // IME Junja mode + KEY_FINAL = 0x18, // IME final mode + KEY_HANJA = 0x19, // IME Hanja mode + KEY_KANJI = 0x19, // IME Kanji mode + KEY_ESCAPE = 0x1B, // ESC key + KEY_CONVERT = 0x1C, // IME convert + KEY_NONCONVERT = 0x1D, // IME nonconvert + KEY_ACCEPT = 0x1E, // IME accept + KEY_MODECHANGE = 0x1F, // IME mode change request + KEY_SPACE = 0x20, // SPACEBAR + KEY_PRIOR = 0x21, // PAGE UP key + KEY_NEXT = 0x22, // PAGE DOWN key + KEY_END = 0x23, // END key + KEY_HOME = 0x24, // HOME key + KEY_LEFT = 0x25, // LEFT ARROW key + KEY_UP = 0x26, // UP ARROW key + KEY_RIGHT = 0x27, // RIGHT ARROW key + KEY_DOWN = 0x28, // DOWN ARROW key + KEY_SELECT = 0x29, // SELECT key + KEY_PRINT = 0x2A, // PRINT key + KEY_EXECUT = 0x2B, // EXECUTE key + KEY_SNAPSHOT = 0x2C, // PRINT SCREEN key + KEY_INSERT = 0x2D, // INS key + KEY_DELETE = 0x2E, // DEL key + KEY_HELP = 0x2F, // HELP key + KEY_KEY_0 = 0x30, // 0 key + KEY_KEY_1 = 0x31, // 1 key + KEY_KEY_2 = 0x32, // 2 key + KEY_KEY_3 = 0x33, // 3 key + KEY_KEY_4 = 0x34, // 4 key + KEY_KEY_5 = 0x35, // 5 key + KEY_KEY_6 = 0x36, // 6 key + KEY_KEY_7 = 0x37, // 7 key + KEY_KEY_8 = 0x38, // 8 key + KEY_KEY_9 = 0x39, // 9 key + KEY_KEY_A = 0x41, // A key + KEY_KEY_B = 0x42, // B key + KEY_KEY_C = 0x43, // C key + KEY_KEY_D = 0x44, // D key + KEY_KEY_E = 0x45, // E key + KEY_KEY_F = 0x46, // F key + KEY_KEY_G = 0x47, // G key + KEY_KEY_H = 0x48, // H key + KEY_KEY_I = 0x49, // I key + KEY_KEY_J = 0x4A, // J key + KEY_KEY_K = 0x4B, // K key + KEY_KEY_L = 0x4C, // L key + KEY_KEY_M = 0x4D, // M key + KEY_KEY_N = 0x4E, // N key + KEY_KEY_O = 0x4F, // O key + KEY_KEY_P = 0x50, // P key + KEY_KEY_Q = 0x51, // Q key + KEY_KEY_R = 0x52, // R key + KEY_KEY_S = 0x53, // S key + KEY_KEY_T = 0x54, // T key + KEY_KEY_U = 0x55, // U key + KEY_KEY_V = 0x56, // V key + KEY_KEY_W = 0x57, // W key + KEY_KEY_X = 0x58, // X key + KEY_KEY_Y = 0x59, // Y key + KEY_KEY_Z = 0x5A, // Z key + KEY_LWIN = 0x5B, // Left Windows key (Microsoft Natural keyboard) + KEY_RWIN = 0x5C, // Right Windows key (Natural keyboard) + KEY_APPS = 0x5D, // Applications key (Natural keyboard) + KEY_SLEEP = 0x5F, // Computer Sleep key + KEY_NUMPAD0 = 0x60, // Numeric keypad 0 key + KEY_NUMPAD1 = 0x61, // Numeric keypad 1 key + KEY_NUMPAD2 = 0x62, // Numeric keypad 2 key + KEY_NUMPAD3 = 0x63, // Numeric keypad 3 key + KEY_NUMPAD4 = 0x64, // Numeric keypad 4 key + KEY_NUMPAD5 = 0x65, // Numeric keypad 5 key + KEY_NUMPAD6 = 0x66, // Numeric keypad 6 key + KEY_NUMPAD7 = 0x67, // Numeric keypad 7 key + KEY_NUMPAD8 = 0x68, // Numeric keypad 8 key + KEY_NUMPAD9 = 0x69, // Numeric keypad 9 key + KEY_MULTIPLY = 0x6A, // Multiply key + KEY_ADD = 0x6B, // Add key + KEY_SEPARATOR = 0x6C, // Separator key + KEY_SUBTRACT = 0x6D, // Subtract key + KEY_DECIMAL = 0x6E, // Decimal key + KEY_DIVIDE = 0x6F, // Divide key + KEY_F1 = 0x70, // F1 key + KEY_F2 = 0x71, // F2 key + KEY_F3 = 0x72, // F3 key + KEY_F4 = 0x73, // F4 key + KEY_F5 = 0x74, // F5 key + KEY_F6 = 0x75, // F6 key + KEY_F7 = 0x76, // F7 key + KEY_F8 = 0x77, // F8 key + KEY_F9 = 0x78, // F9 key + KEY_F10 = 0x79, // F10 key + KEY_F11 = 0x7A, // F11 key + KEY_F12 = 0x7B, // F12 key + KEY_F13 = 0x7C, // F13 key + KEY_F14 = 0x7D, // F14 key + KEY_F15 = 0x7E, // F15 key + KEY_F16 = 0x7F, // F16 key + KEY_F17 = 0x80, // F17 key + KEY_F18 = 0x81, // F18 key + KEY_F19 = 0x82, // F19 key + KEY_F20 = 0x83, // F20 key + KEY_F21 = 0x84, // F21 key + KEY_F22 = 0x85, // F22 key + KEY_F23 = 0x86, // F23 key + KEY_F24 = 0x87, // F24 key + KEY_NUMLOCK = 0x90, // NUM LOCK key + KEY_SCROLL = 0x91, // SCROLL LOCK key + KEY_LSHIFT = 0xA0, // Left SHIFT key + KEY_RSHIFT = 0xA1, // Right SHIFT key + KEY_LCONTROL = 0xA2, // Left CONTROL key + KEY_RCONTROL = 0xA3, // Right CONTROL key + KEY_LMENU = 0xA4, // Left MENU key + KEY_RMENU = 0xA5, // Right MENU key + KEY_BROWSER_BACK = 0xA6, // Browser Back key + KEY_BROWSER_FORWARD = 0xA7, // Browser Forward key + KEY_BROWSER_REFRESH = 0xA8, // Browser Refresh key + KEY_BROWSER_STOP = 0xA9, // Browser Stop key + KEY_BROWSER_SEARCH = 0xAA, // Browser Search key + KEY_BROWSER_FAVORITES = 0xAB, // Browser Favorites key + KEY_BROWSER_HOME = 0xAC, // Browser Start and Home key + KEY_VOLUME_MUTE = 0xAD, // Volume Mute key + KEY_VOLUME_DOWN = 0xAE, // Volume Down key + KEY_VOLUME_UP = 0xAF, // Volume Up key + KEY_MEDIA_NEXT_TRACK = 0xB0, // Next Track key + KEY_MEDIA_PREV_TRACK = 0xB1, // Previous Track key + KEY_MEDIA_STOP = 0xB2, // Stop Media key + KEY_MEDIA_PLAY_PAUSE = 0xB3, // Play/Pause Media key + KEY_OEM_1 = 0xBA, // for US ";:" + KEY_PLUS = 0xBB, // Plus Key "+" + KEY_COMMA = 0xBC, // Comma Key "," + KEY_MINUS = 0xBD, // Minus Key "-" + KEY_PERIOD = 0xBE, // Period Key "." + KEY_OEM_2 = 0xBF, // for US "/?" + KEY_OEM_3 = 0xC0, // for US "`~" + KEY_OEM_4 = 0xDB, // for US "[{" + KEY_OEM_5 = 0xDC, // for US "\|" + KEY_OEM_6 = 0xDD, // for US "]}" + KEY_OEM_7 = 0xDE, // for US "'"" + KEY_OEM_8 = 0xDF, // None + KEY_OEM_AX = 0xE1, // for Japan "AX" + KEY_OEM_102 = 0xE2, // "<>" or "\|" + KEY_ATTN = 0xF6, // Attn key + KEY_CRSEL = 0xF7, // CrSel key + KEY_EXSEL = 0xF8, // ExSel key + KEY_EREOF = 0xF9, // Erase EOF key + KEY_PLAY = 0xFA, // Play key + KEY_ZOOM = 0xFB, // Zoom key + KEY_PA1 = 0xFD, // PA1 key + KEY_OEM_CLEAR = 0xFE, // Clear key + KEY_NONE = 0xFF, // usually no key mapping, but some laptops use it for fn key + + KEY_KEY_CODES_COUNT = 0x100 // this is not a key, but the amount of keycodes there are. +}; + +} // end namespace irr diff --git a/irr/include/S3DVertex.h b/irr/include/S3DVertex.h new file mode 100644 index 000000000..2039df0e5 --- /dev/null +++ b/irr/include/S3DVertex.h @@ -0,0 +1,288 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "vector3d.h" +#include "vector2d.h" +#include "SColor.h" + +namespace irr +{ +namespace video +{ + +//! Enumeration for all vertex types there are. +enum E_VERTEX_TYPE +{ + //! Standard vertex type used by the Irrlicht engine, video::S3DVertex. + EVT_STANDARD = 0, + + //! Vertex with two texture coordinates, video::S3DVertex2TCoords. + /** Usually used for geometry with lightmaps or other special materials. */ + EVT_2TCOORDS, + + //! Vertex with a tangent and binormal vector, video::S3DVertexTangents. + /** Usually used for tangent space normal mapping. + Usually tangent and binormal get send to shaders as texture coordinate sets 1 and 2. + */ + EVT_TANGENTS +}; + +//! Array holding the built in vertex type names +const char *const sBuiltInVertexTypeNames[] = { + "standard", + "2tcoords", + "tangents", + 0, + }; + +//! standard vertex used by the Irrlicht engine. +struct S3DVertex +{ + //! default constructor + constexpr S3DVertex() : + Color(0xffffffff) {} + + //! constructor + constexpr S3DVertex(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv) : + Pos(x, y, z), Normal(nx, ny, nz), Color(c), TCoords(tu, tv) {} + + //! constructor + constexpr S3DVertex(const core::vector3df &pos, const core::vector3df &normal, + SColor color, const core::vector2df &tcoords) : + Pos(pos), + Normal(normal), Color(color), TCoords(tcoords) {} + + //! Position + core::vector3df Pos; + + //! Normal vector + core::vector3df Normal; + + //! Color + SColor Color; + + //! Texture coordinates + core::vector2df TCoords; + + constexpr bool operator==(const S3DVertex &other) const + { + return ((Pos == other.Pos) && (Normal == other.Normal) && + (Color == other.Color) && (TCoords == other.TCoords)); + } + + constexpr bool operator!=(const S3DVertex &other) const + { + return ((Pos != other.Pos) || (Normal != other.Normal) || + (Color != other.Color) || (TCoords != other.TCoords)); + } + + constexpr bool operator<(const S3DVertex &other) const + { + return ((Pos < other.Pos) || + ((Pos == other.Pos) && (Normal < other.Normal)) || + ((Pos == other.Pos) && (Normal == other.Normal) && (Color < other.Color)) || + ((Pos == other.Pos) && (Normal == other.Normal) && (Color == other.Color) && (TCoords < other.TCoords))); + } + + //! Get type of the class + static E_VERTEX_TYPE getType() + { + return EVT_STANDARD; + } + + //\param d d=0 returns other, d=1 returns this, values between interpolate. + S3DVertex getInterpolated(const S3DVertex &other, f32 d) + { + d = core::clamp(d, 0.0f, 1.0f); + return S3DVertex(Pos.getInterpolated(other.Pos, d), + Normal.getInterpolated(other.Normal, d), + Color.getInterpolated(other.Color, d), + TCoords.getInterpolated(other.TCoords, d)); + } +}; + +//! Vertex with two texture coordinates. +/** Usually used for geometry with lightmaps +or other special materials. +*/ +struct S3DVertex2TCoords : public S3DVertex +{ + //! default constructor + constexpr S3DVertex2TCoords() : + S3DVertex() {} + + //! constructor with two different texture coords, but no normal + constexpr S3DVertex2TCoords(f32 x, f32 y, f32 z, SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2) : + S3DVertex(x, y, z, 0.0f, 0.0f, 0.0f, c, tu, tv), TCoords2(tu2, tv2) {} + + //! constructor with two different texture coords, but no normal + constexpr S3DVertex2TCoords(const core::vector3df &pos, SColor color, + const core::vector2df &tcoords, const core::vector2df &tcoords2) : + S3DVertex(pos, core::vector3df(), color, tcoords), + TCoords2(tcoords2) {} + + //! constructor with all values + constexpr S3DVertex2TCoords(const core::vector3df &pos, const core::vector3df &normal, const SColor &color, + const core::vector2df &tcoords, const core::vector2df &tcoords2) : + S3DVertex(pos, normal, color, tcoords), + TCoords2(tcoords2) {} + + //! constructor with all values + constexpr S3DVertex2TCoords(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, + SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2) : + S3DVertex(x, y, z, nx, ny, nz, c, tu, tv), + TCoords2(tu2, tv2) {} + + //! constructor with the same texture coords and normal + constexpr S3DVertex2TCoords(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, + SColor c, f32 tu, f32 tv) : + S3DVertex(x, y, z, nx, ny, nz, c, tu, tv), + TCoords2(tu, tv) {} + + //! constructor with the same texture coords and normal + constexpr S3DVertex2TCoords(const core::vector3df &pos, const core::vector3df &normal, + SColor color, const core::vector2df &tcoords) : + S3DVertex(pos, normal, color, tcoords), + TCoords2(tcoords) {} + + //! constructor from S3DVertex + constexpr S3DVertex2TCoords(const S3DVertex &o) : + S3DVertex(o) {} + + //! Second set of texture coordinates + core::vector2df TCoords2; + + //! Equality operator + constexpr bool operator==(const S3DVertex2TCoords &other) const + { + return ((static_cast(*this) == static_cast(other)) && + (TCoords2 == other.TCoords2)); + } + + //! Inequality operator + constexpr bool operator!=(const S3DVertex2TCoords &other) const + { + return ((static_cast(*this) != static_cast(other)) || + (TCoords2 != other.TCoords2)); + } + + constexpr bool operator<(const S3DVertex2TCoords &other) const + { + return ((static_cast(*this) < other) || + ((static_cast(*this) == static_cast(other)) && (TCoords2 < other.TCoords2))); + } + + static E_VERTEX_TYPE getType() + { + return EVT_2TCOORDS; + } + + //\param d d=0 returns other, d=1 returns this, values between interpolate. + S3DVertex2TCoords getInterpolated(const S3DVertex2TCoords &other, f32 d) + { + d = core::clamp(d, 0.0f, 1.0f); + return S3DVertex2TCoords(Pos.getInterpolated(other.Pos, d), + Normal.getInterpolated(other.Normal, d), + Color.getInterpolated(other.Color, d), + TCoords.getInterpolated(other.TCoords, d), + TCoords2.getInterpolated(other.TCoords2, d)); + } +}; + +//! Vertex with a tangent and binormal vector. +/** Usually used for tangent space normal mapping. + Usually tangent and binormal get send to shaders as texture coordinate sets 1 and 2. +*/ +struct S3DVertexTangents : public S3DVertex +{ + //! default constructor + S3DVertexTangents() : + S3DVertex() {} + + //! constructor + constexpr S3DVertexTangents(f32 x, f32 y, f32 z, f32 nx = 0.0f, f32 ny = 0.0f, f32 nz = 0.0f, + SColor c = 0xFFFFFFFF, f32 tu = 0.0f, f32 tv = 0.0f, + f32 tanx = 0.0f, f32 tany = 0.0f, f32 tanz = 0.0f, + f32 bx = 0.0f, f32 by = 0.0f, f32 bz = 0.0f) : + S3DVertex(x, y, z, nx, ny, nz, c, tu, tv), + Tangent(tanx, tany, tanz), Binormal(bx, by, bz) {} + + //! constructor + constexpr S3DVertexTangents(const core::vector3df &pos, SColor c, + const core::vector2df &tcoords) : + S3DVertex(pos, core::vector3df(), c, tcoords) {} + + //! constructor + constexpr S3DVertexTangents(const core::vector3df &pos, + const core::vector3df &normal, SColor c, + const core::vector2df &tcoords, + const core::vector3df &tangent = core::vector3df(), + const core::vector3df &binormal = core::vector3df()) : + S3DVertex(pos, normal, c, tcoords), + Tangent(tangent), Binormal(binormal) {} + + //! constructor from S3DVertex + constexpr S3DVertexTangents(const S3DVertex &o) : + S3DVertex(o) {} + + //! Tangent vector along the x-axis of the texture + core::vector3df Tangent; + + //! Binormal vector (tangent x normal) + core::vector3df Binormal; + + constexpr bool operator==(const S3DVertexTangents &other) const + { + return ((static_cast(*this) == static_cast(other)) && + (Tangent == other.Tangent) && + (Binormal == other.Binormal)); + } + + constexpr bool operator!=(const S3DVertexTangents &other) const + { + return ((static_cast(*this) != static_cast(other)) || + (Tangent != other.Tangent) || + (Binormal != other.Binormal)); + } + + constexpr bool operator<(const S3DVertexTangents &other) const + { + return ((static_cast(*this) < other) || + ((static_cast(*this) == static_cast(other)) && (Tangent < other.Tangent)) || + ((static_cast(*this) == static_cast(other)) && (Tangent == other.Tangent) && (Binormal < other.Binormal))); + } + + static E_VERTEX_TYPE getType() + { + return EVT_TANGENTS; + } + + S3DVertexTangents getInterpolated(const S3DVertexTangents &other, f32 d) + { + d = core::clamp(d, 0.0f, 1.0f); + return S3DVertexTangents(Pos.getInterpolated(other.Pos, d), + Normal.getInterpolated(other.Normal, d), + Color.getInterpolated(other.Color, d), + TCoords.getInterpolated(other.TCoords, d), + Tangent.getInterpolated(other.Tangent, d), + Binormal.getInterpolated(other.Binormal, d)); + } +}; + +inline u32 getVertexPitchFromType(E_VERTEX_TYPE vertexType) +{ + switch (vertexType) { + case video::EVT_2TCOORDS: + return sizeof(video::S3DVertex2TCoords); + case video::EVT_TANGENTS: + return sizeof(video::S3DVertexTangents); + default: + return sizeof(video::S3DVertex); + } +} + +} // end namespace video +} // end namespace irr diff --git a/irr/include/SAnimatedMesh.h b/irr/include/SAnimatedMesh.h new file mode 100644 index 000000000..8fdaae0ee --- /dev/null +++ b/irr/include/SAnimatedMesh.h @@ -0,0 +1,177 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IAnimatedMesh.h" +#include "IMesh.h" +#include "aabbox3d.h" +#include "irrArray.h" + +namespace irr +{ +namespace scene +{ + +//! Simple implementation of the IAnimatedMesh interface. +struct SAnimatedMesh : public IAnimatedMesh +{ + //! constructor + SAnimatedMesh(scene::IMesh *mesh = 0, scene::E_ANIMATED_MESH_TYPE type = scene::EAMT_UNKNOWN) : + IAnimatedMesh(), FramesPerSecond(25.f), Type(type) + { +#ifdef _DEBUG + setDebugName("SAnimatedMesh"); +#endif + addMesh(mesh); + recalculateBoundingBox(); + } + + //! destructor + virtual ~SAnimatedMesh() + { + // drop meshes + for (u32 i = 0; i < Meshes.size(); ++i) + Meshes[i]->drop(); + } + + //! Gets the frame count of the animated mesh. + /** \return Amount of frames. If the amount is 1, it is a static, non animated mesh. */ + u32 getFrameCount() const override + { + return Meshes.size(); + } + + //! Gets the default animation speed of the animated mesh. + /** \return Amount of frames per second. If the amount is 0, it is a static, non animated mesh. */ + f32 getAnimationSpeed() const override + { + return FramesPerSecond; + } + + //! Gets the frame count of the animated mesh. + /** \param fps Frames per second to play the animation with. If the amount is 0, it is not animated. + The actual speed is set in the scene node the mesh is instantiated in.*/ + void setAnimationSpeed(f32 fps) override + { + FramesPerSecond = fps; + } + + //! Returns the IMesh interface for a frame. + /** \param frame: Frame number as zero based index. The maximum frame number is + getFrameCount() - 1; + \param detailLevel: Level of detail. 0 is the lowest, + 255 the highest level of detail. Most meshes will ignore the detail level. + \param startFrameLoop: start frame + \param endFrameLoop: end frame + \return The animated mesh based on a detail level. */ + IMesh *getMesh(s32 frame, s32 detailLevel = 255, s32 startFrameLoop = -1, s32 endFrameLoop = -1) override + { + if (Meshes.empty()) + return 0; + + return Meshes[frame]; + } + + //! adds a Mesh + void addMesh(IMesh *mesh) + { + if (mesh) { + mesh->grab(); + Meshes.push_back(mesh); + } + } + + //! Returns an axis aligned bounding box of the mesh. + /** \return A bounding box of this mesh is returned. */ + const core::aabbox3d &getBoundingBox() const override + { + return Box; + } + + //! set user axis aligned bounding box + void setBoundingBox(const core::aabbox3df &box) override + { + Box = box; + } + + //! Recalculates the bounding box. + void recalculateBoundingBox() + { + Box.reset(0, 0, 0); + + if (Meshes.empty()) + return; + + Box = Meshes[0]->getBoundingBox(); + + for (u32 i = 1; i < Meshes.size(); ++i) + Box.addInternalBox(Meshes[i]->getBoundingBox()); + } + + //! Returns the type of the animated mesh. + E_ANIMATED_MESH_TYPE getMeshType() const override + { + return Type; + } + + //! returns amount of mesh buffers. + u32 getMeshBufferCount() const override + { + if (Meshes.empty()) + return 0; + + return Meshes[0]->getMeshBufferCount(); + } + + //! returns pointer to a mesh buffer + IMeshBuffer *getMeshBuffer(u32 nr) const override + { + if (Meshes.empty()) + return 0; + + return Meshes[0]->getMeshBuffer(nr); + } + + //! Returns pointer to a mesh buffer which fits a material + /** \param material: material to search for + \return Returns the pointer to the mesh buffer or + NULL if there is no such mesh buffer. */ + IMeshBuffer *getMeshBuffer(const video::SMaterial &material) const override + { + if (Meshes.empty()) + return 0; + + return Meshes[0]->getMeshBuffer(material); + } + + //! set the hardware mapping hint, for driver + void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer = EBT_VERTEX_AND_INDEX) override + { + for (u32 i = 0; i < Meshes.size(); ++i) + Meshes[i]->setHardwareMappingHint(newMappingHint, buffer); + } + + //! flags the meshbuffer as changed, reloads hardware buffers + void setDirty(E_BUFFER_TYPE buffer = EBT_VERTEX_AND_INDEX) override + { + for (u32 i = 0; i < Meshes.size(); ++i) + Meshes[i]->setDirty(buffer); + } + + //! All meshes defining the animated mesh + core::array Meshes; + + //! The bounding box of this mesh + core::aabbox3d Box; + + //! Default animation speed of this mesh. + f32 FramesPerSecond; + + //! The type of the mesh. + E_ANIMATED_MESH_TYPE Type; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/SColor.h b/irr/include/SColor.h new file mode 100644 index 000000000..284ab3351 --- /dev/null +++ b/irr/include/SColor.h @@ -0,0 +1,728 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" +#include "irrMath.h" + +namespace irr +{ +namespace video +{ +//! An enum for the color format of textures used by the Irrlicht Engine. +/** A color format specifies how color information is stored. + NOTE: Byte order in memory is usually flipped (it's probably correct in bitmap files, but flipped on reading). + So for example ECF_A8R8G8B8 is BGRA in memory same as in DX9's D3DFMT_A8R8G8B8 format. +*/ +enum ECOLOR_FORMAT +{ + //! 16 bit color format used by the software driver. + /** It is thus preferred by all other irrlicht engine video drivers. + There are 5 bits for every color component, and a single bit is left + for alpha information. */ + ECF_A1R5G5B5 = 0, + + //! Standard 16 bit color format. + ECF_R5G6B5, + + //! 24 bit color, no alpha channel, but 8 bit for red, green and blue. + //! Warning: 24 bit formats tend to be badly supported. Depending on driver it's usually converted to another + // format or even not working at all. It's mostly better to use 16-bit or 32-bit formats. + ECF_R8G8B8, + + //! Default 32 bit color format. 8 bits are used for every component: red, green, blue and alpha. + //! Warning: This tends to be BGRA in memory (it's ARGB on file, but with usual big-endian memory it's flipped) + ECF_A8R8G8B8, + + /** The following formats may only be used for render target textures. */ + + /** Floating point formats. */ + + //! 16 bit format using 16 bits for the red channel. + ECF_R16F, + + //! 32 bit format using 16 bits for the red and green channels. + ECF_G16R16F, + + //! 64 bit format using 16 bits for the red, green, blue and alpha channels. + ECF_A16B16G16R16F, + + //! 32 bit format using 32 bits for the red channel. + ECF_R32F, + + //! 64 bit format using 32 bits for the red and green channels. + ECF_G32R32F, + + //! 128 bit format using 32 bits for the red, green, blue and alpha channels. + ECF_A32B32G32R32F, + + /** Unsigned normalized integer formats. */ + + //! 8 bit format using 8 bits for the red channel. + ECF_R8, + + //! 16 bit format using 8 bits for the red and green channels. + ECF_R8G8, + + //! 16 bit format using 16 bits for the red channel. + ECF_R16, + + //! 32 bit format using 16 bits for the red and green channels. + ECF_R16G16, + + /** Depth and stencil formats. */ + + //! 16 bit format using 16 bits for depth. + ECF_D16, + + //! 32 bit format using 32 bits for depth. + ECF_D32, + + //! 32 bit format using 24 bits for depth and 8 bits for stencil. + ECF_D24S8, + + //! Unknown color format: + ECF_UNKNOWN +}; + +//! Names for ECOLOR_FORMAT types +const c8 *const ColorFormatNames[ECF_UNKNOWN + 2] = { + "A1R5G5B5", + "R5G6B5", + "R8G8B8", + "A8R8G8B8", + "R16F", + "G16R16F", + "A16B16G16R16F", + "R32F", + "G32R32F", + "A32B32G32R32F", + "R8", + "R8G8", + "R16", + "R16G16", + "D16", + "D32", + "D24S8", + "UNKNOWN", + 0, + }; + +//! Creates a 16 bit A1R5G5B5 color +inline u16 RGBA16(u32 r, u32 g, u32 b, u32 a = 0xFF) +{ + return (u16)((a & 0x80) << 8 | + (r & 0xF8) << 7 | + (g & 0xF8) << 2 | + (b & 0xF8) >> 3); +} + +//! Creates a 16 bit A1R5G5B5 color +inline u16 RGB16(u32 r, u32 g, u32 b) +{ + return RGBA16(r, g, b); +} + +//! Creates a 16bit A1R5G5B5 color, based on 16bit input values +inline u16 RGB16from16(u16 r, u16 g, u16 b) +{ + return (0x8000 | + (r & 0x1F) << 10 | + (g & 0x1F) << 5 | + (b & 0x1F)); +} + +//! Converts a 32bit (X8R8G8B8) color to a 16bit A1R5G5B5 color +inline u16 X8R8G8B8toA1R5G5B5(u32 color) +{ + return (u16)(0x8000 | + (color & 0x00F80000) >> 9 | + (color & 0x0000F800) >> 6 | + (color & 0x000000F8) >> 3); +} + +//! Converts a 32bit (A8R8G8B8) color to a 16bit A1R5G5B5 color +inline u16 A8R8G8B8toA1R5G5B5(u32 color) +{ + return (u16)((color & 0x80000000) >> 16 | + (color & 0x00F80000) >> 9 | + (color & 0x0000F800) >> 6 | + (color & 0x000000F8) >> 3); +} + +//! Converts a 32bit (A8R8G8B8) color to a 16bit R5G6B5 color +inline u16 A8R8G8B8toR5G6B5(u32 color) +{ + return (u16)((color & 0x00F80000) >> 8 | + (color & 0x0000FC00) >> 5 | + (color & 0x000000F8) >> 3); +} + +//! Convert A8R8G8B8 Color from A1R5G5B5 color +/** build a nicer 32bit Color by extending dest lower bits with source high bits. */ +inline u32 A1R5G5B5toA8R8G8B8(u16 color) +{ + return (((-((s32)color & 0x00008000) >> (s32)31) & 0xFF000000) | + ((color & 0x00007C00) << 9) | ((color & 0x00007000) << 4) | + ((color & 0x000003E0) << 6) | ((color & 0x00000380) << 1) | + ((color & 0x0000001F) << 3) | ((color & 0x0000001C) >> 2)); +} + +//! Returns A8R8G8B8 Color from R5G6B5 color +inline u32 R5G6B5toA8R8G8B8(u16 color) +{ + return 0xFF000000 | + ((color & 0xF800) << 8) | + ((color & 0x07E0) << 5) | + ((color & 0x001F) << 3); +} + +//! Returns A1R5G5B5 Color from R5G6B5 color +inline u16 R5G6B5toA1R5G5B5(u16 color) +{ + return 0x8000 | (((color & 0xFFC0) >> 1) | (color & 0x1F)); +} + +//! Returns R5G6B5 Color from A1R5G5B5 color +inline u16 A1R5G5B5toR5G6B5(u16 color) +{ + return (((color & 0x7FE0) << 1) | (color & 0x1F)); +} + +//! Returns the alpha component from A1R5G5B5 color +/** In Irrlicht, alpha refers to opacity. +\return The alpha value of the color. 0 is transparent, 1 is opaque. */ +inline u32 getAlpha(u16 color) +{ + return ((color >> 15) & 0x1); +} + +//! Returns the red component from A1R5G5B5 color. +/** Shift left by 3 to get 8 bit value. */ +inline u32 getRed(u16 color) +{ + return ((color >> 10) & 0x1F); +} + +//! Returns the green component from A1R5G5B5 color +/** Shift left by 3 to get 8 bit value. */ +inline u32 getGreen(u16 color) +{ + return ((color >> 5) & 0x1F); +} + +//! Returns the blue component from A1R5G5B5 color +/** Shift left by 3 to get 8 bit value. */ +inline u32 getBlue(u16 color) +{ + return (color & 0x1F); +} + +//! Returns the average from a 16 bit A1R5G5B5 color +inline s32 getAverage(s16 color) +{ + return ((getRed(color) << 3) + (getGreen(color) << 3) + (getBlue(color) << 3)) / 3; +} + +//! Class representing a 32 bit ARGB color. +/** The color values for alpha, red, green, and blue are +stored in a single u32. So all four values may be between 0 and 255. +Alpha in Irrlicht is opacity, so 0 is fully transparent, 255 is fully opaque (solid). +This class is used by most parts of the Irrlicht Engine +to specify a color. Another way is using the class SColorf, which +stores the color values in 4 floats. +This class must consist of only one u32 and must not use virtual functions. +*/ +class SColor +{ +public: + //! Constructor of the Color. Does nothing. + /** The color value is not initialized to save time. */ + SColor() {} + + //! Constructs the color from 4 values representing the alpha, red, green and blue component. + /** Must be values between 0 and 255. */ + constexpr SColor(u32 a, u32 r, u32 g, u32 b) : + color(((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff)) {} + + //! Constructs the color from a 32 bit value. Could be another color. + constexpr SColor(u32 clr) : + color(clr) {} + + //! Returns the alpha component of the color. + /** The alpha component defines how opaque a color is. + \return The alpha value of the color. 0 is fully transparent, 255 is fully opaque. */ + u32 getAlpha() const { return color >> 24; } + + //! Returns the red component of the color. + /** \return Value between 0 and 255, specifying how red the color is. + 0 means no red, 255 means full red. */ + u32 getRed() const { return (color >> 16) & 0xff; } + + //! Returns the green component of the color. + /** \return Value between 0 and 255, specifying how green the color is. + 0 means no green, 255 means full green. */ + u32 getGreen() const { return (color >> 8) & 0xff; } + + //! Returns the blue component of the color. + /** \return Value between 0 and 255, specifying how blue the color is. + 0 means no blue, 255 means full blue. */ + u32 getBlue() const { return color & 0xff; } + + //! Get lightness of the color in the range [0,255] + f32 getLightness() const + { + return 0.5f * (core::max_(core::max_(getRed(), getGreen()), getBlue()) + core::min_(core::min_(getRed(), getGreen()), getBlue())); + } + + //! Get luminance of the color in the range [0,255]. + f32 getLuminance() const + { + return 0.3f * getRed() + 0.59f * getGreen() + 0.11f * getBlue(); + } + + //! Get average intensity of the color in the range [0,255]. + u32 getAverage() const + { + return (getRed() + getGreen() + getBlue()) / 3; + } + + //! Sets the alpha component of the Color. + /** The alpha component defines how transparent a color should be. + \param a The alpha value of the color. 0 is fully transparent, 255 is fully opaque. */ + void setAlpha(u32 a) { color = ((a & 0xff) << 24) | (color & 0x00ffffff); } + + //! Sets the red component of the Color. + /** \param r: Has to be a value between 0 and 255. + 0 means no red, 255 means full red. */ + void setRed(u32 r) { color = ((r & 0xff) << 16) | (color & 0xff00ffff); } + + //! Sets the green component of the Color. + /** \param g: Has to be a value between 0 and 255. + 0 means no green, 255 means full green. */ + void setGreen(u32 g) { color = ((g & 0xff) << 8) | (color & 0xffff00ff); } + + //! Sets the blue component of the Color. + /** \param b: Has to be a value between 0 and 255. + 0 means no blue, 255 means full blue. */ + void setBlue(u32 b) { color = (b & 0xff) | (color & 0xffffff00); } + + //! Calculates a 16 bit A1R5G5B5 value of this color. + /** \return 16 bit A1R5G5B5 value of this color. */ + u16 toA1R5G5B5() const { return A8R8G8B8toA1R5G5B5(color); } + + //! Converts color to OpenGL color format + /** From ARGB to RGBA in 4 byte components for endian aware + passing to OpenGL + \param dest: address where the 4x8 bit OpenGL color is stored. */ + void toOpenGLColor(u8 *dest) const + { + *dest = (u8)getRed(); + *++dest = (u8)getGreen(); + *++dest = (u8)getBlue(); + *++dest = (u8)getAlpha(); + } + + //! Sets all four components of the color at once. + /** Constructs the color from 4 values representing the alpha, + red, green and blue components of the color. Must be values + between 0 and 255. + \param a: Alpha component of the color. The alpha component + defines how transparent a color should be. Has to be a value + between 0 and 255. 255 means not transparent (opaque), 0 means + fully transparent. + \param r: Sets the red component of the Color. Has to be a + value between 0 and 255. 0 means no red, 255 means full red. + \param g: Sets the green component of the Color. Has to be a + value between 0 and 255. 0 means no green, 255 means full + green. + \param b: Sets the blue component of the Color. Has to be a + value between 0 and 255. 0 means no blue, 255 means full blue. */ + void set(u32 a, u32 r, u32 g, u32 b) + { + color = (((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff)); + } + void set(u32 col) { color = col; } + + //! Compares the color to another color. + /** \return True if the colors are the same, and false if not. */ + bool operator==(const SColor &other) const { return other.color == color; } + + //! Compares the color to another color. + /** \return True if the colors are different, and false if they are the same. */ + bool operator!=(const SColor &other) const { return other.color != color; } + + //! comparison operator + /** \return True if this color is smaller than the other one */ + bool operator<(const SColor &other) const { return (color < other.color); } + + //! Adds two colors, result is clamped to 0..255 values + /** \param other Color to add to this color + \return Addition of the two colors, clamped to 0..255 values */ + SColor operator+(const SColor &other) const + { + return SColor(core::min_(getAlpha() + other.getAlpha(), 255u), + core::min_(getRed() + other.getRed(), 255u), + core::min_(getGreen() + other.getGreen(), 255u), + core::min_(getBlue() + other.getBlue(), 255u)); + } + + //! Interpolates the color with a f32 value to another color + /** \param other: Other color + \param d: value between 0.0f and 1.0f. d=0 returns other, d=1 returns this, values between interpolate. + \return Interpolated color. */ + SColor getInterpolated(const SColor &other, f32 d) const + { + d = core::clamp(d, 0.f, 1.f); + const f32 inv = 1.0f - d; + return SColor((u32)core::round32(other.getAlpha() * inv + getAlpha() * d), + (u32)core::round32(other.getRed() * inv + getRed() * d), + (u32)core::round32(other.getGreen() * inv + getGreen() * d), + (u32)core::round32(other.getBlue() * inv + getBlue() * d)); + } + + //! Returns interpolated color. ( quadratic ) + /** \param c1: first color to interpolate with + \param c2: second color to interpolate with + \param d: value between 0.0f and 1.0f. */ + SColor getInterpolated_quadratic(const SColor &c1, const SColor &c2, f32 d) const + { + // this*(1-d)*(1-d) + 2 * c1 * (1-d) + c2 * d * d; + d = core::clamp(d, 0.f, 1.f); + const f32 inv = 1.f - d; + const f32 mul0 = inv * inv; + const f32 mul1 = 2.f * d * inv; + const f32 mul2 = d * d; + + return SColor( + core::clamp(core::floor32( + getAlpha() * mul0 + c1.getAlpha() * mul1 + c2.getAlpha() * mul2), + 0, 255), + core::clamp(core::floor32( + getRed() * mul0 + c1.getRed() * mul1 + c2.getRed() * mul2), + 0, 255), + core::clamp(core::floor32( + getGreen() * mul0 + c1.getGreen() * mul1 + c2.getGreen() * mul2), + 0, 255), + core::clamp(core::floor32( + getBlue() * mul0 + c1.getBlue() * mul1 + c2.getBlue() * mul2), + 0, 255)); + } + + //! set the color by expecting data in the given format + /** \param data: must point to valid memory containing color information in the given format + \param format: tells the format in which data is available + */ + void setData(const void *data, ECOLOR_FORMAT format) + { + switch (format) { + case ECF_A1R5G5B5: + color = A1R5G5B5toA8R8G8B8(*(u16 *)data); + break; + case ECF_R5G6B5: + color = R5G6B5toA8R8G8B8(*(u16 *)data); + break; + case ECF_A8R8G8B8: + color = *(u32 *)data; + break; + case ECF_R8G8B8: { + const u8 *p = (u8 *)data; + set(255, p[0], p[1], p[2]); + } break; + default: + color = 0xffffffff; + break; + } + } + + //! Write the color to data in the defined format + /** \param data: target to write the color. Must contain sufficiently large memory to receive the number of bytes neede for format + \param format: tells the format used to write the color into data + */ + void getData(void *data, ECOLOR_FORMAT format) const + { + switch (format) { + case ECF_A1R5G5B5: { + u16 *dest = (u16 *)data; + *dest = video::A8R8G8B8toA1R5G5B5(color); + } break; + + case ECF_R5G6B5: { + u16 *dest = (u16 *)data; + *dest = video::A8R8G8B8toR5G6B5(color); + } break; + + case ECF_R8G8B8: { + u8 *dest = (u8 *)data; + dest[0] = (u8)getRed(); + dest[1] = (u8)getGreen(); + dest[2] = (u8)getBlue(); + } break; + + case ECF_A8R8G8B8: { + u32 *dest = (u32 *)data; + *dest = color; + } break; + + default: + break; + } + } + + //! color in A8R8G8B8 Format + u32 color; +}; + +//! Class representing a color with four floats. +/** The color values for red, green, blue +and alpha are each stored in a 32 bit floating point variable. +So all four values may be between 0.0f and 1.0f. +Another, faster way to define colors is using the class SColor, which +stores the color values in a single 32 bit integer. +*/ +class SColorf +{ +public: + //! Default constructor for SColorf. + /** Sets red, green and blue to 0.0f and alpha to 1.0f. */ + SColorf() : + r(0.0f), g(0.0f), b(0.0f), a(1.0f) {} + + //! Constructs a color from up to four color values: red, green, blue, and alpha. + /** \param r: Red color component. Should be a value between + 0.0f meaning no red and 1.0f, meaning full red. + \param g: Green color component. Should be a value between 0.0f + meaning no green and 1.0f, meaning full green. + \param b: Blue color component. Should be a value between 0.0f + meaning no blue and 1.0f, meaning full blue. + \param a: Alpha color component of the color. The alpha + component defines how transparent a color should be. Has to be + a value between 0.0f and 1.0f, 1.0f means not transparent + (opaque), 0.0f means fully transparent. */ + SColorf(f32 r, f32 g, f32 b, f32 a = 1.0f) : + r(r), g(g), b(b), a(a) {} + + //! Constructs a color from 32 bit Color. + /** \param c: 32 bit color from which this SColorf class is + constructed from. */ + SColorf(SColor c) + { + const f32 inv = 1.0f / 255.0f; + r = c.getRed() * inv; + g = c.getGreen() * inv; + b = c.getBlue() * inv; + a = c.getAlpha() * inv; + } + + //! Converts this color to a SColor without floats. + SColor toSColor() const + { + return SColor((u32)core::round32(a * 255.0f), (u32)core::round32(r * 255.0f), (u32)core::round32(g * 255.0f), (u32)core::round32(b * 255.0f)); + } + + //! Sets three color components to new values at once. + /** \param rr: Red color component. Should be a value between 0.0f meaning + no red (=black) and 1.0f, meaning full red. + \param gg: Green color component. Should be a value between 0.0f meaning + no green (=black) and 1.0f, meaning full green. + \param bb: Blue color component. Should be a value between 0.0f meaning + no blue (=black) and 1.0f, meaning full blue. */ + void set(f32 rr, f32 gg, f32 bb) + { + r = rr; + g = gg; + b = bb; + } + + //! Sets all four color components to new values at once. + /** \param aa: Alpha component. Should be a value between 0.0f meaning + fully transparent and 1.0f, meaning opaque. + \param rr: Red color component. Should be a value between 0.0f meaning + no red and 1.0f, meaning full red. + \param gg: Green color component. Should be a value between 0.0f meaning + no green and 1.0f, meaning full green. + \param bb: Blue color component. Should be a value between 0.0f meaning + no blue and 1.0f, meaning full blue. */ + void set(f32 aa, f32 rr, f32 gg, f32 bb) + { + a = aa; + r = rr; + g = gg; + b = bb; + } + + //! Interpolates the color with a f32 value to another color + /** \param other: Other color + \param d: value between 0.0f and 1.0f + \return Interpolated color. */ + SColorf getInterpolated(const SColorf &other, f32 d) const + { + d = core::clamp(d, 0.f, 1.f); + const f32 inv = 1.0f - d; + return SColorf(other.r * inv + r * d, + other.g * inv + g * d, other.b * inv + b * d, other.a * inv + a * d); + } + + //! Returns interpolated color. ( quadratic ) + /** \param c1: first color to interpolate with + \param c2: second color to interpolate with + \param d: value between 0.0f and 1.0f. */ + inline SColorf getInterpolated_quadratic(const SColorf &c1, const SColorf &c2, + f32 d) const + { + d = core::clamp(d, 0.f, 1.f); + // this*(1-d)*(1-d) + 2 * c1 * (1-d) + c2 * d * d; + const f32 inv = 1.f - d; + const f32 mul0 = inv * inv; + const f32 mul1 = 2.f * d * inv; + const f32 mul2 = d * d; + + return SColorf(r * mul0 + c1.r * mul1 + c2.r * mul2, + g * mul0 + c1.g * mul1 + c2.g * mul2, + b * mul0 + c1.b * mul1 + c2.b * mul2, + a * mul0 + c1.a * mul1 + c2.a * mul2); + } + + //! Sets a color component by index. R=0, G=1, B=2, A=3 + void setColorComponentValue(s32 index, f32 value) + { + switch (index) { + case 0: + r = value; + break; + case 1: + g = value; + break; + case 2: + b = value; + break; + case 3: + a = value; + break; + } + } + + //! Returns the alpha component of the color in the range 0.0 (transparent) to 1.0 (opaque) + f32 getAlpha() const { return a; } + + //! Returns the red component of the color in the range 0.0 to 1.0 + f32 getRed() const { return r; } + + //! Returns the green component of the color in the range 0.0 to 1.0 + f32 getGreen() const { return g; } + + //! Returns the blue component of the color in the range 0.0 to 1.0 + f32 getBlue() const { return b; } + + //! red color component + f32 r; + + //! green color component + f32 g; + + //! blue component + f32 b; + + //! alpha color component + f32 a; +}; + +//! Class representing a color in HSL format +/** The color values for hue, saturation, luminance +are stored in 32bit floating point variables. Hue is in range [0,360], +Luminance and Saturation are in percent [0,100] +*/ +class SColorHSL +{ +public: + constexpr SColorHSL(f32 h = 0.f, f32 s = 0.f, f32 l = 0.f) : + Hue(h), Saturation(s), Luminance(l) {} + + void fromRGB(const SColorf &color); + void toRGB(SColorf &color) const; + + f32 Hue; + f32 Saturation; + f32 Luminance; + +private: + inline f32 toRGB1(f32 rm1, f32 rm2, f32 rh) const; +}; + +inline void SColorHSL::fromRGB(const SColorf &color) +{ + const f32 maxVal = core::max_(color.getRed(), color.getGreen(), color.getBlue()); + const f32 minVal = (f32)core::min_(color.getRed(), color.getGreen(), color.getBlue()); + Luminance = (maxVal + minVal) * 50; + if (core::equals(maxVal, minVal)) { + Hue = 0.f; + Saturation = 0.f; + return; + } + + const f32 delta = maxVal - minVal; + if (Luminance <= 50) { + Saturation = (delta) / (maxVal + minVal); + } else { + Saturation = (delta) / (2 - maxVal - minVal); + } + Saturation *= 100; + + if (core::equals(maxVal, color.getRed())) + Hue = (color.getGreen() - color.getBlue()) / delta; + else if (core::equals(maxVal, color.getGreen())) + Hue = 2 + ((color.getBlue() - color.getRed()) / delta); + else // blue is max + Hue = 4 + ((color.getRed() - color.getGreen()) / delta); + + Hue *= 60.0f; + while (Hue < 0.f) + Hue += 360; +} + +inline void SColorHSL::toRGB(SColorf &color) const +{ + const f32 l = Luminance / 100; + if (core::iszero(Saturation)) { // grey + color.set(l, l, l); + return; + } + + f32 rm2; + + if (Luminance <= 50) { + rm2 = l + l * (Saturation / 100); + } else { + rm2 = l + (1 - l) * (Saturation / 100); + } + + const f32 rm1 = 2.0f * l - rm2; + + const f32 h = Hue / 360.0f; + color.set(toRGB1(rm1, rm2, h + 1.f / 3.f), + toRGB1(rm1, rm2, h), + toRGB1(rm1, rm2, h - 1.f / 3.f)); +} + +// algorithm from Foley/Van-Dam +inline f32 SColorHSL::toRGB1(f32 rm1, f32 rm2, f32 rh) const +{ + if (rh < 0) + rh += 1; + if (rh > 1) + rh -= 1; + + if (rh < 1.f / 6.f) + rm1 = rm1 + (rm2 - rm1) * rh * 6.f; + else if (rh < 0.5f) + rm1 = rm2; + else if (rh < 2.f / 3.f) + rm1 = rm1 + (rm2 - rm1) * ((2.f / 3.f) - rh) * 6.f; + + return rm1; +} + +} // end namespace video +} // end namespace irr diff --git a/irr/include/SExposedVideoData.h b/irr/include/SExposedVideoData.h new file mode 100644 index 000000000..346bd037c --- /dev/null +++ b/irr/include/SExposedVideoData.h @@ -0,0 +1,89 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +namespace irr +{ +namespace video +{ + +//! structure for holding data describing a driver and operating system specific data. +/** This data can be retrieved by IVideoDriver::getExposedVideoData(). Use this with caution. +This only should be used to make it possible to extend the engine easily without +modification of its source. Note that this structure does not contain any valid data, if +you are using the software or the null device. +*/ +struct SExposedVideoData +{ + SExposedVideoData() + { + OpenGLWin32.HDc = 0; + OpenGLWin32.HRc = 0; + OpenGLWin32.HWnd = 0; + } + explicit SExposedVideoData(void *Window) + { + OpenGLWin32.HDc = 0; + OpenGLWin32.HRc = 0; + OpenGLWin32.HWnd = Window; + } + + struct SOpenGLWin32 + { + //! Private GDI Device Context. + /** Get if for example with: HDC h = reinterpret_cast(exposedData.OpenGLWin32.HDc) */ + void *HDc; + + //! Permanent Rendering Context. + /** Get if for example with: HGLRC h = reinterpret_cast(exposedData.OpenGLWin32.HRc) */ + void *HRc; + + //! Window handle. + /** Get with for example with: HWND h = reinterpret_cast(exposedData.OpenGLWin32.HWnd) */ + void *HWnd; + }; + + struct SOpenGLLinux + { + // XWindow handles + void *X11Display; + void *X11Context; + unsigned long X11Window; + unsigned long GLXWindow; + }; + + struct SOpenGLOSX + { + //! The NSOpenGLContext object. + void *Context; + + //! The NSWindow object. + void *Window; + }; + + struct SOpenGLFB + { + //! The EGLNativeWindowType object. + void *Window; + }; + + struct SOGLESAndroid + { + //! The ANativeWindow object. + void *Window; + }; + + union + { + SOpenGLWin32 OpenGLWin32; + SOpenGLLinux OpenGLLinux; + SOpenGLOSX OpenGLOSX; + SOpenGLFB OpenGLFB; + SOGLESAndroid OGLESAndroid; + }; +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/include/SIrrCreationParameters.h b/irr/include/SIrrCreationParameters.h new file mode 100644 index 000000000..26e46e324 --- /dev/null +++ b/irr/include/SIrrCreationParameters.h @@ -0,0 +1,267 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "EDriverTypes.h" +#include "EDeviceTypes.h" +#include "dimension2d.h" +#include "ILogger.h" +#include "position2d.h" +#include "path.h" +#include "IrrCompileConfig.h" // for IRRLICHT_SDK_VERSION + +namespace irr +{ +class IEventReceiver; + +//! Structure for holding Irrlicht Device creation parameters. +/** This structure is used in the createDeviceEx() function. */ +struct SIrrlichtCreationParameters +{ + //! Constructs a SIrrlichtCreationParameters structure with default values. + SIrrlichtCreationParameters() : + DeviceType(EIDT_BEST), + DriverType(video::EDT_OPENGL), + WindowSize(core::dimension2d(800, 600)), + WindowPosition(core::position2di(-1, -1)), + Bits(32), + ZBufferBits(24), + Fullscreen(false), + WindowMaximized(false), + WindowResizable(2), + Stencilbuffer(true), + Vsync(false), + AntiAlias(0), + WithAlphaChannel(false), + Doublebuffer(true), + Stereobuffer(false), + EventReceiver(0), + WindowId(0), +#ifdef _DEBUG + LoggingLevel(ELL_DEBUG), +#else + LoggingLevel(ELL_INFORMATION), +#endif + SDK_version_do_not_use(IRRLICHT_SDK_VERSION), + PrivateData(0), +#ifdef IRR_MOBILE_PATHS + OGLES2ShaderPath("media/Shaders/") +#else + OGLES2ShaderPath("../../media/Shaders/") +#endif + { + } + + SIrrlichtCreationParameters(const SIrrlichtCreationParameters &other) : + SDK_version_do_not_use(IRRLICHT_SDK_VERSION) + { + *this = other; + } + + SIrrlichtCreationParameters &operator=(const SIrrlichtCreationParameters &other) + { + DeviceType = other.DeviceType; + DriverType = other.DriverType; + WindowSize = other.WindowSize; + WindowPosition = other.WindowPosition; + Bits = other.Bits; + ZBufferBits = other.ZBufferBits; + Fullscreen = other.Fullscreen; + WindowMaximized = other.WindowMaximized; + WindowResizable = other.WindowResizable; + Stencilbuffer = other.Stencilbuffer; + Vsync = other.Vsync; + AntiAlias = other.AntiAlias; + WithAlphaChannel = other.WithAlphaChannel; + Doublebuffer = other.Doublebuffer; + Stereobuffer = other.Stereobuffer; + EventReceiver = other.EventReceiver; + WindowId = other.WindowId; + LoggingLevel = other.LoggingLevel; + PrivateData = other.PrivateData; + OGLES2ShaderPath = other.OGLES2ShaderPath; + return *this; + } + + //! Type of the device. + /** This setting decides the windowing system used by the device, most device types are native + to a specific operating system and so may not be available. + EIDT_WIN32 is only available on Windows desktops, + EIDT_COCOA is only available on Mac OSX, + EIDT_X11 is available on Linux, Solaris, BSD and other operating systems which use X11, + EIDT_SDL is available on most systems if compiled in, + EIDT_BEST will select the best available device for your operating system. + Default: EIDT_BEST. */ + E_DEVICE_TYPE DeviceType; + + //! Type of video driver used to render graphics. + video::E_DRIVER_TYPE DriverType; + + //! Size of the window or the video mode in fullscreen mode. Default: 800x600 + core::dimension2d WindowSize; + + //! Position of the window on-screen. Default: (-1, -1) or centered. + core::position2di WindowPosition; + + //! Minimum Bits per pixel of the color buffer in fullscreen mode. Ignored if windowed mode. Default: 32. + u8 Bits; + + //! Minimum Bits per pixel of the depth buffer. Default: 24. + u8 ZBufferBits; + + //! Should be set to true if the device should run in fullscreen. + /** Otherwise the device runs in windowed mode. Default: false. */ + bool Fullscreen; + + //! Maximised window. (Only supported on SDL.) Default: false + bool WindowMaximized; + + //! Should a non-fullscreen window be resizable. + /** Might not be supported by all devices. Ignored when Fullscreen is true. + Values: 0 = not resizable, 1 = resizable, 2 = system decides default itself + Default: 2*/ + u8 WindowResizable; + + //! Specifies if the stencil buffer should be enabled. + /** Set this to true, if you want the engine be able to draw + stencil buffer shadows. Note that not all drivers are able to + use the stencil buffer, hence it can be ignored during device + creation. Without the stencil buffer no shadows will be drawn. + Default: true. */ + bool Stencilbuffer; + + //! Specifies vertical synchronization. + /** If set to true, the driver will wait for the vertical + retrace period, otherwise not. May be silently ignored. + Default: false */ + bool Vsync; + + //! Specifies if the device should use fullscreen anti aliasing + /** Makes sharp/pixelated edges softer, but requires more + performance. Also, 2D elements might look blurred with this + switched on. The resulting rendering quality also depends on + the hardware and driver you are using, your program might look + different on different hardware with this. So if you are + writing a game/application with AntiAlias switched on, it would + be a good idea to make it possible to switch this option off + again by the user. + The value is the maximal antialiasing factor requested for + the device. The creation method will automatically try smaller + values if no window can be created with the given value. + Value one is usually the same as 0 (disabled), but might be a + special value on some platforms. On D3D devices it maps to + NONMASKABLE. + Default value: 0 - disabled */ + u8 AntiAlias; + + //! Whether the main framebuffer uses an alpha channel. + /** In some situations it might be desirable to get a color + buffer with an alpha channel, e.g. when rendering into a + transparent window or overlay. If this flag is set the device + tries to create a framebuffer with alpha channel. + If this flag is set, only color buffers with alpha channel + are considered. Otherwise, it depends on the actual hardware + if the colorbuffer has an alpha channel or not. + Default value: false */ + bool WithAlphaChannel; + + //! Whether the main framebuffer uses doublebuffering. + /** This should be usually enabled, in order to avoid render + artifacts on the visible framebuffer. However, it might be + useful to use only one buffer on very small devices. If no + doublebuffering is available, the drivers will fall back to + single buffers. Default value: true */ + bool Doublebuffer; + + //! Specifies if the device should use stereo buffers + /** Some high-end gfx cards support two framebuffers for direct + support of stereoscopic output devices. If this flag is set the + device tries to create a stereo context. + Currently only supported by OpenGL. + Default value: false */ + bool Stereobuffer; + + //! A user created event receiver. + IEventReceiver *EventReceiver; + + //! Window Id. + /** If this is set to a value other than 0, the Irrlicht Engine + will be created in an already existing window. + For Windows, set this to the HWND of the window you want. + The windowSize and FullScreen options will be ignored when using + the WindowId parameter. Default this is set to 0. + To make Irrlicht run inside the custom window, you still will + have to draw Irrlicht on your own. You can use this loop, as + usual: + \code + while (device->run()) + { + driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, 0); + smgr->drawAll(); + driver->endScene(); + } + \endcode + Instead of this, you can also simply use your own message loop + using GetMessage, DispatchMessage and whatever. Calling + IrrlichtDevice::run() will cause Irrlicht to dispatch messages + internally too. You need not call Device->run() if you want to + do your own message dispatching loop, but Irrlicht will not be + able to fetch user input then and you have to do it on your own + using the window messages, DirectInput, or whatever. Also, + you'll have to increment the Irrlicht timer. + An alternative, own message dispatching loop without + device->run() would look like this: + \code + MSG msg; + while (true) + { + if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + + if (msg.message == WM_QUIT) + break; + } + + // increase virtual timer time + device->getTimer()->tick(); + + // draw engine picture + driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, 0); + smgr->drawAll(); + driver->endScene(); + } + \endcode + However, there is no need to draw the picture this often. Just + do it how you like. */ + void *WindowId; + + //! Specifies the logging level used in the logging interface. + /** The default value is ELL_INFORMATION. You can access the ILogger interface + later on from the IrrlichtDevice with getLogger() and set another level. + But if you need more or less logging information already from device creation, + then you have to change it here. + */ + ELOG_LEVEL LoggingLevel; + + //! Don't use or change this parameter. + /** Always set it to IRRLICHT_SDK_VERSION, which is done by default. + This is needed for sdk version checks. */ + const c8 *const SDK_version_do_not_use; + + //! Define some private data storage. + /** Used when platform devices need access to OS specific data structures etc. + This is only used for Android at the moment in order to access the native + Java RE. */ + void *PrivateData; + + //! Set the path where default-shaders to simulate the fixed-function pipeline can be found. + /** This is about the shaders which can be found in media/Shaders by default. It's only necessary + to set when using OGL-ES 2.0 */ + irr::io::path OGLES2ShaderPath; +}; + +} // end namespace irr diff --git a/irr/include/SMaterial.h b/irr/include/SMaterial.h new file mode 100644 index 000000000..c803f5fde --- /dev/null +++ b/irr/include/SMaterial.h @@ -0,0 +1,566 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "SColor.h" +#include "matrix4.h" +#include "irrArray.h" +#include "irrMath.h" +#include "EMaterialTypes.h" +#include "EMaterialProps.h" +#include "SMaterialLayer.h" +#include "IrrCompileConfig.h" // for IRRLICHT_API + +namespace irr +{ +namespace video +{ +class ITexture; + +//! Flag for MaterialTypeParam (in combination with EMT_ONETEXTURE_BLEND) or for BlendFactor +//! BlendFunc = source * sourceFactor + dest * destFactor +enum E_BLEND_FACTOR +{ + EBF_ZERO = 0, //!< src & dest (0, 0, 0, 0) + EBF_ONE, //!< src & dest (1, 1, 1, 1) + EBF_DST_COLOR, //!< src (destR, destG, destB, destA) + EBF_ONE_MINUS_DST_COLOR, //!< src (1-destR, 1-destG, 1-destB, 1-destA) + EBF_SRC_COLOR, //!< dest (srcR, srcG, srcB, srcA) + EBF_ONE_MINUS_SRC_COLOR, //!< dest (1-srcR, 1-srcG, 1-srcB, 1-srcA) + EBF_SRC_ALPHA, //!< src & dest (srcA, srcA, srcA, srcA) + EBF_ONE_MINUS_SRC_ALPHA, //!< src & dest (1-srcA, 1-srcA, 1-srcA, 1-srcA) + EBF_DST_ALPHA, //!< src & dest (destA, destA, destA, destA) + EBF_ONE_MINUS_DST_ALPHA, //!< src & dest (1-destA, 1-destA, 1-destA, 1-destA) + EBF_SRC_ALPHA_SATURATE //!< src (min(srcA, 1-destA), idem, ...) +}; + +//! Values defining the blend operation +enum E_BLEND_OPERATION +{ + EBO_NONE = 0, //!< No blending happens + EBO_ADD, //!< Default blending adds the color values + EBO_SUBTRACT, //!< This mode subtracts the color values + EBO_REVSUBTRACT, //!< This modes subtracts destination from source + EBO_MIN, //!< Choose minimum value of each color channel + EBO_MAX, //!< Choose maximum value of each color channel + EBO_MIN_FACTOR, //!< Choose minimum value of each color channel after applying blend factors, not widely supported + EBO_MAX_FACTOR, //!< Choose maximum value of each color channel after applying blend factors, not widely supported + EBO_MIN_ALPHA, //!< Choose minimum value of each color channel based on alpha value, not widely supported + EBO_MAX_ALPHA //!< Choose maximum value of each color channel based on alpha value, not widely supported +}; + +//! MaterialTypeParam: e.g. DirectX: D3DTOP_MODULATE, D3DTOP_MODULATE2X, D3DTOP_MODULATE4X +enum E_MODULATE_FUNC +{ + EMFN_MODULATE_1X = 1, + EMFN_MODULATE_2X = 2, + EMFN_MODULATE_4X = 4 +}; + +//! Comparison function, e.g. for depth buffer test +enum E_COMPARISON_FUNC +{ + //! Depth test disabled (disable also write to depth buffer) + ECFN_DISABLED = 0, + //! <= test, default for e.g. depth test + ECFN_LESSEQUAL = 1, + //! Exact equality + ECFN_EQUAL = 2, + //! exclusive less comparison, i.e. < + ECFN_LESS, + //! Succeeds almost always, except for exact equality + ECFN_NOTEQUAL, + //! >= test + ECFN_GREATEREQUAL, + //! inverse of <= + ECFN_GREATER, + //! test succeeds always + ECFN_ALWAYS, + //! Test never succeeds + ECFN_NEVER +}; + +//! Enum values for enabling/disabling color planes for rendering +enum E_COLOR_PLANE +{ + //! No color enabled + ECP_NONE = 0, + //! Alpha enabled + ECP_ALPHA = 1, + //! Red enabled + ECP_RED = 2, + //! Green enabled + ECP_GREEN = 4, + //! Blue enabled + ECP_BLUE = 8, + //! All colors, no alpha + ECP_RGB = 14, + //! All planes enabled + ECP_ALL = 15 +}; + +//! Source of the alpha value to take +/** This is currently only supported in EMT_ONETEXTURE_BLEND. You can use an +or'ed combination of values. Alpha values are modulated (multiplied). */ +enum E_ALPHA_SOURCE +{ + //! Use no alpha, somewhat redundant with other settings + EAS_NONE = 0, + //! Use vertex color alpha + EAS_VERTEX_COLOR, + //! Use texture alpha channel + EAS_TEXTURE +}; + +//! Pack srcFact, dstFact, Modulate and alpha source to MaterialTypeParam or BlendFactor +/** alpha source can be an OR'ed combination of E_ALPHA_SOURCE values. */ +inline f32 pack_textureBlendFunc(const E_BLEND_FACTOR srcFact, const E_BLEND_FACTOR dstFact, + const E_MODULATE_FUNC modulate = EMFN_MODULATE_1X, const u32 alphaSource = EAS_TEXTURE) +{ + const u32 tmp = (alphaSource << 20) | (modulate << 16) | (srcFact << 12) | (dstFact << 8) | (srcFact << 4) | dstFact; + return FR(tmp); +} + +//! Pack srcRGBFact, dstRGBFact, srcAlphaFact, dstAlphaFact, Modulate and alpha source to MaterialTypeParam or BlendFactor +/** alpha source can be an OR'ed combination of E_ALPHA_SOURCE values. */ +inline f32 pack_textureBlendFuncSeparate(const E_BLEND_FACTOR srcRGBFact, const E_BLEND_FACTOR dstRGBFact, + const E_BLEND_FACTOR srcAlphaFact, const E_BLEND_FACTOR dstAlphaFact, + const E_MODULATE_FUNC modulate = EMFN_MODULATE_1X, const u32 alphaSource = EAS_TEXTURE) +{ + const u32 tmp = (alphaSource << 20) | (modulate << 16) | (srcAlphaFact << 12) | (dstAlphaFact << 8) | (srcRGBFact << 4) | dstRGBFact; + return FR(tmp); +} + +//! Unpack srcFact, dstFact, modulo and alphaSource factors +/** The fields don't use the full byte range, so we could pack even more... */ +inline void unpack_textureBlendFunc(E_BLEND_FACTOR &srcFact, E_BLEND_FACTOR &dstFact, + E_MODULATE_FUNC &modulo, u32 &alphaSource, const f32 param) +{ + const u32 state = IR(param); + alphaSource = (state & 0x00F00000) >> 20; + modulo = E_MODULATE_FUNC((state & 0x000F0000) >> 16); + srcFact = E_BLEND_FACTOR((state & 0x000000F0) >> 4); + dstFact = E_BLEND_FACTOR((state & 0x0000000F)); +} + +//! Unpack srcRGBFact, dstRGBFact, srcAlphaFact, dstAlphaFact, modulo and alphaSource factors +/** The fields don't use the full byte range, so we could pack even more... */ +inline void unpack_textureBlendFuncSeparate(E_BLEND_FACTOR &srcRGBFact, E_BLEND_FACTOR &dstRGBFact, + E_BLEND_FACTOR &srcAlphaFact, E_BLEND_FACTOR &dstAlphaFact, + E_MODULATE_FUNC &modulo, u32 &alphaSource, const f32 param) +{ + const u32 state = IR(param); + alphaSource = (state & 0x00F00000) >> 20; + modulo = E_MODULATE_FUNC((state & 0x000F0000) >> 16); + srcAlphaFact = E_BLEND_FACTOR((state & 0x0000F000) >> 12); + dstAlphaFact = E_BLEND_FACTOR((state & 0x00000F00) >> 8); + srcRGBFact = E_BLEND_FACTOR((state & 0x000000F0) >> 4); + dstRGBFact = E_BLEND_FACTOR((state & 0x0000000F)); +} + +//! has blend factor alphablending +inline bool textureBlendFunc_hasAlpha(const E_BLEND_FACTOR factor) +{ + switch (factor) { + case EBF_SRC_ALPHA: + case EBF_ONE_MINUS_SRC_ALPHA: + case EBF_DST_ALPHA: + case EBF_ONE_MINUS_DST_ALPHA: + case EBF_SRC_ALPHA_SATURATE: + return true; + default: + return false; + } +} + +//! These flags are used to specify the anti-aliasing and smoothing modes +/** Techniques supported are multisampling, geometry smoothing, and alpha +to coverage. +Some drivers don't support a per-material setting of the anti-aliasing +modes. In those cases, FSAA/multisampling is defined by the device mode +chosen upon creation via irr::SIrrCreationParameters. +*/ +enum E_ANTI_ALIASING_MODE +{ + //! Use to turn off anti-aliasing for this material + EAAM_OFF = 0, + //! Default anti-aliasing mode + EAAM_SIMPLE = 1, + //! High-quality anti-aliasing, not always supported, automatically enables SIMPLE mode + EAAM_QUALITY = 3, + //! Enhanced anti-aliasing for transparent materials + /** Usually used with EMT_TRANSPARENT_ALPHA_CHANNEL_REF and multisampling. */ + EAAM_ALPHA_TO_COVERAGE = 4 +}; + +//! These flags allow to define the interpretation of vertex color when lighting is enabled +/** Without lighting being enabled the vertex color is the only value defining the fragment color. +Once lighting is enabled, the four values for diffuse, ambient, emissive, and specular take over. +With these flags it is possible to define which lighting factor shall be defined by the vertex color +instead of the lighting factor which is the same for all faces of that material. +The default is to use vertex color for the diffuse value, another pretty common value is to use +vertex color for both diffuse and ambient factor. */ +enum E_COLOR_MATERIAL +{ + //! Don't use vertex color for lighting + ECM_NONE = 0, + //! Use vertex color for diffuse light, this is default + ECM_DIFFUSE, + //! Use vertex color for ambient light + ECM_AMBIENT, + //! Use vertex color for emissive light + ECM_EMISSIVE, + //! Use vertex color for specular light + ECM_SPECULAR, + //! Use vertex color for both diffuse and ambient light + ECM_DIFFUSE_AND_AMBIENT +}; + +//! Names for polygon offset direction +const c8 *const PolygonOffsetDirectionNames[] = { + "Back", + "Front", + 0, + }; + +//! For SMaterial.ZWriteEnable +enum E_ZWRITE +{ + //! zwrite always disabled for this material + EZW_OFF = 0, + + //! This is the default setting for SMaterial and tries to handle things automatically. + //! This is what you want to set to enable zwriting. + //! Usually zwriting is enabled non-transparent materials - as far as Irrlicht can recognize those. + //! Basically Irrlicht tries to handle the zwriting for you and assumes transparent materials don't need it. + //! This is addionally affected by IVideoDriver::setAllowZWriteOnTransparent + EZW_AUTO, + + //! zwrite always enabled for this material + EZW_ON +}; + +//! Names for E_ZWRITE +const c8 *const ZWriteNames[] = { + "Off", + "Auto", + "On", + 0, + }; + +//! Maximum number of texture an SMaterial can have. +/** SMaterial might ignore some textures in most function, like assignment and comparison, + when SIrrlichtCreationParameters::MaxTextureUnits is set to a lower number. +*/ +const u32 MATERIAL_MAX_TEXTURES = 4; + +//! Struct for holding parameters for a material renderer +// Note for implementors: Serialization is in CNullDriver +class SMaterial +{ +public: + //! Default constructor. Creates a solid, lit material with white colors + SMaterial() : + MaterialType(EMT_SOLID), AmbientColor(255, 255, 255, 255), + DiffuseColor(255, 255, 255, 255), EmissiveColor(0, 0, 0, 0), + SpecularColor(255, 255, 255, 255), Shininess(0.0f), + MaterialTypeParam(0.0f), Thickness(1.0f), ZBuffer(ECFN_LESSEQUAL), + AntiAliasing(EAAM_SIMPLE), ColorMask(ECP_ALL), ColorMaterial(ECM_DIFFUSE), + BlendOperation(EBO_NONE), BlendFactor(0.0f), PolygonOffsetDepthBias(0.f), + PolygonOffsetSlopeScale(0.f), Wireframe(false), PointCloud(false), + GouraudShading(true), Lighting(true), ZWriteEnable(EZW_AUTO), + BackfaceCulling(true), FrontfaceCulling(false), FogEnable(false), + NormalizeNormals(false), UseMipMaps(true) + { + } + + //! Texture layer array. + SMaterialLayer TextureLayers[MATERIAL_MAX_TEXTURES]; + + //! Type of the material. Specifies how everything is blended together + E_MATERIAL_TYPE MaterialType; + + //! How much ambient light (a global light) is reflected by this material. + /** The default is full white, meaning objects are completely + globally illuminated. Reduce this if you want to see diffuse + or specular light effects. */ + SColor AmbientColor; + + //! How much diffuse light coming from a light source is reflected by this material. + /** The default is full white. */ + SColor DiffuseColor; + + //! Light emitted by this material. Default is to emit no light. + SColor EmissiveColor; + + //! How much specular light (highlights from a light) is reflected. + /** The default is to reflect white specular light. See + SMaterial::Shininess on how to enable specular lights. */ + SColor SpecularColor; + + //! Value affecting the size of specular highlights. + /** A value of 20 is common. If set to 0, no specular + highlights are being used. To activate, simply set the + shininess of a material to a value in the range [0.5;128]: + \code + sceneNode->getMaterial(0).Shininess = 20.0f; + \endcode + + You can change the color of the highlights using + \code + sceneNode->getMaterial(0).SpecularColor.set(255,255,255,255); + \endcode + + The specular color of the dynamic lights + (SLight::SpecularColor) will influence the the highlight color + too, but they are set to a useful value by default when + creating the light scene node.*/ + f32 Shininess; + + //! Free parameter, dependent on the material type. + /** Mostly ignored, used for example in + EMT_TRANSPARENT_ALPHA_CHANNEL and EMT_ONETEXTURE_BLEND. */ + f32 MaterialTypeParam; + + //! Thickness of non-3dimensional elements such as lines and points. + f32 Thickness; + + //! Is the ZBuffer enabled? Default: ECFN_LESSEQUAL + /** If you want to disable depth test for this material + just set this parameter to ECFN_DISABLED. + Values are from E_COMPARISON_FUNC. */ + u8 ZBuffer; + + //! Sets the antialiasing mode + /** Values are chosen from E_ANTI_ALIASING_MODE. Default is + EAAM_SIMPLE, i.e. simple multi-sample anti-aliasing. */ + u8 AntiAliasing; + + //! Defines the enabled color planes + /** Values are defined as or'ed values of the E_COLOR_PLANE enum. + Only enabled color planes will be rendered to the current render + target. Typical use is to disable all colors when rendering only to + depth or stencil buffer, or using Red and Green for Stereo rendering. */ + u8 ColorMask : 4; + + //! Defines the interpretation of vertex color in the lighting equation + /** Values should be chosen from E_COLOR_MATERIAL. + When lighting is enabled, vertex color can be used instead of the + material values for light modulation. This allows to easily change e.g. the + diffuse light behavior of each face. The default, ECM_DIFFUSE, will result in + a very similar rendering as with lighting turned off, just with light shading. */ + u8 ColorMaterial : 3; + + //! Store the blend operation of choice + /** Values to be chosen from E_BLEND_OPERATION. */ + E_BLEND_OPERATION BlendOperation : 4; + + //! Store the blend factors + /** textureBlendFunc/textureBlendFuncSeparate functions should be used to write + properly blending factors to this parameter. + Due to historical reasons this parameter is not used for material type + EMT_ONETEXTURE_BLEND which uses MaterialTypeParam instead for the blend factor. + It's generally used only for materials without any blending otherwise (like EMT_SOLID). + It's main use is to allow having shader materials which can enable/disable + blending after they have been created. + When you set this you usually also have to set BlendOperation to a value != EBO_NONE + (setting it to EBO_ADD is probably the most common one value). */ + f32 BlendFactor; + + //! A constant z-buffer offset for a polygon/line/point + /** The range of the value is driver specific. + On OpenGL you get units which are multiplied by the smallest value that is guaranteed to produce a resolvable offset. + On D3D9 you can pass a range between -1 and 1. But you should likely divide it by the range of the depthbuffer. + Like dividing by 65535.0 for a 16 bit depthbuffer. Thought it still might produce too large of a bias. + Some article (https://aras-p.info/blog/2008/06/12/depth-bias-and-the-power-of-deceiving-yourself/) + recommends multiplying by 2.0*4.8e-7 (and strangely on both 16 bit and 24 bit). */ + f32 PolygonOffsetDepthBias; + + //! Variable Z-Buffer offset based on the slope of the polygon. + /** For polygons looking flat at a camera you could use 0 (for example in a 2D game) + But in most cases you will have polygons rendered at a certain slope. + The driver will calculate the slope for you and this value allows to scale that slope. + The complete polygon offset is: PolygonOffsetSlopeScale*slope + PolygonOffsetDepthBias + A good default here is to use 1.f if you want to push the polygons away from the camera + and -1.f to pull them towards the camera. */ + f32 PolygonOffsetSlopeScale; + + //! Draw as wireframe or filled triangles? Default: false + bool Wireframe : 1; + + //! Draw as point cloud or filled triangles? Default: false + bool PointCloud : 1; + + //! Flat or Gouraud shading? Default: true + bool GouraudShading : 1; + + //! Will this material be lighted? Default: true + bool Lighting : 1; + + //! Is the zbuffer writable or is it read-only. Default: EZW_AUTO. + /** If this parameter is not EZW_OFF, you probably also want to set ZBuffer + to values other than ECFN_DISABLED */ + E_ZWRITE ZWriteEnable : 2; + + //! Is backface culling enabled? Default: true + bool BackfaceCulling : 1; + + //! Is frontface culling enabled? Default: false + bool FrontfaceCulling : 1; + + //! Is fog enabled? Default: false + bool FogEnable : 1; + + //! Should normals be normalized? + /** Always use this if the mesh lit and scaled. Default: false */ + bool NormalizeNormals : 1; + + //! Shall mipmaps be used if available + /** Sometimes, disabling mipmap usage can be useful. Default: true */ + bool UseMipMaps : 1; + + //! Execute a function on all texture layers. + /** Useful for setting properties which are not per material, but per + texture layer, e.g. bilinear filtering. */ + template + void forEachTexture(F &&fn) + { + for (u32 i = 0; i < MATERIAL_MAX_TEXTURES; i++) { + fn(TextureLayers[i]); + } + } + + //! Gets the texture transformation matrix for level i + /** \param i The desired level. Must not be larger than MATERIAL_MAX_TEXTURES + \return Texture matrix for texture level i. */ + core::matrix4 &getTextureMatrix(u32 i) + { + return TextureLayers[i].getTextureMatrix(); + } + + //! Gets the immutable texture transformation matrix for level i + /** \param i The desired level. + \return Texture matrix for texture level i, or identity matrix for levels larger than MATERIAL_MAX_TEXTURES. */ + const core::matrix4 &getTextureMatrix(u32 i) const + { + if (i < MATERIAL_MAX_TEXTURES) + return TextureLayers[i].getTextureMatrix(); + else + return core::IdentityMatrix; + } + + //! Sets the i-th texture transformation matrix + /** \param i The desired level. + \param mat Texture matrix for texture level i. */ + void setTextureMatrix(u32 i, const core::matrix4 &mat) + { + if (i >= MATERIAL_MAX_TEXTURES) + return; + TextureLayers[i].setTextureMatrix(mat); + } + + //! Gets the i-th texture + /** \param i The desired level. + \return Texture for texture level i, if defined, else 0. */ + ITexture *getTexture(u32 i) const + { + return i < MATERIAL_MAX_TEXTURES ? TextureLayers[i].Texture : 0; + } + + //! Sets the i-th texture + /** If i>=MATERIAL_MAX_TEXTURES this setting will be ignored. + \param i The desired level. + \param tex Texture for texture level i. */ + void setTexture(u32 i, ITexture *tex) + { + if (i >= MATERIAL_MAX_TEXTURES) + return; + TextureLayers[i].Texture = tex; + } + + //! Inequality operator + /** \param b Material to compare to. + \return True if the materials differ, else false. */ + inline bool operator!=(const SMaterial &b) const + { + bool different = + MaterialType != b.MaterialType || + AmbientColor != b.AmbientColor || + DiffuseColor != b.DiffuseColor || + EmissiveColor != b.EmissiveColor || + SpecularColor != b.SpecularColor || + Shininess != b.Shininess || + MaterialTypeParam != b.MaterialTypeParam || + Thickness != b.Thickness || + Wireframe != b.Wireframe || + PointCloud != b.PointCloud || + GouraudShading != b.GouraudShading || + Lighting != b.Lighting || + ZBuffer != b.ZBuffer || + ZWriteEnable != b.ZWriteEnable || + BackfaceCulling != b.BackfaceCulling || + FrontfaceCulling != b.FrontfaceCulling || + FogEnable != b.FogEnable || + NormalizeNormals != b.NormalizeNormals || + AntiAliasing != b.AntiAliasing || + ColorMask != b.ColorMask || + ColorMaterial != b.ColorMaterial || + BlendOperation != b.BlendOperation || + BlendFactor != b.BlendFactor || + PolygonOffsetDepthBias != b.PolygonOffsetDepthBias || + PolygonOffsetSlopeScale != b.PolygonOffsetSlopeScale || + UseMipMaps != b.UseMipMaps; + for (u32 i = 0; (i < MATERIAL_MAX_TEXTURES) && !different; ++i) { + different |= (TextureLayers[i] != b.TextureLayers[i]); + } + return different; + } + + //! Equality operator + /** \param b Material to compare to. + \return True if the materials are equal, else false. */ + inline bool operator==(const SMaterial &b) const + { + return !(b != *this); + } + + //! Check if material needs alpha blending + bool isAlphaBlendOperation() const + { + if (BlendOperation != EBO_NONE && BlendFactor != 0.f) { + E_BLEND_FACTOR srcRGBFact = EBF_ZERO; + E_BLEND_FACTOR dstRGBFact = EBF_ZERO; + E_BLEND_FACTOR srcAlphaFact = EBF_ZERO; + E_BLEND_FACTOR dstAlphaFact = EBF_ZERO; + E_MODULATE_FUNC modulo = EMFN_MODULATE_1X; + u32 alphaSource = 0; + + unpack_textureBlendFuncSeparate(srcRGBFact, dstRGBFact, srcAlphaFact, dstAlphaFact, modulo, alphaSource, BlendFactor); + + if (textureBlendFunc_hasAlpha(srcRGBFact) || textureBlendFunc_hasAlpha(dstRGBFact) || + textureBlendFunc_hasAlpha(srcAlphaFact) || textureBlendFunc_hasAlpha(dstAlphaFact)) { + return true; + } + } + return false; + } + + //! Check for some fixed-function transparent types. Still used internally, but might be deprecated soon. + //! You probably should not use this anymore, IVideoDriver::needsTransparentRenderPass is more useful in most situations + //! as it asks the material renders directly what they do with the material. + bool isTransparent() const + { + if (MaterialType == EMT_TRANSPARENT_ALPHA_CHANNEL || + MaterialType == EMT_TRANSPARENT_VERTEX_ALPHA) + return true; + + return false; + } +}; + +//! global const identity Material +IRRLICHT_API extern SMaterial IdentityMaterial; +} // end namespace video +} // end namespace irr diff --git a/irr/include/SMaterialLayer.h b/irr/include/SMaterialLayer.h new file mode 100644 index 000000000..419a8f1e9 --- /dev/null +++ b/irr/include/SMaterialLayer.h @@ -0,0 +1,238 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "matrix4.h" + +namespace irr +{ +namespace video +{ +class ITexture; + +//! Texture coord clamp mode outside [0.0, 1.0] +enum E_TEXTURE_CLAMP +{ + //! Texture repeats + ETC_REPEAT = 0, + //! Texture is clamped to the last pixel + ETC_CLAMP, + //! Texture is clamped to the edge pixel + ETC_CLAMP_TO_EDGE, + //! Texture is clamped to the border pixel (if exists) + ETC_CLAMP_TO_BORDER, + //! Texture is alternatingly mirrored (0..1..0..1..0..) + ETC_MIRROR, + //! Texture is mirrored once and then clamped (0..1..0) + ETC_MIRROR_CLAMP, + //! Texture is mirrored once and then clamped to edge + ETC_MIRROR_CLAMP_TO_EDGE, + //! Texture is mirrored once and then clamped to border + ETC_MIRROR_CLAMP_TO_BORDER +}; +static const char *const aTextureClampNames[] = { + "texture_clamp_repeat", + "texture_clamp_clamp", + "texture_clamp_clamp_to_edge", + "texture_clamp_clamp_to_border", + "texture_clamp_mirror", + "texture_clamp_mirror_clamp", + "texture_clamp_mirror_clamp_to_edge", + "texture_clamp_mirror_clamp_to_border", 0}; + +//! Texture minification filter. +/** Used when scaling textures down. See the documentation on OpenGL's +`GL_TEXTURE_MIN_FILTER` for more information. */ +enum E_TEXTURE_MIN_FILTER +{ + //! Aka nearest-neighbor. + ETMINF_NEAREST_MIPMAP_NEAREST = 0, + //! Aka bilinear. + ETMINF_LINEAR_MIPMAP_NEAREST, + //! Isn't known by any other name. + ETMINF_NEAREST_MIPMAP_LINEAR, + //! Aka trilinear. + ETMINF_LINEAR_MIPMAP_LINEAR, +}; + +//! Texture magnification filter. +/** Used when scaling textures up. See the documentation on OpenGL's +`GL_TEXTURE_MAG_FILTER` for more information. +Note that mipmaps are only used for minification, not for magnification. */ +enum E_TEXTURE_MAG_FILTER +{ + //! Aka nearest-neighbor. + ETMAGF_NEAREST = 0, + //! Aka bilinear. + ETMAGF_LINEAR, +}; + +//! Struct for holding material parameters which exist per texture layer +// Note for implementors: Serialization is in CNullDriver +class SMaterialLayer +{ +public: + //! Default constructor + SMaterialLayer() : + Texture(0), TextureWrapU(ETC_REPEAT), TextureWrapV(ETC_REPEAT), TextureWrapW(ETC_REPEAT), + MinFilter(ETMINF_LINEAR_MIPMAP_NEAREST), MagFilter(ETMAGF_LINEAR), AnisotropicFilter(0), LODBias(0), TextureMatrix(0) + { + } + + //! Copy constructor + /** \param other Material layer to copy from. */ + SMaterialLayer(const SMaterialLayer &other) + { + // This pointer is checked during assignment + TextureMatrix = 0; + *this = other; + } + + //! Destructor + ~SMaterialLayer() + { + if (TextureMatrix) { + delete TextureMatrix; + } + } + + //! Assignment operator + /** \param other Material layer to copy from. + \return This material layer, updated. */ + SMaterialLayer &operator=(const SMaterialLayer &other) + { + // Check for self-assignment! + if (this == &other) + return *this; + + Texture = other.Texture; + if (TextureMatrix) { + if (other.TextureMatrix) + *TextureMatrix = *other.TextureMatrix; + else { + delete TextureMatrix; + TextureMatrix = 0; + } + } else { + if (other.TextureMatrix) { + TextureMatrix = new core::matrix4(*other.TextureMatrix); + } else + TextureMatrix = 0; + } + TextureWrapU = other.TextureWrapU; + TextureWrapV = other.TextureWrapV; + TextureWrapW = other.TextureWrapW; + MinFilter = other.MinFilter; + MagFilter = other.MagFilter; + AnisotropicFilter = other.AnisotropicFilter; + LODBias = other.LODBias; + + return *this; + } + + //! Gets the texture transformation matrix + /** \return Texture matrix of this layer. */ + core::matrix4 &getTextureMatrix() + { + if (!TextureMatrix) { + TextureMatrix = new core::matrix4(); + } + return *TextureMatrix; + } + + //! Gets the immutable texture transformation matrix + /** \return Texture matrix of this layer. */ + const core::matrix4 &getTextureMatrix() const + { + if (TextureMatrix) + return *TextureMatrix; + else + return core::IdentityMatrix; + } + + //! Sets the texture transformation matrix to mat + /** NOTE: Pipelines can ignore this matrix when the + texture is 0. + \param mat New texture matrix for this layer. */ + void setTextureMatrix(const core::matrix4 &mat) + { + if (!TextureMatrix) { + TextureMatrix = new core::matrix4(mat); + } else + *TextureMatrix = mat; + } + + //! Inequality operator + /** \param b Layer to compare to. + \return True if layers are different, else false. */ + inline bool operator!=(const SMaterialLayer &b) const + { + bool different = + Texture != b.Texture || + TextureWrapU != b.TextureWrapU || + TextureWrapV != b.TextureWrapV || + TextureWrapW != b.TextureWrapW || + MinFilter != b.MinFilter || + MagFilter != b.MagFilter || + AnisotropicFilter != b.AnisotropicFilter || + LODBias != b.LODBias; + if (different) + return true; + else + different |= (TextureMatrix != b.TextureMatrix) && + (!TextureMatrix || !b.TextureMatrix || (*TextureMatrix != *(b.TextureMatrix))); + return different; + } + + //! Equality operator + /** \param b Layer to compare to. + \return True if layers are equal, else false. */ + inline bool operator==(const SMaterialLayer &b) const + { + return !(b != *this); + } + + //! Texture + ITexture *Texture; + + //! Texture Clamp Mode + /** Values are taken from E_TEXTURE_CLAMP. */ + u8 TextureWrapU : 4; + u8 TextureWrapV : 4; + u8 TextureWrapW : 4; + + //! Minification (downscaling) filter + E_TEXTURE_MIN_FILTER MinFilter; + + //! Magnification (upscaling) filter + E_TEXTURE_MAG_FILTER MagFilter; + + //! Is anisotropic filtering enabled? Default: 0, disabled + /** In Irrlicht you can use anisotropic texture filtering + in conjunction with bilinear or trilinear texture + filtering to improve rendering results. Primitives + will look less blurry with this flag switched on. The number gives + the maximal anisotropy degree, and is often in the range 2-16. + Value 1 is equivalent to 0, but should be avoided. */ + u8 AnisotropicFilter; + + //! Bias for the mipmap choosing decision. + /** This value can make the textures more or less blurry than with the + default value of 0. The value (divided by 8.f) is added to the mipmap level + chosen initially, and thus takes a smaller mipmap for a region + if the value is positive. */ + s8 LODBias; + +private: + friend class SMaterial; + + //! Texture Matrix + /** Do not access this element directly as the internal + resource management has to cope with Null pointers etc. */ + core::matrix4 *TextureMatrix; +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/include/SMesh.h b/irr/include/SMesh.h new file mode 100644 index 000000000..e865a5d2d --- /dev/null +++ b/irr/include/SMesh.h @@ -0,0 +1,132 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IMesh.h" +#include "IMeshBuffer.h" +#include "aabbox3d.h" +#include "irrArray.h" + +namespace irr +{ +namespace scene +{ +//! Simple implementation of the IMesh interface. +struct SMesh : public IMesh +{ + //! constructor + SMesh() + { +#ifdef _DEBUG + setDebugName("SMesh"); +#endif + } + + //! destructor + virtual ~SMesh() + { + // drop buffers + for (u32 i = 0; i < MeshBuffers.size(); ++i) + MeshBuffers[i]->drop(); + } + + //! clean mesh + virtual void clear() + { + for (u32 i = 0; i < MeshBuffers.size(); ++i) + MeshBuffers[i]->drop(); + MeshBuffers.clear(); + BoundingBox.reset(0.f, 0.f, 0.f); + } + + //! returns amount of mesh buffers. + u32 getMeshBufferCount() const override + { + return MeshBuffers.size(); + } + + //! returns pointer to a mesh buffer + IMeshBuffer *getMeshBuffer(u32 nr) const override + { + return MeshBuffers[nr]; + } + + //! returns a meshbuffer which fits a material + /** reverse search */ + IMeshBuffer *getMeshBuffer(const video::SMaterial &material) const override + { + for (s32 i = (s32)MeshBuffers.size() - 1; i >= 0; --i) { + if (material == MeshBuffers[i]->getMaterial()) + return MeshBuffers[i]; + } + + return 0; + } + + //! returns an axis aligned bounding box + const core::aabbox3d &getBoundingBox() const override + { + return BoundingBox; + } + + //! set user axis aligned bounding box + void setBoundingBox(const core::aabbox3df &box) override + { + BoundingBox = box; + } + + //! recalculates the bounding box + void recalculateBoundingBox() + { + bool hasMeshBufferBBox = false; + for (u32 i = 0; i < MeshBuffers.size(); ++i) { + const core::aabbox3df &bb = MeshBuffers[i]->getBoundingBox(); + if (!bb.isEmpty()) { + if (!hasMeshBufferBBox) { + hasMeshBufferBBox = true; + BoundingBox = bb; + } else { + BoundingBox.addInternalBox(bb); + } + } + } + + if (!hasMeshBufferBBox) + BoundingBox.reset(0.0f, 0.0f, 0.0f); + } + + //! adds a MeshBuffer + /** The bounding box is not updated automatically. */ + void addMeshBuffer(IMeshBuffer *buf) + { + if (buf) { + buf->grab(); + MeshBuffers.push_back(buf); + } + } + + //! set the hardware mapping hint, for driver + void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer = EBT_VERTEX_AND_INDEX) override + { + for (u32 i = 0; i < MeshBuffers.size(); ++i) + MeshBuffers[i]->setHardwareMappingHint(newMappingHint, buffer); + } + + //! flags the meshbuffer as changed, reloads hardware buffers + void setDirty(E_BUFFER_TYPE buffer = EBT_VERTEX_AND_INDEX) override + { + for (u32 i = 0; i < MeshBuffers.size(); ++i) + MeshBuffers[i]->setDirty(buffer); + } + + //! The meshbuffers of this mesh + core::array MeshBuffers; + + //! The bounding box of this mesh + core::aabbox3d BoundingBox; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/SMeshBuffer.h b/irr/include/SMeshBuffer.h new file mode 100644 index 000000000..2053db958 --- /dev/null +++ b/irr/include/SMeshBuffer.h @@ -0,0 +1,6 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +// replaced by template +#include "CMeshBuffer.h" diff --git a/irr/include/SOverrideMaterial.h b/irr/include/SOverrideMaterial.h new file mode 100644 index 000000000..6de6e6ebb --- /dev/null +++ b/irr/include/SOverrideMaterial.h @@ -0,0 +1,192 @@ +// Copyright (C) 2017 Michael Zeilfelder +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "SMaterial.h" + +namespace irr +{ +namespace video +{ + +struct SOverrideMaterial +{ + //! The Material values + SMaterial Material; + + //! Which values are overridden + /** OR'ed values from E_MATERIAL_PROPS. */ + u32 EnableProps; + + //! For those properties in EnableProps which affect layers, set which of the layers are affected + bool EnableLayerProps[MATERIAL_MAX_TEXTURES]; + + //! Which textures are overridden + bool EnableTextures[MATERIAL_MAX_TEXTURES]; + + //! Overwrite complete layers (settings of EnableLayerProps and EnableTextures don't matter then for layer data) + bool EnableLayers[MATERIAL_MAX_TEXTURES]; + + //! Set in which render passes the material override is active. + /** OR'ed values from E_SCENE_NODE_RENDER_PASS. */ + u16 EnablePasses; + + //! Global enable flag, overwritten by the SceneManager in each pass + /** NOTE: This is generally _not_ set by users of the engine, but the + Scenemanager uses the EnablePass array and sets Enabled to true if the + Override material is enabled in the current pass. + As user you generally _only_ set EnablePasses. + The exception is when rendering without SceneManager but using draw calls in the VideoDriver. */ + bool Enabled; + + struct SMaterialTypeReplacement + { + SMaterialTypeReplacement(s32 original, u32 replacement) : + Original(original), Replacement(replacement) {} + SMaterialTypeReplacement(u32 replacement) : + Original(-1), Replacement(replacement) {} + + //! SMaterial.MaterialType to replace. + //! -1 for all types or a specific value to only replace that one (which is either one of E_MATERIAL_TYPE or a shader material id) + s32 Original; + + //! MaterialType to used to override Original (either one of E_MATERIAL_TYPE or a shader material id) + u32 Replacement; + }; + + //! To overwrite SMaterial::MaterialType + core::array MaterialTypes; + + //! Default constructor + SOverrideMaterial() : + EnableProps(0), EnablePasses(0), Enabled(false) + { + } + + //! disable overrides and reset all properties + void reset() + { + EnableProps = 0; + EnablePasses = 0; + Enabled = false; + for (u32 i = 0; i < MATERIAL_MAX_TEXTURES; ++i) { + EnableLayerProps[i] = true; // doesn't do anything unless EnableProps is set, just saying by default all texture layers are affected by properties + EnableTextures[i] = false; + EnableLayers[i] = false; + } + MaterialTypes.clear(); + } + + //! Apply the enabled overrides + void apply(SMaterial &material) + { + if (Enabled) { + for (u32 i = 0; i < MaterialTypes.size(); ++i) { + const SMaterialTypeReplacement &mtr = MaterialTypes[i]; + if (mtr.Original < 0 || (s32)mtr.Original == material.MaterialType) + material.MaterialType = (E_MATERIAL_TYPE)mtr.Replacement; + } + for (u32 f = 0; f < 32; ++f) { + const u32 num = (1 << f); + if (EnableProps & num) { + switch (num) { + case EMP_WIREFRAME: + material.Wireframe = Material.Wireframe; + break; + case EMP_POINTCLOUD: + material.PointCloud = Material.PointCloud; + break; + case EMP_GOURAUD_SHADING: + material.GouraudShading = Material.GouraudShading; + break; + case EMP_LIGHTING: + material.Lighting = Material.Lighting; + break; + case EMP_ZBUFFER: + material.ZBuffer = Material.ZBuffer; + break; + case EMP_ZWRITE_ENABLE: + material.ZWriteEnable = Material.ZWriteEnable; + break; + case EMP_BACK_FACE_CULLING: + material.BackfaceCulling = Material.BackfaceCulling; + break; + case EMP_FRONT_FACE_CULLING: + material.FrontfaceCulling = Material.FrontfaceCulling; + break; + case EMP_MIN_FILTER: + for (u32 i = 0; i < MATERIAL_MAX_TEXTURES; ++i) { + if (EnableLayerProps[i]) { + material.TextureLayers[i].MinFilter = Material.TextureLayers[i].MinFilter; + } + } + break; + case EMP_MAG_FILTER: + for (u32 i = 0; i < MATERIAL_MAX_TEXTURES; ++i) { + if (EnableLayerProps[i]) { + material.TextureLayers[i].MagFilter = Material.TextureLayers[i].MagFilter; + } + } + break; + case EMP_ANISOTROPIC_FILTER: + for (u32 i = 0; i < MATERIAL_MAX_TEXTURES; ++i) { + if (EnableLayerProps[i]) { + material.TextureLayers[i].AnisotropicFilter = Material.TextureLayers[i].AnisotropicFilter; + } + } + break; + case EMP_FOG_ENABLE: + material.FogEnable = Material.FogEnable; + break; + case EMP_NORMALIZE_NORMALS: + material.NormalizeNormals = Material.NormalizeNormals; + break; + case EMP_TEXTURE_WRAP: + for (u32 i = 0; i < MATERIAL_MAX_TEXTURES; ++i) { + if (EnableLayerProps[i]) { + material.TextureLayers[i].TextureWrapU = Material.TextureLayers[i].TextureWrapU; + material.TextureLayers[i].TextureWrapV = Material.TextureLayers[i].TextureWrapV; + material.TextureLayers[i].TextureWrapW = Material.TextureLayers[i].TextureWrapW; + } + } + break; + case EMP_ANTI_ALIASING: + material.AntiAliasing = Material.AntiAliasing; + break; + case EMP_COLOR_MASK: + material.ColorMask = Material.ColorMask; + break; + case EMP_COLOR_MATERIAL: + material.ColorMaterial = Material.ColorMaterial; + break; + case EMP_USE_MIP_MAPS: + material.UseMipMaps = Material.UseMipMaps; + break; + case EMP_BLEND_OPERATION: + material.BlendOperation = Material.BlendOperation; + break; + case EMP_BLEND_FACTOR: + material.BlendFactor = Material.BlendFactor; + break; + case EMP_POLYGON_OFFSET: + material.PolygonOffsetDepthBias = Material.PolygonOffsetDepthBias; + material.PolygonOffsetSlopeScale = Material.PolygonOffsetSlopeScale; + break; + } + } + } + for (u32 i = 0; i < MATERIAL_MAX_TEXTURES; ++i) { + if (EnableLayers[i]) { + material.TextureLayers[i] = Material.TextureLayers[i]; + } else if (EnableTextures[i]) { + material.TextureLayers[i].Texture = Material.TextureLayers[i].Texture; + } + } + } + } +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/include/SSkinMeshBuffer.h b/irr/include/SSkinMeshBuffer.h new file mode 100644 index 000000000..5ced6057d --- /dev/null +++ b/irr/include/SSkinMeshBuffer.h @@ -0,0 +1,398 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IMeshBuffer.h" +#include "S3DVertex.h" + +namespace irr +{ +namespace scene +{ + +//! A mesh buffer able to choose between S3DVertex2TCoords, S3DVertex and S3DVertexTangents at runtime +struct SSkinMeshBuffer : public IMeshBuffer +{ + //! Default constructor + SSkinMeshBuffer(video::E_VERTEX_TYPE vt = video::EVT_STANDARD) : + ChangedID_Vertex(1), ChangedID_Index(1), VertexType(vt), + PrimitiveType(EPT_TRIANGLES), + MappingHint_Vertex(EHM_NEVER), MappingHint_Index(EHM_NEVER), + HWBuffer(NULL), + BoundingBoxNeedsRecalculated(true) + { +#ifdef _DEBUG + setDebugName("SSkinMeshBuffer"); +#endif + } + + //! Get Material of this buffer. + const video::SMaterial &getMaterial() const override + { + return Material; + } + + //! Get Material of this buffer. + video::SMaterial &getMaterial() override + { + return Material; + } + + //! Get standard vertex at given index + virtual video::S3DVertex *getVertex(u32 index) + { + switch (VertexType) { + case video::EVT_2TCOORDS: + return (video::S3DVertex *)&Vertices_2TCoords[index]; + case video::EVT_TANGENTS: + return (video::S3DVertex *)&Vertices_Tangents[index]; + default: + return &Vertices_Standard[index]; + } + } + + //! Get pointer to vertex array + const void *getVertices() const override + { + switch (VertexType) { + case video::EVT_2TCOORDS: + return Vertices_2TCoords.const_pointer(); + case video::EVT_TANGENTS: + return Vertices_Tangents.const_pointer(); + default: + return Vertices_Standard.const_pointer(); + } + } + + //! Get pointer to vertex array + void *getVertices() override + { + switch (VertexType) { + case video::EVT_2TCOORDS: + return Vertices_2TCoords.pointer(); + case video::EVT_TANGENTS: + return Vertices_Tangents.pointer(); + default: + return Vertices_Standard.pointer(); + } + } + + //! Get vertex count + u32 getVertexCount() const override + { + switch (VertexType) { + case video::EVT_2TCOORDS: + return Vertices_2TCoords.size(); + case video::EVT_TANGENTS: + return Vertices_Tangents.size(); + default: + return Vertices_Standard.size(); + } + } + + //! Get type of index data which is stored in this meshbuffer. + /** \return Index type of this buffer. */ + video::E_INDEX_TYPE getIndexType() const override + { + return video::EIT_16BIT; + } + + //! Get pointer to index array + const u16 *getIndices() const override + { + return Indices.const_pointer(); + } + + //! Get pointer to index array + u16 *getIndices() override + { + return Indices.pointer(); + } + + //! Get index count + u32 getIndexCount() const override + { + return Indices.size(); + } + + //! Get bounding box + const core::aabbox3d &getBoundingBox() const override + { + return BoundingBox; + } + + //! Set bounding box + void setBoundingBox(const core::aabbox3df &box) override + { + BoundingBox = box; + } + + //! Recalculate bounding box + void recalculateBoundingBox() override + { + if (!BoundingBoxNeedsRecalculated) + return; + + BoundingBoxNeedsRecalculated = false; + + switch (VertexType) { + case video::EVT_STANDARD: { + if (Vertices_Standard.empty()) + BoundingBox.reset(0, 0, 0); + else { + BoundingBox.reset(Vertices_Standard[0].Pos); + for (u32 i = 1; i < Vertices_Standard.size(); ++i) + BoundingBox.addInternalPoint(Vertices_Standard[i].Pos); + } + break; + } + case video::EVT_2TCOORDS: { + if (Vertices_2TCoords.empty()) + BoundingBox.reset(0, 0, 0); + else { + BoundingBox.reset(Vertices_2TCoords[0].Pos); + for (u32 i = 1; i < Vertices_2TCoords.size(); ++i) + BoundingBox.addInternalPoint(Vertices_2TCoords[i].Pos); + } + break; + } + case video::EVT_TANGENTS: { + if (Vertices_Tangents.empty()) + BoundingBox.reset(0, 0, 0); + else { + BoundingBox.reset(Vertices_Tangents[0].Pos); + for (u32 i = 1; i < Vertices_Tangents.size(); ++i) + BoundingBox.addInternalPoint(Vertices_Tangents[i].Pos); + } + break; + } + } + } + + //! Get vertex type + video::E_VERTEX_TYPE getVertexType() const override + { + return VertexType; + } + + //! Convert to 2tcoords vertex type + void convertTo2TCoords() + { + if (VertexType == video::EVT_STANDARD) { + for (u32 n = 0; n < Vertices_Standard.size(); ++n) { + video::S3DVertex2TCoords Vertex; + Vertex.Color = Vertices_Standard[n].Color; + Vertex.Pos = Vertices_Standard[n].Pos; + Vertex.Normal = Vertices_Standard[n].Normal; + Vertex.TCoords = Vertices_Standard[n].TCoords; + Vertices_2TCoords.push_back(Vertex); + } + Vertices_Standard.clear(); + VertexType = video::EVT_2TCOORDS; + } + } + + //! Convert to tangents vertex type + void convertToTangents() + { + if (VertexType == video::EVT_STANDARD) { + for (u32 n = 0; n < Vertices_Standard.size(); ++n) { + video::S3DVertexTangents Vertex; + Vertex.Color = Vertices_Standard[n].Color; + Vertex.Pos = Vertices_Standard[n].Pos; + Vertex.Normal = Vertices_Standard[n].Normal; + Vertex.TCoords = Vertices_Standard[n].TCoords; + Vertices_Tangents.push_back(Vertex); + } + Vertices_Standard.clear(); + VertexType = video::EVT_TANGENTS; + } else if (VertexType == video::EVT_2TCOORDS) { + for (u32 n = 0; n < Vertices_2TCoords.size(); ++n) { + video::S3DVertexTangents Vertex; + Vertex.Color = Vertices_2TCoords[n].Color; + Vertex.Pos = Vertices_2TCoords[n].Pos; + Vertex.Normal = Vertices_2TCoords[n].Normal; + Vertex.TCoords = Vertices_2TCoords[n].TCoords; + Vertices_Tangents.push_back(Vertex); + } + Vertices_2TCoords.clear(); + VertexType = video::EVT_TANGENTS; + } + } + + //! returns position of vertex i + const core::vector3df &getPosition(u32 i) const override + { + switch (VertexType) { + case video::EVT_2TCOORDS: + return Vertices_2TCoords[i].Pos; + case video::EVT_TANGENTS: + return Vertices_Tangents[i].Pos; + default: + return Vertices_Standard[i].Pos; + } + } + + //! returns position of vertex i + core::vector3df &getPosition(u32 i) override + { + switch (VertexType) { + case video::EVT_2TCOORDS: + return Vertices_2TCoords[i].Pos; + case video::EVT_TANGENTS: + return Vertices_Tangents[i].Pos; + default: + return Vertices_Standard[i].Pos; + } + } + + //! returns normal of vertex i + const core::vector3df &getNormal(u32 i) const override + { + switch (VertexType) { + case video::EVT_2TCOORDS: + return Vertices_2TCoords[i].Normal; + case video::EVT_TANGENTS: + return Vertices_Tangents[i].Normal; + default: + return Vertices_Standard[i].Normal; + } + } + + //! returns normal of vertex i + core::vector3df &getNormal(u32 i) override + { + switch (VertexType) { + case video::EVT_2TCOORDS: + return Vertices_2TCoords[i].Normal; + case video::EVT_TANGENTS: + return Vertices_Tangents[i].Normal; + default: + return Vertices_Standard[i].Normal; + } + } + + //! returns texture coords of vertex i + const core::vector2df &getTCoords(u32 i) const override + { + switch (VertexType) { + case video::EVT_2TCOORDS: + return Vertices_2TCoords[i].TCoords; + case video::EVT_TANGENTS: + return Vertices_Tangents[i].TCoords; + default: + return Vertices_Standard[i].TCoords; + } + } + + //! returns texture coords of vertex i + core::vector2df &getTCoords(u32 i) override + { + switch (VertexType) { + case video::EVT_2TCOORDS: + return Vertices_2TCoords[i].TCoords; + case video::EVT_TANGENTS: + return Vertices_Tangents[i].TCoords; + default: + return Vertices_Standard[i].TCoords; + } + } + + //! append the vertices and indices to the current buffer + void append(const void *const vertices, u32 numVertices, const u16 *const indices, u32 numIndices) override {} + + //! get the current hardware mapping hint for vertex buffers + E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const override + { + return MappingHint_Vertex; + } + + //! get the current hardware mapping hint for index buffers + E_HARDWARE_MAPPING getHardwareMappingHint_Index() const override + { + return MappingHint_Index; + } + + //! set the hardware mapping hint, for driver + void setHardwareMappingHint(E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE Buffer = EBT_VERTEX_AND_INDEX) override + { + if (Buffer == EBT_VERTEX) + MappingHint_Vertex = NewMappingHint; + else if (Buffer == EBT_INDEX) + MappingHint_Index = NewMappingHint; + else if (Buffer == EBT_VERTEX_AND_INDEX) { + MappingHint_Vertex = NewMappingHint; + MappingHint_Index = NewMappingHint; + } + } + + //! Describe what kind of primitive geometry is used by the meshbuffer + void setPrimitiveType(E_PRIMITIVE_TYPE type) override + { + PrimitiveType = type; + } + + //! Get the kind of primitive geometry which is used by the meshbuffer + E_PRIMITIVE_TYPE getPrimitiveType() const override + { + return PrimitiveType; + } + + //! flags the mesh as changed, reloads hardware buffers + void setDirty(E_BUFFER_TYPE Buffer = EBT_VERTEX_AND_INDEX) override + { + if (Buffer == EBT_VERTEX_AND_INDEX || Buffer == EBT_VERTEX) + ++ChangedID_Vertex; + if (Buffer == EBT_VERTEX_AND_INDEX || Buffer == EBT_INDEX) + ++ChangedID_Index; + } + + u32 getChangedID_Vertex() const override { return ChangedID_Vertex; } + + u32 getChangedID_Index() const override { return ChangedID_Index; } + + void setHWBuffer(void *ptr) const override + { + HWBuffer = ptr; + } + + void *getHWBuffer() const override + { + return HWBuffer; + } + + //! Call this after changing the positions of any vertex. + void boundingBoxNeedsRecalculated(void) { BoundingBoxNeedsRecalculated = true; } + + core::array Vertices_Tangents; + core::array Vertices_2TCoords; + core::array Vertices_Standard; + core::array Indices; + + u32 ChangedID_Vertex; + u32 ChangedID_Index; + + // ISkinnedMesh::SJoint *AttachedJoint; + core::matrix4 Transformation; + + video::SMaterial Material; + video::E_VERTEX_TYPE VertexType; + + core::aabbox3d BoundingBox; + + //! Primitive type used for rendering (triangles, lines, ...) + E_PRIMITIVE_TYPE PrimitiveType; + + // hardware mapping hint + E_HARDWARE_MAPPING MappingHint_Vertex : 3; + E_HARDWARE_MAPPING MappingHint_Index : 3; + + mutable void *HWBuffer; + + bool BoundingBoxNeedsRecalculated : 1; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/SVertexIndex.h b/irr/include/SVertexIndex.h new file mode 100644 index 000000000..21cf42583 --- /dev/null +++ b/irr/include/SVertexIndex.h @@ -0,0 +1,20 @@ +// Copyright (C) 2008-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" + +namespace irr +{ +namespace video +{ +enum E_INDEX_TYPE +{ + EIT_16BIT = 0, + EIT_32BIT +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/include/SVertexManipulator.h b/irr/include/SVertexManipulator.h new file mode 100644 index 000000000..f302273c8 --- /dev/null +++ b/irr/include/SVertexManipulator.h @@ -0,0 +1,44 @@ +// Copyright (C) 2009-2012 Christian Stehno +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "matrix4.h" +#include "S3DVertex.h" +#include "SColor.h" + +namespace irr +{ +namespace scene +{ + +class IMesh; +class IMeshBuffer; +struct SMesh; + +//! Interface for vertex manipulators. +/** You should derive your manipulator from this class if it shall be called for every vertex, getting as parameter just the vertex. + */ +struct IVertexManipulator +{ +}; + +//! Vertex manipulator which scales the position of the vertex +class SVertexPositionScaleManipulator : public IVertexManipulator +{ +public: + SVertexPositionScaleManipulator(const core::vector3df &factor) : + Factor(factor) {} + template + void operator()(VType &vertex) const + { + vertex.Pos *= Factor; + } + +private: + core::vector3df Factor; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/SViewFrustum.h b/irr/include/SViewFrustum.h new file mode 100644 index 000000000..06983cc5e --- /dev/null +++ b/irr/include/SViewFrustum.h @@ -0,0 +1,449 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "plane3d.h" +#include "vector3d.h" +#include "line3d.h" +#include "aabbox3d.h" +#include "matrix4.h" +#include "IVideoDriver.h" + +namespace irr +{ +namespace scene +{ + +//! Defines the view frustum. That's the space visible by the camera. +/** The view frustum is enclosed by 6 planes. These six planes share +eight points. A bounding box around these eight points is also stored in +this structure. +*/ +struct SViewFrustum +{ + enum VFPLANES + { + //! Far plane of the frustum. That is the plane furthest away from the eye. + VF_FAR_PLANE = 0, + //! Near plane of the frustum. That is the plane nearest to the eye. + VF_NEAR_PLANE, + //! Left plane of the frustum. + VF_LEFT_PLANE, + //! Right plane of the frustum. + VF_RIGHT_PLANE, + //! Bottom plane of the frustum. + VF_BOTTOM_PLANE, + //! Top plane of the frustum. + VF_TOP_PLANE, + + //! Amount of planes enclosing the view frustum. Should be 6. + VF_PLANE_COUNT + }; + + //! Default Constructor + SViewFrustum() : + BoundingRadius(0.f), FarNearDistance(0.f) {} + + //! Copy Constructor + SViewFrustum(const SViewFrustum &other); + + //! This constructor creates a view frustum based on a projection and/or view matrix. + //\param zClipFromZero: Clipping of z can be projected from 0 to w when true (D3D style) and from -w to w when false (OGL style). + SViewFrustum(const core::matrix4 &mat, bool zClipFromZero); + + //! This constructor creates a view frustum based on a projection and/or view matrix. + //\param zClipFromZero: Clipping of z can be projected from 0 to w when true (D3D style) and from -w to w when false (OGL style). + inline void setFrom(const core::matrix4 &mat, bool zClipFromZero); + + //! transforms the frustum by the matrix + /** \param mat: Matrix by which the view frustum is transformed.*/ + void transform(const core::matrix4 &mat); + + //! returns the point which is on the far left upper corner inside the the view frustum. + core::vector3df getFarLeftUp() const; + + //! returns the point which is on the far left bottom corner inside the the view frustum. + core::vector3df getFarLeftDown() const; + + //! returns the point which is on the far right top corner inside the the view frustum. + core::vector3df getFarRightUp() const; + + //! returns the point which is on the far right bottom corner inside the the view frustum. + core::vector3df getFarRightDown() const; + + //! returns the point which is on the near left upper corner inside the the view frustum. + core::vector3df getNearLeftUp() const; + + //! returns the point which is on the near left bottom corner inside the the view frustum. + core::vector3df getNearLeftDown() const; + + //! returns the point which is on the near right top corner inside the the view frustum. + core::vector3df getNearRightUp() const; + + //! returns the point which is on the near right bottom corner inside the the view frustum. + core::vector3df getNearRightDown() const; + + //! returns a bounding box enclosing the whole view frustum + const core::aabbox3d &getBoundingBox() const; + + //! recalculates the bounding box and sphere based on the planes + inline void recalculateBoundingBox(); + + //! get the bounding sphere's radius (of an optimized sphere, not the AABB's) + float getBoundingRadius() const; + + //! get the bounding sphere's radius (of an optimized sphere, not the AABB's) + core::vector3df getBoundingCenter() const; + + //! the cam should tell the frustum the distance between far and near + void setFarNearDistance(float distance); + + //! get the given state's matrix based on frustum E_TRANSFORMATION_STATE + core::matrix4 &getTransform(video::E_TRANSFORMATION_STATE state); + + //! get the given state's matrix based on frustum E_TRANSFORMATION_STATE + const core::matrix4 &getTransform(video::E_TRANSFORMATION_STATE state) const; + + //! clips a line to the view frustum. + /** \return True if the line was clipped, false if not */ + bool clipLine(core::line3d &line) const; + + //! the position of the camera + core::vector3df cameraPosition; + + //! all planes enclosing the view frustum. + core::plane3d planes[VF_PLANE_COUNT]; + + //! bounding box around the view frustum + core::aabbox3d boundingBox; + +private: + //! Hold a copy of important transform matrices + enum E_TRANSFORMATION_STATE_FRUSTUM + { + ETS_VIEW = 0, + ETS_PROJECTION = 1, + ETS_COUNT_FRUSTUM + }; + + //! recalculates the bounding sphere based on the planes + inline void recalculateBoundingSphere(); + + //! Hold a copy of important transform matrices + core::matrix4 Matrices[ETS_COUNT_FRUSTUM]; + + float BoundingRadius; + float FarNearDistance; + core::vector3df BoundingCenter; +}; + +/*! + Copy constructor ViewFrustum +*/ +inline SViewFrustum::SViewFrustum(const SViewFrustum &other) +{ + cameraPosition = other.cameraPosition; + boundingBox = other.boundingBox; + + u32 i; + for (i = 0; i < VF_PLANE_COUNT; ++i) + planes[i] = other.planes[i]; + + for (i = 0; i < ETS_COUNT_FRUSTUM; ++i) + Matrices[i] = other.Matrices[i]; + + BoundingRadius = other.BoundingRadius; + FarNearDistance = other.FarNearDistance; + BoundingCenter = other.BoundingCenter; +} + +inline SViewFrustum::SViewFrustum(const core::matrix4 &mat, bool zClipFromZero) +{ + setFrom(mat, zClipFromZero); +} + +inline void SViewFrustum::transform(const core::matrix4 &mat) +{ + for (u32 i = 0; i < VF_PLANE_COUNT; ++i) + mat.transformPlane(planes[i]); + + mat.transformVect(cameraPosition); + recalculateBoundingBox(); +} + +inline core::vector3df SViewFrustum::getFarLeftUp() const +{ + core::vector3df p; + planes[scene::SViewFrustum::VF_FAR_PLANE].getIntersectionWithPlanes( + planes[scene::SViewFrustum::VF_TOP_PLANE], + planes[scene::SViewFrustum::VF_LEFT_PLANE], p); + + return p; +} + +inline core::vector3df SViewFrustum::getFarLeftDown() const +{ + core::vector3df p; + planes[scene::SViewFrustum::VF_FAR_PLANE].getIntersectionWithPlanes( + planes[scene::SViewFrustum::VF_BOTTOM_PLANE], + planes[scene::SViewFrustum::VF_LEFT_PLANE], p); + + return p; +} + +inline core::vector3df SViewFrustum::getFarRightUp() const +{ + core::vector3df p; + planes[scene::SViewFrustum::VF_FAR_PLANE].getIntersectionWithPlanes( + planes[scene::SViewFrustum::VF_TOP_PLANE], + planes[scene::SViewFrustum::VF_RIGHT_PLANE], p); + + return p; +} + +inline core::vector3df SViewFrustum::getFarRightDown() const +{ + core::vector3df p; + planes[scene::SViewFrustum::VF_FAR_PLANE].getIntersectionWithPlanes( + planes[scene::SViewFrustum::VF_BOTTOM_PLANE], + planes[scene::SViewFrustum::VF_RIGHT_PLANE], p); + + return p; +} + +inline core::vector3df SViewFrustum::getNearLeftUp() const +{ + core::vector3df p; + planes[scene::SViewFrustum::VF_NEAR_PLANE].getIntersectionWithPlanes( + planes[scene::SViewFrustum::VF_TOP_PLANE], + planes[scene::SViewFrustum::VF_LEFT_PLANE], p); + + return p; +} + +inline core::vector3df SViewFrustum::getNearLeftDown() const +{ + core::vector3df p; + planes[scene::SViewFrustum::VF_NEAR_PLANE].getIntersectionWithPlanes( + planes[scene::SViewFrustum::VF_BOTTOM_PLANE], + planes[scene::SViewFrustum::VF_LEFT_PLANE], p); + + return p; +} + +inline core::vector3df SViewFrustum::getNearRightUp() const +{ + core::vector3df p; + planes[scene::SViewFrustum::VF_NEAR_PLANE].getIntersectionWithPlanes( + planes[scene::SViewFrustum::VF_TOP_PLANE], + planes[scene::SViewFrustum::VF_RIGHT_PLANE], p); + + return p; +} + +inline core::vector3df SViewFrustum::getNearRightDown() const +{ + core::vector3df p; + planes[scene::SViewFrustum::VF_NEAR_PLANE].getIntersectionWithPlanes( + planes[scene::SViewFrustum::VF_BOTTOM_PLANE], + planes[scene::SViewFrustum::VF_RIGHT_PLANE], p); + + return p; +} + +inline const core::aabbox3d &SViewFrustum::getBoundingBox() const +{ + return boundingBox; +} + +inline void SViewFrustum::recalculateBoundingBox() +{ + boundingBox.reset(getNearLeftUp()); + boundingBox.addInternalPoint(getNearRightUp()); + boundingBox.addInternalPoint(getNearLeftDown()); + boundingBox.addInternalPoint(getNearRightDown()); + boundingBox.addInternalPoint(getFarRightUp()); + boundingBox.addInternalPoint(getFarLeftDown()); + boundingBox.addInternalPoint(getFarRightDown()); + boundingBox.addInternalPoint(getFarLeftUp()); + + // Also recalculate the bounding sphere when the bbox changes + recalculateBoundingSphere(); +} + +inline float SViewFrustum::getBoundingRadius() const +{ + return BoundingRadius; +} + +inline core::vector3df SViewFrustum::getBoundingCenter() const +{ + return BoundingCenter; +} + +inline void SViewFrustum::setFarNearDistance(float distance) +{ + FarNearDistance = distance; +} + +//! This constructor creates a view frustum based on a projection +//! and/or view matrix. +inline void SViewFrustum::setFrom(const core::matrix4 &mat, bool zClipFromZero) +{ + // left clipping plane + planes[VF_LEFT_PLANE].Normal.X = mat[3] + mat[0]; + planes[VF_LEFT_PLANE].Normal.Y = mat[7] + mat[4]; + planes[VF_LEFT_PLANE].Normal.Z = mat[11] + mat[8]; + planes[VF_LEFT_PLANE].D = mat[15] + mat[12]; + + // right clipping plane + planes[VF_RIGHT_PLANE].Normal.X = mat[3] - mat[0]; + planes[VF_RIGHT_PLANE].Normal.Y = mat[7] - mat[4]; + planes[VF_RIGHT_PLANE].Normal.Z = mat[11] - mat[8]; + planes[VF_RIGHT_PLANE].D = mat[15] - mat[12]; + + // top clipping plane + planes[VF_TOP_PLANE].Normal.X = mat[3] - mat[1]; + planes[VF_TOP_PLANE].Normal.Y = mat[7] - mat[5]; + planes[VF_TOP_PLANE].Normal.Z = mat[11] - mat[9]; + planes[VF_TOP_PLANE].D = mat[15] - mat[13]; + + // bottom clipping plane + planes[VF_BOTTOM_PLANE].Normal.X = mat[3] + mat[1]; + planes[VF_BOTTOM_PLANE].Normal.Y = mat[7] + mat[5]; + planes[VF_BOTTOM_PLANE].Normal.Z = mat[11] + mat[9]; + planes[VF_BOTTOM_PLANE].D = mat[15] + mat[13]; + + // far clipping plane + planes[VF_FAR_PLANE].Normal.X = mat[3] - mat[2]; + planes[VF_FAR_PLANE].Normal.Y = mat[7] - mat[6]; + planes[VF_FAR_PLANE].Normal.Z = mat[11] - mat[10]; + planes[VF_FAR_PLANE].D = mat[15] - mat[14]; + + // near clipping plane + if (zClipFromZero) { + planes[VF_NEAR_PLANE].Normal.X = mat[2]; + planes[VF_NEAR_PLANE].Normal.Y = mat[6]; + planes[VF_NEAR_PLANE].Normal.Z = mat[10]; + planes[VF_NEAR_PLANE].D = mat[14]; + } else { + // near clipping plane + planes[VF_NEAR_PLANE].Normal.X = mat[3] + mat[2]; + planes[VF_NEAR_PLANE].Normal.Y = mat[7] + mat[6]; + planes[VF_NEAR_PLANE].Normal.Z = mat[11] + mat[10]; + planes[VF_NEAR_PLANE].D = mat[15] + mat[14]; + } + + // normalize normals + u32 i; + for (i = 0; i != VF_PLANE_COUNT; ++i) { + const f32 len = -core::reciprocal_squareroot( + planes[i].Normal.getLengthSQ()); + planes[i].Normal *= len; + planes[i].D *= len; + } + + // make bounding box + recalculateBoundingBox(); +} + +/*! + View Frustum depends on Projection & View Matrix +*/ +inline core::matrix4 &SViewFrustum::getTransform(video::E_TRANSFORMATION_STATE state) +{ + u32 index = 0; + switch (state) { + case video::ETS_PROJECTION: + index = SViewFrustum::ETS_PROJECTION; + break; + case video::ETS_VIEW: + index = SViewFrustum::ETS_VIEW; + break; + default: + break; + } + return Matrices[index]; +} + +/*! + View Frustum depends on Projection & View Matrix +*/ +inline const core::matrix4 &SViewFrustum::getTransform(video::E_TRANSFORMATION_STATE state) const +{ + u32 index = 0; + switch (state) { + case video::ETS_PROJECTION: + index = SViewFrustum::ETS_PROJECTION; + break; + case video::ETS_VIEW: + index = SViewFrustum::ETS_VIEW; + break; + default: + break; + } + return Matrices[index]; +} + +//! Clips a line to the frustum +inline bool SViewFrustum::clipLine(core::line3d &line) const +{ + bool wasClipped = false; + for (u32 i = 0; i < VF_PLANE_COUNT; ++i) { + if (planes[i].classifyPointRelation(line.start) == core::ISREL3D_FRONT) { + line.start = line.start.getInterpolated(line.end, + 1.f - planes[i].getKnownIntersectionWithLine(line.start, line.end)); + wasClipped = true; + } + if (planes[i].classifyPointRelation(line.end) == core::ISREL3D_FRONT) { + line.end = line.start.getInterpolated(line.end, + 1.f - planes[i].getKnownIntersectionWithLine(line.start, line.end)); + wasClipped = true; + } + } + return wasClipped; +} + +inline void SViewFrustum::recalculateBoundingSphere() +{ + // Find the center + const float shortlen = (getNearLeftUp() - getNearRightUp()).getLength(); + const float longlen = (getFarLeftUp() - getFarRightUp()).getLength(); + + const float farlen = FarNearDistance; + const float fartocenter = (farlen + (shortlen - longlen) * (shortlen + longlen) / (4 * farlen)) / 2; + const float neartocenter = farlen - fartocenter; + + BoundingCenter = cameraPosition + -planes[VF_NEAR_PLANE].Normal * neartocenter; + + // Find the radius + core::vector3df dir[8]; + dir[0] = getFarLeftUp() - BoundingCenter; + dir[1] = getFarRightUp() - BoundingCenter; + dir[2] = getFarLeftDown() - BoundingCenter; + dir[3] = getFarRightDown() - BoundingCenter; + dir[4] = getNearRightDown() - BoundingCenter; + dir[5] = getNearLeftDown() - BoundingCenter; + dir[6] = getNearRightUp() - BoundingCenter; + dir[7] = getNearLeftUp() - BoundingCenter; + + u32 i = 0; + float diam[8] = {0.f}; + + for (i = 0; i < 8; ++i) + diam[i] = dir[i].getLengthSQ(); + + float longest = 0; + + for (i = 0; i < 8; ++i) { + if (diam[i] > longest) + longest = diam[i]; + } + + BoundingRadius = sqrtf(longest); +} + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/SceneParameters.h b/irr/include/SceneParameters.h new file mode 100644 index 000000000..717797e26 --- /dev/null +++ b/irr/include/SceneParameters.h @@ -0,0 +1,50 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" + +/*! \file SceneParameters.h + \brief Header file containing all scene parameters for modifying mesh loading etc. + + This file includes all parameter names which can be set using ISceneManager::getParameters() + to modify the behavior of plugins and mesh loaders. +*/ + +namespace irr +{ +namespace scene +{ +//! Name of the parameter for changing how Irrlicht handles the ZWrite flag for transparent (blending) materials +/** The default behavior in Irrlicht is to disable writing to the +z-buffer for all really transparent, i.e. blending materials. This +avoids problems with intersecting faces, but can also break renderings. +If transparent materials should use the SMaterial flag for ZWriteEnable +just as other material types use this attribute. +Use it like this: +\code +SceneManager->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true); +\endcode +**/ +const c8 *const ALLOW_ZWRITE_ON_TRANSPARENT = "Allow_ZWrite_On_Transparent"; + +//! Flag to avoid loading group structures in .obj files +/** Use it like this: +\code +SceneManager->getParameters()->setAttribute(scene::OBJ_LOADER_IGNORE_GROUPS, true); +\endcode +**/ +const c8 *const OBJ_LOADER_IGNORE_GROUPS = "OBJ_IgnoreGroups"; + +//! Flag to avoid loading material .mtl file for .obj files +/** Use it like this: +\code +SceneManager->getParameters()->setAttribute(scene::OBJ_LOADER_IGNORE_MATERIAL_FILES, true); +\endcode +**/ +const c8 *const OBJ_LOADER_IGNORE_MATERIAL_FILES = "OBJ_IgnoreMaterialFiles"; + +} // end namespace scene +} // end namespace irr diff --git a/irr/include/aabbox3d.h b/irr/include/aabbox3d.h new file mode 100644 index 000000000..81c2293ad --- /dev/null +++ b/irr/include/aabbox3d.h @@ -0,0 +1,389 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrMath.h" +#include "plane3d.h" +#include "line3d.h" + +namespace irr +{ +namespace core +{ + +//! Axis aligned bounding box in 3d dimensional space. +/** Has some useful methods used with occlusion culling or clipping. + */ +template +class aabbox3d +{ +public: + //! Default Constructor. + constexpr aabbox3d() : + MinEdge(-1, -1, -1), MaxEdge(1, 1, 1) {} + //! Constructor with min edge and max edge. + constexpr aabbox3d(const vector3d &min, const vector3d &max) : + MinEdge(min), MaxEdge(max) {} + //! Constructor with only one point. + constexpr aabbox3d(const vector3d &init) : + MinEdge(init), MaxEdge(init) {} + //! Constructor with min edge and max edge as single values, not vectors. + constexpr aabbox3d(T minx, T miny, T minz, T maxx, T maxy, T maxz) : + MinEdge(minx, miny, minz), MaxEdge(maxx, maxy, maxz) {} + + // operators + //! Equality operator + /** \param other box to compare with. + \return True if both boxes are equal, else false. */ + constexpr inline bool operator==(const aabbox3d &other) const + { + return (MinEdge == other.MinEdge && other.MaxEdge == MaxEdge); + } + //! Inequality operator + /** \param other box to compare with. + \return True if both boxes are different, else false. */ + constexpr inline bool operator!=(const aabbox3d &other) const + { + return !(MinEdge == other.MinEdge && other.MaxEdge == MaxEdge); + } + + // functions + + //! Resets the bounding box to a one-point box. + /** \param x X coord of the point. + \param y Y coord of the point. + \param z Z coord of the point. */ + void reset(T x, T y, T z) + { + MaxEdge.set(x, y, z); + MinEdge = MaxEdge; + } + + //! Resets the bounding box. + /** \param initValue New box to set this one to. */ + void reset(const aabbox3d &initValue) + { + *this = initValue; + } + + //! Resets the bounding box to a one-point box. + /** \param initValue New point. */ + void reset(const vector3d &initValue) + { + MaxEdge = initValue; + MinEdge = initValue; + } + + //! Adds a point to the bounding box + /** The box grows bigger, if point was outside of the box. + \param p: Point to add into the box. */ + void addInternalPoint(const vector3d &p) + { + addInternalPoint(p.X, p.Y, p.Z); + } + + //! Adds another bounding box + /** The box grows bigger, if the new box was outside of the box. + \param b: Other bounding box to add into this box. */ + void addInternalBox(const aabbox3d &b) + { + addInternalPoint(b.MaxEdge); + addInternalPoint(b.MinEdge); + } + + //! Adds a point to the bounding box + /** The box grows bigger, if point is outside of the box. + \param x X coordinate of the point to add to this box. + \param y Y coordinate of the point to add to this box. + \param z Z coordinate of the point to add to this box. */ + void addInternalPoint(T x, T y, T z) + { + if (x > MaxEdge.X) + MaxEdge.X = x; + if (y > MaxEdge.Y) + MaxEdge.Y = y; + if (z > MaxEdge.Z) + MaxEdge.Z = z; + + if (x < MinEdge.X) + MinEdge.X = x; + if (y < MinEdge.Y) + MinEdge.Y = y; + if (z < MinEdge.Z) + MinEdge.Z = z; + } + + //! Get center of the bounding box + /** \return Center of the bounding box. */ + vector3d getCenter() const + { + return (MinEdge + MaxEdge) / 2; + } + + //! Get extent of the box (maximal distance of two points in the box) + /** \return Extent of the bounding box. */ + vector3d getExtent() const + { + return MaxEdge - MinEdge; + } + + //! Get radius of the bounding sphere + /** \return Radius of the bounding sphere. */ + T getRadius() const + { + const T radius = getExtent().getLength() / 2; + return radius; + } + + //! Check if the box is empty. + /** This means that there is no space between the min and max edge. + \return True if box is empty, else false. */ + bool isEmpty() const + { + return MinEdge.equals(MaxEdge); + } + + //! Get the volume enclosed by the box in cubed units + T getVolume() const + { + const vector3d e = getExtent(); + return e.X * e.Y * e.Z; + } + + //! Get the surface area of the box in squared units + T getArea() const + { + const vector3d e = getExtent(); + return 2 * (e.X * e.Y + e.X * e.Z + e.Y * e.Z); + } + + //! Stores all 8 edges of the box into an array + /** \param edges: Pointer to array of 8 edges. */ + void getEdges(vector3d *edges) const + { + const core::vector3d middle = getCenter(); + const core::vector3d diag = middle - MaxEdge; + + /* + Edges are stored in this way: + Hey, am I an ascii artist, or what? :) niko. + /3--------/7 + / | / | + / | / | + 1---------5 | + | /2- - -|- -6 + | / | / + |/ | / + 0---------4/ + */ + + edges[0].set(middle.X + diag.X, middle.Y + diag.Y, middle.Z + diag.Z); + edges[1].set(middle.X + diag.X, middle.Y - diag.Y, middle.Z + diag.Z); + edges[2].set(middle.X + diag.X, middle.Y + diag.Y, middle.Z - diag.Z); + edges[3].set(middle.X + diag.X, middle.Y - diag.Y, middle.Z - diag.Z); + edges[4].set(middle.X - diag.X, middle.Y + diag.Y, middle.Z + diag.Z); + edges[5].set(middle.X - diag.X, middle.Y - diag.Y, middle.Z + diag.Z); + edges[6].set(middle.X - diag.X, middle.Y + diag.Y, middle.Z - diag.Z); + edges[7].set(middle.X - diag.X, middle.Y - diag.Y, middle.Z - diag.Z); + } + + //! Repairs the box. + /** Necessary if for example MinEdge and MaxEdge are swapped. */ + void repair() + { + T t; + + if (MinEdge.X > MaxEdge.X) { + t = MinEdge.X; + MinEdge.X = MaxEdge.X; + MaxEdge.X = t; + } + if (MinEdge.Y > MaxEdge.Y) { + t = MinEdge.Y; + MinEdge.Y = MaxEdge.Y; + MaxEdge.Y = t; + } + if (MinEdge.Z > MaxEdge.Z) { + t = MinEdge.Z; + MinEdge.Z = MaxEdge.Z; + MaxEdge.Z = t; + } + } + + // Check if MaxEdge > MinEdge + bool isValid() const + { + if (MinEdge.X > MaxEdge.X) + return false; + if (MinEdge.Y > MaxEdge.Y) + return false; + if (MinEdge.Z > MaxEdge.Z) + return false; + + return true; + } + + //! Calculates a new interpolated bounding box. + /** d=0 returns other, d=1 returns this, all other values blend between + the two boxes. + \param other Other box to interpolate between + \param d Value between 0.0f and 1.0f. + \return Interpolated box. */ + aabbox3d getInterpolated(const aabbox3d &other, f32 d) const + { + f32 inv = 1.0f - d; + return aabbox3d((other.MinEdge * inv) + (MinEdge * d), + (other.MaxEdge * inv) + (MaxEdge * d)); + } + + //! Determines if a point is within this box. + /** Border is included (IS part of the box)! + \param p: Point to check. + \return True if the point is within the box and false if not */ + bool isPointInside(const vector3d &p) const + { + return (p.X >= MinEdge.X && p.X <= MaxEdge.X && + p.Y >= MinEdge.Y && p.Y <= MaxEdge.Y && + p.Z >= MinEdge.Z && p.Z <= MaxEdge.Z); + } + + //! Determines if a point is within this box and not its borders. + /** Border is excluded (NOT part of the box)! + \param p: Point to check. + \return True if the point is within the box and false if not. */ + bool isPointTotalInside(const vector3d &p) const + { + return (p.X > MinEdge.X && p.X < MaxEdge.X && + p.Y > MinEdge.Y && p.Y < MaxEdge.Y && + p.Z > MinEdge.Z && p.Z < MaxEdge.Z); + } + + //! Check if this box is completely inside the 'other' box. + /** \param other: Other box to check against. + \return True if this box is completely inside the other box, + otherwise false. */ + bool isFullInside(const aabbox3d &other) const + { + return (MinEdge.X >= other.MinEdge.X && MinEdge.Y >= other.MinEdge.Y && MinEdge.Z >= other.MinEdge.Z && + MaxEdge.X <= other.MaxEdge.X && MaxEdge.Y <= other.MaxEdge.Y && MaxEdge.Z <= other.MaxEdge.Z); + } + + //! Returns the intersection of this box with another, if possible. + aabbox3d intersect(const aabbox3d &other) const + { + aabbox3d out; + + if (!intersectsWithBox(other)) + return out; + + out.MaxEdge.X = min_(MaxEdge.X, other.MaxEdge.X); + out.MaxEdge.Y = min_(MaxEdge.Y, other.MaxEdge.Y); + out.MaxEdge.Z = min_(MaxEdge.Z, other.MaxEdge.Z); + + out.MinEdge.X = max_(MinEdge.X, other.MinEdge.X); + out.MinEdge.Y = max_(MinEdge.Y, other.MinEdge.Y); + out.MinEdge.Z = max_(MinEdge.Z, other.MinEdge.Z); + + return out; + } + + //! Determines if the axis-aligned box intersects with another axis-aligned box. + /** \param other: Other box to check a intersection with. + \return True if there is an intersection with the other box, + otherwise false. */ + bool intersectsWithBox(const aabbox3d &other) const + { + return (MinEdge.X <= other.MaxEdge.X && MinEdge.Y <= other.MaxEdge.Y && MinEdge.Z <= other.MaxEdge.Z && + MaxEdge.X >= other.MinEdge.X && MaxEdge.Y >= other.MinEdge.Y && MaxEdge.Z >= other.MinEdge.Z); + } + + //! Tests if the box intersects with a line + /** \param line: Line to test intersection with. + \return True if there is an intersection , else false. */ + bool intersectsWithLine(const line3d &line) const + { + return intersectsWithLine(line.getMiddle(), line.getVector().normalize(), + (T)(line.getLength() * 0.5)); + } + + //! Tests if the box intersects with a line + /** \param linemiddle Center of the line. + \param linevect Vector of the line. + \param halflength Half length of the line. + \return True if there is an intersection, else false. */ + bool intersectsWithLine(const vector3d &linemiddle, + const vector3d &linevect, T halflength) const + { + const vector3d e = getExtent() * (T)0.5; + const vector3d t = getCenter() - linemiddle; + + if ((fabs(t.X) > e.X + halflength * fabs(linevect.X)) || + (fabs(t.Y) > e.Y + halflength * fabs(linevect.Y)) || + (fabs(t.Z) > e.Z + halflength * fabs(linevect.Z))) + return false; + + T r = e.Y * (T)fabs(linevect.Z) + e.Z * (T)fabs(linevect.Y); + if (fabs(t.Y * linevect.Z - t.Z * linevect.Y) > r) + return false; + + r = e.X * (T)fabs(linevect.Z) + e.Z * (T)fabs(linevect.X); + if (fabs(t.Z * linevect.X - t.X * linevect.Z) > r) + return false; + + r = e.X * (T)fabs(linevect.Y) + e.Y * (T)fabs(linevect.X); + if (fabs(t.X * linevect.Y - t.Y * linevect.X) > r) + return false; + + return true; + } + + //! Classifies a relation with a plane. + /** \param plane Plane to classify relation to. + \return Returns ISREL3D_FRONT if the box is in front of the plane, + ISREL3D_BACK if the box is behind the plane, and + ISREL3D_CLIPPED if it is on both sides of the plane. */ + EIntersectionRelation3D classifyPlaneRelation(const plane3d &plane) const + { + vector3d nearPoint(MaxEdge); + vector3d farPoint(MinEdge); + + if (plane.Normal.X > (T)0) { + nearPoint.X = MinEdge.X; + farPoint.X = MaxEdge.X; + } + + if (plane.Normal.Y > (T)0) { + nearPoint.Y = MinEdge.Y; + farPoint.Y = MaxEdge.Y; + } + + if (plane.Normal.Z > (T)0) { + nearPoint.Z = MinEdge.Z; + farPoint.Z = MaxEdge.Z; + } + + if (plane.Normal.dotProduct(nearPoint) + plane.D > (T)0) + return ISREL3D_FRONT; + + if (plane.Normal.dotProduct(farPoint) + plane.D > (T)0) + return ISREL3D_CLIPPED; + + return ISREL3D_BACK; + } + + //! The near edge + vector3d MinEdge; + + //! The far edge + vector3d MaxEdge; +}; + +//! Typedef for a f32 3d bounding box. +typedef aabbox3d aabbox3df; +//! Typedef for an integer 3d bounding box. +typedef aabbox3d aabbox3di; + +} // end namespace core +} // end namespace irr diff --git a/irr/include/coreutil.h b/irr/include/coreutil.h new file mode 100644 index 000000000..60014c4a7 --- /dev/null +++ b/irr/include/coreutil.h @@ -0,0 +1,194 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrString.h" +#include "path.h" + +namespace irr +{ +namespace core +{ + +/*! \file coreutil.h + \brief File containing useful basic utility functions +*/ + +// ----------- some basic quite often used string functions ----------------- + +//! search if a filename has a proper extension +inline s32 isFileExtension(const io::path &filename, const io::path &ext0, + const io::path &ext1, const io::path &ext2) +{ + s32 extPos = filename.findLast('.'); + if (extPos < 0) + return 0; + + extPos += 1; + if (filename.equals_substring_ignore_case(ext0, extPos)) + return 1; + if (filename.equals_substring_ignore_case(ext1, extPos)) + return 2; + if (filename.equals_substring_ignore_case(ext2, extPos)) + return 3; + return 0; +} + +//! search if a filename has a proper extension +inline bool hasFileExtension(const io::path &filename, const io::path &ext0, + const io::path &ext1 = "", const io::path &ext2 = "") +{ + return isFileExtension(filename, ext0, ext1, ext2) > 0; +} + +//! cut the filename extension from a source file path and store it in a dest file path +inline io::path &cutFilenameExtension(io::path &dest, const io::path &source) +{ + s32 endPos = source.findLast('.'); + dest = source.subString(0, endPos < 0 ? source.size() : endPos); + return dest; +} + +//! get the filename extension from a file path +inline io::path &getFileNameExtension(io::path &dest, const io::path &source) +{ + s32 endPos = source.findLast('.'); + if (endPos < 0) + dest = ""; + else + dest = source.subString(endPos, source.size()); + return dest; +} + +//! delete path from filename +inline io::path &deletePathFromFilename(io::path &filename) +{ + // delete path from filename + const fschar_t *s = filename.c_str(); + const fschar_t *p = s + filename.size(); + + // search for path separator or beginning + while (*p != '/' && *p != '\\' && p != s) + p--; + + if (p != s) { + ++p; + filename = p; + } + return filename; +} + +//! trim paths +inline io::path &deletePathFromPath(io::path &filename, s32 pathCount) +{ + // delete path from filename + s32 i = filename.size(); + + // search for path separator or beginning + while (i >= 0) { + if (filename[i] == '/' || filename[i] == '\\') { + if (--pathCount <= 0) + break; + } + --i; + } + + if (i > 0) { + filename[i + 1] = 0; + filename.validate(); + } else + filename = ""; + return filename; +} + +//! looks if file is in the same directory of path. returns offset of directory. +//! 0 means in same directory. 1 means file is direct child of path +inline s32 isInSameDirectory(const io::path &path, const io::path &file) +{ + if (path.size() && !path.equalsn(file, path.size())) + return -1; + + s32 subA = 0; + s32 subB = 0; + s32 pos = 0; + while ((pos = path.findNext('/', pos)) >= 0) { + subA += 1; + pos += 1; + } + + pos = 0; + while ((pos = file.findNext('/', pos)) >= 0) { + subB += 1; + pos += 1; + } + + return subB - subA; +} + +//! splits a path into components +static inline void splitFilename(const io::path &name, io::path *path = 0, + io::path *filename = 0, io::path *extension = 0, bool make_lower = false) +{ + s32 i = name.size(); + s32 extpos = i; + + // search for path separator or beginning + while (i >= 0) { + if (name[i] == '.') { + extpos = i; + if (extension) + *extension = name.subString(extpos + 1, name.size() - (extpos + 1), make_lower); + } else if (name[i] == '/' || name[i] == '\\') { + if (filename) + *filename = name.subString(i + 1, extpos - (i + 1), make_lower); + if (path) { + *path = name.subString(0, i + 1, make_lower); + path->replace('\\', '/'); + } + return; + } + i -= 1; + } + if (filename) + *filename = name.subString(0, extpos, make_lower); +} + +//! create a filename from components +static inline io::path mergeFilename(const io::path &path, const io::path &filename, const io::path &extension = "") +{ + io::path result(path); + + if (!result.empty()) { + fschar_t last = result.lastChar(); + if (last != _IRR_TEXT('/') && last != _IRR_TEXT('\\')) + result += _IRR_TEXT('/'); + } + if (!filename.empty()) + result += filename; + if (!extension.empty()) { + if (!result.empty() && extension[0] != _IRR_TEXT('.')) + result += _IRR_TEXT('.'); + result += extension; + } + + return result; +} + +//! some standard function ( to remove dependencies ) +inline bool isdigit(s32 c) +{ + return c >= '0' && c <= '9'; +} +inline bool isspace(s32 c) +{ + return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v'; +} +inline bool isupper(s32 c) +{ + return c >= 'A' && c <= 'Z'; +} + +} // end namespace core +} // end namespace irr diff --git a/irr/include/dimension2d.h b/irr/include/dimension2d.h new file mode 100644 index 000000000..ab6c81c30 --- /dev/null +++ b/irr/include/dimension2d.h @@ -0,0 +1,216 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" +#include "irrMath.h" // for irr::core::equals() + +namespace irr +{ +namespace core +{ +template +class vector2d; + +//! Specifies a 2 dimensional size. +template +class dimension2d +{ +public: + //! Default constructor for empty dimension + constexpr dimension2d() : + Width(0), Height(0) {} + //! Constructor with width and height + constexpr dimension2d(const T &width, const T &height) : + Width(width), Height(height) {} + + dimension2d(const vector2d &other); // Defined in vector2d.h + + //! Use this constructor only where you are sure that the conversion is valid. + template + explicit constexpr dimension2d(const dimension2d &other) : + Width((T)other.Width), Height((T)other.Height) + { + } + + template + dimension2d &operator=(const dimension2d &other) + { + Width = (T)other.Width; + Height = (T)other.Height; + return *this; + } + + //! Equality operator + bool operator==(const dimension2d &other) const + { + return core::equals(Width, other.Width) && + core::equals(Height, other.Height); + } + + //! Inequality operator + bool operator!=(const dimension2d &other) const + { + return !(*this == other); + } + + bool operator==(const vector2d &other) const; // Defined in vector2d.h + + bool operator!=(const vector2d &other) const + { + return !(*this == other); + } + + //! Set to new values + dimension2d &set(const T &width, const T &height) + { + Width = width; + Height = height; + return *this; + } + + //! Divide width and height by scalar + dimension2d &operator/=(const T &scale) + { + Width /= scale; + Height /= scale; + return *this; + } + + //! Divide width and height by scalar + dimension2d operator/(const T &scale) const + { + return dimension2d(Width / scale, Height / scale); + } + + //! Multiply width and height by scalar + dimension2d &operator*=(const T &scale) + { + Width *= scale; + Height *= scale; + return *this; + } + + //! Multiply width and height by scalar + dimension2d operator*(const T &scale) const + { + return dimension2d(Width * scale, Height * scale); + } + + //! Add another dimension to this one. + dimension2d &operator+=(const dimension2d &other) + { + Width += other.Width; + Height += other.Height; + return *this; + } + + //! Add two dimensions + dimension2d operator+(const dimension2d &other) const + { + return dimension2d(Width + other.Width, Height + other.Height); + } + + //! Subtract a dimension from this one + dimension2d &operator-=(const dimension2d &other) + { + Width -= other.Width; + Height -= other.Height; + return *this; + } + + //! Subtract one dimension from another + dimension2d operator-(const dimension2d &other) const + { + return dimension2d(Width - other.Width, Height - other.Height); + } + + //! Get area + T getArea() const + { + return Width * Height; + } + + //! Get the optimal size according to some properties + /** This is a function often used for texture dimension + calculations. The function returns the next larger or + smaller dimension which is a power-of-two dimension + (2^n,2^m) and/or square (Width=Height). + \param requirePowerOfTwo Forces the result to use only + powers of two as values. + \param requireSquare Makes width==height in the result + \param larger Choose whether the result is larger or + smaller than the current dimension. If one dimension + need not be changed it is kept with any value of larger. + \param maxValue Maximum texturesize. if value > 0 size is + clamped to maxValue + \return The optimal dimension under the given + constraints. */ + dimension2d getOptimalSize( + bool requirePowerOfTwo = true, + bool requireSquare = false, + bool larger = true, + u32 maxValue = 0) const + { + u32 i = 1; + u32 j = 1; + if (requirePowerOfTwo) { + while (i < (u32)Width) + i <<= 1; + if (!larger && i != 1 && i != (u32)Width) + i >>= 1; + while (j < (u32)Height) + j <<= 1; + if (!larger && j != 1 && j != (u32)Height) + j >>= 1; + } else { + i = (u32)Width; + j = (u32)Height; + } + + if (requireSquare) { + if ((larger && (i > j)) || (!larger && (i < j))) + j = i; + else + i = j; + } + + if (maxValue > 0 && i > maxValue) + i = maxValue; + + if (maxValue > 0 && j > maxValue) + j = maxValue; + + return dimension2d((T)i, (T)j); + } + + //! Get the interpolated dimension + /** \param other Other dimension to interpolate with. + \param d Value between 0.0f and 1.0f. d=0 returns other, d=1 returns this, values between interpolate. + \return Interpolated dimension. */ + dimension2d getInterpolated(const dimension2d &other, f32 d) const + { + f32 inv = (1.0f - d); + return dimension2d((T)(other.Width * inv + Width * d), (T)(other.Height * inv + Height * d)); + } + + //! Width of the dimension. + T Width; + //! Height of the dimension. + T Height; +}; + +//! Typedef for an f32 dimension. +typedef dimension2d dimension2df; +//! Typedef for an unsigned integer dimension. +typedef dimension2d dimension2du; + +//! Typedef for an integer dimension. +/** There are few cases where negative dimensions make sense. Please consider using + dimension2du instead. */ +typedef dimension2d dimension2di; + +} // end namespace core +} // end namespace irr diff --git a/irr/include/exampleHelper.h b/irr/include/exampleHelper.h new file mode 100755 index 000000000..698430cb9 --- /dev/null +++ b/irr/include/exampleHelper.h @@ -0,0 +1,21 @@ +// Copyright (C) 2015 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "path.h" + +namespace irr +{ + +static io::path getExampleMediaPath() +{ +#ifdef IRR_MOBILE_PATHS + return io::path("media/"); +#else + return io::path("../../media/"); +#endif +} + +} // end namespace irr diff --git a/irr/include/fast_atof.h b/irr/include/fast_atof.h new file mode 100644 index 000000000..8bbd0e9f1 --- /dev/null +++ b/irr/include/fast_atof.h @@ -0,0 +1,343 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine" and the "irrXML" project. +// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h + +#pragma once + +#include "irrMath.h" +#include "irrString.h" + +namespace irr +{ +namespace core +{ + +#define IRR_ATOF_TABLE_SIZE 17 +// we write [IRR_ATOF_TABLE_SIZE] here instead of [] to work around a swig bug +const float fast_atof_table[17] = { + 0.f, + 0.1f, + 0.01f, + 0.001f, + 0.0001f, + 0.00001f, + 0.000001f, + 0.0000001f, + 0.00000001f, + 0.000000001f, + 0.0000000001f, + 0.00000000001f, + 0.000000000001f, + 0.0000000000001f, + 0.00000000000001f, + 0.000000000000001f, + 0.0000000000000001f}; + +//! Convert a simple string of base 10 digits into an unsigned 32 bit integer. +/** \param[in] in: The string of digits to convert. No leading chars are + allowed, only digits 0 to 9. Parsing stops at the first non-digit. + \param[out] out: (optional) If provided, it will be set to point at the + first character not used in the calculation. + \return The unsigned integer value of the digits. If the string specifies + too many digits to encode in an u32 then INT_MAX will be returned. +*/ +inline u32 strtoul10(const char *in, const char **out = 0) +{ + if (!in) { + if (out) + *out = in; + return 0; + } + + bool overflow = false; + u32 unsignedValue = 0; + while ((*in >= '0') && (*in <= '9')) { + const u32 tmp = (unsignedValue * 10) + (*in - '0'); + if (tmp < unsignedValue) { + unsignedValue = (u32)0xffffffff; + overflow = true; + } + if (!overflow) + unsignedValue = tmp; + ++in; + } + + if (out) + *out = in; + + return unsignedValue; +} + +//! Convert a simple string of base 10 digits into a signed 32 bit integer. +/** \param[in] in: The string of digits to convert. Only a leading - or + + followed by digits 0 to 9 will be considered. Parsing stops at the first + non-digit. + \param[out] out: (optional) If provided, it will be set to point at the + first character not used in the calculation. + \return The signed integer value of the digits. If the string specifies + too many digits to encode in an s32 then +INT_MAX or -INT_MAX will be + returned. +*/ +inline s32 strtol10(const char *in, const char **out = 0) +{ + if (!in) { + if (out) + *out = in; + return 0; + } + + const bool negative = ('-' == *in); + if (negative || ('+' == *in)) + ++in; + + const u32 unsignedValue = strtoul10(in, out); + if (unsignedValue > (u32)INT_MAX) { + if (negative) + return (s32)INT_MIN; + else + return (s32)INT_MAX; + } else { + if (negative) + return -((s32)unsignedValue); + else + return (s32)unsignedValue; + } +} + +//! Convert a hex-encoded character to an unsigned integer. +/** \param[in] in The digit to convert. Only digits 0 to 9 and chars A-F,a-f + will be considered. + \return The unsigned integer value of the digit. 0xffffffff if the input is + not hex +*/ +inline u32 ctoul16(char in) +{ + if (in >= '0' && in <= '9') + return in - '0'; + else if (in >= 'a' && in <= 'f') + return 10u + in - 'a'; + else if (in >= 'A' && in <= 'F') + return 10u + in - 'A'; + else + return 0xffffffff; +} + +//! Convert a simple string of base 16 digits into an unsigned 32 bit integer. +/** \param[in] in: The string of digits to convert. No leading chars are + allowed, only digits 0 to 9 and chars A-F,a-f are allowed. Parsing stops + at the first illegal char. + \param[out] out: (optional) If provided, it will be set to point at the + first character not used in the calculation. + \return The unsigned integer value of the digits. If the string specifies + too many digits to encode in an u32 then INT_MAX will be returned. +*/ +inline u32 strtoul16(const char *in, const char **out = 0) +{ + if (!in) { + if (out) + *out = in; + return 0; + } + + bool overflow = false; + u32 unsignedValue = 0; + while (true) { + u32 tmp = 0; + if ((*in >= '0') && (*in <= '9')) + tmp = (unsignedValue << 4u) + (*in - '0'); + else if ((*in >= 'A') && (*in <= 'F')) + tmp = (unsignedValue << 4u) + (*in - 'A') + 10; + else if ((*in >= 'a') && (*in <= 'f')) + tmp = (unsignedValue << 4u) + (*in - 'a') + 10; + else + break; + if (tmp < unsignedValue) { + unsignedValue = (u32)INT_MAX; + overflow = true; + } + if (!overflow) + unsignedValue = tmp; + ++in; + } + + if (out) + *out = in; + + return unsignedValue; +} + +//! Convert a simple string of base 8 digits into an unsigned 32 bit integer. +/** \param[in] in The string of digits to convert. No leading chars are + allowed, only digits 0 to 7 are allowed. Parsing stops at the first illegal + char. + \param[out] out (optional) If provided, it will be set to point at the + first character not used in the calculation. + \return The unsigned integer value of the digits. If the string specifies + too many digits to encode in an u32 then INT_MAX will be returned. +*/ +inline u32 strtoul8(const char *in, const char **out = 0) +{ + if (!in) { + if (out) + *out = in; + return 0; + } + + bool overflow = false; + u32 unsignedValue = 0; + while (true) { + u32 tmp = 0; + if ((*in >= '0') && (*in <= '7')) + tmp = (unsignedValue << 3u) + (*in - '0'); + else + break; + if (tmp < unsignedValue) { + unsignedValue = (u32)INT_MAX; + overflow = true; + } + if (!overflow) + unsignedValue = tmp; + ++in; + } + + if (out) + *out = in; + + return unsignedValue; +} + +//! Convert a C-style prefixed string (hex, oct, integer) into an unsigned 32 bit integer. +/** \param[in] in The string of digits to convert. If string starts with 0x the + hex parser is used, if only leading 0 is used, oct parser is used. In all + other cases, the usual unsigned parser is used. + \param[out] out (optional) If provided, it will be set to point at the + first character not used in the calculation. + \return The unsigned integer value of the digits. If the string specifies + too many digits to encode in an u32 then INT_MAX will be returned. +*/ +inline u32 strtoul_prefix(const char *in, const char **out = 0) +{ + if (!in) { + if (out) + *out = in; + return 0; + } + if ('0' == in[0]) + return ('x' == in[1] ? strtoul16(in + 2, out) : strtoul8(in + 1, out)); + return strtoul10(in, out); +} + +//! Converts a sequence of digits into a whole positive floating point value. +/** Only digits 0 to 9 are parsed. Parsing stops at any other character, + including sign characters or a decimal point. + \param in: the sequence of digits to convert. + \param out: (optional) will be set to point at the first non-converted + character. + \return The whole positive floating point representation of the digit + sequence. +*/ +inline f32 strtof10(const char *in, const char **out = 0) +{ + if (!in) { + if (out) + *out = in; + return 0.f; + } + + const u32 MAX_SAFE_U32_VALUE = UINT_MAX / 10 - 10; + u32 intValue = 0; + + // Use integer arithmetic for as long as possible, for speed + // and precision. + while ((*in >= '0') && (*in <= '9')) { + // If it looks like we're going to overflow, bail out + // now and start using floating point. + if (intValue >= MAX_SAFE_U32_VALUE) + break; + + intValue = (intValue * 10) + (*in - '0'); + ++in; + } + + f32 floatValue = (f32)intValue; + + // If there are any digits left to parse, then we need to use + // floating point arithmetic from here. + while ((*in >= '0') && (*in <= '9')) { + floatValue = (floatValue * 10.f) + (f32)(*in - '0'); + ++in; + if (floatValue > FLT_MAX) // Just give up. + break; + } + + if (out) + *out = in; + + return floatValue; +} + +//! Provides a fast function for converting a string into a float. +/** This is not guaranteed to be as accurate as atof(), but is + approximately 6 to 8 times as fast. + \param[in] in The string to convert. + \param[out] result The resultant float will be written here. + \return Pointer to the first character in the string that wasn't used + to create the float value. +*/ +inline const char *fast_atof_move(const char *in, f32 &result) +{ + // Please run the regression test when making any modifications to this function. + + result = 0.f; + if (!in) + return 0; + + const bool negative = ('-' == *in); + if (negative || ('+' == *in)) + ++in; + + f32 value = strtof10(in, &in); + + if (*in == '.') { + const char *afterDecimal = ++in; + const f32 decimal = strtof10(in, &afterDecimal); + const size_t numDecimals = afterDecimal - in; + if (numDecimals < IRR_ATOF_TABLE_SIZE) { + value += decimal * fast_atof_table[numDecimals]; + } else { + value += decimal * (f32)pow(10.f, -(float)numDecimals); + } + in = afterDecimal; + } + + if ('e' == *in || 'E' == *in) { + ++in; + // Assume that the exponent is a whole number. + // strtol10() will deal with both + and - signs, + // but calculate as f32 to prevent overflow at FLT_MAX + // Using pow with float cast instead of powf as otherwise accuracy decreases. + value *= (f32)pow(10.f, (f32)strtol10(in, &in)); + } + + result = negative ? -value : value; + return in; +} + +//! Convert a string to a floating point number +/** \param floatAsString The string to convert. + \param out Optional pointer to the first character in the string that + wasn't used to create the float value. + \result Float value parsed from the input string +*/ +inline float fast_atof(const char *floatAsString, const char **out = 0) +{ + float ret; + if (out) + *out = fast_atof_move(floatAsString, ret); + else + fast_atof_move(floatAsString, ret); + return ret; +} + +} // end namespace core +} // end namespace irr diff --git a/irr/include/irrArray.h b/irr/include/irrArray.h new file mode 100644 index 000000000..b6f573a79 --- /dev/null +++ b/irr/include/irrArray.h @@ -0,0 +1,422 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine" and the "irrXML" project. +// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h + +#pragma once +#include +#include +#include + +#include "irrTypes.h" +#include "irrMath.h" + +namespace irr +{ +namespace core +{ + +//! Self reallocating template array (like stl vector) with additional features. +/** Some features are: Heap sorting, binary search methods, easier debugging. + */ +template +class array +{ +public: + static_assert(!std::is_same::value, + "irr::core::array with T = bool not supported. Use std::vector instead."); + + //! Default constructor for empty array. + array() : + m_data(), is_sorted(true) + { + } + + //! Constructs an array and allocates an initial chunk of memory. + /** \param start_count Amount of elements to pre-allocate. */ + explicit array(u32 start_count) : + m_data(), is_sorted(true) + { + m_data.reserve(start_count); + } + + //! Copy constructor + array(const array &other) : + m_data(other.m_data), is_sorted(other.is_sorted) + { + } + + //! Reallocates the array, make it bigger or smaller. + /** \param new_size New size of array. + \param canShrink Specifies whether the array is reallocated even if + enough space is available. Setting this flag to false can speed up + array usage, but may use more memory than required by the data. + */ + void reallocate(u32 new_size, bool canShrink = true) + { + size_t allocated = m_data.capacity(); + if (new_size < allocated) { + if (canShrink) + m_data.resize(new_size); + } else { + m_data.reserve(new_size); + } + } + + //! Adds an element at back of array. + /** If the array is too small to add this new element it is made bigger. + \param element: Element to add at the back of the array. */ + void push_back(const T &element) + { + m_data.push_back(element); + is_sorted = false; + } + + void push_back(T &&element) + { + m_data.push_back(std::move(element)); + is_sorted = false; + } + + //! Adds an element at the front of the array. + /** If the array is to small to add this new element, the array is + made bigger. Please note that this is slow, because the whole array + needs to be copied for this. + \param element Element to add at the back of the array. */ + void push_front(const T &element) + { + m_data.insert(m_data.begin(), element); + is_sorted = false; + } + + void push_front(T &&element) + { + m_data.insert(m_data.begin(), std::move(element)); + is_sorted = false; + } + + //! Insert item into array at specified position. + /** + \param element: Element to be inserted + \param index: Where position to insert the new element. */ + void insert(const T &element, u32 index = 0) + { + _IRR_DEBUG_BREAK_IF(index > m_data.size()) // access violation + auto pos = std::next(m_data.begin(), index); + m_data.insert(pos, element); + is_sorted = false; + } + + //! Clears the array and deletes all allocated memory. + void clear() + { + // vector::clear() reduces the size to 0, but doesn't free memory. + // This swap is guaranteed to delete the allocated memory. + std::vector().swap(m_data); + is_sorted = true; + } + + //! Set (copy) data from given memory block + /** \param newData data to set, must have newSize elements + \param newSize Amount of elements in newData + \param canShrink When true we reallocate the array even it can shrink. + May reduce memory usage, but call is more whenever size changes. + \param newDataIsSorted Info if you pass sorted/unsorted data + */ + void set_data(const T *newData, u32 newSize, bool newDataIsSorted = false, bool canShrink = false) + { + m_data.resize(newSize); + if (canShrink) { + m_data.shrink_to_fit(); + } + std::copy(newData, newData + newSize, m_data.begin()); + is_sorted = newDataIsSorted; + } + + //! Compare if given data block is identical to the data in our array + /** Like operator ==, but without the need to create the array + \param otherData Address to data against which we compare, must contain size elements + \param size Amount of elements in otherData */ + bool equals(const T *otherData, u32 size) const + { + if (m_data.size() != size) + return false; + return std::equal(m_data.begin(), m_data.end(), otherData); + } + + //! Sets the size of the array and allocates new elements if necessary. + /** \param usedNow Amount of elements now used. */ + void set_used(u32 usedNow) + { + m_data.resize(usedNow); + } + + //! Assignment operator + const array &operator=(const array &other) + { + if (this == &other) + return *this; + m_data = other.m_data; + is_sorted = other.is_sorted; + return *this; + } + + array &operator=(const std::vector &other) + { + m_data = other; + is_sorted = false; + return *this; + } + + array &operator=(std::vector &&other) + { + m_data = std::move(other); + is_sorted = false; + return *this; + } + + //! Equality operator + bool operator==(const array &other) const + { + return equals(other.const_pointer(), other.size()); + } + + //! Inequality operator + bool operator!=(const array &other) const + { + return !(*this == other); + } + + //! Direct access operator + T &operator[](u32 index) + { + _IRR_DEBUG_BREAK_IF(index >= m_data.size()) // access violation + + return m_data[index]; + } + + //! Direct const access operator + const T &operator[](u32 index) const + { + _IRR_DEBUG_BREAK_IF(index >= m_data.size()) // access violation + + return m_data[index]; + } + + //! Gets last element. + T &getLast() + { + _IRR_DEBUG_BREAK_IF(m_data.empty()) // access violation + + return m_data.back(); + } + + //! Gets last element + const T &getLast() const + { + _IRR_DEBUG_BREAK_IF(m_data.empty()) // access violation + + return m_data.back(); + } + + //! Gets a pointer to the array. + /** \return Pointer to the array. */ + T *pointer() + { + return m_data.empty() ? nullptr : &m_data[0]; + } + + //! Gets a const pointer to the array. + /** \return Pointer to the array. */ + const T *const_pointer() const + { + return m_data.empty() ? nullptr : &m_data[0]; + } + + //! Get number of occupied elements of the array. + /** \return Size of elements in the array which are actually occupied. */ + u32 size() const + { + return static_cast(m_data.size()); + } + + //! Get amount of memory allocated. + /** \return Amount of memory allocated. The amount of bytes + allocated would be allocated_size() * sizeof(ElementTypeUsed); */ + u32 allocated_size() const + { + return m_data.capacity(); + } + + //! Check if array is empty. + /** \return True if the array is empty false if not. */ + bool empty() const + { + return m_data.empty(); + } + + //! Sorts the array using heapsort. + /** There is no additional memory waste and the algorithm performs + O(n*log n) in worst case. */ + void sort() + { + if (!is_sorted) { + std::sort(m_data.begin(), m_data.end()); + is_sorted = true; + } + } + + //! Performs a binary search for an element, returns -1 if not found. + /** The array will be sorted before the binary search if it is not + already sorted. Caution is advised! Be careful not to call this on + unsorted const arrays, or the slower method will be used. + \param element Element to search for. + \return Position of the searched element if it was found, + otherwise -1 is returned. */ + s32 binary_search(const T &element) + { + sort(); + return binary_search(element, 0, (s32)m_data.size() - 1); + } + + //! Performs a binary search for an element if possible, returns -1 if not found. + /** This method is for const arrays and so cannot call sort(), if the array is + not sorted then linear_search will be used instead. Potentially very slow! + \param element Element to search for. + \return Position of the searched element if it was found, + otherwise -1 is returned. */ + s32 binary_search(const T &element) const + { + if (is_sorted) + return binary_search(element, 0, (s32)m_data.size() - 1); + else + return linear_search(element); + } + + //! Performs a binary search for an element, returns -1 if not found. + /** \param element: Element to search for. + \param left First left index + \param right Last right index. + \return Position of the searched element if it was found, otherwise -1 + is returned. */ + s32 binary_search(const T &element, s32 left, s32 right) const + { + if (left > right) + return -1; + auto lpos = std::next(m_data.begin(), left); + auto rpos = std::next(m_data.begin(), right); + auto it = std::lower_bound(lpos, rpos, element); + // *it = first element in [first, last) that is >= element, or last if not found. + if (*it < element || element < *it) + return -1; + return static_cast(it - m_data.begin()); + } + + //! Performs a binary search for an element, returns -1 if not found. + //! it is used for searching a multiset + /** The array will be sorted before the binary search if it is not + already sorted. + \param element Element to search for. + \param &last return lastIndex of equal elements + \return Position of the first searched element if it was found, + otherwise -1 is returned. */ + s32 binary_search_multi(const T &element, s32 &last) + { + sort(); + auto iters = std::equal_range(m_data.begin(), m_data.end(), element); + if (iters.first == iters.second) + return -1; + last = static_cast((iters.second - m_data.begin()) - 1); + return static_cast(iters.first - m_data.begin()); + } + + //! Finds an element in linear time, which is very slow. + /** Use binary_search for faster finding. Only works if ==operator is + implemented. + \param element Element to search for. + \return Position of the searched element if it was found, otherwise -1 + is returned. */ + s32 linear_search(const T &element) const + { + auto it = std::find(m_data.begin(), m_data.end(), element); + if (it == m_data.end()) + return -1; + return static_cast(it - m_data.begin()); + } + + //! Finds an element in linear time, which is very slow. + /** Use binary_search for faster finding. Only works if ==operator is + implemented. + \param element: Element to search for. + \return Position of the searched element if it was found, otherwise -1 + is returned. */ + s32 linear_reverse_search(const T &element) const + { + auto it = std::find(m_data.rbegin(), m_data.rend(), element); + if (it == m_data.rend()) + return -1; + size_t offset = it - m_data.rbegin(); + return m_data.size() - offset - 1; + } + + //! Erases an element from the array. + /** May be slow, because all elements following after the erased + element have to be copied. + \param index: Index of element to be erased. */ + void erase(u32 index) + { + _IRR_DEBUG_BREAK_IF(index >= m_data.size()) // access violation + auto it = std::next(m_data.begin(), index); + m_data.erase(it); + } + + //! Erases some elements from the array. + /** May be slow, because all elements following after the erased + element have to be copied. + \param index: Index of the first element to be erased. + \param count: Amount of elements to be erased. */ + void erase(u32 index, s32 count) + { + if (index >= m_data.size() || count < 1) + return; + count = core::min_(count, (s32)m_data.size() - (s32)index); + auto first = std::next(m_data.begin(), index); + auto last = std::next(first, count); + m_data.erase(first, last); + } + + //! Sets if the array is sorted + void set_sorted(bool _is_sorted) + { + is_sorted = _is_sorted; + } + + //! Swap the content of this array container with the content of another array + /** Afterward this object will contain the content of the other object and the other + object will contain the content of this object. + \param other Swap content with this object */ + void swap(array &other) + { + m_data.swap(other.m_data); + std::swap(is_sorted, other.is_sorted); + } + + //! Pull the contents of this array as a vector. + // The array is left empty. + std::vector steal() + { + std::vector ret = std::move(m_data); + m_data.clear(); + is_sorted = true; + return ret; + } + + typedef T value_type; + typedef u32 size_type; + +private: + std::vector m_data; + bool is_sorted; +}; + +} // end namespace core +} // end namespace irr diff --git a/irr/include/irrMath.h b/irr/include/irrMath.h new file mode 100644 index 000000000..3a1471a02 --- /dev/null +++ b/irr/include/irrMath.h @@ -0,0 +1,477 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" +#include +#include +#include // for abs() etc. +#include // For INT_MAX / UINT_MAX +#include + +namespace irr +{ +namespace core +{ + +//! Rounding error constant often used when comparing f32 values. + +const f32 ROUNDING_ERROR_f32 = 0.000001f; +const f64 ROUNDING_ERROR_f64 = 0.00000001; + +#ifdef PI // make sure we don't collide with a define +#undef PI +#endif +//! Constant for PI. +const f32 PI = 3.14159265359f; + +//! Constant for reciprocal of PI. +const f32 RECIPROCAL_PI = 1.0f / PI; + +//! Constant for half of PI. +const f32 HALF_PI = PI / 2.0f; + +#ifdef PI64 // make sure we don't collide with a define +#undef PI64 +#endif +//! Constant for 64bit PI. +const f64 PI64 = 3.1415926535897932384626433832795028841971693993751; + +//! Constant for 64bit reciprocal of PI. +const f64 RECIPROCAL_PI64 = 1.0 / PI64; + +//! 32bit Constant for converting from degrees to radians +const f32 DEGTORAD = PI / 180.0f; + +//! 32bit constant for converting from radians to degrees (formally known as GRAD_PI) +const f32 RADTODEG = 180.0f / PI; + +//! 64bit constant for converting from degrees to radians (formally known as GRAD_PI2) +const f64 DEGTORAD64 = PI64 / 180.0; + +//! 64bit constant for converting from radians to degrees +const f64 RADTODEG64 = 180.0 / PI64; + +//! Utility function to convert a radian value to degrees +/** Provided as it can be clearer to write radToDeg(X) than RADTODEG * X +\param radians The radians value to convert to degrees. +*/ +inline f32 radToDeg(f32 radians) +{ + return RADTODEG * radians; +} + +//! Utility function to convert a radian value to degrees +/** Provided as it can be clearer to write radToDeg(X) than RADTODEG * X +\param radians The radians value to convert to degrees. +*/ +inline f64 radToDeg(f64 radians) +{ + return RADTODEG64 * radians; +} + +//! Utility function to convert a degrees value to radians +/** Provided as it can be clearer to write degToRad(X) than DEGTORAD * X +\param degrees The degrees value to convert to radians. +*/ +inline f32 degToRad(f32 degrees) +{ + return DEGTORAD * degrees; +} + +//! Utility function to convert a degrees value to radians +/** Provided as it can be clearer to write degToRad(X) than DEGTORAD * X +\param degrees The degrees value to convert to radians. +*/ +inline f64 degToRad(f64 degrees) +{ + return DEGTORAD64 * degrees; +} + +//! returns minimum of two values. Own implementation to get rid of the STL (VS6 problems) +template +inline const T &min_(const T &a, const T &b) +{ + return a < b ? a : b; +} + +//! returns minimum of three values. Own implementation to get rid of the STL (VS6 problems) +template +inline const T &min_(const T &a, const T &b, const T &c) +{ + return a < b ? min_(a, c) : min_(b, c); +} + +//! returns maximum of two values. Own implementation to get rid of the STL (VS6 problems) +template +inline const T &max_(const T &a, const T &b) +{ + return a < b ? b : a; +} + +//! returns maximum of three values. Own implementation to get rid of the STL (VS6 problems) +template +inline const T &max_(const T &a, const T &b, const T &c) +{ + return a < b ? max_(b, c) : max_(a, c); +} + +//! returns abs of two values. Own implementation to get rid of STL (VS6 problems) +template +inline T abs_(const T &a) +{ + return a < (T)0 ? -a : a; +} + +//! returns linear interpolation of a and b with ratio t +//! \return: a if t==0, b if t==1, and the linear interpolation else +template +inline T lerp(const T &a, const T &b, const f32 t) +{ + return (T)(a * (1.f - t)) + (b * t); +} + +//! clamps a value between low and high +template +inline const T clamp(const T &value, const T &low, const T &high) +{ + return min_(max_(value, low), high); +} + +//! swaps the content of the passed parameters +// Note: We use the same trick as boost and use two template arguments to +// avoid ambiguity when swapping objects of an Irrlicht type that has not +// it's own swap overload. Otherwise we get conflicts with some compilers +// in combination with stl. +template +inline void swap(T1 &a, T2 &b) +{ + T1 c(a); + a = b; + b = c; +} + +template +inline T roundingError(); + +template <> +inline f32 roundingError() +{ + return ROUNDING_ERROR_f32; +} + +template <> +inline f64 roundingError() +{ + return ROUNDING_ERROR_f64; +} + +template +inline T relativeErrorFactor() +{ + return 1; +} + +template <> +inline f32 relativeErrorFactor() +{ + return 4; +} + +template <> +inline f64 relativeErrorFactor() +{ + return 8; +} + +//! returns if a equals b, for types without rounding errors +template ::value, bool> = true> +inline bool equals(const T a, const T b) +{ + return a == b; +} + +//! returns if a equals b, taking possible rounding errors into account +template ::value, bool> = true> +inline bool equals(const T a, const T b, const T tolerance = roundingError()) +{ + return std::abs(a - b) <= tolerance; +} + +//! returns if a equals b, taking relative error in form of factor +//! this particular function does not involve any division. +template +inline bool equalsRelative(const T a, const T b, const T factor = relativeErrorFactor()) +{ + // https://eagergames.wordpress.com/2017/04/01/fast-parallel-lines-and-vectors-test/ + + const T maxi = max_(a, b); + const T mini = min_(a, b); + const T maxMagnitude = max_(maxi, -mini); + + return (maxMagnitude * factor + maxi) == (maxMagnitude * factor + mini); // MAD Wise +} + +union FloatIntUnion32 +{ + FloatIntUnion32(float f1 = 0.0f) : + f(f1) {} + // Portable sign-extraction + bool sign() const { return (i >> 31) != 0; } + + irr::s32 i; + irr::f32 f; +}; + +//! We compare the difference in ULP's (spacing between floating-point numbers, aka ULP=1 means there exists no float between). +//\result true when numbers have a ULP <= maxUlpDiff AND have the same sign. +inline bool equalsByUlp(f32 a, f32 b, int maxUlpDiff) +{ + // Based on the ideas and code from Bruce Dawson on + // http://www.altdevblogaday.com/2012/02/22/comparing-floating-point-numbers-2012-edition/ + // When floats are interpreted as integers the two nearest possible float numbers differ just + // by one integer number. Also works the other way round, an integer of 1 interpreted as float + // is for example the smallest possible float number. + + const FloatIntUnion32 fa(a); + const FloatIntUnion32 fb(b); + + // Different signs, we could maybe get difference to 0, but so close to 0 using epsilons is better. + if (fa.sign() != fb.sign()) { + // Check for equality to make sure +0==-0 + if (fa.i == fb.i) + return true; + return false; + } + + // Find the difference in ULPs. + const int ulpsDiff = abs_(fa.i - fb.i); + if (ulpsDiff <= maxUlpDiff) + return true; + + return false; +} + +//! returns if a equals zero, taking rounding errors into account +inline bool iszero(const f64 a, const f64 tolerance = ROUNDING_ERROR_f64) +{ + return fabs(a) <= tolerance; +} + +//! returns if a equals zero, taking rounding errors into account +inline bool iszero(const f32 a, const f32 tolerance = ROUNDING_ERROR_f32) +{ + return fabsf(a) <= tolerance; +} + +//! returns if a equals not zero, taking rounding errors into account +inline bool isnotzero(const f32 a, const f32 tolerance = ROUNDING_ERROR_f32) +{ + return fabsf(a) > tolerance; +} + +//! returns if a equals zero, taking rounding errors into account +inline bool iszero(const s32 a, const s32 tolerance = 0) +{ + return (a & 0x7ffffff) <= tolerance; +} + +//! returns if a equals zero, taking rounding errors into account +inline bool iszero(const u32 a, const u32 tolerance = 0) +{ + return a <= tolerance; +} + +//! returns if a equals zero, taking rounding errors into account +inline bool iszero(const s64 a, const s64 tolerance = 0) +{ + return abs_(a) <= tolerance; +} + +inline s32 s32_min(s32 a, s32 b) +{ + return min_(a, b); +} + +inline s32 s32_max(s32 a, s32 b) +{ + return max_(a, b); +} + +inline s32 s32_clamp(s32 value, s32 low, s32 high) +{ + return clamp(value, low, high); +} + +/* + float IEEE-754 bit representation + + 0 0x00000000 + 1.0 0x3f800000 + 0.5 0x3f000000 + 3 0x40400000 + +inf 0x7f800000 + -inf 0xff800000 + +NaN 0x7fc00000 or 0x7ff00000 + in general: number = (sign ? -1:1) * 2^(exponent) * 1.(mantissa bits) +*/ + +typedef union +{ + u32 u; + s32 s; + f32 f; +} inttofloat; + +#define F32_AS_S32(f) (*((s32 *)&(f))) +#define F32_AS_U32(f) (*((u32 *)&(f))) +#define F32_AS_U32_POINTER(f) (((u32 *)&(f))) + +#define F32_VALUE_0 0x00000000 +#define F32_VALUE_1 0x3f800000 + +//! code is taken from IceFPU +//! Integer representation of a floating-point value. +inline u32 IR(f32 x) +{ + inttofloat tmp; + tmp.f = x; + return tmp.u; +} + +//! Floating-point representation of an integer value. +inline f32 FR(u32 x) +{ + inttofloat tmp; + tmp.u = x; + return tmp.f; +} +inline f32 FR(s32 x) +{ + inttofloat tmp; + tmp.s = x; + return tmp.f; +} + +#define F32_LOWER_0(n) ((n) < 0.0f) +#define F32_LOWER_EQUAL_0(n) ((n) <= 0.0f) +#define F32_GREATER_0(n) ((n) > 0.0f) +#define F32_GREATER_EQUAL_0(n) ((n) >= 0.0f) +#define F32_EQUAL_1(n) ((n) == 1.0f) +#define F32_EQUAL_0(n) ((n) == 0.0f) +#define F32_A_GREATER_B(a, b) ((a) > (b)) + +#ifndef REALINLINE +#ifdef _MSC_VER +#define REALINLINE __forceinline +#else +#define REALINLINE inline +#endif +#endif + +// NOTE: This is not as exact as the c99/c++11 round function, especially at high numbers starting with 8388609 +// (only low number which seems to go wrong is 0.49999997 which is rounded to 1) +// Also negative 0.5 is rounded up not down unlike with the standard function (p.E. input -0.5 will be 0 and not -1) +inline f32 round_(f32 x) +{ + return floorf(x + 0.5f); +} + +// calculate: sqrt ( x ) +REALINLINE f32 squareroot(const f32 f) +{ + return sqrtf(f); +} + +// calculate: sqrt ( x ) +REALINLINE f64 squareroot(const f64 f) +{ + return sqrt(f); +} + +// calculate: sqrt ( x ) +REALINLINE s32 squareroot(const s32 f) +{ + return static_cast(squareroot(static_cast(f))); +} + +// calculate: sqrt ( x ) +REALINLINE s64 squareroot(const s64 f) +{ + return static_cast(squareroot(static_cast(f))); +} + +// calculate: 1 / sqrt ( x ) +REALINLINE f64 reciprocal_squareroot(const f64 x) +{ + return 1.0 / sqrt(x); +} + +// calculate: 1 / sqrtf ( x ) +REALINLINE f32 reciprocal_squareroot(const f32 f) +{ + return 1.f / sqrtf(f); +} + +// calculate: 1 / sqrtf( x ) +REALINLINE s32 reciprocal_squareroot(const s32 x) +{ + return static_cast(reciprocal_squareroot(static_cast(x))); +} + +// calculate: 1 / x +REALINLINE f32 reciprocal(const f32 f) +{ + return 1.f / f; +} + +// calculate: 1 / x +REALINLINE f64 reciprocal(const f64 f) +{ + return 1.0 / f; +} + +// calculate: 1 / x, low precision allowed +REALINLINE f32 reciprocal_approxim(const f32 f) +{ + return 1.f / f; +} + +REALINLINE s32 floor32(f32 x) +{ + return (s32)floorf(x); +} + +REALINLINE s32 ceil32(f32 x) +{ + return (s32)ceilf(x); +} + +// NOTE: Please check round_ documentation about some inaccuracies in this compared to standard library round function. +REALINLINE s32 round32(f32 x) +{ + return (s32)round_(x); +} + +inline f32 f32_max3(const f32 a, const f32 b, const f32 c) +{ + return a > b ? (a > c ? a : c) : (b > c ? b : c); +} + +inline f32 f32_min3(const f32 a, const f32 b, const f32 c) +{ + return a < b ? (a < c ? a : c) : (b < c ? b : c); +} + +inline f32 fract(f32 x) +{ + return x - floorf(x); +} + +} // end namespace core +} // end namespace irr + +using irr::core::FR; +using irr::core::IR; diff --git a/irr/include/irrString.h b/irr/include/irrString.h new file mode 100644 index 000000000..5bf604e49 --- /dev/null +++ b/irr/include/irrString.h @@ -0,0 +1,931 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine" and the "irrXML" project. +// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h + +#pragma once + +#include "irrTypes.h" +#include +#include +#include +#include +#include +#include +#include + +namespace irr +{ +namespace core +{ + +//! Very simple string class with some useful features. +/** string and string both accept Unicode AND ASCII/Latin-1, +so you can assign Unicode to string and ASCII/Latin-1 to string +(and the other way round) if you want to. + +However, note that the conversation between both is not done using any encoding. +This means that c8 strings are treated as ASCII/Latin-1, not UTF-8, and +are simply expanded to the equivalent wchar_t, while Unicode/wchar_t +characters are truncated to 8-bit ASCII/Latin-1 characters, discarding all +other information in the wchar_t. + +Helper functions for converting between UTF-8 and wchar_t are provided +outside the string class for explicit use. +*/ + +// forward declarations +template +class string; + +//! Typedef for character strings +typedef string stringc; + +//! Typedef for wide character strings +typedef string stringw; + +//! Returns a character converted to lower case +static inline u32 locale_lower(u32 x) +{ + // ansi + return x >= 'A' && x <= 'Z' ? x + 0x20 : x; +} + +//! Returns a character converted to upper case +static inline u32 locale_upper(u32 x) +{ + // ansi + return x >= 'a' && x <= 'z' ? x + ('A' - 'a') : x; +} + +template +class string +{ +public: + typedef T char_type; + + //! Default constructor + string() + { + } + + //! Copy constructor + string(const string &other) + { + *this = other; + } + + //! Constructor from other string types + template + string(const string &other) + { + *this = other; + } + + //! Constructs a string from a float + explicit string(const double number) + { + c8 tmpbuf[32]; + snprintf_irr(tmpbuf, sizeof(tmpbuf), "%0.6f", number); + str = tmpbuf; + } + + //! Constructs a string from an int + explicit string(int number) + { + str = std::to_string(number); + } + + //! Constructs a string from an unsigned int + explicit string(unsigned int number) + { + str = std::to_string(number); + } + + //! Constructs a string from a long + explicit string(long number) + { + str = std::to_string(number); + } + + //! Constructs a string from an unsigned long + explicit string(unsigned long number) + { + str = std::to_string(number); + } + + //! Constructor for copying a string from a pointer with a given length + template + string(const B *const c, u32 length) + { + if (!c) + return; + + str.resize(length); + for (u32 l = 0; l < length; ++l) + str[l] = (T)c[l]; + } + + //! Constructor for Unicode and ASCII strings + template + string(const B *const c) + { + *this = c; + } + + //! Destructor + ~string() + { + } + + //! Assignment operator + string &operator=(const string &other) + { + if (this == &other) + return *this; + + str = other.str; + return *this; + } + + //! Assignment operator for other string types + template + string &operator=(const string &other) + { + *this = other.c_str(); + return *this; + } + + //! Assignment operator for strings, ASCII and Unicode + template + string &operator=(const B *const c) + { + if (!c) { + clear(); + return *this; + } + + // no longer allowed! + _IRR_DEBUG_BREAK_IF((void *)c == (void *)c_str()); + + u32 len = calclen(c); + str.resize(len); + for (u32 l = 0; l < len; ++l) + str[l] = (T)c[l]; + + return *this; + } + + //! Append operator for other strings + string operator+(const string &other) const + { + string tmp(*this); + tmp.append(other); + + return tmp; + } + + //! Append operator for strings, ASCII and Unicode + template + string operator+(const B *const c) const + { + string tmp(*this); + tmp.append(c); + + return tmp; + } + + //! Direct access operator + T &operator[](const u32 index) + { + return str[index]; + } + + //! Direct access operator + const T &operator[](const u32 index) const + { + return str[index]; + } + + //! Equality operator + bool operator==(const T *const other) const + { + if (!other) + return false; + return !cmp(c_str(), other); + } + + //! Equality operator + bool operator==(const string &other) const + { + return str == other.str; + } + + //! Is smaller comparator + bool operator<(const string &other) const + { + return str < other.str; + } + + //! Inequality operator + bool operator!=(const T *const other) const + { + return !(*this == other); + } + + //! Inequality operator + bool operator!=(const string &other) const + { + return !(*this == other); + } + + //! Returns length of the string's content + /** \return Length of the string's content in characters, excluding + the trailing NUL. */ + u32 size() const + { + return static_cast(str.size()); + } + + //! Informs if the string is empty or not. + //! \return True if the string is empty, false if not. + bool empty() const + { + return str.empty(); + } + + void clear(bool releaseMemory = true) + { + if (releaseMemory) { + stl_type empty; + std::swap(str, empty); + } else { + str.clear(); + } + } + + //! Returns character string + /** \return pointer to C-style NUL terminated string. */ + const T *c_str() const + { + return str.c_str(); + } + + //! Makes the string lower case. + string &make_lower() + { + std::transform(str.begin(), str.end(), str.begin(), [](const T &c) { + return locale_lower(c); + }); + return *this; + } + + //! Makes the string upper case. + string &make_upper() + { + std::transform(str.begin(), str.end(), str.begin(), [](const T &c) { + return locale_upper(c); + }); + return *this; + } + + //! Compares the strings ignoring case. + /** \param other: Other string to compare. + \return True if the strings are equal ignoring case. */ + bool equals_ignore_case(const string &other) const + { + const T *array = c_str(); + for (u32 i = 0; array[i] && other[i]; ++i) + if (locale_lower(array[i]) != locale_lower(other[i])) + return false; + + return size() == other.size(); + } + + //! Compares the strings ignoring case. + /** \param other: Other string to compare. + \param sourcePos: where to start to compare in the string + \return True if the strings are equal ignoring case. */ + bool equals_substring_ignore_case(const string &other, const u32 sourcePos = 0) const + { + if (sourcePos >= size() + 1) + return false; + + const T *array = c_str(); + u32 i; + for (i = 0; array[sourcePos + i] && other[i]; ++i) + if (locale_lower(array[sourcePos + i]) != locale_lower(other[i])) + return false; + + return array[sourcePos + i] == 0 && other[i] == 0; + } + + //! Compares the strings ignoring case. + /** \param other: Other string to compare. + \return True if this string is smaller ignoring case. */ + bool lower_ignore_case(const string &other) const + { + const T *array = c_str(); + for (u32 i = 0; array[i] && other[i]; ++i) { + s32 diff = (s32)locale_lower(array[i]) - (s32)locale_lower(other[i]); + if (diff) + return diff < 0; + } + + return size() < other.size(); + } + + //! compares the first n characters of the strings + /** \param other Other string to compare. + \param n Number of characters to compare + \return True if the n first characters of both strings are equal. */ + bool equalsn(const string &other, u32 n) const + { + const T *array = c_str(); + u32 i; + for (i = 0; i < n && array[i] && other[i]; ++i) + if (array[i] != other[i]) + return false; + + // if one (or both) of the strings was smaller then they + // are only equal if they have the same length + return (i == n) || (size() == other.size()); + } + + //! compares the first n characters of the strings + /** \param str Other string to compare. + \param n Number of characters to compare + \return True if the n first characters of both strings are equal. */ + bool equalsn(const T *const other, u32 n) const + { + if (!other) + return false; + const T *array = c_str(); + u32 i; + for (i = 0; i < n && array[i] && other[i]; ++i) + if (array[i] != other[i]) + return false; + + // if one (or both) of the strings was smaller then they + // are only equal if they have the same length + return (i == n) || (array[i] == 0 && other[i] == 0); + } + + //! Appends a character to this string + /** \param character: Character to append. */ + string &append(T character) + { + str.append(1, character); + return *this; + } + + //! Appends a char string to this string + /** \param other: Char string to append. */ + /** \param length: The length of the string to append. */ + string &append(const T *const other, u32 length = 0xffffffff) + { + if (!other) + return *this; + + u32 len = calclen(other); + if (len > length) + len = length; + + str.append(other, len); + return *this; + } + + //! Appends a string to this string + /** \param other: String to append. */ + string &append(const string &other) + { + str.append(other.str); + return *this; + } + + //! Appends a string of the length l to this string. + /** \param other: other String to append to this string. + \param length: How much characters of the other string to add to this one. */ + string &append(const string &other, u32 length) + { + if (other.size() < length) + append(other); + else + str.append(other.c_str(), length); + return *this; + } + + //! Insert a certain amount of characters into the string before the given index + //\param pos Insert the characters before this index + //\param s String to insert. Must be at least of size n + //\param n Number of characters from string s to use. + string &insert(u32 pos, const T *s, u32 n) + { + if (pos < size() + 1) { + str.insert(pos, s, n); + } + + return *this; + } + + //! Reserves some memory. + /** \param count: Amount of characters to reserve, including + the trailing NUL. */ + void reserve(u32 count) + { + if (count == 0) + return; + str.reserve(count - 1); + } + + //! finds first occurrence of character in string + /** \param c: Character to search for. + \return Position where the character has been found, + or -1 if not found. */ + s32 findFirst(T c) const + { + auto r = str.find(c); + return pos_from_stl(r); + } + + //! finds first occurrence of a character of a list in string + /** \param c: List of characters to find. For example if the method + should find the first occurrence of 'a' or 'b', this parameter should be "ab". + \param count: Amount of characters in the list. Usually, + this should be strlen(c) + \return Position where one of the characters has been found, + or -1 if not found. */ + s32 findFirstChar(const T *const c, u32 count = 1) const + { + if (!c || !count) + return -1; + + auto r = str.find_first_of(c, 0, count); + return pos_from_stl(r); + } + + //! Finds first position of a character not in a given list. + /** \param c: List of characters not to find. For example if the method + should find the first occurrence of a character not 'a' or 'b', this parameter should be "ab". + \param count: Amount of characters in the list. Usually, + this should be strlen(c) + \return Position where the character has been found, + or -1 if not found. */ + s32 findFirstCharNotInList(const T *const c, u32 count = 1) const + { + if (!c || !count) + return -1; + + auto r = str.find_first_not_of(c, 0, count); + return pos_from_stl(r); + } + + //! Finds last position of a character not in a given list. + /** \param c: List of characters not to find. For example if the method + should find the first occurrence of a character not 'a' or 'b', this parameter should be "ab". + \param count: Amount of characters in the list. Usually, + this should be strlen(c) + \return Position where the character has been found, + or -1 if not found. */ + s32 findLastCharNotInList(const T *const c, u32 count = 1) const + { + if (!c || !count) + return -1; + + auto r = str.find_last_not_of(c, npos, count); + return pos_from_stl(r); + } + + //! finds next occurrence of character in string + /** \param c: Character to search for. + \param startPos: Position in string to start searching. + \return Position where the character has been found, + or -1 if not found. */ + s32 findNext(T c, u32 startPos) const + { + auto r = str.find(c, startPos); + return pos_from_stl(r); + } + + //! finds last occurrence of character in string + /** \param c: Character to search for. + \param start: start to search reverse ( default = -1, on end ) + \return Position where the character has been found, + or -1 if not found. */ + s32 findLast(T c, s32 start = -1) const + { + auto r = str.rfind(c, pos_to_stl(start)); + return pos_from_stl(r); + } + + //! finds last occurrence of a character of a list in string + /** \param c: List of strings to find. For example if the method + should find the last occurrence of 'a' or 'b', this parameter should be "ab". + \param count: Amount of characters in the list. Usually, + this should be strlen(c) + \return Position where one of the characters has been found, + or -1 if not found. */ + s32 findLastChar(const T *const c, u32 count = 1) const + { + if (!c || !count) + return -1; + + auto r = str.find_last_of(c, npos, count); + return pos_from_stl(r); + } + + //! finds another string in this string + /** \param str: Another string + \param start: Start position of the search + \return Positions where the string has been found, + or -1 if not found. */ + s32 find(const T *const other, const u32 start = 0) const + { + if (other && *other) { + auto r = str.find(other, start); + return pos_from_stl(r); + } + + return -1; + } + + //! Returns a substring + /** \param begin Start of substring. + \param length Length of substring. + \param make_lower copy only lower case */ + string subString(u32 begin, s32 length, bool make_lower = false) const + { + // if start after string + // or no proper substring length + if ((length <= 0) || (begin >= size())) + return string(""); + + string o = str.substr(begin, length); + if (make_lower) + o.make_lower(); + return o; + } + + //! Appends a character to this string + /** \param c Character to append. */ + string &operator+=(T c) + { + append(c); + return *this; + } + + //! Appends a char string to this string + /** \param c Char string to append. */ + string &operator+=(const T *const c) + { + append(c); + return *this; + } + + //! Appends a string to this string + /** \param other String to append. */ + string &operator+=(const string &other) + { + append(other); + return *this; + } + + //! Appends a string representation of a number to this string + /** \param i Number to append. */ + string &operator+=(const int i) + { + append(string(i)); + return *this; + } + + //! Appends a string representation of a number to this string + /** \param i Number to append. */ + string &operator+=(const unsigned int i) + { + append(string(i)); + return *this; + } + + //! Appends a string representation of a number to this string + /** \param i Number to append. */ + string &operator+=(const long i) + { + append(string(i)); + return *this; + } + + //! Appends a string representation of a number to this string + /** \param i Number to append. */ + string &operator+=(const unsigned long i) + { + append(string(i)); + return *this; + } + + //! Appends a string representation of a number to this string + /** \param i Number to append. */ + string &operator+=(const double i) + { + append(string(i)); + return *this; + } + + //! Appends a string representation of a number to this string + /** \param i Number to append. */ + string &operator+=(const float i) + { + append(string(i)); + return *this; + } + + //! Replaces all characters of a special type with another one + /** \param toReplace Character to replace. + \param replaceWith Character replacing the old one. */ + string &replace(T toReplace, T replaceWith) + { + std::replace(str.begin(), str.end(), toReplace, replaceWith); + return *this; + } + + //! Replaces all instances of a string with another one. + /** \param toReplace The string to replace. + \param replaceWith The string replacing the old one. */ + string &replace(const string &toReplace, const string &replaceWith) + { + size_type pos = 0; + while ((pos = str.find(toReplace.str, pos)) != npos) { + str.replace(pos, toReplace.size(), replaceWith.str); + pos += replaceWith.size(); + } + + return *this; + } + + //! Removes a character from a string. + /** \param c: Character to remove. */ + string &remove(T c) + { + str.erase(std::remove(str.begin(), str.end(), c), str.end()); + return *this; + } + + //! Removes a string from the string. + /** \param toRemove: String to remove. */ + string &remove(const string &toRemove) + { + u32 size = toRemove.size(); + if (size == 0) + return *this; + u32 pos = 0; + u32 found = 0; + for (u32 i = 0; i < str.size(); ++i) { + u32 j = 0; + while (j < size) { + if (str[i + j] != toRemove[j]) + break; + ++j; + } + if (j == size) { + found += size; + i += size - 1; + continue; + } + + str[pos++] = str[i]; + } + str.resize(str.size() - found); + return *this; + } + + //! Removes characters from a string. + /** \param characters: Characters to remove. */ + string &removeChars(const string &characters) + { + if (characters.size() == 0) + return *this; + + for (u32 i = 0; i < characters.size(); i++) + remove(characters[i]); + return *this; + } + + //! Trims the string. + /** Removes the specified characters (by default, Latin-1 whitespace) + from the beginning and the end of the string. */ + string &trim(const string &whitespace = " \t\n\r") + { + // find start and end of the substring without the specified characters + const s32 begin = findFirstCharNotInList(whitespace.c_str(), whitespace.size()); + if (begin == -1) + return (*this = ""); + + const s32 end = findLastCharNotInList(whitespace.c_str(), whitespace.size()); + + return (*this = subString(begin, (end + 1) - begin)); + } + + //! Erases a character from the string. + /** May be slow, because all elements + following after the erased element have to be copied. + \param index: Index of element to be erased. */ + string &erase(u32 index) + { + str.erase(str.begin() + index); + return *this; + } + + //! verify the existing string. + string &validate() + { + // truncate to existing null + u32 len = calclen(c_str()); + if (len != size()) + str.resize(len); + + return *this; + } + + //! gets the last char of a string or null + T lastChar() const + { + return !str.empty() ? str.back() : 0; + } + + //! Split string into parts (tokens). + /** This method will split a string at certain delimiter characters + into the container passed in as reference. The type of the container + has to be given as template parameter. It must provide a push_back and + a size method. + \param ret The result container. Tokens are added, the container is not cleared. + \param delimiter C-style string of delimiter characters + \param countDelimiters Number of delimiter characters + \param ignoreEmptyTokens Flag to avoid empty substrings in the result + container. If two delimiters occur without a character in between or an + empty substring would be placed in the result. Or if a delimiter is the last + character an empty substring would be added at the end. If this flag is set, + only non-empty strings are stored. + \param keepSeparators Flag which allows to add the separator to the + result string. If this flag is true, the concatenation of the + substrings results in the original string. Otherwise, only the + characters between the delimiters are returned. + \return The number of resulting substrings + */ + template + u32 split(container &ret, const T *const delimiter, u32 countDelimiters = 1, bool ignoreEmptyTokens = true, bool keepSeparators = false) const + { + if (!delimiter) + return 0; + + const u32 oldSize = static_cast(ret.size()); + + u32 tokenStartIdx = 0; + for (u32 i = 0; i < size() + 1; ++i) { + for (u32 j = 0; j < countDelimiters; ++j) { + if (str[i] == delimiter[j]) { + if (i - tokenStartIdx > 0) + ret.push_back(string(&str[tokenStartIdx], i - tokenStartIdx)); + else if (!ignoreEmptyTokens) + ret.push_back(string()); + if (keepSeparators) { + ret.push_back(string(&str[i], 1)); + } + + tokenStartIdx = i + 1; + break; + } + } + } + if (size() > tokenStartIdx) + ret.push_back(string(&str[tokenStartIdx], size() - tokenStartIdx)); + else if (!ignoreEmptyTokens) + ret.push_back(string()); + + return static_cast(ret.size() - oldSize); + } + + // This function should not be used and is only kept for "CGUIFileOpenDialog::pathToStringW". + friend size_t multibyteToWString(stringw &destination, const stringc &source); + + friend size_t utf8ToWString(stringw &destination, const char *source); + friend size_t wStringToUTF8(stringc &destination, const wchar_t *source); + +private: + typedef std::basic_string stl_type; + + //! Private constructor + string(stl_type &&str) : + str(str) + { + } + + //! strlen wrapper + template + static inline u32 calclen(const U *p) + { + u32 len = 0; + while (*p++) + len++; + return len; + } + static inline u32 calclen(const char *p) + { + return static_cast(strlen(p)); + } + static inline u32 calclen(const wchar_t *p) + { + return static_cast(wcslen(p)); + } + + //! strcmp wrapper + template + static inline int cmp(const U *p, const U *p2) + { + while (*p && *p == *p2) + p++, p2++; + return (int)*p - (int)*p2; + } + static inline int cmp(const char *p, const char *p2) + { + return strcmp(p, p2); + } + static inline int cmp(const wchar_t *p, const wchar_t *p2) + { + return wcscmp(p, p2); + } + + typedef typename stl_type::size_type size_type; + static const size_type npos = stl_type::npos; + + static inline s32 pos_from_stl(size_type pos) + { + return pos == npos ? -1 : (s32)pos; + } + static inline size_type pos_to_stl(s32 pos) + { + return pos == -1 ? npos : (size_type)pos; + } + + stl_type str; +}; + +//! Convert multibyte string to wide-character string +/** Wrapper around mbstowcs from standard library, but directly using Irrlicht string class. +What the function does exactly depends on the LC_CTYPE of the current c locale. +\param destination Wide-character string receiving the converted source +\param source multibyte string +\return The number of wide characters written to destination, not including the eventual terminating null character or -1 when conversion failed + +This function should not be used and is only kept for "CGUIFileOpenDialog::pathToStringW". */ +inline size_t multibyteToWString(stringw &destination, const core::stringc &source) +{ + u32 sourceSize = source.size(); + + if (sourceSize) { + destination.str.resize(sourceSize + 1); +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable : 4996) // 'mbstowcs': This function or variable may be unsafe. Consider using mbstowcs_s instead. +#endif + const size_t written = mbstowcs(&destination[0], source.c_str(), (size_t)sourceSize); +#if defined(_MSC_VER) +#pragma warning(pop) +#endif + if (written != (size_t)-1) { + destination.str.resize(written); + } else { + // Likely character which got converted until the invalid character was encountered are in destination now. + // And it seems even 0-terminated, but I found no documentation anywhere that this (the 0-termination) is guaranteed :-( + destination.clear(); + } + return written; + } else { + destination.clear(); + return 0; + } +} + +inline size_t utf8ToWString(stringw &destination, const char *source) +{ + std::wstring_convert> conv; + destination = conv.from_bytes(source); + return destination.size(); +} + +inline size_t utf8ToWString(stringw &destination, const stringc &source) +{ + return utf8ToWString(destination, source.c_str()); +} + +inline size_t wStringToUTF8(stringc &destination, const wchar_t *source) +{ + std::wstring_convert> conv; + destination = conv.to_bytes(source); + return destination.size(); +} + +inline size_t wStringToUTF8(stringc &destination, const stringw &source) +{ + return wStringToUTF8(destination, source.c_str()); +} + +} // end namespace core +} // end namespace irr diff --git a/irr/include/irrTypes.h b/irr/include/irrTypes.h new file mode 100644 index 000000000..6c0ee661c --- /dev/null +++ b/irr/include/irrTypes.h @@ -0,0 +1,93 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include + +namespace irr +{ + +//! 8 bit unsigned variable. +typedef uint8_t u8; + +//! 8 bit signed variable. +typedef int8_t s8; + +//! 8 bit character variable. +/** This is a typedef for char, it ensures portability of the engine. */ +typedef char c8; + +//! 16 bit unsigned variable. +typedef uint16_t u16; + +//! 16 bit signed variable. +typedef int16_t s16; + +//! 32 bit unsigned variable. +typedef uint32_t u32; + +//! 32 bit signed variable. +typedef int32_t s32; + +//! 64 bit unsigned variable. +typedef uint64_t u64; + +//! 64 bit signed variable. +typedef int64_t s64; + +//! 32 bit floating point variable. +/** This is a typedef for float, it ensures portability of the engine. */ +typedef float f32; + +//! 64 bit floating point variable. +/** This is a typedef for double, it ensures portability of the engine. */ +typedef double f64; + +} // end namespace irr + +//! Defines for snprintf_irr because snprintf method does not match the ISO C +//! standard on Windows platforms. +//! We want int snprintf_irr(char *str, size_t size, const char *format, ...); +#if defined(_MSC_VER) +#define snprintf_irr sprintf_s +#else +#define snprintf_irr snprintf +#endif // _MSC_VER + +namespace irr +{ + +//! Type name for character type used by the file system (legacy). +typedef char fschar_t; +#define _IRR_TEXT(X) X + +} // end namespace irr + +//! define a break macro for debugging. +#if defined(_DEBUG) +#if defined(_IRR_WINDOWS_API_) && defined(_MSC_VER) +#include +#define _IRR_DEBUG_BREAK_IF(_CONDITION_) \ + if (_CONDITION_) { \ + _CrtDbgBreak(); \ + } +#else +#include +#define _IRR_DEBUG_BREAK_IF(_CONDITION_) assert(!(_CONDITION_)); +#endif +#else +#define _IRR_DEBUG_BREAK_IF(_CONDITION_) +#endif + +//! deprecated macro for virtual function override +/** prefer to use the override keyword for new code */ +#define _IRR_OVERRIDE_ override + +//! creates four CC codes used in Irrlicht for simple ids +/** some compilers can create those by directly writing the +code like 'code', but some generate warnings so we use this macro here */ +#define MAKE_IRR_ID(c0, c1, c2, c3) \ + ((irr::u32)(irr::u8)(c0) | ((irr::u32)(irr::u8)(c1) << 8) | \ + ((irr::u32)(irr::u8)(c2) << 16) | ((irr::u32)(irr::u8)(c3) << 24)) diff --git a/irr/include/irrlicht.h b/irr/include/irrlicht.h new file mode 100644 index 000000000..5b7042fc6 --- /dev/null +++ b/irr/include/irrlicht.h @@ -0,0 +1,318 @@ +/* irrlicht.h -- interface of the 'Irrlicht Engine' + + Copyright (C) 2002-2012 Nikolaus Gebhardt + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Please note that the Irrlicht Engine is based in part on the work of the + Independent JPEG Group, the zlib and the libPng. This means that if you use + the Irrlicht Engine in your product, you must acknowledge somewhere in your + documentation that you've used the IJG code. It would also be nice to mention + that you use the Irrlicht Engine, the zlib and libPng. See the README files + in the jpeglib, the zlib and libPng for further information. +*/ + +#pragma once + +#include "aabbox3d.h" +#include "CMeshBuffer.h" +#include "coreutil.h" +#include "dimension2d.h" +#include "ECullingTypes.h" +#include "EDebugSceneTypes.h" +#include "EDriverFeatures.h" +#include "EDriverTypes.h" +#include "EGUIAlignment.h" +#include "EGUIElementTypes.h" +#include "EHardwareBufferFlags.h" +#include "EMaterialProps.h" +#include "EMaterialTypes.h" +#include "ESceneNodeTypes.h" +#include "fast_atof.h" +#include "IAnimatedMesh.h" +#include "IAnimatedMeshSceneNode.h" +#include "IAttributes.h" +#include "IBillboardSceneNode.h" +#include "IBoneSceneNode.h" +#include "ICameraSceneNode.h" +#include "IContextManager.h" +#include "ICursorControl.h" +#include "IDummyTransformationSceneNode.h" +#include "IEventReceiver.h" +#include "IFileList.h" +#include "IFileSystem.h" +#include "IGPUProgrammingServices.h" +#include "IGUIButton.h" +#include "IGUICheckBox.h" +#include "IGUIComboBox.h" +#include "IGUIEditBox.h" +#include "IGUIElement.h" +#include "IGUIEnvironment.h" +#include "IGUIFileOpenDialog.h" +#include "IGUIFont.h" +#include "IGUIFontBitmap.h" +#include "IGUIImage.h" +#include "IGUIListBox.h" +#include "IGUIScrollBar.h" +#include "IGUISkin.h" +#include "IGUISpriteBank.h" +#include "IGUIStaticText.h" +#include "IGUITabControl.h" +#include "IGUIToolbar.h" +#include "IImage.h" +#include "IImageLoader.h" +#include "IImageWriter.h" +#include "IIndexBuffer.h" +#include "ILogger.h" +#include "IMaterialRenderer.h" +#include "IMaterialRendererServices.h" +#include "IMesh.h" +#include "IMeshBuffer.h" +#include "IMeshCache.h" +#include "IMeshLoader.h" +#include "IMeshManipulator.h" +#include "IMeshSceneNode.h" +#include "IOSOperator.h" +#include "IReadFile.h" +#include "IReferenceCounted.h" +#include "irrArray.h" +#include "IRenderTarget.h" +#include "IrrlichtDevice.h" +#include "irrMath.h" +#include "irrString.h" +#include "irrTypes.h" +#include "path.h" +#include "ISceneCollisionManager.h" +#include "ISceneManager.h" +#include "ISceneNode.h" +#include "IShaderConstantSetCallBack.h" +#include "ISkinnedMesh.h" +#include "ITexture.h" +#include "ITimer.h" +#include "IVertexBuffer.h" +#include "IVideoDriver.h" +#include "IWriteFile.h" +#include "Keycodes.h" +#include "line2d.h" +#include "line3d.h" +#include "matrix4.h" +#include "plane3d.h" +#include "position2d.h" +#include "quaternion.h" +#include "rect.h" +#include "S3DVertex.h" +#include "SAnimatedMesh.h" +#include "SceneParameters.h" +#include "SColor.h" +#include "SExposedVideoData.h" +#include "SIrrCreationParameters.h" +#include "SMaterial.h" +#include "SMesh.h" +#include "SMeshBuffer.h" +#include "SSkinMeshBuffer.h" +#include "SVertexIndex.h" +#include "SViewFrustum.h" +#include "vector2d.h" +#include "vector3d.h" +#include "IrrCompileConfig.h" // for IRRLICHT_API and IRRCALLCONV + +/*! \mainpage Irrlicht Engine 1.9 API documentation + * + *
+ * + * \section intro Introduction + * + * Welcome to the Irrlicht Engine API documentation. + * Here you'll find any information you'll need to develop applications with + * the Irrlicht Engine. If you are looking for a tutorial on how to start, you'll + * find some on the homepage of the Irrlicht Engine at + * irrlicht.sourceforge.net + * or inside the SDK in the examples directory. + * + * The Irrlicht Engine is intended to be an easy-to-use 3d engine, so + * this documentation is an important part of it. If you have any questions or + * suggestions, just send a email to the author of the engine, Nikolaus Gebhardt + * (niko (at) irrlicht3d.org). + * + * + * \section links Links + * + * Namespaces: A very good place to start reading + * the documentation.
+ * Class list: List of all classes with descriptions.
+ * Class members: Good place to find forgotten features.
+ * + * \section irrexample Short example + * + * A simple application, starting up the engine, loading a Quake 2 animated + * model file and the corresponding texture, animating and displaying it + * in front of a blue background and placing a user controlable 3d camera + * would look like the following code. I think this example shows the usage + * of the engine quite well: + * + * \code + * #include + * using namespace irr; + * + * int main() + * { + * // start up the engine + * IrrlichtDevice *device = createDevice(video::EDT_OPENGL, + * core::dimension2d(640,480)); + * + * video::IVideoDriver* driver = device->getVideoDriver(); + * scene::ISceneManager* scenemgr = device->getSceneManager(); + * + * device->setWindowCaption(L"Hello World!"); + * + * // load and show quake2 .md2 model + * scene::ISceneNode* node = scenemgr->addAnimatedMeshSceneNode( + * scenemgr->getMesh("quake2model.md2")); + * + * // if everything worked, add a texture and disable lighting + * if (node) + * { + * node->setMaterialTexture(0, driver->getTexture("texture.bmp")); + * node->setMaterialFlag(video::EMF_LIGHTING, false); + * } + * + * // add a first person shooter style user controlled camera + * scenemgr->addCameraSceneNodeFPS(); + * + * // draw everything + * while(device->run() && driver) + * { + * driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255,0,0,255)); + * scenemgr->drawAll(); + * driver->endScene(); + * } + * + * // delete device + * device->drop(); + * return 0; + * } + * \endcode + * + * Irrlicht can load a lot of file formats automatically, see irr::scene::ISceneManager::getMesh() + * for a detailed list. So if you would like to replace the simple blue screen background by + * a cool Quake 3 Map, optimized by an octree, just insert this code + * somewhere before the while loop: + * + * \code + * // add .pk3 archive to the file system + * device->getFileSystem()->addZipFileArchive("quake3map.pk3"); + * + * // load .bsp file and show it using an octree + * scenemgr->addOctreeSceneNode( + * scenemgr->getMesh("quake3map.bsp")); + * \endcode + * + * As you can see, the engine uses namespaces. Everything in the engine is + * placed into the namespace 'irr', but there are also 5 sub namespaces. + * You can find a list of all namespaces with descriptions at the + * namespaces page. + * This is also a good place to start reading the documentation. If you + * don't want to write the namespace names all the time, just use all namespaces like + * this: + * \code + * using namespace core; + * using namespace scene; + * using namespace video; + * using namespace io; + * using namespace gui; + * \endcode + * + * There is a lot more the engine can do, but I hope this gave a short + * overview over the basic features of the engine. For more examples, please take + * a look into the examples directory of the SDK. + */ + +#include "SIrrCreationParameters.h" + +//! Everything in the Irrlicht Engine can be found in this namespace. +namespace irr +{ +//! Creates an Irrlicht device. The Irrlicht device is the root object for using the engine. +/** If you need more parameters to be passed to the creation of the Irrlicht Engine device, +use the createDeviceEx() function. +\param driverType: Type of the video driver to use. +\param windowSize: Size of the window or the video mode in fullscreen mode. +\param bits: Bits per pixel in fullscreen mode. Ignored if windowed mode. +\param fullscreen: Should be set to true if the device should run in fullscreen. Otherwise + the device runs in windowed mode. +\param stencilbuffer: Specifies if the stencil buffer should be enabled. Set this to true, +if you want the engine be able to draw stencil buffer shadows. Note that not all +devices are able to use the stencil buffer. If they don't no shadows will be drawn. +\param vsync: Specifies vertical synchronization: If set to true, the driver will wait +for the vertical retrace period, otherwise not. +\param receiver: A user created event receiver. +\return Returns pointer to the created IrrlichtDevice or null if the +device could not be created. +*/ +extern "C" IRRLICHT_API IrrlichtDevice *IRRCALLCONV createDevice( + video::E_DRIVER_TYPE driverType = video::EDT_OPENGL, + // parentheses are necessary for some compilers + const core::dimension2d &windowSize = (core::dimension2d(640, 480)), + u32 bits = 32, + bool fullscreen = false, + bool stencilbuffer = true, + bool vsync = false, + IEventReceiver *receiver = 0); + +//! Creates an Irrlicht device with the option to specify advanced parameters. +/** Usually you should used createDevice() for creating an Irrlicht Engine device. +Use this function only if you wish to specify advanced parameters like a window +handle in which the device should be created. +\param parameters: Structure containing advanced parameters for the creation of the device. +See irr::SIrrlichtCreationParameters for details. +\return Returns pointer to the created IrrlichtDevice or null if the +device could not be created. */ +extern "C" IRRLICHT_API IrrlichtDevice *IRRCALLCONV createDeviceEx( + const SIrrlichtCreationParameters ¶meters); + +// THE FOLLOWING IS AN EMPTY LIST OF ALL SUB NAMESPACES +// EXISTING ONLY FOR THE DOCUMENTATION SOFTWARE DOXYGEN. + +//! Basic classes such as vectors, planes, arrays, lists, and so on can be found in this namespace. +namespace core +{ +} + +//! The gui namespace contains useful classes for easy creation of a graphical user interface. +namespace gui +{ +} + +//! This namespace provides interfaces for input/output: Reading and writing files, accessing zip archives, ... +namespace io +{ +} + +//! All scene management can be found in this namespace: Mesh loading, special scene nodes like octrees and billboards, ... +namespace scene +{ +} + +//! The video namespace contains classes for accessing the video driver. All 2d and 3d rendering is done here. +namespace video +{ +} +} + +/*! \file irrlicht.h + \brief Main header file of the irrlicht, the only file needed to include. +*/ diff --git a/irr/include/irrpack.h b/irr/include/irrpack.h new file mode 100644 index 000000000..5887cda63 --- /dev/null +++ b/irr/include/irrpack.h @@ -0,0 +1,25 @@ +// Copyright (C) 2007-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +// include this file right before the data structures to be 1-aligned +// and add to each structure the PACK_STRUCT define just like this: +// struct mystruct +// { +// ... +// } PACK_STRUCT; +// Always include the irrunpack.h file right after the last type declared +// like this, and do not put any other types with different alignment +// in between! + +// byte-align structures +#if defined(_MSC_VER) +#pragma warning(disable : 4103) +#pragma pack(push, packing) +#pragma pack(1) +#define PACK_STRUCT +#elif defined(__GNUC__) +#define PACK_STRUCT __attribute__((packed)) +#else +#error compiler not supported +#endif diff --git a/irr/include/irrunpack.h b/irr/include/irrunpack.h new file mode 100644 index 000000000..999e1ea05 --- /dev/null +++ b/irr/include/irrunpack.h @@ -0,0 +1,13 @@ +// Copyright (C) 2007-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +// include this file to switch back to default alignment +// file belongs to irrpack.h, see there for more info + +// Default alignment +#if defined(_MSC_VER) +#pragma pack(pop, packing) +#endif + +#undef PACK_STRUCT diff --git a/irr/include/line2d.h b/irr/include/line2d.h new file mode 100644 index 000000000..fb58f0b7a --- /dev/null +++ b/irr/include/line2d.h @@ -0,0 +1,380 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" +#include "vector2d.h" + +namespace irr +{ +namespace core +{ + +//! 2D line between two points with intersection methods. +template +class line2d +{ +public: + //! Default constructor for line going from (0,0) to (1,1). + constexpr line2d() : + start(0, 0), end(1, 1) {} + //! Constructor for line between the two points. + constexpr line2d(T xa, T ya, T xb, T yb) : + start(xa, ya), end(xb, yb) {} + //! Constructor for line between the two points given as vectors. + constexpr line2d(const vector2d &start, const vector2d &end) : + start(start), end(end) {} + + // operators + + line2d operator+(const vector2d &point) const { return line2d(start + point, end + point); } + line2d &operator+=(const vector2d &point) + { + start += point; + end += point; + return *this; + } + + line2d operator-(const vector2d &point) const { return line2d(start - point, end - point); } + line2d &operator-=(const vector2d &point) + { + start -= point; + end -= point; + return *this; + } + + constexpr bool operator==(const line2d &other) const + { + return (start == other.start && end == other.end) || (end == other.start && start == other.end); + } + constexpr bool operator!=(const line2d &other) const + { + return !(start == other.start && end == other.end) || (end == other.start && start == other.end); + } + + // functions + //! Set this line to new line going through the two points. + void setLine(const T &xa, const T &ya, const T &xb, const T &yb) + { + start.set(xa, ya); + end.set(xb, yb); + } + //! Set this line to new line going through the two points. + void setLine(const vector2d &nstart, const vector2d &nend) + { + start.set(nstart); + end.set(nend); + } + //! Set this line to new line given as parameter. + void setLine(const line2d &line) + { + start.set(line.start); + end.set(line.end); + } + + //! Get length of line + /** \return Length of the line. */ + T getLength() const { return start.getDistanceFrom(end); } + + //! Get squared length of the line + /** \return Squared length of line. */ + T getLengthSQ() const { return start.getDistanceFromSQ(end); } + + //! Get middle of the line + /** \return center of the line. */ + vector2d getMiddle() const + { + return (start + end) / (T)2; + } + + //! Get the vector of the line. + /** \return The vector of the line. */ + vector2d getVector() const { return vector2d(end.X - start.X, end.Y - start.Y); } + + /*! Check if this segment intersects another segment, + or if segments are coincident (colinear). */ + bool intersectAsSegments(const line2d &other) const + { + // Taken from: + // http://www.geeksforgeeks.org/check-if-two-given-line-segments-intersect/ + + // Find the four orientations needed for general and + // special cases + s32 o1 = start.checkOrientation(end, other.start); + s32 o2 = start.checkOrientation(end, other.end); + s32 o3 = other.start.checkOrientation(other.end, start); + s32 o4 = other.start.checkOrientation(other.end, end); + + // General case + if (o1 != o2 && o3 != o4) + return true; + + // Special Cases to check if segments are colinear + if (o1 == 0 && other.start.isBetweenPoints(start, end)) + return true; + if (o2 == 0 && other.end.isBetweenPoints(start, end)) + return true; + if (o3 == 0 && start.isBetweenPoints(other.start, other.end)) + return true; + if (o4 == 0 && end.isBetweenPoints(other.start, other.end)) + return true; + + return false; // Doesn't fall in any of the above cases + } + + /*! Check if 2 segments are incident (intersects in exactly 1 point).*/ + bool incidentSegments(const line2d &other) const + { + return start.checkOrientation(end, other.start) != start.checkOrientation(end, other.end) && other.start.checkOrientation(other.end, start) != other.start.checkOrientation(other.end, end); + } + + /*! Check if 2 lines/segments are parallel or nearly parallel.*/ + bool nearlyParallel(const line2d &line, const T factor = relativeErrorFactor()) const + { + const vector2d a = getVector(); + const vector2d b = line.getVector(); + + return a.nearlyParallel(b, factor); + } + + /*! returns a intersection point of 2 lines (if lines are not parallel). Behaviour + undefined if lines are parallel or coincident. + It's on optimized intersectWith with checkOnlySegments=false and ignoreCoincidentLines=true + */ + vector2d fastLinesIntersection(const line2d &l) const + { + const f32 commonDenominator = (f32)((l.end.Y - l.start.Y) * (end.X - start.X) - + (l.end.X - l.start.X) * (end.Y - start.Y)); + + if (commonDenominator != 0.f) { + const f32 numeratorA = (f32)((l.end.X - l.start.X) * (start.Y - l.start.Y) - + (l.end.Y - l.start.Y) * (start.X - l.start.X)); + + const f32 uA = numeratorA / commonDenominator; + + // Calculate the intersection point. + return vector2d( + (T)(start.X + uA * (end.X - start.X)), + (T)(start.Y + uA * (end.Y - start.Y))); + } else + return l.start; + } + + /*! Check if this line intersect a segment. The eventual intersection point is returned in "out".*/ + bool lineIntersectSegment(const line2d &segment, vector2d &out) const + { + if (nearlyParallel(segment)) + return false; + + out = fastLinesIntersection(segment); + + return out.isBetweenPoints(segment.start, segment.end); + } + + //! Tests if this line intersects with another line. + /** \param l: Other line to test intersection with. + \param checkOnlySegments: Default is to check intersection between the begin and endpoints. + When set to false the function will check for the first intersection point when extending the lines. + \param out: If there is an intersection, the location of the + intersection will be stored in this vector. + \param ignoreCoincidentLines: When true coincident lines (lines above each other) are never considered as intersecting. + When false the center of the overlapping part is returned. + \return True if there is an intersection, false if not. */ + bool intersectWith(const line2d &l, vector2d &out, bool checkOnlySegments = true, bool ignoreCoincidentLines = false) const + { + // Uses the method given at: + // http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/ + const f32 commonDenominator = (f32)((l.end.Y - l.start.Y) * (end.X - start.X) - + (l.end.X - l.start.X) * (end.Y - start.Y)); + + const f32 numeratorA = (f32)((l.end.X - l.start.X) * (start.Y - l.start.Y) - + (l.end.Y - l.start.Y) * (start.X - l.start.X)); + + const f32 numeratorB = (f32)((end.X - start.X) * (start.Y - l.start.Y) - + (end.Y - start.Y) * (start.X - l.start.X)); + + if (equals(commonDenominator, 0.f)) { + // The lines are either coincident or parallel + // if both numerators are 0, the lines are coincident + if (!ignoreCoincidentLines && equals(numeratorA, 0.f) && equals(numeratorB, 0.f)) { + // Try and find a common endpoint + if (l.start == start || l.end == start) + out = start; + else if (l.end == end || l.start == end) + out = end; + // now check if the two segments are disjunct + else if (l.start.X > start.X && l.end.X > start.X && l.start.X > end.X && l.end.X > end.X) + return false; + else if (l.start.Y > start.Y && l.end.Y > start.Y && l.start.Y > end.Y && l.end.Y > end.Y) + return false; + else if (l.start.X < start.X && l.end.X < start.X && l.start.X < end.X && l.end.X < end.X) + return false; + else if (l.start.Y < start.Y && l.end.Y < start.Y && l.start.Y < end.Y && l.end.Y < end.Y) + return false; + // else the lines are overlapping to some extent + else { + // find the points which are not contributing to the + // common part + vector2d maxp; + vector2d minp; + if ((start.X > l.start.X && start.X > l.end.X && start.X > end.X) || (start.Y > l.start.Y && start.Y > l.end.Y && start.Y > end.Y)) + maxp = start; + else if ((end.X > l.start.X && end.X > l.end.X && end.X > start.X) || (end.Y > l.start.Y && end.Y > l.end.Y && end.Y > start.Y)) + maxp = end; + else if ((l.start.X > start.X && l.start.X > l.end.X && l.start.X > end.X) || (l.start.Y > start.Y && l.start.Y > l.end.Y && l.start.Y > end.Y)) + maxp = l.start; + else + maxp = l.end; + if (maxp != start && ((start.X < l.start.X && start.X < l.end.X && start.X < end.X) || (start.Y < l.start.Y && start.Y < l.end.Y && start.Y < end.Y))) + minp = start; + else if (maxp != end && ((end.X < l.start.X && end.X < l.end.X && end.X < start.X) || (end.Y < l.start.Y && end.Y < l.end.Y && end.Y < start.Y))) + minp = end; + else if (maxp != l.start && ((l.start.X < start.X && l.start.X < l.end.X && l.start.X < end.X) || (l.start.Y < start.Y && l.start.Y < l.end.Y && l.start.Y < end.Y))) + minp = l.start; + else + minp = l.end; + + // one line is contained in the other. Pick the center + // of the remaining points, which overlap for sure + out = core::vector2d(); + if (start != maxp && start != minp) + out += start; + if (end != maxp && end != minp) + out += end; + if (l.start != maxp && l.start != minp) + out += l.start; + if (l.end != maxp && l.end != minp) + out += l.end; + out.X = (T)(out.X / 2); + out.Y = (T)(out.Y / 2); + } + + return true; // coincident + } + + return false; // parallel + } + + // Get the point of intersection on this line, checking that + // it is within the line segment. + const f32 uA = numeratorA / commonDenominator; + if (checkOnlySegments) { + if (uA < 0.f || uA > 1.f) + return false; // Outside the line segment + + const f32 uB = numeratorB / commonDenominator; + if (uB < 0.f || uB > 1.f) + return false; // Outside the line segment + } + + // Calculate the intersection point. + out.X = (T)(start.X + uA * (end.X - start.X)); + out.Y = (T)(start.Y + uA * (end.Y - start.Y)); + return true; + } + + //! Get unit vector of the line. + /** \return Unit vector of this line. */ + vector2d getUnitVector() const + { + T len = (T)(1.0 / getLength()); + return vector2d((end.X - start.X) * len, (end.Y - start.Y) * len); + } + + //! Get angle between this line and given line. + /** \param l Other line for test. + \return Angle in degrees. */ + f64 getAngleWith(const line2d &l) const + { + vector2d vect = getVector(); + vector2d vect2 = l.getVector(); + return vect.getAngleWith(vect2); + } + + //! Tells us if the given point lies to the left, right, or on the line. + /** \return 0 if the point is on the line + <0 if to the left, or >0 if to the right. */ + T getPointOrientation(const vector2d &point) const + { + return ((end.X - start.X) * (point.Y - start.Y) - + (point.X - start.X) * (end.Y - start.Y)); + } + + //! Check if the given point is a member of the line + /** \return True if point is between start and end, else false. */ + bool isPointOnLine(const vector2d &point) const + { + T d = getPointOrientation(point); + return (d == 0 && point.isBetweenPoints(start, end)); + } + + //! Check if the given point is between start and end of the line. + /** Assumes that the point is already somewhere on the line. */ + bool isPointBetweenStartAndEnd(const vector2d &point) const + { + return point.isBetweenPoints(start, end); + } + + //! Get the closest point on this line to a point + /** \param point: Starting search at this point + \param checkOnlySegments: Default (true) is to return a point on the line-segment (between begin and end) of the line. + When set to false the function will check for the first the closest point on the the line even when outside the segment. */ + vector2d getClosestPoint(const vector2d &point, bool checkOnlySegments = true) const + { + vector2d c((f64)(point.X - start.X), (f64)(point.Y - start.Y)); + vector2d v((f64)(end.X - start.X), (f64)(end.Y - start.Y)); + f64 d = v.getLength(); + if (d == 0) // can't tell much when the line is just a single point + return start; + v /= d; + f64 t = v.dotProduct(c); + + if (checkOnlySegments) { + if (t < 0) + return vector2d((T)start.X, (T)start.Y); + if (t > d) + return vector2d((T)end.X, (T)end.Y); + } + + v *= t; + return vector2d((T)(start.X + v.X), (T)(start.Y + v.Y)); + } + + //! Start point of the line. + vector2d start; + //! End point of the line. + vector2d end; +}; + +// partial specialization to optimize lines (avoiding casts) +template <> +inline vector2df line2d::getClosestPoint(const vector2df &point, bool checkOnlySegments) const +{ + const vector2df c = point - start; + vector2df v = end - start; + const f32 d = (f32)v.getLength(); + if (d == 0) // can't tell much when the line is just a single point + return start; + v /= d; + const f32 t = v.dotProduct(c); + + if (checkOnlySegments) { + if (t < 0) + return start; + if (t > d) + return end; + } + + v *= t; + return start + v; +} + +//! Typedef for an f32 line. +typedef line2d line2df; +//! Typedef for an integer line. +typedef line2d line2di; + +} // end namespace core +} // end namespace irr diff --git a/irr/include/line3d.h b/irr/include/line3d.h new file mode 100644 index 000000000..ea198fba4 --- /dev/null +++ b/irr/include/line3d.h @@ -0,0 +1,165 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" +#include "vector3d.h" + +namespace irr +{ +namespace core +{ + +//! 3D line between two points with intersection methods. +template +class line3d +{ +public: + //! Default constructor + /** line from (0,0,0) to (1,1,1) */ + constexpr line3d() : + start(0, 0, 0), end(1, 1, 1) {} + //! Constructor with two points + constexpr line3d(T xa, T ya, T za, T xb, T yb, T zb) : + start(xa, ya, za), end(xb, yb, zb) {} + //! Constructor with two points as vectors + constexpr line3d(const vector3d &start, const vector3d &end) : + start(start), end(end) {} + + // operators + + line3d operator+(const vector3d &point) const { return line3d(start + point, end + point); } + line3d &operator+=(const vector3d &point) + { + start += point; + end += point; + return *this; + } + + line3d operator-(const vector3d &point) const { return line3d(start - point, end - point); } + line3d &operator-=(const vector3d &point) + { + start -= point; + end -= point; + return *this; + } + + constexpr bool operator==(const line3d &other) const + { + return (start == other.start && end == other.end) || (end == other.start && start == other.end); + } + constexpr bool operator!=(const line3d &other) const + { + return !(start == other.start && end == other.end) || (end == other.start && start == other.end); + } + + // functions + //! Set this line to a new line going through the two points. + void setLine(const T &xa, const T &ya, const T &za, const T &xb, const T &yb, const T &zb) + { + start.set(xa, ya, za); + end.set(xb, yb, zb); + } + //! Set this line to a new line going through the two points. + void setLine(const vector3d &nstart, const vector3d &nend) + { + start.set(nstart); + end.set(nend); + } + //! Set this line to new line given as parameter. + void setLine(const line3d &line) + { + start.set(line.start); + end.set(line.end); + } + + //! Get length of line + /** \return Length of line. */ + T getLength() const { return start.getDistanceFrom(end); } + + //! Get squared length of line + /** \return Squared length of line. */ + T getLengthSQ() const { return start.getDistanceFromSQ(end); } + + //! Get middle of line + /** \return Center of line. */ + vector3d getMiddle() const + { + return (start + end) / (T)2; + } + + //! Get vector of line + /** \return vector of line. */ + vector3d getVector() const + { + return end - start; + } + + //! Check if the given point is between start and end of the line. + /** Assumes that the point is already somewhere on the line. + \param point The point to test. + \return True if point is on the line between start and end, else false. + */ + bool isPointBetweenStartAndEnd(const vector3d &point) const + { + return point.isBetweenPoints(start, end); + } + + //! Get the closest point on this line to a point + /** \param point The point to compare to. + \return The nearest point which is part of the line. */ + vector3d getClosestPoint(const vector3d &point) const + { + vector3d c = point - start; + vector3d v = end - start; + T d = (T)v.getLength(); + v /= d; + T t = v.dotProduct(c); + + if (t < (T)0.0) + return start; + if (t > d) + return end; + + v *= t; + return start + v; + } + + //! Check if the line intersects with a sphere + /** \param sorigin: Origin of the sphere. + \param sradius: Radius of the sphere. + \param outdistance: The distance to the first intersection point. + \return True if there is an intersection. + If there is one, the distance to the first intersection point + is stored in outdistance. */ + bool getIntersectionWithSphere(const vector3d &sorigin, T sradius, f64 &outdistance) const + { + const vector3d q = sorigin - start; + T c = q.getLength(); + T v = q.dotProduct(getVector().normalize()); + T d = sradius * sradius - (c * c - v * v); + + if (d < 0.0) + return false; + + outdistance = v - core::squareroot(d); + return true; + } + + // member variables + + //! Start point of line + vector3d start; + //! End point of line + vector3d end; +}; + +//! Typedef for an f32 line. +typedef line3d line3df; +//! Typedef for an integer line. +typedef line3d line3di; + +} // end namespace core +} // end namespace irr diff --git a/irr/include/matrix4.h b/irr/include/matrix4.h new file mode 100644 index 000000000..374fc6e4a --- /dev/null +++ b/irr/include/matrix4.h @@ -0,0 +1,2282 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include // memset, memcpy +#include "irrMath.h" +#include "vector3d.h" +#include "vector2d.h" +#include "plane3d.h" +#include "aabbox3d.h" +#include "rect.h" +#include "IrrCompileConfig.h" // for IRRLICHT_API + +// enable this to keep track of changes to the matrix +// and make simpler identity check for seldom changing matrices +// otherwise identity check will always compare the elements +// #define USE_MATRIX_TEST + +namespace irr +{ +namespace core +{ + +//! 4x4 matrix. Mostly used as transformation matrix for 3d calculations. +/** The matrix is a D3D style matrix, row major with translations in the 4th row. */ +template +class CMatrix4 +{ +public: + //! Constructor Flags + enum eConstructor + { + EM4CONST_NOTHING = 0, + EM4CONST_COPY, + EM4CONST_IDENTITY, + EM4CONST_TRANSPOSED, + EM4CONST_INVERSE, + EM4CONST_INVERSE_TRANSPOSED + }; + + //! Default constructor + /** \param constructor Choose the initialization style */ + CMatrix4(eConstructor constructor = EM4CONST_IDENTITY); + + //! Constructor with value initialization + constexpr CMatrix4(const T &r0c0, const T &r0c1, const T &r0c2, const T &r0c3, + const T &r1c0, const T &r1c1, const T &r1c2, const T &r1c3, + const T &r2c0, const T &r2c1, const T &r2c2, const T &r2c3, + const T &r3c0, const T &r3c1, const T &r3c2, const T &r3c3) + { + M[0] = r0c0; + M[1] = r0c1; + M[2] = r0c2; + M[3] = r0c3; + M[4] = r1c0; + M[5] = r1c1; + M[6] = r1c2; + M[7] = r1c3; + M[8] = r2c0; + M[9] = r2c1; + M[10] = r2c2; + M[11] = r2c3; + M[12] = r3c0; + M[13] = r3c1; + M[14] = r3c2; + M[15] = r3c3; + } + + //! Copy constructor + /** \param other Other matrix to copy from + \param constructor Choose the initialization style */ + CMatrix4(const CMatrix4 &other, eConstructor constructor = EM4CONST_COPY); + + //! Simple operator for directly accessing every element of the matrix. + T &operator()(const s32 row, const s32 col) + { +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return M[row * 4 + col]; + } + + //! Simple operator for directly accessing every element of the matrix. + const T &operator()(const s32 row, const s32 col) const { return M[row * 4 + col]; } + + //! Simple operator for linearly accessing every element of the matrix. + T &operator[](u32 index) + { +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return M[index]; + } + + //! Simple operator for linearly accessing every element of the matrix. + const T &operator[](u32 index) const { return M[index]; } + + //! Sets this matrix equal to the other matrix. + CMatrix4 &operator=(const CMatrix4 &other) = default; + + //! Sets all elements of this matrix to the value. + inline CMatrix4 &operator=(const T &scalar); + + //! Returns pointer to internal array + const T *pointer() const { return M; } + T *pointer() + { +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return M; + } + + //! Returns true if other matrix is equal to this matrix. + constexpr bool operator==(const CMatrix4 &other) const + { +#if defined(USE_MATRIX_TEST) + if (definitelyIdentityMatrix && other.definitelyIdentityMatrix) + return true; +#endif + for (s32 i = 0; i < 16; ++i) + if (M[i] != other.M[i]) + return false; + + return true; + } + + //! Returns true if other matrix is not equal to this matrix. + constexpr bool operator!=(const CMatrix4 &other) const + { + return !(*this == other); + } + + //! Add another matrix. + CMatrix4 operator+(const CMatrix4 &other) const; + + //! Add another matrix. + CMatrix4 &operator+=(const CMatrix4 &other); + + //! Subtract another matrix. + CMatrix4 operator-(const CMatrix4 &other) const; + + //! Subtract another matrix. + CMatrix4 &operator-=(const CMatrix4 &other); + + //! set this matrix to the product of two matrices + /** Calculate b*a */ + inline CMatrix4 &setbyproduct(const CMatrix4 &other_a, const CMatrix4 &other_b); + + //! Set this matrix to the product of two matrices + /** Calculate b*a, no optimization used, + use it if you know you never have an identity matrix */ + CMatrix4 &setbyproduct_nocheck(const CMatrix4 &other_a, const CMatrix4 &other_b); + + //! Multiply by another matrix. + /** Calculate other*this */ + CMatrix4 operator*(const CMatrix4 &other) const; + + //! Multiply by another matrix. + /** Like calling: (*this) = (*this) * other + */ + CMatrix4 &operator*=(const CMatrix4 &other); + + //! Multiply by scalar. + CMatrix4 operator*(const T &scalar) const; + + //! Multiply by scalar. + CMatrix4 &operator*=(const T &scalar); + + //! Set matrix to identity. + inline CMatrix4 &makeIdentity(); + + //! Returns true if the matrix is the identity matrix + inline bool isIdentity() const; + + //! Returns true if the matrix is orthogonal + inline bool isOrthogonal() const; + + //! Returns true if the matrix is the identity matrix + bool isIdentity_integer_base() const; + + //! Set the translation of the current matrix. Will erase any previous values. + CMatrix4 &setTranslation(const vector3d &translation); + + //! Gets the current translation + vector3d getTranslation() const; + + //! Set the inverse translation of the current matrix. Will erase any previous values. + CMatrix4 &setInverseTranslation(const vector3d &translation); + + //! Make a rotation matrix from Euler angles. The 4th row and column are unmodified. + inline CMatrix4 &setRotationRadians(const vector3d &rotation); + + //! Make a rotation matrix from Euler angles. The 4th row and column are unmodified. + CMatrix4 &setRotationDegrees(const vector3d &rotation); + + //! Get the rotation, as set by setRotation() when you already know the scale used to create the matrix + /** NOTE: The scale needs to be the correct one used to create this matrix. + You can _not_ use the result of getScale(), but have to save your scale + variable in another place (like ISceneNode does). + NOTE: No scale value can be 0 or the result is undefined. + NOTE: It does not necessarily return the *same* Euler angles as those set by setRotationDegrees(), + but the rotation will be equivalent, i.e. will have the same result when used to rotate a vector or node. + NOTE: It will (usually) give wrong results when further transformations have been added in the matrix (like shear). + WARNING: There have been troubles with this function over the years and we may still have missed some corner cases. + It's generally safer to keep the rotation and scale you used to create the matrix around and work with those. + */ + core::vector3d getRotationDegrees(const vector3d &scale) const; + + //! Returns the rotation, as set by setRotation(). + /** NOTE: You will have the same end-rotation as used in setRotation, but it might not use the same axis values. + NOTE: This only works correct if no other matrix operations have been done on the inner 3x3 matrix besides + setting rotation (so no scale/shear). Thought it (probably) works as long as scale doesn't flip handedness. + NOTE: It does not necessarily return the *same* Euler angles as those set by setRotationDegrees(), + but the rotation will be equivalent, i.e. will have the same result when used to rotate a vector or node. + */ + core::vector3d getRotationDegrees() const; + + //! Make an inverted rotation matrix from Euler angles. + /** The 4th row and column are unmodified. */ + inline CMatrix4 &setInverseRotationRadians(const vector3d &rotation); + + //! Make an inverted rotation matrix from Euler angles. + /** The 4th row and column are unmodified. */ + inline CMatrix4 &setInverseRotationDegrees(const vector3d &rotation); + + //! Make a rotation matrix from angle and axis, assuming left handed rotation. + /** The 4th row and column are unmodified. */ + inline CMatrix4 &setRotationAxisRadians(const T &angle, const vector3d &axis); + + //! Set Scale + CMatrix4 &setScale(const vector3d &scale); + + //! Set Scale + CMatrix4 &setScale(const T scale) { return setScale(core::vector3d(scale, scale, scale)); } + + //! Get Scale + core::vector3d getScale() const; + + //! Translate a vector by the inverse of the translation part of this matrix. + void inverseTranslateVect(vector3df &vect) const; + + //! Rotate a vector by the inverse of the rotation part of this matrix. + void inverseRotateVect(vector3df &vect) const; + + //! Rotate a vector by the rotation part of this matrix. + void rotateVect(vector3df &vect) const; + + //! An alternate transform vector method, writing into a second vector + void rotateVect(core::vector3df &out, const core::vector3df &in) const; + + //! An alternate transform vector method, writing into an array of 3 floats + void rotateVect(T *out, const core::vector3df &in) const; + + //! Transforms the vector by this matrix + /** This operation is performed as if the vector was 4d with the 4th component =1 */ + void transformVect(vector3df &vect) const; + + //! Transforms input vector by this matrix and stores result in output vector + /** This operation is performed as if the vector was 4d with the 4th component =1 */ + void transformVect(vector3df &out, const vector3df &in) const; + + //! An alternate transform vector method, writing into an array of 4 floats + /** This operation is performed as if the vector was 4d with the 4th component =1. + NOTE: out[3] will be written to (4th vector component)*/ + void transformVect(T *out, const core::vector3df &in) const; + + //! An alternate transform vector method, reading from and writing to an array of 3 floats + /** This operation is performed as if the vector was 4d with the 4th component =1 + NOTE: out[3] will be written to (4th vector component)*/ + void transformVec3(T *out, const T *in) const; + + //! An alternate transform vector method, reading from and writing to an array of 4 floats + void transformVec4(T *out, const T *in) const; + + //! Translate a vector by the translation part of this matrix. + /** This operation is performed as if the vector was 4d with the 4th component =1 */ + void translateVect(vector3df &vect) const; + + //! Transforms a plane by this matrix + void transformPlane(core::plane3d &plane) const; + + //! Transforms a plane by this matrix + void transformPlane(const core::plane3d &in, core::plane3d &out) const; + + //! Transforms a axis aligned bounding box + void transformBoxEx(core::aabbox3d &box) const; + + //! Multiplies this matrix by a 1x4 matrix + void multiplyWith1x4Matrix(T *matrix) const; + + //! Calculates inverse of matrix. Slow. + /** \return Returns false if there is no inverse matrix.*/ + bool makeInverse(); + + //! Inverts a primitive matrix which only contains a translation and a rotation + /** \param out: where result matrix is written to. */ + bool getInversePrimitive(CMatrix4 &out) const; + + //! Gets the inverse matrix of this one + /** \param out: where result matrix is written to. + \return Returns false if there is no inverse matrix. */ + bool getInverse(CMatrix4 &out) const; + + //! Builds a right-handed perspective projection matrix based on a field of view + //\param zClipFromZero: Clipping of z can be projected from 0 to w when true (D3D style) and from -w to w when false (OGL style). + CMatrix4 &buildProjectionMatrixPerspectiveFovRH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero = true); + + //! Builds a left-handed perspective projection matrix based on a field of view + CMatrix4 &buildProjectionMatrixPerspectiveFovLH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero = true); + + //! Builds a left-handed perspective projection matrix based on a field of view, with far plane at infinity + CMatrix4 &buildProjectionMatrixPerspectiveFovInfinityLH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 epsilon = 0); + + //! Builds a right-handed perspective projection matrix. + CMatrix4 &buildProjectionMatrixPerspectiveRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero = true); + + //! Builds a left-handed perspective projection matrix. + CMatrix4 &buildProjectionMatrixPerspectiveLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero = true); + + //! Builds a left-handed orthogonal projection matrix. + //\param zClipFromZero: Clipping of z can be projected from 0 to 1 when true (D3D style) and from -1 to 1 when false (OGL style). + CMatrix4 &buildProjectionMatrixOrthoLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero = true); + + //! Builds a right-handed orthogonal projection matrix. + CMatrix4 &buildProjectionMatrixOrthoRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero = true); + + //! Builds a left-handed look-at matrix. + CMatrix4 &buildCameraLookAtMatrixLH( + const vector3df &position, + const vector3df &target, + const vector3df &upVector); + + //! Builds a right-handed look-at matrix. + CMatrix4 &buildCameraLookAtMatrixRH( + const vector3df &position, + const vector3df &target, + const vector3df &upVector); + + //! Builds a matrix that flattens geometry into a plane. + /** \param light: light source + \param plane: plane into which the geometry if flattened into + \param point: value between 0 and 1, describing the light source. + If this is 1, it is a point light, if it is 0, it is a directional light. */ + CMatrix4 &buildShadowMatrix(const core::vector3df &light, core::plane3df plane, f32 point = 1.0f); + + //! Builds a matrix which transforms a normalized Device Coordinate to Device Coordinates. + /** Used to scale <-1,-1><1,1> to viewport, for example from <-1,-1> <1,1> to the viewport <0,0><0,640> */ + CMatrix4 &buildNDCToDCMatrix(const core::rect &area, f32 zScale); + + //! Creates a new matrix as interpolated matrix from two other ones. + /** \param b: other matrix to interpolate with + \param time: Must be a value between 0 and 1. */ + CMatrix4 interpolate(const core::CMatrix4 &b, f32 time) const; + + //! Gets transposed matrix + CMatrix4 getTransposed() const; + + //! Gets transposed matrix + inline void getTransposed(CMatrix4 &dest) const; + + //! Builds a matrix that rotates from one vector to another + /** \param from: vector to rotate from + \param to: vector to rotate to + */ + CMatrix4 &buildRotateFromTo(const core::vector3df &from, const core::vector3df &to); + + //! Builds a combined matrix which translates to a center before rotation and translates from origin afterwards + /** \param center Position to rotate around + \param translate Translation applied after the rotation + */ + void setRotationCenter(const core::vector3df ¢er, const core::vector3df &translate); + + //! Builds a matrix which rotates a source vector to a look vector over an arbitrary axis + /** \param camPos: viewer position in world coo + \param center: object position in world-coo and rotation pivot + \param translation: object final translation from center + \param axis: axis to rotate about + \param from: source vector to rotate from + */ + void buildAxisAlignedBillboard(const core::vector3df &camPos, + const core::vector3df ¢er, + const core::vector3df &translation, + const core::vector3df &axis, + const core::vector3df &from); + + /* + construct 2D Texture transformations + rotate about center, scale, and transform. + */ + //! Set to a texture transformation matrix with the given parameters. + CMatrix4 &buildTextureTransform(f32 rotateRad, + const core::vector2df &rotatecenter, + const core::vector2df &translate, + const core::vector2df &scale); + + //! Set texture transformation rotation + /** Rotate about z axis, recenter at (0.5,0.5). + Doesn't clear other elements than those affected + \param radAngle Angle in radians + \return Altered matrix */ + CMatrix4 &setTextureRotationCenter(f32 radAngle); + + //! Set texture transformation translation + /** Doesn't clear other elements than those affected. + \param x Offset on x axis + \param y Offset on y axis + \return Altered matrix */ + CMatrix4 &setTextureTranslate(f32 x, f32 y); + + //! Get texture transformation translation + /** \param x returns offset on x axis + \param y returns offset on y axis */ + void getTextureTranslate(f32 &x, f32 &y) const; + + //! Set texture transformation translation, using a transposed representation + /** Doesn't clear other elements than those affected. + \param x Offset on x axis + \param y Offset on y axis + \return Altered matrix */ + CMatrix4 &setTextureTranslateTransposed(f32 x, f32 y); + + //! Set texture transformation scale + /** Doesn't clear other elements than those affected. + \param sx Scale factor on x axis + \param sy Scale factor on y axis + \return Altered matrix. */ + CMatrix4 &setTextureScale(f32 sx, f32 sy); + + //! Get texture transformation scale + /** \param sx Returns x axis scale factor + \param sy Returns y axis scale factor */ + void getTextureScale(f32 &sx, f32 &sy) const; + + //! Set texture transformation scale, and recenter at (0.5,0.5) + /** Doesn't clear other elements than those affected. + \param sx Scale factor on x axis + \param sy Scale factor on y axis + \return Altered matrix. */ + CMatrix4 &setTextureScaleCenter(f32 sx, f32 sy); + + //! Sets all matrix data members at once + CMatrix4 &setM(const T *data); + + //! Sets if the matrix is definitely identity matrix + void setDefinitelyIdentityMatrix(bool isDefinitelyIdentityMatrix); + + //! Gets if the matrix is definitely identity matrix + bool getDefinitelyIdentityMatrix() const; + + //! Compare two matrices using the equal method + bool equals(const core::CMatrix4 &other, const T tolerance = (T)ROUNDING_ERROR_f64) const; + +private: + //! Matrix data, stored in row-major order + T M[16]; +#if defined(USE_MATRIX_TEST) + //! Flag is this matrix is identity matrix + mutable u32 definitelyIdentityMatrix; +#endif +}; + +// Default constructor +template +inline CMatrix4::CMatrix4(eConstructor constructor) +#if defined(USE_MATRIX_TEST) + : + definitelyIdentityMatrix(BIT_UNTESTED) +#endif +{ + switch (constructor) { + case EM4CONST_NOTHING: + case EM4CONST_COPY: + break; + case EM4CONST_IDENTITY: + case EM4CONST_INVERSE: + default: + makeIdentity(); + break; + } +} + +// Copy constructor +template +inline CMatrix4::CMatrix4(const CMatrix4 &other, eConstructor constructor) +#if defined(USE_MATRIX_TEST) + : + definitelyIdentityMatrix(BIT_UNTESTED) +#endif +{ + switch (constructor) { + case EM4CONST_IDENTITY: + makeIdentity(); + break; + case EM4CONST_NOTHING: + break; + case EM4CONST_COPY: + *this = other; + break; + case EM4CONST_TRANSPOSED: + other.getTransposed(*this); + break; + case EM4CONST_INVERSE: + if (!other.getInverse(*this)) + memset(M, 0, 16 * sizeof(T)); + break; + case EM4CONST_INVERSE_TRANSPOSED: + if (!other.getInverse(*this)) + memset(M, 0, 16 * sizeof(T)); + else + *this = getTransposed(); + break; + } +} + +//! Add another matrix. +template +inline CMatrix4 CMatrix4::operator+(const CMatrix4 &other) const +{ + CMatrix4 temp(EM4CONST_NOTHING); + + temp[0] = M[0] + other[0]; + temp[1] = M[1] + other[1]; + temp[2] = M[2] + other[2]; + temp[3] = M[3] + other[3]; + temp[4] = M[4] + other[4]; + temp[5] = M[5] + other[5]; + temp[6] = M[6] + other[6]; + temp[7] = M[7] + other[7]; + temp[8] = M[8] + other[8]; + temp[9] = M[9] + other[9]; + temp[10] = M[10] + other[10]; + temp[11] = M[11] + other[11]; + temp[12] = M[12] + other[12]; + temp[13] = M[13] + other[13]; + temp[14] = M[14] + other[14]; + temp[15] = M[15] + other[15]; + + return temp; +} + +//! Add another matrix. +template +inline CMatrix4 &CMatrix4::operator+=(const CMatrix4 &other) +{ + M[0] += other[0]; + M[1] += other[1]; + M[2] += other[2]; + M[3] += other[3]; + M[4] += other[4]; + M[5] += other[5]; + M[6] += other[6]; + M[7] += other[7]; + M[8] += other[8]; + M[9] += other[9]; + M[10] += other[10]; + M[11] += other[11]; + M[12] += other[12]; + M[13] += other[13]; + M[14] += other[14]; + M[15] += other[15]; + + return *this; +} + +//! Subtract another matrix. +template +inline CMatrix4 CMatrix4::operator-(const CMatrix4 &other) const +{ + CMatrix4 temp(EM4CONST_NOTHING); + + temp[0] = M[0] - other[0]; + temp[1] = M[1] - other[1]; + temp[2] = M[2] - other[2]; + temp[3] = M[3] - other[3]; + temp[4] = M[4] - other[4]; + temp[5] = M[5] - other[5]; + temp[6] = M[6] - other[6]; + temp[7] = M[7] - other[7]; + temp[8] = M[8] - other[8]; + temp[9] = M[9] - other[9]; + temp[10] = M[10] - other[10]; + temp[11] = M[11] - other[11]; + temp[12] = M[12] - other[12]; + temp[13] = M[13] - other[13]; + temp[14] = M[14] - other[14]; + temp[15] = M[15] - other[15]; + + return temp; +} + +//! Subtract another matrix. +template +inline CMatrix4 &CMatrix4::operator-=(const CMatrix4 &other) +{ + M[0] -= other[0]; + M[1] -= other[1]; + M[2] -= other[2]; + M[3] -= other[3]; + M[4] -= other[4]; + M[5] -= other[5]; + M[6] -= other[6]; + M[7] -= other[7]; + M[8] -= other[8]; + M[9] -= other[9]; + M[10] -= other[10]; + M[11] -= other[11]; + M[12] -= other[12]; + M[13] -= other[13]; + M[14] -= other[14]; + M[15] -= other[15]; + + return *this; +} + +//! Multiply by scalar. +template +inline CMatrix4 CMatrix4::operator*(const T &scalar) const +{ + CMatrix4 temp(EM4CONST_NOTHING); + + temp[0] = M[0] * scalar; + temp[1] = M[1] * scalar; + temp[2] = M[2] * scalar; + temp[3] = M[3] * scalar; + temp[4] = M[4] * scalar; + temp[5] = M[5] * scalar; + temp[6] = M[6] * scalar; + temp[7] = M[7] * scalar; + temp[8] = M[8] * scalar; + temp[9] = M[9] * scalar; + temp[10] = M[10] * scalar; + temp[11] = M[11] * scalar; + temp[12] = M[12] * scalar; + temp[13] = M[13] * scalar; + temp[14] = M[14] * scalar; + temp[15] = M[15] * scalar; + + return temp; +} + +//! Multiply by scalar. +template +inline CMatrix4 &CMatrix4::operator*=(const T &scalar) +{ + M[0] *= scalar; + M[1] *= scalar; + M[2] *= scalar; + M[3] *= scalar; + M[4] *= scalar; + M[5] *= scalar; + M[6] *= scalar; + M[7] *= scalar; + M[8] *= scalar; + M[9] *= scalar; + M[10] *= scalar; + M[11] *= scalar; + M[12] *= scalar; + M[13] *= scalar; + M[14] *= scalar; + M[15] *= scalar; + + return *this; +} + +//! Multiply by another matrix. +template +inline CMatrix4 &CMatrix4::operator*=(const CMatrix4 &other) +{ +#if defined(USE_MATRIX_TEST) + // do checks on your own in order to avoid copy creation + if (!other.isIdentity()) { + if (this->isIdentity()) { + return (*this = other); + } else { + CMatrix4 temp(*this); + return setbyproduct_nocheck(temp, other); + } + } + return *this; +#else + CMatrix4 temp(*this); + return setbyproduct_nocheck(temp, other); +#endif +} + +//! multiply by another matrix +// set this matrix to the product of two other matrices +// goal is to reduce stack use and copy +template +inline CMatrix4 &CMatrix4::setbyproduct_nocheck(const CMatrix4 &other_a, const CMatrix4 &other_b) +{ + const T *m1 = other_a.M; + const T *m2 = other_b.M; + + M[0] = m1[0] * m2[0] + m1[4] * m2[1] + m1[8] * m2[2] + m1[12] * m2[3]; + M[1] = m1[1] * m2[0] + m1[5] * m2[1] + m1[9] * m2[2] + m1[13] * m2[3]; + M[2] = m1[2] * m2[0] + m1[6] * m2[1] + m1[10] * m2[2] + m1[14] * m2[3]; + M[3] = m1[3] * m2[0] + m1[7] * m2[1] + m1[11] * m2[2] + m1[15] * m2[3]; + + M[4] = m1[0] * m2[4] + m1[4] * m2[5] + m1[8] * m2[6] + m1[12] * m2[7]; + M[5] = m1[1] * m2[4] + m1[5] * m2[5] + m1[9] * m2[6] + m1[13] * m2[7]; + M[6] = m1[2] * m2[4] + m1[6] * m2[5] + m1[10] * m2[6] + m1[14] * m2[7]; + M[7] = m1[3] * m2[4] + m1[7] * m2[5] + m1[11] * m2[6] + m1[15] * m2[7]; + + M[8] = m1[0] * m2[8] + m1[4] * m2[9] + m1[8] * m2[10] + m1[12] * m2[11]; + M[9] = m1[1] * m2[8] + m1[5] * m2[9] + m1[9] * m2[10] + m1[13] * m2[11]; + M[10] = m1[2] * m2[8] + m1[6] * m2[9] + m1[10] * m2[10] + m1[14] * m2[11]; + M[11] = m1[3] * m2[8] + m1[7] * m2[9] + m1[11] * m2[10] + m1[15] * m2[11]; + + M[12] = m1[0] * m2[12] + m1[4] * m2[13] + m1[8] * m2[14] + m1[12] * m2[15]; + M[13] = m1[1] * m2[12] + m1[5] * m2[13] + m1[9] * m2[14] + m1[13] * m2[15]; + M[14] = m1[2] * m2[12] + m1[6] * m2[13] + m1[10] * m2[14] + m1[14] * m2[15]; + M[15] = m1[3] * m2[12] + m1[7] * m2[13] + m1[11] * m2[14] + m1[15] * m2[15]; +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return *this; +} + +//! multiply by another matrix +// set this matrix to the product of two other matrices +// goal is to reduce stack use and copy +template +inline CMatrix4 &CMatrix4::setbyproduct(const CMatrix4 &other_a, const CMatrix4 &other_b) +{ +#if defined(USE_MATRIX_TEST) + if (other_a.isIdentity()) + return (*this = other_b); + else if (other_b.isIdentity()) + return (*this = other_a); + else + return setbyproduct_nocheck(other_a, other_b); +#else + return setbyproduct_nocheck(other_a, other_b); +#endif +} + +//! multiply by another matrix +template +inline CMatrix4 CMatrix4::operator*(const CMatrix4 &m2) const +{ +#if defined(USE_MATRIX_TEST) + // Testing purpose.. + if (this->isIdentity()) + return m2; + if (m2.isIdentity()) + return *this; +#endif + + CMatrix4 m3(EM4CONST_NOTHING); + + const T *m1 = M; + + m3[0] = m1[0] * m2[0] + m1[4] * m2[1] + m1[8] * m2[2] + m1[12] * m2[3]; + m3[1] = m1[1] * m2[0] + m1[5] * m2[1] + m1[9] * m2[2] + m1[13] * m2[3]; + m3[2] = m1[2] * m2[0] + m1[6] * m2[1] + m1[10] * m2[2] + m1[14] * m2[3]; + m3[3] = m1[3] * m2[0] + m1[7] * m2[1] + m1[11] * m2[2] + m1[15] * m2[3]; + + m3[4] = m1[0] * m2[4] + m1[4] * m2[5] + m1[8] * m2[6] + m1[12] * m2[7]; + m3[5] = m1[1] * m2[4] + m1[5] * m2[5] + m1[9] * m2[6] + m1[13] * m2[7]; + m3[6] = m1[2] * m2[4] + m1[6] * m2[5] + m1[10] * m2[6] + m1[14] * m2[7]; + m3[7] = m1[3] * m2[4] + m1[7] * m2[5] + m1[11] * m2[6] + m1[15] * m2[7]; + + m3[8] = m1[0] * m2[8] + m1[4] * m2[9] + m1[8] * m2[10] + m1[12] * m2[11]; + m3[9] = m1[1] * m2[8] + m1[5] * m2[9] + m1[9] * m2[10] + m1[13] * m2[11]; + m3[10] = m1[2] * m2[8] + m1[6] * m2[9] + m1[10] * m2[10] + m1[14] * m2[11]; + m3[11] = m1[3] * m2[8] + m1[7] * m2[9] + m1[11] * m2[10] + m1[15] * m2[11]; + + m3[12] = m1[0] * m2[12] + m1[4] * m2[13] + m1[8] * m2[14] + m1[12] * m2[15]; + m3[13] = m1[1] * m2[12] + m1[5] * m2[13] + m1[9] * m2[14] + m1[13] * m2[15]; + m3[14] = m1[2] * m2[12] + m1[6] * m2[13] + m1[10] * m2[14] + m1[14] * m2[15]; + m3[15] = m1[3] * m2[12] + m1[7] * m2[13] + m1[11] * m2[14] + m1[15] * m2[15]; + return m3; +} + +template +inline vector3d CMatrix4::getTranslation() const +{ + return vector3d(M[12], M[13], M[14]); +} + +template +inline CMatrix4 &CMatrix4::setTranslation(const vector3d &translation) +{ + M[12] = translation.X; + M[13] = translation.Y; + M[14] = translation.Z; +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return *this; +} + +template +inline CMatrix4 &CMatrix4::setInverseTranslation(const vector3d &translation) +{ + M[12] = -translation.X; + M[13] = -translation.Y; + M[14] = -translation.Z; +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return *this; +} + +template +inline CMatrix4 &CMatrix4::setScale(const vector3d &scale) +{ + M[0] = scale.X; + M[5] = scale.Y; + M[10] = scale.Z; +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return *this; +} + +//! Returns the absolute values of the scales of the matrix. +/** +Note: You only get back original values if the matrix only set the scale. +Otherwise the result is a scale you can use to normalize the matrix axes, +but it's usually no longer what you did set with setScale. +*/ +template +inline vector3d CMatrix4::getScale() const +{ + // See http://www.robertblum.com/articles/2005/02/14/decomposing-matrices + + // Deal with the 0 rotation case first + // Prior to Irrlicht 1.6, we always returned this value. + if (core::iszero(M[1]) && core::iszero(M[2]) && + core::iszero(M[4]) && core::iszero(M[6]) && + core::iszero(M[8]) && core::iszero(M[9])) + return vector3d(M[0], M[5], M[10]); + + // We have to do the full calculation. + return vector3d(sqrtf(M[0] * M[0] + M[1] * M[1] + M[2] * M[2]), + sqrtf(M[4] * M[4] + M[5] * M[5] + M[6] * M[6]), + sqrtf(M[8] * M[8] + M[9] * M[9] + M[10] * M[10])); +} + +template +inline CMatrix4 &CMatrix4::setRotationDegrees(const vector3d &rotation) +{ + return setRotationRadians(rotation * core::DEGTORAD); +} + +template +inline CMatrix4 &CMatrix4::setInverseRotationDegrees(const vector3d &rotation) +{ + return setInverseRotationRadians(rotation * core::DEGTORAD); +} + +template +inline CMatrix4 &CMatrix4::setRotationRadians(const vector3d &rotation) +{ + const f64 cr = cos(rotation.X); + const f64 sr = sin(rotation.X); + const f64 cp = cos(rotation.Y); + const f64 sp = sin(rotation.Y); + const f64 cy = cos(rotation.Z); + const f64 sy = sin(rotation.Z); + + M[0] = (T)(cp * cy); + M[1] = (T)(cp * sy); + M[2] = (T)(-sp); + + const f64 srsp = sr * sp; + const f64 crsp = cr * sp; + + M[4] = (T)(srsp * cy - cr * sy); + M[5] = (T)(srsp * sy + cr * cy); + M[6] = (T)(sr * cp); + + M[8] = (T)(crsp * cy + sr * sy); + M[9] = (T)(crsp * sy - sr * cy); + M[10] = (T)(cr * cp); +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return *this; +} + +//! Returns a rotation which (mostly) works in combination with the given scale +/** +This code was originally written by by Chev (assuming no scaling back then, +we can be blamed for all problems added by regarding scale) +*/ +template +inline core::vector3d CMatrix4::getRotationDegrees(const vector3d &scale_) const +{ + const CMatrix4 &mat = *this; + const core::vector3d scale(core::iszero(scale_.X) ? FLT_MAX : scale_.X, core::iszero(scale_.Y) ? FLT_MAX : scale_.Y, core::iszero(scale_.Z) ? FLT_MAX : scale_.Z); + const core::vector3d invScale(core::reciprocal(scale.X), core::reciprocal(scale.Y), core::reciprocal(scale.Z)); + + f64 Y = -asin(core::clamp(mat[2] * invScale.X, -1.0, 1.0)); + const f64 C = cos(Y); + Y *= RADTODEG64; + + f64 rotx, roty, X, Z; + + if (!core::iszero((T)C)) { + const f64 invC = core::reciprocal(C); + rotx = mat[10] * invC * invScale.Z; + roty = mat[6] * invC * invScale.Y; + X = atan2(roty, rotx) * RADTODEG64; + rotx = mat[0] * invC * invScale.X; + roty = mat[1] * invC * invScale.X; + Z = atan2(roty, rotx) * RADTODEG64; + } else { + X = 0.0; + rotx = mat[5] * invScale.Y; + roty = -mat[4] * invScale.Y; + Z = atan2(roty, rotx) * RADTODEG64; + } + + // fix values that get below zero + if (X < 0.0) + X += 360.0; + if (Y < 0.0) + Y += 360.0; + if (Z < 0.0) + Z += 360.0; + + return vector3d((T)X, (T)Y, (T)Z); +} + +//! Returns a rotation that is equivalent to that set by setRotationDegrees(). +template +inline core::vector3d CMatrix4::getRotationDegrees() const +{ + // Note: Using getScale() here make it look like it could do matrix decomposition. + // It can't! It works (or should work) as long as rotation doesn't flip the handedness + // aka scale swapping 1 or 3 axes. (I think we could catch that as well by comparing + // crossproduct of first 2 axes to direction of third axis, but TODO) + // And maybe it should also offer the solution for the simple calculation + // without regarding scaling as Irrlicht did before 1.7 + core::vector3d scale(getScale()); + + // We assume the matrix uses rotations instead of negative scaling 2 axes. + // Otherwise it fails even for some simple cases, like rotating around + // 2 axes by 180° which getScale thinks is a negative scaling. + if (scale.Y < 0 && scale.Z < 0) { + scale.Y = -scale.Y; + scale.Z = -scale.Z; + } else if (scale.X < 0 && scale.Z < 0) { + scale.X = -scale.X; + scale.Z = -scale.Z; + } else if (scale.X < 0 && scale.Y < 0) { + scale.X = -scale.X; + scale.Y = -scale.Y; + } + + return getRotationDegrees(scale); +} + +//! Sets matrix to rotation matrix of inverse angles given as parameters +template +inline CMatrix4 &CMatrix4::setInverseRotationRadians(const vector3d &rotation) +{ + f64 cr = cos(rotation.X); + f64 sr = sin(rotation.X); + f64 cp = cos(rotation.Y); + f64 sp = sin(rotation.Y); + f64 cy = cos(rotation.Z); + f64 sy = sin(rotation.Z); + + M[0] = (T)(cp * cy); + M[4] = (T)(cp * sy); + M[8] = (T)(-sp); + + f64 srsp = sr * sp; + f64 crsp = cr * sp; + + M[1] = (T)(srsp * cy - cr * sy); + M[5] = (T)(srsp * sy + cr * cy); + M[9] = (T)(sr * cp); + + M[2] = (T)(crsp * cy + sr * sy); + M[6] = (T)(crsp * sy - sr * cy); + M[10] = (T)(cr * cp); +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return *this; +} + +//! Sets matrix to rotation matrix defined by axis and angle, assuming LH rotation +template +inline CMatrix4 &CMatrix4::setRotationAxisRadians(const T &angle, const vector3d &axis) +{ + const f64 c = cos(angle); + const f64 s = sin(angle); + const f64 t = 1.0 - c; + + const f64 tx = t * axis.X; + const f64 ty = t * axis.Y; + const f64 tz = t * axis.Z; + + const f64 sx = s * axis.X; + const f64 sy = s * axis.Y; + const f64 sz = s * axis.Z; + + M[0] = (T)(tx * axis.X + c); + M[1] = (T)(tx * axis.Y + sz); + M[2] = (T)(tx * axis.Z - sy); + + M[4] = (T)(ty * axis.X - sz); + M[5] = (T)(ty * axis.Y + c); + M[6] = (T)(ty * axis.Z + sx); + + M[8] = (T)(tz * axis.X + sy); + M[9] = (T)(tz * axis.Y - sx); + M[10] = (T)(tz * axis.Z + c); + +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return *this; +} + +/*! + */ +template +inline CMatrix4 &CMatrix4::makeIdentity() +{ + memset(M, 0, 16 * sizeof(T)); + M[0] = M[5] = M[10] = M[15] = (T)1; +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = true; +#endif + return *this; +} + +/* + check identity with epsilon + solve floating range problems.. +*/ +template +inline bool CMatrix4::isIdentity() const +{ +#if defined(USE_MATRIX_TEST) + if (definitelyIdentityMatrix) + return true; +#endif + if (!core::equals(M[12], (T)0) || !core::equals(M[13], (T)0) || !core::equals(M[14], (T)0) || !core::equals(M[15], (T)1)) + return false; + + if (!core::equals(M[0], (T)1) || !core::equals(M[1], (T)0) || !core::equals(M[2], (T)0) || !core::equals(M[3], (T)0)) + return false; + + if (!core::equals(M[4], (T)0) || !core::equals(M[5], (T)1) || !core::equals(M[6], (T)0) || !core::equals(M[7], (T)0)) + return false; + + if (!core::equals(M[8], (T)0) || !core::equals(M[9], (T)0) || !core::equals(M[10], (T)1) || !core::equals(M[11], (T)0)) + return false; +/* + if (!core::equals( M[ 0], (T)1 ) || + !core::equals( M[ 5], (T)1 ) || + !core::equals( M[10], (T)1 ) || + !core::equals( M[15], (T)1 )) + return false; + + for (s32 i=0; i<4; ++i) + for (s32 j=0; j<4; ++j) + if ((j != i) && (!iszero((*this)(i,j)))) + return false; +*/ +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = true; +#endif + return true; +} + +/* Check orthogonality of matrix. */ +template +inline bool CMatrix4::isOrthogonal() const +{ + T dp = M[0] * M[4] + M[1] * M[5] + M[2] * M[6] + M[3] * M[7]; + if (!iszero(dp)) + return false; + dp = M[0] * M[8] + M[1] * M[9] + M[2] * M[10] + M[3] * M[11]; + if (!iszero(dp)) + return false; + dp = M[0] * M[12] + M[1] * M[13] + M[2] * M[14] + M[3] * M[15]; + if (!iszero(dp)) + return false; + dp = M[4] * M[8] + M[5] * M[9] + M[6] * M[10] + M[7] * M[11]; + if (!iszero(dp)) + return false; + dp = M[4] * M[12] + M[5] * M[13] + M[6] * M[14] + M[7] * M[15]; + if (!iszero(dp)) + return false; + dp = M[8] * M[12] + M[9] * M[13] + M[10] * M[14] + M[11] * M[15]; + return (iszero(dp)); +} + +/* + doesn't solve floating range problems.. + but takes care on +/- 0 on translation because we are changing it.. + reducing floating point branches + but it needs the floats in memory.. +*/ +template +inline bool CMatrix4::isIdentity_integer_base() const +{ +#if defined(USE_MATRIX_TEST) + if (definitelyIdentityMatrix) + return true; +#endif + if (IR(M[0]) != F32_VALUE_1) + return false; + if (IR(M[1]) != 0) + return false; + if (IR(M[2]) != 0) + return false; + if (IR(M[3]) != 0) + return false; + + if (IR(M[4]) != 0) + return false; + if (IR(M[5]) != F32_VALUE_1) + return false; + if (IR(M[6]) != 0) + return false; + if (IR(M[7]) != 0) + return false; + + if (IR(M[8]) != 0) + return false; + if (IR(M[9]) != 0) + return false; + if (IR(M[10]) != F32_VALUE_1) + return false; + if (IR(M[11]) != 0) + return false; + + if (IR(M[12]) != 0) + return false; + if (IR(M[13]) != 0) + return false; + if (IR(M[13]) != 0) + return false; + if (IR(M[15]) != F32_VALUE_1) + return false; + +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = true; +#endif + return true; +} + +template +inline void CMatrix4::rotateVect(vector3df &vect) const +{ + vector3d tmp(static_cast(vect.X), static_cast(vect.Y), static_cast(vect.Z)); + vect.X = static_cast(tmp.X * M[0] + tmp.Y * M[4] + tmp.Z * M[8]); + vect.Y = static_cast(tmp.X * M[1] + tmp.Y * M[5] + tmp.Z * M[9]); + vect.Z = static_cast(tmp.X * M[2] + tmp.Y * M[6] + tmp.Z * M[10]); +} + +//! An alternate transform vector method, writing into a second vector +template +inline void CMatrix4::rotateVect(core::vector3df &out, const core::vector3df &in) const +{ + out.X = in.X * M[0] + in.Y * M[4] + in.Z * M[8]; + out.Y = in.X * M[1] + in.Y * M[5] + in.Z * M[9]; + out.Z = in.X * M[2] + in.Y * M[6] + in.Z * M[10]; +} + +//! An alternate transform vector method, writing into an array of 3 floats +template +inline void CMatrix4::rotateVect(T *out, const core::vector3df &in) const +{ + out[0] = in.X * M[0] + in.Y * M[4] + in.Z * M[8]; + out[1] = in.X * M[1] + in.Y * M[5] + in.Z * M[9]; + out[2] = in.X * M[2] + in.Y * M[6] + in.Z * M[10]; +} + +template +inline void CMatrix4::inverseRotateVect(vector3df &vect) const +{ + vector3d tmp(static_cast(vect.X), static_cast(vect.Y), static_cast(vect.Z)); + vect.X = static_cast(tmp.X * M[0] + tmp.Y * M[1] + tmp.Z * M[2]); + vect.Y = static_cast(tmp.X * M[4] + tmp.Y * M[5] + tmp.Z * M[6]); + vect.Z = static_cast(tmp.X * M[8] + tmp.Y * M[9] + tmp.Z * M[10]); +} + +template +inline void CMatrix4::transformVect(vector3df &vect) const +{ + T vector[3]; + + vector[0] = vect.X * M[0] + vect.Y * M[4] + vect.Z * M[8] + M[12]; + vector[1] = vect.X * M[1] + vect.Y * M[5] + vect.Z * M[9] + M[13]; + vector[2] = vect.X * M[2] + vect.Y * M[6] + vect.Z * M[10] + M[14]; + + vect.X = static_cast(vector[0]); + vect.Y = static_cast(vector[1]); + vect.Z = static_cast(vector[2]); +} + +template +inline void CMatrix4::transformVect(vector3df &out, const vector3df &in) const +{ + out.X = in.X * M[0] + in.Y * M[4] + in.Z * M[8] + M[12]; + out.Y = in.X * M[1] + in.Y * M[5] + in.Z * M[9] + M[13]; + out.Z = in.X * M[2] + in.Y * M[6] + in.Z * M[10] + M[14]; +} + +template +inline void CMatrix4::transformVect(T *out, const core::vector3df &in) const +{ + out[0] = in.X * M[0] + in.Y * M[4] + in.Z * M[8] + M[12]; + out[1] = in.X * M[1] + in.Y * M[5] + in.Z * M[9] + M[13]; + out[2] = in.X * M[2] + in.Y * M[6] + in.Z * M[10] + M[14]; + out[3] = in.X * M[3] + in.Y * M[7] + in.Z * M[11] + M[15]; +} + +template +inline void CMatrix4::transformVec3(T *out, const T *in) const +{ + out[0] = in[0] * M[0] + in[1] * M[4] + in[2] * M[8] + M[12]; + out[1] = in[0] * M[1] + in[1] * M[5] + in[2] * M[9] + M[13]; + out[2] = in[0] * M[2] + in[1] * M[6] + in[2] * M[10] + M[14]; +} + +template +inline void CMatrix4::transformVec4(T *out, const T *in) const +{ + out[0] = in[0] * M[0] + in[1] * M[4] + in[2] * M[8] + in[3] * M[12]; + out[1] = in[0] * M[1] + in[1] * M[5] + in[2] * M[9] + in[3] * M[13]; + out[2] = in[0] * M[2] + in[1] * M[6] + in[2] * M[10] + in[3] * M[14]; + out[3] = in[0] * M[3] + in[1] * M[7] + in[2] * M[11] + in[3] * M[15]; +} + +//! Transforms a plane by this matrix +template +inline void CMatrix4::transformPlane(core::plane3d &plane) const +{ + vector3df member; + // Transform the plane member point, i.e. rotate, translate and scale it. + transformVect(member, plane.getMemberPoint()); + + // Transform the normal by the transposed inverse of the matrix + CMatrix4 transposedInverse(*this, EM4CONST_INVERSE_TRANSPOSED); + vector3df normal = plane.Normal; + transposedInverse.rotateVect(normal); + plane.setPlane(member, normal.normalize()); +} + +//! Transforms a plane by this matrix +template +inline void CMatrix4::transformPlane(const core::plane3d &in, core::plane3d &out) const +{ + out = in; + transformPlane(out); +} + +//! Transforms a axis aligned bounding box more accurately than transformBox() +template +inline void CMatrix4::transformBoxEx(core::aabbox3d &box) const +{ +#if defined(USE_MATRIX_TEST) + if (isIdentity()) + return; +#endif + + const f32 Amin[3] = {box.MinEdge.X, box.MinEdge.Y, box.MinEdge.Z}; + const f32 Amax[3] = {box.MaxEdge.X, box.MaxEdge.Y, box.MaxEdge.Z}; + + f32 Bmin[3]; + f32 Bmax[3]; + + Bmin[0] = Bmax[0] = M[12]; + Bmin[1] = Bmax[1] = M[13]; + Bmin[2] = Bmax[2] = M[14]; + + const CMatrix4 &m = *this; + + for (u32 i = 0; i < 3; ++i) { + for (u32 j = 0; j < 3; ++j) { + const f32 a = m(j, i) * Amin[j]; + const f32 b = m(j, i) * Amax[j]; + + if (a < b) { + Bmin[i] += a; + Bmax[i] += b; + } else { + Bmin[i] += b; + Bmax[i] += a; + } + } + } + + box.MinEdge.X = Bmin[0]; + box.MinEdge.Y = Bmin[1]; + box.MinEdge.Z = Bmin[2]; + + box.MaxEdge.X = Bmax[0]; + box.MaxEdge.Y = Bmax[1]; + box.MaxEdge.Z = Bmax[2]; +} + +//! Multiplies this matrix by a 1x4 matrix +template +inline void CMatrix4::multiplyWith1x4Matrix(T *matrix) const +{ + /* + 0 1 2 3 + 4 5 6 7 + 8 9 10 11 + 12 13 14 15 + */ + + T mat[4]; + mat[0] = matrix[0]; + mat[1] = matrix[1]; + mat[2] = matrix[2]; + mat[3] = matrix[3]; + + matrix[0] = M[0] * mat[0] + M[4] * mat[1] + M[8] * mat[2] + M[12] * mat[3]; + matrix[1] = M[1] * mat[0] + M[5] * mat[1] + M[9] * mat[2] + M[13] * mat[3]; + matrix[2] = M[2] * mat[0] + M[6] * mat[1] + M[10] * mat[2] + M[14] * mat[3]; + matrix[3] = M[3] * mat[0] + M[7] * mat[1] + M[11] * mat[2] + M[15] * mat[3]; +} + +template +inline void CMatrix4::inverseTranslateVect(vector3df &vect) const +{ + vect.X = vect.X - M[12]; + vect.Y = vect.Y - M[13]; + vect.Z = vect.Z - M[14]; +} + +template +inline void CMatrix4::translateVect(vector3df &vect) const +{ + vect.X = vect.X + M[12]; + vect.Y = vect.Y + M[13]; + vect.Z = vect.Z + M[14]; +} + +template +inline bool CMatrix4::getInverse(CMatrix4 &out) const +{ + /// Calculates the inverse of this Matrix + /// The inverse is calculated using Cramers rule. + /// If no inverse exists then 'false' is returned. + +#if defined(USE_MATRIX_TEST) + if (this->isIdentity()) { + out = *this; + return true; + } +#endif + const CMatrix4 &m = *this; + + f32 d = (m[0] * m[5] - m[1] * m[4]) * (m[10] * m[15] - m[11] * m[14]) - + (m[0] * m[6] - m[2] * m[4]) * (m[9] * m[15] - m[11] * m[13]) + + (m[0] * m[7] - m[3] * m[4]) * (m[9] * m[14] - m[10] * m[13]) + + (m[1] * m[6] - m[2] * m[5]) * (m[8] * m[15] - m[11] * m[12]) - + (m[1] * m[7] - m[3] * m[5]) * (m[8] * m[14] - m[10] * m[12]) + + (m[2] * m[7] - m[3] * m[6]) * (m[8] * m[13] - m[9] * m[12]); + + if (core::iszero(d, FLT_MIN)) + return false; + + d = core::reciprocal(d); + + out[0] = d * (m[5] * (m[10] * m[15] - m[11] * m[14]) + + m[6] * (m[11] * m[13] - m[9] * m[15]) + + m[7] * (m[9] * m[14] - m[10] * m[13])); + out[1] = d * (m[9] * (m[2] * m[15] - m[3] * m[14]) + + m[10] * (m[3] * m[13] - m[1] * m[15]) + + m[11] * (m[1] * m[14] - m[2] * m[13])); + out[2] = d * (m[13] * (m[2] * m[7] - m[3] * m[6]) + + m[14] * (m[3] * m[5] - m[1] * m[7]) + + m[15] * (m[1] * m[6] - m[2] * m[5])); + out[3] = d * (m[1] * (m[7] * m[10] - m[6] * m[11]) + + m[2] * (m[5] * m[11] - m[7] * m[9]) + + m[3] * (m[6] * m[9] - m[5] * m[10])); + out[4] = d * (m[6] * (m[8] * m[15] - m[11] * m[12]) + + m[7] * (m[10] * m[12] - m[8] * m[14]) + + m[4] * (m[11] * m[14] - m[10] * m[15])); + out[5] = d * (m[10] * (m[0] * m[15] - m[3] * m[12]) + + m[11] * (m[2] * m[12] - m[0] * m[14]) + + m[8] * (m[3] * m[14] - m[2] * m[15])); + out[6] = d * (m[14] * (m[0] * m[7] - m[3] * m[4]) + + m[15] * (m[2] * m[4] - m[0] * m[6]) + + m[12] * (m[3] * m[6] - m[2] * m[7])); + out[7] = d * (m[2] * (m[7] * m[8] - m[4] * m[11]) + + m[3] * (m[4] * m[10] - m[6] * m[8]) + + m[0] * (m[6] * m[11] - m[7] * m[10])); + out[8] = d * (m[7] * (m[8] * m[13] - m[9] * m[12]) + + m[4] * (m[9] * m[15] - m[11] * m[13]) + + m[5] * (m[11] * m[12] - m[8] * m[15])); + out[9] = d * (m[11] * (m[0] * m[13] - m[1] * m[12]) + + m[8] * (m[1] * m[15] - m[3] * m[13]) + + m[9] * (m[3] * m[12] - m[0] * m[15])); + out[10] = d * (m[15] * (m[0] * m[5] - m[1] * m[4]) + + m[12] * (m[1] * m[7] - m[3] * m[5]) + + m[13] * (m[3] * m[4] - m[0] * m[7])); + out[11] = d * (m[3] * (m[5] * m[8] - m[4] * m[9]) + + m[0] * (m[7] * m[9] - m[5] * m[11]) + + m[1] * (m[4] * m[11] - m[7] * m[8])); + out[12] = d * (m[4] * (m[10] * m[13] - m[9] * m[14]) + + m[5] * (m[8] * m[14] - m[10] * m[12]) + + m[6] * (m[9] * m[12] - m[8] * m[13])); + out[13] = d * (m[8] * (m[2] * m[13] - m[1] * m[14]) + + m[9] * (m[0] * m[14] - m[2] * m[12]) + + m[10] * (m[1] * m[12] - m[0] * m[13])); + out[14] = d * (m[12] * (m[2] * m[5] - m[1] * m[6]) + + m[13] * (m[0] * m[6] - m[2] * m[4]) + + m[14] * (m[1] * m[4] - m[0] * m[5])); + out[15] = d * (m[0] * (m[5] * m[10] - m[6] * m[9]) + + m[1] * (m[6] * m[8] - m[4] * m[10]) + + m[2] * (m[4] * m[9] - m[5] * m[8])); + +#if defined(USE_MATRIX_TEST) + out.definitelyIdentityMatrix = definitelyIdentityMatrix; +#endif + return true; +} + +//! Inverts a primitive matrix which only contains a translation and a rotation +//! \param out: where result matrix is written to. +template +inline bool CMatrix4::getInversePrimitive(CMatrix4 &out) const +{ + out.M[0] = M[0]; + out.M[1] = M[4]; + out.M[2] = M[8]; + out.M[3] = 0; + + out.M[4] = M[1]; + out.M[5] = M[5]; + out.M[6] = M[9]; + out.M[7] = 0; + + out.M[8] = M[2]; + out.M[9] = M[6]; + out.M[10] = M[10]; + out.M[11] = 0; + + out.M[12] = (T) - (M[12] * M[0] + M[13] * M[1] + M[14] * M[2]); + out.M[13] = (T) - (M[12] * M[4] + M[13] * M[5] + M[14] * M[6]); + out.M[14] = (T) - (M[12] * M[8] + M[13] * M[9] + M[14] * M[10]); + out.M[15] = 1; + +#if defined(USE_MATRIX_TEST) + out.definitelyIdentityMatrix = definitelyIdentityMatrix; +#endif + return true; +} + +/*! + */ +template +inline bool CMatrix4::makeInverse() +{ +#if defined(USE_MATRIX_TEST) + if (definitelyIdentityMatrix) + return true; +#endif + CMatrix4 temp(EM4CONST_NOTHING); + + if (getInverse(temp)) { + *this = temp; + return true; + } + + return false; +} + +template +inline CMatrix4 &CMatrix4::operator=(const T &scalar) +{ + for (s32 i = 0; i < 16; ++i) + M[i] = scalar; + +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return *this; +} + +// Builds a right-handed perspective projection matrix based on a field of view +template +inline CMatrix4 &CMatrix4::buildProjectionMatrixPerspectiveFovRH( + f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero) +{ + const f64 h = reciprocal(tan(fieldOfViewRadians * 0.5)); + _IRR_DEBUG_BREAK_IF(aspectRatio == 0.f); // divide by zero + const T w = static_cast(h / aspectRatio); + + _IRR_DEBUG_BREAK_IF(zNear == zFar); // divide by zero + M[0] = w; + M[1] = 0; + M[2] = 0; + M[3] = 0; + + M[4] = 0; + M[5] = (T)h; + M[6] = 0; + M[7] = 0; + + M[8] = 0; + M[9] = 0; + // M[10] + M[11] = -1; + + M[12] = 0; + M[13] = 0; + // M[14] + M[15] = 0; + + if (zClipFromZero) { // DirectX version + M[10] = (T)(zFar / (zNear - zFar)); + M[14] = (T)(zNear * zFar / (zNear - zFar)); + } else // OpenGL version + { + M[10] = (T)((zFar + zNear) / (zNear - zFar)); + M[14] = (T)(2.0f * zNear * zFar / (zNear - zFar)); + } + +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return *this; +} + +// Builds a left-handed perspective projection matrix based on a field of view +template +inline CMatrix4 &CMatrix4::buildProjectionMatrixPerspectiveFovLH( + f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero) +{ + const f64 h = reciprocal(tan(fieldOfViewRadians * 0.5)); + _IRR_DEBUG_BREAK_IF(aspectRatio == 0.f); // divide by zero + const T w = static_cast(h / aspectRatio); + + _IRR_DEBUG_BREAK_IF(zNear == zFar); // divide by zero + M[0] = w; + M[1] = 0; + M[2] = 0; + M[3] = 0; + + M[4] = 0; + M[5] = (T)h; + M[6] = 0; + M[7] = 0; + + M[8] = 0; + M[9] = 0; + // M[10] + M[11] = 1; + + M[12] = 0; + M[13] = 0; + // M[14] + M[15] = 0; + + if (zClipFromZero) { // DirectX version + M[10] = (T)(zFar / (zFar - zNear)); + M[14] = (T)(-zNear * zFar / (zFar - zNear)); + } else // OpenGL version + { + M[10] = (T)((zFar + zNear) / (zFar - zNear)); + M[14] = (T)(2.0f * zNear * zFar / (zNear - zFar)); + } + +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return *this; +} + +// Builds a left-handed perspective projection matrix based on a field of view, with far plane culling at infinity +template +inline CMatrix4 &CMatrix4::buildProjectionMatrixPerspectiveFovInfinityLH( + f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 epsilon) +{ + const f64 h = reciprocal(tan(fieldOfViewRadians * 0.5)); + _IRR_DEBUG_BREAK_IF(aspectRatio == 0.f); // divide by zero + const T w = static_cast(h / aspectRatio); + + M[0] = w; + M[1] = 0; + M[2] = 0; + M[3] = 0; + + M[4] = 0; + M[5] = (T)h; + M[6] = 0; + M[7] = 0; + + M[8] = 0; + M[9] = 0; + M[10] = (T)(1.f - epsilon); + M[11] = 1; + + M[12] = 0; + M[13] = 0; + M[14] = (T)(zNear * (epsilon - 1.f)); + M[15] = 0; + +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return *this; +} + +// Builds a left-handed orthogonal projection matrix. +template +inline CMatrix4 &CMatrix4::buildProjectionMatrixOrthoLH( + f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero) +{ + _IRR_DEBUG_BREAK_IF(widthOfViewVolume == 0.f); // divide by zero + _IRR_DEBUG_BREAK_IF(heightOfViewVolume == 0.f); // divide by zero + _IRR_DEBUG_BREAK_IF(zNear == zFar); // divide by zero + M[0] = (T)(2 / widthOfViewVolume); + M[1] = 0; + M[2] = 0; + M[3] = 0; + + M[4] = 0; + M[5] = (T)(2 / heightOfViewVolume); + M[6] = 0; + M[7] = 0; + + M[8] = 0; + M[9] = 0; + // M[10] + M[11] = 0; + + M[12] = 0; + M[13] = 0; + // M[14] + M[15] = 1; + + if (zClipFromZero) { + M[10] = (T)(1 / (zFar - zNear)); + M[14] = (T)(zNear / (zNear - zFar)); + } else { + M[10] = (T)(2 / (zFar - zNear)); + M[14] = (T) - (zFar + zNear) / (zFar - zNear); + } + +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return *this; +} + +// Builds a right-handed orthogonal projection matrix. +template +inline CMatrix4 &CMatrix4::buildProjectionMatrixOrthoRH( + f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero) +{ + _IRR_DEBUG_BREAK_IF(widthOfViewVolume == 0.f); // divide by zero + _IRR_DEBUG_BREAK_IF(heightOfViewVolume == 0.f); // divide by zero + _IRR_DEBUG_BREAK_IF(zNear == zFar); // divide by zero + M[0] = (T)(2 / widthOfViewVolume); + M[1] = 0; + M[2] = 0; + M[3] = 0; + + M[4] = 0; + M[5] = (T)(2 / heightOfViewVolume); + M[6] = 0; + M[7] = 0; + + M[8] = 0; + M[9] = 0; + // M[10] + M[11] = 0; + + M[12] = 0; + M[13] = 0; + // M[14] + M[15] = 1; + + if (zClipFromZero) { + M[10] = (T)(1 / (zNear - zFar)); + M[14] = (T)(zNear / (zNear - zFar)); + } else { + M[10] = (T)(2 / (zNear - zFar)); + M[14] = (T) - (zFar + zNear) / (zFar - zNear); + } + +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return *this; +} + +// Builds a right-handed perspective projection matrix. +template +inline CMatrix4 &CMatrix4::buildProjectionMatrixPerspectiveRH( + f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero) +{ + _IRR_DEBUG_BREAK_IF(widthOfViewVolume == 0.f); // divide by zero + _IRR_DEBUG_BREAK_IF(heightOfViewVolume == 0.f); // divide by zero + _IRR_DEBUG_BREAK_IF(zNear == zFar); // divide by zero + M[0] = (T)(2 * zNear / widthOfViewVolume); + M[1] = 0; + M[2] = 0; + M[3] = 0; + + M[4] = 0; + M[5] = (T)(2 * zNear / heightOfViewVolume); + M[6] = 0; + M[7] = 0; + + M[8] = 0; + M[9] = 0; + // M[10] + M[11] = -1; + + M[12] = 0; + M[13] = 0; + // M[14] + M[15] = 0; + + if (zClipFromZero) { // DirectX version + M[10] = (T)(zFar / (zNear - zFar)); + M[14] = (T)(zNear * zFar / (zNear - zFar)); + } else // OpenGL version + { + M[10] = (T)((zFar + zNear) / (zNear - zFar)); + M[14] = (T)(2.0f * zNear * zFar / (zNear - zFar)); + } + +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return *this; +} + +// Builds a left-handed perspective projection matrix. +template +inline CMatrix4 &CMatrix4::buildProjectionMatrixPerspectiveLH( + f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero) +{ + _IRR_DEBUG_BREAK_IF(widthOfViewVolume == 0.f); // divide by zero + _IRR_DEBUG_BREAK_IF(heightOfViewVolume == 0.f); // divide by zero + _IRR_DEBUG_BREAK_IF(zNear == zFar); // divide by zero + M[0] = (T)(2 * zNear / widthOfViewVolume); + M[1] = 0; + M[2] = 0; + M[3] = 0; + + M[4] = 0; + M[5] = (T)(2 * zNear / heightOfViewVolume); + M[6] = 0; + M[7] = 0; + + M[8] = 0; + M[9] = 0; + // M[10] + M[11] = 1; + + M[12] = 0; + M[13] = 0; + // M[14] = (T)(zNear*zFar/(zNear-zFar)); + M[15] = 0; + + if (zClipFromZero) { // DirectX version + M[10] = (T)(zFar / (zFar - zNear)); + M[14] = (T)(zNear * zFar / (zNear - zFar)); + } else // OpenGL version + { + M[10] = (T)((zFar + zNear) / (zFar - zNear)); + M[14] = (T)(2.0f * zNear * zFar / (zNear - zFar)); + } + +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return *this; +} + +// Builds a matrix that flattens geometry into a plane. +template +inline CMatrix4 &CMatrix4::buildShadowMatrix(const core::vector3df &light, core::plane3df plane, f32 point) +{ + plane.Normal.normalize(); + const f32 d = plane.Normal.dotProduct(light); + + M[0] = (T)(-plane.Normal.X * light.X + d); + M[1] = (T)(-plane.Normal.X * light.Y); + M[2] = (T)(-plane.Normal.X * light.Z); + M[3] = (T)(-plane.Normal.X * point); + + M[4] = (T)(-plane.Normal.Y * light.X); + M[5] = (T)(-plane.Normal.Y * light.Y + d); + M[6] = (T)(-plane.Normal.Y * light.Z); + M[7] = (T)(-plane.Normal.Y * point); + + M[8] = (T)(-plane.Normal.Z * light.X); + M[9] = (T)(-plane.Normal.Z * light.Y); + M[10] = (T)(-plane.Normal.Z * light.Z + d); + M[11] = (T)(-plane.Normal.Z * point); + + M[12] = (T)(-plane.D * light.X); + M[13] = (T)(-plane.D * light.Y); + M[14] = (T)(-plane.D * light.Z); + M[15] = (T)(-plane.D * point + d); +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return *this; +} + +// Builds a left-handed look-at matrix. +template +inline CMatrix4 &CMatrix4::buildCameraLookAtMatrixLH( + const vector3df &position, + const vector3df &target, + const vector3df &upVector) +{ + vector3df zaxis = target - position; + zaxis.normalize(); + + vector3df xaxis = upVector.crossProduct(zaxis); + xaxis.normalize(); + + vector3df yaxis = zaxis.crossProduct(xaxis); + + M[0] = (T)xaxis.X; + M[1] = (T)yaxis.X; + M[2] = (T)zaxis.X; + M[3] = 0; + + M[4] = (T)xaxis.Y; + M[5] = (T)yaxis.Y; + M[6] = (T)zaxis.Y; + M[7] = 0; + + M[8] = (T)xaxis.Z; + M[9] = (T)yaxis.Z; + M[10] = (T)zaxis.Z; + M[11] = 0; + + M[12] = (T)-xaxis.dotProduct(position); + M[13] = (T)-yaxis.dotProduct(position); + M[14] = (T)-zaxis.dotProduct(position); + M[15] = 1; +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return *this; +} + +// Builds a right-handed look-at matrix. +template +inline CMatrix4 &CMatrix4::buildCameraLookAtMatrixRH( + const vector3df &position, + const vector3df &target, + const vector3df &upVector) +{ + vector3df zaxis = position - target; + zaxis.normalize(); + + vector3df xaxis = upVector.crossProduct(zaxis); + xaxis.normalize(); + + vector3df yaxis = zaxis.crossProduct(xaxis); + + M[0] = (T)xaxis.X; + M[1] = (T)yaxis.X; + M[2] = (T)zaxis.X; + M[3] = 0; + + M[4] = (T)xaxis.Y; + M[5] = (T)yaxis.Y; + M[6] = (T)zaxis.Y; + M[7] = 0; + + M[8] = (T)xaxis.Z; + M[9] = (T)yaxis.Z; + M[10] = (T)zaxis.Z; + M[11] = 0; + + M[12] = (T)-xaxis.dotProduct(position); + M[13] = (T)-yaxis.dotProduct(position); + M[14] = (T)-zaxis.dotProduct(position); + M[15] = 1; +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return *this; +} + +// creates a new matrix as interpolated matrix from this and the passed one. +template +inline CMatrix4 CMatrix4::interpolate(const core::CMatrix4 &b, f32 time) const +{ + CMatrix4 mat(EM4CONST_NOTHING); + + for (u32 i = 0; i < 16; i += 4) { + mat.M[i + 0] = (T)(M[i + 0] + (b.M[i + 0] - M[i + 0]) * time); + mat.M[i + 1] = (T)(M[i + 1] + (b.M[i + 1] - M[i + 1]) * time); + mat.M[i + 2] = (T)(M[i + 2] + (b.M[i + 2] - M[i + 2]) * time); + mat.M[i + 3] = (T)(M[i + 3] + (b.M[i + 3] - M[i + 3]) * time); + } + return mat; +} + +// returns transposed matrix +template +inline CMatrix4 CMatrix4::getTransposed() const +{ + CMatrix4 t(EM4CONST_NOTHING); + getTransposed(t); + return t; +} + +// returns transposed matrix +template +inline void CMatrix4::getTransposed(CMatrix4 &o) const +{ + o[0] = M[0]; + o[1] = M[4]; + o[2] = M[8]; + o[3] = M[12]; + + o[4] = M[1]; + o[5] = M[5]; + o[6] = M[9]; + o[7] = M[13]; + + o[8] = M[2]; + o[9] = M[6]; + o[10] = M[10]; + o[11] = M[14]; + + o[12] = M[3]; + o[13] = M[7]; + o[14] = M[11]; + o[15] = M[15]; +#if defined(USE_MATRIX_TEST) + o.definitelyIdentityMatrix = definitelyIdentityMatrix; +#endif +} + +// used to scale <-1,-1><1,1> to viewport +template +inline CMatrix4 &CMatrix4::buildNDCToDCMatrix(const core::rect &viewport, f32 zScale) +{ + const f32 scaleX = (viewport.getWidth() - 0.75f) * 0.5f; + const f32 scaleY = -(viewport.getHeight() - 0.75f) * 0.5f; + + const f32 dx = -0.5f + ((viewport.UpperLeftCorner.X + viewport.LowerRightCorner.X) * 0.5f); + const f32 dy = -0.5f + ((viewport.UpperLeftCorner.Y + viewport.LowerRightCorner.Y) * 0.5f); + + makeIdentity(); + M[12] = (T)dx; + M[13] = (T)dy; + return setScale(core::vector3d((T)scaleX, (T)scaleY, (T)zScale)); +} + +//! Builds a matrix that rotates from one vector to another +/** \param from: vector to rotate from +\param to: vector to rotate to + + http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToMatrix/index.htm + */ +template +inline CMatrix4 &CMatrix4::buildRotateFromTo(const core::vector3df &from, const core::vector3df &to) +{ + // unit vectors + core::vector3df f(from); + core::vector3df t(to); + f.normalize(); + t.normalize(); + + // axis multiplication by sin + core::vector3df vs(t.crossProduct(f)); + + // axis of rotation + core::vector3df v(vs); + v.normalize(); + + // cosine angle + T ca = f.dotProduct(t); + + core::vector3df vt(v * (1 - ca)); + + M[0] = vt.X * v.X + ca; + M[5] = vt.Y * v.Y + ca; + M[10] = vt.Z * v.Z + ca; + + vt.X *= v.Y; + vt.Z *= v.X; + vt.Y *= v.Z; + + M[1] = vt.X - vs.Z; + M[2] = vt.Z + vs.Y; + M[3] = 0; + + M[4] = vt.X + vs.Z; + M[6] = vt.Y - vs.X; + M[7] = 0; + + M[8] = vt.Z - vs.Y; + M[9] = vt.Y + vs.X; + M[11] = 0; + + M[12] = 0; + M[13] = 0; + M[14] = 0; + M[15] = 1; + + return *this; +} + +//! Builds a matrix which rotates a source vector to a look vector over an arbitrary axis +/** \param camPos: viewer position in world coord +\param center: object position in world-coord, rotation pivot +\param translation: object final translation from center +\param axis: axis to rotate about +\param from: source vector to rotate from + */ +template +inline void CMatrix4::buildAxisAlignedBillboard( + const core::vector3df &camPos, + const core::vector3df ¢er, + const core::vector3df &translation, + const core::vector3df &axis, + const core::vector3df &from) +{ + // axis of rotation + core::vector3df up = axis; + up.normalize(); + const core::vector3df forward = (camPos - center).normalize(); + const core::vector3df right = up.crossProduct(forward).normalize(); + + // correct look vector + const core::vector3df look = right.crossProduct(up); + + // rotate from to + // axis multiplication by sin + const core::vector3df vs = look.crossProduct(from); + + // cosine angle + const f32 ca = from.dotProduct(look); + + core::vector3df vt(up * (1.f - ca)); + + M[0] = static_cast(vt.X * up.X + ca); + M[5] = static_cast(vt.Y * up.Y + ca); + M[10] = static_cast(vt.Z * up.Z + ca); + + vt.X *= up.Y; + vt.Z *= up.X; + vt.Y *= up.Z; + + M[1] = static_cast(vt.X - vs.Z); + M[2] = static_cast(vt.Z + vs.Y); + M[3] = 0; + + M[4] = static_cast(vt.X + vs.Z); + M[6] = static_cast(vt.Y - vs.X); + M[7] = 0; + + M[8] = static_cast(vt.Z - vs.Y); + M[9] = static_cast(vt.Y + vs.X); + M[11] = 0; + + setRotationCenter(center, translation); +} + +//! Builds a combined matrix which translate to a center before rotation and translate afterward +template +inline void CMatrix4::setRotationCenter(const core::vector3df ¢er, const core::vector3df &translation) +{ + M[12] = -M[0] * center.X - M[4] * center.Y - M[8] * center.Z + (center.X - translation.X); + M[13] = -M[1] * center.X - M[5] * center.Y - M[9] * center.Z + (center.Y - translation.Y); + M[14] = -M[2] * center.X - M[6] * center.Y - M[10] * center.Z + (center.Z - translation.Z); + M[15] = (T)1.0; +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif +} + +/*! + Generate texture coordinates as linear functions so that: + u = Ux*x + Uy*y + Uz*z + Uw + v = Vx*x + Vy*y + Vz*z + Vw + The matrix M for this case is: + Ux Vx 0 0 + Uy Vy 0 0 + Uz Vz 0 0 + Uw Vw 0 0 +*/ + +template +inline CMatrix4 &CMatrix4::buildTextureTransform(f32 rotateRad, + const core::vector2df &rotatecenter, + const core::vector2df &translate, + const core::vector2df &scale) +{ + const f32 c = cosf(rotateRad); + const f32 s = sinf(rotateRad); + + M[0] = (T)(c * scale.X); + M[1] = (T)(s * scale.Y); + M[2] = 0; + M[3] = 0; + + M[4] = (T)(-s * scale.X); + M[5] = (T)(c * scale.Y); + M[6] = 0; + M[7] = 0; + + M[8] = (T)(c * scale.X * rotatecenter.X + -s * rotatecenter.Y + translate.X); + M[9] = (T)(s * scale.Y * rotatecenter.X + c * rotatecenter.Y + translate.Y); + M[10] = 1; + M[11] = 0; + + M[12] = 0; + M[13] = 0; + M[14] = 0; + M[15] = 1; +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return *this; +} + +// rotate about z axis, center ( 0.5, 0.5 ) +template +inline CMatrix4 &CMatrix4::setTextureRotationCenter(f32 rotateRad) +{ + const f32 c = cosf(rotateRad); + const f32 s = sinf(rotateRad); + M[0] = (T)c; + M[1] = (T)s; + + M[4] = (T)-s; + M[5] = (T)c; + + M[8] = (T)(0.5f * (s - c) + 0.5f); + M[9] = (T)(-0.5f * (s + c) + 0.5f); + +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = definitelyIdentityMatrix && (rotateRad == 0.0f); +#endif + return *this; +} + +template +inline CMatrix4 &CMatrix4::setTextureTranslate(f32 x, f32 y) +{ + M[8] = (T)x; + M[9] = (T)y; + +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = definitelyIdentityMatrix && (x == 0.0f) && (y == 0.0f); +#endif + return *this; +} + +template +inline void CMatrix4::getTextureTranslate(f32 &x, f32 &y) const +{ + x = (f32)M[8]; + y = (f32)M[9]; +} + +template +inline CMatrix4 &CMatrix4::setTextureTranslateTransposed(f32 x, f32 y) +{ + M[2] = (T)x; + M[6] = (T)y; + +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = definitelyIdentityMatrix && (x == 0.0f) && (y == 0.0f); +#endif + return *this; +} + +template +inline CMatrix4 &CMatrix4::setTextureScale(f32 sx, f32 sy) +{ + M[0] = (T)sx; + M[5] = (T)sy; +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = definitelyIdentityMatrix && (sx == 1.0f) && (sy == 1.0f); +#endif + return *this; +} + +template +inline void CMatrix4::getTextureScale(f32 &sx, f32 &sy) const +{ + sx = (f32)M[0]; + sy = (f32)M[5]; +} + +template +inline CMatrix4 &CMatrix4::setTextureScaleCenter(f32 sx, f32 sy) +{ + M[0] = (T)sx; + M[5] = (T)sy; + M[8] = (T)(0.5f - 0.5f * sx); + M[9] = (T)(0.5f - 0.5f * sy); + +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = definitelyIdentityMatrix && (sx == 1.0f) && (sy == 1.0f); +#endif + return *this; +} + +// sets all matrix data members at once +template +inline CMatrix4 &CMatrix4::setM(const T *data) +{ + memcpy(M, data, 16 * sizeof(T)); + +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = false; +#endif + return *this; +} + +// sets if the matrix is definitely identity matrix +template +inline void CMatrix4::setDefinitelyIdentityMatrix(bool isDefinitelyIdentityMatrix) +{ +#if defined(USE_MATRIX_TEST) + definitelyIdentityMatrix = isDefinitelyIdentityMatrix; +#else + (void)isDefinitelyIdentityMatrix; // prevent compiler warning +#endif +} + +// gets if the matrix is definitely identity matrix +template +inline bool CMatrix4::getDefinitelyIdentityMatrix() const +{ +#if defined(USE_MATRIX_TEST) + return definitelyIdentityMatrix; +#else + return false; +#endif +} + +//! Compare two matrices using the equal method +template +inline bool CMatrix4::equals(const core::CMatrix4 &other, const T tolerance) const +{ +#if defined(USE_MATRIX_TEST) + if (definitelyIdentityMatrix && other.definitelyIdentityMatrix) + return true; +#endif + for (s32 i = 0; i < 16; ++i) + if (!core::equals(M[i], other.M[i], tolerance)) + return false; + + return true; +} + +// Multiply by scalar. +template +inline CMatrix4 operator*(const T scalar, const CMatrix4 &mat) +{ + return mat * scalar; +} + +//! Typedef for f32 matrix +typedef CMatrix4 matrix4; + +//! global const identity matrix +IRRLICHT_API extern const matrix4 IdentityMatrix; + +} // end namespace core +} // end namespace irr diff --git a/irr/include/mt_opengl.h b/irr/include/mt_opengl.h new file mode 100755 index 000000000..32d3f1c0a --- /dev/null +++ b/irr/include/mt_opengl.h @@ -0,0 +1,3195 @@ +// This code was generated by scripts/BindingGenerator.lua +// Do not modify it, modify and run the generator instead. + +#pragma once + +#include +#include +#include "IrrCompileConfig.h" // for IRRLICHT_API +#include "irrTypes.h" +#include "IContextManager.h" +#include + +#ifndef APIENTRY + #define APIENTRY KHRONOS_APIENTRY +#endif +#ifndef APIENTRYP + #define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI + #define GLAPI extern +#endif + +class OpenGLProcedures { +private: + // ./glcorearb.h + typedef void GLvoid; + typedef unsigned int GLenum; + typedef khronos_float_t GLfloat; + typedef int GLint; + typedef int GLsizei; + typedef unsigned int GLbitfield; + typedef double GLdouble; + typedef unsigned int GLuint; + typedef unsigned char GLboolean; + typedef khronos_uint8_t GLubyte; + typedef khronos_float_t GLclampf; + typedef double GLclampd; + typedef khronos_ssize_t GLsizeiptr; + typedef khronos_intptr_t GLintptr; + typedef char GLchar; + typedef khronos_int16_t GLshort; + typedef khronos_int8_t GLbyte; + typedef khronos_uint16_t GLushort; + typedef khronos_uint16_t GLhalf; + typedef struct __GLsync *GLsync; + typedef khronos_uint64_t GLuint64; + typedef khronos_int64_t GLint64; + typedef khronos_uint64_t GLuint64EXT; + typedef void *GLeglImageOES; + typedef khronos_int64_t GLint64EXT; + + typedef void *GLeglClientBufferEXT; + // The script will miss this particular typedef thinking it's a PFN, + // so we have to paste it in manually. It's the only such type in OpenGL. + typedef void (APIENTRY *GLDEBUGPROC) + (GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); + + typedef void (APIENTRYP PFNGLCULLFACEPROC_MT) (GLenum mode); + typedef void (APIENTRYP PFNGLFRONTFACEPROC_MT) (GLenum mode); + typedef void (APIENTRYP PFNGLHINTPROC_MT) (GLenum target, GLenum mode); + typedef void (APIENTRYP PFNGLLINEWIDTHPROC_MT) (GLfloat width); + typedef void (APIENTRYP PFNGLPOINTSIZEPROC_MT) (GLfloat size); + typedef void (APIENTRYP PFNGLPOLYGONMODEPROC_MT) (GLenum face, GLenum mode); + typedef void (APIENTRYP PFNGLSCISSORPROC_MT) (GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLTEXPARAMETERFPROC_MT) (GLenum target, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLTEXPARAMETERFVPROC_MT) (GLenum target, GLenum pname, const GLfloat * params); + typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC_MT) (GLenum target, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLTEXPARAMETERIVPROC_MT) (GLenum target, GLenum pname, const GLint * params); + typedef void (APIENTRYP PFNGLTEXIMAGE1DPROC_MT) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void * pixels); + typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC_MT) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels); + typedef void (APIENTRYP PFNGLDRAWBUFFERPROC_MT) (GLenum buf); + typedef void (APIENTRYP PFNGLCLEARPROC_MT) (GLbitfield mask); + typedef void (APIENTRYP PFNGLCLEARCOLORPROC_MT) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); + typedef void (APIENTRYP PFNGLCLEARSTENCILPROC_MT) (GLint s); + typedef void (APIENTRYP PFNGLCLEARDEPTHPROC_MT) (GLdouble depth); + typedef void (APIENTRYP PFNGLSTENCILMASKPROC_MT) (GLuint mask); + typedef void (APIENTRYP PFNGLCOLORMASKPROC_MT) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); + typedef void (APIENTRYP PFNGLDEPTHMASKPROC_MT) (GLboolean flag); + typedef void (APIENTRYP PFNGLDISABLEPROC_MT) (GLenum cap); + typedef void (APIENTRYP PFNGLENABLEPROC_MT) (GLenum cap); + typedef void (APIENTRYP PFNGLFINISHPROC_MT) ( void); + typedef void (APIENTRYP PFNGLFLUSHPROC_MT) ( void); + typedef void (APIENTRYP PFNGLBLENDFUNCPROC_MT) (GLenum sfactor, GLenum dfactor); + typedef void (APIENTRYP PFNGLLOGICOPPROC_MT) (GLenum opcode); + typedef void (APIENTRYP PFNGLSTENCILFUNCPROC_MT) (GLenum func, GLint ref, GLuint mask); + typedef void (APIENTRYP PFNGLSTENCILOPPROC_MT) (GLenum fail, GLenum zfail, GLenum zpass); + typedef void (APIENTRYP PFNGLDEPTHFUNCPROC_MT) (GLenum func); + typedef void (APIENTRYP PFNGLPIXELSTOREFPROC_MT) (GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLPIXELSTOREIPROC_MT) (GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLREADBUFFERPROC_MT) (GLenum src); + typedef void (APIENTRYP PFNGLREADPIXELSPROC_MT) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels); + typedef void (APIENTRYP PFNGLGETBOOLEANVPROC_MT) (GLenum pname, GLboolean * data); + typedef void (APIENTRYP PFNGLGETDOUBLEVPROC_MT) (GLenum pname, GLdouble * data); + typedef GLenum (APIENTRYP PFNGLGETERRORPROC_MT) ( void); + typedef void (APIENTRYP PFNGLGETFLOATVPROC_MT) (GLenum pname, GLfloat * data); + typedef void (APIENTRYP PFNGLGETINTEGERVPROC_MT) (GLenum pname, GLint * data); + typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGPROC_MT) (GLenum name); + typedef void (APIENTRYP PFNGLGETTEXIMAGEPROC_MT) (GLenum target, GLint level, GLenum format, GLenum type, void * pixels); + typedef void (APIENTRYP PFNGLGETTEXPARAMETERFVPROC_MT) (GLenum target, GLenum pname, GLfloat * params); + typedef void (APIENTRYP PFNGLGETTEXPARAMETERIVPROC_MT) (GLenum target, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC_MT) (GLenum target, GLint level, GLenum pname, GLfloat * params); + typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC_MT) (GLenum target, GLint level, GLenum pname, GLint * params); + typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC_MT) (GLenum cap); + typedef void (APIENTRYP PFNGLDEPTHRANGEPROC_MT) (GLdouble n, GLdouble f); + typedef void (APIENTRYP PFNGLVIEWPORTPROC_MT) (GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLDRAWARRAYSPROC_MT) (GLenum mode, GLint first, GLsizei count); + typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC_MT) (GLenum mode, GLsizei count, GLenum type, const void * indices); + typedef void (APIENTRYP PFNGLGETPOINTERVPROC_MT) (GLenum pname, void ** params); + typedef void (APIENTRYP PFNGLPOLYGONOFFSETPROC_MT) (GLfloat factor, GLfloat units); + typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DPROC_MT) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); + typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DPROC_MT) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); + typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DPROC_MT) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC_MT) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DPROC_MT) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void * pixels); + typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC_MT) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels); + typedef void (APIENTRYP PFNGLBINDTEXTUREPROC_MT) (GLenum target, GLuint texture); + typedef void (APIENTRYP PFNGLDELETETEXTURESPROC_MT) (GLsizei n, const GLuint * textures); + typedef void (APIENTRYP PFNGLGENTEXTURESPROC_MT) (GLsizei n, GLuint * textures); + typedef GLboolean (APIENTRYP PFNGLISTEXTUREPROC_MT) (GLuint texture); + typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC_MT) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices); + typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC_MT) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels); + typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC_MT) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels); + typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC_MT) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC_MT) (GLenum texture); + typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC_MT) (GLfloat value, GLboolean invert); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC_MT) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC_MT) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC_MT) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void * data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC_MT) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC_MT) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC_MT) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void * data); + typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC_MT) (GLenum target, GLint level, void * img); + typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC_MT) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); + typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC_MT) (GLenum mode, const GLint * first, const GLsizei * count, GLsizei drawcount); + typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC_MT) (GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount); + typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC_MT) (GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC_MT) (GLenum pname, const GLfloat * params); + typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC_MT) (GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC_MT) (GLenum pname, const GLint * params); + typedef void (APIENTRYP PFNGLBLENDCOLORPROC_MT) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); + typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC_MT) (GLenum mode); + typedef void (APIENTRYP PFNGLGENQUERIESPROC_MT) (GLsizei n, GLuint * ids); + typedef void (APIENTRYP PFNGLDELETEQUERIESPROC_MT) (GLsizei n, const GLuint * ids); + typedef GLboolean (APIENTRYP PFNGLISQUERYPROC_MT) (GLuint id); + typedef void (APIENTRYP PFNGLBEGINQUERYPROC_MT) (GLenum target, GLuint id); + typedef void (APIENTRYP PFNGLENDQUERYPROC_MT) (GLenum target); + typedef void (APIENTRYP PFNGLGETQUERYIVPROC_MT) (GLenum target, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC_MT) (GLuint id, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC_MT) (GLuint id, GLenum pname, GLuint * params); + typedef void (APIENTRYP PFNGLBINDBUFFERPROC_MT) (GLenum target, GLuint buffer); + typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC_MT) (GLsizei n, const GLuint * buffers); + typedef void (APIENTRYP PFNGLGENBUFFERSPROC_MT) (GLsizei n, GLuint * buffers); + typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC_MT) (GLuint buffer); + typedef void (APIENTRYP PFNGLBUFFERDATAPROC_MT) (GLenum target, GLsizeiptr size, const void * data, GLenum usage); + typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC_MT) (GLenum target, GLintptr offset, GLsizeiptr size, const void * data); + typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC_MT) (GLenum target, GLintptr offset, GLsizeiptr size, void * data); + typedef void * (APIENTRYP PFNGLMAPBUFFERPROC_MT) (GLenum target, GLenum access); + typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC_MT) (GLenum target); + typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC_MT) (GLenum target, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC_MT) (GLenum target, GLenum pname, void ** params); + typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC_MT) (GLenum modeRGB, GLenum modeAlpha); + typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC_MT) (GLsizei n, const GLenum * bufs); + typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC_MT) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); + typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC_MT) (GLenum face, GLenum func, GLint ref, GLuint mask); + typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC_MT) (GLenum face, GLuint mask); + typedef void (APIENTRYP PFNGLATTACHSHADERPROC_MT) (GLuint program, GLuint shader); + typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC_MT) (GLuint program, GLuint index, const GLchar * name); + typedef void (APIENTRYP PFNGLCOMPILESHADERPROC_MT) (GLuint shader); + typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC_MT) ( void); + typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC_MT) (GLenum type); + typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC_MT) (GLuint program); + typedef void (APIENTRYP PFNGLDELETESHADERPROC_MT) (GLuint shader); + typedef void (APIENTRYP PFNGLDETACHSHADERPROC_MT) (GLuint program, GLuint shader); + typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC_MT) (GLuint index); + typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC_MT) (GLuint index); + typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC_MT) (GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name); + typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC_MT) (GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name); + typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC_MT) (GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders); + typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC_MT) (GLuint program, const GLchar * name); + typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC_MT) (GLuint program, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC_MT) (GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog); + typedef void (APIENTRYP PFNGLGETSHADERIVPROC_MT) (GLuint shader, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC_MT) (GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog); + typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC_MT) (GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source); + typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC_MT) (GLuint program, const GLchar * name); + typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC_MT) (GLuint program, GLint location, GLfloat * params); + typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC_MT) (GLuint program, GLint location, GLint * params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC_MT) (GLuint index, GLenum pname, GLdouble * params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC_MT) (GLuint index, GLenum pname, GLfloat * params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC_MT) (GLuint index, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC_MT) (GLuint index, GLenum pname, void ** pointer); + typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC_MT) (GLuint program); + typedef GLboolean (APIENTRYP PFNGLISSHADERPROC_MT) (GLuint shader); + typedef void (APIENTRYP PFNGLLINKPROGRAMPROC_MT) (GLuint program); + typedef void (APIENTRYP PFNGLSHADERSOURCEPROC_MT) (GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length); + typedef void (APIENTRYP PFNGLUSEPROGRAMPROC_MT) (GLuint program); + typedef void (APIENTRYP PFNGLUNIFORM1FPROC_MT) (GLint location, GLfloat v0); + typedef void (APIENTRYP PFNGLUNIFORM2FPROC_MT) (GLint location, GLfloat v0, GLfloat v1); + typedef void (APIENTRYP PFNGLUNIFORM3FPROC_MT) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); + typedef void (APIENTRYP PFNGLUNIFORM4FPROC_MT) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + typedef void (APIENTRYP PFNGLUNIFORM1IPROC_MT) (GLint location, GLint v0); + typedef void (APIENTRYP PFNGLUNIFORM2IPROC_MT) (GLint location, GLint v0, GLint v1); + typedef void (APIENTRYP PFNGLUNIFORM3IPROC_MT) (GLint location, GLint v0, GLint v1, GLint v2); + typedef void (APIENTRYP PFNGLUNIFORM4IPROC_MT) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); + typedef void (APIENTRYP PFNGLUNIFORM1FVPROC_MT) (GLint location, GLsizei count, const GLfloat * value); + typedef void (APIENTRYP PFNGLUNIFORM2FVPROC_MT) (GLint location, GLsizei count, const GLfloat * value); + typedef void (APIENTRYP PFNGLUNIFORM3FVPROC_MT) (GLint location, GLsizei count, const GLfloat * value); + typedef void (APIENTRYP PFNGLUNIFORM4FVPROC_MT) (GLint location, GLsizei count, const GLfloat * value); + typedef void (APIENTRYP PFNGLUNIFORM1IVPROC_MT) (GLint location, GLsizei count, const GLint * value); + typedef void (APIENTRYP PFNGLUNIFORM2IVPROC_MT) (GLint location, GLsizei count, const GLint * value); + typedef void (APIENTRYP PFNGLUNIFORM3IVPROC_MT) (GLint location, GLsizei count, const GLint * value); + typedef void (APIENTRYP PFNGLUNIFORM4IVPROC_MT) (GLint location, GLsizei count, const GLint * value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC_MT) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC_MT) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC_MT) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); + typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC_MT) (GLuint program); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC_MT) (GLuint index, GLdouble x); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC_MT) (GLuint index, const GLdouble * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC_MT) (GLuint index, GLfloat x); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC_MT) (GLuint index, const GLfloat * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC_MT) (GLuint index, GLshort x); + typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC_MT) (GLuint index, const GLshort * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC_MT) (GLuint index, GLdouble x, GLdouble y); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC_MT) (GLuint index, const GLdouble * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC_MT) (GLuint index, GLfloat x, GLfloat y); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC_MT) (GLuint index, const GLfloat * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC_MT) (GLuint index, GLshort x, GLshort y); + typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC_MT) (GLuint index, const GLshort * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC_MT) (GLuint index, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC_MT) (GLuint index, const GLdouble * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC_MT) (GLuint index, GLfloat x, GLfloat y, GLfloat z); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC_MT) (GLuint index, const GLfloat * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC_MT) (GLuint index, GLshort x, GLshort y, GLshort z); + typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC_MT) (GLuint index, const GLshort * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC_MT) (GLuint index, const GLbyte * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC_MT) (GLuint index, const GLint * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC_MT) (GLuint index, const GLshort * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC_MT) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC_MT) (GLuint index, const GLubyte * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC_MT) (GLuint index, const GLuint * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC_MT) (GLuint index, const GLushort * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC_MT) (GLuint index, const GLbyte * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC_MT) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC_MT) (GLuint index, const GLdouble * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC_MT) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC_MT) (GLuint index, const GLfloat * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC_MT) (GLuint index, const GLint * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC_MT) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC_MT) (GLuint index, const GLshort * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC_MT) (GLuint index, const GLubyte * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC_MT) (GLuint index, const GLuint * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC_MT) (GLuint index, const GLushort * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC_MT) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC_MT) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC_MT) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC_MT) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC_MT) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC_MT) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC_MT) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); + typedef void (APIENTRYP PFNGLCOLORMASKIPROC_MT) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); + typedef void (APIENTRYP PFNGLENABLEIPROC_MT) (GLenum target, GLuint index); + typedef void (APIENTRYP PFNGLDISABLEIPROC_MT) (GLenum target, GLuint index); + typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC_MT) (GLenum target, GLuint index); + typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC_MT) (GLenum primitiveMode); + typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC_MT) ( void); + typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC_MT) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC_MT) (GLenum target, GLuint index, GLuint buffer); + typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC_MT) (GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode); + typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC_MT) (GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name); + typedef void (APIENTRYP PFNGLCLAMPCOLORPROC_MT) (GLenum target, GLenum clamp); + typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC_MT) (GLuint id, GLenum mode); + typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC_MT) ( void); + typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC_MT) (GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC_MT) (GLuint index, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC_MT) (GLuint index, GLenum pname, GLuint * params); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC_MT) (GLuint index, GLint x); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC_MT) (GLuint index, GLint x, GLint y); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC_MT) (GLuint index, GLint x, GLint y, GLint z); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC_MT) (GLuint index, GLint x, GLint y, GLint z, GLint w); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC_MT) (GLuint index, GLuint x); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC_MT) (GLuint index, GLuint x, GLuint y); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC_MT) (GLuint index, GLuint x, GLuint y, GLuint z); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC_MT) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC_MT) (GLuint index, const GLint * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC_MT) (GLuint index, const GLint * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC_MT) (GLuint index, const GLint * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC_MT) (GLuint index, const GLint * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC_MT) (GLuint index, const GLuint * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC_MT) (GLuint index, const GLuint * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC_MT) (GLuint index, const GLuint * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC_MT) (GLuint index, const GLuint * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC_MT) (GLuint index, const GLbyte * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC_MT) (GLuint index, const GLshort * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC_MT) (GLuint index, const GLubyte * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC_MT) (GLuint index, const GLushort * v); + typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC_MT) (GLuint program, GLint location, GLuint * params); + typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC_MT) (GLuint program, GLuint color, const GLchar * name); + typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC_MT) (GLuint program, const GLchar * name); + typedef void (APIENTRYP PFNGLUNIFORM1UIPROC_MT) (GLint location, GLuint v0); + typedef void (APIENTRYP PFNGLUNIFORM2UIPROC_MT) (GLint location, GLuint v0, GLuint v1); + typedef void (APIENTRYP PFNGLUNIFORM3UIPROC_MT) (GLint location, GLuint v0, GLuint v1, GLuint v2); + typedef void (APIENTRYP PFNGLUNIFORM4UIPROC_MT) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC_MT) (GLint location, GLsizei count, const GLuint * value); + typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC_MT) (GLint location, GLsizei count, const GLuint * value); + typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC_MT) (GLint location, GLsizei count, const GLuint * value); + typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC_MT) (GLint location, GLsizei count, const GLuint * value); + typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC_MT) (GLenum target, GLenum pname, const GLint * params); + typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC_MT) (GLenum target, GLenum pname, const GLuint * params); + typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC_MT) (GLenum target, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC_MT) (GLenum target, GLenum pname, GLuint * params); + typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC_MT) (GLenum buffer, GLint drawbuffer, const GLint * value); + typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC_MT) (GLenum buffer, GLint drawbuffer, const GLuint * value); + typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC_MT) (GLenum buffer, GLint drawbuffer, const GLfloat * value); + typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC_MT) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); + typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC_MT) (GLenum name, GLuint index); + typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC_MT) (GLuint renderbuffer); + typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC_MT) (GLenum target, GLuint renderbuffer); + typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC_MT) (GLsizei n, const GLuint * renderbuffers); + typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC_MT) (GLsizei n, GLuint * renderbuffers); + typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC_MT) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC_MT) (GLenum target, GLenum pname, GLint * params); + typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC_MT) (GLuint framebuffer); + typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC_MT) (GLenum target, GLuint framebuffer); + typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC_MT) (GLsizei n, const GLuint * framebuffers); + typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC_MT) (GLsizei n, GLuint * framebuffers); + typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC_MT) (GLenum target); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC_MT) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC_MT) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC_MT) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); + typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC_MT) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC_MT) (GLenum target, GLenum attachment, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC_MT) (GLenum target); + typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC_MT) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC_MT) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC_MT) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); + typedef void * (APIENTRYP PFNGLMAPBUFFERRANGEPROC_MT) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); + typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC_MT) (GLenum target, GLintptr offset, GLsizeiptr length); + typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC_MT) (GLuint array); + typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC_MT) (GLsizei n, const GLuint * arrays); + typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC_MT) (GLsizei n, GLuint * arrays); + typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC_MT) (GLuint array); + typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC_MT) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); + typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC_MT) (GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount); + typedef void (APIENTRYP PFNGLTEXBUFFERPROC_MT) (GLenum target, GLenum internalformat, GLuint buffer); + typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC_MT) (GLuint index); + typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC_MT) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC_MT) (GLuint program, GLsizei uniformCount, const GLchar *const* uniformNames, GLuint * uniformIndices); + typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC_MT) (GLuint program, GLsizei uniformCount, const GLuint * uniformIndices, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC_MT) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformName); + typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC_MT) (GLuint program, const GLchar * uniformBlockName); + typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC_MT) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC_MT) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformBlockName); + typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC_MT) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); + typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC_MT) (GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex); + typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC_MT) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices, GLint basevertex); + typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC_MT) (GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex); + typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC_MT) (GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount, const GLint * basevertex); + typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC_MT) (GLenum mode); + typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC_MT) (GLenum condition, GLbitfield flags); + typedef GLboolean (APIENTRYP PFNGLISSYNCPROC_MT) (GLsync sync); + typedef void (APIENTRYP PFNGLDELETESYNCPROC_MT) (GLsync sync); + typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC_MT) (GLsync sync, GLbitfield flags, GLuint64 timeout); + typedef void (APIENTRYP PFNGLWAITSYNCPROC_MT) (GLsync sync, GLbitfield flags, GLuint64 timeout); + typedef void (APIENTRYP PFNGLGETINTEGER64VPROC_MT) (GLenum pname, GLint64 * data); + typedef void (APIENTRYP PFNGLGETSYNCIVPROC_MT) (GLsync sync, GLenum pname, GLsizei count, GLsizei * length, GLint * values); + typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC_MT) (GLenum target, GLenum pname, GLint64 * params); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC_MT) (GLenum target, GLenum attachment, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC_MT) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC_MT) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC_MT) (GLenum pname, GLuint index, GLfloat * val); + typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC_MT) (GLuint maskNumber, GLbitfield mask); + typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC_MT) (GLuint program, GLuint colorNumber, GLuint index, const GLchar * name); + typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC_MT) (GLuint program, const GLchar * name); + typedef void (APIENTRYP PFNGLGENSAMPLERSPROC_MT) (GLsizei count, GLuint * samplers); + typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC_MT) (GLsizei count, const GLuint * samplers); + typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC_MT) (GLuint sampler); + typedef void (APIENTRYP PFNGLBINDSAMPLERPROC_MT) (GLuint unit, GLuint sampler); + typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC_MT) (GLuint sampler, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC_MT) (GLuint sampler, GLenum pname, const GLint * param); + typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC_MT) (GLuint sampler, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC_MT) (GLuint sampler, GLenum pname, const GLfloat * param); + typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC_MT) (GLuint sampler, GLenum pname, const GLint * param); + typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC_MT) (GLuint sampler, GLenum pname, const GLuint * param); + typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC_MT) (GLuint sampler, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC_MT) (GLuint sampler, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC_MT) (GLuint sampler, GLenum pname, GLfloat * params); + typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC_MT) (GLuint sampler, GLenum pname, GLuint * params); + typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC_MT) (GLuint id, GLenum target); + typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC_MT) (GLuint id, GLenum pname, GLint64 * params); + typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC_MT) (GLuint id, GLenum pname, GLuint64 * params); + typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC_MT) (GLuint index, GLuint divisor); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC_MT) (GLuint index, GLenum type, GLboolean normalized, GLuint value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC_MT) (GLuint index, GLenum type, GLboolean normalized, const GLuint * value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC_MT) (GLuint index, GLenum type, GLboolean normalized, GLuint value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC_MT) (GLuint index, GLenum type, GLboolean normalized, const GLuint * value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC_MT) (GLuint index, GLenum type, GLboolean normalized, GLuint value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC_MT) (GLuint index, GLenum type, GLboolean normalized, const GLuint * value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC_MT) (GLuint index, GLenum type, GLboolean normalized, GLuint value); + typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC_MT) (GLuint index, GLenum type, GLboolean normalized, const GLuint * value); + typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC_MT) (GLfloat value); + typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC_MT) (GLuint buf, GLenum mode); + typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC_MT) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); + typedef void (APIENTRYP PFNGLBLENDFUNCIPROC_MT) (GLuint buf, GLenum src, GLenum dst); + typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC_MT) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); + typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC_MT) (GLenum mode, const void * indirect); + typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC_MT) (GLenum mode, GLenum type, const void * indirect); + typedef void (APIENTRYP PFNGLUNIFORM1DPROC_MT) (GLint location, GLdouble x); + typedef void (APIENTRYP PFNGLUNIFORM2DPROC_MT) (GLint location, GLdouble x, GLdouble y); + typedef void (APIENTRYP PFNGLUNIFORM3DPROC_MT) (GLint location, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLUNIFORM4DPROC_MT) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLUNIFORM1DVPROC_MT) (GLint location, GLsizei count, const GLdouble * value); + typedef void (APIENTRYP PFNGLUNIFORM2DVPROC_MT) (GLint location, GLsizei count, const GLdouble * value); + typedef void (APIENTRYP PFNGLUNIFORM3DVPROC_MT) (GLint location, GLsizei count, const GLdouble * value); + typedef void (APIENTRYP PFNGLUNIFORM4DVPROC_MT) (GLint location, GLsizei count, const GLdouble * value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC_MT) (GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC_MT) (GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC_MT) (GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC_MT) (GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC_MT) (GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC_MT) (GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC_MT) (GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC_MT) (GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); + typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC_MT) (GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); + typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC_MT) (GLuint program, GLint location, GLdouble * params); + typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC_MT) (GLuint program, GLenum shadertype, const GLchar * name); + typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC_MT) (GLuint program, GLenum shadertype, const GLchar * name); + typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC_MT) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint * values); + typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC_MT) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei * length, GLchar * name); + typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC_MT) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei * length, GLchar * name); + typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC_MT) (GLenum shadertype, GLsizei count, const GLuint * indices); + typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC_MT) (GLenum shadertype, GLint location, GLuint * params); + typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC_MT) (GLuint program, GLenum shadertype, GLenum pname, GLint * values); + typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC_MT) (GLenum pname, GLint value); + typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC_MT) (GLenum pname, const GLfloat * values); + typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC_MT) (GLenum target, GLuint id); + typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC_MT) (GLsizei n, const GLuint * ids); + typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC_MT) (GLsizei n, GLuint * ids); + typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC_MT) (GLuint id); + typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC_MT) ( void); + typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC_MT) ( void); + typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC_MT) (GLenum mode, GLuint id); + typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC_MT) (GLenum mode, GLuint id, GLuint stream); + typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC_MT) (GLenum target, GLuint index, GLuint id); + typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC_MT) (GLenum target, GLuint index); + typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC_MT) (GLenum target, GLuint index, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC_MT) ( void); + typedef void (APIENTRYP PFNGLSHADERBINARYPROC_MT) (GLsizei count, const GLuint * shaders, GLenum binaryFormat, const void * binary, GLsizei length); + typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC_MT) (GLenum shadertype, GLenum precisiontype, GLint * range, GLint * precision); + typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC_MT) (GLfloat n, GLfloat f); + typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC_MT) (GLfloat d); + typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC_MT) (GLuint program, GLsizei bufSize, GLsizei * length, GLenum * binaryFormat, void * binary); + typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC_MT) (GLuint program, GLenum binaryFormat, const void * binary, GLsizei length); + typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC_MT) (GLuint program, GLenum pname, GLint value); + typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC_MT) (GLuint pipeline, GLbitfield stages, GLuint program); + typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC_MT) (GLuint pipeline, GLuint program); + typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC_MT) (GLenum type, GLsizei count, const GLchar *const* strings); + typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC_MT) (GLuint pipeline); + typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC_MT) (GLsizei n, const GLuint * pipelines); + typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC_MT) (GLsizei n, GLuint * pipelines); + typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC_MT) (GLuint pipeline); + typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC_MT) (GLuint pipeline, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC_MT) (GLuint program, GLint location, GLint v0); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC_MT) (GLuint program, GLint location, GLsizei count, const GLint * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC_MT) (GLuint program, GLint location, GLfloat v0); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC_MT) (GLuint program, GLint location, GLsizei count, const GLfloat * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC_MT) (GLuint program, GLint location, GLdouble v0); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC_MT) (GLuint program, GLint location, GLsizei count, const GLdouble * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC_MT) (GLuint program, GLint location, GLuint v0); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC_MT) (GLuint program, GLint location, GLsizei count, const GLuint * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC_MT) (GLuint program, GLint location, GLint v0, GLint v1); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC_MT) (GLuint program, GLint location, GLsizei count, const GLint * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC_MT) (GLuint program, GLint location, GLfloat v0, GLfloat v1); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC_MT) (GLuint program, GLint location, GLsizei count, const GLfloat * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC_MT) (GLuint program, GLint location, GLdouble v0, GLdouble v1); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC_MT) (GLuint program, GLint location, GLsizei count, const GLdouble * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC_MT) (GLuint program, GLint location, GLuint v0, GLuint v1); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC_MT) (GLuint program, GLint location, GLsizei count, const GLuint * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC_MT) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC_MT) (GLuint program, GLint location, GLsizei count, const GLint * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC_MT) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC_MT) (GLuint program, GLint location, GLsizei count, const GLfloat * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC_MT) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC_MT) (GLuint program, GLint location, GLsizei count, const GLdouble * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC_MT) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC_MT) (GLuint program, GLint location, GLsizei count, const GLuint * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC_MT) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC_MT) (GLuint program, GLint location, GLsizei count, const GLint * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC_MT) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC_MT) (GLuint program, GLint location, GLsizei count, const GLfloat * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC_MT) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC_MT) (GLuint program, GLint location, GLsizei count, const GLdouble * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC_MT) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC_MT) (GLuint program, GLint location, GLsizei count, const GLuint * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC_MT) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC_MT) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC_MT) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC_MT) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC_MT) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC_MT) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC_MT) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC_MT) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC_MT) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC_MT) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC_MT) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC_MT) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC_MT) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC_MT) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC_MT) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC_MT) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC_MT) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC_MT) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble * value); + typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC_MT) (GLuint pipeline); + typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC_MT) (GLuint pipeline, GLsizei bufSize, GLsizei * length, GLchar * infoLog); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC_MT) (GLuint index, GLdouble x); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC_MT) (GLuint index, GLdouble x, GLdouble y); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC_MT) (GLuint index, GLdouble x, GLdouble y, GLdouble z); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC_MT) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC_MT) (GLuint index, const GLdouble * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC_MT) (GLuint index, const GLdouble * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC_MT) (GLuint index, const GLdouble * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC_MT) (GLuint index, const GLdouble * v); + typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC_MT) (GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC_MT) (GLuint index, GLenum pname, GLdouble * params); + typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC_MT) (GLuint first, GLsizei count, const GLfloat * v); + typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC_MT) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); + typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC_MT) (GLuint index, const GLfloat * v); + typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC_MT) (GLuint first, GLsizei count, const GLint * v); + typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC_MT) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC_MT) (GLuint index, const GLint * v); + typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC_MT) (GLuint first, GLsizei count, const GLdouble * v); + typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC_MT) (GLuint index, GLdouble n, GLdouble f); + typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC_MT) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); + typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC_MT) (GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLuint baseinstance); + typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC_MT) (GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); + typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC_MT) (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint * params); + typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC_MT) (GLuint program, GLuint bufferIndex, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC_MT) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); + typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC_MT) (GLbitfield barriers); + typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC_MT) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); + typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC_MT) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC_MT) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); + typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC_MT) (GLenum mode, GLuint id, GLsizei instancecount); + typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC_MT) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); + typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC_MT) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void * data); + typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC_MT) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void * data); + typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC_MT) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); + typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC_MT) (GLintptr indirect); + typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC_MT) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); + typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC_MT) (GLenum target, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC_MT) (GLenum target, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC_MT) (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 * params); + typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC_MT) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); + typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC_MT) (GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC_MT) (GLuint buffer, GLintptr offset, GLsizeiptr length); + typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC_MT) (GLuint buffer); + typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC_MT) (GLenum target, GLsizei numAttachments, const GLenum * attachments); + typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC_MT) (GLenum target, GLsizei numAttachments, const GLenum * attachments, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC_MT) (GLenum mode, const void * indirect, GLsizei drawcount, GLsizei stride); + typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC_MT) (GLenum mode, GLenum type, const void * indirect, GLsizei drawcount, GLsizei stride); + typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC_MT) (GLuint program, GLenum programInterface, GLenum pname, GLint * params); + typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC_MT) (GLuint program, GLenum programInterface, const GLchar * name); + typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC_MT) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei * length, GLchar * name); + typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC_MT) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum * props, GLsizei count, GLsizei * length, GLint * params); + typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC_MT) (GLuint program, GLenum programInterface, const GLchar * name); + typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC_MT) (GLuint program, GLenum programInterface, const GLchar * name); + typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC_MT) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); + typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC_MT) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC_MT) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC_MT) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC_MT) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); + typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC_MT) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); + typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC_MT) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC_MT) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC_MT) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC_MT) (GLuint attribindex, GLuint bindingindex); + typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC_MT) (GLuint bindingindex, GLuint divisor); + typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC_MT) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint * ids, GLboolean enabled); + typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC_MT) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * buf); + typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC_MT) (GLDEBUGPROC callback, const void * userParam); + typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC_MT) (GLuint count, GLsizei bufSize, GLenum * sources, GLenum * types, GLuint * ids, GLenum * severities, GLsizei * lengths, GLchar * messageLog); + typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC_MT) (GLenum source, GLuint id, GLsizei length, const GLchar * message); + typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC_MT) ( void); + typedef void (APIENTRYP PFNGLOBJECTLABELPROC_MT) (GLenum identifier, GLuint name, GLsizei length, const GLchar * label); + typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC_MT) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei * length, GLchar * label); + typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC_MT) (const void * ptr, GLsizei length, const GLchar * label); + typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC_MT) (const void * ptr, GLsizei bufSize, GLsizei * length, GLchar * label); + typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC_MT) (GLenum target, GLsizeiptr size, const void * data, GLbitfield flags); + typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC_MT) (GLuint texture, GLint level, GLenum format, GLenum type, const void * data); + typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC_MT) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * data); + typedef void (APIENTRYP PFNGLBINDBUFFERSBASEPROC_MT) (GLenum target, GLuint first, GLsizei count, const GLuint * buffers); + typedef void (APIENTRYP PFNGLBINDBUFFERSRANGEPROC_MT) (GLenum target, GLuint first, GLsizei count, const GLuint * buffers, const GLintptr * offsets, const GLsizeiptr * sizes); + typedef void (APIENTRYP PFNGLBINDTEXTURESPROC_MT) (GLuint first, GLsizei count, const GLuint * textures); + typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC_MT) (GLuint first, GLsizei count, const GLuint * samplers); + typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC_MT) (GLuint first, GLsizei count, const GLuint * textures); + typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERSPROC_MT) (GLuint first, GLsizei count, const GLuint * buffers, const GLintptr * offsets, const GLsizei * strides); + typedef void (APIENTRYP PFNGLCLIPCONTROLPROC_MT) (GLenum origin, GLenum depth); + typedef void (APIENTRYP PFNGLCREATETRANSFORMFEEDBACKSPROC_MT) (GLsizei n, GLuint * ids); + typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC_MT) (GLuint xfb, GLuint index, GLuint buffer); + typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC_MT) (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKIVPROC_MT) (GLuint xfb, GLenum pname, GLint * param); + typedef void (APIENTRYP PFNGLCREATEBUFFERSPROC_MT) (GLsizei n, GLuint * buffers); + typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEPROC_MT) (GLuint buffer, GLsizeiptr size, const void * data, GLbitfield flags); + typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAPROC_MT) (GLuint buffer, GLsizeiptr size, const void * data, GLenum usage); + typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAPROC_MT) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void * data); + typedef void (APIENTRYP PFNGLCOPYNAMEDBUFFERSUBDATAPROC_MT) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAPROC_MT) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void * data); + typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAPROC_MT) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void * data); + typedef void * (APIENTRYP PFNGLMAPNAMEDBUFFERPROC_MT) (GLuint buffer, GLenum access); + typedef void * (APIENTRYP PFNGLMAPNAMEDBUFFERRANGEPROC_MT) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); + typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFERPROC_MT) (GLuint buffer); + typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC_MT) (GLuint buffer, GLintptr offset, GLsizeiptr length); + typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVPROC_MT) (GLuint buffer, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERI64VPROC_MT) (GLuint buffer, GLenum pname, GLint64 * params); + typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVPROC_MT) (GLuint buffer, GLenum pname, void ** params); + typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAPROC_MT) (GLuint buffer, GLintptr offset, GLsizeiptr size, void * data); + typedef void (APIENTRYP PFNGLCREATEFRAMEBUFFERSPROC_MT) (GLsizei n, GLuint * framebuffers); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC_MT) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC_MT) (GLuint framebuffer, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREPROC_MT) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC_MT) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC_MT) (GLuint framebuffer, GLenum buf); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC_MT) (GLuint framebuffer, GLsizei n, const GLenum * bufs); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC_MT) (GLuint framebuffer, GLenum src); + typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC_MT) (GLuint framebuffer, GLsizei numAttachments, const GLenum * attachments); + typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC_MT) (GLuint framebuffer, GLsizei numAttachments, const GLenum * attachments, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERIVPROC_MT) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint * value); + typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC_MT) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint * value); + typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFVPROC_MT) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat * value); + typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFIPROC_MT) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); + typedef void (APIENTRYP PFNGLBLITNAMEDFRAMEBUFFERPROC_MT) (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC_MT) (GLuint framebuffer, GLenum target); + typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC_MT) (GLuint framebuffer, GLenum pname, GLint * param); + typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC_MT) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLCREATERENDERBUFFERSPROC_MT) (GLsizei n, GLuint * renderbuffers); + typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEPROC_MT) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC_MT) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC_MT) (GLuint renderbuffer, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLCREATETEXTURESPROC_MT) (GLenum target, GLsizei n, GLuint * textures); + typedef void (APIENTRYP PFNGLTEXTUREBUFFERPROC_MT) (GLuint texture, GLenum internalformat, GLuint buffer); + typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEPROC_MT) (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DPROC_MT) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DPROC_MT) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DPROC_MT) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC_MT) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC_MT) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DPROC_MT) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void * pixels); + typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DPROC_MT) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels); + typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DPROC_MT) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC_MT) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void * data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC_MT) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data); + typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC_MT) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data); + typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DPROC_MT) (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DPROC_MT) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DPROC_MT) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFPROC_MT) (GLuint texture, GLenum pname, GLfloat param); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVPROC_MT) (GLuint texture, GLenum pname, const GLfloat * param); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIPROC_MT) (GLuint texture, GLenum pname, GLint param); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVPROC_MT) (GLuint texture, GLenum pname, const GLint * params); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVPROC_MT) (GLuint texture, GLenum pname, const GLuint * params); + typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVPROC_MT) (GLuint texture, GLenum pname, const GLint * param); + typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPPROC_MT) (GLuint texture); + typedef void (APIENTRYP PFNGLBINDTEXTUREUNITPROC_MT) (GLuint unit, GLuint texture); + typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEPROC_MT) (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void * pixels); + typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC_MT) (GLuint texture, GLint level, GLsizei bufSize, void * pixels); + typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVPROC_MT) (GLuint texture, GLint level, GLenum pname, GLfloat * params); + typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVPROC_MT) (GLuint texture, GLint level, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVPROC_MT) (GLuint texture, GLenum pname, GLfloat * params); + typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVPROC_MT) (GLuint texture, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVPROC_MT) (GLuint texture, GLenum pname, GLuint * params); + typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVPROC_MT) (GLuint texture, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLCREATEVERTEXARRAYSPROC_MT) (GLsizei n, GLuint * arrays); + typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBPROC_MT) (GLuint vaobj, GLuint index); + typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBPROC_MT) (GLuint vaobj, GLuint index); + typedef void (APIENTRYP PFNGLVERTEXARRAYELEMENTBUFFERPROC_MT) (GLuint vaobj, GLuint buffer); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERPROC_MT) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); + typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERSPROC_MT) (GLuint vaobj, GLuint first, GLsizei count, const GLuint * buffers, const GLintptr * offsets, const GLsizei * strides); + typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBBINDINGPROC_MT) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); + typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBFORMATPROC_MT) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBIFORMATPROC_MT) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBLFORMATPROC_MT) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (APIENTRYP PFNGLVERTEXARRAYBINDINGDIVISORPROC_MT) (GLuint vaobj, GLuint bindingindex, GLuint divisor); + typedef void (APIENTRYP PFNGLGETVERTEXARRAYIVPROC_MT) (GLuint vaobj, GLenum pname, GLint * param); + typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXEDIVPROC_MT) (GLuint vaobj, GLuint index, GLenum pname, GLint * param); + typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXED64IVPROC_MT) (GLuint vaobj, GLuint index, GLenum pname, GLint64 * param); + typedef void (APIENTRYP PFNGLCREATESAMPLERSPROC_MT) (GLsizei n, GLuint * samplers); + typedef void (APIENTRYP PFNGLCREATEPROGRAMPIPELINESPROC_MT) (GLsizei n, GLuint * pipelines); + typedef void (APIENTRYP PFNGLCREATEQUERIESPROC_MT) (GLenum target, GLsizei n, GLuint * ids); + typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTI64VPROC_MT) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); + typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTIVPROC_MT) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); + typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUI64VPROC_MT) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); + typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUIVPROC_MT) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); + typedef void (APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC_MT) (GLbitfield barriers); + typedef void (APIENTRYP PFNGLGETTEXTURESUBIMAGEPROC_MT) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void * pixels); + typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC_MT) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void * pixels); + typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSPROC_MT) ( void); + typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEPROC_MT) (GLenum target, GLint lod, GLsizei bufSize, void * pixels); + typedef void (APIENTRYP PFNGLGETNTEXIMAGEPROC_MT) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void * pixels); + typedef void (APIENTRYP PFNGLGETNUNIFORMDVPROC_MT) (GLuint program, GLint location, GLsizei bufSize, GLdouble * params); + typedef void (APIENTRYP PFNGLGETNUNIFORMFVPROC_MT) (GLuint program, GLint location, GLsizei bufSize, GLfloat * params); + typedef void (APIENTRYP PFNGLGETNUNIFORMIVPROC_MT) (GLuint program, GLint location, GLsizei bufSize, GLint * params); + typedef void (APIENTRYP PFNGLGETNUNIFORMUIVPROC_MT) (GLuint program, GLint location, GLsizei bufSize, GLuint * params); + typedef void (APIENTRYP PFNGLREADNPIXELSPROC_MT) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void * data); + typedef void (APIENTRYP PFNGLTEXTUREBARRIERPROC_MT) ( void); + typedef void (APIENTRYP PFNGLSPECIALIZESHADERPROC_MT) (GLuint shader, const GLchar * pEntryPoint, GLuint numSpecializationConstants, const GLuint * pConstantIndex, const GLuint * pConstantValue); + 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 PFNGLPOLYGONOFFSETCLAMPPROC_MT) (GLfloat factor, GLfloat units, GLfloat clamp); + 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 PFNGLGETTEXTURESAMPLERHANDLEPROC_MT) (GLuint texture, GLuint sampler); + typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTPROC_MT) (GLuint64 handle); + typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTPROC_MT) (GLuint64 handle); + typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLEPROC_MT) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); + typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTPROC_MT) (GLuint64 handle, GLenum access); + typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTPROC_MT) (GLuint64 handle); + typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64PROC_MT) (GLint location, GLuint64 value); + typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VPROC_MT) (GLint location, GLsizei count, const GLuint64 * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64PROC_MT) (GLuint program, GLint location, GLuint64 value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VPROC_MT) (GLuint program, GLint location, GLsizei count, const GLuint64 * values); + typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTPROC_MT) (GLuint64 handle); + typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTPROC_MT) (GLuint64 handle); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64PROC_MT) (GLuint index, GLuint64 x); + typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VPROC_MT) (GLuint index, const GLuint64 * v); + typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VPROC_MT) (GLuint index, GLenum pname, GLuint64 * params); + typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTPROC_MT) (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); + typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEGROUPSIZEPROC_MT) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); + typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEPROC_MT) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); + typedef void (APIENTRYP PFNGLUNIFORM1I64PROC_MT) (GLint location, GLint64 x); + typedef void (APIENTRYP PFNGLUNIFORM2I64PROC_MT) (GLint location, GLint64 x, GLint64 y); + typedef void (APIENTRYP PFNGLUNIFORM3I64PROC_MT) (GLint location, GLint64 x, GLint64 y, GLint64 z); + typedef void (APIENTRYP PFNGLUNIFORM4I64PROC_MT) (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); + typedef void (APIENTRYP PFNGLUNIFORM1I64VPROC_MT) (GLint location, GLsizei count, const GLint64 * value); + typedef void (APIENTRYP PFNGLUNIFORM2I64VPROC_MT) (GLint location, GLsizei count, const GLint64 * value); + typedef void (APIENTRYP PFNGLUNIFORM3I64VPROC_MT) (GLint location, GLsizei count, const GLint64 * value); + typedef void (APIENTRYP PFNGLUNIFORM4I64VPROC_MT) (GLint location, GLsizei count, const GLint64 * value); + typedef void (APIENTRYP PFNGLUNIFORM1UI64PROC_MT) (GLint location, GLuint64 x); + typedef void (APIENTRYP PFNGLUNIFORM2UI64PROC_MT) (GLint location, GLuint64 x, GLuint64 y); + typedef void (APIENTRYP PFNGLUNIFORM3UI64PROC_MT) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); + typedef void (APIENTRYP PFNGLUNIFORM4UI64PROC_MT) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); + typedef void (APIENTRYP PFNGLUNIFORM1UI64VPROC_MT) (GLint location, GLsizei count, const GLuint64 * value); + typedef void (APIENTRYP PFNGLUNIFORM2UI64VPROC_MT) (GLint location, GLsizei count, const GLuint64 * value); + typedef void (APIENTRYP PFNGLUNIFORM3UI64VPROC_MT) (GLint location, GLsizei count, const GLuint64 * value); + typedef void (APIENTRYP PFNGLUNIFORM4UI64VPROC_MT) (GLint location, GLsizei count, const GLuint64 * value); + typedef void (APIENTRYP PFNGLGETUNIFORMI64VPROC_MT) (GLuint program, GLint location, GLint64 * params); + typedef void (APIENTRYP PFNGLGETUNIFORMUI64VPROC_MT) (GLuint program, GLint location, GLuint64 * params); + typedef void (APIENTRYP PFNGLGETNUNIFORMI64VPROC_MT) (GLuint program, GLint location, GLsizei bufSize, GLint64 * params); + typedef void (APIENTRYP PFNGLGETNUNIFORMUI64VPROC_MT) (GLuint program, GLint location, GLsizei bufSize, GLuint64 * params); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64PROC_MT) (GLuint program, GLint location, GLint64 x); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64PROC_MT) (GLuint program, GLint location, GLint64 x, GLint64 y); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64PROC_MT) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64PROC_MT) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VPROC_MT) (GLuint program, GLint location, GLsizei count, const GLint64 * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VPROC_MT) (GLuint program, GLint location, GLsizei count, const GLint64 * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VPROC_MT) (GLuint program, GLint location, GLsizei count, const GLint64 * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VPROC_MT) (GLuint program, GLint location, GLsizei count, const GLint64 * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64PROC_MT) (GLuint program, GLint location, GLuint64 x); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64PROC_MT) (GLuint program, GLint location, GLuint64 x, GLuint64 y); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64PROC_MT) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64PROC_MT) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VPROC_MT) (GLuint program, GLint location, GLsizei count, const GLuint64 * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VPROC_MT) (GLuint program, GLint location, GLsizei count, const GLuint64 * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VPROC_MT) (GLuint program, GLint location, GLsizei count, const GLuint64 * value); + typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VPROC_MT) (GLuint program, GLint location, GLsizei count, const GLuint64 * value); + typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSPROC_MT) (GLuint count); + typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVPROC_MT) (GLenum target, GLuint start, GLsizei count, const GLfloat * v); + typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVPROC_MT) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat * v); + typedef void (APIENTRYP PFNGLEVALUATEDEPTHVALUESPROC_MT) ( void); + typedef void (APIENTRYP PFNGLNAMEDSTRINGPROC_MT) (GLenum type, GLint namelen, const GLchar * name, GLint stringlen, const GLchar * string); + typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGPROC_MT) (GLint namelen, const GLchar * name); + typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEPROC_MT) (GLuint shader, GLsizei count, const GLchar *const* path, const GLint * length); + typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGPROC_MT) (GLint namelen, const GLchar * name); + typedef void (APIENTRYP PFNGLGETNAMEDSTRINGPROC_MT) (GLint namelen, const GLchar * name, GLsizei bufSize, GLint * stringlen, GLchar * string); + typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVPROC_MT) (GLint namelen, const GLchar * name, GLenum pname, GLint * params); + typedef void (APIENTRYP PFNGLBUFFERPAGECOMMITMENTPROC_MT) (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); + typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTPROC_MT) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); + typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTPROC_MT) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); + + std::unordered_set extensions; +public: + // Call this once after creating the context. + void LoadAllProcedures(irr::video::IContextManager *cmgr); + // Check if an extension is supported. + inline bool IsExtensionPresent(const std::string &ext) const + { + return extensions.count(ext) > 0; + } + + PFNGLCULLFACEPROC_MT CullFace = NULL; + PFNGLFRONTFACEPROC_MT FrontFace = NULL; + PFNGLHINTPROC_MT Hint = NULL; + PFNGLLINEWIDTHPROC_MT LineWidth = NULL; + PFNGLPOINTSIZEPROC_MT PointSize = NULL; + PFNGLPOLYGONMODEPROC_MT PolygonMode = NULL; + PFNGLSCISSORPROC_MT Scissor = NULL; + PFNGLTEXPARAMETERFPROC_MT TexParameterf = NULL; + PFNGLTEXPARAMETERFVPROC_MT TexParameterfv = NULL; + PFNGLTEXPARAMETERIPROC_MT TexParameteri = NULL; + PFNGLTEXPARAMETERIVPROC_MT TexParameteriv = NULL; + PFNGLTEXIMAGE1DPROC_MT TexImage1D = NULL; + PFNGLTEXIMAGE2DPROC_MT TexImage2D = NULL; + PFNGLDRAWBUFFERPROC_MT DrawBuffer = NULL; + PFNGLCLEARPROC_MT Clear = NULL; + PFNGLCLEARCOLORPROC_MT ClearColor = NULL; + PFNGLCLEARSTENCILPROC_MT ClearStencil = NULL; + PFNGLCLEARDEPTHPROC_MT ClearDepth = NULL; + PFNGLSTENCILMASKPROC_MT StencilMask = NULL; + PFNGLCOLORMASKPROC_MT ColorMask = NULL; + PFNGLDEPTHMASKPROC_MT DepthMask = NULL; + PFNGLDISABLEPROC_MT Disable = NULL; + PFNGLENABLEPROC_MT Enable = NULL; + PFNGLFINISHPROC_MT Finish = NULL; + PFNGLFLUSHPROC_MT Flush = NULL; + PFNGLBLENDFUNCPROC_MT BlendFunc = NULL; + PFNGLLOGICOPPROC_MT LogicOp = NULL; + PFNGLSTENCILFUNCPROC_MT StencilFunc = NULL; + PFNGLSTENCILOPPROC_MT StencilOp = NULL; + PFNGLDEPTHFUNCPROC_MT DepthFunc = NULL; + PFNGLPIXELSTOREFPROC_MT PixelStoref = NULL; + PFNGLPIXELSTOREIPROC_MT PixelStorei = NULL; + PFNGLREADBUFFERPROC_MT ReadBuffer = NULL; + PFNGLREADPIXELSPROC_MT ReadPixels = NULL; + PFNGLGETBOOLEANVPROC_MT GetBooleanv = NULL; + PFNGLGETDOUBLEVPROC_MT GetDoublev = NULL; + PFNGLGETERRORPROC_MT GetError = NULL; + PFNGLGETFLOATVPROC_MT GetFloatv = NULL; + PFNGLGETINTEGERVPROC_MT GetIntegerv = NULL; + PFNGLGETSTRINGPROC_MT GetString = NULL; + PFNGLGETTEXIMAGEPROC_MT GetTexImage = NULL; + PFNGLGETTEXPARAMETERFVPROC_MT GetTexParameterfv = NULL; + PFNGLGETTEXPARAMETERIVPROC_MT GetTexParameteriv = NULL; + PFNGLGETTEXLEVELPARAMETERFVPROC_MT GetTexLevelParameterfv = NULL; + PFNGLGETTEXLEVELPARAMETERIVPROC_MT GetTexLevelParameteriv = NULL; + PFNGLISENABLEDPROC_MT IsEnabled = NULL; + PFNGLDEPTHRANGEPROC_MT DepthRange = NULL; + PFNGLVIEWPORTPROC_MT Viewport = NULL; + PFNGLDRAWARRAYSPROC_MT DrawArrays = NULL; + PFNGLDRAWELEMENTSPROC_MT DrawElements = NULL; + PFNGLGETPOINTERVPROC_MT GetPointerv = NULL; + PFNGLPOLYGONOFFSETPROC_MT PolygonOffset = NULL; + PFNGLCOPYTEXIMAGE1DPROC_MT CopyTexImage1D = NULL; + PFNGLCOPYTEXIMAGE2DPROC_MT CopyTexImage2D = NULL; + PFNGLCOPYTEXSUBIMAGE1DPROC_MT CopyTexSubImage1D = NULL; + PFNGLCOPYTEXSUBIMAGE2DPROC_MT CopyTexSubImage2D = NULL; + PFNGLTEXSUBIMAGE1DPROC_MT TexSubImage1D = NULL; + PFNGLTEXSUBIMAGE2DPROC_MT TexSubImage2D = NULL; + PFNGLBINDTEXTUREPROC_MT BindTexture = NULL; + PFNGLDELETETEXTURESPROC_MT DeleteTextures = NULL; + PFNGLGENTEXTURESPROC_MT GenTextures = NULL; + PFNGLISTEXTUREPROC_MT IsTexture = NULL; + PFNGLDRAWRANGEELEMENTSPROC_MT DrawRangeElements = NULL; + PFNGLTEXIMAGE3DPROC_MT TexImage3D = NULL; + PFNGLTEXSUBIMAGE3DPROC_MT TexSubImage3D = NULL; + PFNGLCOPYTEXSUBIMAGE3DPROC_MT CopyTexSubImage3D = NULL; + PFNGLACTIVETEXTUREPROC_MT ActiveTexture = NULL; + PFNGLSAMPLECOVERAGEPROC_MT SampleCoverage = NULL; + PFNGLCOMPRESSEDTEXIMAGE3DPROC_MT CompressedTexImage3D = NULL; + PFNGLCOMPRESSEDTEXIMAGE2DPROC_MT CompressedTexImage2D = NULL; + PFNGLCOMPRESSEDTEXIMAGE1DPROC_MT CompressedTexImage1D = NULL; + PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC_MT CompressedTexSubImage3D = NULL; + PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC_MT CompressedTexSubImage2D = NULL; + PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC_MT CompressedTexSubImage1D = NULL; + PFNGLGETCOMPRESSEDTEXIMAGEPROC_MT GetCompressedTexImage = NULL; + PFNGLBLENDFUNCSEPARATEPROC_MT BlendFuncSeparate = NULL; + PFNGLMULTIDRAWARRAYSPROC_MT MultiDrawArrays = NULL; + PFNGLMULTIDRAWELEMENTSPROC_MT MultiDrawElements = NULL; + PFNGLPOINTPARAMETERFPROC_MT PointParameterf = NULL; + PFNGLPOINTPARAMETERFVPROC_MT PointParameterfv = NULL; + PFNGLPOINTPARAMETERIPROC_MT PointParameteri = NULL; + PFNGLPOINTPARAMETERIVPROC_MT PointParameteriv = NULL; + PFNGLBLENDCOLORPROC_MT BlendColor = NULL; + PFNGLBLENDEQUATIONPROC_MT BlendEquation = NULL; + PFNGLGENQUERIESPROC_MT GenQueries = NULL; + PFNGLDELETEQUERIESPROC_MT DeleteQueries = NULL; + PFNGLISQUERYPROC_MT IsQuery = NULL; + PFNGLBEGINQUERYPROC_MT BeginQuery = NULL; + PFNGLENDQUERYPROC_MT EndQuery = NULL; + PFNGLGETQUERYIVPROC_MT GetQueryiv = NULL; + PFNGLGETQUERYOBJECTIVPROC_MT GetQueryObjectiv = NULL; + PFNGLGETQUERYOBJECTUIVPROC_MT GetQueryObjectuiv = NULL; + PFNGLBINDBUFFERPROC_MT BindBuffer = NULL; + PFNGLDELETEBUFFERSPROC_MT DeleteBuffers = NULL; + PFNGLGENBUFFERSPROC_MT GenBuffers = NULL; + PFNGLISBUFFERPROC_MT IsBuffer = NULL; + PFNGLBUFFERDATAPROC_MT BufferData = NULL; + PFNGLBUFFERSUBDATAPROC_MT BufferSubData = NULL; + PFNGLGETBUFFERSUBDATAPROC_MT GetBufferSubData = NULL; + PFNGLMAPBUFFERPROC_MT MapBuffer = NULL; + PFNGLUNMAPBUFFERPROC_MT UnmapBuffer = NULL; + PFNGLGETBUFFERPARAMETERIVPROC_MT GetBufferParameteriv = NULL; + PFNGLGETBUFFERPOINTERVPROC_MT GetBufferPointerv = NULL; + PFNGLBLENDEQUATIONSEPARATEPROC_MT BlendEquationSeparate = NULL; + PFNGLDRAWBUFFERSPROC_MT DrawBuffers = NULL; + PFNGLSTENCILOPSEPARATEPROC_MT StencilOpSeparate = NULL; + PFNGLSTENCILFUNCSEPARATEPROC_MT StencilFuncSeparate = NULL; + PFNGLSTENCILMASKSEPARATEPROC_MT StencilMaskSeparate = NULL; + PFNGLATTACHSHADERPROC_MT AttachShader = NULL; + PFNGLBINDATTRIBLOCATIONPROC_MT BindAttribLocation = NULL; + PFNGLCOMPILESHADERPROC_MT CompileShader = NULL; + PFNGLCREATEPROGRAMPROC_MT CreateProgram = NULL; + PFNGLCREATESHADERPROC_MT CreateShader = NULL; + PFNGLDELETEPROGRAMPROC_MT DeleteProgram = NULL; + PFNGLDELETESHADERPROC_MT DeleteShader = NULL; + PFNGLDETACHSHADERPROC_MT DetachShader = NULL; + PFNGLDISABLEVERTEXATTRIBARRAYPROC_MT DisableVertexAttribArray = NULL; + PFNGLENABLEVERTEXATTRIBARRAYPROC_MT EnableVertexAttribArray = NULL; + PFNGLGETACTIVEATTRIBPROC_MT GetActiveAttrib = NULL; + PFNGLGETACTIVEUNIFORMPROC_MT GetActiveUniform = NULL; + PFNGLGETATTACHEDSHADERSPROC_MT GetAttachedShaders = NULL; + PFNGLGETATTRIBLOCATIONPROC_MT GetAttribLocation = NULL; + PFNGLGETPROGRAMIVPROC_MT GetProgramiv = NULL; + PFNGLGETPROGRAMINFOLOGPROC_MT GetProgramInfoLog = NULL; + PFNGLGETSHADERIVPROC_MT GetShaderiv = NULL; + PFNGLGETSHADERINFOLOGPROC_MT GetShaderInfoLog = NULL; + PFNGLGETSHADERSOURCEPROC_MT GetShaderSource = NULL; + PFNGLGETUNIFORMLOCATIONPROC_MT GetUniformLocation = NULL; + PFNGLGETUNIFORMFVPROC_MT GetUniformfv = NULL; + PFNGLGETUNIFORMIVPROC_MT GetUniformiv = NULL; + PFNGLGETVERTEXATTRIBDVPROC_MT GetVertexAttribdv = NULL; + PFNGLGETVERTEXATTRIBFVPROC_MT GetVertexAttribfv = NULL; + PFNGLGETVERTEXATTRIBIVPROC_MT GetVertexAttribiv = NULL; + PFNGLGETVERTEXATTRIBPOINTERVPROC_MT GetVertexAttribPointerv = NULL; + PFNGLISPROGRAMPROC_MT IsProgram = NULL; + PFNGLISSHADERPROC_MT IsShader = NULL; + PFNGLLINKPROGRAMPROC_MT LinkProgram = NULL; + PFNGLSHADERSOURCEPROC_MT ShaderSource = NULL; + PFNGLUSEPROGRAMPROC_MT UseProgram = NULL; + PFNGLUNIFORM1FPROC_MT Uniform1f = NULL; + PFNGLUNIFORM2FPROC_MT Uniform2f = NULL; + PFNGLUNIFORM3FPROC_MT Uniform3f = NULL; + PFNGLUNIFORM4FPROC_MT Uniform4f = NULL; + PFNGLUNIFORM1IPROC_MT Uniform1i = NULL; + PFNGLUNIFORM2IPROC_MT Uniform2i = NULL; + PFNGLUNIFORM3IPROC_MT Uniform3i = NULL; + PFNGLUNIFORM4IPROC_MT Uniform4i = NULL; + PFNGLUNIFORM1FVPROC_MT Uniform1fv = NULL; + PFNGLUNIFORM2FVPROC_MT Uniform2fv = NULL; + PFNGLUNIFORM3FVPROC_MT Uniform3fv = NULL; + PFNGLUNIFORM4FVPROC_MT Uniform4fv = NULL; + PFNGLUNIFORM1IVPROC_MT Uniform1iv = NULL; + PFNGLUNIFORM2IVPROC_MT Uniform2iv = NULL; + PFNGLUNIFORM3IVPROC_MT Uniform3iv = NULL; + PFNGLUNIFORM4IVPROC_MT Uniform4iv = NULL; + PFNGLUNIFORMMATRIX2FVPROC_MT UniformMatrix2fv = NULL; + PFNGLUNIFORMMATRIX3FVPROC_MT UniformMatrix3fv = NULL; + PFNGLUNIFORMMATRIX4FVPROC_MT UniformMatrix4fv = NULL; + PFNGLVALIDATEPROGRAMPROC_MT ValidateProgram = NULL; + PFNGLVERTEXATTRIB1DPROC_MT VertexAttrib1d = NULL; + PFNGLVERTEXATTRIB1DVPROC_MT VertexAttrib1dv = NULL; + PFNGLVERTEXATTRIB1FPROC_MT VertexAttrib1f = NULL; + PFNGLVERTEXATTRIB1FVPROC_MT VertexAttrib1fv = NULL; + PFNGLVERTEXATTRIB1SPROC_MT VertexAttrib1s = NULL; + PFNGLVERTEXATTRIB1SVPROC_MT VertexAttrib1sv = NULL; + PFNGLVERTEXATTRIB2DPROC_MT VertexAttrib2d = NULL; + PFNGLVERTEXATTRIB2DVPROC_MT VertexAttrib2dv = NULL; + PFNGLVERTEXATTRIB2FPROC_MT VertexAttrib2f = NULL; + PFNGLVERTEXATTRIB2FVPROC_MT VertexAttrib2fv = NULL; + PFNGLVERTEXATTRIB2SPROC_MT VertexAttrib2s = NULL; + PFNGLVERTEXATTRIB2SVPROC_MT VertexAttrib2sv = NULL; + PFNGLVERTEXATTRIB3DPROC_MT VertexAttrib3d = NULL; + PFNGLVERTEXATTRIB3DVPROC_MT VertexAttrib3dv = NULL; + PFNGLVERTEXATTRIB3FPROC_MT VertexAttrib3f = NULL; + PFNGLVERTEXATTRIB3FVPROC_MT VertexAttrib3fv = NULL; + PFNGLVERTEXATTRIB3SPROC_MT VertexAttrib3s = NULL; + PFNGLVERTEXATTRIB3SVPROC_MT VertexAttrib3sv = NULL; + PFNGLVERTEXATTRIB4NBVPROC_MT VertexAttrib4Nbv = NULL; + PFNGLVERTEXATTRIB4NIVPROC_MT VertexAttrib4Niv = NULL; + PFNGLVERTEXATTRIB4NSVPROC_MT VertexAttrib4Nsv = NULL; + PFNGLVERTEXATTRIB4NUBPROC_MT VertexAttrib4Nub = NULL; + PFNGLVERTEXATTRIB4NUBVPROC_MT VertexAttrib4Nubv = NULL; + PFNGLVERTEXATTRIB4NUIVPROC_MT VertexAttrib4Nuiv = NULL; + PFNGLVERTEXATTRIB4NUSVPROC_MT VertexAttrib4Nusv = NULL; + PFNGLVERTEXATTRIB4BVPROC_MT VertexAttrib4bv = NULL; + PFNGLVERTEXATTRIB4DPROC_MT VertexAttrib4d = NULL; + PFNGLVERTEXATTRIB4DVPROC_MT VertexAttrib4dv = NULL; + PFNGLVERTEXATTRIB4FPROC_MT VertexAttrib4f = NULL; + PFNGLVERTEXATTRIB4FVPROC_MT VertexAttrib4fv = NULL; + PFNGLVERTEXATTRIB4IVPROC_MT VertexAttrib4iv = NULL; + PFNGLVERTEXATTRIB4SPROC_MT VertexAttrib4s = NULL; + PFNGLVERTEXATTRIB4SVPROC_MT VertexAttrib4sv = NULL; + PFNGLVERTEXATTRIB4UBVPROC_MT VertexAttrib4ubv = NULL; + PFNGLVERTEXATTRIB4UIVPROC_MT VertexAttrib4uiv = NULL; + PFNGLVERTEXATTRIB4USVPROC_MT VertexAttrib4usv = NULL; + PFNGLVERTEXATTRIBPOINTERPROC_MT VertexAttribPointer = NULL; + PFNGLUNIFORMMATRIX2X3FVPROC_MT UniformMatrix2x3fv = NULL; + PFNGLUNIFORMMATRIX3X2FVPROC_MT UniformMatrix3x2fv = NULL; + PFNGLUNIFORMMATRIX2X4FVPROC_MT UniformMatrix2x4fv = NULL; + PFNGLUNIFORMMATRIX4X2FVPROC_MT UniformMatrix4x2fv = NULL; + PFNGLUNIFORMMATRIX3X4FVPROC_MT UniformMatrix3x4fv = NULL; + PFNGLUNIFORMMATRIX4X3FVPROC_MT UniformMatrix4x3fv = NULL; + PFNGLCOLORMASKIPROC_MT ColorMaski = NULL; + PFNGLENABLEIPROC_MT Enablei = NULL; + PFNGLDISABLEIPROC_MT Disablei = NULL; + PFNGLISENABLEDIPROC_MT IsEnabledi = NULL; + PFNGLBEGINTRANSFORMFEEDBACKPROC_MT BeginTransformFeedback = NULL; + PFNGLENDTRANSFORMFEEDBACKPROC_MT EndTransformFeedback = NULL; + PFNGLBINDBUFFERRANGEPROC_MT BindBufferRange = NULL; + PFNGLBINDBUFFERBASEPROC_MT BindBufferBase = NULL; + PFNGLTRANSFORMFEEDBACKVARYINGSPROC_MT TransformFeedbackVaryings = NULL; + PFNGLGETTRANSFORMFEEDBACKVARYINGPROC_MT GetTransformFeedbackVarying = NULL; + PFNGLCLAMPCOLORPROC_MT ClampColor = NULL; + PFNGLBEGINCONDITIONALRENDERPROC_MT BeginConditionalRender = NULL; + PFNGLENDCONDITIONALRENDERPROC_MT EndConditionalRender = NULL; + PFNGLVERTEXATTRIBIPOINTERPROC_MT VertexAttribIPointer = NULL; + PFNGLGETVERTEXATTRIBIIVPROC_MT GetVertexAttribIiv = NULL; + PFNGLGETVERTEXATTRIBIUIVPROC_MT GetVertexAttribIuiv = NULL; + PFNGLVERTEXATTRIBI1IPROC_MT VertexAttribI1i = NULL; + PFNGLVERTEXATTRIBI2IPROC_MT VertexAttribI2i = NULL; + PFNGLVERTEXATTRIBI3IPROC_MT VertexAttribI3i = NULL; + PFNGLVERTEXATTRIBI4IPROC_MT VertexAttribI4i = NULL; + PFNGLVERTEXATTRIBI1UIPROC_MT VertexAttribI1ui = NULL; + PFNGLVERTEXATTRIBI2UIPROC_MT VertexAttribI2ui = NULL; + PFNGLVERTEXATTRIBI3UIPROC_MT VertexAttribI3ui = NULL; + PFNGLVERTEXATTRIBI4UIPROC_MT VertexAttribI4ui = NULL; + PFNGLVERTEXATTRIBI1IVPROC_MT VertexAttribI1iv = NULL; + PFNGLVERTEXATTRIBI2IVPROC_MT VertexAttribI2iv = NULL; + PFNGLVERTEXATTRIBI3IVPROC_MT VertexAttribI3iv = NULL; + PFNGLVERTEXATTRIBI4IVPROC_MT VertexAttribI4iv = NULL; + PFNGLVERTEXATTRIBI1UIVPROC_MT VertexAttribI1uiv = NULL; + PFNGLVERTEXATTRIBI2UIVPROC_MT VertexAttribI2uiv = NULL; + PFNGLVERTEXATTRIBI3UIVPROC_MT VertexAttribI3uiv = NULL; + PFNGLVERTEXATTRIBI4UIVPROC_MT VertexAttribI4uiv = NULL; + PFNGLVERTEXATTRIBI4BVPROC_MT VertexAttribI4bv = NULL; + PFNGLVERTEXATTRIBI4SVPROC_MT VertexAttribI4sv = NULL; + PFNGLVERTEXATTRIBI4UBVPROC_MT VertexAttribI4ubv = NULL; + PFNGLVERTEXATTRIBI4USVPROC_MT VertexAttribI4usv = NULL; + PFNGLGETUNIFORMUIVPROC_MT GetUniformuiv = NULL; + PFNGLBINDFRAGDATALOCATIONPROC_MT BindFragDataLocation = NULL; + PFNGLGETFRAGDATALOCATIONPROC_MT GetFragDataLocation = NULL; + PFNGLUNIFORM1UIPROC_MT Uniform1ui = NULL; + PFNGLUNIFORM2UIPROC_MT Uniform2ui = NULL; + PFNGLUNIFORM3UIPROC_MT Uniform3ui = NULL; + PFNGLUNIFORM4UIPROC_MT Uniform4ui = NULL; + PFNGLUNIFORM1UIVPROC_MT Uniform1uiv = NULL; + PFNGLUNIFORM2UIVPROC_MT Uniform2uiv = NULL; + PFNGLUNIFORM3UIVPROC_MT Uniform3uiv = NULL; + PFNGLUNIFORM4UIVPROC_MT Uniform4uiv = NULL; + PFNGLTEXPARAMETERIIVPROC_MT TexParameterIiv = NULL; + PFNGLTEXPARAMETERIUIVPROC_MT TexParameterIuiv = NULL; + PFNGLGETTEXPARAMETERIIVPROC_MT GetTexParameterIiv = NULL; + PFNGLGETTEXPARAMETERIUIVPROC_MT GetTexParameterIuiv = NULL; + PFNGLCLEARBUFFERIVPROC_MT ClearBufferiv = NULL; + PFNGLCLEARBUFFERUIVPROC_MT ClearBufferuiv = NULL; + PFNGLCLEARBUFFERFVPROC_MT ClearBufferfv = NULL; + PFNGLCLEARBUFFERFIPROC_MT ClearBufferfi = NULL; + PFNGLGETSTRINGIPROC_MT GetStringi = NULL; + PFNGLISRENDERBUFFERPROC_MT IsRenderbuffer = NULL; + PFNGLBINDRENDERBUFFERPROC_MT BindRenderbuffer = NULL; + PFNGLDELETERENDERBUFFERSPROC_MT DeleteRenderbuffers = NULL; + PFNGLGENRENDERBUFFERSPROC_MT GenRenderbuffers = NULL; + PFNGLRENDERBUFFERSTORAGEPROC_MT RenderbufferStorage = NULL; + PFNGLGETRENDERBUFFERPARAMETERIVPROC_MT GetRenderbufferParameteriv = NULL; + PFNGLISFRAMEBUFFERPROC_MT IsFramebuffer = NULL; + PFNGLBINDFRAMEBUFFERPROC_MT BindFramebuffer = NULL; + PFNGLDELETEFRAMEBUFFERSPROC_MT DeleteFramebuffers = NULL; + PFNGLGENFRAMEBUFFERSPROC_MT GenFramebuffers = NULL; + PFNGLCHECKFRAMEBUFFERSTATUSPROC_MT CheckFramebufferStatus = NULL; + PFNGLFRAMEBUFFERTEXTURE1DPROC_MT FramebufferTexture1D = NULL; + PFNGLFRAMEBUFFERTEXTURE2DPROC_MT FramebufferTexture2D = NULL; + PFNGLFRAMEBUFFERTEXTURE3DPROC_MT FramebufferTexture3D = NULL; + PFNGLFRAMEBUFFERRENDERBUFFERPROC_MT FramebufferRenderbuffer = NULL; + PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC_MT GetFramebufferAttachmentParameteriv = NULL; + PFNGLGENERATEMIPMAPPROC_MT GenerateMipmap = NULL; + PFNGLBLITFRAMEBUFFERPROC_MT BlitFramebuffer = NULL; + PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC_MT RenderbufferStorageMultisample = NULL; + PFNGLFRAMEBUFFERTEXTURELAYERPROC_MT FramebufferTextureLayer = NULL; + PFNGLMAPBUFFERRANGEPROC_MT MapBufferRange = NULL; + PFNGLFLUSHMAPPEDBUFFERRANGEPROC_MT FlushMappedBufferRange = NULL; + PFNGLBINDVERTEXARRAYPROC_MT BindVertexArray = NULL; + PFNGLDELETEVERTEXARRAYSPROC_MT DeleteVertexArrays = NULL; + PFNGLGENVERTEXARRAYSPROC_MT GenVertexArrays = NULL; + PFNGLISVERTEXARRAYPROC_MT IsVertexArray = NULL; + PFNGLDRAWARRAYSINSTANCEDPROC_MT DrawArraysInstanced = NULL; + PFNGLDRAWELEMENTSINSTANCEDPROC_MT DrawElementsInstanced = NULL; + PFNGLTEXBUFFERPROC_MT TexBuffer = NULL; + PFNGLPRIMITIVERESTARTINDEXPROC_MT PrimitiveRestartIndex = NULL; + PFNGLCOPYBUFFERSUBDATAPROC_MT CopyBufferSubData = NULL; + PFNGLGETUNIFORMINDICESPROC_MT GetUniformIndices = NULL; + PFNGLGETACTIVEUNIFORMSIVPROC_MT GetActiveUniformsiv = NULL; + PFNGLGETACTIVEUNIFORMNAMEPROC_MT GetActiveUniformName = NULL; + PFNGLGETUNIFORMBLOCKINDEXPROC_MT GetUniformBlockIndex = NULL; + PFNGLGETACTIVEUNIFORMBLOCKIVPROC_MT GetActiveUniformBlockiv = NULL; + PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC_MT GetActiveUniformBlockName = NULL; + PFNGLUNIFORMBLOCKBINDINGPROC_MT UniformBlockBinding = NULL; + PFNGLDRAWELEMENTSBASEVERTEXPROC_MT DrawElementsBaseVertex = NULL; + PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC_MT DrawRangeElementsBaseVertex = NULL; + PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC_MT DrawElementsInstancedBaseVertex = NULL; + PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC_MT MultiDrawElementsBaseVertex = NULL; + PFNGLPROVOKINGVERTEXPROC_MT ProvokingVertex = NULL; + PFNGLFENCESYNCPROC_MT FenceSync = NULL; + PFNGLISSYNCPROC_MT IsSync = NULL; + PFNGLDELETESYNCPROC_MT DeleteSync = NULL; + PFNGLCLIENTWAITSYNCPROC_MT ClientWaitSync = NULL; + PFNGLWAITSYNCPROC_MT WaitSync = NULL; + PFNGLGETINTEGER64VPROC_MT GetInteger64v = NULL; + PFNGLGETSYNCIVPROC_MT GetSynciv = NULL; + PFNGLGETBUFFERPARAMETERI64VPROC_MT GetBufferParameteri64v = NULL; + PFNGLFRAMEBUFFERTEXTUREPROC_MT FramebufferTexture = NULL; + PFNGLTEXIMAGE2DMULTISAMPLEPROC_MT TexImage2DMultisample = NULL; + PFNGLTEXIMAGE3DMULTISAMPLEPROC_MT TexImage3DMultisample = NULL; + PFNGLGETMULTISAMPLEFVPROC_MT GetMultisamplefv = NULL; + PFNGLSAMPLEMASKIPROC_MT SampleMaski = NULL; + PFNGLBINDFRAGDATALOCATIONINDEXEDPROC_MT BindFragDataLocationIndexed = NULL; + PFNGLGETFRAGDATAINDEXPROC_MT GetFragDataIndex = NULL; + PFNGLGENSAMPLERSPROC_MT GenSamplers = NULL; + PFNGLDELETESAMPLERSPROC_MT DeleteSamplers = NULL; + PFNGLISSAMPLERPROC_MT IsSampler = NULL; + PFNGLBINDSAMPLERPROC_MT BindSampler = NULL; + PFNGLSAMPLERPARAMETERIPROC_MT SamplerParameteri = NULL; + PFNGLSAMPLERPARAMETERIVPROC_MT SamplerParameteriv = NULL; + PFNGLSAMPLERPARAMETERFPROC_MT SamplerParameterf = NULL; + PFNGLSAMPLERPARAMETERFVPROC_MT SamplerParameterfv = NULL; + PFNGLSAMPLERPARAMETERIIVPROC_MT SamplerParameterIiv = NULL; + PFNGLSAMPLERPARAMETERIUIVPROC_MT SamplerParameterIuiv = NULL; + PFNGLGETSAMPLERPARAMETERIVPROC_MT GetSamplerParameteriv = NULL; + PFNGLGETSAMPLERPARAMETERIIVPROC_MT GetSamplerParameterIiv = NULL; + PFNGLGETSAMPLERPARAMETERFVPROC_MT GetSamplerParameterfv = NULL; + PFNGLGETSAMPLERPARAMETERIUIVPROC_MT GetSamplerParameterIuiv = NULL; + PFNGLQUERYCOUNTERPROC_MT QueryCounter = NULL; + PFNGLGETQUERYOBJECTI64VPROC_MT GetQueryObjecti64v = NULL; + PFNGLGETQUERYOBJECTUI64VPROC_MT GetQueryObjectui64v = NULL; + PFNGLVERTEXATTRIBDIVISORPROC_MT VertexAttribDivisor = NULL; + PFNGLVERTEXATTRIBP1UIPROC_MT VertexAttribP1ui = NULL; + PFNGLVERTEXATTRIBP1UIVPROC_MT VertexAttribP1uiv = NULL; + PFNGLVERTEXATTRIBP2UIPROC_MT VertexAttribP2ui = NULL; + PFNGLVERTEXATTRIBP2UIVPROC_MT VertexAttribP2uiv = NULL; + PFNGLVERTEXATTRIBP3UIPROC_MT VertexAttribP3ui = NULL; + PFNGLVERTEXATTRIBP3UIVPROC_MT VertexAttribP3uiv = NULL; + PFNGLVERTEXATTRIBP4UIPROC_MT VertexAttribP4ui = NULL; + PFNGLVERTEXATTRIBP4UIVPROC_MT VertexAttribP4uiv = NULL; + PFNGLMINSAMPLESHADINGPROC_MT MinSampleShading = NULL; + PFNGLBLENDEQUATIONIPROC_MT BlendEquationi = NULL; + PFNGLBLENDEQUATIONSEPARATEIPROC_MT BlendEquationSeparatei = NULL; + PFNGLBLENDFUNCIPROC_MT BlendFunci = NULL; + PFNGLBLENDFUNCSEPARATEIPROC_MT BlendFuncSeparatei = NULL; + PFNGLDRAWARRAYSINDIRECTPROC_MT DrawArraysIndirect = NULL; + PFNGLDRAWELEMENTSINDIRECTPROC_MT DrawElementsIndirect = NULL; + PFNGLUNIFORM1DPROC_MT Uniform1d = NULL; + PFNGLUNIFORM2DPROC_MT Uniform2d = NULL; + PFNGLUNIFORM3DPROC_MT Uniform3d = NULL; + PFNGLUNIFORM4DPROC_MT Uniform4d = NULL; + PFNGLUNIFORM1DVPROC_MT Uniform1dv = NULL; + PFNGLUNIFORM2DVPROC_MT Uniform2dv = NULL; + PFNGLUNIFORM3DVPROC_MT Uniform3dv = NULL; + PFNGLUNIFORM4DVPROC_MT Uniform4dv = NULL; + PFNGLUNIFORMMATRIX2DVPROC_MT UniformMatrix2dv = NULL; + PFNGLUNIFORMMATRIX3DVPROC_MT UniformMatrix3dv = NULL; + PFNGLUNIFORMMATRIX4DVPROC_MT UniformMatrix4dv = NULL; + PFNGLUNIFORMMATRIX2X3DVPROC_MT UniformMatrix2x3dv = NULL; + PFNGLUNIFORMMATRIX2X4DVPROC_MT UniformMatrix2x4dv = NULL; + PFNGLUNIFORMMATRIX3X2DVPROC_MT UniformMatrix3x2dv = NULL; + PFNGLUNIFORMMATRIX3X4DVPROC_MT UniformMatrix3x4dv = NULL; + PFNGLUNIFORMMATRIX4X2DVPROC_MT UniformMatrix4x2dv = NULL; + PFNGLUNIFORMMATRIX4X3DVPROC_MT UniformMatrix4x3dv = NULL; + PFNGLGETUNIFORMDVPROC_MT GetUniformdv = NULL; + PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC_MT GetSubroutineUniformLocation = NULL; + PFNGLGETSUBROUTINEINDEXPROC_MT GetSubroutineIndex = NULL; + PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC_MT GetActiveSubroutineUniformiv = NULL; + PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC_MT GetActiveSubroutineUniformName = NULL; + PFNGLGETACTIVESUBROUTINENAMEPROC_MT GetActiveSubroutineName = NULL; + PFNGLUNIFORMSUBROUTINESUIVPROC_MT UniformSubroutinesuiv = NULL; + PFNGLGETUNIFORMSUBROUTINEUIVPROC_MT GetUniformSubroutineuiv = NULL; + PFNGLGETPROGRAMSTAGEIVPROC_MT GetProgramStageiv = NULL; + PFNGLPATCHPARAMETERIPROC_MT PatchParameteri = NULL; + PFNGLPATCHPARAMETERFVPROC_MT PatchParameterfv = NULL; + PFNGLBINDTRANSFORMFEEDBACKPROC_MT BindTransformFeedback = NULL; + PFNGLDELETETRANSFORMFEEDBACKSPROC_MT DeleteTransformFeedbacks = NULL; + PFNGLGENTRANSFORMFEEDBACKSPROC_MT GenTransformFeedbacks = NULL; + PFNGLISTRANSFORMFEEDBACKPROC_MT IsTransformFeedback = NULL; + PFNGLPAUSETRANSFORMFEEDBACKPROC_MT PauseTransformFeedback = NULL; + PFNGLRESUMETRANSFORMFEEDBACKPROC_MT ResumeTransformFeedback = NULL; + PFNGLDRAWTRANSFORMFEEDBACKPROC_MT DrawTransformFeedback = NULL; + PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC_MT DrawTransformFeedbackStream = NULL; + PFNGLBEGINQUERYINDEXEDPROC_MT BeginQueryIndexed = NULL; + PFNGLENDQUERYINDEXEDPROC_MT EndQueryIndexed = NULL; + PFNGLGETQUERYINDEXEDIVPROC_MT GetQueryIndexediv = NULL; + PFNGLRELEASESHADERCOMPILERPROC_MT ReleaseShaderCompiler = NULL; + PFNGLSHADERBINARYPROC_MT ShaderBinary = NULL; + PFNGLGETSHADERPRECISIONFORMATPROC_MT GetShaderPrecisionFormat = NULL; + PFNGLDEPTHRANGEFPROC_MT DepthRangef = NULL; + PFNGLCLEARDEPTHFPROC_MT ClearDepthf = NULL; + PFNGLGETPROGRAMBINARYPROC_MT GetProgramBinary = NULL; + PFNGLPROGRAMBINARYPROC_MT ProgramBinary = NULL; + PFNGLPROGRAMPARAMETERIPROC_MT ProgramParameteri = NULL; + PFNGLUSEPROGRAMSTAGESPROC_MT UseProgramStages = NULL; + PFNGLACTIVESHADERPROGRAMPROC_MT ActiveShaderProgram = NULL; + PFNGLCREATESHADERPROGRAMVPROC_MT CreateShaderProgramv = NULL; + PFNGLBINDPROGRAMPIPELINEPROC_MT BindProgramPipeline = NULL; + PFNGLDELETEPROGRAMPIPELINESPROC_MT DeleteProgramPipelines = NULL; + PFNGLGENPROGRAMPIPELINESPROC_MT GenProgramPipelines = NULL; + PFNGLISPROGRAMPIPELINEPROC_MT IsProgramPipeline = NULL; + PFNGLGETPROGRAMPIPELINEIVPROC_MT GetProgramPipelineiv = NULL; + PFNGLPROGRAMUNIFORM1IPROC_MT ProgramUniform1i = NULL; + PFNGLPROGRAMUNIFORM1IVPROC_MT ProgramUniform1iv = NULL; + PFNGLPROGRAMUNIFORM1FPROC_MT ProgramUniform1f = NULL; + PFNGLPROGRAMUNIFORM1FVPROC_MT ProgramUniform1fv = NULL; + PFNGLPROGRAMUNIFORM1DPROC_MT ProgramUniform1d = NULL; + PFNGLPROGRAMUNIFORM1DVPROC_MT ProgramUniform1dv = NULL; + PFNGLPROGRAMUNIFORM1UIPROC_MT ProgramUniform1ui = NULL; + PFNGLPROGRAMUNIFORM1UIVPROC_MT ProgramUniform1uiv = NULL; + PFNGLPROGRAMUNIFORM2IPROC_MT ProgramUniform2i = NULL; + PFNGLPROGRAMUNIFORM2IVPROC_MT ProgramUniform2iv = NULL; + PFNGLPROGRAMUNIFORM2FPROC_MT ProgramUniform2f = NULL; + PFNGLPROGRAMUNIFORM2FVPROC_MT ProgramUniform2fv = NULL; + PFNGLPROGRAMUNIFORM2DPROC_MT ProgramUniform2d = NULL; + PFNGLPROGRAMUNIFORM2DVPROC_MT ProgramUniform2dv = NULL; + PFNGLPROGRAMUNIFORM2UIPROC_MT ProgramUniform2ui = NULL; + PFNGLPROGRAMUNIFORM2UIVPROC_MT ProgramUniform2uiv = NULL; + PFNGLPROGRAMUNIFORM3IPROC_MT ProgramUniform3i = NULL; + PFNGLPROGRAMUNIFORM3IVPROC_MT ProgramUniform3iv = NULL; + PFNGLPROGRAMUNIFORM3FPROC_MT ProgramUniform3f = NULL; + PFNGLPROGRAMUNIFORM3FVPROC_MT ProgramUniform3fv = NULL; + PFNGLPROGRAMUNIFORM3DPROC_MT ProgramUniform3d = NULL; + PFNGLPROGRAMUNIFORM3DVPROC_MT ProgramUniform3dv = NULL; + PFNGLPROGRAMUNIFORM3UIPROC_MT ProgramUniform3ui = NULL; + PFNGLPROGRAMUNIFORM3UIVPROC_MT ProgramUniform3uiv = NULL; + PFNGLPROGRAMUNIFORM4IPROC_MT ProgramUniform4i = NULL; + PFNGLPROGRAMUNIFORM4IVPROC_MT ProgramUniform4iv = NULL; + PFNGLPROGRAMUNIFORM4FPROC_MT ProgramUniform4f = NULL; + PFNGLPROGRAMUNIFORM4FVPROC_MT ProgramUniform4fv = NULL; + PFNGLPROGRAMUNIFORM4DPROC_MT ProgramUniform4d = NULL; + PFNGLPROGRAMUNIFORM4DVPROC_MT ProgramUniform4dv = NULL; + PFNGLPROGRAMUNIFORM4UIPROC_MT ProgramUniform4ui = NULL; + PFNGLPROGRAMUNIFORM4UIVPROC_MT ProgramUniform4uiv = NULL; + PFNGLPROGRAMUNIFORMMATRIX2FVPROC_MT ProgramUniformMatrix2fv = NULL; + PFNGLPROGRAMUNIFORMMATRIX3FVPROC_MT ProgramUniformMatrix3fv = NULL; + PFNGLPROGRAMUNIFORMMATRIX4FVPROC_MT ProgramUniformMatrix4fv = NULL; + PFNGLPROGRAMUNIFORMMATRIX2DVPROC_MT ProgramUniformMatrix2dv = NULL; + PFNGLPROGRAMUNIFORMMATRIX3DVPROC_MT ProgramUniformMatrix3dv = NULL; + PFNGLPROGRAMUNIFORMMATRIX4DVPROC_MT ProgramUniformMatrix4dv = NULL; + PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC_MT ProgramUniformMatrix2x3fv = NULL; + PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC_MT ProgramUniformMatrix3x2fv = NULL; + PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC_MT ProgramUniformMatrix2x4fv = NULL; + PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC_MT ProgramUniformMatrix4x2fv = NULL; + PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC_MT ProgramUniformMatrix3x4fv = NULL; + PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC_MT ProgramUniformMatrix4x3fv = NULL; + PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC_MT ProgramUniformMatrix2x3dv = NULL; + PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC_MT ProgramUniformMatrix3x2dv = NULL; + PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC_MT ProgramUniformMatrix2x4dv = NULL; + PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC_MT ProgramUniformMatrix4x2dv = NULL; + PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC_MT ProgramUniformMatrix3x4dv = NULL; + PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC_MT ProgramUniformMatrix4x3dv = NULL; + PFNGLVALIDATEPROGRAMPIPELINEPROC_MT ValidateProgramPipeline = NULL; + PFNGLGETPROGRAMPIPELINEINFOLOGPROC_MT GetProgramPipelineInfoLog = NULL; + PFNGLVERTEXATTRIBL1DPROC_MT VertexAttribL1d = NULL; + PFNGLVERTEXATTRIBL2DPROC_MT VertexAttribL2d = NULL; + PFNGLVERTEXATTRIBL3DPROC_MT VertexAttribL3d = NULL; + PFNGLVERTEXATTRIBL4DPROC_MT VertexAttribL4d = NULL; + PFNGLVERTEXATTRIBL1DVPROC_MT VertexAttribL1dv = NULL; + PFNGLVERTEXATTRIBL2DVPROC_MT VertexAttribL2dv = NULL; + PFNGLVERTEXATTRIBL3DVPROC_MT VertexAttribL3dv = NULL; + PFNGLVERTEXATTRIBL4DVPROC_MT VertexAttribL4dv = NULL; + PFNGLVERTEXATTRIBLPOINTERPROC_MT VertexAttribLPointer = NULL; + PFNGLGETVERTEXATTRIBLDVPROC_MT GetVertexAttribLdv = NULL; + PFNGLVIEWPORTARRAYVPROC_MT ViewportArrayv = NULL; + PFNGLVIEWPORTINDEXEDFPROC_MT ViewportIndexedf = NULL; + PFNGLVIEWPORTINDEXEDFVPROC_MT ViewportIndexedfv = NULL; + PFNGLSCISSORARRAYVPROC_MT ScissorArrayv = NULL; + PFNGLSCISSORINDEXEDPROC_MT ScissorIndexed = NULL; + PFNGLSCISSORINDEXEDVPROC_MT ScissorIndexedv = NULL; + PFNGLDEPTHRANGEARRAYVPROC_MT DepthRangeArrayv = NULL; + PFNGLDEPTHRANGEINDEXEDPROC_MT DepthRangeIndexed = NULL; + PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC_MT DrawArraysInstancedBaseInstance = NULL; + PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC_MT DrawElementsInstancedBaseInstance = NULL; + PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC_MT DrawElementsInstancedBaseVertexBaseInstance = NULL; + PFNGLGETINTERNALFORMATIVPROC_MT GetInternalformativ = NULL; + PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC_MT GetActiveAtomicCounterBufferiv = NULL; + PFNGLBINDIMAGETEXTUREPROC_MT BindImageTexture = NULL; + PFNGLMEMORYBARRIERPROC_MT MemoryBarrier = NULL; + PFNGLTEXSTORAGE1DPROC_MT TexStorage1D = NULL; + PFNGLTEXSTORAGE2DPROC_MT TexStorage2D = NULL; + PFNGLTEXSTORAGE3DPROC_MT TexStorage3D = NULL; + PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC_MT DrawTransformFeedbackInstanced = NULL; + PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC_MT DrawTransformFeedbackStreamInstanced = NULL; + PFNGLCLEARBUFFERDATAPROC_MT ClearBufferData = NULL; + PFNGLCLEARBUFFERSUBDATAPROC_MT ClearBufferSubData = NULL; + PFNGLDISPATCHCOMPUTEPROC_MT DispatchCompute = NULL; + PFNGLDISPATCHCOMPUTEINDIRECTPROC_MT DispatchComputeIndirect = NULL; + PFNGLCOPYIMAGESUBDATAPROC_MT CopyImageSubData = NULL; + PFNGLFRAMEBUFFERPARAMETERIPROC_MT FramebufferParameteri = NULL; + PFNGLGETFRAMEBUFFERPARAMETERIVPROC_MT GetFramebufferParameteriv = NULL; + PFNGLGETINTERNALFORMATI64VPROC_MT GetInternalformati64v = NULL; + PFNGLINVALIDATETEXSUBIMAGEPROC_MT InvalidateTexSubImage = NULL; + PFNGLINVALIDATETEXIMAGEPROC_MT InvalidateTexImage = NULL; + PFNGLINVALIDATEBUFFERSUBDATAPROC_MT InvalidateBufferSubData = NULL; + PFNGLINVALIDATEBUFFERDATAPROC_MT InvalidateBufferData = NULL; + PFNGLINVALIDATEFRAMEBUFFERPROC_MT InvalidateFramebuffer = NULL; + PFNGLINVALIDATESUBFRAMEBUFFERPROC_MT InvalidateSubFramebuffer = NULL; + PFNGLMULTIDRAWARRAYSINDIRECTPROC_MT MultiDrawArraysIndirect = NULL; + PFNGLMULTIDRAWELEMENTSINDIRECTPROC_MT MultiDrawElementsIndirect = NULL; + PFNGLGETPROGRAMINTERFACEIVPROC_MT GetProgramInterfaceiv = NULL; + PFNGLGETPROGRAMRESOURCEINDEXPROC_MT GetProgramResourceIndex = NULL; + PFNGLGETPROGRAMRESOURCENAMEPROC_MT GetProgramResourceName = NULL; + PFNGLGETPROGRAMRESOURCEIVPROC_MT GetProgramResourceiv = NULL; + PFNGLGETPROGRAMRESOURCELOCATIONPROC_MT GetProgramResourceLocation = NULL; + PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC_MT GetProgramResourceLocationIndex = NULL; + PFNGLSHADERSTORAGEBLOCKBINDINGPROC_MT ShaderStorageBlockBinding = NULL; + PFNGLTEXBUFFERRANGEPROC_MT TexBufferRange = NULL; + PFNGLTEXSTORAGE2DMULTISAMPLEPROC_MT TexStorage2DMultisample = NULL; + PFNGLTEXSTORAGE3DMULTISAMPLEPROC_MT TexStorage3DMultisample = NULL; + PFNGLTEXTUREVIEWPROC_MT TextureView = NULL; + PFNGLBINDVERTEXBUFFERPROC_MT BindVertexBuffer = NULL; + PFNGLVERTEXATTRIBFORMATPROC_MT VertexAttribFormat = NULL; + PFNGLVERTEXATTRIBIFORMATPROC_MT VertexAttribIFormat = NULL; + PFNGLVERTEXATTRIBLFORMATPROC_MT VertexAttribLFormat = NULL; + PFNGLVERTEXATTRIBBINDINGPROC_MT VertexAttribBinding = NULL; + PFNGLVERTEXBINDINGDIVISORPROC_MT VertexBindingDivisor = NULL; + PFNGLDEBUGMESSAGECONTROLPROC_MT DebugMessageControl = NULL; + PFNGLDEBUGMESSAGEINSERTPROC_MT DebugMessageInsert = NULL; + PFNGLDEBUGMESSAGECALLBACKPROC_MT DebugMessageCallback = NULL; + PFNGLGETDEBUGMESSAGELOGPROC_MT GetDebugMessageLog = NULL; + PFNGLPUSHDEBUGGROUPPROC_MT PushDebugGroup = NULL; + PFNGLPOPDEBUGGROUPPROC_MT PopDebugGroup = NULL; + PFNGLOBJECTLABELPROC_MT ObjectLabel = NULL; + PFNGLGETOBJECTLABELPROC_MT GetObjectLabel = NULL; + PFNGLOBJECTPTRLABELPROC_MT ObjectPtrLabel = NULL; + PFNGLGETOBJECTPTRLABELPROC_MT GetObjectPtrLabel = NULL; + PFNGLBUFFERSTORAGEPROC_MT BufferStorage = NULL; + PFNGLCLEARTEXIMAGEPROC_MT ClearTexImage = NULL; + PFNGLCLEARTEXSUBIMAGEPROC_MT ClearTexSubImage = NULL; + PFNGLBINDBUFFERSBASEPROC_MT BindBuffersBase = NULL; + PFNGLBINDBUFFERSRANGEPROC_MT BindBuffersRange = NULL; + PFNGLBINDTEXTURESPROC_MT BindTextures = NULL; + PFNGLBINDSAMPLERSPROC_MT BindSamplers = NULL; + PFNGLBINDIMAGETEXTURESPROC_MT BindImageTextures = NULL; + PFNGLBINDVERTEXBUFFERSPROC_MT BindVertexBuffers = NULL; + PFNGLCLIPCONTROLPROC_MT ClipControl = NULL; + PFNGLCREATETRANSFORMFEEDBACKSPROC_MT CreateTransformFeedbacks = NULL; + PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC_MT TransformFeedbackBufferBase = NULL; + PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC_MT TransformFeedbackBufferRange = NULL; + PFNGLGETTRANSFORMFEEDBACKIVPROC_MT GetTransformFeedbackiv = NULL; + PFNGLCREATEBUFFERSPROC_MT CreateBuffers = NULL; + PFNGLNAMEDBUFFERSTORAGEPROC_MT NamedBufferStorage = NULL; + PFNGLNAMEDBUFFERDATAPROC_MT NamedBufferData = NULL; + PFNGLNAMEDBUFFERSUBDATAPROC_MT NamedBufferSubData = NULL; + PFNGLCOPYNAMEDBUFFERSUBDATAPROC_MT CopyNamedBufferSubData = NULL; + PFNGLCLEARNAMEDBUFFERDATAPROC_MT ClearNamedBufferData = NULL; + PFNGLCLEARNAMEDBUFFERSUBDATAPROC_MT ClearNamedBufferSubData = NULL; + PFNGLMAPNAMEDBUFFERPROC_MT MapNamedBuffer = NULL; + PFNGLMAPNAMEDBUFFERRANGEPROC_MT MapNamedBufferRange = NULL; + PFNGLUNMAPNAMEDBUFFERPROC_MT UnmapNamedBuffer = NULL; + PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC_MT FlushMappedNamedBufferRange = NULL; + PFNGLGETNAMEDBUFFERPARAMETERIVPROC_MT GetNamedBufferParameteriv = NULL; + PFNGLGETNAMEDBUFFERPARAMETERI64VPROC_MT GetNamedBufferParameteri64v = NULL; + PFNGLGETNAMEDBUFFERPOINTERVPROC_MT GetNamedBufferPointerv = NULL; + PFNGLGETNAMEDBUFFERSUBDATAPROC_MT GetNamedBufferSubData = NULL; + PFNGLCREATEFRAMEBUFFERSPROC_MT CreateFramebuffers = NULL; + PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC_MT NamedFramebufferRenderbuffer = NULL; + PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC_MT NamedFramebufferParameteri = NULL; + PFNGLNAMEDFRAMEBUFFERTEXTUREPROC_MT NamedFramebufferTexture = NULL; + PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC_MT NamedFramebufferTextureLayer = NULL; + PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC_MT NamedFramebufferDrawBuffer = NULL; + PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC_MT NamedFramebufferDrawBuffers = NULL; + PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC_MT NamedFramebufferReadBuffer = NULL; + PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC_MT InvalidateNamedFramebufferData = NULL; + PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC_MT InvalidateNamedFramebufferSubData = NULL; + PFNGLCLEARNAMEDFRAMEBUFFERIVPROC_MT ClearNamedFramebufferiv = NULL; + PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC_MT ClearNamedFramebufferuiv = NULL; + PFNGLCLEARNAMEDFRAMEBUFFERFVPROC_MT ClearNamedFramebufferfv = NULL; + PFNGLCLEARNAMEDFRAMEBUFFERFIPROC_MT ClearNamedFramebufferfi = NULL; + PFNGLBLITNAMEDFRAMEBUFFERPROC_MT BlitNamedFramebuffer = NULL; + PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC_MT CheckNamedFramebufferStatus = NULL; + PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC_MT GetNamedFramebufferParameteriv = NULL; + PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC_MT GetNamedFramebufferAttachmentParameteriv = NULL; + PFNGLCREATERENDERBUFFERSPROC_MT CreateRenderbuffers = NULL; + PFNGLNAMEDRENDERBUFFERSTORAGEPROC_MT NamedRenderbufferStorage = NULL; + PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC_MT NamedRenderbufferStorageMultisample = NULL; + PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC_MT GetNamedRenderbufferParameteriv = NULL; + PFNGLCREATETEXTURESPROC_MT CreateTextures = NULL; + PFNGLTEXTUREBUFFERPROC_MT TextureBuffer = NULL; + PFNGLTEXTUREBUFFERRANGEPROC_MT TextureBufferRange = NULL; + PFNGLTEXTURESTORAGE1DPROC_MT TextureStorage1D = NULL; + PFNGLTEXTURESTORAGE2DPROC_MT TextureStorage2D = NULL; + PFNGLTEXTURESTORAGE3DPROC_MT TextureStorage3D = NULL; + PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC_MT TextureStorage2DMultisample = NULL; + PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC_MT TextureStorage3DMultisample = NULL; + PFNGLTEXTURESUBIMAGE1DPROC_MT TextureSubImage1D = NULL; + PFNGLTEXTURESUBIMAGE2DPROC_MT TextureSubImage2D = NULL; + PFNGLTEXTURESUBIMAGE3DPROC_MT TextureSubImage3D = NULL; + PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC_MT CompressedTextureSubImage1D = NULL; + PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC_MT CompressedTextureSubImage2D = NULL; + PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC_MT CompressedTextureSubImage3D = NULL; + PFNGLCOPYTEXTURESUBIMAGE1DPROC_MT CopyTextureSubImage1D = NULL; + PFNGLCOPYTEXTURESUBIMAGE2DPROC_MT CopyTextureSubImage2D = NULL; + PFNGLCOPYTEXTURESUBIMAGE3DPROC_MT CopyTextureSubImage3D = NULL; + PFNGLTEXTUREPARAMETERFPROC_MT TextureParameterf = NULL; + PFNGLTEXTUREPARAMETERFVPROC_MT TextureParameterfv = NULL; + PFNGLTEXTUREPARAMETERIPROC_MT TextureParameteri = NULL; + PFNGLTEXTUREPARAMETERIIVPROC_MT TextureParameterIiv = NULL; + PFNGLTEXTUREPARAMETERIUIVPROC_MT TextureParameterIuiv = NULL; + PFNGLTEXTUREPARAMETERIVPROC_MT TextureParameteriv = NULL; + PFNGLGENERATETEXTUREMIPMAPPROC_MT GenerateTextureMipmap = NULL; + PFNGLBINDTEXTUREUNITPROC_MT BindTextureUnit = NULL; + PFNGLGETTEXTUREIMAGEPROC_MT GetTextureImage = NULL; + PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC_MT GetCompressedTextureImage = NULL; + PFNGLGETTEXTURELEVELPARAMETERFVPROC_MT GetTextureLevelParameterfv = NULL; + PFNGLGETTEXTURELEVELPARAMETERIVPROC_MT GetTextureLevelParameteriv = NULL; + PFNGLGETTEXTUREPARAMETERFVPROC_MT GetTextureParameterfv = NULL; + PFNGLGETTEXTUREPARAMETERIIVPROC_MT GetTextureParameterIiv = NULL; + PFNGLGETTEXTUREPARAMETERIUIVPROC_MT GetTextureParameterIuiv = NULL; + PFNGLGETTEXTUREPARAMETERIVPROC_MT GetTextureParameteriv = NULL; + PFNGLCREATEVERTEXARRAYSPROC_MT CreateVertexArrays = NULL; + PFNGLDISABLEVERTEXARRAYATTRIBPROC_MT DisableVertexArrayAttrib = NULL; + PFNGLENABLEVERTEXARRAYATTRIBPROC_MT EnableVertexArrayAttrib = NULL; + PFNGLVERTEXARRAYELEMENTBUFFERPROC_MT VertexArrayElementBuffer = NULL; + PFNGLVERTEXARRAYVERTEXBUFFERPROC_MT VertexArrayVertexBuffer = NULL; + PFNGLVERTEXARRAYVERTEXBUFFERSPROC_MT VertexArrayVertexBuffers = NULL; + PFNGLVERTEXARRAYATTRIBBINDINGPROC_MT VertexArrayAttribBinding = NULL; + PFNGLVERTEXARRAYATTRIBFORMATPROC_MT VertexArrayAttribFormat = NULL; + PFNGLVERTEXARRAYATTRIBIFORMATPROC_MT VertexArrayAttribIFormat = NULL; + PFNGLVERTEXARRAYATTRIBLFORMATPROC_MT VertexArrayAttribLFormat = NULL; + PFNGLVERTEXARRAYBINDINGDIVISORPROC_MT VertexArrayBindingDivisor = NULL; + PFNGLGETVERTEXARRAYIVPROC_MT GetVertexArrayiv = NULL; + PFNGLGETVERTEXARRAYINDEXEDIVPROC_MT GetVertexArrayIndexediv = NULL; + PFNGLGETVERTEXARRAYINDEXED64IVPROC_MT GetVertexArrayIndexed64iv = NULL; + PFNGLCREATESAMPLERSPROC_MT CreateSamplers = NULL; + PFNGLCREATEPROGRAMPIPELINESPROC_MT CreateProgramPipelines = NULL; + PFNGLCREATEQUERIESPROC_MT CreateQueries = NULL; + PFNGLGETQUERYBUFFEROBJECTI64VPROC_MT GetQueryBufferObjecti64v = NULL; + PFNGLGETQUERYBUFFEROBJECTIVPROC_MT GetQueryBufferObjectiv = NULL; + PFNGLGETQUERYBUFFEROBJECTUI64VPROC_MT GetQueryBufferObjectui64v = NULL; + PFNGLGETQUERYBUFFEROBJECTUIVPROC_MT GetQueryBufferObjectuiv = NULL; + PFNGLMEMORYBARRIERBYREGIONPROC_MT MemoryBarrierByRegion = NULL; + PFNGLGETTEXTURESUBIMAGEPROC_MT GetTextureSubImage = NULL; + PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC_MT GetCompressedTextureSubImage = NULL; + PFNGLGETGRAPHICSRESETSTATUSPROC_MT GetGraphicsResetStatus = NULL; + PFNGLGETNCOMPRESSEDTEXIMAGEPROC_MT GetnCompressedTexImage = NULL; + PFNGLGETNTEXIMAGEPROC_MT GetnTexImage = NULL; + PFNGLGETNUNIFORMDVPROC_MT GetnUniformdv = NULL; + PFNGLGETNUNIFORMFVPROC_MT GetnUniformfv = NULL; + PFNGLGETNUNIFORMIVPROC_MT GetnUniformiv = NULL; + PFNGLGETNUNIFORMUIVPROC_MT GetnUniformuiv = NULL; + PFNGLREADNPIXELSPROC_MT ReadnPixels = NULL; + PFNGLTEXTUREBARRIERPROC_MT TextureBarrier = NULL; + PFNGLSPECIALIZESHADERPROC_MT SpecializeShader = NULL; + PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC_MT MultiDrawArraysIndirectCount = NULL; + PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC_MT MultiDrawElementsIndirectCount = NULL; + PFNGLPOLYGONOFFSETCLAMPPROC_MT PolygonOffsetClamp = NULL; + PFNGLPRIMITIVEBOUNDINGBOXPROC_MT PrimitiveBoundingBox = NULL; + PFNGLGETTEXTUREHANDLEPROC_MT GetTextureHandle = NULL; + PFNGLGETTEXTURESAMPLERHANDLEPROC_MT GetTextureSamplerHandle = NULL; + PFNGLMAKETEXTUREHANDLERESIDENTPROC_MT MakeTextureHandleResident = NULL; + PFNGLMAKETEXTUREHANDLENONRESIDENTPROC_MT MakeTextureHandleNonResident = NULL; + PFNGLGETIMAGEHANDLEPROC_MT GetImageHandle = NULL; + PFNGLMAKEIMAGEHANDLERESIDENTPROC_MT MakeImageHandleResident = NULL; + PFNGLMAKEIMAGEHANDLENONRESIDENTPROC_MT MakeImageHandleNonResident = NULL; + PFNGLUNIFORMHANDLEUI64PROC_MT UniformHandleui64 = NULL; + PFNGLUNIFORMHANDLEUI64VPROC_MT UniformHandleui64v = NULL; + PFNGLPROGRAMUNIFORMHANDLEUI64PROC_MT ProgramUniformHandleui64 = NULL; + PFNGLPROGRAMUNIFORMHANDLEUI64VPROC_MT ProgramUniformHandleui64v = NULL; + PFNGLISTEXTUREHANDLERESIDENTPROC_MT IsTextureHandleResident = NULL; + PFNGLISIMAGEHANDLERESIDENTPROC_MT IsImageHandleResident = NULL; + PFNGLVERTEXATTRIBL1UI64PROC_MT VertexAttribL1ui64 = NULL; + PFNGLVERTEXATTRIBL1UI64VPROC_MT VertexAttribL1ui64v = NULL; + PFNGLGETVERTEXATTRIBLUI64VPROC_MT GetVertexAttribLui64v = NULL; + PFNGLCREATESYNCFROMCLEVENTPROC_MT CreateSyncFromCLevent = NULL; + PFNGLDISPATCHCOMPUTEGROUPSIZEPROC_MT DispatchComputeGroupSize = NULL; + PFNGLFRAMEBUFFERTEXTUREFACEPROC_MT FramebufferTextureFace = NULL; + PFNGLUNIFORM1I64PROC_MT Uniform1i64 = NULL; + PFNGLUNIFORM2I64PROC_MT Uniform2i64 = NULL; + PFNGLUNIFORM3I64PROC_MT Uniform3i64 = NULL; + PFNGLUNIFORM4I64PROC_MT Uniform4i64 = NULL; + PFNGLUNIFORM1I64VPROC_MT Uniform1i64v = NULL; + PFNGLUNIFORM2I64VPROC_MT Uniform2i64v = NULL; + PFNGLUNIFORM3I64VPROC_MT Uniform3i64v = NULL; + PFNGLUNIFORM4I64VPROC_MT Uniform4i64v = NULL; + PFNGLUNIFORM1UI64PROC_MT Uniform1ui64 = NULL; + PFNGLUNIFORM2UI64PROC_MT Uniform2ui64 = NULL; + PFNGLUNIFORM3UI64PROC_MT Uniform3ui64 = NULL; + PFNGLUNIFORM4UI64PROC_MT Uniform4ui64 = NULL; + PFNGLUNIFORM1UI64VPROC_MT Uniform1ui64v = NULL; + PFNGLUNIFORM2UI64VPROC_MT Uniform2ui64v = NULL; + PFNGLUNIFORM3UI64VPROC_MT Uniform3ui64v = NULL; + PFNGLUNIFORM4UI64VPROC_MT Uniform4ui64v = NULL; + PFNGLGETUNIFORMI64VPROC_MT GetUniformi64v = NULL; + PFNGLGETUNIFORMUI64VPROC_MT GetUniformui64v = NULL; + PFNGLGETNUNIFORMI64VPROC_MT GetnUniformi64v = NULL; + PFNGLGETNUNIFORMUI64VPROC_MT GetnUniformui64v = NULL; + PFNGLPROGRAMUNIFORM1I64PROC_MT ProgramUniform1i64 = NULL; + PFNGLPROGRAMUNIFORM2I64PROC_MT ProgramUniform2i64 = NULL; + PFNGLPROGRAMUNIFORM3I64PROC_MT ProgramUniform3i64 = NULL; + PFNGLPROGRAMUNIFORM4I64PROC_MT ProgramUniform4i64 = NULL; + PFNGLPROGRAMUNIFORM1I64VPROC_MT ProgramUniform1i64v = NULL; + PFNGLPROGRAMUNIFORM2I64VPROC_MT ProgramUniform2i64v = NULL; + PFNGLPROGRAMUNIFORM3I64VPROC_MT ProgramUniform3i64v = NULL; + PFNGLPROGRAMUNIFORM4I64VPROC_MT ProgramUniform4i64v = NULL; + PFNGLPROGRAMUNIFORM1UI64PROC_MT ProgramUniform1ui64 = NULL; + PFNGLPROGRAMUNIFORM2UI64PROC_MT ProgramUniform2ui64 = NULL; + PFNGLPROGRAMUNIFORM3UI64PROC_MT ProgramUniform3ui64 = NULL; + PFNGLPROGRAMUNIFORM4UI64PROC_MT ProgramUniform4ui64 = NULL; + PFNGLPROGRAMUNIFORM1UI64VPROC_MT ProgramUniform1ui64v = NULL; + PFNGLPROGRAMUNIFORM2UI64VPROC_MT ProgramUniform2ui64v = NULL; + PFNGLPROGRAMUNIFORM3UI64VPROC_MT ProgramUniform3ui64v = NULL; + PFNGLPROGRAMUNIFORM4UI64VPROC_MT ProgramUniform4ui64v = NULL; + PFNGLMAXSHADERCOMPILERTHREADSPROC_MT MaxShaderCompilerThreads = NULL; + PFNGLFRAMEBUFFERSAMPLELOCATIONSFVPROC_MT FramebufferSampleLocationsfv = NULL; + PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVPROC_MT NamedFramebufferSampleLocationsfv = NULL; + PFNGLEVALUATEDEPTHVALUESPROC_MT EvaluateDepthValues = NULL; + PFNGLNAMEDSTRINGPROC_MT NamedString = NULL; + PFNGLDELETENAMEDSTRINGPROC_MT DeleteNamedString = NULL; + PFNGLCOMPILESHADERINCLUDEPROC_MT CompileShaderInclude = NULL; + PFNGLISNAMEDSTRINGPROC_MT IsNamedString = NULL; + PFNGLGETNAMEDSTRINGPROC_MT GetNamedString = NULL; + PFNGLGETNAMEDSTRINGIVPROC_MT GetNamedStringiv = NULL; + PFNGLBUFFERPAGECOMMITMENTPROC_MT BufferPageCommitment = NULL; + PFNGLNAMEDBUFFERPAGECOMMITMENTPROC_MT NamedBufferPageCommitment = NULL; + PFNGLTEXPAGECOMMITMENTPROC_MT TexPageCommitment = NULL; + + static constexpr const GLenum DEPTH_BUFFER_BIT = 0x00000100; + static constexpr const GLenum STENCIL_BUFFER_BIT = 0x00000400; + static constexpr const GLenum COLOR_BUFFER_BIT = 0x00004000; + static constexpr const GLenum POINTS = 0x0000; + static constexpr const GLenum LINES = 0x0001; + static constexpr const GLenum LINE_LOOP = 0x0002; + static constexpr const GLenum LINE_STRIP = 0x0003; + static constexpr const GLenum TRIANGLES = 0x0004; + static constexpr const GLenum TRIANGLE_STRIP = 0x0005; + static constexpr const GLenum TRIANGLE_FAN = 0x0006; + static constexpr const GLenum QUADS = 0x0007; + static constexpr const GLenum NEVER = 0x0200; + static constexpr const GLenum LESS = 0x0201; + static constexpr const GLenum EQUAL = 0x0202; + static constexpr const GLenum LEQUAL = 0x0203; + static constexpr const GLenum GREATER = 0x0204; + static constexpr const GLenum NOTEQUAL = 0x0205; + static constexpr const GLenum GEQUAL = 0x0206; + static constexpr const GLenum ALWAYS = 0x0207; + static constexpr const GLenum SRC_COLOR = 0x0300; + static constexpr const GLenum ONE_MINUS_SRC_COLOR = 0x0301; + static constexpr const GLenum SRC_ALPHA = 0x0302; + static constexpr const GLenum ONE_MINUS_SRC_ALPHA = 0x0303; + static constexpr const GLenum DST_ALPHA = 0x0304; + static constexpr const GLenum ONE_MINUS_DST_ALPHA = 0x0305; + static constexpr const GLenum DST_COLOR = 0x0306; + static constexpr const GLenum ONE_MINUS_DST_COLOR = 0x0307; + static constexpr const GLenum SRC_ALPHA_SATURATE = 0x0308; + static constexpr const GLenum FRONT_LEFT = 0x0400; + static constexpr const GLenum FRONT_RIGHT = 0x0401; + static constexpr const GLenum BACK_LEFT = 0x0402; + static constexpr const GLenum BACK_RIGHT = 0x0403; + static constexpr const GLenum FRONT = 0x0404; + static constexpr const GLenum BACK = 0x0405; + static constexpr const GLenum LEFT = 0x0406; + static constexpr const GLenum RIGHT = 0x0407; + static constexpr const GLenum FRONT_AND_BACK = 0x0408; + static constexpr const GLenum INVALID_ENUM = 0x0500; + static constexpr const GLenum INVALID_VALUE = 0x0501; + static constexpr const GLenum INVALID_OPERATION = 0x0502; + static constexpr const GLenum OUT_OF_MEMORY = 0x0505; + static constexpr const GLenum CW = 0x0900; + static constexpr const GLenum CCW = 0x0901; + static constexpr const GLenum POINT_SIZE = 0x0B11; + static constexpr const GLenum POINT_SIZE_RANGE = 0x0B12; + static constexpr const GLenum POINT_SIZE_GRANULARITY = 0x0B13; + static constexpr const GLenum LINE_SMOOTH = 0x0B20; + static constexpr const GLenum LINE_WIDTH = 0x0B21; + static constexpr const GLenum LINE_WIDTH_RANGE = 0x0B22; + static constexpr const GLenum LINE_WIDTH_GRANULARITY = 0x0B23; + static constexpr const GLenum POLYGON_MODE = 0x0B40; + static constexpr const GLenum POLYGON_SMOOTH = 0x0B41; + static constexpr const GLenum CULL_FACE = 0x0B44; + static constexpr const GLenum CULL_FACE_MODE = 0x0B45; + static constexpr const GLenum FRONT_FACE = 0x0B46; + static constexpr const GLenum DEPTH_RANGE = 0x0B70; + static constexpr const GLenum DEPTH_TEST = 0x0B71; + static constexpr const GLenum DEPTH_WRITEMASK = 0x0B72; + static constexpr const GLenum DEPTH_CLEAR_VALUE = 0x0B73; + static constexpr const GLenum DEPTH_FUNC = 0x0B74; + static constexpr const GLenum STENCIL_TEST = 0x0B90; + static constexpr const GLenum STENCIL_CLEAR_VALUE = 0x0B91; + static constexpr const GLenum STENCIL_FUNC = 0x0B92; + static constexpr const GLenum STENCIL_VALUE_MASK = 0x0B93; + static constexpr const GLenum STENCIL_FAIL = 0x0B94; + static constexpr const GLenum STENCIL_PASS_DEPTH_FAIL = 0x0B95; + static constexpr const GLenum STENCIL_PASS_DEPTH_PASS = 0x0B96; + static constexpr const GLenum STENCIL_REF = 0x0B97; + static constexpr const GLenum STENCIL_WRITEMASK = 0x0B98; + static constexpr const GLenum VIEWPORT = 0x0BA2; + static constexpr const GLenum DITHER = 0x0BD0; + static constexpr const GLenum BLEND_DST = 0x0BE0; + static constexpr const GLenum BLEND_SRC = 0x0BE1; + static constexpr const GLenum BLEND = 0x0BE2; + static constexpr const GLenum LOGIC_OP_MODE = 0x0BF0; + static constexpr const GLenum DRAW_BUFFER = 0x0C01; + static constexpr const GLenum READ_BUFFER = 0x0C02; + static constexpr const GLenum SCISSOR_BOX = 0x0C10; + static constexpr const GLenum SCISSOR_TEST = 0x0C11; + static constexpr const GLenum COLOR_CLEAR_VALUE = 0x0C22; + static constexpr const GLenum COLOR_WRITEMASK = 0x0C23; + static constexpr const GLenum DOUBLEBUFFER = 0x0C32; + static constexpr const GLenum STEREO = 0x0C33; + static constexpr const GLenum LINE_SMOOTH_HINT = 0x0C52; + static constexpr const GLenum POLYGON_SMOOTH_HINT = 0x0C53; + static constexpr const GLenum UNPACK_SWAP_BYTES = 0x0CF0; + static constexpr const GLenum UNPACK_LSB_FIRST = 0x0CF1; + static constexpr const GLenum UNPACK_ROW_LENGTH = 0x0CF2; + static constexpr const GLenum UNPACK_SKIP_ROWS = 0x0CF3; + static constexpr const GLenum UNPACK_SKIP_PIXELS = 0x0CF4; + static constexpr const GLenum UNPACK_ALIGNMENT = 0x0CF5; + static constexpr const GLenum PACK_SWAP_BYTES = 0x0D00; + static constexpr const GLenum PACK_LSB_FIRST = 0x0D01; + static constexpr const GLenum PACK_ROW_LENGTH = 0x0D02; + static constexpr const GLenum PACK_SKIP_ROWS = 0x0D03; + static constexpr const GLenum PACK_SKIP_PIXELS = 0x0D04; + static constexpr const GLenum PACK_ALIGNMENT = 0x0D05; + static constexpr const GLenum MAX_TEXTURE_SIZE = 0x0D33; + static constexpr const GLenum MAX_VIEWPORT_DIMS = 0x0D3A; + static constexpr const GLenum SUBPIXEL_BITS = 0x0D50; + static constexpr const GLenum TEXTURE_1D = 0x0DE0; + static constexpr const GLenum TEXTURE_2D = 0x0DE1; + static constexpr const GLenum TEXTURE_WIDTH = 0x1000; + static constexpr const GLenum TEXTURE_HEIGHT = 0x1001; + static constexpr const GLenum TEXTURE_BORDER_COLOR = 0x1004; + static constexpr const GLenum DONT_CARE = 0x1100; + static constexpr const GLenum FASTEST = 0x1101; + static constexpr const GLenum NICEST = 0x1102; + static constexpr const GLenum BYTE = 0x1400; + static constexpr const GLenum UNSIGNED_BYTE = 0x1401; + static constexpr const GLenum SHORT = 0x1402; + static constexpr const GLenum UNSIGNED_SHORT = 0x1403; + static constexpr const GLenum INT = 0x1404; + static constexpr const GLenum UNSIGNED_INT = 0x1405; + static constexpr const GLenum FLOAT = 0x1406; + static constexpr const GLenum STACK_OVERFLOW = 0x0503; + static constexpr const GLenum STACK_UNDERFLOW = 0x0504; + static constexpr const GLenum CLEAR = 0x1500; + static constexpr const GLenum AND = 0x1501; + static constexpr const GLenum AND_REVERSE = 0x1502; + static constexpr const GLenum COPY = 0x1503; + static constexpr const GLenum AND_INVERTED = 0x1504; + static constexpr const GLenum NOOP = 0x1505; + static constexpr const GLenum XOR = 0x1506; + static constexpr const GLenum OR = 0x1507; + static constexpr const GLenum NOR = 0x1508; + static constexpr const GLenum EQUIV = 0x1509; + static constexpr const GLenum INVERT = 0x150A; + static constexpr const GLenum OR_REVERSE = 0x150B; + static constexpr const GLenum COPY_INVERTED = 0x150C; + static constexpr const GLenum OR_INVERTED = 0x150D; + static constexpr const GLenum NAND = 0x150E; + static constexpr const GLenum SET = 0x150F; + static constexpr const GLenum TEXTURE = 0x1702; + static constexpr const GLenum COLOR = 0x1800; + static constexpr const GLenum DEPTH = 0x1801; + static constexpr const GLenum STENCIL = 0x1802; + static constexpr const GLenum STENCIL_INDEX = 0x1901; + static constexpr const GLenum DEPTH_COMPONENT = 0x1902; + static constexpr const GLenum RED = 0x1903; + static constexpr const GLenum GREEN = 0x1904; + static constexpr const GLenum BLUE = 0x1905; + static constexpr const GLenum ALPHA = 0x1906; + static constexpr const GLenum RGB = 0x1907; + static constexpr const GLenum RGBA = 0x1908; + static constexpr const GLenum POINT = 0x1B00; + static constexpr const GLenum LINE = 0x1B01; + static constexpr const GLenum FILL = 0x1B02; + static constexpr const GLenum KEEP = 0x1E00; + static constexpr const GLenum REPLACE = 0x1E01; + static constexpr const GLenum INCR = 0x1E02; + static constexpr const GLenum DECR = 0x1E03; + static constexpr const GLenum VENDOR = 0x1F00; + static constexpr const GLenum RENDERER = 0x1F01; + static constexpr const GLenum VERSION = 0x1F02; + static constexpr const GLenum EXTENSIONS = 0x1F03; + static constexpr const GLenum NEAREST = 0x2600; + static constexpr const GLenum LINEAR = 0x2601; + static constexpr const GLenum NEAREST_MIPMAP_NEAREST = 0x2700; + static constexpr const GLenum LINEAR_MIPMAP_NEAREST = 0x2701; + static constexpr const GLenum NEAREST_MIPMAP_LINEAR = 0x2702; + static constexpr const GLenum LINEAR_MIPMAP_LINEAR = 0x2703; + static constexpr const GLenum TEXTURE_MAG_FILTER = 0x2800; + static constexpr const GLenum TEXTURE_MIN_FILTER = 0x2801; + static constexpr const GLenum TEXTURE_WRAP_S = 0x2802; + static constexpr const GLenum TEXTURE_WRAP_T = 0x2803; + static constexpr const GLenum REPEAT = 0x2901; + static constexpr const GLenum COLOR_LOGIC_OP = 0x0BF2; + static constexpr const GLenum POLYGON_OFFSET_UNITS = 0x2A00; + static constexpr const GLenum POLYGON_OFFSET_POINT = 0x2A01; + static constexpr const GLenum POLYGON_OFFSET_LINE = 0x2A02; + static constexpr const GLenum POLYGON_OFFSET_FILL = 0x8037; + static constexpr const GLenum POLYGON_OFFSET_FACTOR = 0x8038; + static constexpr const GLenum TEXTURE_BINDING_1D = 0x8068; + static constexpr const GLenum TEXTURE_BINDING_2D = 0x8069; + static constexpr const GLenum TEXTURE_INTERNAL_FORMAT = 0x1003; + static constexpr const GLenum TEXTURE_RED_SIZE = 0x805C; + static constexpr const GLenum TEXTURE_GREEN_SIZE = 0x805D; + static constexpr const GLenum TEXTURE_BLUE_SIZE = 0x805E; + static constexpr const GLenum TEXTURE_ALPHA_SIZE = 0x805F; + static constexpr const GLenum DOUBLE = 0x140A; + static constexpr const GLenum PROXY_TEXTURE_1D = 0x8063; + static constexpr const GLenum PROXY_TEXTURE_2D = 0x8064; + static constexpr const GLenum R3_G3_B2 = 0x2A10; + static constexpr const GLenum RGB4 = 0x804F; + static constexpr const GLenum RGB5 = 0x8050; + static constexpr const GLenum RGB8 = 0x8051; + static constexpr const GLenum RGB10 = 0x8052; + static constexpr const GLenum RGB12 = 0x8053; + static constexpr const GLenum RGB16 = 0x8054; + static constexpr const GLenum RGBA2 = 0x8055; + static constexpr const GLenum RGBA4 = 0x8056; + static constexpr const GLenum RGB5_A1 = 0x8057; + static constexpr const GLenum RGBA8 = 0x8058; + static constexpr const GLenum RGB10_A2 = 0x8059; + static constexpr const GLenum RGBA12 = 0x805A; + static constexpr const GLenum RGBA16 = 0x805B; + static constexpr const GLenum VERTEX_ARRAY = 0x8074; + static constexpr const GLenum UNSIGNED_BYTE_3_3_2 = 0x8032; + static constexpr const GLenum UNSIGNED_SHORT_4_4_4_4 = 0x8033; + static constexpr const GLenum UNSIGNED_SHORT_5_5_5_1 = 0x8034; + static constexpr const GLenum UNSIGNED_INT_8_8_8_8 = 0x8035; + static constexpr const GLenum UNSIGNED_INT_10_10_10_2 = 0x8036; + static constexpr const GLenum TEXTURE_BINDING_3D = 0x806A; + static constexpr const GLenum PACK_SKIP_IMAGES = 0x806B; + static constexpr const GLenum PACK_IMAGE_HEIGHT = 0x806C; + static constexpr const GLenum UNPACK_SKIP_IMAGES = 0x806D; + static constexpr const GLenum UNPACK_IMAGE_HEIGHT = 0x806E; + static constexpr const GLenum TEXTURE_3D = 0x806F; + static constexpr const GLenum PROXY_TEXTURE_3D = 0x8070; + static constexpr const GLenum TEXTURE_DEPTH = 0x8071; + static constexpr const GLenum TEXTURE_WRAP_R = 0x8072; + static constexpr const GLenum MAX_3D_TEXTURE_SIZE = 0x8073; + static constexpr const GLenum UNSIGNED_BYTE_2_3_3_REV = 0x8362; + static constexpr const GLenum UNSIGNED_SHORT_5_6_5 = 0x8363; + static constexpr const GLenum UNSIGNED_SHORT_5_6_5_REV = 0x8364; + static constexpr const GLenum UNSIGNED_SHORT_4_4_4_4_REV = 0x8365; + static constexpr const GLenum UNSIGNED_SHORT_1_5_5_5_REV = 0x8366; + static constexpr const GLenum UNSIGNED_INT_8_8_8_8_REV = 0x8367; + static constexpr const GLenum UNSIGNED_INT_2_10_10_10_REV = 0x8368; + static constexpr const GLenum BGR = 0x80E0; + static constexpr const GLenum BGRA = 0x80E1; + static constexpr const GLenum MAX_ELEMENTS_VERTICES = 0x80E8; + static constexpr const GLenum MAX_ELEMENTS_INDICES = 0x80E9; + static constexpr const GLenum CLAMP_TO_EDGE = 0x812F; + static constexpr const GLenum TEXTURE_MIN_LOD = 0x813A; + static constexpr const GLenum TEXTURE_MAX_LOD = 0x813B; + static constexpr const GLenum TEXTURE_BASE_LEVEL = 0x813C; + static constexpr const GLenum TEXTURE_MAX_LEVEL = 0x813D; + static constexpr const GLenum SMOOTH_POINT_SIZE_RANGE = 0x0B12; + static constexpr const GLenum SMOOTH_POINT_SIZE_GRANULARITY = 0x0B13; + static constexpr const GLenum SMOOTH_LINE_WIDTH_RANGE = 0x0B22; + static constexpr const GLenum SMOOTH_LINE_WIDTH_GRANULARITY = 0x0B23; + static constexpr const GLenum ALIASED_LINE_WIDTH_RANGE = 0x846E; + static constexpr const GLenum TEXTURE0 = 0x84C0; + static constexpr const GLenum TEXTURE1 = 0x84C1; + static constexpr const GLenum TEXTURE2 = 0x84C2; + static constexpr const GLenum TEXTURE3 = 0x84C3; + static constexpr const GLenum TEXTURE4 = 0x84C4; + static constexpr const GLenum TEXTURE5 = 0x84C5; + static constexpr const GLenum TEXTURE6 = 0x84C6; + static constexpr const GLenum TEXTURE7 = 0x84C7; + static constexpr const GLenum TEXTURE8 = 0x84C8; + static constexpr const GLenum TEXTURE9 = 0x84C9; + static constexpr const GLenum TEXTURE10 = 0x84CA; + static constexpr const GLenum TEXTURE11 = 0x84CB; + static constexpr const GLenum TEXTURE12 = 0x84CC; + static constexpr const GLenum TEXTURE13 = 0x84CD; + static constexpr const GLenum TEXTURE14 = 0x84CE; + static constexpr const GLenum TEXTURE15 = 0x84CF; + static constexpr const GLenum TEXTURE16 = 0x84D0; + static constexpr const GLenum TEXTURE17 = 0x84D1; + static constexpr const GLenum TEXTURE18 = 0x84D2; + static constexpr const GLenum TEXTURE19 = 0x84D3; + static constexpr const GLenum TEXTURE20 = 0x84D4; + static constexpr const GLenum TEXTURE21 = 0x84D5; + static constexpr const GLenum TEXTURE22 = 0x84D6; + static constexpr const GLenum TEXTURE23 = 0x84D7; + static constexpr const GLenum TEXTURE24 = 0x84D8; + static constexpr const GLenum TEXTURE25 = 0x84D9; + static constexpr const GLenum TEXTURE26 = 0x84DA; + static constexpr const GLenum TEXTURE27 = 0x84DB; + static constexpr const GLenum TEXTURE28 = 0x84DC; + static constexpr const GLenum TEXTURE29 = 0x84DD; + static constexpr const GLenum TEXTURE30 = 0x84DE; + static constexpr const GLenum TEXTURE31 = 0x84DF; + static constexpr const GLenum ACTIVE_TEXTURE = 0x84E0; + static constexpr const GLenum MULTISAMPLE = 0x809D; + static constexpr const GLenum SAMPLE_ALPHA_TO_COVERAGE = 0x809E; + static constexpr const GLenum SAMPLE_ALPHA_TO_ONE = 0x809F; + static constexpr const GLenum SAMPLE_COVERAGE = 0x80A0; + static constexpr const GLenum SAMPLE_BUFFERS = 0x80A8; + static constexpr const GLenum SAMPLES = 0x80A9; + static constexpr const GLenum SAMPLE_COVERAGE_VALUE = 0x80AA; + static constexpr const GLenum SAMPLE_COVERAGE_INVERT = 0x80AB; + static constexpr const GLenum TEXTURE_CUBE_MAP = 0x8513; + static constexpr const GLenum TEXTURE_BINDING_CUBE_MAP = 0x8514; + static constexpr const GLenum TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515; + static constexpr const GLenum TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516; + static constexpr const GLenum TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517; + static constexpr const GLenum TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518; + static constexpr const GLenum TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519; + static constexpr const GLenum TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A; + static constexpr const GLenum PROXY_TEXTURE_CUBE_MAP = 0x851B; + static constexpr const GLenum MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C; + static constexpr const GLenum COMPRESSED_RGB = 0x84ED; + static constexpr const GLenum COMPRESSED_RGBA = 0x84EE; + static constexpr const GLenum TEXTURE_COMPRESSION_HINT = 0x84EF; + static constexpr const GLenum TEXTURE_COMPRESSED_IMAGE_SIZE = 0x86A0; + static constexpr const GLenum TEXTURE_COMPRESSED = 0x86A1; + static constexpr const GLenum NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2; + static constexpr const GLenum COMPRESSED_TEXTURE_FORMATS = 0x86A3; + static constexpr const GLenum CLAMP_TO_BORDER = 0x812D; + static constexpr const GLenum BLEND_DST_RGB = 0x80C8; + static constexpr const GLenum BLEND_SRC_RGB = 0x80C9; + static constexpr const GLenum BLEND_DST_ALPHA = 0x80CA; + static constexpr const GLenum BLEND_SRC_ALPHA = 0x80CB; + static constexpr const GLenum POINT_FADE_THRESHOLD_SIZE = 0x8128; + static constexpr const GLenum DEPTH_COMPONENT16 = 0x81A5; + static constexpr const GLenum DEPTH_COMPONENT24 = 0x81A6; + static constexpr const GLenum DEPTH_COMPONENT32 = 0x81A7; + static constexpr const GLenum MIRRORED_REPEAT = 0x8370; + static constexpr const GLenum MAX_TEXTURE_LOD_BIAS = 0x84FD; + static constexpr const GLenum TEXTURE_LOD_BIAS = 0x8501; + static constexpr const GLenum INCR_WRAP = 0x8507; + static constexpr const GLenum DECR_WRAP = 0x8508; + static constexpr const GLenum TEXTURE_DEPTH_SIZE = 0x884A; + static constexpr const GLenum TEXTURE_COMPARE_MODE = 0x884C; + static constexpr const GLenum TEXTURE_COMPARE_FUNC = 0x884D; + static constexpr const GLenum BLEND_COLOR = 0x8005; + static constexpr const GLenum BLEND_EQUATION = 0x8009; + static constexpr const GLenum CONSTANT_COLOR = 0x8001; + static constexpr const GLenum ONE_MINUS_CONSTANT_COLOR = 0x8002; + static constexpr const GLenum CONSTANT_ALPHA = 0x8003; + static constexpr const GLenum ONE_MINUS_CONSTANT_ALPHA = 0x8004; + static constexpr const GLenum FUNC_ADD = 0x8006; + static constexpr const GLenum FUNC_REVERSE_SUBTRACT = 0x800B; + static constexpr const GLenum FUNC_SUBTRACT = 0x800A; + static constexpr const GLenum MIN = 0x8007; + static constexpr const GLenum MAX = 0x8008; + static constexpr const GLenum BUFFER_SIZE = 0x8764; + static constexpr const GLenum BUFFER_USAGE = 0x8765; + static constexpr const GLenum QUERY_COUNTER_BITS = 0x8864; + static constexpr const GLenum CURRENT_QUERY = 0x8865; + static constexpr const GLenum QUERY_RESULT = 0x8866; + static constexpr const GLenum QUERY_RESULT_AVAILABLE = 0x8867; + static constexpr const GLenum ARRAY_BUFFER = 0x8892; + static constexpr const GLenum ELEMENT_ARRAY_BUFFER = 0x8893; + static constexpr const GLenum ARRAY_BUFFER_BINDING = 0x8894; + static constexpr const GLenum ELEMENT_ARRAY_BUFFER_BINDING = 0x8895; + static constexpr const GLenum VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F; + static constexpr const GLenum READ_ONLY = 0x88B8; + static constexpr const GLenum WRITE_ONLY = 0x88B9; + static constexpr const GLenum READ_WRITE = 0x88BA; + static constexpr const GLenum BUFFER_ACCESS = 0x88BB; + static constexpr const GLenum BUFFER_MAPPED = 0x88BC; + static constexpr const GLenum BUFFER_MAP_POINTER = 0x88BD; + static constexpr const GLenum STREAM_DRAW = 0x88E0; + static constexpr const GLenum STREAM_READ = 0x88E1; + static constexpr const GLenum STREAM_COPY = 0x88E2; + static constexpr const GLenum STATIC_DRAW = 0x88E4; + static constexpr const GLenum STATIC_READ = 0x88E5; + static constexpr const GLenum STATIC_COPY = 0x88E6; + static constexpr const GLenum DYNAMIC_DRAW = 0x88E8; + static constexpr const GLenum DYNAMIC_READ = 0x88E9; + static constexpr const GLenum DYNAMIC_COPY = 0x88EA; + static constexpr const GLenum SAMPLES_PASSED = 0x8914; + static constexpr const GLenum SRC1_ALPHA = 0x8589; + static constexpr const GLenum BLEND_EQUATION_RGB = 0x8009; + static constexpr const GLenum VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622; + static constexpr const GLenum VERTEX_ATTRIB_ARRAY_SIZE = 0x8623; + static constexpr const GLenum VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624; + static constexpr const GLenum VERTEX_ATTRIB_ARRAY_TYPE = 0x8625; + static constexpr const GLenum CURRENT_VERTEX_ATTRIB = 0x8626; + static constexpr const GLenum VERTEX_PROGRAM_POINT_SIZE = 0x8642; + static constexpr const GLenum VERTEX_ATTRIB_ARRAY_POINTER = 0x8645; + static constexpr const GLenum STENCIL_BACK_FUNC = 0x8800; + static constexpr const GLenum STENCIL_BACK_FAIL = 0x8801; + static constexpr const GLenum STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802; + static constexpr const GLenum STENCIL_BACK_PASS_DEPTH_PASS = 0x8803; + static constexpr const GLenum MAX_DRAW_BUFFERS = 0x8824; + static constexpr const GLenum DRAW_BUFFER0 = 0x8825; + static constexpr const GLenum DRAW_BUFFER1 = 0x8826; + static constexpr const GLenum DRAW_BUFFER2 = 0x8827; + static constexpr const GLenum DRAW_BUFFER3 = 0x8828; + static constexpr const GLenum DRAW_BUFFER4 = 0x8829; + static constexpr const GLenum DRAW_BUFFER5 = 0x882A; + static constexpr const GLenum DRAW_BUFFER6 = 0x882B; + static constexpr const GLenum DRAW_BUFFER7 = 0x882C; + static constexpr const GLenum DRAW_BUFFER8 = 0x882D; + static constexpr const GLenum DRAW_BUFFER9 = 0x882E; + static constexpr const GLenum DRAW_BUFFER10 = 0x882F; + static constexpr const GLenum DRAW_BUFFER11 = 0x8830; + static constexpr const GLenum DRAW_BUFFER12 = 0x8831; + static constexpr const GLenum DRAW_BUFFER13 = 0x8832; + static constexpr const GLenum DRAW_BUFFER14 = 0x8833; + static constexpr const GLenum DRAW_BUFFER15 = 0x8834; + static constexpr const GLenum BLEND_EQUATION_ALPHA = 0x883D; + static constexpr const GLenum MAX_VERTEX_ATTRIBS = 0x8869; + static constexpr const GLenum VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A; + static constexpr const GLenum MAX_TEXTURE_IMAGE_UNITS = 0x8872; + static constexpr const GLenum FRAGMENT_SHADER = 0x8B30; + static constexpr const GLenum VERTEX_SHADER = 0x8B31; + static constexpr const GLenum MAX_FRAGMENT_UNIFORM_COMPONENTS = 0x8B49; + static constexpr const GLenum MAX_VERTEX_UNIFORM_COMPONENTS = 0x8B4A; + static constexpr const GLenum MAX_VARYING_FLOATS = 0x8B4B; + static constexpr const GLenum MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C; + static constexpr const GLenum MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D; + static constexpr const GLenum SHADER_TYPE = 0x8B4F; + static constexpr const GLenum FLOAT_VEC2 = 0x8B50; + static constexpr const GLenum FLOAT_VEC3 = 0x8B51; + static constexpr const GLenum FLOAT_VEC4 = 0x8B52; + static constexpr const GLenum INT_VEC2 = 0x8B53; + static constexpr const GLenum INT_VEC3 = 0x8B54; + static constexpr const GLenum INT_VEC4 = 0x8B55; + static constexpr const GLenum BOOL = 0x8B56; + static constexpr const GLenum BOOL_VEC2 = 0x8B57; + static constexpr const GLenum BOOL_VEC3 = 0x8B58; + static constexpr const GLenum BOOL_VEC4 = 0x8B59; + static constexpr const GLenum FLOAT_MAT2 = 0x8B5A; + static constexpr const GLenum FLOAT_MAT3 = 0x8B5B; + static constexpr const GLenum FLOAT_MAT4 = 0x8B5C; + static constexpr const GLenum SAMPLER_1D = 0x8B5D; + static constexpr const GLenum SAMPLER_2D = 0x8B5E; + static constexpr const GLenum SAMPLER_3D = 0x8B5F; + static constexpr const GLenum SAMPLER_CUBE = 0x8B60; + static constexpr const GLenum SAMPLER_1D_SHADOW = 0x8B61; + static constexpr const GLenum SAMPLER_2D_SHADOW = 0x8B62; + static constexpr const GLenum DELETE_STATUS = 0x8B80; + static constexpr const GLenum COMPILE_STATUS = 0x8B81; + static constexpr const GLenum LINK_STATUS = 0x8B82; + static constexpr const GLenum VALIDATE_STATUS = 0x8B83; + static constexpr const GLenum INFO_LOG_LENGTH = 0x8B84; + static constexpr const GLenum ATTACHED_SHADERS = 0x8B85; + static constexpr const GLenum ACTIVE_UNIFORMS = 0x8B86; + static constexpr const GLenum ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87; + static constexpr const GLenum SHADER_SOURCE_LENGTH = 0x8B88; + static constexpr const GLenum ACTIVE_ATTRIBUTES = 0x8B89; + static constexpr const GLenum ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A; + static constexpr const GLenum FRAGMENT_SHADER_DERIVATIVE_HINT = 0x8B8B; + static constexpr const GLenum SHADING_LANGUAGE_VERSION = 0x8B8C; + static constexpr const GLenum CURRENT_PROGRAM = 0x8B8D; + static constexpr const GLenum POINT_SPRITE_COORD_ORIGIN = 0x8CA0; + static constexpr const GLenum LOWER_LEFT = 0x8CA1; + static constexpr const GLenum UPPER_LEFT = 0x8CA2; + static constexpr const GLenum STENCIL_BACK_REF = 0x8CA3; + static constexpr const GLenum STENCIL_BACK_VALUE_MASK = 0x8CA4; + static constexpr const GLenum STENCIL_BACK_WRITEMASK = 0x8CA5; + static constexpr const GLenum PIXEL_PACK_BUFFER = 0x88EB; + static constexpr const GLenum PIXEL_UNPACK_BUFFER = 0x88EC; + static constexpr const GLenum PIXEL_PACK_BUFFER_BINDING = 0x88ED; + static constexpr const GLenum PIXEL_UNPACK_BUFFER_BINDING = 0x88EF; + static constexpr const GLenum FLOAT_MAT2x3 = 0x8B65; + static constexpr const GLenum FLOAT_MAT2x4 = 0x8B66; + static constexpr const GLenum FLOAT_MAT3x2 = 0x8B67; + static constexpr const GLenum FLOAT_MAT3x4 = 0x8B68; + static constexpr const GLenum FLOAT_MAT4x2 = 0x8B69; + static constexpr const GLenum FLOAT_MAT4x3 = 0x8B6A; + static constexpr const GLenum SRGB = 0x8C40; + static constexpr const GLenum SRGB8 = 0x8C41; + static constexpr const GLenum SRGB_ALPHA = 0x8C42; + static constexpr const GLenum SRGB8_ALPHA8 = 0x8C43; + static constexpr const GLenum COMPRESSED_SRGB = 0x8C48; + static constexpr const GLenum COMPRESSED_SRGB_ALPHA = 0x8C49; + static constexpr const GLenum COMPARE_REF_TO_TEXTURE = 0x884E; + static constexpr const GLenum CLIP_DISTANCE0 = 0x3000; + static constexpr const GLenum CLIP_DISTANCE1 = 0x3001; + static constexpr const GLenum CLIP_DISTANCE2 = 0x3002; + static constexpr const GLenum CLIP_DISTANCE3 = 0x3003; + static constexpr const GLenum CLIP_DISTANCE4 = 0x3004; + static constexpr const GLenum CLIP_DISTANCE5 = 0x3005; + static constexpr const GLenum CLIP_DISTANCE6 = 0x3006; + static constexpr const GLenum CLIP_DISTANCE7 = 0x3007; + static constexpr const GLenum MAX_CLIP_DISTANCES = 0x0D32; + static constexpr const GLenum MAJOR_VERSION = 0x821B; + static constexpr const GLenum MINOR_VERSION = 0x821C; + static constexpr const GLenum NUM_EXTENSIONS = 0x821D; + static constexpr const GLenum CONTEXT_FLAGS = 0x821E; + static constexpr const GLenum COMPRESSED_RED = 0x8225; + static constexpr const GLenum COMPRESSED_RG = 0x8226; + static constexpr const GLenum CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT = 0x00000001; + static constexpr const GLenum RGBA32F = 0x8814; + static constexpr const GLenum RGB32F = 0x8815; + static constexpr const GLenum RGBA16F = 0x881A; + static constexpr const GLenum RGB16F = 0x881B; + static constexpr const GLenum VERTEX_ATTRIB_ARRAY_INTEGER = 0x88FD; + static constexpr const GLenum MAX_ARRAY_TEXTURE_LAYERS = 0x88FF; + static constexpr const GLenum MIN_PROGRAM_TEXEL_OFFSET = 0x8904; + static constexpr const GLenum MAX_PROGRAM_TEXEL_OFFSET = 0x8905; + static constexpr const GLenum CLAMP_READ_COLOR = 0x891C; + static constexpr const GLenum FIXED_ONLY = 0x891D; + static constexpr const GLenum MAX_VARYING_COMPONENTS = 0x8B4B; + static constexpr const GLenum TEXTURE_1D_ARRAY = 0x8C18; + static constexpr const GLenum PROXY_TEXTURE_1D_ARRAY = 0x8C19; + static constexpr const GLenum TEXTURE_2D_ARRAY = 0x8C1A; + static constexpr const GLenum PROXY_TEXTURE_2D_ARRAY = 0x8C1B; + static constexpr const GLenum TEXTURE_BINDING_1D_ARRAY = 0x8C1C; + static constexpr const GLenum TEXTURE_BINDING_2D_ARRAY = 0x8C1D; + static constexpr const GLenum R11F_G11F_B10F = 0x8C3A; + static constexpr const GLenum UNSIGNED_INT_10F_11F_11F_REV = 0x8C3B; + static constexpr const GLenum RGB9_E5 = 0x8C3D; + static constexpr const GLenum UNSIGNED_INT_5_9_9_9_REV = 0x8C3E; + static constexpr const GLenum TEXTURE_SHARED_SIZE = 0x8C3F; + static constexpr const GLenum TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH = 0x8C76; + static constexpr const GLenum TRANSFORM_FEEDBACK_BUFFER_MODE = 0x8C7F; + static constexpr const GLenum MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS = 0x8C80; + static constexpr const GLenum TRANSFORM_FEEDBACK_VARYINGS = 0x8C83; + static constexpr const GLenum TRANSFORM_FEEDBACK_BUFFER_START = 0x8C84; + static constexpr const GLenum TRANSFORM_FEEDBACK_BUFFER_SIZE = 0x8C85; + static constexpr const GLenum PRIMITIVES_GENERATED = 0x8C87; + static constexpr const GLenum TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN = 0x8C88; + static constexpr const GLenum RASTERIZER_DISCARD = 0x8C89; + static constexpr const GLenum MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS = 0x8C8A; + static constexpr const GLenum MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS = 0x8C8B; + static constexpr const GLenum INTERLEAVED_ATTRIBS = 0x8C8C; + static constexpr const GLenum SEPARATE_ATTRIBS = 0x8C8D; + static constexpr const GLenum TRANSFORM_FEEDBACK_BUFFER = 0x8C8E; + static constexpr const GLenum TRANSFORM_FEEDBACK_BUFFER_BINDING = 0x8C8F; + static constexpr const GLenum RGBA32UI = 0x8D70; + static constexpr const GLenum RGB32UI = 0x8D71; + static constexpr const GLenum RGBA16UI = 0x8D76; + static constexpr const GLenum RGB16UI = 0x8D77; + static constexpr const GLenum RGBA8UI = 0x8D7C; + static constexpr const GLenum RGB8UI = 0x8D7D; + static constexpr const GLenum RGBA32I = 0x8D82; + static constexpr const GLenum RGB32I = 0x8D83; + static constexpr const GLenum RGBA16I = 0x8D88; + static constexpr const GLenum RGB16I = 0x8D89; + static constexpr const GLenum RGBA8I = 0x8D8E; + static constexpr const GLenum RGB8I = 0x8D8F; + static constexpr const GLenum RED_INTEGER = 0x8D94; + static constexpr const GLenum GREEN_INTEGER = 0x8D95; + static constexpr const GLenum BLUE_INTEGER = 0x8D96; + static constexpr const GLenum RGB_INTEGER = 0x8D98; + static constexpr const GLenum RGBA_INTEGER = 0x8D99; + static constexpr const GLenum BGR_INTEGER = 0x8D9A; + static constexpr const GLenum BGRA_INTEGER = 0x8D9B; + static constexpr const GLenum SAMPLER_1D_ARRAY = 0x8DC0; + static constexpr const GLenum SAMPLER_2D_ARRAY = 0x8DC1; + static constexpr const GLenum SAMPLER_1D_ARRAY_SHADOW = 0x8DC3; + static constexpr const GLenum SAMPLER_2D_ARRAY_SHADOW = 0x8DC4; + static constexpr const GLenum SAMPLER_CUBE_SHADOW = 0x8DC5; + static constexpr const GLenum UNSIGNED_INT_VEC2 = 0x8DC6; + static constexpr const GLenum UNSIGNED_INT_VEC3 = 0x8DC7; + static constexpr const GLenum UNSIGNED_INT_VEC4 = 0x8DC8; + static constexpr const GLenum INT_SAMPLER_1D = 0x8DC9; + static constexpr const GLenum INT_SAMPLER_2D = 0x8DCA; + static constexpr const GLenum INT_SAMPLER_3D = 0x8DCB; + static constexpr const GLenum INT_SAMPLER_CUBE = 0x8DCC; + static constexpr const GLenum INT_SAMPLER_1D_ARRAY = 0x8DCE; + static constexpr const GLenum INT_SAMPLER_2D_ARRAY = 0x8DCF; + static constexpr const GLenum UNSIGNED_INT_SAMPLER_1D = 0x8DD1; + static constexpr const GLenum UNSIGNED_INT_SAMPLER_2D = 0x8DD2; + static constexpr const GLenum UNSIGNED_INT_SAMPLER_3D = 0x8DD3; + static constexpr const GLenum UNSIGNED_INT_SAMPLER_CUBE = 0x8DD4; + static constexpr const GLenum UNSIGNED_INT_SAMPLER_1D_ARRAY = 0x8DD6; + static constexpr const GLenum UNSIGNED_INT_SAMPLER_2D_ARRAY = 0x8DD7; + static constexpr const GLenum QUERY_WAIT = 0x8E13; + static constexpr const GLenum QUERY_NO_WAIT = 0x8E14; + static constexpr const GLenum QUERY_BY_REGION_WAIT = 0x8E15; + static constexpr const GLenum QUERY_BY_REGION_NO_WAIT = 0x8E16; + static constexpr const GLenum BUFFER_ACCESS_FLAGS = 0x911F; + static constexpr const GLenum BUFFER_MAP_LENGTH = 0x9120; + static constexpr const GLenum BUFFER_MAP_OFFSET = 0x9121; + static constexpr const GLenum DEPTH_COMPONENT32F = 0x8CAC; + static constexpr const GLenum DEPTH32F_STENCIL8 = 0x8CAD; + static constexpr const GLenum FLOAT_32_UNSIGNED_INT_24_8_REV = 0x8DAD; + static constexpr const GLenum INVALID_FRAMEBUFFER_OPERATION = 0x0506; + static constexpr const GLenum FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING = 0x8210; + static constexpr const GLenum FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE = 0x8211; + static constexpr const GLenum FRAMEBUFFER_ATTACHMENT_RED_SIZE = 0x8212; + static constexpr const GLenum FRAMEBUFFER_ATTACHMENT_GREEN_SIZE = 0x8213; + static constexpr const GLenum FRAMEBUFFER_ATTACHMENT_BLUE_SIZE = 0x8214; + static constexpr const GLenum FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE = 0x8215; + static constexpr const GLenum FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE = 0x8216; + static constexpr const GLenum FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE = 0x8217; + static constexpr const GLenum FRAMEBUFFER_DEFAULT = 0x8218; + static constexpr const GLenum FRAMEBUFFER_UNDEFINED = 0x8219; + static constexpr const GLenum DEPTH_STENCIL_ATTACHMENT = 0x821A; + static constexpr const GLenum MAX_RENDERBUFFER_SIZE = 0x84E8; + static constexpr const GLenum DEPTH_STENCIL = 0x84F9; + static constexpr const GLenum UNSIGNED_INT_24_8 = 0x84FA; + static constexpr const GLenum DEPTH24_STENCIL8 = 0x88F0; + static constexpr const GLenum TEXTURE_STENCIL_SIZE = 0x88F1; + static constexpr const GLenum TEXTURE_RED_TYPE = 0x8C10; + static constexpr const GLenum TEXTURE_GREEN_TYPE = 0x8C11; + static constexpr const GLenum TEXTURE_BLUE_TYPE = 0x8C12; + static constexpr const GLenum TEXTURE_ALPHA_TYPE = 0x8C13; + static constexpr const GLenum TEXTURE_DEPTH_TYPE = 0x8C16; + static constexpr const GLenum UNSIGNED_NORMALIZED = 0x8C17; + static constexpr const GLenum FRAMEBUFFER_BINDING = 0x8CA6; + static constexpr const GLenum DRAW_FRAMEBUFFER_BINDING = 0x8CA6; + static constexpr const GLenum RENDERBUFFER_BINDING = 0x8CA7; + static constexpr const GLenum READ_FRAMEBUFFER = 0x8CA8; + static constexpr const GLenum DRAW_FRAMEBUFFER = 0x8CA9; + static constexpr const GLenum READ_FRAMEBUFFER_BINDING = 0x8CAA; + static constexpr const GLenum RENDERBUFFER_SAMPLES = 0x8CAB; + static constexpr const GLenum FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0; + static constexpr const GLenum FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1; + static constexpr const GLenum FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2; + static constexpr const GLenum FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3; + static constexpr const GLenum FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER = 0x8CD4; + static constexpr const GLenum FRAMEBUFFER_COMPLETE = 0x8CD5; + static constexpr const GLenum FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6; + static constexpr const GLenum FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7; + static constexpr const GLenum FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = 0x8CDB; + static constexpr const GLenum FRAMEBUFFER_INCOMPLETE_READ_BUFFER = 0x8CDC; + static constexpr const GLenum FRAMEBUFFER_UNSUPPORTED = 0x8CDD; + static constexpr const GLenum MAX_COLOR_ATTACHMENTS = 0x8CDF; + static constexpr const GLenum COLOR_ATTACHMENT0 = 0x8CE0; + static constexpr const GLenum COLOR_ATTACHMENT1 = 0x8CE1; + static constexpr const GLenum COLOR_ATTACHMENT2 = 0x8CE2; + static constexpr const GLenum COLOR_ATTACHMENT3 = 0x8CE3; + static constexpr const GLenum COLOR_ATTACHMENT4 = 0x8CE4; + static constexpr const GLenum COLOR_ATTACHMENT5 = 0x8CE5; + static constexpr const GLenum COLOR_ATTACHMENT6 = 0x8CE6; + static constexpr const GLenum COLOR_ATTACHMENT7 = 0x8CE7; + static constexpr const GLenum COLOR_ATTACHMENT8 = 0x8CE8; + static constexpr const GLenum COLOR_ATTACHMENT9 = 0x8CE9; + static constexpr const GLenum COLOR_ATTACHMENT10 = 0x8CEA; + static constexpr const GLenum COLOR_ATTACHMENT11 = 0x8CEB; + static constexpr const GLenum COLOR_ATTACHMENT12 = 0x8CEC; + static constexpr const GLenum COLOR_ATTACHMENT13 = 0x8CED; + static constexpr const GLenum COLOR_ATTACHMENT14 = 0x8CEE; + static constexpr const GLenum COLOR_ATTACHMENT15 = 0x8CEF; + static constexpr const GLenum COLOR_ATTACHMENT16 = 0x8CF0; + static constexpr const GLenum COLOR_ATTACHMENT17 = 0x8CF1; + static constexpr const GLenum COLOR_ATTACHMENT18 = 0x8CF2; + static constexpr const GLenum COLOR_ATTACHMENT19 = 0x8CF3; + static constexpr const GLenum COLOR_ATTACHMENT20 = 0x8CF4; + static constexpr const GLenum COLOR_ATTACHMENT21 = 0x8CF5; + static constexpr const GLenum COLOR_ATTACHMENT22 = 0x8CF6; + static constexpr const GLenum COLOR_ATTACHMENT23 = 0x8CF7; + static constexpr const GLenum COLOR_ATTACHMENT24 = 0x8CF8; + static constexpr const GLenum COLOR_ATTACHMENT25 = 0x8CF9; + static constexpr const GLenum COLOR_ATTACHMENT26 = 0x8CFA; + static constexpr const GLenum COLOR_ATTACHMENT27 = 0x8CFB; + static constexpr const GLenum COLOR_ATTACHMENT28 = 0x8CFC; + static constexpr const GLenum COLOR_ATTACHMENT29 = 0x8CFD; + static constexpr const GLenum COLOR_ATTACHMENT30 = 0x8CFE; + static constexpr const GLenum COLOR_ATTACHMENT31 = 0x8CFF; + static constexpr const GLenum DEPTH_ATTACHMENT = 0x8D00; + static constexpr const GLenum STENCIL_ATTACHMENT = 0x8D20; + static constexpr const GLenum FRAMEBUFFER = 0x8D40; + static constexpr const GLenum RENDERBUFFER = 0x8D41; + static constexpr const GLenum RENDERBUFFER_WIDTH = 0x8D42; + static constexpr const GLenum RENDERBUFFER_HEIGHT = 0x8D43; + static constexpr const GLenum RENDERBUFFER_INTERNAL_FORMAT = 0x8D44; + static constexpr const GLenum STENCIL_INDEX1 = 0x8D46; + static constexpr const GLenum STENCIL_INDEX4 = 0x8D47; + static constexpr const GLenum STENCIL_INDEX8 = 0x8D48; + static constexpr const GLenum STENCIL_INDEX16 = 0x8D49; + static constexpr const GLenum RENDERBUFFER_RED_SIZE = 0x8D50; + static constexpr const GLenum RENDERBUFFER_GREEN_SIZE = 0x8D51; + static constexpr const GLenum RENDERBUFFER_BLUE_SIZE = 0x8D52; + static constexpr const GLenum RENDERBUFFER_ALPHA_SIZE = 0x8D53; + static constexpr const GLenum RENDERBUFFER_DEPTH_SIZE = 0x8D54; + static constexpr const GLenum RENDERBUFFER_STENCIL_SIZE = 0x8D55; + static constexpr const GLenum FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56; + static constexpr const GLenum MAX_SAMPLES = 0x8D57; + static constexpr const GLenum FRAMEBUFFER_SRGB = 0x8DB9; + static constexpr const GLenum HALF_FLOAT = 0x140B; + static constexpr const GLenum MAP_READ_BIT = 0x0001; + static constexpr const GLenum MAP_WRITE_BIT = 0x0002; + static constexpr const GLenum MAP_INVALIDATE_RANGE_BIT = 0x0004; + static constexpr const GLenum MAP_INVALIDATE_BUFFER_BIT = 0x0008; + static constexpr const GLenum MAP_FLUSH_EXPLICIT_BIT = 0x0010; + static constexpr const GLenum MAP_UNSYNCHRONIZED_BIT = 0x0020; + static constexpr const GLenum COMPRESSED_RED_RGTC1 = 0x8DBB; + static constexpr const GLenum COMPRESSED_SIGNED_RED_RGTC1 = 0x8DBC; + static constexpr const GLenum COMPRESSED_RG_RGTC2 = 0x8DBD; + static constexpr const GLenum COMPRESSED_SIGNED_RG_RGTC2 = 0x8DBE; + static constexpr const GLenum RG = 0x8227; + static constexpr const GLenum RG_INTEGER = 0x8228; + static constexpr const GLenum R8 = 0x8229; + static constexpr const GLenum R16 = 0x822A; + static constexpr const GLenum RG8 = 0x822B; + static constexpr const GLenum RG16 = 0x822C; + static constexpr const GLenum R16F = 0x822D; + static constexpr const GLenum R32F = 0x822E; + static constexpr const GLenum RG16F = 0x822F; + static constexpr const GLenum RG32F = 0x8230; + static constexpr const GLenum R8I = 0x8231; + static constexpr const GLenum R8UI = 0x8232; + static constexpr const GLenum R16I = 0x8233; + static constexpr const GLenum R16UI = 0x8234; + static constexpr const GLenum R32I = 0x8235; + static constexpr const GLenum R32UI = 0x8236; + static constexpr const GLenum RG8I = 0x8237; + static constexpr const GLenum RG8UI = 0x8238; + static constexpr const GLenum RG16I = 0x8239; + static constexpr const GLenum RG16UI = 0x823A; + static constexpr const GLenum RG32I = 0x823B; + static constexpr const GLenum RG32UI = 0x823C; + static constexpr const GLenum VERTEX_ARRAY_BINDING = 0x85B5; + static constexpr const GLenum SAMPLER_2D_RECT = 0x8B63; + static constexpr const GLenum SAMPLER_2D_RECT_SHADOW = 0x8B64; + static constexpr const GLenum SAMPLER_BUFFER = 0x8DC2; + static constexpr const GLenum INT_SAMPLER_2D_RECT = 0x8DCD; + static constexpr const GLenum INT_SAMPLER_BUFFER = 0x8DD0; + static constexpr const GLenum UNSIGNED_INT_SAMPLER_2D_RECT = 0x8DD5; + static constexpr const GLenum UNSIGNED_INT_SAMPLER_BUFFER = 0x8DD8; + static constexpr const GLenum TEXTURE_BUFFER = 0x8C2A; + static constexpr const GLenum MAX_TEXTURE_BUFFER_SIZE = 0x8C2B; + static constexpr const GLenum TEXTURE_BINDING_BUFFER = 0x8C2C; + static constexpr const GLenum TEXTURE_BUFFER_DATA_STORE_BINDING = 0x8C2D; + static constexpr const GLenum TEXTURE_RECTANGLE = 0x84F5; + static constexpr const GLenum TEXTURE_BINDING_RECTANGLE = 0x84F6; + static constexpr const GLenum PROXY_TEXTURE_RECTANGLE = 0x84F7; + static constexpr const GLenum MAX_RECTANGLE_TEXTURE_SIZE = 0x84F8; + static constexpr const GLenum R8_SNORM = 0x8F94; + static constexpr const GLenum RG8_SNORM = 0x8F95; + static constexpr const GLenum RGB8_SNORM = 0x8F96; + static constexpr const GLenum RGBA8_SNORM = 0x8F97; + static constexpr const GLenum R16_SNORM = 0x8F98; + static constexpr const GLenum RG16_SNORM = 0x8F99; + static constexpr const GLenum RGB16_SNORM = 0x8F9A; + static constexpr const GLenum RGBA16_SNORM = 0x8F9B; + static constexpr const GLenum SIGNED_NORMALIZED = 0x8F9C; + static constexpr const GLenum PRIMITIVE_RESTART = 0x8F9D; + static constexpr const GLenum PRIMITIVE_RESTART_INDEX = 0x8F9E; + static constexpr const GLenum COPY_READ_BUFFER = 0x8F36; + static constexpr const GLenum COPY_WRITE_BUFFER = 0x8F37; + static constexpr const GLenum UNIFORM_BUFFER = 0x8A11; + static constexpr const GLenum UNIFORM_BUFFER_BINDING = 0x8A28; + static constexpr const GLenum UNIFORM_BUFFER_START = 0x8A29; + static constexpr const GLenum UNIFORM_BUFFER_SIZE = 0x8A2A; + static constexpr const GLenum MAX_VERTEX_UNIFORM_BLOCKS = 0x8A2B; + static constexpr const GLenum MAX_GEOMETRY_UNIFORM_BLOCKS = 0x8A2C; + static constexpr const GLenum MAX_FRAGMENT_UNIFORM_BLOCKS = 0x8A2D; + static constexpr const GLenum MAX_COMBINED_UNIFORM_BLOCKS = 0x8A2E; + static constexpr const GLenum MAX_UNIFORM_BUFFER_BINDINGS = 0x8A2F; + static constexpr const GLenum MAX_UNIFORM_BLOCK_SIZE = 0x8A30; + static constexpr const GLenum MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS = 0x8A31; + static constexpr const GLenum MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS = 0x8A32; + static constexpr const GLenum MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS = 0x8A33; + static constexpr const GLenum UNIFORM_BUFFER_OFFSET_ALIGNMENT = 0x8A34; + static constexpr const GLenum ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH = 0x8A35; + static constexpr const GLenum ACTIVE_UNIFORM_BLOCKS = 0x8A36; + static constexpr const GLenum UNIFORM_TYPE = 0x8A37; + static constexpr const GLenum UNIFORM_SIZE = 0x8A38; + static constexpr const GLenum UNIFORM_NAME_LENGTH = 0x8A39; + static constexpr const GLenum UNIFORM_BLOCK_INDEX = 0x8A3A; + static constexpr const GLenum UNIFORM_OFFSET = 0x8A3B; + static constexpr const GLenum UNIFORM_ARRAY_STRIDE = 0x8A3C; + static constexpr const GLenum UNIFORM_MATRIX_STRIDE = 0x8A3D; + static constexpr const GLenum UNIFORM_IS_ROW_MAJOR = 0x8A3E; + static constexpr const GLenum UNIFORM_BLOCK_BINDING = 0x8A3F; + static constexpr const GLenum UNIFORM_BLOCK_DATA_SIZE = 0x8A40; + static constexpr const GLenum UNIFORM_BLOCK_NAME_LENGTH = 0x8A41; + static constexpr const GLenum UNIFORM_BLOCK_ACTIVE_UNIFORMS = 0x8A42; + static constexpr const GLenum UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES = 0x8A43; + static constexpr const GLenum UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER = 0x8A44; + static constexpr const GLenum UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER = 0x8A45; + static constexpr const GLenum UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER = 0x8A46; + static constexpr const GLenum INVALID_INDEX = 0xFFFFFFFFu; + static constexpr const GLenum CONTEXT_CORE_PROFILE_BIT = 0x00000001; + static constexpr const GLenum CONTEXT_COMPATIBILITY_PROFILE_BIT = 0x00000002; + static constexpr const GLenum LINES_ADJACENCY = 0x000A; + static constexpr const GLenum LINE_STRIP_ADJACENCY = 0x000B; + static constexpr const GLenum TRIANGLES_ADJACENCY = 0x000C; + static constexpr const GLenum TRIANGLE_STRIP_ADJACENCY = 0x000D; + static constexpr const GLenum PROGRAM_POINT_SIZE = 0x8642; + static constexpr const GLenum MAX_GEOMETRY_TEXTURE_IMAGE_UNITS = 0x8C29; + static constexpr const GLenum FRAMEBUFFER_ATTACHMENT_LAYERED = 0x8DA7; + static constexpr const GLenum FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS = 0x8DA8; + static constexpr const GLenum GEOMETRY_SHADER = 0x8DD9; + static constexpr const GLenum GEOMETRY_VERTICES_OUT = 0x8916; + static constexpr const GLenum GEOMETRY_INPUT_TYPE = 0x8917; + static constexpr const GLenum GEOMETRY_OUTPUT_TYPE = 0x8918; + static constexpr const GLenum MAX_GEOMETRY_UNIFORM_COMPONENTS = 0x8DDF; + static constexpr const GLenum MAX_GEOMETRY_OUTPUT_VERTICES = 0x8DE0; + static constexpr const GLenum MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS = 0x8DE1; + static constexpr const GLenum MAX_VERTEX_OUTPUT_COMPONENTS = 0x9122; + static constexpr const GLenum MAX_GEOMETRY_INPUT_COMPONENTS = 0x9123; + static constexpr const GLenum MAX_GEOMETRY_OUTPUT_COMPONENTS = 0x9124; + static constexpr const GLenum MAX_FRAGMENT_INPUT_COMPONENTS = 0x9125; + static constexpr const GLenum CONTEXT_PROFILE_MASK = 0x9126; + static constexpr const GLenum DEPTH_CLAMP = 0x864F; + static constexpr const GLenum QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION = 0x8E4C; + static constexpr const GLenum FIRST_VERTEX_CONVENTION = 0x8E4D; + static constexpr const GLenum LAST_VERTEX_CONVENTION = 0x8E4E; + static constexpr const GLenum PROVOKING_VERTEX = 0x8E4F; + static constexpr const GLenum TEXTURE_CUBE_MAP_SEAMLESS = 0x884F; + static constexpr const GLenum MAX_SERVER_WAIT_TIMEOUT = 0x9111; + static constexpr const GLenum OBJECT_TYPE = 0x9112; + static constexpr const GLenum SYNC_CONDITION = 0x9113; + static constexpr const GLenum SYNC_STATUS = 0x9114; + static constexpr const GLenum SYNC_FLAGS = 0x9115; + static constexpr const GLenum SYNC_FENCE = 0x9116; + static constexpr const GLenum SYNC_GPU_COMMANDS_COMPLETE = 0x9117; + static constexpr const GLenum UNSIGNALED = 0x9118; + static constexpr const GLenum SIGNALED = 0x9119; + static constexpr const GLenum ALREADY_SIGNALED = 0x911A; + static constexpr const GLenum TIMEOUT_EXPIRED = 0x911B; + static constexpr const GLenum CONDITION_SATISFIED = 0x911C; + static constexpr const GLenum _WAIT_FAILED = 0x911D; + static constexpr const GLuint64 TIMEOUT_IGNORED = 0xFFFFFFFFFFFFFFFFull; + static constexpr const GLenum SYNC_FLUSH_COMMANDS_BIT = 0x00000001; + static constexpr const GLenum SAMPLE_POSITION = 0x8E50; + static constexpr const GLenum SAMPLE_MASK = 0x8E51; + static constexpr const GLenum SAMPLE_MASK_VALUE = 0x8E52; + static constexpr const GLenum MAX_SAMPLE_MASK_WORDS = 0x8E59; + static constexpr const GLenum TEXTURE_2D_MULTISAMPLE = 0x9100; + static constexpr const GLenum PROXY_TEXTURE_2D_MULTISAMPLE = 0x9101; + static constexpr const GLenum TEXTURE_2D_MULTISAMPLE_ARRAY = 0x9102; + static constexpr const GLenum PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY = 0x9103; + static constexpr const GLenum TEXTURE_BINDING_2D_MULTISAMPLE = 0x9104; + static constexpr const GLenum TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY = 0x9105; + static constexpr const GLenum TEXTURE_SAMPLES = 0x9106; + static constexpr const GLenum TEXTURE_FIXED_SAMPLE_LOCATIONS = 0x9107; + static constexpr const GLenum SAMPLER_2D_MULTISAMPLE = 0x9108; + static constexpr const GLenum INT_SAMPLER_2D_MULTISAMPLE = 0x9109; + static constexpr const GLenum UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE = 0x910A; + static constexpr const GLenum SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910B; + static constexpr const GLenum INT_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910C; + static constexpr const GLenum UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910D; + static constexpr const GLenum MAX_COLOR_TEXTURE_SAMPLES = 0x910E; + static constexpr const GLenum MAX_DEPTH_TEXTURE_SAMPLES = 0x910F; + static constexpr const GLenum MAX_INTEGER_SAMPLES = 0x9110; + static constexpr const GLenum VERTEX_ATTRIB_ARRAY_DIVISOR = 0x88FE; + static constexpr const GLenum SRC1_COLOR = 0x88F9; + static constexpr const GLenum ONE_MINUS_SRC1_COLOR = 0x88FA; + static constexpr const GLenum ONE_MINUS_SRC1_ALPHA = 0x88FB; + static constexpr const GLenum MAX_DUAL_SOURCE_DRAW_BUFFERS = 0x88FC; + static constexpr const GLenum ANY_SAMPLES_PASSED = 0x8C2F; + static constexpr const GLenum SAMPLER_BINDING = 0x8919; + static constexpr const GLenum RGB10_A2UI = 0x906F; + static constexpr const GLenum TEXTURE_SWIZZLE_R = 0x8E42; + static constexpr const GLenum TEXTURE_SWIZZLE_G = 0x8E43; + static constexpr const GLenum TEXTURE_SWIZZLE_B = 0x8E44; + static constexpr const GLenum TEXTURE_SWIZZLE_A = 0x8E45; + static constexpr const GLenum TEXTURE_SWIZZLE_RGBA = 0x8E46; + static constexpr const GLenum TIME_ELAPSED = 0x88BF; + static constexpr const GLenum TIMESTAMP = 0x8E28; + static constexpr const GLenum INT_2_10_10_10_REV = 0x8D9F; + static constexpr const GLenum SAMPLE_SHADING = 0x8C36; + static constexpr const GLenum MIN_SAMPLE_SHADING_VALUE = 0x8C37; + static constexpr const GLenum MIN_PROGRAM_TEXTURE_GATHER_OFFSET = 0x8E5E; + static constexpr const GLenum MAX_PROGRAM_TEXTURE_GATHER_OFFSET = 0x8E5F; + static constexpr const GLenum TEXTURE_CUBE_MAP_ARRAY = 0x9009; + static constexpr const GLenum TEXTURE_BINDING_CUBE_MAP_ARRAY = 0x900A; + static constexpr const GLenum PROXY_TEXTURE_CUBE_MAP_ARRAY = 0x900B; + static constexpr const GLenum SAMPLER_CUBE_MAP_ARRAY = 0x900C; + static constexpr const GLenum SAMPLER_CUBE_MAP_ARRAY_SHADOW = 0x900D; + static constexpr const GLenum INT_SAMPLER_CUBE_MAP_ARRAY = 0x900E; + static constexpr const GLenum UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY = 0x900F; + static constexpr const GLenum DRAW_INDIRECT_BUFFER = 0x8F3F; + static constexpr const GLenum DRAW_INDIRECT_BUFFER_BINDING = 0x8F43; + static constexpr const GLenum GEOMETRY_SHADER_INVOCATIONS = 0x887F; + static constexpr const GLenum MAX_GEOMETRY_SHADER_INVOCATIONS = 0x8E5A; + static constexpr const GLenum MIN_FRAGMENT_INTERPOLATION_OFFSET = 0x8E5B; + static constexpr const GLenum MAX_FRAGMENT_INTERPOLATION_OFFSET = 0x8E5C; + static constexpr const GLenum FRAGMENT_INTERPOLATION_OFFSET_BITS = 0x8E5D; + static constexpr const GLenum MAX_VERTEX_STREAMS = 0x8E71; + static constexpr const GLenum DOUBLE_VEC2 = 0x8FFC; + static constexpr const GLenum DOUBLE_VEC3 = 0x8FFD; + static constexpr const GLenum DOUBLE_VEC4 = 0x8FFE; + static constexpr const GLenum DOUBLE_MAT2 = 0x8F46; + static constexpr const GLenum DOUBLE_MAT3 = 0x8F47; + static constexpr const GLenum DOUBLE_MAT4 = 0x8F48; + static constexpr const GLenum DOUBLE_MAT2x3 = 0x8F49; + static constexpr const GLenum DOUBLE_MAT2x4 = 0x8F4A; + static constexpr const GLenum DOUBLE_MAT3x2 = 0x8F4B; + static constexpr const GLenum DOUBLE_MAT3x4 = 0x8F4C; + static constexpr const GLenum DOUBLE_MAT4x2 = 0x8F4D; + static constexpr const GLenum DOUBLE_MAT4x3 = 0x8F4E; + static constexpr const GLenum ACTIVE_SUBROUTINES = 0x8DE5; + static constexpr const GLenum ACTIVE_SUBROUTINE_UNIFORMS = 0x8DE6; + static constexpr const GLenum ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS = 0x8E47; + static constexpr const GLenum ACTIVE_SUBROUTINE_MAX_LENGTH = 0x8E48; + static constexpr const GLenum ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH = 0x8E49; + static constexpr const GLenum MAX_SUBROUTINES = 0x8DE7; + static constexpr const GLenum MAX_SUBROUTINE_UNIFORM_LOCATIONS = 0x8DE8; + static constexpr const GLenum NUM_COMPATIBLE_SUBROUTINES = 0x8E4A; + static constexpr const GLenum COMPATIBLE_SUBROUTINES = 0x8E4B; + static constexpr const GLenum PATCHES = 0x000E; + static constexpr const GLenum PATCH_VERTICES = 0x8E72; + static constexpr const GLenum PATCH_DEFAULT_INNER_LEVEL = 0x8E73; + static constexpr const GLenum PATCH_DEFAULT_OUTER_LEVEL = 0x8E74; + static constexpr const GLenum TESS_CONTROL_OUTPUT_VERTICES = 0x8E75; + static constexpr const GLenum TESS_GEN_MODE = 0x8E76; + static constexpr const GLenum TESS_GEN_SPACING = 0x8E77; + static constexpr const GLenum TESS_GEN_VERTEX_ORDER = 0x8E78; + static constexpr const GLenum TESS_GEN_POINT_MODE = 0x8E79; + static constexpr const GLenum ISOLINES = 0x8E7A; + static constexpr const GLenum FRACTIONAL_ODD = 0x8E7B; + static constexpr const GLenum FRACTIONAL_EVEN = 0x8E7C; + static constexpr const GLenum MAX_PATCH_VERTICES = 0x8E7D; + static constexpr const GLenum MAX_TESS_GEN_LEVEL = 0x8E7E; + static constexpr const GLenum MAX_TESS_CONTROL_UNIFORM_COMPONENTS = 0x8E7F; + static constexpr const GLenum MAX_TESS_EVALUATION_UNIFORM_COMPONENTS = 0x8E80; + static constexpr const GLenum MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS = 0x8E81; + static constexpr const GLenum MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS = 0x8E82; + static constexpr const GLenum MAX_TESS_CONTROL_OUTPUT_COMPONENTS = 0x8E83; + static constexpr const GLenum MAX_TESS_PATCH_COMPONENTS = 0x8E84; + static constexpr const GLenum MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS = 0x8E85; + static constexpr const GLenum MAX_TESS_EVALUATION_OUTPUT_COMPONENTS = 0x8E86; + static constexpr const GLenum MAX_TESS_CONTROL_UNIFORM_BLOCKS = 0x8E89; + static constexpr const GLenum MAX_TESS_EVALUATION_UNIFORM_BLOCKS = 0x8E8A; + static constexpr const GLenum MAX_TESS_CONTROL_INPUT_COMPONENTS = 0x886C; + static constexpr const GLenum MAX_TESS_EVALUATION_INPUT_COMPONENTS = 0x886D; + static constexpr const GLenum MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS = 0x8E1E; + static constexpr const GLenum MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS = 0x8E1F; + static constexpr const GLenum UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER = 0x84F0; + static constexpr const GLenum UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER = 0x84F1; + static constexpr const GLenum TESS_EVALUATION_SHADER = 0x8E87; + static constexpr const GLenum TESS_CONTROL_SHADER = 0x8E88; + static constexpr const GLenum TRANSFORM_FEEDBACK = 0x8E22; + static constexpr const GLenum TRANSFORM_FEEDBACK_BUFFER_PAUSED = 0x8E23; + static constexpr const GLenum TRANSFORM_FEEDBACK_BUFFER_ACTIVE = 0x8E24; + static constexpr const GLenum TRANSFORM_FEEDBACK_BINDING = 0x8E25; + static constexpr const GLenum MAX_TRANSFORM_FEEDBACK_BUFFERS = 0x8E70; + static constexpr const GLenum FIXED = 0x140C; + static constexpr const GLenum IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A; + static constexpr const GLenum IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B; + static constexpr const GLenum LOW_FLOAT = 0x8DF0; + static constexpr const GLenum MEDIUM_FLOAT = 0x8DF1; + static constexpr const GLenum HIGH_FLOAT = 0x8DF2; + static constexpr const GLenum LOW_INT = 0x8DF3; + static constexpr const GLenum MEDIUM_INT = 0x8DF4; + static constexpr const GLenum HIGH_INT = 0x8DF5; + static constexpr const GLenum SHADER_COMPILER = 0x8DFA; + static constexpr const GLenum SHADER_BINARY_FORMATS = 0x8DF8; + static constexpr const GLenum NUM_SHADER_BINARY_FORMATS = 0x8DF9; + static constexpr const GLenum MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB; + static constexpr const GLenum MAX_VARYING_VECTORS = 0x8DFC; + static constexpr const GLenum MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD; + static constexpr const GLenum RGB565 = 0x8D62; + static constexpr const GLenum PROGRAM_BINARY_RETRIEVABLE_HINT = 0x8257; + static constexpr const GLenum PROGRAM_BINARY_LENGTH = 0x8741; + static constexpr const GLenum NUM_PROGRAM_BINARY_FORMATS = 0x87FE; + static constexpr const GLenum PROGRAM_BINARY_FORMATS = 0x87FF; + static constexpr const GLenum VERTEX_SHADER_BIT = 0x00000001; + static constexpr const GLenum FRAGMENT_SHADER_BIT = 0x00000002; + static constexpr const GLenum GEOMETRY_SHADER_BIT = 0x00000004; + static constexpr const GLenum TESS_CONTROL_SHADER_BIT = 0x00000008; + static constexpr const GLenum TESS_EVALUATION_SHADER_BIT = 0x00000010; + static constexpr const GLenum ALL_SHADER_BITS = 0xFFFFFFFF; + static constexpr const GLenum PROGRAM_SEPARABLE = 0x8258; + static constexpr const GLenum ACTIVE_PROGRAM = 0x8259; + static constexpr const GLenum PROGRAM_PIPELINE_BINDING = 0x825A; + static constexpr const GLenum MAX_VIEWPORTS = 0x825B; + static constexpr const GLenum VIEWPORT_SUBPIXEL_BITS = 0x825C; + static constexpr const GLenum VIEWPORT_BOUNDS_RANGE = 0x825D; + static constexpr const GLenum LAYER_PROVOKING_VERTEX = 0x825E; + static constexpr const GLenum VIEWPORT_INDEX_PROVOKING_VERTEX = 0x825F; + static constexpr const GLenum UNDEFINED_VERTEX = 0x8260; + static constexpr const GLenum COPY_READ_BUFFER_BINDING = 0x8F36; + static constexpr const GLenum COPY_WRITE_BUFFER_BINDING = 0x8F37; + static constexpr const GLenum TRANSFORM_FEEDBACK_ACTIVE = 0x8E24; + static constexpr const GLenum TRANSFORM_FEEDBACK_PAUSED = 0x8E23; + static constexpr const GLenum UNPACK_COMPRESSED_BLOCK_WIDTH = 0x9127; + static constexpr const GLenum UNPACK_COMPRESSED_BLOCK_HEIGHT = 0x9128; + static constexpr const GLenum UNPACK_COMPRESSED_BLOCK_DEPTH = 0x9129; + static constexpr const GLenum UNPACK_COMPRESSED_BLOCK_SIZE = 0x912A; + static constexpr const GLenum PACK_COMPRESSED_BLOCK_WIDTH = 0x912B; + static constexpr const GLenum PACK_COMPRESSED_BLOCK_HEIGHT = 0x912C; + static constexpr const GLenum PACK_COMPRESSED_BLOCK_DEPTH = 0x912D; + static constexpr const GLenum PACK_COMPRESSED_BLOCK_SIZE = 0x912E; + static constexpr const GLenum NUM_SAMPLE_COUNTS = 0x9380; + static constexpr const GLenum MIN_MAP_BUFFER_ALIGNMENT = 0x90BC; + static constexpr const GLenum ATOMIC_COUNTER_BUFFER = 0x92C0; + static constexpr const GLenum ATOMIC_COUNTER_BUFFER_BINDING = 0x92C1; + static constexpr const GLenum ATOMIC_COUNTER_BUFFER_START = 0x92C2; + static constexpr const GLenum ATOMIC_COUNTER_BUFFER_SIZE = 0x92C3; + static constexpr const GLenum ATOMIC_COUNTER_BUFFER_DATA_SIZE = 0x92C4; + static constexpr const GLenum ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS = 0x92C5; + static constexpr const GLenum ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES = 0x92C6; + static constexpr const GLenum ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER = 0x92C7; + static constexpr const GLenum ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER = 0x92C8; + static constexpr const GLenum ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER = 0x92C9; + static constexpr const GLenum ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER = 0x92CA; + static constexpr const GLenum ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER = 0x92CB; + static constexpr const GLenum MAX_VERTEX_ATOMIC_COUNTER_BUFFERS = 0x92CC; + static constexpr const GLenum MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS = 0x92CD; + static constexpr const GLenum MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS = 0x92CE; + static constexpr const GLenum MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS = 0x92CF; + static constexpr const GLenum MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS = 0x92D0; + static constexpr const GLenum MAX_COMBINED_ATOMIC_COUNTER_BUFFERS = 0x92D1; + static constexpr const GLenum MAX_VERTEX_ATOMIC_COUNTERS = 0x92D2; + static constexpr const GLenum MAX_TESS_CONTROL_ATOMIC_COUNTERS = 0x92D3; + static constexpr const GLenum MAX_TESS_EVALUATION_ATOMIC_COUNTERS = 0x92D4; + static constexpr const GLenum MAX_GEOMETRY_ATOMIC_COUNTERS = 0x92D5; + static constexpr const GLenum MAX_FRAGMENT_ATOMIC_COUNTERS = 0x92D6; + static constexpr const GLenum MAX_COMBINED_ATOMIC_COUNTERS = 0x92D7; + static constexpr const GLenum MAX_ATOMIC_COUNTER_BUFFER_SIZE = 0x92D8; + static constexpr const GLenum MAX_ATOMIC_COUNTER_BUFFER_BINDINGS = 0x92DC; + static constexpr const GLenum ACTIVE_ATOMIC_COUNTER_BUFFERS = 0x92D9; + static constexpr const GLenum UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX = 0x92DA; + static constexpr const GLenum UNSIGNED_INT_ATOMIC_COUNTER = 0x92DB; + static constexpr const GLenum VERTEX_ATTRIB_ARRAY_BARRIER_BIT = 0x00000001; + static constexpr const GLenum ELEMENT_ARRAY_BARRIER_BIT = 0x00000002; + static constexpr const GLenum UNIFORM_BARRIER_BIT = 0x00000004; + static constexpr const GLenum TEXTURE_FETCH_BARRIER_BIT = 0x00000008; + static constexpr const GLenum SHADER_IMAGE_ACCESS_BARRIER_BIT = 0x00000020; + static constexpr const GLenum COMMAND_BARRIER_BIT = 0x00000040; + static constexpr const GLenum PIXEL_BUFFER_BARRIER_BIT = 0x00000080; + static constexpr const GLenum TEXTURE_UPDATE_BARRIER_BIT = 0x00000100; + static constexpr const GLenum BUFFER_UPDATE_BARRIER_BIT = 0x00000200; + static constexpr const GLenum FRAMEBUFFER_BARRIER_BIT = 0x00000400; + static constexpr const GLenum TRANSFORM_FEEDBACK_BARRIER_BIT = 0x00000800; + static constexpr const GLenum ATOMIC_COUNTER_BARRIER_BIT = 0x00001000; + static constexpr const GLenum ALL_BARRIER_BITS = 0xFFFFFFFF; + static constexpr const GLenum MAX_IMAGE_UNITS = 0x8F38; + static constexpr const GLenum MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS = 0x8F39; + static constexpr const GLenum IMAGE_BINDING_NAME = 0x8F3A; + static constexpr const GLenum IMAGE_BINDING_LEVEL = 0x8F3B; + static constexpr const GLenum IMAGE_BINDING_LAYERED = 0x8F3C; + static constexpr const GLenum IMAGE_BINDING_LAYER = 0x8F3D; + static constexpr const GLenum IMAGE_BINDING_ACCESS = 0x8F3E; + static constexpr const GLenum IMAGE_1D = 0x904C; + static constexpr const GLenum IMAGE_2D = 0x904D; + static constexpr const GLenum IMAGE_3D = 0x904E; + static constexpr const GLenum IMAGE_2D_RECT = 0x904F; + static constexpr const GLenum IMAGE_CUBE = 0x9050; + static constexpr const GLenum IMAGE_BUFFER = 0x9051; + static constexpr const GLenum IMAGE_1D_ARRAY = 0x9052; + static constexpr const GLenum IMAGE_2D_ARRAY = 0x9053; + static constexpr const GLenum IMAGE_CUBE_MAP_ARRAY = 0x9054; + static constexpr const GLenum IMAGE_2D_MULTISAMPLE = 0x9055; + static constexpr const GLenum IMAGE_2D_MULTISAMPLE_ARRAY = 0x9056; + static constexpr const GLenum INT_IMAGE_1D = 0x9057; + static constexpr const GLenum INT_IMAGE_2D = 0x9058; + static constexpr const GLenum INT_IMAGE_3D = 0x9059; + static constexpr const GLenum INT_IMAGE_2D_RECT = 0x905A; + static constexpr const GLenum INT_IMAGE_CUBE = 0x905B; + static constexpr const GLenum INT_IMAGE_BUFFER = 0x905C; + static constexpr const GLenum INT_IMAGE_1D_ARRAY = 0x905D; + static constexpr const GLenum INT_IMAGE_2D_ARRAY = 0x905E; + static constexpr const GLenum INT_IMAGE_CUBE_MAP_ARRAY = 0x905F; + static constexpr const GLenum INT_IMAGE_2D_MULTISAMPLE = 0x9060; + static constexpr const GLenum INT_IMAGE_2D_MULTISAMPLE_ARRAY = 0x9061; + static constexpr const GLenum UNSIGNED_INT_IMAGE_1D = 0x9062; + static constexpr const GLenum UNSIGNED_INT_IMAGE_2D = 0x9063; + static constexpr const GLenum UNSIGNED_INT_IMAGE_3D = 0x9064; + static constexpr const GLenum UNSIGNED_INT_IMAGE_2D_RECT = 0x9065; + static constexpr const GLenum UNSIGNED_INT_IMAGE_CUBE = 0x9066; + static constexpr const GLenum UNSIGNED_INT_IMAGE_BUFFER = 0x9067; + static constexpr const GLenum UNSIGNED_INT_IMAGE_1D_ARRAY = 0x9068; + static constexpr const GLenum UNSIGNED_INT_IMAGE_2D_ARRAY = 0x9069; + static constexpr const GLenum UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY = 0x906A; + static constexpr const GLenum UNSIGNED_INT_IMAGE_2D_MULTISAMPLE = 0x906B; + static constexpr const GLenum UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY = 0x906C; + static constexpr const GLenum MAX_IMAGE_SAMPLES = 0x906D; + static constexpr const GLenum IMAGE_BINDING_FORMAT = 0x906E; + static constexpr const GLenum IMAGE_FORMAT_COMPATIBILITY_TYPE = 0x90C7; + static constexpr const GLenum IMAGE_FORMAT_COMPATIBILITY_BY_SIZE = 0x90C8; + static constexpr const GLenum IMAGE_FORMAT_COMPATIBILITY_BY_CLASS = 0x90C9; + static constexpr const GLenum MAX_VERTEX_IMAGE_UNIFORMS = 0x90CA; + static constexpr const GLenum MAX_TESS_CONTROL_IMAGE_UNIFORMS = 0x90CB; + static constexpr const GLenum MAX_TESS_EVALUATION_IMAGE_UNIFORMS = 0x90CC; + static constexpr const GLenum MAX_GEOMETRY_IMAGE_UNIFORMS = 0x90CD; + static constexpr const GLenum MAX_FRAGMENT_IMAGE_UNIFORMS = 0x90CE; + static constexpr const GLenum MAX_COMBINED_IMAGE_UNIFORMS = 0x90CF; + static constexpr const GLenum COMPRESSED_RGBA_BPTC_UNORM = 0x8E8C; + static constexpr const GLenum COMPRESSED_SRGB_ALPHA_BPTC_UNORM = 0x8E8D; + static constexpr const GLenum COMPRESSED_RGB_BPTC_SIGNED_FLOAT = 0x8E8E; + static constexpr const GLenum COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT = 0x8E8F; + static constexpr const GLenum TEXTURE_IMMUTABLE_FORMAT = 0x912F; + static constexpr const GLenum NUM_SHADING_LANGUAGE_VERSIONS = 0x82E9; + static constexpr const GLenum VERTEX_ATTRIB_ARRAY_LONG = 0x874E; + static constexpr const GLenum COMPRESSED_RGB8_ETC2 = 0x9274; + static constexpr const GLenum COMPRESSED_SRGB8_ETC2 = 0x9275; + static constexpr const GLenum COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276; + static constexpr const GLenum COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277; + static constexpr const GLenum COMPRESSED_RGBA8_ETC2_EAC = 0x9278; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279; + static constexpr const GLenum COMPRESSED_R11_EAC = 0x9270; + static constexpr const GLenum COMPRESSED_SIGNED_R11_EAC = 0x9271; + static constexpr const GLenum COMPRESSED_RG11_EAC = 0x9272; + static constexpr const GLenum COMPRESSED_SIGNED_RG11_EAC = 0x9273; + static constexpr const GLenum PRIMITIVE_RESTART_FIXED_INDEX = 0x8D69; + static constexpr const GLenum ANY_SAMPLES_PASSED_CONSERVATIVE = 0x8D6A; + static constexpr const GLenum MAX_ELEMENT_INDEX = 0x8D6B; + static constexpr const GLenum COMPUTE_SHADER = 0x91B9; + static constexpr const GLenum MAX_COMPUTE_UNIFORM_BLOCKS = 0x91BB; + static constexpr const GLenum MAX_COMPUTE_TEXTURE_IMAGE_UNITS = 0x91BC; + static constexpr const GLenum MAX_COMPUTE_IMAGE_UNIFORMS = 0x91BD; + static constexpr const GLenum MAX_COMPUTE_SHARED_MEMORY_SIZE = 0x8262; + static constexpr const GLenum MAX_COMPUTE_UNIFORM_COMPONENTS = 0x8263; + static constexpr const GLenum MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS = 0x8264; + static constexpr const GLenum MAX_COMPUTE_ATOMIC_COUNTERS = 0x8265; + static constexpr const GLenum MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS = 0x8266; + static constexpr const GLenum MAX_COMPUTE_WORK_GROUP_INVOCATIONS = 0x90EB; + static constexpr const GLenum MAX_COMPUTE_WORK_GROUP_COUNT = 0x91BE; + static constexpr const GLenum MAX_COMPUTE_WORK_GROUP_SIZE = 0x91BF; + static constexpr const GLenum COMPUTE_WORK_GROUP_SIZE = 0x8267; + static constexpr const GLenum UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER = 0x90EC; + static constexpr const GLenum ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER = 0x90ED; + static constexpr const GLenum DISPATCH_INDIRECT_BUFFER = 0x90EE; + static constexpr const GLenum DISPATCH_INDIRECT_BUFFER_BINDING = 0x90EF; + static constexpr const GLenum COMPUTE_SHADER_BIT = 0x00000020; + static constexpr const GLenum DEBUG_OUTPUT_SYNCHRONOUS = 0x8242; + static constexpr const GLenum DEBUG_NEXT_LOGGED_MESSAGE_LENGTH = 0x8243; + static constexpr const GLenum DEBUG_CALLBACK_FUNCTION = 0x8244; + static constexpr const GLenum DEBUG_CALLBACK_USER_PARAM = 0x8245; + static constexpr const GLenum DEBUG_SOURCE_API = 0x8246; + static constexpr const GLenum DEBUG_SOURCE_WINDOW_SYSTEM = 0x8247; + static constexpr const GLenum DEBUG_SOURCE_SHADER_COMPILER = 0x8248; + static constexpr const GLenum DEBUG_SOURCE_THIRD_PARTY = 0x8249; + static constexpr const GLenum DEBUG_SOURCE_APPLICATION = 0x824A; + static constexpr const GLenum DEBUG_SOURCE_OTHER = 0x824B; + static constexpr const GLenum DEBUG_TYPE_ERROR = 0x824C; + static constexpr const GLenum DEBUG_TYPE_DEPRECATED_BEHAVIOR = 0x824D; + static constexpr const GLenum DEBUG_TYPE_UNDEFINED_BEHAVIOR = 0x824E; + static constexpr const GLenum DEBUG_TYPE_PORTABILITY = 0x824F; + static constexpr const GLenum DEBUG_TYPE_PERFORMANCE = 0x8250; + static constexpr const GLenum DEBUG_TYPE_OTHER = 0x8251; + static constexpr const GLenum MAX_DEBUG_MESSAGE_LENGTH = 0x9143; + static constexpr const GLenum MAX_DEBUG_LOGGED_MESSAGES = 0x9144; + static constexpr const GLenum DEBUG_LOGGED_MESSAGES = 0x9145; + static constexpr const GLenum DEBUG_SEVERITY_HIGH = 0x9146; + static constexpr const GLenum DEBUG_SEVERITY_MEDIUM = 0x9147; + static constexpr const GLenum DEBUG_SEVERITY_LOW = 0x9148; + static constexpr const GLenum DEBUG_TYPE_MARKER = 0x8268; + static constexpr const GLenum DEBUG_TYPE_PUSH_GROUP = 0x8269; + static constexpr const GLenum DEBUG_TYPE_POP_GROUP = 0x826A; + static constexpr const GLenum DEBUG_SEVERITY_NOTIFICATION = 0x826B; + static constexpr const GLenum MAX_DEBUG_GROUP_STACK_DEPTH = 0x826C; + static constexpr const GLenum DEBUG_GROUP_STACK_DEPTH = 0x826D; + static constexpr const GLenum BUFFER = 0x82E0; + static constexpr const GLenum SHADER = 0x82E1; + static constexpr const GLenum PROGRAM = 0x82E2; + static constexpr const GLenum QUERY = 0x82E3; + static constexpr const GLenum PROGRAM_PIPELINE = 0x82E4; + static constexpr const GLenum SAMPLER = 0x82E6; + static constexpr const GLenum MAX_LABEL_LENGTH = 0x82E8; + static constexpr const GLenum DEBUG_OUTPUT = 0x92E0; + static constexpr const GLenum CONTEXT_FLAG_DEBUG_BIT = 0x00000002; + static constexpr const GLenum MAX_UNIFORM_LOCATIONS = 0x826E; + static constexpr const GLenum FRAMEBUFFER_DEFAULT_WIDTH = 0x9310; + static constexpr const GLenum FRAMEBUFFER_DEFAULT_HEIGHT = 0x9311; + static constexpr const GLenum FRAMEBUFFER_DEFAULT_LAYERS = 0x9312; + static constexpr const GLenum FRAMEBUFFER_DEFAULT_SAMPLES = 0x9313; + static constexpr const GLenum FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS = 0x9314; + static constexpr const GLenum MAX_FRAMEBUFFER_WIDTH = 0x9315; + static constexpr const GLenum MAX_FRAMEBUFFER_HEIGHT = 0x9316; + static constexpr const GLenum MAX_FRAMEBUFFER_LAYERS = 0x9317; + static constexpr const GLenum MAX_FRAMEBUFFER_SAMPLES = 0x9318; + static constexpr const GLenum INTERNALFORMAT_SUPPORTED = 0x826F; + static constexpr const GLenum INTERNALFORMAT_PREFERRED = 0x8270; + static constexpr const GLenum INTERNALFORMAT_RED_SIZE = 0x8271; + static constexpr const GLenum INTERNALFORMAT_GREEN_SIZE = 0x8272; + static constexpr const GLenum INTERNALFORMAT_BLUE_SIZE = 0x8273; + static constexpr const GLenum INTERNALFORMAT_ALPHA_SIZE = 0x8274; + static constexpr const GLenum INTERNALFORMAT_DEPTH_SIZE = 0x8275; + static constexpr const GLenum INTERNALFORMAT_STENCIL_SIZE = 0x8276; + static constexpr const GLenum INTERNALFORMAT_SHARED_SIZE = 0x8277; + static constexpr const GLenum INTERNALFORMAT_RED_TYPE = 0x8278; + static constexpr const GLenum INTERNALFORMAT_GREEN_TYPE = 0x8279; + static constexpr const GLenum INTERNALFORMAT_BLUE_TYPE = 0x827A; + static constexpr const GLenum INTERNALFORMAT_ALPHA_TYPE = 0x827B; + static constexpr const GLenum INTERNALFORMAT_DEPTH_TYPE = 0x827C; + static constexpr const GLenum INTERNALFORMAT_STENCIL_TYPE = 0x827D; + static constexpr const GLenum MAX_WIDTH = 0x827E; + static constexpr const GLenum MAX_HEIGHT = 0x827F; + static constexpr const GLenum MAX_DEPTH = 0x8280; + static constexpr const GLenum MAX_LAYERS = 0x8281; + static constexpr const GLenum MAX_COMBINED_DIMENSIONS = 0x8282; + static constexpr const GLenum COLOR_COMPONENTS = 0x8283; + static constexpr const GLenum DEPTH_COMPONENTS = 0x8284; + static constexpr const GLenum STENCIL_COMPONENTS = 0x8285; + static constexpr const GLenum COLOR_RENDERABLE = 0x8286; + static constexpr const GLenum DEPTH_RENDERABLE = 0x8287; + static constexpr const GLenum STENCIL_RENDERABLE = 0x8288; + static constexpr const GLenum FRAMEBUFFER_RENDERABLE = 0x8289; + static constexpr const GLenum FRAMEBUFFER_RENDERABLE_LAYERED = 0x828A; + static constexpr const GLenum FRAMEBUFFER_BLEND = 0x828B; + static constexpr const GLenum READ_PIXELS = 0x828C; + static constexpr const GLenum READ_PIXELS_FORMAT = 0x828D; + static constexpr const GLenum READ_PIXELS_TYPE = 0x828E; + static constexpr const GLenum TEXTURE_IMAGE_FORMAT = 0x828F; + static constexpr const GLenum TEXTURE_IMAGE_TYPE = 0x8290; + static constexpr const GLenum GET_TEXTURE_IMAGE_FORMAT = 0x8291; + static constexpr const GLenum GET_TEXTURE_IMAGE_TYPE = 0x8292; + static constexpr const GLenum MIPMAP = 0x8293; + static constexpr const GLenum MANUAL_GENERATE_MIPMAP = 0x8294; + static constexpr const GLenum AUTO_GENERATE_MIPMAP = 0x8295; + static constexpr const GLenum COLOR_ENCODING = 0x8296; + static constexpr const GLenum SRGB_READ = 0x8297; + static constexpr const GLenum SRGB_WRITE = 0x8298; + static constexpr const GLenum FILTER = 0x829A; + static constexpr const GLenum VERTEX_TEXTURE = 0x829B; + static constexpr const GLenum TESS_CONTROL_TEXTURE = 0x829C; + static constexpr const GLenum TESS_EVALUATION_TEXTURE = 0x829D; + static constexpr const GLenum GEOMETRY_TEXTURE = 0x829E; + static constexpr const GLenum FRAGMENT_TEXTURE = 0x829F; + static constexpr const GLenum COMPUTE_TEXTURE = 0x82A0; + static constexpr const GLenum TEXTURE_SHADOW = 0x82A1; + static constexpr const GLenum TEXTURE_GATHER = 0x82A2; + static constexpr const GLenum TEXTURE_GATHER_SHADOW = 0x82A3; + static constexpr const GLenum SHADER_IMAGE_LOAD = 0x82A4; + static constexpr const GLenum SHADER_IMAGE_STORE = 0x82A5; + static constexpr const GLenum SHADER_IMAGE_ATOMIC = 0x82A6; + static constexpr const GLenum IMAGE_TEXEL_SIZE = 0x82A7; + static constexpr const GLenum IMAGE_COMPATIBILITY_CLASS = 0x82A8; + static constexpr const GLenum IMAGE_PIXEL_FORMAT = 0x82A9; + static constexpr const GLenum IMAGE_PIXEL_TYPE = 0x82AA; + static constexpr const GLenum SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST = 0x82AC; + static constexpr const GLenum SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST = 0x82AD; + static constexpr const GLenum SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE = 0x82AE; + static constexpr const GLenum SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE = 0x82AF; + static constexpr const GLenum TEXTURE_COMPRESSED_BLOCK_WIDTH = 0x82B1; + static constexpr const GLenum TEXTURE_COMPRESSED_BLOCK_HEIGHT = 0x82B2; + static constexpr const GLenum TEXTURE_COMPRESSED_BLOCK_SIZE = 0x82B3; + static constexpr const GLenum CLEAR_BUFFER = 0x82B4; + static constexpr const GLenum TEXTURE_VIEW = 0x82B5; + static constexpr const GLenum VIEW_COMPATIBILITY_CLASS = 0x82B6; + static constexpr const GLenum FULL_SUPPORT = 0x82B7; + static constexpr const GLenum CAVEAT_SUPPORT = 0x82B8; + static constexpr const GLenum IMAGE_CLASS_4_X_32 = 0x82B9; + static constexpr const GLenum IMAGE_CLASS_2_X_32 = 0x82BA; + static constexpr const GLenum IMAGE_CLASS_1_X_32 = 0x82BB; + static constexpr const GLenum IMAGE_CLASS_4_X_16 = 0x82BC; + static constexpr const GLenum IMAGE_CLASS_2_X_16 = 0x82BD; + static constexpr const GLenum IMAGE_CLASS_1_X_16 = 0x82BE; + static constexpr const GLenum IMAGE_CLASS_4_X_8 = 0x82BF; + static constexpr const GLenum IMAGE_CLASS_2_X_8 = 0x82C0; + static constexpr const GLenum IMAGE_CLASS_1_X_8 = 0x82C1; + static constexpr const GLenum IMAGE_CLASS_11_11_10 = 0x82C2; + static constexpr const GLenum IMAGE_CLASS_10_10_10_2 = 0x82C3; + static constexpr const GLenum VIEW_CLASS_128_BITS = 0x82C4; + static constexpr const GLenum VIEW_CLASS_96_BITS = 0x82C5; + static constexpr const GLenum VIEW_CLASS_64_BITS = 0x82C6; + static constexpr const GLenum VIEW_CLASS_48_BITS = 0x82C7; + static constexpr const GLenum VIEW_CLASS_32_BITS = 0x82C8; + static constexpr const GLenum VIEW_CLASS_24_BITS = 0x82C9; + static constexpr const GLenum VIEW_CLASS_16_BITS = 0x82CA; + static constexpr const GLenum VIEW_CLASS_8_BITS = 0x82CB; + static constexpr const GLenum VIEW_CLASS_S3TC_DXT1_RGB = 0x82CC; + static constexpr const GLenum VIEW_CLASS_S3TC_DXT1_RGBA = 0x82CD; + static constexpr const GLenum VIEW_CLASS_S3TC_DXT3_RGBA = 0x82CE; + static constexpr const GLenum VIEW_CLASS_S3TC_DXT5_RGBA = 0x82CF; + static constexpr const GLenum VIEW_CLASS_RGTC1_RED = 0x82D0; + static constexpr const GLenum VIEW_CLASS_RGTC2_RG = 0x82D1; + static constexpr const GLenum VIEW_CLASS_BPTC_UNORM = 0x82D2; + static constexpr const GLenum VIEW_CLASS_BPTC_FLOAT = 0x82D3; + static constexpr const GLenum UNIFORM = 0x92E1; + static constexpr const GLenum UNIFORM_BLOCK = 0x92E2; + static constexpr const GLenum PROGRAM_INPUT = 0x92E3; + static constexpr const GLenum PROGRAM_OUTPUT = 0x92E4; + static constexpr const GLenum BUFFER_VARIABLE = 0x92E5; + static constexpr const GLenum SHADER_STORAGE_BLOCK = 0x92E6; + static constexpr const GLenum VERTEX_SUBROUTINE = 0x92E8; + static constexpr const GLenum TESS_CONTROL_SUBROUTINE = 0x92E9; + static constexpr const GLenum TESS_EVALUATION_SUBROUTINE = 0x92EA; + static constexpr const GLenum GEOMETRY_SUBROUTINE = 0x92EB; + static constexpr const GLenum FRAGMENT_SUBROUTINE = 0x92EC; + static constexpr const GLenum COMPUTE_SUBROUTINE = 0x92ED; + static constexpr const GLenum VERTEX_SUBROUTINE_UNIFORM = 0x92EE; + static constexpr const GLenum TESS_CONTROL_SUBROUTINE_UNIFORM = 0x92EF; + static constexpr const GLenum TESS_EVALUATION_SUBROUTINE_UNIFORM = 0x92F0; + static constexpr const GLenum GEOMETRY_SUBROUTINE_UNIFORM = 0x92F1; + static constexpr const GLenum FRAGMENT_SUBROUTINE_UNIFORM = 0x92F2; + static constexpr const GLenum COMPUTE_SUBROUTINE_UNIFORM = 0x92F3; + static constexpr const GLenum TRANSFORM_FEEDBACK_VARYING = 0x92F4; + static constexpr const GLenum ACTIVE_RESOURCES = 0x92F5; + static constexpr const GLenum MAX_NAME_LENGTH = 0x92F6; + static constexpr const GLenum MAX_NUM_ACTIVE_VARIABLES = 0x92F7; + static constexpr const GLenum MAX_NUM_COMPATIBLE_SUBROUTINES = 0x92F8; + static constexpr const GLenum NAME_LENGTH = 0x92F9; + static constexpr const GLenum TYPE = 0x92FA; + static constexpr const GLenum ARRAY_SIZE = 0x92FB; + static constexpr const GLenum OFFSET = 0x92FC; + static constexpr const GLenum BLOCK_INDEX = 0x92FD; + static constexpr const GLenum ARRAY_STRIDE = 0x92FE; + static constexpr const GLenum MATRIX_STRIDE = 0x92FF; + static constexpr const GLenum IS_ROW_MAJOR = 0x9300; + static constexpr const GLenum ATOMIC_COUNTER_BUFFER_INDEX = 0x9301; + static constexpr const GLenum BUFFER_BINDING = 0x9302; + static constexpr const GLenum BUFFER_DATA_SIZE = 0x9303; + static constexpr const GLenum NUM_ACTIVE_VARIABLES = 0x9304; + static constexpr const GLenum ACTIVE_VARIABLES = 0x9305; + static constexpr const GLenum REFERENCED_BY_VERTEX_SHADER = 0x9306; + static constexpr const GLenum REFERENCED_BY_TESS_CONTROL_SHADER = 0x9307; + static constexpr const GLenum REFERENCED_BY_TESS_EVALUATION_SHADER = 0x9308; + static constexpr const GLenum REFERENCED_BY_GEOMETRY_SHADER = 0x9309; + static constexpr const GLenum REFERENCED_BY_FRAGMENT_SHADER = 0x930A; + static constexpr const GLenum REFERENCED_BY_COMPUTE_SHADER = 0x930B; + static constexpr const GLenum TOP_LEVEL_ARRAY_SIZE = 0x930C; + static constexpr const GLenum TOP_LEVEL_ARRAY_STRIDE = 0x930D; + static constexpr const GLenum LOCATION = 0x930E; + static constexpr const GLenum LOCATION_INDEX = 0x930F; + static constexpr const GLenum IS_PER_PATCH = 0x92E7; + static constexpr const GLenum SHADER_STORAGE_BUFFER = 0x90D2; + static constexpr const GLenum SHADER_STORAGE_BUFFER_BINDING = 0x90D3; + static constexpr const GLenum SHADER_STORAGE_BUFFER_START = 0x90D4; + static constexpr const GLenum SHADER_STORAGE_BUFFER_SIZE = 0x90D5; + static constexpr const GLenum MAX_VERTEX_SHADER_STORAGE_BLOCKS = 0x90D6; + static constexpr const GLenum MAX_GEOMETRY_SHADER_STORAGE_BLOCKS = 0x90D7; + static constexpr const GLenum MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS = 0x90D8; + static constexpr const GLenum MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS = 0x90D9; + static constexpr const GLenum MAX_FRAGMENT_SHADER_STORAGE_BLOCKS = 0x90DA; + static constexpr const GLenum MAX_COMPUTE_SHADER_STORAGE_BLOCKS = 0x90DB; + static constexpr const GLenum MAX_COMBINED_SHADER_STORAGE_BLOCKS = 0x90DC; + static constexpr const GLenum MAX_SHADER_STORAGE_BUFFER_BINDINGS = 0x90DD; + static constexpr const GLenum MAX_SHADER_STORAGE_BLOCK_SIZE = 0x90DE; + static constexpr const GLenum SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT = 0x90DF; + static constexpr const GLenum SHADER_STORAGE_BARRIER_BIT = 0x00002000; + static constexpr const GLenum MAX_COMBINED_SHADER_OUTPUT_RESOURCES = 0x8F39; + static constexpr const GLenum DEPTH_STENCIL_TEXTURE_MODE = 0x90EA; + static constexpr const GLenum TEXTURE_BUFFER_OFFSET = 0x919D; + static constexpr const GLenum TEXTURE_BUFFER_SIZE = 0x919E; + static constexpr const GLenum TEXTURE_BUFFER_OFFSET_ALIGNMENT = 0x919F; + static constexpr const GLenum TEXTURE_VIEW_MIN_LEVEL = 0x82DB; + static constexpr const GLenum TEXTURE_VIEW_NUM_LEVELS = 0x82DC; + static constexpr const GLenum TEXTURE_VIEW_MIN_LAYER = 0x82DD; + static constexpr const GLenum TEXTURE_VIEW_NUM_LAYERS = 0x82DE; + static constexpr const GLenum TEXTURE_IMMUTABLE_LEVELS = 0x82DF; + static constexpr const GLenum VERTEX_ATTRIB_BINDING = 0x82D4; + static constexpr const GLenum VERTEX_ATTRIB_RELATIVE_OFFSET = 0x82D5; + static constexpr const GLenum VERTEX_BINDING_DIVISOR = 0x82D6; + static constexpr const GLenum VERTEX_BINDING_OFFSET = 0x82D7; + static constexpr const GLenum VERTEX_BINDING_STRIDE = 0x82D8; + static constexpr const GLenum MAX_VERTEX_ATTRIB_RELATIVE_OFFSET = 0x82D9; + static constexpr const GLenum MAX_VERTEX_ATTRIB_BINDINGS = 0x82DA; + static constexpr const GLenum VERTEX_BINDING_BUFFER = 0x8F4F; + static constexpr const GLenum MAX_VERTEX_ATTRIB_STRIDE = 0x82E5; + static constexpr const GLenum PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED = 0x8221; + static constexpr const GLenum TEXTURE_BUFFER_BINDING = 0x8C2A; + static constexpr const GLenum MAP_PERSISTENT_BIT = 0x0040; + static constexpr const GLenum MAP_COHERENT_BIT = 0x0080; + static constexpr const GLenum DYNAMIC_STORAGE_BIT = 0x0100; + static constexpr const GLenum CLIENT_STORAGE_BIT = 0x0200; + static constexpr const GLenum CLIENT_MAPPED_BUFFER_BARRIER_BIT = 0x00004000; + static constexpr const GLenum BUFFER_IMMUTABLE_STORAGE = 0x821F; + static constexpr const GLenum BUFFER_STORAGE_FLAGS = 0x8220; + static constexpr const GLenum CLEAR_TEXTURE = 0x9365; + static constexpr const GLenum LOCATION_COMPONENT = 0x934A; + static constexpr const GLenum TRANSFORM_FEEDBACK_BUFFER_INDEX = 0x934B; + static constexpr const GLenum TRANSFORM_FEEDBACK_BUFFER_STRIDE = 0x934C; + static constexpr const GLenum QUERY_BUFFER = 0x9192; + static constexpr const GLenum QUERY_BUFFER_BARRIER_BIT = 0x00008000; + static constexpr const GLenum QUERY_BUFFER_BINDING = 0x9193; + static constexpr const GLenum QUERY_RESULT_NO_WAIT = 0x9194; + static constexpr const GLenum MIRROR_CLAMP_TO_EDGE = 0x8743; + static constexpr const GLenum CONTEXT_LOST = 0x0507; + static constexpr const GLenum NEGATIVE_ONE_TO_ONE = 0x935E; + static constexpr const GLenum ZERO_TO_ONE = 0x935F; + static constexpr const GLenum CLIP_ORIGIN = 0x935C; + static constexpr const GLenum CLIP_DEPTH_MODE = 0x935D; + static constexpr const GLenum QUERY_WAIT_INVERTED = 0x8E17; + static constexpr const GLenum QUERY_NO_WAIT_INVERTED = 0x8E18; + static constexpr const GLenum QUERY_BY_REGION_WAIT_INVERTED = 0x8E19; + static constexpr const GLenum QUERY_BY_REGION_NO_WAIT_INVERTED = 0x8E1A; + static constexpr const GLenum MAX_CULL_DISTANCES = 0x82F9; + static constexpr const GLenum MAX_COMBINED_CLIP_AND_CULL_DISTANCES = 0x82FA; + static constexpr const GLenum TEXTURE_TARGET = 0x1006; + static constexpr const GLenum QUERY_TARGET = 0x82EA; + static constexpr const GLenum GUILTY_CONTEXT_RESET = 0x8253; + static constexpr const GLenum INNOCENT_CONTEXT_RESET = 0x8254; + static constexpr const GLenum UNKNOWN_CONTEXT_RESET = 0x8255; + static constexpr const GLenum RESET_NOTIFICATION_STRATEGY = 0x8256; + static constexpr const GLenum LOSE_CONTEXT_ON_RESET = 0x8252; + static constexpr const GLenum NO_RESET_NOTIFICATION = 0x8261; + static constexpr const GLenum CONTEXT_FLAG_ROBUST_ACCESS_BIT = 0x00000004; + static constexpr const GLenum CONTEXT_RELEASE_BEHAVIOR = 0x82FB; + static constexpr const GLenum CONTEXT_RELEASE_BEHAVIOR_FLUSH = 0x82FC; + static constexpr const GLenum SHADER_BINARY_FORMAT_SPIR_V = 0x9551; + static constexpr const GLenum SPIR_V_BINARY = 0x9552; + static constexpr const GLenum PARAMETER_BUFFER = 0x80EE; + static constexpr const GLenum PARAMETER_BUFFER_BINDING = 0x80EF; + static constexpr const GLenum CONTEXT_FLAG_NO_ERROR_BIT = 0x00000008; + static constexpr const GLenum VERTICES_SUBMITTED = 0x82EE; + static constexpr const GLenum PRIMITIVES_SUBMITTED = 0x82EF; + static constexpr const GLenum VERTEX_SHADER_INVOCATIONS = 0x82F0; + static constexpr const GLenum TESS_CONTROL_SHADER_PATCHES = 0x82F1; + static constexpr const GLenum TESS_EVALUATION_SHADER_INVOCATIONS = 0x82F2; + static constexpr const GLenum GEOMETRY_SHADER_PRIMITIVES_EMITTED = 0x82F3; + static constexpr const GLenum FRAGMENT_SHADER_INVOCATIONS = 0x82F4; + static constexpr const GLenum COMPUTE_SHADER_INVOCATIONS = 0x82F5; + static constexpr const GLenum CLIPPING_INPUT_PRIMITIVES = 0x82F6; + static constexpr const GLenum CLIPPING_OUTPUT_PRIMITIVES = 0x82F7; + static constexpr const GLenum POLYGON_OFFSET_CLAMP = 0x8E1B; + static constexpr const GLenum SPIR_V_EXTENSIONS = 0x9553; + static constexpr const GLenum NUM_SPIR_V_EXTENSIONS = 0x9554; + static constexpr const GLenum TEXTURE_MAX_ANISOTROPY = 0x84FE; + static constexpr const GLenum MAX_TEXTURE_MAX_ANISOTROPY = 0x84FF; + static constexpr const GLenum TRANSFORM_FEEDBACK_OVERFLOW = 0x82EC; + static constexpr const GLenum TRANSFORM_FEEDBACK_STREAM_OVERFLOW = 0x82ED; + static constexpr const GLenum PRIMITIVE_BOUNDING_BOX = 0x92BE; + static constexpr const GLenum MULTISAMPLE_LINE_WIDTH_RANGE = 0x9381; + static constexpr const GLenum MULTISAMPLE_LINE_WIDTH_GRANULARITY = 0x9382; + static constexpr const GLenum UNSIGNED_INT64 = 0x140F; + static constexpr const GLenum SYNC_CL_EVENT = 0x8240; + static constexpr const GLenum SYNC_CL_EVENT_COMPLETE = 0x8241; + static constexpr const GLenum MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS = 0x9344; + static constexpr const GLenum MAX_COMPUTE_FIXED_GROUP_INVOCATIONS = 0x90EB; + static constexpr const GLenum MAX_COMPUTE_VARIABLE_GROUP_SIZE = 0x9345; + static constexpr const GLenum MAX_COMPUTE_FIXED_GROUP_SIZE = 0x91BF; + static constexpr const GLenum FRAMEBUFFER_INCOMPLETE_LAYER_COUNT = 0x8DA9; + static constexpr const GLenum MAX_GEOMETRY_VARYING_COMPONENTS = 0x8DDD; + static constexpr const GLenum MAX_VERTEX_VARYING_COMPONENTS = 0x8DDE; + static constexpr const GLenum INT64 = 0x140E; + static constexpr const GLenum INT64_VEC2 = 0x8FE9; + static constexpr const GLenum INT64_VEC3 = 0x8FEA; + static constexpr const GLenum INT64_VEC4 = 0x8FEB; + static constexpr const GLenum UNSIGNED_INT64_VEC2 = 0x8FF5; + static constexpr const GLenum UNSIGNED_INT64_VEC3 = 0x8FF6; + static constexpr const GLenum UNSIGNED_INT64_VEC4 = 0x8FF7; + static constexpr const GLenum SRGB_DECODE = 0x8299; + static constexpr const GLenum VIEW_CLASS_EAC_R11 = 0x9383; + static constexpr const GLenum VIEW_CLASS_EAC_RG11 = 0x9384; + static constexpr const GLenum VIEW_CLASS_ETC2_RGB = 0x9385; + static constexpr const GLenum VIEW_CLASS_ETC2_RGBA = 0x9386; + static constexpr const GLenum VIEW_CLASS_ETC2_EAC_RGBA = 0x9387; + static constexpr const GLenum VIEW_CLASS_ASTC_4x4_RGBA = 0x9388; + static constexpr const GLenum VIEW_CLASS_ASTC_5x4_RGBA = 0x9389; + static constexpr const GLenum VIEW_CLASS_ASTC_5x5_RGBA = 0x938A; + static constexpr const GLenum VIEW_CLASS_ASTC_6x5_RGBA = 0x938B; + static constexpr const GLenum VIEW_CLASS_ASTC_6x6_RGBA = 0x938C; + static constexpr const GLenum VIEW_CLASS_ASTC_8x5_RGBA = 0x938D; + static constexpr const GLenum VIEW_CLASS_ASTC_8x6_RGBA = 0x938E; + static constexpr const GLenum VIEW_CLASS_ASTC_8x8_RGBA = 0x938F; + static constexpr const GLenum VIEW_CLASS_ASTC_10x5_RGBA = 0x9390; + static constexpr const GLenum VIEW_CLASS_ASTC_10x6_RGBA = 0x9391; + static constexpr const GLenum VIEW_CLASS_ASTC_10x8_RGBA = 0x9392; + static constexpr const GLenum VIEW_CLASS_ASTC_10x10_RGBA = 0x9393; + static constexpr const GLenum VIEW_CLASS_ASTC_12x10_RGBA = 0x9394; + static constexpr const GLenum VIEW_CLASS_ASTC_12x12_RGBA = 0x9395; + static constexpr const GLenum MAX_SHADER_COMPILER_THREADS = 0x91B0; + static constexpr const GLenum COMPLETION_STATUS = 0x91B1; + static constexpr const GLenum SAMPLE_LOCATION_SUBPIXEL_BITS = 0x933D; + static constexpr const GLenum SAMPLE_LOCATION_PIXEL_GRID_WIDTH = 0x933E; + static constexpr const GLenum SAMPLE_LOCATION_PIXEL_GRID_HEIGHT = 0x933F; + static constexpr const GLenum PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE = 0x9340; + static constexpr const GLenum SAMPLE_LOCATION = 0x8E50; + static constexpr const GLenum PROGRAMMABLE_SAMPLE_LOCATION = 0x9341; + static constexpr const GLenum FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS = 0x9342; + static constexpr const GLenum FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID = 0x9343; + static constexpr const GLenum SHADER_INCLUDE = 0x8DAE; + static constexpr const GLenum NAMED_STRING_LENGTH = 0x8DE9; + static constexpr const GLenum NAMED_STRING_TYPE = 0x8DEA; + static constexpr const GLenum SPARSE_STORAGE_BIT = 0x0400; + static constexpr const GLenum SPARSE_BUFFER_PAGE_SIZE = 0x82F8; + static constexpr const GLenum TEXTURE_SPARSE = 0x91A6; + static constexpr const GLenum VIRTUAL_PAGE_SIZE_INDEX = 0x91A7; + static constexpr const GLenum NUM_SPARSE_LEVELS = 0x91AA; + static constexpr const GLenum NUM_VIRTUAL_PAGE_SIZES = 0x91A8; + static constexpr const GLenum VIRTUAL_PAGE_SIZE_X = 0x9195; + static constexpr const GLenum VIRTUAL_PAGE_SIZE_Y = 0x9196; + static constexpr const GLenum VIRTUAL_PAGE_SIZE_Z = 0x9197; + static constexpr const GLenum MAX_SPARSE_TEXTURE_SIZE = 0x9198; + static constexpr const GLenum MAX_SPARSE_3D_TEXTURE_SIZE = 0x9199; + static constexpr const GLenum MAX_SPARSE_ARRAY_TEXTURE_LAYERS = 0x919A; + static constexpr const GLenum SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS = 0x91A9; + static constexpr const GLenum TEXTURE_BUFFER_FORMAT = 0x8C2E; + static constexpr const GLenum TEXTURE_REDUCTION_MODE = 0x9366; + static constexpr const GLenum WEIGHTED_AVERAGE = 0x9367; + static constexpr const GLenum MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS = 0x8F9F; + static constexpr const GLenum MULTIPLY = 0x9294; + static constexpr const GLenum SCREEN = 0x9295; + static constexpr const GLenum OVERLAY = 0x9296; + static constexpr const GLenum DARKEN = 0x9297; + static constexpr const GLenum LIGHTEN = 0x9298; + static constexpr const GLenum COLORDODGE = 0x9299; + static constexpr const GLenum COLORBURN = 0x929A; + static constexpr const GLenum HARDLIGHT = 0x929B; + static constexpr const GLenum SOFTLIGHT = 0x929C; + static constexpr const GLenum _DIFFERENCE = 0x929E; + static constexpr const GLenum EXCLUSION = 0x92A0; + static constexpr const GLenum HSL_HUE = 0x92AD; + static constexpr const GLenum HSL_SATURATION = 0x92AE; + static constexpr const GLenum HSL_COLOR = 0x92AF; + static constexpr const GLenum HSL_LUMINOSITY = 0x92B0; + static constexpr const GLenum BLEND_ADVANCED_COHERENT = 0x9285; + static constexpr const GLenum CONTEXT_ROBUST_ACCESS = 0x90F3; + static constexpr const GLenum SUBGROUP_SIZE = 0x9532; + static constexpr const GLenum SUBGROUP_SUPPORTED_STAGES = 0x9533; + static constexpr const GLenum SUBGROUP_SUPPORTED_FEATURES = 0x9534; + static constexpr const GLenum SUBGROUP_QUAD_ALL_STAGES = 0x9535; + static constexpr const GLenum SUBGROUP_FEATURE_BASIC_BIT = 0x00000001; + static constexpr const GLenum SUBGROUP_FEATURE_VOTE_BIT = 0x00000002; + static constexpr const GLenum SUBGROUP_FEATURE_ARITHMETIC_BIT = 0x00000004; + static constexpr const GLenum SUBGROUP_FEATURE_BALLOT_BIT = 0x00000008; + static constexpr const GLenum SUBGROUP_FEATURE_SHUFFLE_BIT = 0x00000010; + static constexpr const GLenum SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT = 0x00000020; + static constexpr const GLenum SUBGROUP_FEATURE_CLUSTERED_BIT = 0x00000040; + static constexpr const GLenum SUBGROUP_FEATURE_QUAD_BIT = 0x00000080; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_4x4 = 0x93B0; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_5x4 = 0x93B1; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_5x5 = 0x93B2; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_6x5 = 0x93B3; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_6x6 = 0x93B4; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_8x5 = 0x93B5; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_8x6 = 0x93B6; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_8x8 = 0x93B7; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_10x5 = 0x93B8; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_10x6 = 0x93B9; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_10x8 = 0x93BA; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_10x10 = 0x93BB; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_12x10 = 0x93BC; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_12x12 = 0x93BD; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_4x4 = 0x93D0; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_5x4 = 0x93D1; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_5x5 = 0x93D2; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_6x5 = 0x93D3; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_6x6 = 0x93D4; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_8x5 = 0x93D5; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_8x6 = 0x93D6; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_8x8 = 0x93D7; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_10x5 = 0x93D8; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_10x6 = 0x93D9; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_10x8 = 0x93DA; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_10x10 = 0x93DB; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_12x10 = 0x93DC; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_12x12 = 0x93DD; + static constexpr const GLenum PROGRAM_PIPELINE_OBJECT = 0x8A4F; + static constexpr const GLenum PROGRAM_OBJECT = 0x8B40; + static constexpr const GLenum SHADER_OBJECT = 0x8B48; + static constexpr const GLenum BUFFER_OBJECT = 0x9151; + static constexpr const GLenum QUERY_OBJECT = 0x9153; + static constexpr const GLenum VERTEX_ARRAY_OBJECT = 0x9154; + static constexpr const GLenum PROGRAM_MATRIX = 0x8E2D; + static constexpr const GLenum TRANSPOSE_PROGRAM_MATRIX = 0x8E2E; + static constexpr const GLenum PROGRAM_MATRIX_STACK_DEPTH = 0x8E2F; + static constexpr const GLenum RASTER_MULTISAMPLE = 0x9327; + static constexpr const GLenum RASTER_SAMPLES = 0x9328; + static constexpr const GLenum MAX_RASTER_SAMPLES = 0x9329; + static constexpr const GLenum RASTER_FIXED_SAMPLE_LOCATIONS = 0x932A; + static constexpr const GLenum MULTISAMPLE_RASTERIZATION_ALLOWED = 0x932B; + static constexpr const GLenum EFFECTIVE_RASTER_SAMPLES = 0x932C; + static constexpr const GLenum FRAGMENT_SHADER_DISCARDS_SAMPLES = 0x8A52; + static constexpr const GLenum COMPRESSED_RGB_S3TC_DXT1 = 0x83F0; + static constexpr const GLenum COMPRESSED_RGBA_S3TC_DXT1 = 0x83F1; + static constexpr const GLenum COMPRESSED_RGBA_S3TC_DXT3 = 0x83F2; + static constexpr const GLenum COMPRESSED_RGBA_S3TC_DXT5 = 0x83F3; + static constexpr const GLenum SR8 = 0x8FBD; + static constexpr const GLenum SRG8 = 0x8FBE; + static constexpr const GLenum TEXTURE_SRGB_DECODE = 0x8A48; + static constexpr const GLenum DECODE = 0x8A49; + 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 EXCLUSIVE = 0x8F11; + static constexpr const GLenum WINDOW_RECTANGLE = 0x8F12; + static constexpr const GLenum WINDOW_RECTANGLE_MODE = 0x8F13; + static constexpr const GLenum MAX_WINDOW_RECTANGLES = 0x8F14; + static constexpr const GLenum NUM_WINDOW_RECTANGLES = 0x8F15; + static constexpr const GLenum TEXTURE_EXTERNAL = 0x8D65; + static constexpr const GLenum TEXTURE_BINDING_EXTERNAL = 0x8D67; + static constexpr const GLenum REQUIRED_TEXTURE_IMAGE_UNITS = 0x8D68; + static constexpr const GLenum SAMPLER_EXTERNAL = 0x8D66; + static constexpr const GLenum ETC1_RGB8 = 0x8D64; + static constexpr const GLenum PALETTE4_RGB8 = 0x8B90; + static constexpr const GLenum PALETTE4_RGBA8 = 0x8B91; + static constexpr const GLenum PALETTE4_R5_G6_B5 = 0x8B92; + static constexpr const GLenum PALETTE4_RGBA4 = 0x8B93; + static constexpr const GLenum PALETTE4_RGB5_A1 = 0x8B94; + static constexpr const GLenum PALETTE8_RGB8 = 0x8B95; + static constexpr const GLenum PALETTE8_RGBA8 = 0x8B96; + static constexpr const GLenum PALETTE8_R5_G6_B5 = 0x8B97; + static constexpr const GLenum PALETTE8_RGBA4 = 0x8B98; + static constexpr const GLenum PALETTE8_RGB5_A1 = 0x8B99; + static constexpr const GLenum GEOMETRY_LINKED_VERTICES_OUT = 0x8916; + static constexpr const GLenum GEOMETRY_LINKED_INPUT_TYPE = 0x8917; + static constexpr const GLenum GEOMETRY_LINKED_OUTPUT_TYPE = 0x8918; + static constexpr const GLenum LUMINANCE4_ALPHA4 = 0x8043; + 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_4x3x3 = 0x93C1; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_4x4x3 = 0x93C2; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_4x4x4 = 0x93C3; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_5x4x4 = 0x93C4; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_5x5x4 = 0x93C5; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_5x5x5 = 0x93C6; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_6x5x5 = 0x93C7; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_6x6x5 = 0x93C8; + static constexpr const GLenum COMPRESSED_RGBA_ASTC_6x6x6 = 0x93C9; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3 = 0x93E0; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3 = 0x93E1; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3 = 0x93E2; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4 = 0x93E3; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4 = 0x93E4; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4 = 0x93E5; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5 = 0x93E6; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5 = 0x93E7; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5 = 0x93E8; + static constexpr const GLenum COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6 = 0x93E9; + static constexpr const GLenum INT_10_10_10_2 = 0x8DF7; + static constexpr const GLenum MALI_PROGRAM_BINARY_ARM = 0x8F61; + static constexpr const GLenum MALI_SHADER_BINARY_ARM = 0x8F60; + static constexpr const GLenum FETCH_PER_SAMPLE_ARM = 0x8F65; + static constexpr const GLenum FRAGMENT_SHADER_FRAMEBUFFER_FETCH_MRT_ARM = 0x8F66; + static constexpr const GLenum TEXTURE_UNNORMALIZED_COORDINATES_ARM = 0x8F6A; + static constexpr const GLenum SMAPHS30_PROGRAM_BINARY_DMP = 0x9251; + static constexpr const GLenum SMAPHS_PROGRAM_BINARY_DMP = 0x9252; + static constexpr const GLenum DMP_PROGRAM_BINARY_DMP = 0x9253; + 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 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 DEDICATED_MEMORY_OBJECT = 0x9581; + static constexpr const GLenum PROTECTED_MEMORY_OBJECT = 0x959B; + static constexpr const GLenum NUM_TILING_TYPES = 0x9582; + static constexpr const GLenum TILING_TYPES = 0x9583; + static constexpr const GLenum OPTIMAL_TILING = 0x9584; + static constexpr const GLenum LINEAR_TILING = 0x9585; + static constexpr const GLenum NUM_DEVICE_UUIDS = 0x9596; + static constexpr const GLenum DEVICE_UUID = 0x9597; + static constexpr const GLenum DRIVER_UUID = 0x9598; + static constexpr const GLenum HANDLE_TYPE_OPAQUE_FD = 0x9586; + static constexpr const GLenum HANDLE_TYPE_OPAQUE_WIN32 = 0x9587; + static constexpr const GLenum HANDLE_TYPE_OPAQUE_WIN32_KMT = 0x9588; + static constexpr const GLenum DEVICE_LUID = 0x9599; + static constexpr const GLenum DEVICE_NODE_MASK = 0x959A; + static constexpr const GLenum HANDLE_TYPE_D3D12_TILEPOOL = 0x9589; + static constexpr const GLenum HANDLE_TYPE_D3D12_RESOURCE = 0x958A; + static constexpr const GLenum HANDLE_TYPE_D3D11_IMAGE = 0x958B; + static constexpr const GLenum HANDLE_TYPE_D3D11_IMAGE_KMT = 0x958C; + static constexpr const GLenum FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES = 0x8D6C; + static constexpr const GLenum COLOR_ATTACHMENT = 0x90F0; + static constexpr const GLenum MULTIVIEW = 0x90F1; + static constexpr const GLenum MAX_MULTIVIEW_BUFFERS = 0x90F2; + static constexpr const GLenum CONTEXT_FLAG_PROTECTED_CONTENT_BIT = 0x00000010; + static constexpr const GLenum TEXTURE_PROTECTED = 0x8BFA; + static constexpr const GLenum COMPRESSED_SRGB_PVRTC_2BPPV1 = 0x8A54; + static constexpr const GLenum COMPRESSED_SRGB_PVRTC_4BPPV1 = 0x8A55; + static constexpr const GLenum COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1 = 0x8A56; + static constexpr const GLenum COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1 = 0x8A57; + static constexpr const GLenum LAYOUT_GENERAL = 0x958D; + static constexpr const GLenum LAYOUT_COLOR_ATTACHMENT = 0x958E; + static constexpr const GLenum LAYOUT_DEPTH_STENCIL_ATTACHMENT = 0x958F; + static constexpr const GLenum LAYOUT_DEPTH_STENCIL_READ_ONLY = 0x9590; + static constexpr const GLenum LAYOUT_SHADER_READ_ONLY = 0x9591; + static constexpr const GLenum LAYOUT_TRANSFER_SRC = 0x9592; + static constexpr const GLenum LAYOUT_TRANSFER_DST = 0x9593; + static constexpr const GLenum LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT = 0x9530; + static constexpr const GLenum LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY = 0x9531; + static constexpr const GLenum HANDLE_TYPE_D3D12_FENCE = 0x9594; + static constexpr const GLenum D3D12_FENCE_VALUE = 0x9595; + static constexpr const GLenum MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE = 0x8F63; + static constexpr const GLenum MAX_SHADER_PIXEL_LOCAL_STORAGE_SIZE = 0x8F67; + static constexpr const GLenum SHADER_PIXEL_LOCAL_STORAGE = 0x8F64; + static constexpr const GLenum MAX_SHADER_COMBINED_LOCAL_STORAGE_FAST_SIZE = 0x9650; + static constexpr const GLenum MAX_SHADER_COMBINED_LOCAL_STORAGE_SIZE = 0x9651; + static constexpr const GLenum FRAMEBUFFER_INCOMPLETE_INSUFFICIENT_SHADER_COMBINED_LOCAL_STORAGE = 0x9652; + static constexpr const GLenum TEXTURE_ASTC_DECODE_PRECISION = 0x8F69; + static constexpr const GLenum COMPRESSED_RED_GREEN_RGTC2 = 0x8DBD; + static constexpr const GLenum COMPRESSED_SIGNED_RED_GREEN_RGTC2 = 0x8DBE; + static constexpr const GLenum COMPRESSED_SRGB_S3TC_DXT1 = 0x8C4C; + static constexpr const GLenum COMPRESSED_SRGB_ALPHA_S3TC_DXT1 = 0x8C4D; + static constexpr const GLenum COMPRESSED_SRGB_ALPHA_S3TC_DXT3 = 0x8C4E; + static constexpr const GLenum COMPRESSED_SRGB_ALPHA_S3TC_DXT5 = 0x8C4F; + static constexpr const GLenum TEXTURE_FORMAT_SRGB_OVERRIDE = 0x8FBF; + static constexpr const GLenum NUM_SURFACE_COMPRESSION_FIXED_RATES = 0x8F6E; + static constexpr const GLenum SURFACE_COMPRESSION_FIXED_RATE_1BPC = 0x96C4; + static constexpr const GLenum SURFACE_COMPRESSION_FIXED_RATE_2BPC = 0x96C5; + static constexpr const GLenum SURFACE_COMPRESSION_FIXED_RATE_3BPC = 0x96C6; + static constexpr const GLenum SURFACE_COMPRESSION_FIXED_RATE_4BPC = 0x96C7; + 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 STATE_RESTORE = 0x8BDC; + static constexpr const GLenum SHADER_BINARY_VIV = 0x8FC4; + + static constexpr const GLenum ZERO = 0; + static constexpr const GLenum ONE = 1; + static constexpr const GLenum NONE = 0; +}; + +// Global GL procedures object. +IRRLICHT_API extern OpenGLProcedures GL; diff --git a/irr/include/path.h b/irr/include/path.h new file mode 100644 index 000000000..06476ef7b --- /dev/null +++ b/irr/include/path.h @@ -0,0 +1,86 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine" and the "irrXML" project. +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrString.h" + +namespace irr +{ +namespace io +{ + +//! Type used for all file system related strings. +/** This type will transparently handle different file system encodings. + NOTE: For historical reasons the tool-functions using io::path are all in coreutil.h +*/ +typedef core::string path; + +// Type only exists for historcal reasons, paths are always char now. +static_assert(sizeof(fschar_t) == sizeof(char)); + +//! Used in places where we identify objects by a filename, but don't actually work with the real filename +/** Irrlicht is internally not case-sensitive when it comes to names. + Also this class is a first step towards support for correctly serializing renamed objects. +*/ +struct SNamedPath +{ + //! Constructor + SNamedPath() {} + + //! Constructor + SNamedPath(const path &p) : + Path(p), InternalName(PathToName(p)) + { + } + + //! Is smaller comparator + bool operator<(const SNamedPath &other) const + { + return InternalName < other.InternalName; + } + + //! Set the path. + void setPath(const path &p) + { + Path = p; + InternalName = PathToName(p); + } + + //! Get the path. + const path &getPath() const + { + return Path; + }; + + //! Get the name which is used to identify the file. + //! This string is similar to the names and filenames used before Irrlicht 1.7 + const path &getInternalName() const + { + return InternalName; + } + + //! Implicit cast to io::path + operator core::stringc() const + { + return core::stringc(getPath()); + } + +protected: + // convert the given path string to a name string. + path PathToName(const path &p) const + { + path name(p); + name.replace('\\', '/'); + name.make_lower(); + return name; + } + +private: + path Path; + path InternalName; +}; + +} // io +} // irr diff --git a/irr/include/plane3d.h b/irr/include/plane3d.h new file mode 100644 index 000000000..4003325b5 --- /dev/null +++ b/irr/include/plane3d.h @@ -0,0 +1,244 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrMath.h" +#include "vector3d.h" + +namespace irr +{ +namespace core +{ + +//! Enumeration for intersection relations of 3d objects +enum EIntersectionRelation3D +{ + ISREL3D_FRONT = 0, + ISREL3D_BACK, + ISREL3D_PLANAR, + ISREL3D_SPANNING, + ISREL3D_CLIPPED +}; + +//! Template plane class with some intersection testing methods. +/** It has to be ensured, that the normal is always normalized. The constructors + and setters of this class will not ensure this automatically. So any normal + passed in has to be normalized in advance. No change to the normal will be + made by any of the class methods. +*/ +template +class plane3d +{ +public: + // Constructors + + plane3d() : + Normal(0, 1, 0) { recalculateD(vector3d(0, 0, 0)); } + + plane3d(const vector3d &MPoint, const vector3d &Normal) : + Normal(Normal) { recalculateD(MPoint); } + + plane3d(T px, T py, T pz, T nx, T ny, T nz) : + Normal(nx, ny, nz) { recalculateD(vector3d(px, py, pz)); } + + plane3d(const vector3d &point1, const vector3d &point2, const vector3d &point3) + { + setPlane(point1, point2, point3); + } + + plane3d(const vector3d &normal, const T d) : + Normal(normal), D(d) {} + + // operators + + inline bool operator==(const plane3d &other) const { return (equals(D, other.D) && Normal == other.Normal); } + + inline bool operator!=(const plane3d &other) const { return !(*this == other); } + + // functions + + void setPlane(const vector3d &point, const vector3d &nvector) + { + Normal = nvector; + recalculateD(point); + } + + void setPlane(const vector3d &nvect, T d) + { + Normal = nvect; + D = d; + } + + void setPlane(const vector3d &point1, const vector3d &point2, const vector3d &point3) + { + // creates the plane from 3 memberpoints + Normal = (point2 - point1).crossProduct(point3 - point1); + Normal.normalize(); + + recalculateD(point1); + } + + //! Get an intersection with a 3d line. + /** \param lineVect Vector of the line to intersect with. + \param linePoint Point of the line to intersect with. + \param outIntersection Place to store the intersection point, if there is one. + \return True if there was an intersection, false if there was not. + */ + bool getIntersectionWithLine(const vector3d &linePoint, + const vector3d &lineVect, + vector3d &outIntersection) const + { + T t2 = Normal.dotProduct(lineVect); + + if (t2 == 0) + return false; + + T t = -(Normal.dotProduct(linePoint) + D) / t2; + outIntersection = linePoint + (lineVect * t); + return true; + } + + //! Get percentage of line between two points where an intersection with this plane happens. + /** Only useful if known that there is an intersection. + \param linePoint1 Point1 of the line to intersect with. + \param linePoint2 Point2 of the line to intersect with. + \return Where on a line between two points an intersection with this plane happened. + For example, 0.5 is returned if the intersection happened exactly in the middle of the two points. + */ + f32 getKnownIntersectionWithLine(const vector3d &linePoint1, + const vector3d &linePoint2) const + { + vector3d vect = linePoint2 - linePoint1; + T t2 = (f32)Normal.dotProduct(vect); + return (f32) - ((Normal.dotProduct(linePoint1) + D) / t2); + } + + //! Get an intersection with a 3d line, limited between two 3d points. + /** \param linePoint1 Point 1 of the line. + \param linePoint2 Point 2 of the line. + \param outIntersection Place to store the intersection point, if there is one. + \return True if there was an intersection, false if there was not. + */ + bool getIntersectionWithLimitedLine( + const vector3d &linePoint1, + const vector3d &linePoint2, + vector3d &outIntersection) const + { + return (getIntersectionWithLine(linePoint1, linePoint2 - linePoint1, outIntersection) && + outIntersection.isBetweenPoints(linePoint1, linePoint2)); + } + + //! Classifies the relation of a point to this plane. + /** \param point Point to classify its relation. + \return ISREL3D_FRONT if the point is in front of the plane, + ISREL3D_BACK if the point is behind of the plane, and + ISREL3D_PLANAR if the point is within the plane. */ + EIntersectionRelation3D classifyPointRelation(const vector3d &point) const + { + const T d = Normal.dotProduct(point) + D; + + if (d < -ROUNDING_ERROR_f32) + return ISREL3D_BACK; + + if (d > ROUNDING_ERROR_f32) + return ISREL3D_FRONT; + + return ISREL3D_PLANAR; + } + + //! Recalculates the distance from origin by applying a new member point to the plane. + void recalculateD(const vector3d &MPoint) + { + D = -MPoint.dotProduct(Normal); + } + + //! Gets a member point of the plane. + vector3d getMemberPoint() const + { + return Normal * -D; + } + + //! Tests if there is an intersection with the other plane + /** \return True if there is a intersection. */ + bool existsIntersection(const plane3d &other) const + { + vector3d cross = other.Normal.crossProduct(Normal); + return cross.getLength() > core::ROUNDING_ERROR_f32; + } + + //! Intersects this plane with another. + /** \param other Other plane to intersect with. + \param outLinePoint Base point of intersection line. + \param outLineVect Vector of intersection. + \return True if there is a intersection, false if not. */ + bool getIntersectionWithPlane(const plane3d &other, + vector3d &outLinePoint, + vector3d &outLineVect) const + { + const T fn00 = Normal.getLength(); + const T fn01 = Normal.dotProduct(other.Normal); + const T fn11 = other.Normal.getLength(); + const f64 det = fn00 * fn11 - fn01 * fn01; + + if (fabs(det) < ROUNDING_ERROR_f64) + return false; + + const f64 invdet = 1.0 / det; + const f64 fc0 = (fn11 * -D + fn01 * other.D) * invdet; + const f64 fc1 = (fn00 * -other.D + fn01 * D) * invdet; + + outLineVect = Normal.crossProduct(other.Normal); + outLinePoint = Normal * (T)fc0 + other.Normal * (T)fc1; + return true; + } + + //! Get the intersection point with two other planes if there is one. + bool getIntersectionWithPlanes(const plane3d &o1, + const plane3d &o2, vector3d &outPoint) const + { + vector3d linePoint, lineVect; + if (getIntersectionWithPlane(o1, linePoint, lineVect)) + return o2.getIntersectionWithLine(linePoint, lineVect, outPoint); + + return false; + } + + //! Test if the triangle would be front or backfacing from any point. + /** Thus, this method assumes a camera position from + which the triangle is definitely visible when looking into + the given direction. + Note that this only works if the normal is Normalized. + Do not use this method with points as it will give wrong results! + \param lookDirection: Look direction. + \return True if the plane is front facing and + false if it is backfacing. */ + bool isFrontFacing(const vector3d &lookDirection) const + { + const f32 d = Normal.dotProduct(lookDirection); + return F32_LOWER_EQUAL_0(d); + } + + //! Get the distance to a point. + /** Note that this only works if the normal is normalized. */ + T getDistanceTo(const vector3d &point) const + { + return point.dotProduct(Normal) + D; + } + + //! Normal vector of the plane. + vector3d Normal; + + //! Distance from origin. + T D; +}; + +//! Typedef for a f32 3d plane. +typedef plane3d plane3df; + +//! Typedef for an integer 3d plane. +typedef plane3d plane3di; + +} // end namespace core +} // end namespace irr diff --git a/irr/include/position2d.h b/irr/include/position2d.h new file mode 100644 index 000000000..ff0d30f4f --- /dev/null +++ b/irr/include/position2d.h @@ -0,0 +1,28 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +//! As of Irrlicht 1.6, position2d is a synonym for vector2d. +/** You should consider position2d to be deprecated, and use vector2d by preference. */ + +#pragma once + +#include "vector2d.h" + +namespace irr +{ +namespace core +{ + +// Use typedefs where possible as they are more explicit... + +//! \deprecated position2d is now a synonym for vector2d, but vector2d should be used directly. +typedef vector2d position2df; + +//! \deprecated position2d is now a synonym for vector2d, but vector2d should be used directly. +typedef vector2d position2di; +} // namespace core +} // namespace irr + +// ...and use a #define to catch the rest, for (e.g.) position2d +#define position2d vector2d diff --git a/irr/include/quaternion.h b/irr/include/quaternion.h new file mode 100644 index 000000000..5a2e16367 --- /dev/null +++ b/irr/include/quaternion.h @@ -0,0 +1,712 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" +#include "irrMath.h" +#include "matrix4.h" +#include "vector3d.h" + +// NOTE: You *only* need this when updating an application from Irrlicht before 1.8 to Irrlicht 1.8 or later. +// Between Irrlicht 1.7 and Irrlicht 1.8 the quaternion-matrix conversions changed. +// Before the fix they had mixed left- and right-handed rotations. +// To test if your code was affected by the change enable IRR_TEST_BROKEN_QUATERNION_USE and try to compile your application. +// This defines removes those functions so you get compile errors anywhere you use them in your code. +// For every line with a compile-errors you have to change the corresponding lines like that: +// - When you pass the matrix to the quaternion constructor then replace the matrix by the transposed matrix. +// - For uses of getMatrix() you have to use quaternion::getMatrix_transposed instead. +// #define IRR_TEST_BROKEN_QUATERNION_USE + +namespace irr +{ +namespace core +{ + +//! Quaternion class for representing rotations. +/** It provides cheap combinations and avoids gimbal locks. +Also useful for interpolations. */ +class quaternion +{ +public: + //! Default Constructor + constexpr quaternion() : + X(0.0f), Y(0.0f), Z(0.0f), W(1.0f) {} + + //! Constructor + constexpr quaternion(f32 x, f32 y, f32 z, f32 w) : + X(x), Y(y), Z(z), W(w) {} + + //! Constructor which converts Euler angles (radians) to a quaternion + quaternion(f32 x, f32 y, f32 z); + + //! Constructor which converts Euler angles (radians) to a quaternion + quaternion(const vector3df &vec); + +#ifndef IRR_TEST_BROKEN_QUATERNION_USE + //! Constructor which converts a matrix to a quaternion + quaternion(const matrix4 &mat); +#endif + + //! Equality operator + constexpr bool operator==(const quaternion &other) const + { + return ((X == other.X) && + (Y == other.Y) && + (Z == other.Z) && + (W == other.W)); + } + + //! inequality operator + constexpr bool operator!=(const quaternion &other) const + { + return !(*this == other); + } + +#ifndef IRR_TEST_BROKEN_QUATERNION_USE + //! Matrix assignment operator + inline quaternion &operator=(const matrix4 &other); +#endif + + //! Add operator + quaternion operator+(const quaternion &other) const; + + //! Multiplication operator + //! Be careful, unfortunately the operator order here is opposite of that in CMatrix4::operator* + quaternion operator*(const quaternion &other) const; + + //! Multiplication operator with scalar + quaternion operator*(f32 s) const; + + //! Multiplication operator with scalar + quaternion &operator*=(f32 s); + + //! Multiplication operator + vector3df operator*(const vector3df &v) const; + + //! Multiplication operator + quaternion &operator*=(const quaternion &other); + + //! Calculates the dot product + inline f32 dotProduct(const quaternion &other) const; + + //! Sets new quaternion + inline quaternion &set(f32 x, f32 y, f32 z, f32 w); + + //! Sets new quaternion based on Euler angles (radians) + inline quaternion &set(f32 x, f32 y, f32 z); + + //! Sets new quaternion based on Euler angles (radians) + inline quaternion &set(const core::vector3df &vec); + + //! Sets new quaternion from other quaternion + inline quaternion &set(const core::quaternion &quat); + + //! returns if this quaternion equals the other one, taking floating point rounding errors into account + inline bool equals(const quaternion &other, + const f32 tolerance = ROUNDING_ERROR_f32) const; + + //! Normalizes the quaternion + inline quaternion &normalize(); + +#ifndef IRR_TEST_BROKEN_QUATERNION_USE + //! Creates a matrix from this quaternion + matrix4 getMatrix() const; +#endif + //! Faster method to create a rotation matrix, you should normalize the quaternion before! + void getMatrixFast(matrix4 &dest) const; + + //! Creates a matrix from this quaternion + void getMatrix(matrix4 &dest, const core::vector3df &translation = core::vector3df()) const; + + /*! + Creates a matrix from this quaternion + Rotate about a center point + shortcut for + core::quaternion q; + q.rotationFromTo ( vin[i].Normal, forward ); + q.getMatrixCenter ( lookat, center, newPos ); + + core::matrix4 m2; + m2.setInverseTranslation ( center ); + lookat *= m2; + + core::matrix4 m3; + m2.setTranslation ( newPos ); + lookat *= m3; + + */ + void getMatrixCenter(matrix4 &dest, const core::vector3df ¢er, const core::vector3df &translation) const; + + //! Creates a matrix from this quaternion + inline void getMatrix_transposed(matrix4 &dest) const; + + //! Inverts this quaternion + quaternion &makeInverse(); + + //! Set this quaternion to the linear interpolation between two quaternions + /** NOTE: lerp result is *not* a normalized quaternion. In most cases + you will want to use lerpN instead as most other quaternion functions expect + to work with a normalized quaternion. + \param q1 First quaternion to be interpolated. + \param q2 Second quaternion to be interpolated. + \param time Progress of interpolation. For time=0 the result is + q1, for time=1 the result is q2. Otherwise interpolation + between q1 and q2. Result is not normalized. + */ + quaternion &lerp(quaternion q1, quaternion q2, f32 time); + + //! Set this quaternion to the linear interpolation between two quaternions and normalize the result + /** + \param q1 First quaternion to be interpolated. + \param q2 Second quaternion to be interpolated. + \param time Progress of interpolation. For time=0 the result is + q1, for time=1 the result is q2. Otherwise interpolation + between q1 and q2. Result is normalized. + */ + quaternion &lerpN(quaternion q1, quaternion q2, f32 time); + + //! Set this quaternion to the result of the spherical interpolation between two quaternions + /** \param q1 First quaternion to be interpolated. + \param q2 Second quaternion to be interpolated. + \param time Progress of interpolation. For time=0 the result is + q1, for time=1 the result is q2. Otherwise interpolation + between q1 and q2. + \param threshold To avoid inaccuracies at the end (time=1) the + interpolation switches to linear interpolation at some point. + This value defines how much of the remaining interpolation will + be calculated with lerp. Everything from 1-threshold up will be + linear interpolation. + */ + quaternion &slerp(quaternion q1, quaternion q2, + f32 time, f32 threshold = .05f); + + //! Set this quaternion to represent a rotation from angle and axis. + /** Axis must be unit length. + The quaternion representing the rotation is + q = cos(A/2)+sin(A/2)*(x*i+y*j+z*k). + \param angle Rotation Angle in radians. + \param axis Rotation axis. */ + quaternion &fromAngleAxis(f32 angle, const vector3df &axis); + + //! Fills an angle (radians) around an axis (unit vector) + void toAngleAxis(f32 &angle, core::vector3df &axis) const; + + //! Output this quaternion to an Euler angle (radians) + void toEuler(vector3df &euler) const; + + //! Set quaternion to identity + quaternion &makeIdentity(); + + //! Set quaternion to represent a rotation from one vector to another. + quaternion &rotationFromTo(const vector3df &from, const vector3df &to); + + //! Quaternion elements. + f32 X; // vectorial (imaginary) part + f32 Y; + f32 Z; + f32 W; // real part +}; + +// Constructor which converts Euler angles to a quaternion +inline quaternion::quaternion(f32 x, f32 y, f32 z) +{ + set(x, y, z); +} + +// Constructor which converts Euler angles to a quaternion +inline quaternion::quaternion(const vector3df &vec) +{ + set(vec.X, vec.Y, vec.Z); +} + +#ifndef IRR_TEST_BROKEN_QUATERNION_USE +// Constructor which converts a matrix to a quaternion +inline quaternion::quaternion(const matrix4 &mat) +{ + (*this) = mat; +} +#endif + +#ifndef IRR_TEST_BROKEN_QUATERNION_USE +// matrix assignment operator +inline quaternion &quaternion::operator=(const matrix4 &m) +{ + const f32 diag = m[0] + m[5] + m[10] + 1; + + if (diag > 0.0f) { + const f32 scale = sqrtf(diag) * 2.0f; // get scale from diagonal + + // TODO: speed this up + X = (m[6] - m[9]) / scale; + Y = (m[8] - m[2]) / scale; + Z = (m[1] - m[4]) / scale; + W = 0.25f * scale; + } else { + if (m[0] > m[5] && m[0] > m[10]) { + // 1st element of diag is greatest value + // find scale according to 1st element, and double it + const f32 scale = sqrtf(1.0f + m[0] - m[5] - m[10]) * 2.0f; + + // TODO: speed this up + X = 0.25f * scale; + Y = (m[4] + m[1]) / scale; + Z = (m[2] + m[8]) / scale; + W = (m[6] - m[9]) / scale; + } else if (m[5] > m[10]) { + // 2nd element of diag is greatest value + // find scale according to 2nd element, and double it + const f32 scale = sqrtf(1.0f + m[5] - m[0] - m[10]) * 2.0f; + + // TODO: speed this up + X = (m[4] + m[1]) / scale; + Y = 0.25f * scale; + Z = (m[9] + m[6]) / scale; + W = (m[8] - m[2]) / scale; + } else { + // 3rd element of diag is greatest value + // find scale according to 3rd element, and double it + const f32 scale = sqrtf(1.0f + m[10] - m[0] - m[5]) * 2.0f; + + // TODO: speed this up + X = (m[8] + m[2]) / scale; + Y = (m[9] + m[6]) / scale; + Z = 0.25f * scale; + W = (m[1] - m[4]) / scale; + } + } + + return normalize(); +} +#endif + +// multiplication operator +inline quaternion quaternion::operator*(const quaternion &other) const +{ + quaternion tmp; + + tmp.W = (other.W * W) - (other.X * X) - (other.Y * Y) - (other.Z * Z); + tmp.X = (other.W * X) + (other.X * W) + (other.Y * Z) - (other.Z * Y); + tmp.Y = (other.W * Y) + (other.Y * W) + (other.Z * X) - (other.X * Z); + tmp.Z = (other.W * Z) + (other.Z * W) + (other.X * Y) - (other.Y * X); + + return tmp; +} + +// multiplication operator +inline quaternion quaternion::operator*(f32 s) const +{ + return quaternion(s * X, s * Y, s * Z, s * W); +} + +// multiplication operator +inline quaternion &quaternion::operator*=(f32 s) +{ + X *= s; + Y *= s; + Z *= s; + W *= s; + return *this; +} + +// multiplication operator +inline quaternion &quaternion::operator*=(const quaternion &other) +{ + return (*this = other * (*this)); +} + +// add operator +inline quaternion quaternion::operator+(const quaternion &b) const +{ + return quaternion(X + b.X, Y + b.Y, Z + b.Z, W + b.W); +} + +#ifndef IRR_TEST_BROKEN_QUATERNION_USE +// Creates a matrix from this quaternion +inline matrix4 quaternion::getMatrix() const +{ + core::matrix4 m; + getMatrix(m); + return m; +} +#endif + +//! Faster method to create a rotation matrix, you should normalize the quaternion before! +inline void quaternion::getMatrixFast(matrix4 &dest) const +{ + // TODO: + // gpu quaternion skinning => fast Bones transform chain O_O YEAH! + // http://www.mrelusive.com/publications/papers/SIMD-From-Quaternion-to-Matrix-and-Back.pdf + dest[0] = 1.0f - 2.0f * Y * Y - 2.0f * Z * Z; + dest[1] = 2.0f * X * Y + 2.0f * Z * W; + dest[2] = 2.0f * X * Z - 2.0f * Y * W; + dest[3] = 0.0f; + + dest[4] = 2.0f * X * Y - 2.0f * Z * W; + dest[5] = 1.0f - 2.0f * X * X - 2.0f * Z * Z; + dest[6] = 2.0f * Z * Y + 2.0f * X * W; + dest[7] = 0.0f; + + dest[8] = 2.0f * X * Z + 2.0f * Y * W; + dest[9] = 2.0f * Z * Y - 2.0f * X * W; + dest[10] = 1.0f - 2.0f * X * X - 2.0f * Y * Y; + dest[11] = 0.0f; + + dest[12] = 0.f; + dest[13] = 0.f; + dest[14] = 0.f; + dest[15] = 1.f; + + dest.setDefinitelyIdentityMatrix(false); +} + +/*! + Creates a matrix from this quaternion +*/ +inline void quaternion::getMatrix(matrix4 &dest, + const core::vector3df ¢er) const +{ + // ok creating a copy may be slower, but at least avoid internal + // state chance (also because otherwise we cannot keep this method "const"). + + quaternion q(*this); + q.normalize(); + f32 X = q.X; + f32 Y = q.Y; + f32 Z = q.Z; + f32 W = q.W; + + dest[0] = 1.0f - 2.0f * Y * Y - 2.0f * Z * Z; + dest[1] = 2.0f * X * Y + 2.0f * Z * W; + dest[2] = 2.0f * X * Z - 2.0f * Y * W; + dest[3] = 0.0f; + + dest[4] = 2.0f * X * Y - 2.0f * Z * W; + dest[5] = 1.0f - 2.0f * X * X - 2.0f * Z * Z; + dest[6] = 2.0f * Z * Y + 2.0f * X * W; + dest[7] = 0.0f; + + dest[8] = 2.0f * X * Z + 2.0f * Y * W; + dest[9] = 2.0f * Z * Y - 2.0f * X * W; + dest[10] = 1.0f - 2.0f * X * X - 2.0f * Y * Y; + dest[11] = 0.0f; + + dest[12] = center.X; + dest[13] = center.Y; + dest[14] = center.Z; + dest[15] = 1.f; + + dest.setDefinitelyIdentityMatrix(false); +} + +/*! + Creates a matrix from this quaternion + Rotate about a center point + shortcut for + core::quaternion q; + q.rotationFromTo(vin[i].Normal, forward); + q.getMatrix(lookat, center); + + core::matrix4 m2; + m2.setInverseTranslation(center); + lookat *= m2; +*/ +inline void quaternion::getMatrixCenter(matrix4 &dest, + const core::vector3df ¢er, + const core::vector3df &translation) const +{ + quaternion q(*this); + q.normalize(); + f32 X = q.X; + f32 Y = q.Y; + f32 Z = q.Z; + f32 W = q.W; + + dest[0] = 1.0f - 2.0f * Y * Y - 2.0f * Z * Z; + dest[1] = 2.0f * X * Y + 2.0f * Z * W; + dest[2] = 2.0f * X * Z - 2.0f * Y * W; + dest[3] = 0.0f; + + dest[4] = 2.0f * X * Y - 2.0f * Z * W; + dest[5] = 1.0f - 2.0f * X * X - 2.0f * Z * Z; + dest[6] = 2.0f * Z * Y + 2.0f * X * W; + dest[7] = 0.0f; + + dest[8] = 2.0f * X * Z + 2.0f * Y * W; + dest[9] = 2.0f * Z * Y - 2.0f * X * W; + dest[10] = 1.0f - 2.0f * X * X - 2.0f * Y * Y; + dest[11] = 0.0f; + + dest.setRotationCenter(center, translation); +} + +// Creates a matrix from this quaternion +inline void quaternion::getMatrix_transposed(matrix4 &dest) const +{ + quaternion q(*this); + q.normalize(); + f32 X = q.X; + f32 Y = q.Y; + f32 Z = q.Z; + f32 W = q.W; + + dest[0] = 1.0f - 2.0f * Y * Y - 2.0f * Z * Z; + dest[4] = 2.0f * X * Y + 2.0f * Z * W; + dest[8] = 2.0f * X * Z - 2.0f * Y * W; + dest[12] = 0.0f; + + dest[1] = 2.0f * X * Y - 2.0f * Z * W; + dest[5] = 1.0f - 2.0f * X * X - 2.0f * Z * Z; + dest[9] = 2.0f * Z * Y + 2.0f * X * W; + dest[13] = 0.0f; + + dest[2] = 2.0f * X * Z + 2.0f * Y * W; + dest[6] = 2.0f * Z * Y - 2.0f * X * W; + dest[10] = 1.0f - 2.0f * X * X - 2.0f * Y * Y; + dest[14] = 0.0f; + + dest[3] = 0.f; + dest[7] = 0.f; + dest[11] = 0.f; + dest[15] = 1.f; + + dest.setDefinitelyIdentityMatrix(false); +} + +// Inverts this quaternion +inline quaternion &quaternion::makeInverse() +{ + X = -X; + Y = -Y; + Z = -Z; + return *this; +} + +// sets new quaternion +inline quaternion &quaternion::set(f32 x, f32 y, f32 z, f32 w) +{ + X = x; + Y = y; + Z = z; + W = w; + return *this; +} + +// sets new quaternion based on Euler angles +inline quaternion &quaternion::set(f32 x, f32 y, f32 z) +{ + f64 angle; + + angle = x * 0.5; + const f64 sr = sin(angle); + const f64 cr = cos(angle); + + angle = y * 0.5; + const f64 sp = sin(angle); + const f64 cp = cos(angle); + + angle = z * 0.5; + const f64 sy = sin(angle); + const f64 cy = cos(angle); + + const f64 cpcy = cp * cy; + const f64 spcy = sp * cy; + const f64 cpsy = cp * sy; + const f64 spsy = sp * sy; + + X = (f32)(sr * cpcy - cr * spsy); + Y = (f32)(cr * spcy + sr * cpsy); + Z = (f32)(cr * cpsy - sr * spcy); + W = (f32)(cr * cpcy + sr * spsy); + + return normalize(); +} + +// sets new quaternion based on Euler angles +inline quaternion &quaternion::set(const core::vector3df &vec) +{ + return set(vec.X, vec.Y, vec.Z); +} + +// sets new quaternion based on other quaternion +inline quaternion &quaternion::set(const core::quaternion &quat) +{ + return (*this = quat); +} + +//! returns if this quaternion equals the other one, taking floating point rounding errors into account +inline bool quaternion::equals(const quaternion &other, const f32 tolerance) const +{ + return core::equals(X, other.X, tolerance) && + core::equals(Y, other.Y, tolerance) && + core::equals(Z, other.Z, tolerance) && + core::equals(W, other.W, tolerance); +} + +// normalizes the quaternion +inline quaternion &quaternion::normalize() +{ + // removed conditional branch since it may slow down and anyway the condition was + // false even after normalization in some cases. + return (*this *= (f32)reciprocal_squareroot((f64)(X * X + Y * Y + Z * Z + W * W))); +} + +// Set this quaternion to the result of the linear interpolation between two quaternions +inline quaternion &quaternion::lerp(quaternion q1, quaternion q2, f32 time) +{ + const f32 scale = 1.0f - time; + return (*this = (q1 * scale) + (q2 * time)); +} + +// Set this quaternion to the result of the linear interpolation between two quaternions and normalize the result +inline quaternion &quaternion::lerpN(quaternion q1, quaternion q2, f32 time) +{ + const f32 scale = 1.0f - time; + return (*this = ((q1 * scale) + (q2 * time)).normalize()); +} + +// set this quaternion to the result of the interpolation between two quaternions +inline quaternion &quaternion::slerp(quaternion q1, quaternion q2, f32 time, f32 threshold) +{ + f32 angle = q1.dotProduct(q2); + + // make sure we use the short rotation + if (angle < 0.0f) { + q1 *= -1.0f; + angle *= -1.0f; + } + + if (angle <= (1 - threshold)) { // spherical interpolation + const f32 theta = acosf(angle); + const f32 invsintheta = reciprocal(sinf(theta)); + const f32 scale = sinf(theta * (1.0f - time)) * invsintheta; + const f32 invscale = sinf(theta * time) * invsintheta; + return (*this = (q1 * scale) + (q2 * invscale)); + } else // linear interpolation + return lerpN(q1, q2, time); +} + +// calculates the dot product +inline f32 quaternion::dotProduct(const quaternion &q2) const +{ + return (X * q2.X) + (Y * q2.Y) + (Z * q2.Z) + (W * q2.W); +} + +//! axis must be unit length, angle in radians +inline quaternion &quaternion::fromAngleAxis(f32 angle, const vector3df &axis) +{ + const f32 fHalfAngle = 0.5f * angle; + const f32 fSin = sinf(fHalfAngle); + W = cosf(fHalfAngle); + X = fSin * axis.X; + Y = fSin * axis.Y; + Z = fSin * axis.Z; + return *this; +} + +inline void quaternion::toAngleAxis(f32 &angle, core::vector3df &axis) const +{ + const f32 scale = sqrtf(X * X + Y * Y + Z * Z); + + if (core::iszero(scale) || W > 1.0f || W < -1.0f) { + angle = 0.0f; + axis.X = 0.0f; + axis.Y = 1.0f; + axis.Z = 0.0f; + } else { + const f32 invscale = reciprocal(scale); + angle = 2.0f * acosf(W); + axis.X = X * invscale; + axis.Y = Y * invscale; + axis.Z = Z * invscale; + } +} + +inline void quaternion::toEuler(vector3df &euler) const +{ + const f64 sqw = W * W; + const f64 sqx = X * X; + const f64 sqy = Y * Y; + const f64 sqz = Z * Z; + const f64 test = 2.0 * (Y * W - X * Z); + + if (core::equals(test, 1.0, 0.000001)) { + // heading = rotation about z-axis + euler.Z = (f32)(-2.0 * atan2(X, W)); + // bank = rotation about x-axis + euler.X = 0; + // attitude = rotation about y-axis + euler.Y = (f32)(core::PI64 / 2.0); + } else if (core::equals(test, -1.0, 0.000001)) { + // heading = rotation about z-axis + euler.Z = (f32)(2.0 * atan2(X, W)); + // bank = rotation about x-axis + euler.X = 0; + // attitude = rotation about y-axis + euler.Y = (f32)(core::PI64 / -2.0); + } else { + // heading = rotation about z-axis + euler.Z = (f32)atan2(2.0 * (X * Y + Z * W), (sqx - sqy - sqz + sqw)); + // bank = rotation about x-axis + euler.X = (f32)atan2(2.0 * (Y * Z + X * W), (-sqx - sqy + sqz + sqw)); + // attitude = rotation about y-axis + euler.Y = (f32)asin(clamp(test, -1.0, 1.0)); + } +} + +inline vector3df quaternion::operator*(const vector3df &v) const +{ + // nVidia SDK implementation + + vector3df uv, uuv; + const vector3df qvec(X, Y, Z); + uv = qvec.crossProduct(v); + uuv = qvec.crossProduct(uv); + uv *= (2.0f * W); + uuv *= 2.0f; + + return v + uv + uuv; +} + +// set quaternion to identity +inline core::quaternion &quaternion::makeIdentity() +{ + W = 1.f; + X = 0.f; + Y = 0.f; + Z = 0.f; + return *this; +} + +inline core::quaternion &quaternion::rotationFromTo(const vector3df &from, const vector3df &to) +{ + // Based on Stan Melax's article in Game Programming Gems + // Optimized by Robert Eisele: https://raw.org/proof/quaternion-from-two-vectors + + // Copy, since cannot modify local + vector3df v0 = from; + vector3df v1 = to; + v0.normalize(); + v1.normalize(); + + const f32 d = v0.dotProduct(v1); + if (d >= 1.0f) { // If dot == 1, vectors are the same + return makeIdentity(); + } else if (d <= -1.0f) { // exactly opposite + core::vector3df axis(1.0f, 0.f, 0.f); + axis = axis.crossProduct(v0); + if (axis.getLength() == 0) { + axis.set(0.f, 1.f, 0.f); + axis = axis.crossProduct(v0); + } + // same as fromAngleAxis(core::PI, axis).normalize(); + return set(axis.X, axis.Y, axis.Z, 0).normalize(); + } + + const vector3df c = v0.crossProduct(v1); + return set(c.X, c.Y, c.Z, 1 + d).normalize(); +} + +} // end namespace core +} // end namespace irr diff --git a/irr/include/rect.h b/irr/include/rect.h new file mode 100644 index 000000000..bced2d59e --- /dev/null +++ b/irr/include/rect.h @@ -0,0 +1,281 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" +#include "dimension2d.h" +#include "position2d.h" + +namespace irr +{ +namespace core +{ + +//! Rectangle template. +/** Mostly used by 2D GUI elements and for 2D drawing methods. +It has 2 positions instead of position and dimension and a fast +method for collision detection with other rectangles and points. + +Coordinates are (0,0) for top-left corner, and increasing to the right +and to the bottom. +*/ +template +class rect +{ +public: + //! Default constructor creating empty rectangle at (0,0) + constexpr rect() : + UpperLeftCorner(0, 0), LowerRightCorner(0, 0) {} + + //! Constructor with two corners + constexpr rect(T x, T y, T x2, T y2) : + UpperLeftCorner(x, y), LowerRightCorner(x2, y2) {} + + //! Constructor with two corners + constexpr rect(const position2d &upperLeft, const position2d &lowerRight) : + UpperLeftCorner(upperLeft), LowerRightCorner(lowerRight) {} + + //! Constructor with upper left corner and dimension + template + constexpr rect(const position2d &pos, const dimension2d &size) : + UpperLeftCorner(pos), LowerRightCorner(pos.X + size.Width, pos.Y + size.Height) + { + } + + //! Constructor with upper left at 0,0 and lower right using dimension + template + explicit constexpr rect(const dimension2d &size) : + UpperLeftCorner(0, 0), LowerRightCorner(size.Width, size.Height) + { + } + + //! move right by given numbers + rect operator+(const position2d &pos) const + { + rect ret(*this); + return ret += pos; + } + + //! move right by given numbers + rect &operator+=(const position2d &pos) + { + UpperLeftCorner += pos; + LowerRightCorner += pos; + return *this; + } + + //! move left by given numbers + rect operator-(const position2d &pos) const + { + rect ret(*this); + return ret -= pos; + } + + //! move left by given numbers + rect &operator-=(const position2d &pos) + { + UpperLeftCorner -= pos; + LowerRightCorner -= pos; + return *this; + } + + //! equality operator + constexpr bool operator==(const rect &other) const + { + return (UpperLeftCorner == other.UpperLeftCorner && + LowerRightCorner == other.LowerRightCorner); + } + + //! inequality operator + constexpr bool operator!=(const rect &other) const + { + return (UpperLeftCorner != other.UpperLeftCorner || + LowerRightCorner != other.LowerRightCorner); + } + + //! compares size of rectangles + bool operator<(const rect &other) const + { + return getArea() < other.getArea(); + } + + //! Returns size of rectangle + T getArea() const + { + return getWidth() * getHeight(); + } + + //! Returns if a 2d point is within this rectangle. + /** \param pos Position to test if it lies within this rectangle. + \return True if the position is within the rectangle, false if not. */ + bool isPointInside(const position2d &pos) const + { + return (UpperLeftCorner.X <= pos.X && + UpperLeftCorner.Y <= pos.Y && + LowerRightCorner.X >= pos.X && + LowerRightCorner.Y >= pos.Y); + } + + //! Check if the rectangle collides with another rectangle. + /** \param other Rectangle to test collision with + \return True if the rectangles collide. */ + bool isRectCollided(const rect &other) const + { + return (LowerRightCorner.Y > other.UpperLeftCorner.Y && + UpperLeftCorner.Y < other.LowerRightCorner.Y && + LowerRightCorner.X > other.UpperLeftCorner.X && + UpperLeftCorner.X < other.LowerRightCorner.X); + } + + //! Clips this rectangle with another one. + /** \param other Rectangle to clip with */ + void clipAgainst(const rect &other) + { + if (other.LowerRightCorner.X < LowerRightCorner.X) + LowerRightCorner.X = other.LowerRightCorner.X; + if (other.LowerRightCorner.Y < LowerRightCorner.Y) + LowerRightCorner.Y = other.LowerRightCorner.Y; + + if (other.UpperLeftCorner.X > LowerRightCorner.X) + LowerRightCorner.X = other.UpperLeftCorner.X; + if (other.UpperLeftCorner.Y > LowerRightCorner.Y) + LowerRightCorner.Y = other.UpperLeftCorner.Y; + + if (other.LowerRightCorner.X < UpperLeftCorner.X) + UpperLeftCorner.X = other.LowerRightCorner.X; + if (other.LowerRightCorner.Y < UpperLeftCorner.Y) + UpperLeftCorner.Y = other.LowerRightCorner.Y; + + if (other.UpperLeftCorner.X > UpperLeftCorner.X) + UpperLeftCorner.X = other.UpperLeftCorner.X; + if (other.UpperLeftCorner.Y > UpperLeftCorner.Y) + UpperLeftCorner.Y = other.UpperLeftCorner.Y; + } + + //! Moves this rectangle to fit inside another one. + /** \return True on success, false if not possible */ + bool constrainTo(const rect &other) + { + if (other.getWidth() < getWidth() || other.getHeight() < getHeight()) + return false; + + T diff = other.LowerRightCorner.X - LowerRightCorner.X; + if (diff < 0) { + LowerRightCorner.X += diff; + UpperLeftCorner.X += diff; + } + + diff = other.LowerRightCorner.Y - LowerRightCorner.Y; + if (diff < 0) { + LowerRightCorner.Y += diff; + UpperLeftCorner.Y += diff; + } + + diff = UpperLeftCorner.X - other.UpperLeftCorner.X; + if (diff < 0) { + UpperLeftCorner.X -= diff; + LowerRightCorner.X -= diff; + } + + diff = UpperLeftCorner.Y - other.UpperLeftCorner.Y; + if (diff < 0) { + UpperLeftCorner.Y -= diff; + LowerRightCorner.Y -= diff; + } + + return true; + } + + //! Get width of rectangle. + T getWidth() const + { + return LowerRightCorner.X - UpperLeftCorner.X; + } + + //! Get height of rectangle. + T getHeight() const + { + return LowerRightCorner.Y - UpperLeftCorner.Y; + } + + //! If the lower right corner of the rect is smaller then the upper left, the points are swapped. + void repair() + { + if (LowerRightCorner.X < UpperLeftCorner.X) { + T t = LowerRightCorner.X; + LowerRightCorner.X = UpperLeftCorner.X; + UpperLeftCorner.X = t; + } + + if (LowerRightCorner.Y < UpperLeftCorner.Y) { + T t = LowerRightCorner.Y; + LowerRightCorner.Y = UpperLeftCorner.Y; + UpperLeftCorner.Y = t; + } + } + + //! Returns if the rect is valid to draw. + /** It would be invalid if the UpperLeftCorner is lower or more + right than the LowerRightCorner. */ + bool isValid() const + { + return ((LowerRightCorner.X >= UpperLeftCorner.X) && + (LowerRightCorner.Y >= UpperLeftCorner.Y)); + } + + //! Get the center of the rectangle + position2d getCenter() const + { + return position2d( + (UpperLeftCorner.X + LowerRightCorner.X) / 2, + (UpperLeftCorner.Y + LowerRightCorner.Y) / 2); + } + + //! Get the dimensions of the rectangle + dimension2d getSize() const + { + return dimension2d(getWidth(), getHeight()); + } + + //! Adds a point to the rectangle + /** Causes the rectangle to grow bigger if point is outside of + the box + \param p Point to add to the box. */ + void addInternalPoint(const position2d &p) + { + addInternalPoint(p.X, p.Y); + } + + //! Adds a point to the bounding rectangle + /** Causes the rectangle to grow bigger if point is outside of + the box + \param x X-Coordinate of the point to add to this box. + \param y Y-Coordinate of the point to add to this box. */ + void addInternalPoint(T x, T y) + { + if (x > LowerRightCorner.X) + LowerRightCorner.X = x; + if (y > LowerRightCorner.Y) + LowerRightCorner.Y = y; + + if (x < UpperLeftCorner.X) + UpperLeftCorner.X = x; + if (y < UpperLeftCorner.Y) + UpperLeftCorner.Y = y; + } + + //! Upper left corner + position2d UpperLeftCorner; + //! Lower right corner + position2d LowerRightCorner; +}; + +//! Rectangle with float values +typedef rect rectf; +//! Rectangle with int values +typedef rect recti; + +} // end namespace core +} // end namespace irr diff --git a/irr/include/vector2d.h b/irr/include/vector2d.h new file mode 100644 index 000000000..4c41389f4 --- /dev/null +++ b/irr/include/vector2d.h @@ -0,0 +1,503 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrMath.h" +#include "dimension2d.h" + +#include + +namespace irr +{ +namespace core +{ + +//! 2d vector template class with lots of operators and methods. +/** As of Irrlicht 1.6, this class supersedes position2d, which should + be considered deprecated. */ +template +class vector2d +{ +public: + //! Default constructor (null vector) + constexpr vector2d() : + X(0), Y(0) {} + //! Constructor with two different values + constexpr vector2d(T nx, T ny) : + X(nx), Y(ny) {} + //! Constructor with the same value for both members + explicit constexpr vector2d(T n) : + X(n), Y(n) {} + + constexpr vector2d(const dimension2d &other) : + X(other.Width), Y(other.Height) {} + + // operators + + vector2d operator-() const { return vector2d(-X, -Y); } + + vector2d &operator=(const dimension2d &other) + { + X = other.Width; + Y = other.Height; + return *this; + } + + vector2d operator+(const vector2d &other) const { return vector2d(X + other.X, Y + other.Y); } + vector2d operator+(const dimension2d &other) const { return vector2d(X + other.Width, Y + other.Height); } + vector2d &operator+=(const vector2d &other) + { + X += other.X; + Y += other.Y; + return *this; + } + vector2d operator+(const T v) const { return vector2d(X + v, Y + v); } + vector2d &operator+=(const T v) + { + X += v; + Y += v; + return *this; + } + vector2d &operator+=(const dimension2d &other) + { + X += other.Width; + Y += other.Height; + return *this; + } + + vector2d operator-(const vector2d &other) const { return vector2d(X - other.X, Y - other.Y); } + vector2d operator-(const dimension2d &other) const { return vector2d(X - other.Width, Y - other.Height); } + vector2d &operator-=(const vector2d &other) + { + X -= other.X; + Y -= other.Y; + return *this; + } + vector2d operator-(const T v) const { return vector2d(X - v, Y - v); } + vector2d &operator-=(const T v) + { + X -= v; + Y -= v; + return *this; + } + vector2d &operator-=(const dimension2d &other) + { + X -= other.Width; + Y -= other.Height; + return *this; + } + + vector2d operator*(const vector2d &other) const { return vector2d(X * other.X, Y * other.Y); } + vector2d &operator*=(const vector2d &other) + { + X *= other.X; + Y *= other.Y; + return *this; + } + vector2d operator*(const T v) const { return vector2d(X * v, Y * v); } + vector2d &operator*=(const T v) + { + X *= v; + Y *= v; + return *this; + } + + vector2d operator/(const vector2d &other) const { return vector2d(X / other.X, Y / other.Y); } + vector2d &operator/=(const vector2d &other) + { + X /= other.X; + Y /= other.Y; + return *this; + } + vector2d operator/(const T v) const { return vector2d(X / v, Y / v); } + vector2d &operator/=(const T v) + { + X /= v; + Y /= v; + return *this; + } + + T &operator[](u32 index) + { + _IRR_DEBUG_BREAK_IF(index > 1) // access violation + + return *(&X + index); + } + + const T &operator[](u32 index) const + { + _IRR_DEBUG_BREAK_IF(index > 1) // access violation + + return *(&X + index); + } + + //! sort in order X, Y. + constexpr bool operator<=(const vector2d &other) const + { + return !(*this > other); + } + + //! sort in order X, Y. + constexpr bool operator>=(const vector2d &other) const + { + return !(*this < other); + } + + //! sort in order X, Y. + constexpr bool operator<(const vector2d &other) const + { + return X < other.X || (X == other.X && Y < other.Y); + } + + //! sort in order X, Y. + constexpr bool operator>(const vector2d &other) const + { + return X > other.X || (X == other.X && Y > other.Y); + } + + constexpr bool operator==(const vector2d &other) const + { + return X == other.X && Y == other.Y; + } + + constexpr bool operator!=(const vector2d &other) const + { + return !(*this == other); + } + + // functions + + //! Checks if this vector equals the other one. + /** Takes floating point rounding errors into account. + \param other Vector to compare with. + \return True if the two vector are (almost) equal, else false. */ + bool equals(const vector2d &other) const + { + return core::equals(X, other.X) && core::equals(Y, other.Y); + } + + vector2d &set(T nx, T ny) + { + X = nx; + Y = ny; + return *this; + } + vector2d &set(const vector2d &p) + { + X = p.X; + Y = p.Y; + return *this; + } + + //! Gets the length of the vector. + /** \return The length of the vector. */ + T getLength() const { return core::squareroot(X * X + Y * Y); } + + //! Get the squared length of this vector + /** This is useful because it is much faster than getLength(). + \return The squared length of the vector. */ + T getLengthSQ() const { return X * X + Y * Y; } + + //! Get the dot product of this vector with another. + /** \param other Other vector to take dot product with. + \return The dot product of the two vectors. */ + T dotProduct(const vector2d &other) const + { + return X * other.X + Y * other.Y; + } + + //! check if this vector is parallel to another vector + bool nearlyParallel(const vector2d &other, const T factor = relativeErrorFactor()) const + { + // https://eagergames.wordpress.com/2017/04/01/fast-parallel-lines-and-vectors-test/ + // if a || b then a.x/a.y = b.x/b.y (similar triangles) + // if a || b then either both x are 0 or both y are 0. + + return equalsRelative(X * other.Y, other.X * Y, factor) && // a bit counterintuitive, but makes sure that + // only y or only x are 0, and at same time deals + // with the case where one vector is zero vector. + (X * other.X + Y * other.Y) != 0; + } + + //! Gets distance from another point. + /** Here, the vector is interpreted as a point in 2-dimensional space. + \param other Other vector to measure from. + \return Distance from other point. */ + T getDistanceFrom(const vector2d &other) const + { + return vector2d(X - other.X, Y - other.Y).getLength(); + } + + //! Returns squared distance from another point. + /** Here, the vector is interpreted as a point in 2-dimensional space. + \param other Other vector to measure from. + \return Squared distance from other point. */ + T getDistanceFromSQ(const vector2d &other) const + { + return vector2d(X - other.X, Y - other.Y).getLengthSQ(); + } + + //! rotates the point anticlockwise around a center by an amount of degrees. + /** \param degrees Amount of degrees to rotate by, anticlockwise. + \param center Rotation center. + \return This vector after transformation. */ + vector2d &rotateBy(f64 degrees, const vector2d ¢er = vector2d()) + { + degrees *= DEGTORAD64; + const f64 cs = cos(degrees); + const f64 sn = sin(degrees); + + X -= center.X; + Y -= center.Y; + + set((T)(X * cs - Y * sn), (T)(X * sn + Y * cs)); + + X += center.X; + Y += center.Y; + return *this; + } + + //! Normalize the vector. + /** The null vector is left untouched. + \return Reference to this vector, after normalization. */ + vector2d &normalize() + { + f32 length = (f32)(X * X + Y * Y); + if (length == 0) + return *this; + length = core::reciprocal_squareroot(length); + X = (T)(X * length); + Y = (T)(Y * length); + return *this; + } + + //! Calculates the angle of this vector in degrees in the trigonometric sense. + /** 0 is to the right (3 o'clock), values increase counter-clockwise. + This method has been suggested by Pr3t3nd3r. + \return Returns a value between 0 and 360. */ + f64 getAngleTrig() const + { + if (Y == 0) + return X < 0 ? 180 : 0; + else if (X == 0) + return Y < 0 ? 270 : 90; + + if (Y > 0) + if (X > 0) + return atan((irr::f64)Y / (irr::f64)X) * RADTODEG64; + else + return 180.0 - atan((irr::f64)Y / -(irr::f64)X) * RADTODEG64; + else if (X > 0) + return 360.0 - atan(-(irr::f64)Y / (irr::f64)X) * RADTODEG64; + else + return 180.0 + atan(-(irr::f64)Y / -(irr::f64)X) * RADTODEG64; + } + + //! Calculates the angle of this vector in degrees in the counter trigonometric sense. + /** 0 is to the right (3 o'clock), values increase clockwise. + \return Returns a value between 0 and 360. */ + inline f64 getAngle() const + { + if (Y == 0) // corrected thanks to a suggestion by Jox + return X < 0 ? 180 : 0; + else if (X == 0) + return Y < 0 ? 90 : 270; + + // don't use getLength here to avoid precision loss with s32 vectors + // avoid floating-point trouble as sqrt(y*y) is occasionally larger than y, so clamp + const f64 tmp = core::clamp(Y / sqrt((f64)(X * X + Y * Y)), -1.0, 1.0); + const f64 angle = atan(core::squareroot(1 - tmp * tmp) / tmp) * RADTODEG64; + + if (X > 0 && Y > 0) + return angle + 270; + else if (X > 0 && Y < 0) + return angle + 90; + else if (X < 0 && Y < 0) + return 90 - angle; + else if (X < 0 && Y > 0) + return 270 - angle; + + return angle; + } + + //! Calculates the angle between this vector and another one in degree. + /** \param b Other vector to test with. + \return Returns a value between 0 and 90. */ + inline f64 getAngleWith(const vector2d &b) const + { + f64 tmp = (f64)(X * b.X + Y * b.Y); + + if (tmp == 0.0) + return 90.0; + + tmp = tmp / core::squareroot((f64)((X * X + Y * Y) * (b.X * b.X + b.Y * b.Y))); + if (tmp < 0.0) + tmp = -tmp; + if (tmp > 1.0) // avoid floating-point trouble + tmp = 1.0; + + return atan(sqrt(1 - tmp * tmp) / tmp) * RADTODEG64; + } + + //! Returns if this vector interpreted as a point is on a line between two other points. + /** It is assumed that the point is on the line. + \param begin Beginning vector to compare between. + \param end Ending vector to compare between. + \return True if this vector is between begin and end, false if not. */ + bool isBetweenPoints(const vector2d &begin, const vector2d &end) const + { + // . end + // / + // / + // / + // . begin + // - + // - + // . this point (am I inside or outside)? + // + if (begin.X != end.X) { + return ((begin.X <= X && X <= end.X) || + (begin.X >= X && X >= end.X)); + } else { + return ((begin.Y <= Y && Y <= end.Y) || + (begin.Y >= Y && Y >= end.Y)); + } + } + + //! Creates an interpolated vector between this vector and another vector. + /** \param other The other vector to interpolate with. + \param d Interpolation value between 0.0f (all the other vector) and 1.0f (all this vector). + Note that this is the opposite direction of interpolation to getInterpolated_quadratic() + \return An interpolated vector. This vector is not modified. */ + vector2d getInterpolated(const vector2d &other, f64 d) const + { + const f64 inv = 1.0f - d; + return vector2d((T)(other.X * inv + X * d), (T)(other.Y * inv + Y * d)); + } + + //! Creates a quadratically interpolated vector between this and two other vectors. + /** \param v2 Second vector to interpolate with. + \param v3 Third vector to interpolate with (maximum at 1.0f) + \param d Interpolation value between 0.0f (all this vector) and 1.0f (all the 3rd vector). + Note that this is the opposite direction of interpolation to getInterpolated() and interpolate() + \return An interpolated vector. This vector is not modified. */ + vector2d getInterpolated_quadratic(const vector2d &v2, const vector2d &v3, f64 d) const + { + // this*(1-d)*(1-d) + 2 * v2 * (1-d) + v3 * d * d; + const f64 inv = 1.0f - d; + const f64 mul0 = inv * inv; + const f64 mul1 = 2.0f * d * inv; + const f64 mul2 = d * d; + + return vector2d((T)(X * mul0 + v2.X * mul1 + v3.X * mul2), + (T)(Y * mul0 + v2.Y * mul1 + v3.Y * mul2)); + } + + /*! Test if this point and another 2 points taken as triplet + are colinear, clockwise, anticlockwise. This can be used also + to check winding order in triangles for 2D meshes. + \return 0 if points are colinear, 1 if clockwise, 2 if anticlockwise + */ + s32 checkOrientation(const vector2d &b, const vector2d &c) const + { + // Example of clockwise points + // + // ^ Y + // | A + // | . . + // | . . + // | C.....B + // +---------------> X + + T val = (b.Y - Y) * (c.X - b.X) - + (b.X - X) * (c.Y - b.Y); + + if (val == 0) + return 0; // colinear + + return (val > 0) ? 1 : 2; // clock or counterclock wise + } + + /*! Returns true if points (a,b,c) are clockwise on the X,Y plane*/ + inline bool areClockwise(const vector2d &b, const vector2d &c) const + { + T val = (b.Y - Y) * (c.X - b.X) - + (b.X - X) * (c.Y - b.Y); + + return val > 0; + } + + /*! Returns true if points (a,b,c) are counterclockwise on the X,Y plane*/ + inline bool areCounterClockwise(const vector2d &b, const vector2d &c) const + { + T val = (b.Y - Y) * (c.X - b.X) - + (b.X - X) * (c.Y - b.Y); + + return val < 0; + } + + //! Sets this vector to the linearly interpolated vector between a and b. + /** \param a first vector to interpolate with, maximum at 1.0f + \param b second vector to interpolate with, maximum at 0.0f + \param d Interpolation value between 0.0f (all vector b) and 1.0f (all vector a) + Note that this is the opposite direction of interpolation to getInterpolated_quadratic() + */ + vector2d &interpolate(const vector2d &a, const vector2d &b, f64 d) + { + X = (T)((f64)b.X + ((a.X - b.X) * d)); + Y = (T)((f64)b.Y + ((a.Y - b.Y) * d)); + return *this; + } + + //! X coordinate of vector. + T X; + + //! Y coordinate of vector. + T Y; +}; + +//! Typedef for f32 2d vector. +typedef vector2d vector2df; + +//! Typedef for integer 2d vector. +typedef vector2d vector2di; + +template +vector2d operator*(const S scalar, const vector2d &vector) +{ + return vector * scalar; +} + +// These methods are declared in dimension2d, but need definitions of vector2d +template +dimension2d::dimension2d(const vector2d &other) : + Width(other.X), Height(other.Y) +{ +} + +template +bool dimension2d::operator==(const vector2d &other) const +{ + return Width == other.X && Height == other.Y; +} + +} // end namespace core +} // end namespace irr + +namespace std +{ + +template +struct hash> +{ + size_t operator()(const irr::core::vector2d &vec) const + { + size_t h1 = hash()(vec.X); + size_t h2 = hash()(vec.Y); + return (h1 << (4 * sizeof(h1)) | h1 >> (4 * sizeof(h1))) ^ h2; + } +}; + +} diff --git a/irr/include/vector3d.h b/irr/include/vector3d.h new file mode 100644 index 000000000..a69f17e16 --- /dev/null +++ b/irr/include/vector3d.h @@ -0,0 +1,549 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrMath.h" + +#include + +namespace irr +{ +namespace core +{ + +//! 3d vector template class with lots of operators and methods. +/** The vector3d class is used in Irrlicht for three main purposes: + 1) As a direction vector (most of the methods assume this). + 2) As a position in 3d space (which is synonymous with a direction vector from the origin to this position). + 3) To hold three Euler rotations, where X is pitch, Y is yaw and Z is roll. +*/ +template +class vector3d +{ +public: + //! Default constructor (null vector). + constexpr vector3d() : + X(0), Y(0), Z(0) {} + //! Constructor with three different values + constexpr vector3d(T nx, T ny, T nz) : + X(nx), Y(ny), Z(nz) {} + //! Constructor with the same value for all elements + explicit constexpr vector3d(T n) : + X(n), Y(n), Z(n) {} + + // operators + + vector3d operator-() const { return vector3d(-X, -Y, -Z); } + + vector3d operator+(const vector3d &other) const { return vector3d(X + other.X, Y + other.Y, Z + other.Z); } + vector3d &operator+=(const vector3d &other) + { + X += other.X; + Y += other.Y; + Z += other.Z; + return *this; + } + vector3d operator+(const T val) const { return vector3d(X + val, Y + val, Z + val); } + vector3d &operator+=(const T val) + { + X += val; + Y += val; + Z += val; + return *this; + } + + vector3d operator-(const vector3d &other) const { return vector3d(X - other.X, Y - other.Y, Z - other.Z); } + vector3d &operator-=(const vector3d &other) + { + X -= other.X; + Y -= other.Y; + Z -= other.Z; + return *this; + } + vector3d operator-(const T val) const { return vector3d(X - val, Y - val, Z - val); } + vector3d &operator-=(const T val) + { + X -= val; + Y -= val; + Z -= val; + return *this; + } + + vector3d operator*(const vector3d &other) const { return vector3d(X * other.X, Y * other.Y, Z * other.Z); } + vector3d &operator*=(const vector3d &other) + { + X *= other.X; + Y *= other.Y; + Z *= other.Z; + return *this; + } + vector3d operator*(const T v) const { return vector3d(X * v, Y * v, Z * v); } + vector3d &operator*=(const T v) + { + X *= v; + Y *= v; + Z *= v; + return *this; + } + + vector3d operator/(const vector3d &other) const { return vector3d(X / other.X, Y / other.Y, Z / other.Z); } + vector3d &operator/=(const vector3d &other) + { + X /= other.X; + Y /= other.Y; + Z /= other.Z; + return *this; + } + vector3d operator/(const T v) const { return vector3d(X / v, Y / v, Z / v); } + vector3d &operator/=(const T v) + { + X /= v; + Y /= v; + Z /= v; + return *this; + } + + T &operator[](u32 index) + { + _IRR_DEBUG_BREAK_IF(index > 2) // access violation + + return *(&X + index); + } + + const T &operator[](u32 index) const + { + _IRR_DEBUG_BREAK_IF(index > 2) // access violation + + return *(&X + index); + } + + //! sort in order X, Y, Z. + constexpr bool operator<=(const vector3d &other) const + { + return !(*this > other); + } + + //! sort in order X, Y, Z. + constexpr bool operator>=(const vector3d &other) const + { + return !(*this < other); + } + + //! sort in order X, Y, Z. + constexpr bool operator<(const vector3d &other) const + { + return X < other.X || (X == other.X && Y < other.Y) || + (X == other.X && Y == other.Y && Z < other.Z); + } + + //! sort in order X, Y, Z. + constexpr bool operator>(const vector3d &other) const + { + return X > other.X || (X == other.X && Y > other.Y) || + (X == other.X && Y == other.Y && Z > other.Z); + } + + constexpr bool operator==(const vector3d &other) const + { + return X == other.X && Y == other.Y && Z == other.Z; + } + + constexpr bool operator!=(const vector3d &other) const + { + return !(*this == other); + } + + // functions + + //! Checks if this vector equals the other one. + /** Takes floating point rounding errors into account. + \param other Vector to compare with. + \return True if the two vector are (almost) equal, else false. */ + bool equals(const vector3d &other) const + { + return core::equals(X, other.X) && core::equals(Y, other.Y) && core::equals(Z, other.Z); + } + + vector3d &set(const T nx, const T ny, const T nz) + { + X = nx; + Y = ny; + Z = nz; + return *this; + } + vector3d &set(const vector3d &p) + { + X = p.X; + Y = p.Y; + Z = p.Z; + return *this; + } + + //! Get length of the vector. + T getLength() const { return core::squareroot(X * X + Y * Y + Z * Z); } + + //! Get squared length of the vector. + /** This is useful because it is much faster than getLength(). + \return Squared length of the vector. */ + T getLengthSQ() const { return X * X + Y * Y + Z * Z; } + + //! Get the dot product with another vector. + T dotProduct(const vector3d &other) const + { + return X * other.X + Y * other.Y + Z * other.Z; + } + + //! Get distance from another point. + /** Here, the vector is interpreted as point in 3 dimensional space. */ + T getDistanceFrom(const vector3d &other) const + { + return vector3d(X - other.X, Y - other.Y, Z - other.Z).getLength(); + } + + //! Returns squared distance from another point. + /** Here, the vector is interpreted as point in 3 dimensional space. */ + T getDistanceFromSQ(const vector3d &other) const + { + return vector3d(X - other.X, Y - other.Y, Z - other.Z).getLengthSQ(); + } + + //! Calculates the cross product with another vector. + /** \param p Vector to multiply with. + \return Cross product of this vector with p. */ + vector3d crossProduct(const vector3d &p) const + { + return vector3d(Y * p.Z - Z * p.Y, Z * p.X - X * p.Z, X * p.Y - Y * p.X); + } + + //! Returns if this vector interpreted as a point is on a line between two other points. + /** It is assumed that the point is on the line. + \param begin Beginning vector to compare between. + \param end Ending vector to compare between. + \return True if this vector is between begin and end, false if not. */ + bool isBetweenPoints(const vector3d &begin, const vector3d &end) const + { + const T f = (end - begin).getLengthSQ(); + return getDistanceFromSQ(begin) <= f && + getDistanceFromSQ(end) <= f; + } + + //! Normalizes the vector. + /** In case of the 0 vector the result is still 0, otherwise + the length of the vector will be 1. + \return Reference to this vector after normalization. */ + vector3d &normalize() + { + f64 length = X * X + Y * Y + Z * Z; + if (length == 0) // this check isn't an optimization but prevents getting NAN in the sqrt. + return *this; + length = core::reciprocal_squareroot(length); + + X = (T)(X * length); + Y = (T)(Y * length); + Z = (T)(Z * length); + return *this; + } + + //! Sets the length of the vector to a new value + vector3d &setLength(T newlength) + { + normalize(); + return (*this *= newlength); + } + + //! Inverts the vector. + vector3d &invert() + { + X *= -1; + Y *= -1; + Z *= -1; + return *this; + } + + //! Rotates the vector by a specified number of degrees around the Y axis and the specified center. + /** CAREFUL: For historical reasons rotateXZBy uses a right-handed rotation + (maybe to make it more similar to the 2D vector rotations which are counterclockwise). + To have this work the same way as rest of Irrlicht (nodes, matrices, other rotateBy functions) pass -1*degrees in here. + \param degrees Number of degrees to rotate around the Y axis. + \param center The center of the rotation. */ + void rotateXZBy(f64 degrees, const vector3d ¢er = vector3d()) + { + degrees *= DEGTORAD64; + f64 cs = cos(degrees); + f64 sn = sin(degrees); + X -= center.X; + Z -= center.Z; + set((T)(X * cs - Z * sn), Y, (T)(X * sn + Z * cs)); + X += center.X; + Z += center.Z; + } + + //! Rotates the vector by a specified number of degrees around the Z axis and the specified center. + /** \param degrees: Number of degrees to rotate around the Z axis. + \param center: The center of the rotation. */ + void rotateXYBy(f64 degrees, const vector3d ¢er = vector3d()) + { + degrees *= DEGTORAD64; + f64 cs = cos(degrees); + f64 sn = sin(degrees); + X -= center.X; + Y -= center.Y; + set((T)(X * cs - Y * sn), (T)(X * sn + Y * cs), Z); + X += center.X; + Y += center.Y; + } + + //! Rotates the vector by a specified number of degrees around the X axis and the specified center. + /** \param degrees: Number of degrees to rotate around the X axis. + \param center: The center of the rotation. */ + void rotateYZBy(f64 degrees, const vector3d ¢er = vector3d()) + { + degrees *= DEGTORAD64; + f64 cs = cos(degrees); + f64 sn = sin(degrees); + Z -= center.Z; + Y -= center.Y; + set(X, (T)(Y * cs - Z * sn), (T)(Y * sn + Z * cs)); + Z += center.Z; + Y += center.Y; + } + + //! Creates an interpolated vector between this vector and another vector. + /** \param other The other vector to interpolate with. + \param d Interpolation value between 0.0f (all the other vector) and 1.0f (all this vector). + Note that this is the opposite direction of interpolation to getInterpolated_quadratic() + \return An interpolated vector. This vector is not modified. */ + vector3d getInterpolated(const vector3d &other, f64 d) const + { + const f64 inv = 1.0 - d; + return vector3d((T)(other.X * inv + X * d), (T)(other.Y * inv + Y * d), (T)(other.Z * inv + Z * d)); + } + + //! Creates a quadratically interpolated vector between this and two other vectors. + /** \param v2 Second vector to interpolate with. + \param v3 Third vector to interpolate with (maximum at 1.0f) + \param d Interpolation value between 0.0f (all this vector) and 1.0f (all the 3rd vector). + Note that this is the opposite direction of interpolation to getInterpolated() and interpolate() + \return An interpolated vector. This vector is not modified. */ + vector3d getInterpolated_quadratic(const vector3d &v2, const vector3d &v3, f64 d) const + { + // this*(1-d)*(1-d) + 2 * v2 * (1-d) + v3 * d * d; + const f64 inv = (T)1.0 - d; + const f64 mul0 = inv * inv; + const f64 mul1 = (T)2.0 * d * inv; + const f64 mul2 = d * d; + + return vector3d((T)(X * mul0 + v2.X * mul1 + v3.X * mul2), + (T)(Y * mul0 + v2.Y * mul1 + v3.Y * mul2), + (T)(Z * mul0 + v2.Z * mul1 + v3.Z * mul2)); + } + + //! Sets this vector to the linearly interpolated vector between a and b. + /** \param a first vector to interpolate with, maximum at 1.0f + \param b second vector to interpolate with, maximum at 0.0f + \param d Interpolation value between 0.0f (all vector b) and 1.0f (all vector a) + Note that this is the opposite direction of interpolation to getInterpolated_quadratic() + */ + vector3d &interpolate(const vector3d &a, const vector3d &b, f64 d) + { + X = (T)((f64)b.X + ((a.X - b.X) * d)); + Y = (T)((f64)b.Y + ((a.Y - b.Y) * d)); + Z = (T)((f64)b.Z + ((a.Z - b.Z) * d)); + return *this; + } + + //! Get the rotations that would make a (0,0,1) direction vector point in the same direction as this direction vector. + /** Thanks to Arras on the Irrlicht forums for this method. This utility method is very useful for + orienting scene nodes towards specific targets. For example, if this vector represents the difference + between two scene nodes, then applying the result of getHorizontalAngle() to one scene node will point + it at the other one. + Example code: + // Where target and seeker are of type ISceneNode* + const vector3df toTarget(target->getAbsolutePosition() - seeker->getAbsolutePosition()); + const vector3df requiredRotation = toTarget.getHorizontalAngle(); + seeker->setRotation(requiredRotation); + + \return A rotation vector containing the X (pitch) and Y (raw) rotations (in degrees) that when applied to a + +Z (e.g. 0, 0, 1) direction vector would make it point in the same direction as this vector. The Z (roll) rotation + is always 0, since two Euler rotations are sufficient to point in any given direction. */ + vector3d getHorizontalAngle() const + { + vector3d angle; + + // tmp avoids some precision troubles on some compilers when working with T=s32 + f64 tmp = (atan2((f64)X, (f64)Z) * RADTODEG64); + angle.Y = (T)tmp; + + if (angle.Y < 0) + angle.Y += 360; + if (angle.Y >= 360) + angle.Y -= 360; + + const f64 z1 = core::squareroot(X * X + Z * Z); + + tmp = (atan2((f64)z1, (f64)Y) * RADTODEG64 - 90.0); + angle.X = (T)tmp; + + if (angle.X < 0) + angle.X += 360; + if (angle.X >= 360) + angle.X -= 360; + + return angle; + } + + //! Get the spherical coordinate angles + /** This returns Euler degrees for the point represented by + this vector. The calculation assumes the pole at (0,1,0) and + returns the angles in X and Y. + */ + vector3d getSphericalCoordinateAngles() const + { + vector3d angle; + const f64 length = X * X + Y * Y + Z * Z; + + if (length) { + if (X != 0) { + angle.Y = (T)(atan2((f64)Z, (f64)X) * RADTODEG64); + } else if (Z < 0) + angle.Y = 180; + + angle.X = (T)(acos(Y * core::reciprocal_squareroot(length)) * RADTODEG64); + } + return angle; + } + + //! Builds a direction vector from (this) rotation vector. + /** This vector is assumed to be a rotation vector composed of 3 Euler angle rotations, in degrees. + The implementation performs the same calculations as using a matrix to do the rotation. + + \param[in] forwards The direction representing "forwards" which will be rotated by this vector. + If you do not provide a direction, then the +Z axis (0, 0, 1) will be assumed to be forwards. + \return A direction vector calculated by rotating the forwards direction by the 3 Euler angles + (in degrees) represented by this vector. */ + vector3d rotationToDirection(const vector3d &forwards = vector3d(0, 0, 1)) const + { + const f64 cr = cos(core::DEGTORAD64 * X); + const f64 sr = sin(core::DEGTORAD64 * X); + const f64 cp = cos(core::DEGTORAD64 * Y); + const f64 sp = sin(core::DEGTORAD64 * Y); + const f64 cy = cos(core::DEGTORAD64 * Z); + const f64 sy = sin(core::DEGTORAD64 * Z); + + const f64 srsp = sr * sp; + const f64 crsp = cr * sp; + + const f64 pseudoMatrix[] = { + (cp * cy), (cp * sy), (-sp), + (srsp * cy - cr * sy), (srsp * sy + cr * cy), (sr * cp), + (crsp * cy + sr * sy), (crsp * sy - sr * cy), (cr * cp)}; + + return vector3d( + (T)(forwards.X * pseudoMatrix[0] + + forwards.Y * pseudoMatrix[3] + + forwards.Z * pseudoMatrix[6]), + (T)(forwards.X * pseudoMatrix[1] + + forwards.Y * pseudoMatrix[4] + + forwards.Z * pseudoMatrix[7]), + (T)(forwards.X * pseudoMatrix[2] + + forwards.Y * pseudoMatrix[5] + + forwards.Z * pseudoMatrix[8])); + } + + //! Fills an array of 4 values with the vector data (usually floats). + /** Useful for setting in shader constants for example. The fourth value + will always be 0. */ + void getAs4Values(T *array) const + { + array[0] = X; + array[1] = Y; + array[2] = Z; + array[3] = 0; + } + + //! Fills an array of 3 values with the vector data (usually floats). + /** Useful for setting in shader constants for example.*/ + void getAs3Values(T *array) const + { + array[0] = X; + array[1] = Y; + array[2] = Z; + } + + //! X coordinate of the vector + T X; + + //! Y coordinate of the vector + T Y; + + //! Z coordinate of the vector + T Z; +}; + +//! partial specialization for integer vectors +// Implementer note: inline keyword needed due to template specialization for s32. Otherwise put specialization into a .cpp +template <> +inline vector3d vector3d::operator/(s32 val) const +{ + return core::vector3d(X / val, Y / val, Z / val); +} +template <> +inline vector3d &vector3d::operator/=(s32 val) +{ + X /= val; + Y /= val; + Z /= val; + return *this; +} + +template <> +inline vector3d vector3d::getSphericalCoordinateAngles() const +{ + vector3d angle; + const f64 length = X * X + Y * Y + Z * Z; + + if (length) { + if (X != 0) { + angle.Y = round32((f32)(atan2((f64)Z, (f64)X) * RADTODEG64)); + } else if (Z < 0) + angle.Y = 180; + + angle.X = round32((f32)(acos(Y * core::reciprocal_squareroot(length)) * RADTODEG64)); + } + return angle; +} + +//! Typedef for a f32 3d vector. +typedef vector3d vector3df; + +//! Typedef for an integer 3d vector. +typedef vector3d vector3di; + +//! Function multiplying a scalar and a vector component-wise. +template +vector3d operator*(const S scalar, const vector3d &vector) +{ + return vector * scalar; +} + +} // end namespace core +} // end namespace irr + +namespace std +{ + +template +struct hash> +{ + size_t operator()(const irr::core::vector3d &vec) const + { + size_t h1 = hash()(vec.X); + size_t h2 = hash()(vec.Y); + size_t h3 = hash()(vec.Z); + return (h1 << (5 * sizeof(h1)) | h1 >> (3 * sizeof(h1))) ^ (h2 << (2 * sizeof(h2)) | h2 >> (6 * sizeof(h2))) ^ h3; + } +}; + +} diff --git a/irr/media/Shaders/OneTextureBlend.fsh b/irr/media/Shaders/OneTextureBlend.fsh new file mode 100644 index 000000000..7ecb7e1a2 --- /dev/null +++ b/irr/media/Shaders/OneTextureBlend.fsh @@ -0,0 +1,75 @@ +#version 100 + +precision mediump float; + +/* Uniforms */ + +uniform int uTextureUsage0; +uniform sampler2D uTextureUnit0; +uniform int uBlendType; +uniform int uFogEnable; +uniform int uFogType; +uniform vec4 uFogColor; +uniform float uFogStart; +uniform float uFogEnd; +uniform float uFogDensity; + +/* Varyings */ + +varying vec2 vTextureCoord0; +varying vec4 vVertexColor; +varying float vFogCoord; + +float computeFog() +{ + const float LOG2 = 1.442695; + float FogFactor = 0.0; + + if (uFogType == 0) // Exp + { + FogFactor = exp2(-uFogDensity * vFogCoord * LOG2); + } + else if (uFogType == 1) // Linear + { + float Scale = 1.0 / (uFogEnd - uFogStart); + FogFactor = (uFogEnd - vFogCoord) * Scale; + } + else if (uFogType == 2) // Exp2 + { + FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2); + } + + FogFactor = clamp(FogFactor, 0.0, 1.0); + + return FogFactor; +} + +void main() +{ + vec4 Color0 = vVertexColor; + vec4 Color1 = vec4(1.0, 1.0, 1.0, 1.0); + + if (bool(uTextureUsage0)) + Color1 = texture2D(uTextureUnit0, vTextureCoord0); + + vec4 FinalColor = Color0 * Color1; + + if (uBlendType == 1) + { + FinalColor.w = Color0.w; + } + else if (uBlendType == 2) + { + FinalColor.w = Color1.w; + } + + if (bool(uFogEnable)) + { + float FogFactor = computeFog(); + vec4 FogColor = uFogColor; + FogColor.a = 1.0; + FinalColor = mix(FogColor, FinalColor, FogFactor); + } + + gl_FragColor = FinalColor; +} diff --git a/irr/media/Shaders/Renderer2D.fsh b/irr/media/Shaders/Renderer2D.fsh new file mode 100644 index 000000000..89aef7e59 --- /dev/null +++ b/irr/media/Shaders/Renderer2D.fsh @@ -0,0 +1,23 @@ +#version 100 + +precision mediump float; + +/* Uniforms */ + +uniform int uTextureUsage; +uniform sampler2D uTextureUnit; + +/* Varyings */ + +varying vec2 vTextureCoord; +varying vec4 vVertexColor; + +void main() +{ + vec4 Color = vVertexColor; + + if (bool(uTextureUsage)) + Color *= texture2D(uTextureUnit, vTextureCoord); + + gl_FragColor = Color; +} diff --git a/irr/media/Shaders/Renderer2D.vsh b/irr/media/Shaders/Renderer2D.vsh new file mode 100644 index 000000000..914214895 --- /dev/null +++ b/irr/media/Shaders/Renderer2D.vsh @@ -0,0 +1,24 @@ +#version 100 + +/* Attributes */ + +attribute vec4 inVertexPosition; +attribute vec4 inVertexColor; +attribute vec2 inTexCoord0; + +/* Uniforms */ + +uniform float uThickness; + +/* Varyings */ + +varying vec2 vTextureCoord; +varying vec4 vVertexColor; + +void main() +{ + gl_Position = inVertexPosition; + gl_PointSize = uThickness; + vTextureCoord = inTexCoord0; + vVertexColor = inVertexColor.bgra; +} diff --git a/irr/media/Shaders/Renderer2D_noTex.fsh b/irr/media/Shaders/Renderer2D_noTex.fsh new file mode 100644 index 000000000..600097232 --- /dev/null +++ b/irr/media/Shaders/Renderer2D_noTex.fsh @@ -0,0 +1,11 @@ +#version 100 + +precision mediump float; + +/* Varyings */ +varying vec4 vVertexColor; + +void main() +{ + gl_FragColor = vVertexColor; +} diff --git a/irr/media/Shaders/Solid.fsh b/irr/media/Shaders/Solid.fsh new file mode 100644 index 000000000..c85c6baf1 --- /dev/null +++ b/irr/media/Shaders/Solid.fsh @@ -0,0 +1,62 @@ +#version 100 + +precision mediump float; + +/* Uniforms */ + +uniform int uTextureUsage0; +uniform sampler2D uTextureUnit0; +uniform int uFogEnable; +uniform int uFogType; +uniform vec4 uFogColor; +uniform float uFogStart; +uniform float uFogEnd; +uniform float uFogDensity; + +/* Varyings */ + +varying vec2 vTextureCoord0; +varying vec4 vVertexColor; +varying float vFogCoord; + +float computeFog() +{ + const float LOG2 = 1.442695; + float FogFactor = 0.0; + + if (uFogType == 0) // Exp + { + FogFactor = exp2(-uFogDensity * vFogCoord * LOG2); + } + else if (uFogType == 1) // Linear + { + float Scale = 1.0 / (uFogEnd - uFogStart); + FogFactor = (uFogEnd - vFogCoord) * Scale; + } + else if (uFogType == 2) // Exp2 + { + FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2); + } + + FogFactor = clamp(FogFactor, 0.0, 1.0); + + return FogFactor; +} + +void main() +{ + vec4 Color = vVertexColor; + + if (bool(uTextureUsage0)) + Color *= texture2D(uTextureUnit0, vTextureCoord0); + + if (bool(uFogEnable)) + { + float FogFactor = computeFog(); + vec4 FogColor = uFogColor; + FogColor.a = 1.0; + Color = mix(FogColor, Color, FogFactor); + } + + gl_FragColor = Color; +} diff --git a/irr/media/Shaders/Solid.vsh b/irr/media/Shaders/Solid.vsh new file mode 100644 index 000000000..7379e5bb4 --- /dev/null +++ b/irr/media/Shaders/Solid.vsh @@ -0,0 +1,38 @@ +#version 100 + +/* Attributes */ + +attribute vec3 inVertexPosition; +attribute vec3 inVertexNormal; +attribute vec4 inVertexColor; +attribute vec2 inTexCoord0; + +/* Uniforms */ + +uniform mat4 uWVPMatrix; +uniform mat4 uWVMatrix; +uniform mat4 uNMatrix; +uniform mat4 uTMatrix0; + +uniform float uThickness; + +/* Varyings */ + +varying vec2 vTextureCoord0; +varying vec4 vVertexColor; +varying float vFogCoord; + +void main() +{ + gl_Position = uWVPMatrix * vec4(inVertexPosition, 1.0); + gl_PointSize = uThickness; + + vec4 TextureCoord0 = vec4(inTexCoord0.x, inTexCoord0.y, 1.0, 1.0); + vTextureCoord0 = vec4(uTMatrix0 * TextureCoord0).xy; + + vVertexColor = inVertexColor.bgra; + + vec3 Position = (uWVMatrix * vec4(inVertexPosition, 1.0)).xyz; + + vFogCoord = length(Position); +} diff --git a/irr/media/Shaders/TransparentAlphaChannel.fsh b/irr/media/Shaders/TransparentAlphaChannel.fsh new file mode 100644 index 000000000..8491068aa --- /dev/null +++ b/irr/media/Shaders/TransparentAlphaChannel.fsh @@ -0,0 +1,69 @@ +#version 100 + +precision mediump float; + +/* Uniforms */ + +uniform float uAlphaRef; +uniform int uTextureUsage0; +uniform sampler2D uTextureUnit0; +uniform int uFogEnable; +uniform int uFogType; +uniform vec4 uFogColor; +uniform float uFogStart; +uniform float uFogEnd; +uniform float uFogDensity; + +/* Varyings */ + +varying vec2 vTextureCoord0; +varying vec4 vVertexColor; +varying float vFogCoord; + +float computeFog() +{ + const float LOG2 = 1.442695; + float FogFactor = 0.0; + + if (uFogType == 0) // Exp + { + FogFactor = exp2(-uFogDensity * vFogCoord * LOG2); + } + else if (uFogType == 1) // Linear + { + float Scale = 1.0 / (uFogEnd - uFogStart); + FogFactor = (uFogEnd - vFogCoord) * Scale; + } + else if (uFogType == 2) // Exp2 + { + FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2); + } + + FogFactor = clamp(FogFactor, 0.0, 1.0); + + return FogFactor; +} + +void main() +{ + vec4 Color = vVertexColor; + + if (bool(uTextureUsage0)) + { + Color *= texture2D(uTextureUnit0, vTextureCoord0); + + // TODO: uAlphaRef should rather control sharpness of alpha, don't know how to do that right now and this works in most cases. + if (Color.a < uAlphaRef) + discard; + } + + if (bool(uFogEnable)) + { + float FogFactor = computeFog(); + vec4 FogColor = uFogColor; + FogColor.a = 1.0; + Color = mix(FogColor, Color, FogFactor); + } + + gl_FragColor = Color; +} diff --git a/irr/media/Shaders/TransparentAlphaChannelRef.fsh b/irr/media/Shaders/TransparentAlphaChannelRef.fsh new file mode 100644 index 000000000..ac762f0c2 --- /dev/null +++ b/irr/media/Shaders/TransparentAlphaChannelRef.fsh @@ -0,0 +1,66 @@ +#version 100 + +precision mediump float; + +/* Uniforms */ + +uniform float uAlphaRef; +uniform int uTextureUsage0; +uniform sampler2D uTextureUnit0; +uniform int uFogEnable; +uniform int uFogType; +uniform vec4 uFogColor; +uniform float uFogStart; +uniform float uFogEnd; +uniform float uFogDensity; + +/* Varyings */ + +varying vec2 vTextureCoord0; +varying vec4 vVertexColor; +varying float vFogCoord; + +float computeFog() +{ + const float LOG2 = 1.442695; + float FogFactor = 0.0; + + if (uFogType == 0) // Exp + { + FogFactor = exp2(-uFogDensity * vFogCoord * LOG2); + } + else if (uFogType == 1) // Linear + { + float Scale = 1.0 / (uFogEnd - uFogStart); + FogFactor = (uFogEnd - vFogCoord) * Scale; + } + else if (uFogType == 2) // Exp2 + { + FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2); + } + + FogFactor = clamp(FogFactor, 0.0, 1.0); + + return FogFactor; +} + +void main() +{ + vec4 Color = vVertexColor; + + if (bool(uTextureUsage0)) + Color *= texture2D(uTextureUnit0, vTextureCoord0); + + if (Color.a < uAlphaRef) + discard; + + if (bool(uFogEnable)) + { + float FogFactor = computeFog(); + vec4 FogColor = uFogColor; + FogColor.a = 1.0; + Color = mix(FogColor, Color, FogFactor); + } + + gl_FragColor = Color; +} diff --git a/irr/media/Shaders/TransparentVertexAlpha.fsh b/irr/media/Shaders/TransparentVertexAlpha.fsh new file mode 100644 index 000000000..c85c6baf1 --- /dev/null +++ b/irr/media/Shaders/TransparentVertexAlpha.fsh @@ -0,0 +1,62 @@ +#version 100 + +precision mediump float; + +/* Uniforms */ + +uniform int uTextureUsage0; +uniform sampler2D uTextureUnit0; +uniform int uFogEnable; +uniform int uFogType; +uniform vec4 uFogColor; +uniform float uFogStart; +uniform float uFogEnd; +uniform float uFogDensity; + +/* Varyings */ + +varying vec2 vTextureCoord0; +varying vec4 vVertexColor; +varying float vFogCoord; + +float computeFog() +{ + const float LOG2 = 1.442695; + float FogFactor = 0.0; + + if (uFogType == 0) // Exp + { + FogFactor = exp2(-uFogDensity * vFogCoord * LOG2); + } + else if (uFogType == 1) // Linear + { + float Scale = 1.0 / (uFogEnd - uFogStart); + FogFactor = (uFogEnd - vFogCoord) * Scale; + } + else if (uFogType == 2) // Exp2 + { + FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2); + } + + FogFactor = clamp(FogFactor, 0.0, 1.0); + + return FogFactor; +} + +void main() +{ + vec4 Color = vVertexColor; + + if (bool(uTextureUsage0)) + Color *= texture2D(uTextureUnit0, vTextureCoord0); + + if (bool(uFogEnable)) + { + float FogFactor = computeFog(); + vec4 FogColor = uFogColor; + FogColor.a = 1.0; + Color = mix(FogColor, Color, FogFactor); + } + + gl_FragColor = Color; +} diff --git a/irr/media/coolguy_opt.x b/irr/media/coolguy_opt.x new file mode 100755 index 000000000..e806d8315 --- /dev/null +++ b/irr/media/coolguy_opt.x @@ -0,0 +1,2 @@ +xof 0303txt 0032 +AnimationSet{Animation{{Armature}AnimationKey{0;2;0;4;1,0,0,0;;,29;4;1,0,0,0;;;}AnimationKey{2;2;0;3;0,0,0;;,29;3;0,0,0;;;}}Animation{{Armature_knee_r}AnimationKey{0;16;0;4;0.864183,0.503177,0,0;;,1;4;0.829812,0.558043,0,0;;,3;4;0.708698,0.705512,0,0;;,5;4;0.589108,0.808054,0,0;;,7;4;0.593659,0.804717,0,0;;,9;4;0.748627,0.662991,0,0;;,11;4;0.910305,0.413938,0,0;;,13;4;0.975925,0.218107,0,0;;,15;4;0.981302,0.192476,0,0;;,17;4;0.975476,0.220108,0,0;;,19;4;0.963662,0.267124,0,0;;,21;4;0.945893,0.324478,0,0;;,23;4;0.923816,0.382838,0,0;;,25;4;0.901205,0.433394,0,0;;,27;4;0.883429,0.468566,0,0;;,29;4;0.876305,0.481757,0,0;;;}AnimationKey{2;2;0;3;0,0,1.10139;;,29;3;0,0,1.10139;;;}}Animation{{Armature_elbow_r}AnimationKey{0;16;0;4;0.756295,0.004619,-0.619265,0.210967;;,1;4;0.771977,0.005599,-0.60257,0.202311;;,3;4;0.825501,0.009164,-0.538259,0.169533;;,5;4;0.891859,0.014253,-0.436142,0.119019;;,7;4;0.949154,0.019821,-0.308768,0.058108;;,9;4;0.983251,0.024703,-0.18057,-0.001258;;,11;4;0.995416,0.028143,-0.07812,-0.047458;;,13;4;0.996672,0.02991,-0.020368,-0.073041;;,15;4;0.996672,0.02991,-0.020368,-0.073041;;,17;4;0.995416,0.028143,-0.07812,-0.047458;;,19;4;0.983251,0.024703,-0.18057,-0.001258;;,21;4;0.949154,0.019821,-0.308768,0.058108;;,23;4;0.891859,0.014253,-0.436142,0.119019;;,25;4;0.825501,0.009164,-0.538259,0.169533;;,27;4;0.771977,0.005599,-0.60257,0.202311;;,29;4;0.750682,0.004275,-0.625038,0.213976;;;}AnimationKey{2;2;0;3;0,0,0.754892;;,29;3;0,0,0.754892;;;}}Animation{{Armature_arm_r}AnimationKey{0;16;0;4;0.28219,0.629905,0.723388,-0.017285;;,1;4;0.277641,0.632543,0.722699,-0.022614;;,3;4;0.261375,0.641615,0.719924,-0.041507;;,5;4;0.238321,0.653533,0.715186,-0.067874;;,7;4;0.212026,0.665838,0.708676,-0.097381;;,9;4;0.186345,0.676585,0.701229,-0.125643;;,11;4;0.165298,0.684491,0.694351,-0.14841;;,13;4;0.152894,0.688778,0.68998,-0.161665;;,15;4;0.152894,0.688779,0.68998,-0.161665;;,17;4;0.165298,0.684491,0.694351,-0.14841;;,19;4;0.186345,0.676585,0.701229,-0.125643;;,21;4;0.212026,0.665838,0.708676,-0.097381;;,23;4;0.238321,0.653533,0.715186,-0.067874;;,25;4;0.261375,0.641615,0.719924,-0.041507;;,27;4;0.277641,0.632543,0.722699,-0.022614;;,29;4;0.283802,0.628959,0.723623,-0.015394;;;}AnimationKey{2;2;0;3;-0.545315,0,1;;,29;3;-0.545315,0,1;;;}}Animation{{Armature_knee_l}AnimationKey{0;16;0;4;0.981896,0.189423,0,0;;,1;4;0.9814,0.191974,0,0;;,3;4;0.979127,0.203251,0,0;;,5;4;0.974526,0.224276,0,0;;,7;4;0.96645,0.256853,0,0;;,9;4;0.953088,0.302692,0,0;;,11;4;0.931731,0.36315,0,0;;,13;4;0.898645,0.438676,0,0;;,15;4;0.848226,0.529634,0,0;;,17;4;0.773692,0.633562,0,0;;,19;4;0.689831,0.72397,0,0;;,21;4;0.629304,0.777159,0,0;;,23;4;0.648685,0.761057,0,0;;,25;4;0.812268,0.583284,0,0;;,27;4;0.948066,0.318074,0,0;;,29;4;0.982049,0.188624,0,0;;;}AnimationKey{2;2;0;3;0,0,1.10139;;,29;3;0,0,1.10139;;;}}Animation{{Armature_Bone_007}AnimationKey{0;16;0;4;0.993671,-0.112331,0,0;;,1;4;0.994784,-0.102002,0,0;;,3;4;0.997507,-0.070564,0,0;;,5;4;0.999237,-0.039056,0,0;;,7;4;0.999694,-0.024737,0,0;;,9;4;0.999079,-0.042907,0,0;;,11;4;0.99677,-0.080308,0,0;;,13;4;0.993798,-0.111199,0,0;;,15;4;0.993599,-0.112965,0,0;;,17;4;0.995813,-0.091409,0,0;;,19;4;0.998181,-0.060285,0,0;;,21;4;0.999479,-0.032286,0,0;;,23;4;0.999797,-0.020142,0,0;;,25;4;0.998983,-0.045097,0,0;;,27;4;0.995813,-0.091409,0,0;;,29;4;0.993221,-0.116243,0,0;;;}AnimationKey{2;2;0;3;0,0,1.221802;;,29;3;0,0,1.221802;;;}}Animation{{Armature_elbow_l}AnimationKey{0;16;0;4;0.995195,-0.034868,-0.015799,-0.090119;;,1;4;0.993465,-0.046368,-0.030155,-0.099838;;,3;4;0.983557,-0.0879,-0.082099,-0.134715;;,5;4;0.959324,-0.146904,-0.156177,-0.183648;;,7;4;0.917546,-0.212233,-0.238611,-0.236921;;,9;4;0.864109,-0.271657,-0.314022,-0.284443;;,11;4;0.813172,-0.315829,-0.370387,-0.319087;;,13;4;0.781004,-0.339668,-0.400938,-0.337501;;,15;4;0.781004,-0.339668,-0.400938,-0.337501;;,17;4;0.813172,-0.315829,-0.370387,-0.319087;;,19;4;0.864109,-0.271657,-0.314022,-0.284443;;,21;4;0.917546,-0.212233,-0.238611,-0.236921;;,23;4;0.959324,-0.146904,-0.156177,-0.183648;;,25;4;0.983557,-0.0879,-0.082099,-0.134715;;,27;4;0.993465,-0.046368,-0.030155,-0.099838;;,29;4;0.995701,-0.030812,-0.010739,-0.086685;;;}AnimationKey{2;2;0;3;0,0,0.754892;;,29;3;0,0,0.754892;;;}}Animation{{Armature_body}AnimationKey{0;16;0;4;-0,0,0.601298,0.799025;;,1;4;-0,0,0.608144,0.793827;;,3;4;-0,0,0.627465,0.778645;;,5;4;-0,0,0.643183,0.765712;;,7;4;-0,0,0.643755,0.765231;;,9;4;-0,0,0.631076,0.775721;;,11;4;-0,0,0.613775,0.789481;;,13;4;-0,0,0.6007,0.799474;;,15;4;-0,0,0.601488,0.798882;;,17;4;-0,0,0.619499,0.784997;;,19;4;-0,0,0.643196,0.765702;;,21;4;-0,0,0.660441,0.750878;;,23;4;-0,0,0.659666,0.751559;;,25;4;-0,0,0.638264,0.769817;;,27;4;-0,0,0.611752,0.791049;;,29;4;-0,0,0.598631,0.801025;;;}AnimationKey{2;2;0;3;0,2.580534,0;;,29;3;0,2.571201,0;;;}}Animation{{Armature_leg_l}AnimationKey{0;16;0;4;0.390287,0.920693,0,0;;,1;4;0.362565,0.931959,0,0;;,3;4;0.266163,0.963928,0,0;;,5;4;0.138294,0.990391,0,0;;,7;4;0.012725,0.999919,0,0;;,9;4;-0.090194,0.995924,0,0;;,11;4;-0.162502,0.986708,0,0;;,13;4;-0.201466,0.979496,0,0;;,15;4;-0.185641,0.982618,0,0;;,17;4;-0.013697,0.999906,0,0;;,19;4;0.24238,0.970181,0,0;;,21;4;0.417271,0.908782,0,0;;,23;4;0.439308,0.898336,0,0;;,25;4;0.424255,0.905543,0,0;;,27;4;0.407664,0.913132,0,0;;,29;4;0.400263,0.9164,0,0;;;}AnimationKey{2;2;0;3;0.246294,0,-0.171352;;,29;3;0.246294,0,-0.171351;;;}}Animation{{Armature_leg_r}AnimationKey{0;16;0;4;0.174933,-0.98458,0,0;;,1;4;0.082829,-0.996564,0,0;;,3;4;-0.21147,-0.977384,0,0;;,5;4;-0.442802,-0.89662,0,0;;,7;4;-0.47604,-0.879424,0,0;;,9;4;-0.47279,-0.881175,0,0;;,11;4;-0.459567,-0.888143,0,0;;,13;4;-0.427425,-0.904051,0,0;;,15;4;-0.361724,-0.932285,0,0;;,17;4;-0.251362,-0.967893,0,0;;,19;4;-0.114531,-0.99342,0,0;;,21;4;0.021053,-0.999778,0,0;;,23;4;0.12473,-0.992191,0,0;;,25;4;0.181473,-0.983396,0,0;;,27;4;0.204037,-0.978963,0,0;;,29;4;0.208187,-0.978089,0,0;;;}AnimationKey{2;2;0;3;-0.246294,0,-0.171352;;,29;3;-0.246294,0,-0.171351;;;}}Animation{{Armature_arm_l}AnimationKey{0;16;0;4;0.200754,-0.659656,-0.716264,-0.107316;;,1;4;0.192268,-0.660735,-0.716526,-0.114246;;,3;4;0.161871,-0.663925,-0.716753,-0.138802;;,5;4;0.118745,-0.666682,-0.715211,-0.17294;;,7;4;0.069733,-0.667364,-0.710872,-0.210767;;,9;4;0.022313,-0.665594,-0.704111,-0.246404;;,11;4;-0.016046,-0.662426,-0.696821,-0.274543;;,13;4;-0.038374,-0.659874,-0.691824,-0.290643;;,15;4;-0.038373,-0.659874,-0.691824,-0.290643;;,17;4;-0.016044,-0.662427,-0.696822,-0.274543;;,19;4;0.022312,-0.665594,-0.70411,-0.246404;;,21;4;0.069733,-0.667365,-0.710872,-0.210767;;,23;4;0.118745,-0.666682,-0.715211,-0.17294;;,25;4;0.161871,-0.663925,-0.716753,-0.138802;;,27;4;0.192268,-0.660735,-0.716526,-0.114246;;,29;4;0.203757,-0.659255,-0.716151,-0.104856;;;}AnimationKey{2;2;0;3;0.545315,0,1;;,29;3;0.545315,0,1;;;}}}Frame Root{FrameTransformMatrix{1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1;;}Frame Armature{FrameTransformMatrix{1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1;;}Frame Armature_body{FrameTransformMatrix{-1,0,0,0,0,0,1,0,0,1,0,0,0,2.571201,0,1;;}Frame Armature_arm_r{FrameTransformMatrix{-0.047733,0.997488,-0.05233,0,0.901521,0.020464,-0.432251,0,-0.430095,-0.067809,-0.900233,0,-0.545315,0,1,1;;}Frame Armature_elbow_r{FrameTransformMatrix{0.987983,0.151721,-0.029519,0,-0.153228,0.986478,-0.058162,0,0.020295,0.061987,0.997871,0,0,0,0.754892,1;;}}}Frame Armature_arm_l{FrameTransformMatrix{-0.047732,0.994072,-0.097683,0,0.901521,0.084983,0.424309,0,0.430095,-0.067809,-0.900233,0,0.545315,0,1,1;;}Frame Armature_elbow_l{FrameTransformMatrix{0.984741,0.173286,-0.016044,0,-0.171963,0.983073,0.063221,0,0.026727,-0.059497,0.99787,0,0,0,0.754892,1;;}}}Frame Armature_leg_l{FrameTransformMatrix{1,0,0,0,0,-0.998426,-0.056453,0,0,0.056453,-0.998405,0,0.246294,0,-0.171351,1;;}Frame Armature_knee_l{FrameTransformMatrix{1,0,0,0,0,0.993861,-0.110639,0,0,0.110639,0.993861,0,0,0,1.10139,1;;}}}Frame Armature_leg_r{FrameTransformMatrix{1,0,0,0,0,-0.998426,-0.056453,0,0,0.056453,-0.998405,0,-0.246294,0,-0.171351,1;;}Frame Armature_knee_r{FrameTransformMatrix{1,0,0,0,0,0.993861,-0.110639,0,0,0.110639,0.993861,0,0,0,1.10139,1;;}}}Frame Armature_Bone_007{FrameTransformMatrix{1,0,0,0,0,1,0,0,0,0,1,0,0,0,1.221802,1;;}}}Frame cool_dude{FrameTransformMatrix{-1,0,0,0,0,1,0,0,0,0,-1,0,0,0,0,1;;}Mesh{272;0;2.440814;0.219926;,0;3.688199;0.219926;,0.466212;3.688199;0.219926;,0.466212;2.440814;0.219926;,0.466212;2.440814;0.219926;,0.466212;3.688199;0.219926;,0.466212;3.688199;-0.219926;,0.466212;2.440814;-0.219926;,0;2.440814;0.219926;,0.466212;2.440814;0.219926;,0.466212;2.440814;-0.219926;,0;2.440814;-0.219926;,0.055633;1.27575;-0.190081;,0.055633;2.35741;-0.190081;,0.055633;2.35741;0.190081;,0.055633;1.27575;0.190081;,0.055633;1.27575;0.190081;,0.055633;2.35741;0.190081;,0.43017;2.35741;0.190081;,0.43017;1.27575;0.190081;,0.43017;1.27575;0.190081;,0.43017;2.35741;0.190081;,0.43017;2.35741;-0.190081;,0.43017;1.27575;-0.190081;,0.43017;1.27575;-0.190081;,0.43017;2.35741;-0.190081;,0.055633;2.35741;-0.190081;,0.055633;1.27575;-0.190081;,0.055633;1.27575;0.190081;,0.43017;1.27575;0.190081;,0.43017;1.27575;-0.190081;,0.055633;1.27575;-0.190081;,0.43017;2.35741;0.190081;,0.055633;2.35741;0.190081;,0.055633;2.35741;-0.190081;,0.43017;2.35741;-0.190081;,0.466212;3.688199;0.219926;,0;3.688199;0.219926;,0;3.688199;-0.219926;,0.466212;3.688199;-0.219926;,0.466212;2.440814;-0.219926;,0.466212;3.688199;-0.219926;,0;3.688199;-0.219926;,0;2.440814;-0.219926;,0.769341;2.834949;-0.041122;,0.440953;3.555781;-0.041122;,0.440953;3.555781;0.207294;,0.769341;2.834949;0.207294;,0.769341;2.834949;0.207294;,0.440953;3.555781;0.207294;,0.616273;3.635651;0.207294;,0.944661;2.914819;0.207294;,0.944661;2.914819;0.207294;,0.616273;3.635651;0.207294;,0.616273;3.635651;-0.041122;,0.944661;2.914819;-0.041122;,0.944661;2.914819;-0.041122;,0.616273;3.635651;-0.041122;,0.440953;3.555781;-0.041122;,0.769341;2.834949;-0.041122;,0.769341;2.834949;0.207294;,0.944661;2.914819;0.207294;,0.944661;2.914819;-0.041122;,0.769341;2.834949;-0.041122;,0.616273;3.635651;0.207294;,0.440953;3.555781;0.207294;,0.440953;3.555781;-0.041122;,0.616273;3.635651;-0.041122;,1.104504;2.080977;-0.086788;,0.776116;2.801809;-0.086788;,0.776116;2.801809;0.161627;,1.104504;2.080977;0.161627;,1.104504;2.080977;0.161627;,0.776116;2.801809;0.161627;,0.951436;2.881679;0.161627;,1.279824;2.160847;0.161627;,1.279824;2.160847;0.161627;,0.951436;2.881679;0.161627;,0.951436;2.881679;-0.086788;,1.279824;2.160847;-0.086788;,1.279824;2.160847;-0.086788;,0.951436;2.881679;-0.086788;,0.776116;2.801809;-0.086788;,1.104504;2.080977;-0.086788;,1.104504;2.080977;0.161627;,1.279824;2.160847;0.161627;,1.279824;2.160847;-0.086788;,1.104504;2.080977;-0.086788;,0.951436;2.881679;0.161627;,0.776116;2.801809;0.161627;,0.776116;2.801809;-0.086788;,0.951436;2.881679;-0.086788;,0.055633;0.093601;-0.190081;,0.055633;1.205294;-0.190081;,0.055633;1.205294;0.190081;,0.055633;0.093601;0.190081;,0.055633;0.093601;0.190081;,0.055633;1.205294;0.190081;,0.43017;1.205294;0.190081;,0.43017;0.093601;0.190081;,0.43017;0.093601;0.190081;,0.43017;1.205294;0.190081;,0.43017;1.205294;-0.190081;,0.43017;0.093601;-0.190081;,0.43017;0.093601;-0.190081;,0.43017;1.205294;-0.190081;,0.055633;1.205294;-0.190081;,0.055633;0.093601;-0.190081;,0.055633;0.093601;0.190081;,0.43017;0.093601;0.190081;,0.43017;0.093601;-0.190081;,0.055633;0.093601;-0.190081;,0.43017;1.205294;0.190081;,0.055633;1.205294;0.190081;,0.055633;1.205294;-0.190081;,0.43017;1.205294;-0.190081;,0;3.790919;0.428464;,0;4.579204;0.428464;,0.43344;4.560537;0.409797;,0.43344;3.809586;0.409797;,0.43344;3.809586;0.409797;,0.43344;4.560537;0.409797;,0.43344;4.560537;-0.284975;,0.43344;3.809586;-0.284975;,0;3.790919;0.428464;,0.43344;3.809586;0.409797;,0.43344;3.809586;-0.284975;,0;3.790919;-0.303642;,0.43344;4.560537;0.409797;,0;4.579204;0.428464;,0;4.579204;-0.303642;,0.43344;4.560537;-0.284975;,0.43344;3.809586;-0.284975;,0.43344;4.560537;-0.284975;,0;4.579204;-0.303642;,0;3.790919;-0.303642;,0;2.440814;0.219926;,-0.466212;2.440814;0.219926;,-0.466212;3.688199;0.219926;,0;3.688199;0.219926;,-0.466212;2.440814;0.219926;,-0.466212;2.440814;-0.219926;,-0.466212;3.688199;-0.219926;,-0.466212;3.688199;0.219926;,0;2.440814;0.219926;,0;2.440814;-0.219926;,-0.466212;2.440814;-0.219926;,-0.466212;2.440814;0.219926;,-0.055633;1.27575;-0.190081;,-0.055633;1.27575;0.190081;,-0.055633;2.35741;0.190081;,-0.055633;2.35741;-0.190081;,-0.055633;1.27575;0.190081;,-0.43017;1.27575;0.190081;,-0.43017;2.35741;0.190081;,-0.055633;2.35741;0.190081;,-0.43017;1.27575;0.190081;,-0.43017;1.27575;-0.190081;,-0.43017;2.35741;-0.190081;,-0.43017;2.35741;0.190081;,-0.43017;1.27575;-0.190081;,-0.055633;1.27575;-0.190081;,-0.055633;2.35741;-0.190081;,-0.43017;2.35741;-0.190081;,-0.055633;1.27575;0.190081;,-0.055633;1.27575;-0.190081;,-0.43017;1.27575;-0.190081;,-0.43017;1.27575;0.190081;,-0.43017;2.35741;0.190081;,-0.43017;2.35741;-0.190081;,-0.055633;2.35741;-0.190081;,-0.055633;2.35741;0.190081;,-0.466212;3.688199;0.219926;,-0.466212;3.688199;-0.219926;,0;3.688199;-0.219926;,0;3.688199;0.219926;,-0.466212;2.440814;-0.219926;,0;2.440814;-0.219926;,0;3.688199;-0.219926;,-0.466212;3.688199;-0.219926;,-0.769341;2.834949;-0.041122;,-0.769341;2.834949;0.207294;,-0.440953;3.555781;0.207294;,-0.440953;3.555781;-0.041122;,-0.769341;2.834949;0.207294;,-0.944661;2.914819;0.207294;,-0.616273;3.635651;0.207294;,-0.440953;3.555781;0.207294;,-0.944661;2.914819;0.207294;,-0.944661;2.914819;-0.041122;,-0.616273;3.635651;-0.041122;,-0.616273;3.635651;0.207294;,-0.944661;2.914819;-0.041122;,-0.769341;2.834949;-0.041122;,-0.440953;3.555781;-0.041122;,-0.616273;3.635651;-0.041122;,-0.769341;2.834949;0.207294;,-0.769341;2.834949;-0.041122;,-0.944661;2.914819;-0.041122;,-0.944661;2.914819;0.207294;,-0.616273;3.635651;0.207294;,-0.616273;3.635651;-0.041122;,-0.440953;3.555781;-0.041122;,-0.440953;3.555781;0.207294;,-1.104504;2.080977;-0.086788;,-1.104504;2.080977;0.161627;,-0.776116;2.801809;0.161627;,-0.776116;2.801809;-0.086788;,-1.104504;2.080977;0.161627;,-1.279824;2.160847;0.161627;,-0.951436;2.881679;0.161627;,-0.776116;2.801809;0.161627;,-1.279824;2.160847;0.161627;,-1.279824;2.160847;-0.086788;,-0.951436;2.881679;-0.086788;,-0.951436;2.881679;0.161627;,-1.279824;2.160847;-0.086788;,-1.104504;2.080977;-0.086788;,-0.776116;2.801809;-0.086788;,-0.951436;2.881679;-0.086788;,-1.104504;2.080977;0.161627;,-1.104504;2.080977;-0.086788;,-1.279824;2.160847;-0.086788;,-1.279824;2.160847;0.161627;,-0.951436;2.881679;0.161627;,-0.951436;2.881679;-0.086788;,-0.776116;2.801809;-0.086788;,-0.776116;2.801809;0.161627;,-0.055633;0.093601;-0.190081;,-0.055633;0.093601;0.190081;,-0.055633;1.205294;0.190081;,-0.055633;1.205294;-0.190081;,-0.055633;0.093601;0.190081;,-0.43017;0.093601;0.190081;,-0.43017;1.205294;0.190081;,-0.055633;1.205294;0.190081;,-0.43017;0.093601;0.190081;,-0.43017;0.093601;-0.190081;,-0.43017;1.205294;-0.190081;,-0.43017;1.205294;0.190081;,-0.43017;0.093601;-0.190081;,-0.055633;0.093601;-0.190081;,-0.055633;1.205294;-0.190081;,-0.43017;1.205294;-0.190081;,-0.055633;0.093601;0.190081;,-0.055633;0.093601;-0.190081;,-0.43017;0.093601;-0.190081;,-0.43017;0.093601;0.190081;,-0.43017;1.205294;0.190081;,-0.43017;1.205294;-0.190081;,-0.055633;1.205294;-0.190081;,-0.055633;1.205294;0.190081;,0;3.790919;0.428464;,-0.43344;3.809586;0.409797;,-0.43344;4.560537;0.409797;,0;4.579204;0.428464;,-0.43344;3.809586;0.409797;,-0.43344;3.809586;-0.284975;,-0.43344;4.560537;-0.284975;,-0.43344;4.560537;0.409797;,0;3.790919;0.428464;,0;3.790919;-0.303642;,-0.43344;3.809586;-0.284975;,-0.43344;3.809586;0.409797;,-0.43344;4.560537;0.409797;,-0.43344;4.560537;-0.284975;,0;4.579204;-0.303642;,0;4.579204;0.428464;,-0.43344;3.809586;-0.284975;,0;3.790919;-0.303642;,0;4.579204;-0.303642;,-0.43344;4.560537;-0.284975;;68;4;3,2,1,0;,4;7,6,5,4;,4;11,10,9,8;,4;15,14,13,12;,4;19,18,17,16;,4;23,22,21,20;,4;27,26,25,24;,4;31,30,29,28;,4;35,34,33,32;,4;39,38,37,36;,4;43,42,41,40;,4;47,46,45,44;,4;51,50,49,48;,4;55,54,53,52;,4;59,58,57,56;,4;63,62,61,60;,4;67,66,65,64;,4;71,70,69,68;,4;75,74,73,72;,4;79,78,77,76;,4;83,82,81,80;,4;87,86,85,84;,4;91,90,89,88;,4;95,94,93,92;,4;99,98,97,96;,4;103,102,101,100;,4;107,106,105,104;,4;111,110,109,108;,4;115,114,113,112;,4;119,118,117,116;,4;123,122,121,120;,4;127,126,125,124;,4;131,130,129,128;,4;135,134,133,132;,4;139,138,137,136;,4;143,142,141,140;,4;147,146,145,144;,4;151,150,149,148;,4;155,154,153,152;,4;159,158,157,156;,4;163,162,161,160;,4;167,166,165,164;,4;171,170,169,168;,4;175,174,173,172;,4;179,178,177,176;,4;183,182,181,180;,4;187,186,185,184;,4;191,190,189,188;,4;195,194,193,192;,4;199,198,197,196;,4;203,202,201,200;,4;207,206,205,204;,4;211,210,209,208;,4;215,214,213,212;,4;219,218,217,216;,4;223,222,221,220;,4;227,226,225,224;,4;231,230,229,228;,4;235,234,233,232;,4;239,238,237,236;,4;243,242,241,240;,4;247,246,245,244;,4;251,250,249,248;,4;255,254,253,252;,4;259,258,257,256;,4;263,262,261,260;,4;267,266,265,264;,4;271,270,269,268;;MeshNormals{272;0;-0.707083;0.707083;,0;0.707083;0.707083;,0.577349;0.577349;0.577349;,0.577349;-0.577349;0.577349;,0.577349;-0.577349;0.577349;,0.577349;0.577349;0.577349;,0.577349;0.577349;-0.577349;,0.577349;-0.577349;-0.577349;,0;-0.707083;0.707083;,0.577349;-0.577349;0.577349;,0.577349;-0.577349;-0.577349;,0;-0.707083;-0.707083;,-0.577349;-0.577349;-0.577349;,-0.577349;0.577349;-0.577349;,-0.577349;0.577349;0.577349;,-0.577349;-0.577349;0.577349;,-0.577349;-0.577349;0.577349;,-0.577349;0.577349;0.577349;,0.577349;0.577349;0.577349;,0.577349;-0.577349;0.577349;,0.577349;-0.577349;0.577349;,0.577349;0.577349;0.577349;,0.577349;0.577349;-0.577349;,0.577349;-0.577349;-0.577349;,0.577349;-0.577349;-0.577349;,0.577349;0.577349;-0.577349;,-0.577349;0.577349;-0.577349;,-0.577349;-0.577349;-0.577349;,-0.577349;-0.577349;0.577349;,0.577349;-0.577349;0.577349;,0.577349;-0.577349;-0.577349;,-0.577349;-0.577349;-0.577349;,0.577349;0.577349;0.577349;,-0.577349;0.577349;0.577349;,-0.577349;0.577349;-0.577349;,0.577349;0.577349;-0.577349;,0.577349;0.577349;0.577349;,0;0.707083;0.707083;,0;0.707083;-0.707083;,0.577349;0.577349;-0.577349;,0.577349;-0.577349;-0.577349;,0.577349;0.577349;-0.577349;,0;0.707083;-0.707083;,0;-0.707083;-0.707083;,-0.286019;-0.764733;-0.577349;,-0.764733;0.286019;-0.577349;,-0.764733;0.286019;0.577349;,-0.286019;-0.764733;0.577349;,-0.286019;-0.764733;0.577349;,-0.764733;0.286019;0.577349;,0.286019;0.764733;0.577349;,0.764733;-0.286019;0.577349;,0.764733;-0.286019;0.577349;,0.286019;0.764733;0.577349;,0.286019;0.764733;-0.577349;,0.764733;-0.286019;-0.577349;,0.764733;-0.286019;-0.577349;,0.286019;0.764733;-0.577349;,-0.764733;0.286019;-0.577349;,-0.286019;-0.764733;-0.577349;,-0.286019;-0.764733;0.577349;,0.764733;-0.286019;0.577349;,0.764733;-0.286019;-0.577349;,-0.286019;-0.764733;-0.577349;,0.286019;0.764733;0.577349;,-0.764733;0.286019;0.577349;,-0.764733;0.286019;-0.577349;,0.286019;0.764733;-0.577349;,-0.286019;-0.764733;-0.577349;,-0.764733;0.286019;-0.577349;,-0.764733;0.286019;0.577349;,-0.286019;-0.764733;0.577349;,-0.286019;-0.764733;0.577349;,-0.764733;0.286019;0.577349;,0.286019;0.764733;0.577349;,0.764733;-0.286019;0.577349;,0.764733;-0.286019;0.577349;,0.286019;0.764733;0.577349;,0.286019;0.764733;-0.577349;,0.764733;-0.286019;-0.577349;,0.764733;-0.286019;-0.577349;,0.286019;0.764733;-0.577349;,-0.764733;0.286019;-0.577349;,-0.286019;-0.764733;-0.577349;,-0.286019;-0.764733;0.577349;,0.764733;-0.286019;0.577349;,0.764733;-0.286019;-0.577349;,-0.286019;-0.764733;-0.577349;,0.286019;0.764733;0.577349;,-0.764733;0.286019;0.577349;,-0.764733;0.286019;-0.577349;,0.286019;0.764733;-0.577349;,-0.577349;-0.577349;-0.577349;,-0.577349;0.577349;-0.577349;,-0.577349;0.577349;0.577349;,-0.577349;-0.577349;0.577349;,-0.577349;-0.577349;0.577349;,-0.577349;0.577349;0.577349;,0.577349;0.577349;0.577349;,0.577349;-0.577349;0.577349;,0.577349;-0.577349;0.577349;,0.577349;0.577349;0.577349;,0.577349;0.577349;-0.577349;,0.577349;-0.577349;-0.577349;,0.577349;-0.577349;-0.577349;,0.577349;0.577349;-0.577349;,-0.577349;0.577349;-0.577349;,-0.577349;-0.577349;-0.577349;,-0.577349;-0.577349;0.577349;,0.577349;-0.577349;0.577349;,0.577349;-0.577349;-0.577349;,-0.577349;-0.577349;-0.577349;,0.577349;0.577349;0.577349;,-0.577349;0.577349;0.577349;,-0.577349;0.577349;-0.577349;,0.577349;0.577349;-0.577349;,0;-0.707083;0.707083;,0;0.707083;0.707083;,0.599902;0.565722;0.565722;,0.599902;-0.565722;0.565722;,0.599902;-0.565722;0.565722;,0.599902;0.565722;0.565722;,0.599902;0.565722;-0.565722;,0.599902;-0.565722;-0.565722;,0;-0.707083;0.707083;,0.599902;-0.565722;0.565722;,0.599902;-0.565722;-0.565722;,0;-0.707083;-0.707083;,0.599902;0.565722;0.565722;,0;0.707083;0.707083;,0;0.707083;-0.707083;,0.599902;0.565722;-0.565722;,0.599902;-0.565722;-0.565722;,0.599902;0.565722;-0.565722;,0;0.707083;-0.707083;,0;-0.707083;-0.707083;,0;-0.707083;0.707083;,-0.577349;-0.577349;0.577349;,-0.577349;0.577349;0.577349;,0;0.707083;0.707083;,-0.577349;-0.577349;0.577349;,-0.577349;-0.577349;-0.577349;,-0.577349;0.577349;-0.577349;,-0.577349;0.577349;0.577349;,0;-0.707083;0.707083;,0;-0.707083;-0.707083;,-0.577349;-0.577349;-0.577349;,-0.577349;-0.577349;0.577349;,0.577349;-0.577349;-0.577349;,0.577349;-0.577349;0.577349;,0.577349;0.577349;0.577349;,0.577349;0.577349;-0.577349;,0.577349;-0.577349;0.577349;,-0.577349;-0.577349;0.577349;,-0.577349;0.577349;0.577349;,0.577349;0.577349;0.577349;,-0.577349;-0.577349;0.577349;,-0.577349;-0.577349;-0.577349;,-0.577349;0.577349;-0.577349;,-0.577349;0.577349;0.577349;,-0.577349;-0.577349;-0.577349;,0.577349;-0.577349;-0.577349;,0.577349;0.577349;-0.577349;,-0.577349;0.577349;-0.577349;,0.577349;-0.577349;0.577349;,0.577349;-0.577349;-0.577349;,-0.577349;-0.577349;-0.577349;,-0.577349;-0.577349;0.577349;,-0.577349;0.577349;0.577349;,-0.577349;0.577349;-0.577349;,0.577349;0.577349;-0.577349;,0.577349;0.577349;0.577349;,-0.577349;0.577349;0.577349;,-0.577349;0.577349;-0.577349;,0;0.707083;-0.707083;,0;0.707083;0.707083;,-0.577349;-0.577349;-0.577349;,0;-0.707083;-0.707083;,0;0.707083;-0.707083;,-0.577349;0.577349;-0.577349;,0.286019;-0.764733;-0.577349;,0.286019;-0.764733;0.577349;,0.764733;0.286019;0.577349;,0.764733;0.286019;-0.577349;,0.286019;-0.764733;0.577349;,-0.764733;-0.286019;0.577349;,-0.286019;0.764733;0.577349;,0.764733;0.286019;0.577349;,-0.764733;-0.286019;0.577349;,-0.764733;-0.286019;-0.577349;,-0.286019;0.764733;-0.577349;,-0.286019;0.764733;0.577349;,-0.764733;-0.286019;-0.577349;,0.286019;-0.764733;-0.577349;,0.764733;0.286019;-0.577349;,-0.286019;0.764733;-0.577349;,0.286019;-0.764733;0.577349;,0.286019;-0.764733;-0.577349;,-0.764733;-0.286019;-0.577349;,-0.764733;-0.286019;0.577349;,-0.286019;0.764733;0.577349;,-0.286019;0.764733;-0.577349;,0.764733;0.286019;-0.577349;,0.764733;0.286019;0.577349;,0.286019;-0.764733;-0.577349;,0.286019;-0.764733;0.577349;,0.764733;0.286019;0.577349;,0.764733;0.286019;-0.577349;,0.286019;-0.764733;0.577349;,-0.764733;-0.286019;0.577349;,-0.286019;0.764733;0.577349;,0.764733;0.286019;0.577349;,-0.764733;-0.286019;0.577349;,-0.764733;-0.286019;-0.577349;,-0.286019;0.764733;-0.577349;,-0.286019;0.764733;0.577349;,-0.764733;-0.286019;-0.577349;,0.286019;-0.764733;-0.577349;,0.764733;0.286019;-0.577349;,-0.286019;0.764733;-0.577349;,0.286019;-0.764733;0.577349;,0.286019;-0.764733;-0.577349;,-0.764733;-0.286019;-0.577349;,-0.764733;-0.286019;0.577349;,-0.286019;0.764733;0.577349;,-0.286019;0.764733;-0.577349;,0.764733;0.286019;-0.577349;,0.764733;0.286019;0.577349;,0.577349;-0.577349;-0.577349;,0.577349;-0.577349;0.577349;,0.577349;0.577349;0.577349;,0.577349;0.577349;-0.577349;,0.577349;-0.577349;0.577349;,-0.577349;-0.577349;0.577349;,-0.577349;0.577349;0.577349;,0.577349;0.577349;0.577349;,-0.577349;-0.577349;0.577349;,-0.577349;-0.577349;-0.577349;,-0.577349;0.577349;-0.577349;,-0.577349;0.577349;0.577349;,-0.577349;-0.577349;-0.577349;,0.577349;-0.577349;-0.577349;,0.577349;0.577349;-0.577349;,-0.577349;0.577349;-0.577349;,0.577349;-0.577349;0.577349;,0.577349;-0.577349;-0.577349;,-0.577349;-0.577349;-0.577349;,-0.577349;-0.577349;0.577349;,-0.577349;0.577349;0.577349;,-0.577349;0.577349;-0.577349;,0.577349;0.577349;-0.577349;,0.577349;0.577349;0.577349;,0;-0.707083;0.707083;,-0.599902;-0.565722;0.565722;,-0.599872;0.565722;0.565722;,0;0.707083;0.707083;,-0.599902;-0.565722;0.565722;,-0.599902;-0.565722;-0.565722;,-0.599872;0.565722;-0.565722;,-0.599872;0.565722;0.565722;,0;-0.707083;0.707083;,0;-0.707083;-0.707083;,-0.599902;-0.565722;-0.565722;,-0.599902;-0.565722;0.565722;,-0.599872;0.565722;0.565722;,-0.599872;0.565722;-0.565722;,0;0.707083;-0.707083;,0;0.707083;0.707083;,-0.599902;-0.565722;-0.565722;,0;-0.707083;-0.707083;,0;0.707083;-0.707083;,-0.599872;0.565722;-0.565722;;68;4;3,2,1,0;,4;7,6,5,4;,4;11,10,9,8;,4;15,14,13,12;,4;19,18,17,16;,4;23,22,21,20;,4;27,26,25,24;,4;31,30,29,28;,4;35,34,33,32;,4;39,38,37,36;,4;43,42,41,40;,4;47,46,45,44;,4;51,50,49,48;,4;55,54,53,52;,4;59,58,57,56;,4;63,62,61,60;,4;67,66,65,64;,4;71,70,69,68;,4;75,74,73,72;,4;79,78,77,76;,4;83,82,81,80;,4;87,86,85,84;,4;91,90,89,88;,4;95,94,93,92;,4;99,98,97,96;,4;103,102,101,100;,4;107,106,105,104;,4;111,110,109,108;,4;115,114,113,112;,4;119,118,117,116;,4;123,122,121,120;,4;127,126,125,124;,4;131,130,129,128;,4;135,134,133,132;,4;139,138,137,136;,4;143,142,141,140;,4;147,146,145,144;,4;151,150,149,148;,4;155,154,153,152;,4;159,158,157,156;,4;163,162,161,160;,4;167,166,165,164;,4;171,170,169,168;,4;175,174,173,172;,4;179,178,177,176;,4;183,182,181,180;,4;187,186,185,184;,4;191,190,189,188;,4;195,194,193,192;,4;199,198,197,196;,4;203,202,201,200;,4;207,206,205,204;,4;211,210,209,208;,4;215,214,213,212;,4;219,218,217,216;,4;223,222,221,220;,4;227,226,225,224;,4;231,230,229,228;,4;235,234,233,232;,4;239,238,237,236;,4;243,242,241,240;,4;247,246,245,244;,4;251,250,249,248;,4;255,254,253,252;,4;259,258,257,256;,4;263,262,261,260;,4;267,266,265,264;,4;271,270,269,268;;}MeshTextureCoords{272;0.849264;0.899246;,0.849264;0.931916;,0.861547;0.931916;,0.861547;0.899246;,0.916988;0.931916;,0.916988;0.899246;,0.9054;0.899246;,0.9054;0.931916;,0.84857;0.844707;,0.84857;0.83254;,0.836981;0.83254;,0.836981;0.844707;,0.927004;0.903587;,0.927004;0.931916;,0.937019;0.931916;,0.937019;0.903587;,0.937019;0.903587;,0.937019;0.931916;,0.946887;0.931916;,0.946887;0.903587;,0.888533;0.856954;,0.888533;0.828625;,0.878517;0.828625;,0.878517;0.856954;,0.939292;0.870917;,0.939292;0.899246;,0.949159;0.899246;,0.949159;0.870917;,0.946887;0.91117;,0.956719;0.91117;,0.956719;0.901213;,0.946887;0.901213;,0.865118;0.813135;,0.855286;0.813135;,0.855286;0.823092;,0.865118;0.823092;,0.866874;0.847426;,0.866874;0.835259;,0.855286;0.835259;,0.855286;0.847426;,0.598002;0.973516;,0.598002;0.206739;,0.309722;0.206739;,0.309722;0.973516;,0.909393;0.822135;,0.909393;0.841014;,0.915938;0.841014;,0.915938;0.822135;,0.951962;0.931916;,0.951962;0.91117;,0.946887;0.91117;,0.946887;0.931916;,0.948762;0.841801;,0.948762;0.822921;,0.942217;0.822921;,0.942217;0.841801;,0.893608;0.838075;,0.893608;0.817329;,0.888533;0.817329;,0.888533;0.838075;,0.900724;0.909292;,0.90515;0.909292;,0.90515;0.902786;,0.900724;0.902786;,0.953585;0.871994;,0.949159;0.871994;,0.949159;0.8785;,0.953585;0.8785;,0.84857;0.837995;,0.84857;0.856874;,0.855114;0.856874;,0.855114;0.837995;,0.902881;0.83746;,0.902881;0.816714;,0.897805;0.816714;,0.897805;0.83746;,0.942217;0.841801;,0.942217;0.822921;,0.935673;0.822921;,0.935673;0.841801;,0.949159;0.8785;,0.949159;0.899246;,0.954235;0.899246;,0.954235;0.8785;,0.919226;0.822135;,0.923651;0.822135;,0.923651;0.815629;,0.919226;0.815629;,0.928077;0.815629;,0.923651;0.815629;,0.923651;0.822135;,0.928077;0.822135;,0.865301;0.847426;,0.865301;0.876542;,0.875317;0.876542;,0.875317;0.847426;,0.909393;0.841014;,0.909393;0.87013;,0.919261;0.87013;,0.919261;0.841014;,0.855286;0.847426;,0.855286;0.876542;,0.865301;0.876542;,0.865301;0.847426;,0.919261;0.841014;,0.919261;0.87013;,0.929128;0.87013;,0.929128;0.841014;,0.878517;0.828625;,0.888349;0.828625;,0.88835;0.818668;,0.878517;0.818668;,0.836981;0.83254;,0.846814;0.83254;,0.846814;0.822583;,0.836981;0.822583;,0.857749;0.887894;,0.836981;0.887894;,0.837473;0.899246;,0.857257;0.899246;,0.855286;0.876542;,0.855286;0.856874;,0.836981;0.856874;,0.836981;0.876542;,0.897805;0.887893;,0.897313;0.876622;,0.879009;0.876622;,0.878517;0.887893;,0.886604;0.909292;,0.886112;0.920645;,0.9054;0.920645;,0.904908;0.909292;,0.977665;0.442421;,0.977665;0.131438;,0.799225;0.123708;,0.799225;0.450151;,0.849264;0.899246;,0.836981;0.899246;,0.836981;0.931916;,0.849264;0.931916;,0.909393;0.866576;,0.897805;0.866576;,0.897805;0.899246;,0.909393;0.899246;,0.84857;0.844707;,0.836981;0.844707;,0.836981;0.856874;,0.84857;0.856874;,0.929276;0.899246;,0.939292;0.899246;,0.939292;0.870917;,0.929276;0.870917;,0.876741;0.819096;,0.866874;0.819096;,0.866874;0.847426;,0.876741;0.847426;,0.939144;0.841801;,0.929128;0.841801;,0.929128;0.87013;,0.939144;0.87013;,0.949011;0.841801;,0.939144;0.841801;,0.939144;0.87013;,0.949011;0.87013;,0.836981;0.812626;,0.836981;0.822583;,0.846814;0.822583;,0.846814;0.812626;,0.909393;0.812178;,0.909393;0.822135;,0.919226;0.822135;,0.919226;0.812178;,0.866874;0.823092;,0.855286;0.823092;,0.855286;0.835259;,0.866874;0.835259;,0.021442;0.973516;,0.309722;0.973516;,0.309722;0.206739;,0.021442;0.206739;,0.916039;0.841014;,0.922583;0.841014;,0.922583;0.822135;,0.916039;0.822135;,0.907956;0.816714;,0.902881;0.816714;,0.902881;0.83746;,0.907956;0.83746;,0.929128;0.822135;,0.922583;0.822135;,0.922583;0.841014;,0.929128;0.841014;,0.853645;0.817249;,0.84857;0.817249;,0.84857;0.837995;,0.853645;0.837995;,0.900724;0.909292;,0.900724;0.902786;,0.895944;0.902786;,0.895944;0.909292;,0.93896;0.816415;,0.93896;0.822921;,0.94374;0.822921;,0.94374;0.816415;,0.935673;0.822921;,0.929128;0.822921;,0.929128;0.841801;,0.935673;0.841801;,0.954087;0.849384;,0.949011;0.849384;,0.949011;0.87013;,0.954087;0.87013;,0.895077;0.838075;,0.888533;0.838075;,0.888533;0.856954;,0.895077;0.856954;,0.948762;0.841801;,0.953838;0.841801;,0.953838;0.821055;,0.948762;0.821055;,0.94374;0.816415;,0.94374;0.822921;,0.94852;0.822921;,0.94852;0.816415;,0.949011;0.842878;,0.949011;0.849384;,0.953791;0.849384;,0.953791;0.842878;,0.919409;0.87013;,0.909393;0.87013;,0.909393;0.899246;,0.919409;0.899246;,0.897805;0.866576;,0.907672;0.866576;,0.907672;0.83746;,0.897805;0.83746;,0.927004;0.9028;,0.916988;0.9028;,0.916988;0.931916;,0.927004;0.931916;,0.929276;0.87013;,0.919409;0.87013;,0.919409;0.899246;,0.929276;0.899246;,0.93896;0.822921;,0.93896;0.812965;,0.929128;0.812965;,0.929128;0.822921;,0.886112;0.899336;,0.886112;0.909292;,0.895944;0.909292;,0.895944;0.899336;,0.857749;0.887894;,0.857257;0.876542;,0.837473;0.876542;,0.836981;0.887894;,0.896821;0.856954;,0.878517;0.856954;,0.878517;0.876622;,0.896821;0.876622;,0.897805;0.887893;,0.878517;0.887893;,0.879009;0.899246;,0.897313;0.899246;,0.886604;0.931916;,0.904908;0.931916;,0.9054;0.920645;,0.886112;0.920645;,0.620785;0.44242;,0.799225;0.450151;,0.799225;0.123708;,0.620785;0.131438;;}XSkinMeshHeader{3;9;10;}SkinWeights{"Armature_arm_l";24;44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,67,66;1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1;-0.047733,0.901521,0.430095,0,-0.097683,0.424309,-0.900233,0,-0.994073,-0.084983,0.06781,0,0.374873,-2.006904,2.980378,1;;}SkinWeights{"Armature_elbow_r";24;216,219,218,213,212,215,214,209,224,208,227,211,226,210,206,221,207,220,204,223,205,222,225,217;1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1;0.102316,0.92166,-0.374266,0,-0.090709,-0.366028,-0.926173,0,-0.990608,0.128712,0.046152,0,0.402018,1.853661,2.350172,1;;}SkinWeights{"Armature_arm_r";24;186,187,184,185,182,183,180,194,195,203,202,192,193,201,200,199,190,198,191,197,188,196,189,181;1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1;-0.047733,0.901521,-0.430095,0,-0.05233,-0.432251,-0.900234,0,-0.997489,-0.020464,0.067809,0,0.160852,2.035269,2.980378,1;;}SkinWeights{"Armature_knee_l";24;105,99,114,106,98,115,107,101,93,108,100,92,109,103,95,110,102,94,111,97,112,104,113,96;1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1;1,0,0,0,0,0.054357,-0.998522,0,0,0.998501,0.054355,0,-0.246294,-0.008592,1.301673,1;;}SkinWeights{"Armature_Bone_007";40;132,133,134,135,124,125,126,252,253,254,255,121,122,264,265,123,267,268,269,270,116,256,258,259,260,261,262,263,271,266,120,119,117,128,129,127,130,118,131,257;1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1;1,0,0,0,0,0,1,0,0,-1,0,0,0,0,-3.793003,1;;}SkinWeights{"Armature_elbow_l";24;88,80,72,91,83,75,90,82,74,70,85,77,71,84,76,68,87,79,69,86,78,89,81,73;1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1;0.102316,0.92166,0.374266,0,-0.008222,0.377011,-0.926173,0,-0.994719,0.091686,0.046152,0,-0.014321,-1.896701,2.350171,1;;}SkinWeights{"Armature_knee_r";24;249,235,250,234,251,229,244,228,245,231,246,230,247,240,241,242,243,237,236,239,238,233,248,232;1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1;1,0,0,0,0,0.054357,-0.998522,0,0,0.998501,0.054355,0,0.246294,-0.008592,1.301673,1;;}SkinWeights{"Armature_leg_l";38;0,3,4,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,40,43,136,145,177,144;0.055873,0.852304,0.852304,0.82998,0.055873,0.852304,0.82998,0.054606,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0.82998,0.054606,0.055873,0.054606,0.054606,0.055873;1,0,0,0,0,-0.056452,-0.998405,0,0,0.998385,-0.056452,0,-0.246294,0.135476,2.396023,1;;}SkinWeights{"Armature_leg_r";38;0,170,169,11,168,151,150,149,148,147,146,176,145,177,144,159,158,157,156,155,154,153,167,136,166,137,165,164,163,140,162,141,161,43,160,152,8,171;0.055873,1,1,0.054606,1,1,1,1,1,0.852304,0.82998,0.82998,0.054606,0.054606,0.055873,1,1,1,1,1,1,1,1,0.055873,1,0.852304,1,1,1,0.852304,1,0.82998,1,0.054606,1,1,0.055873,1;1,0,0,0,0,-0.056452,-0.998405,0,0,0.998385,-0.056452,0,0.246294,0.135476,2.396023,1;;}SkinWeights{"Armature_body";40;0,1,2,3,4,5,6,7,8,9,10,11,36,37,38,39,40,41,42,43,136,137,138,139,140,147,141,146,142,145,143,144,179,174,178,173,177,172,176,175;0.888255,1,1,0.147696,0.147696,1,1,0.17002,0.888255,0.147696,0.17002,0.890788,1,1,1,1,0.17002,1,1,0.890788,0.888255,0.147696,1,1,0.147696,0.147696,0.17002,0.17002,1,0.890788,1,0.888255,1,1,1,1,0.890788,1,0.17002,1;1,0,0,0,0,0,1,0,0,-1,0,0,0,0,-2.571201,1;;}}}}} \ No newline at end of file diff --git a/irr/media/cooltexture.png b/irr/media/cooltexture.png new file mode 100755 index 000000000..fcc219ac7 Binary files /dev/null and b/irr/media/cooltexture.png differ diff --git a/irr/scripts/BindingGenerator.lua b/irr/scripts/BindingGenerator.lua new file mode 100755 index 000000000..0f9ffa764 --- /dev/null +++ b/irr/scripts/BindingGenerator.lua @@ -0,0 +1,453 @@ +#!/usr/bin/lua +-- BindingGenerator.lua (c) hecks 2021 +-- This script is a part of IrrlichtMT, released under the same license. + +-- By default we assume you're running this from /scripts/ +-- and that you have the necessary headers there (gitignored for your convenience) +local sourceTreePath = os.getenv( "IRRMTREPO" ) or ".."; +-- Otherwise run this from wherever you want and set the above env variable. +local glHeaderPath = os.getenv( "GLHEADERPATH" ) or "."; +-- GL headers will be looked for in the current directory or GLHEADERPATH. +-- At the moment we require: +-- "glcorearb.h" +-- "gl2ext.h" +-- Files other than glcorearb.h are only parsed for vendor specific defines +-- and aliases. Otherwise we only use what exists in glcorearb.h, further +-- restricted to procedures that are either core or ARB. + + +-- Emulate a portion of the libraries that this was written against. +getmetatable( "" ).__index = string; +getmetatable( "" ).__len = string.len; +getmetatable( "" ).__call = string.format; +function string:Split( pat ) + local r = {}; + local pos = 1; + local from, to; + while pos and pos <= #self do + from, to = self:find( pat, pos ); + if not from then + break; + end + r[#r+1] = self:sub( pos, from - 1 ); + pos = to + 1; + end + r[#r+1] = self:sub( pos, #self ); + return r; +end +function string:TrimBothEnds() + return self:gsub("^%s+",""):gsub("%s+$",""); +end +local List; +List = function( t ) + return setmetatable( t or {}, { + __index = { + Add = function( t, v ) + t[#t+1] = v; + end; + AddFormat = function( t, str, ... ) + t:Add( str( ... ) ); + end; + Where = function( t, f ) + local r = {}; + for i=1, #t do + if f(t[i]) then r[#r+1] = t[i]; end + end + return List( r ); + end; + Select = function( t, f ) + local r = {}; + for i=1, #t do + r[#r+1] = f( t[i] ); + end + return List( r ); + end; + Join = function( t, n ) + local r = {}; + for i=1, #t do + r[i] = t[i]; + end + for i=1, #n do + r[#r+1] = n[i]; + end + return List( r ); + end; + Concat = table.concat; + }; + } ); +end + + +------------ Header parsing ------------ + +-- GL and GLES alike +local driverVendors = { + "NV", "AMD", "INTEL", "OVR", "QCOM", "IMG", "ANGLE", "APPLE", "MESA" +} +local vendorSuffixes = { + "ARB", "EXT", "KHR", "OES", + unpack( driverVendors ) +}; +local vendorSuffixPattern = {}; +local constSuffixPattern = {}; +for i=1, #vendorSuffixes do + vendorSuffixPattern[i] = vendorSuffixes[i] .. "$"; + constSuffixPattern[i] = ("_%s$")( vendorSuffixes[i] ); +end +local constBanned = {}; +for i=1, #driverVendors do + constBanned[driverVendors[i]] = true; +end +-- Strip the uppercase extension vendor suffix from a name. +local function StripVendorSuffix( str, const ) + local patterns = const and constSuffixPattern or vendorSuffixPattern; + local n; + for i=1, #patterns do + str, n = str:gsub( patterns[i], "" ); + if n > 0 then + return str, vendorSuffixes[i]; + end + end + return str; +end + +-- Normalize the type of an argument or return, also stripping any suffix +-- and normalizing all whitespace regions to single spaces. +local function NormalizeType( str ) + local chunks = str:Split( "%s+" ); + for j=1, #chunks do + chunks[j] = StripVendorSuffix( chunks[j] ); + end + local T = table.concat(chunks, " " ); + return T:TrimBothEnds(); +end + +-- Normalize an argument, returning the normalized type and the name separately, +-- always sticking the * of a pointer to the type rather than the name. +-- We need this to generate a normalized arg list and function signature (below) +local function NormalizeArgument( str ) + local chunks = str:Split( "%s+" ); + for j=1, #chunks do + chunks[j] = StripVendorSuffix( chunks[j] ); + end + local last = chunks[#chunks]; + local name = last:match( "[%w_]+$" ); + chunks[#chunks] = #name ~= #last and last:sub( 1, #last-#name) or nil; + local T = table.concat(chunks, " " ):TrimBothEnds(); + return T, name +end + +-- Normalize an argument list so that two matching prototypes +-- will produce the same table if fed to this function. +local function NormalizeArgList( str ) + local args = str:Split( ",%s*" ); + local r = {}; + for i=1, #args do + local T, name = NormalizeArgument( args[i] ); + r[i] = { T, name }; + end + return r; +end + +-- Normalize a function signature into a unique string for keying +-- in such a way that if two different GL procedures may be assigned +-- to the same function pointer, this will produce an identical string for both. +-- This makes it possible to detect function aliases that may work as a fallback. +-- You still have to check for the appropriate extension. +local function NormalizeFunctionSignature( T, str ) + local args = str:Split( ",%s*" ); + local r = {}; + for i=1, #args do + r[i] = NormalizeArgument( args[i] ); + end + return ("%s(%s)")( T, table.concat( r, ", " ) ); +end + +-- Mangle the PFN name so that we don't collide with a +-- typedef from any of the GL headers. +local pfnFormat = "PFNGL%sPROC_MT"; + +--( T, name, args ) +local typedefFormat = "\ttypedef %s (APIENTRYP %s) (%s);" +-- Generate a PFN...GL style typedef for a procedure +-- +local function GetProcedureTypedef( proc ) + local args = {}; + for i=1, #proc.args do + args[i] = ("%s %s")( unpack( proc.args[i] ) ) + end + return typedefFormat( proc.retType, pfnFormat( proc.name:upper() ), table.concat( args, ", " ) ); +end + +local procedures = List(); +local nameset = {}; +local definitions = List(); +local consts = List(); + +--[[ + Structured procedure representation: + + ProcSpec = { + string name; -- Normalized name as it appears in the GL spec + string? vendor; -- Uppercase vendor string (ARB, EXT, AMD, NV etc) + string signature; + string retType; + args = { { type, name } }; + }; +]] +-- Parse a whole header, extracting the data. +local function ParseHeader( path, into, apiRegex, defs, consts, nameSet, noNewNames ) + defs:AddFormat( "\t// %s", path ); + local f = assert( io.open( path, "r" ), "Could not open " .. path ); + for line in f:lines() do + -- Do not parse PFN typedefs; they're easily reconstructible. + local T, rawName, args = line:match( apiRegex ); + if T then + T = NormalizeType( T ); + -- Strip the 'gl' namespace prefix. + local procName = rawName:sub(3,-1); + local name, vendor = StripVendorSuffix( procName ); + if not (noNewNames and nameSet[name]) then + nameSet[name] = true; + into:Add{ + name = name; + vendor = vendor; + -- pfnType = pfnFormat( procName:upper() ); + signature = NormalizeFunctionSignature( T, args ); + retType = T; + args = NormalizeArgList( args ); + }; + end + elseif ( line:find( "#" ) and not line:find( "#include" ) ) then + local rawName, value = line:match( "#define%s+GL_([_%w]+)%s+0x(%w+)" ); + if rawName and value then + local name, vendor = StripVendorSuffix( rawName, true ); + if not constBanned[vendor] then + consts:Add{ name = name, vendor = vendor, value = "0x"..value }; + end + end + ::skip:: + elseif( line:find( "typedef" ) and not line:find( "%(" ) ) then + -- Passthrough non-PFN typedefs + defs:Add( "\t" .. line ); + end + end + defs:Add ""; + f:close(); +end + +------------ Parse the headers ------------ + +-- ES/gl2.h is a subset of glcorearb.h and does not need parsing. + +local funcRegex = "GLAPI%s+(.+)APIENTRY%s+(%w+)%s*%((.*)%)"; +local funcRegexES = "GL_APICALL%s+(.+)GL_APIENTRY%s+(%w+)%s*%((.*)%)"; +ParseHeader( glHeaderPath .. "/glcorearb.h", procedures, funcRegex, definitions, consts, nameset ); +ParseHeader( glHeaderPath .. "/gl2ext.h", procedures, funcRegexES, List(), consts, nameset, true ); +-- Typedefs are redirected to a dummy list here on purpose. +-- The only unique typedef from gl2ext is this: +definitions:Add "\ttypedef void *GLeglClientBufferEXT;"; + +------------ Sort out constants ------------ + +local cppConsts = List(); +do + local constBuckets = {}; + for i=1, #consts do + local vendor = consts[i].vendor or "core"; + constBuckets[consts[i].name] = constBuckets[consts[i].name] or {}; + constBuckets[consts[i].name][vendor] = consts[i].value; + end + local names = {}; + for i=1, #consts do + local k = consts[i].name; + local b = constBuckets[k]; + if k == "WAIT_FAILED" or k == "DIFFERENCE" then + -- This is why using #define as const is evil. + k = "_" .. k; + end + if b and not names[k] then + names[k] = true; + -- I have empirically tested that constants in GL with the same name do not differ, + -- at least for these suffixes. + local v = b.core or b.KHR or b.ARB or b.OES or b.EXT; + if v then + local T = v:find( "ull" ) and "GLuint64" or "GLenum"; + cppConsts:AddFormat( "\tstatic constexpr const %s %s = %s;", T, k, v ); + end + end + end +end + + +------------ Sort out procedures ------------ + +local procTable = {}; + +local coreProcedures = procedures:Where( function(x) return not x.vendor; end ); +local arbProcedures = procedures:Where( function(x) return x.vendor == "ARB"; end ); + +-- Only consider core and ARB functions. +local nameList = coreProcedures:Join( arbProcedures ):Select( + function(p) + return p.name; + end ); + +local nameSet = {}; +local uniqueNames = List(); + +for s, k in ipairs( nameList ) do + if not nameSet[k] then + nameSet[k] = true; + uniqueNames:Add( k ); + end +end + +for i=1, #procedures do + local p = procedures[i]; + procTable[p.name] = procTable[p.name] or {}; + local key = p.vendor or "core"; + procTable[p.name][key] = p; +end + +local priorityList = List{ "core", "ARB", "OES", "KHR" }; + +local typedefs = List(); +local pointers = List(); +local loader = List(); + +for s, str in ipairs( uniqueNames ) do + pointers:Add( ("\t%s %s = NULL;")( pfnFormat( str:upper() ), str ) ); + local typeDefGenerated = false; + for i=1, #priorityList do + local k = priorityList[i]; + local proc = procTable[str][k] + if proc then + if not typeDefGenerated then + typedefs:Add( GetProcedureTypedef( proc ) ); + typeDefGenerated = true; + end + local vendor = k == "core" and "" or k; + loader:AddFormat( + '\tif (!%s) %s = (%s)cmgr->getProcAddress("%s");\n', + str, str, pfnFormat( proc.name:upper() ), ("gl%s%s")(str,vendor) + ); + end + end +end + + +------------ Write files ------------ + +-- Write loader header +local f = io.open( sourceTreePath .. "/include/mt_opengl.h", "wb" ); +f:write[[ +// This code was generated by scripts/BindingGenerator.lua +// Do not modify it, modify and run the generator instead. + +#pragma once + +#include +#include +#include "IrrCompileConfig.h" // for IRRLICHT_API +#include "irrTypes.h" +#include "IContextManager.h" +#include + +#ifndef APIENTRY + #define APIENTRY KHRONOS_APIENTRY +#endif +#ifndef APIENTRYP + #define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI + #define GLAPI extern +#endif + +]]; + +f:write[[ +class OpenGLProcedures { +private: +]]; +f:write( definitions:Concat( "\n" ) ); +f:write( "\n" ); +f:write[[ + // The script will miss this particular typedef thinking it's a PFN, + // so we have to paste it in manually. It's the only such type in OpenGL. + typedef void (APIENTRY *GLDEBUGPROC) + (GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); + +]] +f:write( typedefs:Concat( "\n" ) ); +f:write( "\n\n" ); +f:write [[ + std::unordered_set extensions; +public: + // Call this once after creating the context. + void LoadAllProcedures(irr::video::IContextManager *cmgr); + // Check if an extension is supported. + inline bool IsExtensionPresent(const std::string &ext) const + { + return extensions.count(ext) > 0; + } + +]]; +f:write( pointers:Concat( "\n" ) ); +f:write( "\n\n" ); +f:write( cppConsts:Concat( "\n" ) ); +f:write( "\n\n" ); +f:write[[ + static constexpr const GLenum ZERO = 0; + static constexpr const GLenum ONE = 1; + static constexpr const GLenum NONE = 0; +]]; +f:write( "};\n" ); +f:write( "\n// Global GL procedures object.\n" ); +f:write( "IRRLICHT_API extern OpenGLProcedures GL;\n" ); +f:close(); + +-- Write loader implementation +f = io.open( sourceTreePath .. "/src/mt_opengl_loader.cpp", "wb" ); +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 +#include + +OpenGLProcedures GL = OpenGLProcedures(); + +void OpenGLProcedures::LoadAllProcedures(irr::video::IContextManager *cmgr) +{ + +]]; +f:write( loader:Concat() ); +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 + std::stringstream ext_ss((char*)ext_str); + std::string tmp; + while (std::getline(ext_ss, tmp, ' ')) + extensions.emplace(tmp); + +} +]]; +f:close(); diff --git a/irr/scripts/ci-build-android.sh b/irr/scripts/ci-build-android.sh new file mode 100755 index 000000000..a865e56a4 --- /dev/null +++ b/irr/scripts/ci-build-android.sh @@ -0,0 +1,123 @@ +#!/bin/bash -e + +# NOTE: this code is mostly copied from minetest_android_deps +# + +png_ver=1.6.40 +jpeg_ver=3.0.1 + +download () { + get_tar_archive libpng "https://download.sourceforge.net/libpng/libpng-${png_ver}.tar.gz" + get_tar_archive libjpeg "https://download.sourceforge.net/libjpeg-turbo/libjpeg-turbo-${jpeg_ver}.tar.gz" +} + +build () { + # Build libjpg and libpng first because Irrlicht needs them + mkdir -p libpng + pushd libpng + $srcdir/libpng/configure --host=$CROSS_PREFIX + make && make DESTDIR=$PWD install + popd + + mkdir -p libjpeg + pushd libjpeg + cmake $srcdir/libjpeg "${CMAKE_FLAGS[@]}" -DENABLE_SHARED=OFF + make && make DESTDIR=$PWD install + popd + + local libpng=$PWD/libpng/usr/local/lib/libpng.a + local libjpeg=$(echo $PWD/libjpeg/opt/libjpeg-turbo/lib*/libjpeg.a) + cmake $srcdir/irrlicht "${CMAKE_FLAGS[@]}" \ + -DBUILD_SHARED_LIBS=OFF \ + -DPNG_LIBRARY=$libpng \ + -DPNG_PNG_INCLUDE_DIR=$(dirname "$libpng")/../include \ + -DJPEG_LIBRARY=$libjpeg \ + -DJPEG_INCLUDE_DIR=$(dirname "$libjpeg")/../include + make + + cp -p lib/Android/libIrrlichtMt.a $libpng $libjpeg $pkgdir/ + cp -a $srcdir/irrlicht/include $pkgdir/include + cp -a $srcdir/irrlicht/media/Shaders $pkgdir/Shaders +} + +get_tar_archive () { + # $1: folder to extract to, $2: URL + local filename="${2##*/}" + [ -d "$1" ] && return 0 + wget -c "$2" -O "$filename" + mkdir -p "$1" + tar -xaf "$filename" -C "$1" --strip-components=1 + rm "$filename" +} + +_setup_toolchain () { + local toolchain=$(echo "$ANDROID_NDK"/toolchains/llvm/prebuilt/*) + if [ ! -d "$toolchain" ]; then + echo "Android NDK path not specified or incorrect"; return 1 + fi + export PATH="$toolchain/bin:$ANDROID_NDK:$PATH" + + unset CFLAGS CPPFLAGS CXXFLAGS + + TARGET_ABI="$1" + API=21 + if [ "$TARGET_ABI" == armeabi-v7a ]; then + CROSS_PREFIX=armv7a-linux-androideabi + CFLAGS="-mthumb" + CXXFLAGS="-mthumb" + elif [ "$TARGET_ABI" == arm64-v8a ]; then + CROSS_PREFIX=aarch64-linux-android + elif [ "$TARGET_ABI" == x86 ]; then + CROSS_PREFIX=i686-linux-android + CFLAGS="-mssse3 -mfpmath=sse" + CXXFLAGS="-mssse3 -mfpmath=sse" + elif [ "$TARGET_ABI" == x86_64 ]; then + CROSS_PREFIX=x86_64-linux-android + else + echo "Invalid ABI given"; return 1 + fi + export CC=$CROSS_PREFIX$API-clang + export CXX=$CROSS_PREFIX$API-clang++ + export AR=llvm-ar + export RANLIB=llvm-ranlib + export CFLAGS="-fPIC ${CFLAGS}" + export CXXFLAGS="-fPIC ${CXXFLAGS}" + + CMAKE_FLAGS=( + "-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake" + "-DANDROID_ABI=$TARGET_ABI" "-DANDROID_NATIVE_API_LEVEL=$API" + "-DCMAKE_BUILD_TYPE=Release" + ) + + # make sure pkg-config doesn't interfere + export PKG_CONFIG=/bin/false + + export MAKEFLAGS="-j$(nproc)" +} + +_run_build () { + local abi=$1 + irrdir=$PWD + + mkdir -p $RUNNER_TEMP/src + cd $RUNNER_TEMP/src + srcdir=$PWD + [ -d irrlicht ] || ln -s $irrdir irrlicht + download + + builddir=$RUNNER_TEMP/build/irrlicht-$abi + pkgdir=$RUNNER_TEMP/pkg/$abi/Irrlicht + rm -rf "$pkgdir" + mkdir -p "$builddir" "$pkgdir" + + cd "$builddir" + build +} + +if [ $# -lt 1 ]; then + echo "Usage: ci-build-android.sh " + exit 1 +fi + +_setup_toolchain $1 +_run_build $1 diff --git a/irr/scripts/ci-build-mingw.sh b/irr/scripts/ci-build-mingw.sh new file mode 100755 index 000000000..b1fdd7b99 --- /dev/null +++ b/irr/scripts/ci-build-mingw.sh @@ -0,0 +1,70 @@ +#!/bin/bash -e +topdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +[[ -z "$CC" || -z "$CXX" ]] && exit 255 +variant=win32 +[[ "$(basename "$CXX")" == "x86_64-"* ]] && variant=win64 +with_sdl=0 +[[ "$extras" == *"-sdl"* ]] && with_sdl=1 +#with_gl3=0 +#[[ "$extras" == *"-gl3"* ]] && with_gl3=1 + +libjpeg_version=3.0.1 +libpng_version=1.6.40 +sdl2_version=2.28.5 +zlib_version=1.3.1 + +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" +} + +libs=$PWD/libs +mkdir -p libs +pushd libs +libhost="http://minetest.kitsunemimi.pw" +download "$libhost/llvm/libjpeg-$libjpeg_version-$variant.zip" +download "$libhost/llvm/libpng-$libpng_version-$variant.zip" +[ $with_sdl -eq 1 ] && download "$libhost/llvm/sdl2-$sdl2_version-$variant.zip" +download "$libhost/llvm/zlib-$zlib_version-$variant.zip" +popd + +tmp=( + -DCMAKE_SYSTEM_NAME=Windows \ + -DPNG_LIBRARY=$libs/libpng/lib/libpng.dll.a \ + -DPNG_PNG_INCLUDE_DIR=$libs/libpng/include \ + -DJPEG_LIBRARY=$libs/libjpeg/lib/libjpeg.dll.a \ + -DJPEG_INCLUDE_DIR=$libs/libjpeg/include \ + -DZLIB_LIBRARY=$libs/zlib/lib/libz.dll.a \ + -DZLIB_INCLUDE_DIR=$libs/zlib/include +) +if [ $with_sdl -eq 1 ]; then + tmp+=( + -DUSE_SDL2=ON + -DCMAKE_PREFIX_PATH=$libs/sdl2/lib/cmake + ) +else + tmp+=(-DUSE_SDL2=OFF) +fi +#[ $with_gl3 -eq 1 ] && tmp+=(-DENABLE_OPENGL=OFF -DENABLE_OPENGL3=ON) + +cmake . "${tmp[@]}" +make -j$(nproc) + +if [ "$1" = "package" ]; then + make DESTDIR=$PWD/_install install + # strip library + "${CXX%-*}-strip" --strip-unneeded _install/usr/local/lib/*.dll + # bundle the DLLs that are specific to Irrlicht (kind of a hack) + shopt -s nullglob + cp -p $libs/*/bin/{libjpeg,libpng,SDL}*.dll _install/usr/local/lib/ + # create a ZIP + (cd _install/usr/local; zip -9r "$OLDPWD/irrlicht-$variant$extras.zip" -- *) +fi +exit 0 diff --git a/irr/scripts/ci-get-mingw.sh b/irr/scripts/ci-get-mingw.sh new file mode 100755 index 000000000..9cf933fea --- /dev/null +++ b/irr/scripts/ci-get-mingw.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e +topdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +name=llvm-mingw-20231128-ucrt-ubuntu-20.04-x86_64.tar.xz +wget "https://github.com/mstorsjo/llvm-mingw/releases/download/20231128/$name" -O "$name" +sha256sum -w -c <(grep -F "$name" "$topdir/sha256sums.txt") +sudo tar -xaf "$name" -C /usr --strip-components=1 +rm -f "$name" diff --git a/irr/scripts/sha256sums.txt b/irr/scripts/sha256sums.txt new file mode 100644 index 000000000..0c080de3b --- /dev/null +++ b/irr/scripts/sha256sums.txt @@ -0,0 +1,9 @@ +0f21ff3be90311092fe32e0e30878ef3ae9d9437b8d9ac25ef279e0d84e9bb8e llvm-mingw-20231128-ucrt-ubuntu-20.04-x86_64.tar.xz +53dfd31285f470fcf0dca88217c5cf9c557729af6d103afae5936e72ddc38d3c libjpeg-3.0.1-win32.zip +3d44e0740914e6878300e30653aad39e974821b5d7f6c2567e246b4eb04a5324 libjpeg-3.0.1-win64.zip +6baf4e819bfb3573760524b5dc9a04b5e479090d6d2046b86cf39a3107c0071f libpng-1.6.40-win32.zip +c02e029f01fce44baea7f4aecfd2564bd8a03507c0c6af8b03339ae0452c8b7d libpng-1.6.40-win64.zip +f9f890af960e92fd3f532f2e9ac00681c33bc67a722e000dfdaeb41b0064f1a0 sdl2-2.28.5-win32.zip +8dde2c6963544b7d8a2e87c128ebbdf51ad0e70c7e2df986ff4e963ce9996d9b sdl2-2.28.5-win64.zip +8af10515d57dbfee5d2106cd66cafa2adeb4270d4c6047ccbf7e8b5d2d50681c zlib-1.3.1-win32.zip +ad43f5d23052590c65633530743e5d622cc76b33c109072e6fd7b487aff56bca zlib-1.3.1-win64.zip diff --git a/irr/src/Android/CAndroidAssetFileArchive.cpp b/irr/src/Android/CAndroidAssetFileArchive.cpp new file mode 100644 index 000000000..59df2d2a1 --- /dev/null +++ b/irr/src/Android/CAndroidAssetFileArchive.cpp @@ -0,0 +1,100 @@ +// Copyright (C) 2002-2011 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CAndroidAssetReader.h" + +#include "CReadFile.h" +#include "coreutil.h" +#include "CAndroidAssetFileArchive.h" +#include "CIrrDeviceAndroid.h" +#include "os.h" // for logging (just keep it in even when not needed right now as it's used all the time) + +#include +#include +#include + +namespace irr +{ +namespace io +{ + +CAndroidAssetFileArchive::CAndroidAssetFileArchive(AAssetManager *assetManager, bool ignoreCase, bool ignorePaths) : + CFileList("/asset", ignoreCase, ignorePaths), AssetManager(assetManager) +{ +} + +CAndroidAssetFileArchive::~CAndroidAssetFileArchive() +{ +} + +//! get the archive type +E_FILE_ARCHIVE_TYPE CAndroidAssetFileArchive::getType() const +{ + return EFAT_ANDROID_ASSET; +} + +const IFileList *CAndroidAssetFileArchive::getFileList() const +{ + // The assert_manager can not read directory names, so + // getFileList returns only files in folders which have been added. + return this; +} + +//! opens a file by file name +IReadFile *CAndroidAssetFileArchive::createAndOpenFile(const io::path &filename) +{ + CAndroidAssetReader *reader = new CAndroidAssetReader(AssetManager, filename); + + if (reader->isOpen()) + return reader; + + reader->drop(); + return NULL; +} + +//! opens a file by index +IReadFile *CAndroidAssetFileArchive::createAndOpenFile(u32 index) +{ + const io::path &filename(getFullFileName(index)); + if (filename.empty()) + return 0; + + return createAndOpenFile(filename); +} + +void CAndroidAssetFileArchive::addDirectoryToFileList(const io::path &dirname_) +{ + io::path dirname(dirname_); + fschar_t lastChar = dirname.lastChar(); + if (lastChar == '/' || lastChar == '\\') + dirname.erase(dirname.size() - 1); + + // os::Printer::log("addDirectoryToFileList:", dirname.c_str(), ELL_DEBUG); + if (findFile(dirname, true) >= 0) + return; // was already added + + AAssetDir *dir = AAssetManager_openDir(AssetManager, core::stringc(dirname).c_str()); + if (!dir) + return; + + // add directory itself + addItem(dirname, 0, 0, /*isDir*/ true, getFileCount()); + + // add all files in folder. + // Note: AAssetDir_getNextFileName does not return directory names (neither does any other NDK function) + while (const char *filename = AAssetDir_getNextFileName(dir)) { + core::stringc full_filename = dirname == "" ? filename + : dirname + "/" + filename; + + // We can't get the size without opening the file - so for performance + // reasons we set the file size to 0. + // TODO: Does this really cost so much performance that it's worth losing this information? Dirs are usually just added once at startup... + addItem(full_filename, /*offet*/ 0, /*size*/ 0, /*isDir*/ false, getFileCount()); + // os::Printer::log("addItem:", full_filename.c_str(), ELL_DEBUG); + } + AAssetDir_close(dir); +} + +} // end namespace io +} // end namespace irr diff --git a/irr/src/Android/CAndroidAssetFileArchive.h b/irr/src/Android/CAndroidAssetFileArchive.h new file mode 100644 index 000000000..3ca815ed5 --- /dev/null +++ b/irr/src/Android/CAndroidAssetFileArchive.h @@ -0,0 +1,58 @@ +// Copyright (C) 2012 Joerg Henrichs +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReadFile.h" +#include "IFileArchive.h" +#include "CFileList.h" + +#include + +namespace irr +{ +namespace io +{ + +/*! + Android asset file system written August 2012 by J.Henrichs (later reworked by others). +*/ +class CAndroidAssetFileArchive : public virtual IFileArchive, + virtual CFileList +{ +public: + //! constructor + CAndroidAssetFileArchive(AAssetManager *assetManager, bool ignoreCase, bool ignorePaths); + + //! destructor + virtual ~CAndroidAssetFileArchive(); + + //! opens a file by file name + virtual IReadFile *createAndOpenFile(const io::path &filename); + + //! opens a file by index + virtual IReadFile *createAndOpenFile(u32 index); + + //! returns the list of files + virtual const IFileList *getFileList() const; + + //! get the archive type + virtual E_FILE_ARCHIVE_TYPE getType() const; + + //! Add a directory to read files from. Since the Android + //! API does not return names of directories, they need to + //! be added manually. + virtual void addDirectoryToFileList(const io::path &filename); + + //! return the name (id) of the file Archive + const io::path &getArchiveName() const override { return Path; } + +protected: + //! Android's asset manager + AAssetManager *AssetManager; + +}; // CAndroidAssetFileArchive + +} // end namespace io +} // end namespace irr diff --git a/irr/src/Android/CAndroidAssetReader.cpp b/irr/src/Android/CAndroidAssetReader.cpp new file mode 100644 index 000000000..bf3c51af8 --- /dev/null +++ b/irr/src/Android/CAndroidAssetReader.cpp @@ -0,0 +1,65 @@ +// Copyright (C) 2002-2011 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CAndroidAssetReader.h" + +#include "CReadFile.h" +#include "coreutil.h" +#include "CAndroidAssetReader.h" +#include "CIrrDeviceAndroid.h" + +#include +#include + +namespace irr +{ +namespace io +{ + +CAndroidAssetReader::CAndroidAssetReader(AAssetManager *assetManager, const io::path &filename) : + AssetManager(assetManager), Filename(filename) +{ + Asset = AAssetManager_open(AssetManager, + core::stringc(filename).c_str(), + AASSET_MODE_RANDOM); +} + +CAndroidAssetReader::~CAndroidAssetReader() +{ + if (Asset) + AAsset_close(Asset); +} + +size_t CAndroidAssetReader::read(void *buffer, size_t sizeToRead) +{ + int readBytes = AAsset_read(Asset, buffer, sizeToRead); + if (readBytes >= 0) + return size_t(readBytes); + return 0; // direct fd access is not possible (for example, if the asset is compressed). +} + +bool CAndroidAssetReader::seek(long finalPos, bool relativeMovement) +{ + off_t status = AAsset_seek(Asset, finalPos, relativeMovement ? SEEK_CUR : SEEK_SET); + + return status + 1; +} + +long CAndroidAssetReader::getSize() const +{ + return AAsset_getLength(Asset); +} + +long CAndroidAssetReader::getPos() const +{ + return AAsset_getLength(Asset) - AAsset_getRemainingLength(Asset); +} + +const io::path &CAndroidAssetReader::getFileName() const +{ + return Filename; +} + +} // end namespace io +} // end namespace irr diff --git a/irr/src/Android/CAndroidAssetReader.h b/irr/src/Android/CAndroidAssetReader.h new file mode 100644 index 000000000..9f6156f3f --- /dev/null +++ b/irr/src/Android/CAndroidAssetReader.h @@ -0,0 +1,64 @@ +// Copyright (C) 2012 Joerg Henrichs +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReadFile.h" + +struct AAssetManager; +struct AAsset; +struct ANativeActivity; + +namespace irr +{ +namespace io +{ + +class CAndroidAssetReader : public virtual IReadFile +{ +public: + CAndroidAssetReader(AAssetManager *assetManager, const io::path &filename); + + virtual ~CAndroidAssetReader(); + + //! Reads an amount of bytes from the file. + /** \param buffer Pointer to buffer where read bytes are written to. + \param sizeToRead Amount of bytes to read from the file. + \return How many bytes were read. */ + virtual size_t read(void *buffer, size_t sizeToRead); + + //! Changes position in file + /** \param finalPos Destination position in the file. + \param relativeMovement If set to true, the position in the file is + changed relative to current position. Otherwise the position is changed + from beginning of file. + \return True if successful, otherwise false. */ + virtual bool seek(long finalPos, bool relativeMovement = false); + + //! Get size of file. + /** \return Size of the file in bytes. */ + virtual long getSize() const; + + //! Get the current position in the file. + /** \return Current position in the file in bytes. */ + virtual long getPos() const; + + //! Get name of file. + /** \return File name as zero terminated character string. */ + virtual const io::path &getFileName() const; + + /** Return true if the file could be opened. */ + bool isOpen() const { return Asset != NULL; } + +private: + //! Android's asset manager + AAssetManager *AssetManager; + + // An asset, i.e. file + AAsset *Asset; + path Filename; +}; + +} // end namespace io +} // end namespace irr diff --git a/irr/src/Android/CIrrDeviceAndroid.cpp b/irr/src/Android/CIrrDeviceAndroid.cpp new file mode 100644 index 000000000..35c33ef6f --- /dev/null +++ b/irr/src/Android/CIrrDeviceAndroid.cpp @@ -0,0 +1,828 @@ +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// Copyright (C) 2007-2011 Christian Stehno +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CIrrDeviceAndroid.h" + +#include "os.h" +#include "CFileSystem.h" +#include "CAndroidAssetReader.h" +#include "CAndroidAssetFileArchive.h" +#include "CKeyEventWrapper.h" +#include "CEGLManager.h" +#include "ISceneManager.h" +#include "IGUIEnvironment.h" +#include "CEGLManager.h" + +namespace irr +{ +namespace video +{ +IVideoDriver *createOGLES1Driver(const SIrrlichtCreationParameters ¶ms, + io::IFileSystem *io, video::IContextManager *contextManager); + +IVideoDriver *createOGLES2Driver(const SIrrlichtCreationParameters ¶ms, + io::IFileSystem *io, video::IContextManager *contextManager); +} +} + +namespace irr +{ + +CIrrDeviceAndroid::CIrrDeviceAndroid(const SIrrlichtCreationParameters ¶m) : + CIrrDeviceStub(param), Accelerometer(0), Gyroscope(0), Initialized(false), + Stopped(true), Paused(true), Focused(false), JNIEnvAttachedToVM(0) +{ +#ifdef _DEBUG + setDebugName("CIrrDeviceAndroid"); +#endif + + // Get the interface to the native Android activity. + Android = (android_app *)(param.PrivateData); + + // Set the private data so we can use it in any static callbacks. + Android->userData = this; + + // Set the default command handler. This is a callback function that the Android + // OS invokes to send the native activity messages. + Android->onAppCmd = handleAndroidCommand; + + createKeyMap(); + + // Create a sensor manager to receive touch screen events from the java activity. + SensorManager = ASensorManager_getInstance(); + SensorEventQueue = ASensorManager_createEventQueue(SensorManager, Android->looper, LOOPER_ID_USER, 0, 0); + Android->onInputEvent = handleInput; + + // Create EGL manager. + ContextManager = new video::CEGLManager(); + + os::Printer::log("Waiting for Android activity window to be created.", ELL_DEBUG); + + do { + s32 Events = 0; + android_poll_source *Source = 0; + + while ((ALooper_pollAll((!Initialized || isWindowActive()) ? 0 : -1, 0, &Events, (void **)&Source)) >= 0) { + if (Source) + Source->process(Android, Source); + } + } while (!Initialized); +} + +CIrrDeviceAndroid::~CIrrDeviceAndroid() +{ + if (GUIEnvironment) { + GUIEnvironment->drop(); + GUIEnvironment = 0; + } + + if (SceneManager) { + SceneManager->drop(); + SceneManager = 0; + } + + if (VideoDriver) { + VideoDriver->drop(); + VideoDriver = 0; + } +} + +bool CIrrDeviceAndroid::run() +{ + if (!Initialized) + return false; + + os::Timer::tick(); + + s32 id; + s32 Events = 0; + android_poll_source *Source = 0; + + while ((id = ALooper_pollAll(0, 0, &Events, (void **)&Source)) >= 0) { + if (Source) + Source->process(Android, Source); + + // if a sensor has data, we'll process it now. + if (id == LOOPER_ID_USER) { + ASensorEvent sensorEvent; + while (ASensorEventQueue_getEvents(SensorEventQueue, &sensorEvent, 1) > 0) { + switch (sensorEvent.type) { + case ASENSOR_TYPE_ACCELEROMETER: + SEvent accEvent; + accEvent.EventType = EET_ACCELEROMETER_EVENT; + accEvent.AccelerometerEvent.X = sensorEvent.acceleration.x; + accEvent.AccelerometerEvent.Y = sensorEvent.acceleration.y; + accEvent.AccelerometerEvent.Z = sensorEvent.acceleration.z; + + postEventFromUser(accEvent); + break; + + case ASENSOR_TYPE_GYROSCOPE: + SEvent gyroEvent; + gyroEvent.EventType = EET_GYROSCOPE_EVENT; + gyroEvent.GyroscopeEvent.X = sensorEvent.vector.x; + gyroEvent.GyroscopeEvent.Y = sensorEvent.vector.y; + gyroEvent.GyroscopeEvent.Z = sensorEvent.vector.z; + + postEventFromUser(gyroEvent); + break; + default: + break; + } + } + } + + if (!Initialized) + break; + } + + return Initialized; +} + +void CIrrDeviceAndroid::yield() +{ + struct timespec ts = {0, 1}; + nanosleep(&ts, NULL); +} + +void CIrrDeviceAndroid::sleep(u32 timeMs, bool pauseTimer) +{ + const bool wasStopped = Timer ? Timer->isStopped() : true; + + struct timespec ts; + ts.tv_sec = (time_t)(timeMs / 1000); + ts.tv_nsec = (long)(timeMs % 1000) * 1000000; + + if (pauseTimer && !wasStopped) + Timer->stop(); + + nanosleep(&ts, NULL); + + if (pauseTimer && !wasStopped) + Timer->start(); +} + +void CIrrDeviceAndroid::setWindowCaption(const wchar_t *text) +{ +} + +bool CIrrDeviceAndroid::isWindowActive() const +{ + return (Focused && !Paused && !Stopped); +} + +bool CIrrDeviceAndroid::isWindowFocused() const +{ + return Focused; +} + +bool CIrrDeviceAndroid::isWindowMinimized() const +{ + return !Focused; +} + +bool CIrrDeviceAndroid::isWindowVisible() const +{ + return !Stopped; +} + +void CIrrDeviceAndroid::closeDevice() +{ + ANativeActivity_finish(Android->activity); +} + +void CIrrDeviceAndroid::setResizable(bool resize) +{ +} + +void CIrrDeviceAndroid::minimizeWindow() +{ +} + +void CIrrDeviceAndroid::maximizeWindow() +{ +} + +void CIrrDeviceAndroid::restoreWindow() +{ +} + +core::position2di CIrrDeviceAndroid::getWindowPosition() +{ + return core::position2di(0, 0); +} + +E_DEVICE_TYPE CIrrDeviceAndroid::getType() const +{ + return EIDT_ANDROID; +} + +void CIrrDeviceAndroid::handleAndroidCommand(android_app *app, int32_t cmd) +{ + CIrrDeviceAndroid *device = (CIrrDeviceAndroid *)app->userData; + + SEvent event; + event.EventType = EET_SYSTEM_EVENT; + event.SystemEvent.EventType = ESET_ANDROID_CMD; + event.SystemEvent.AndroidCmd.Cmd = cmd; + if (device->postEventFromUser(event)) + return; + + switch (cmd) { + case APP_CMD_INPUT_CHANGED: + os::Printer::log("Android command APP_CMD_INPUT_CHANGED", ELL_DEBUG); + break; + case APP_CMD_WINDOW_RESIZED: + os::Printer::log("Android command APP_CMD_WINDOW_RESIZED", ELL_DEBUG); + break; + case APP_CMD_WINDOW_REDRAW_NEEDED: + os::Printer::log("Android command APP_CMD_WINDOW_REDRAW_NEEDED", ELL_DEBUG); + break; + case APP_CMD_SAVE_STATE: + os::Printer::log("Android command APP_CMD_SAVE_STATE", ELL_DEBUG); + break; + case APP_CMD_CONTENT_RECT_CHANGED: + os::Printer::log("Android command APP_CMD_CONTENT_RECT_CHANGED", ELL_DEBUG); + break; + case APP_CMD_CONFIG_CHANGED: + os::Printer::log("Android command APP_CMD_CONFIG_CHANGED", ELL_DEBUG); + break; + case APP_CMD_LOW_MEMORY: + os::Printer::log("Android command APP_CMD_LOW_MEMORY", ELL_DEBUG); + break; + case APP_CMD_START: + os::Printer::log("Android command APP_CMD_START", ELL_DEBUG); + device->Stopped = false; + break; + case APP_CMD_INIT_WINDOW: + os::Printer::log("Android command APP_CMD_INIT_WINDOW", ELL_DEBUG); + device->getExposedVideoData().OGLESAndroid.Window = app->window; + + if (device->CreationParams.WindowSize.Width == 0 || device->CreationParams.WindowSize.Height == 0) { + device->CreationParams.WindowSize.Width = ANativeWindow_getWidth(app->window); + device->CreationParams.WindowSize.Height = ANativeWindow_getHeight(app->window); + } + + device->getContextManager()->initialize(device->CreationParams, device->ExposedVideoData); + device->getContextManager()->generateSurface(); + device->getContextManager()->generateContext(); + device->getContextManager()->activateContext(device->getContextManager()->getContext()); + + if (!device->Initialized) { + io::CAndroidAssetFileArchive *assets = new io::CAndroidAssetFileArchive(device->Android->activity->assetManager, false, false); + assets->addDirectoryToFileList(""); + device->FileSystem->addFileArchive(assets); + assets->drop(); + + device->createDriver(); + + if (device->VideoDriver) + device->createGUIAndScene(); + } + device->Initialized = true; + break; + case APP_CMD_TERM_WINDOW: + os::Printer::log("Android command APP_CMD_TERM_WINDOW", ELL_DEBUG); + device->getContextManager()->destroySurface(); + break; + case APP_CMD_GAINED_FOCUS: + os::Printer::log("Android command APP_CMD_GAINED_FOCUS", ELL_DEBUG); + device->Focused = true; + break; + case APP_CMD_LOST_FOCUS: + os::Printer::log("Android command APP_CMD_LOST_FOCUS", ELL_DEBUG); + device->Focused = false; + break; + case APP_CMD_DESTROY: + os::Printer::log("Android command APP_CMD_DESTROY", ELL_DEBUG); + if (device->JNIEnvAttachedToVM) { + device->JNIEnvAttachedToVM = 0; + device->Android->activity->vm->DetachCurrentThread(); + } + device->Initialized = false; + break; + case APP_CMD_PAUSE: + os::Printer::log("Android command APP_CMD_PAUSE", ELL_DEBUG); + device->Paused = true; + break; + case APP_CMD_STOP: + os::Printer::log("Android command APP_CMD_STOP", ELL_DEBUG); + device->Stopped = true; + break; + case APP_CMD_RESUME: + os::Printer::log("Android command APP_CMD_RESUME", ELL_DEBUG); + device->Paused = false; + break; + default: + break; + } +} + +s32 CIrrDeviceAndroid::handleInput(android_app *app, AInputEvent *androidEvent) +{ + CIrrDeviceAndroid *device = (CIrrDeviceAndroid *)app->userData; + s32 status = 0; + + switch (AInputEvent_getType(androidEvent)) { + case AINPUT_EVENT_TYPE_MOTION: { + SEvent event; + event.EventType = EET_TOUCH_INPUT_EVENT; + + s32 eventAction = AMotionEvent_getAction(androidEvent); + s32 eventType = eventAction & AMOTION_EVENT_ACTION_MASK; + +#if 0 + // Useful for debugging. We might have to pass some of those infos on at some point. + // but preferably device independent (so iphone can use same irrlicht flags). + int32_t flags = AMotionEvent_getFlags(androidEvent); + os::Printer::log("flags: ", core::stringc(flags).c_str(), ELL_DEBUG); + int32_t metaState = AMotionEvent_getMetaState(androidEvent); + os::Printer::log("metaState: ", core::stringc(metaState).c_str(), ELL_DEBUG); + int32_t edgeFlags = AMotionEvent_getEdgeFlags(androidEvent); + os::Printer::log("edgeFlags: ", core::stringc(flags).c_str(), ELL_DEBUG); +#endif + + bool touchReceived = true; + + switch (eventType) { + case AMOTION_EVENT_ACTION_DOWN: + case AMOTION_EVENT_ACTION_POINTER_DOWN: + event.TouchInput.Event = ETIE_PRESSED_DOWN; + break; + case AMOTION_EVENT_ACTION_MOVE: + event.TouchInput.Event = ETIE_MOVED; + break; + case AMOTION_EVENT_ACTION_UP: + case AMOTION_EVENT_ACTION_POINTER_UP: + case AMOTION_EVENT_ACTION_CANCEL: + event.TouchInput.Event = ETIE_LEFT_UP; + break; + default: + touchReceived = false; + break; + } + + if (touchReceived) { + // Process all touches for move action. + if (event.TouchInput.Event == ETIE_MOVED) { + s32 pointerCount = AMotionEvent_getPointerCount(androidEvent); + + for (s32 i = 0; i < pointerCount; ++i) { + event.TouchInput.ID = AMotionEvent_getPointerId(androidEvent, i); + event.TouchInput.X = AMotionEvent_getX(androidEvent, i); + event.TouchInput.Y = AMotionEvent_getY(androidEvent, i); + event.TouchInput.touchedCount = AMotionEvent_getPointerCount(androidEvent); + + device->postEventFromUser(event); + } + } else // Process one touch for other actions. + { + s32 pointerIndex = (eventAction & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; + + event.TouchInput.ID = AMotionEvent_getPointerId(androidEvent, pointerIndex); + event.TouchInput.X = AMotionEvent_getX(androidEvent, pointerIndex); + event.TouchInput.Y = AMotionEvent_getY(androidEvent, pointerIndex); + event.TouchInput.touchedCount = AMotionEvent_getPointerCount(androidEvent); + + device->postEventFromUser(event); + } + + status = 1; + } + } break; + case AINPUT_EVENT_TYPE_KEY: { + SEvent event; + event.EventType = EET_KEY_INPUT_EVENT; + + int32_t keyCode = AKeyEvent_getKeyCode(androidEvent); + // os::Printer::log("keyCode: ", core::stringc(keyCode).c_str(), ELL_DEBUG); + + int32_t keyAction = AKeyEvent_getAction(androidEvent); + int32_t keyMetaState = AKeyEvent_getMetaState(androidEvent); + + if (keyCode >= 0 && (u32)keyCode < device->KeyMap.size()) + event.KeyInput.Key = device->KeyMap[keyCode]; + else + event.KeyInput.Key = KEY_UNKNOWN; + event.KeyInput.SystemKeyCode = (u32)keyCode; + if (keyAction == AKEY_EVENT_ACTION_DOWN) + event.KeyInput.PressedDown = true; + else if (keyAction == AKEY_EVENT_ACTION_UP) + event.KeyInput.PressedDown = false; + else if (keyAction == AKEY_EVENT_ACTION_MULTIPLE) { + // TODO: Multiple duplicate key events have occurred in a row, + // or a complex string is being delivered. The repeat_count + // property of the key event contains the number of times the + // given key code should be executed. + // I guess this might necessary for more complicated i18n key input, + // but don't see yet how to handle this correctly. + } + + /* no use for meta keys so far. + if ( keyMetaState & AMETA_ALT_ON + || keyMetaState & AMETA_ALT_LEFT_ON + || keyMetaState & AMETA_ALT_RIGHT_ON ) + ; + // what is a sym? + if ( keyMetaState & AMETA_SYM_ON ) + ; + */ + if (keyMetaState & AMETA_SHIFT_ON || keyMetaState & AMETA_SHIFT_LEFT_ON || keyMetaState & AMETA_SHIFT_RIGHT_ON) + event.KeyInput.Shift = true; + else + event.KeyInput.Shift = false; + event.KeyInput.Control = false; + + // Having memory allocations + going through JNI for each key-press is pretty bad (slow). + // So we do it only for those keys which are likely text-characters and avoid it for all other keys. + // So it's fast for keys like game controller input and special keys. And text keys are typically + // only used or entering text and not for gaming on Android, so speed likely doesn't matter there too much. + if (event.KeyInput.Key > 0) { + // TODO: + // Not sure why we have to attach a JNIEnv here, but it won't work when doing that in the constructor or + // trying to use the activity->env. My best guess is that the event-handling happens in an own thread. + // It means JNIEnvAttachedToVM will never get detached as I don't know a safe way where to do that + // (we could attach & detach each time, but that would probably be slow) + // Also - it has to be each time as it get's invalid when the application mode changes. + if (device->Initialized && device->Android && device->Android->activity && device->Android->activity->vm) { + JavaVMAttachArgs attachArgs; + attachArgs.version = JNI_VERSION_1_6; + attachArgs.name = 0; + attachArgs.group = NULL; + + // Not a big problem calling it each time - it's a no-op when the thread already is attached. + // And we have to do that as someone else can have detached the thread in the meantime. + jint result = device->Android->activity->vm->AttachCurrentThread(&device->JNIEnvAttachedToVM, &attachArgs); + if (result == JNI_ERR) { + os::Printer::log("AttachCurrentThread for the JNI environment failed.", ELL_WARNING); + device->JNIEnvAttachedToVM = 0; + } + + if (device->JNIEnvAttachedToVM) { + jni::CKeyEventWrapper *keyEventWrapper = new jni::CKeyEventWrapper(device->JNIEnvAttachedToVM, keyAction, keyCode); + event.KeyInput.Char = keyEventWrapper->getUnicodeChar(keyMetaState); + delete keyEventWrapper; + } + } + if (event.KeyInput.Key == KEY_BACK) { + event.KeyInput.Char = 0x08; // same key-code as on other operating systems. Otherwise we have to handle too much system specific stuff in the editbox. + } + // os::Printer::log("char-code: ", core::stringc((int)event.KeyInput.Char).c_str(), ELL_DEBUG); + + } else { + // os::Printer::log("keyCode: ", core::stringc(keyCode).c_str(), ELL_DEBUG); + event.KeyInput.Char = 0; + } + + status = device->postEventFromUser(event); + } break; + default: + break; + } + + return status; +} + +void CIrrDeviceAndroid::createDriver() +{ + switch (CreationParams.DriverType) { + case video::EDT_OGLES1: +#ifdef _IRR_COMPILE_WITH_OGLES1_ + VideoDriver = video::createOGLES1Driver(CreationParams, FileSystem, ContextManager); +#else + os::Printer::log("No OpenGL ES 1.0 support compiled in.", ELL_ERROR); +#endif + break; + case video::EDT_OGLES2: +#ifdef _IRR_COMPILE_WITH_OGLES2_ + VideoDriver = video::createOGLES2Driver(CreationParams, FileSystem, ContextManager); +#else + os::Printer::log("No OpenGL ES 2.0 support compiled in.", ELL_ERROR); +#endif + break; + case video::EDT_NULL: + VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); + break; + case video::EDT_OPENGL: + os::Printer::log("This driver is not available in Android. Try OpenGL ES 1.0 or ES 2.0.", ELL_ERROR); + break; + default: + os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR); + break; + } +} + +video::SExposedVideoData &CIrrDeviceAndroid::getExposedVideoData() +{ + return ExposedVideoData; +} + +void CIrrDeviceAndroid::createKeyMap() +{ + KeyMap.set_used(223); + + KeyMap[0] = KEY_UNKNOWN; // AKEYCODE_UNKNOWN + KeyMap[1] = KEY_LBUTTON; // AKEYCODE_SOFT_LEFT + KeyMap[2] = KEY_RBUTTON; // AKEYCODE_SOFT_RIGHT + KeyMap[3] = KEY_HOME; // AKEYCODE_HOME + KeyMap[4] = KEY_CANCEL; // AKEYCODE_BACK + KeyMap[5] = KEY_UNKNOWN; // AKEYCODE_CALL + KeyMap[6] = KEY_UNKNOWN; // AKEYCODE_ENDCALL + KeyMap[7] = KEY_KEY_0; // AKEYCODE_0 + KeyMap[8] = KEY_KEY_1; // AKEYCODE_1 + KeyMap[9] = KEY_KEY_2; // AKEYCODE_2 + KeyMap[10] = KEY_KEY_3; // AKEYCODE_3 + KeyMap[11] = KEY_KEY_4; // AKEYCODE_4 + KeyMap[12] = KEY_KEY_5; // AKEYCODE_5 + KeyMap[13] = KEY_KEY_6; // AKEYCODE_6 + KeyMap[14] = KEY_KEY_7; // AKEYCODE_7 + KeyMap[15] = KEY_KEY_8; // AKEYCODE_8 + KeyMap[16] = KEY_KEY_9; // AKEYCODE_9 + KeyMap[17] = KEY_UNKNOWN; // AKEYCODE_STAR + KeyMap[18] = KEY_UNKNOWN; // AKEYCODE_POUND + KeyMap[19] = KEY_UP; // AKEYCODE_DPAD_UP + KeyMap[20] = KEY_DOWN; // AKEYCODE_DPAD_DOWN + KeyMap[21] = KEY_LEFT; // AKEYCODE_DPAD_LEFT + KeyMap[22] = KEY_RIGHT; // AKEYCODE_DPAD_RIGHT + KeyMap[23] = KEY_SELECT; // AKEYCODE_DPAD_CENTER + KeyMap[24] = KEY_VOLUME_DOWN; // AKEYCODE_VOLUME_UP + KeyMap[25] = KEY_VOLUME_UP; // AKEYCODE_VOLUME_DOWN + KeyMap[26] = KEY_UNKNOWN; // AKEYCODE_POWER + KeyMap[27] = KEY_UNKNOWN; // AKEYCODE_CAMERA + KeyMap[28] = KEY_CLEAR; // AKEYCODE_CLEAR + KeyMap[29] = KEY_KEY_A; // AKEYCODE_A + KeyMap[30] = KEY_KEY_B; // AKEYCODE_B + KeyMap[31] = KEY_KEY_C; // AKEYCODE_C + KeyMap[32] = KEY_KEY_D; // AKEYCODE_D + KeyMap[33] = KEY_KEY_E; // AKEYCODE_E + KeyMap[34] = KEY_KEY_F; // AKEYCODE_F + KeyMap[35] = KEY_KEY_G; // AKEYCODE_G + KeyMap[36] = KEY_KEY_H; // AKEYCODE_H + KeyMap[37] = KEY_KEY_I; // AKEYCODE_I + KeyMap[38] = KEY_KEY_J; // AKEYCODE_J + KeyMap[39] = KEY_KEY_K; // AKEYCODE_K + KeyMap[40] = KEY_KEY_L; // AKEYCODE_L + KeyMap[41] = KEY_KEY_M; // AKEYCODE_M + KeyMap[42] = KEY_KEY_N; // AKEYCODE_N + KeyMap[43] = KEY_KEY_O; // AKEYCODE_O + KeyMap[44] = KEY_KEY_P; // AKEYCODE_P + KeyMap[45] = KEY_KEY_Q; // AKEYCODE_Q + KeyMap[46] = KEY_KEY_R; // AKEYCODE_R + KeyMap[47] = KEY_KEY_S; // AKEYCODE_S + KeyMap[48] = KEY_KEY_T; // AKEYCODE_T + KeyMap[49] = KEY_KEY_U; // AKEYCODE_U + KeyMap[50] = KEY_KEY_V; // AKEYCODE_V + KeyMap[51] = KEY_KEY_W; // AKEYCODE_W + KeyMap[52] = KEY_KEY_X; // AKEYCODE_X + KeyMap[53] = KEY_KEY_Y; // AKEYCODE_Y + KeyMap[54] = KEY_KEY_Z; // AKEYCODE_Z + KeyMap[55] = KEY_COMMA; // AKEYCODE_COMMA + KeyMap[56] = KEY_PERIOD; // AKEYCODE_PERIOD + KeyMap[57] = KEY_MENU; // AKEYCODE_ALT_LEFT + KeyMap[58] = KEY_MENU; // AKEYCODE_ALT_RIGHT + KeyMap[59] = KEY_LSHIFT; // AKEYCODE_SHIFT_LEFT + KeyMap[60] = KEY_RSHIFT; // AKEYCODE_SHIFT_RIGHT + KeyMap[61] = KEY_TAB; // AKEYCODE_TAB + KeyMap[62] = KEY_SPACE; // AKEYCODE_SPACE + KeyMap[63] = KEY_UNKNOWN; // AKEYCODE_SYM + KeyMap[64] = KEY_UNKNOWN; // AKEYCODE_EXPLORER + KeyMap[65] = KEY_UNKNOWN; // AKEYCODE_ENVELOPE + KeyMap[66] = KEY_RETURN; // AKEYCODE_ENTER + KeyMap[67] = KEY_BACK; // AKEYCODE_DEL + KeyMap[68] = KEY_OEM_3; // AKEYCODE_GRAVE + KeyMap[69] = KEY_MINUS; // AKEYCODE_MINUS + KeyMap[70] = KEY_UNKNOWN; // AKEYCODE_EQUALS + KeyMap[71] = KEY_UNKNOWN; // AKEYCODE_LEFT_BRACKET + KeyMap[72] = KEY_UNKNOWN; // AKEYCODE_RIGHT_BRACKET + KeyMap[73] = KEY_UNKNOWN; // AKEYCODE_BACKSLASH + KeyMap[74] = KEY_UNKNOWN; // AKEYCODE_SEMICOLON + KeyMap[75] = KEY_UNKNOWN; // AKEYCODE_APOSTROPHE + KeyMap[76] = KEY_UNKNOWN; // AKEYCODE_SLASH + KeyMap[77] = KEY_UNKNOWN; // AKEYCODE_AT + KeyMap[78] = KEY_UNKNOWN; // AKEYCODE_NUM + KeyMap[79] = KEY_UNKNOWN; // AKEYCODE_HEADSETHOOK + KeyMap[80] = KEY_UNKNOWN; // AKEYCODE_FOCUS (*Camera* focus) + KeyMap[81] = KEY_PLUS; // AKEYCODE_PLUS + KeyMap[82] = KEY_MENU; // AKEYCODE_MENU + KeyMap[83] = KEY_UNKNOWN; // AKEYCODE_NOTIFICATION + KeyMap[84] = KEY_UNKNOWN; // AKEYCODE_SEARCH + KeyMap[85] = KEY_MEDIA_PLAY_PAUSE; // AKEYCODE_MEDIA_PLAY_PAUSE + KeyMap[86] = KEY_MEDIA_STOP; // AKEYCODE_MEDIA_STOP + KeyMap[87] = KEY_MEDIA_NEXT_TRACK; // AKEYCODE_MEDIA_NEXT + KeyMap[88] = KEY_MEDIA_PREV_TRACK; // AKEYCODE_MEDIA_PREVIOUS + KeyMap[89] = KEY_UNKNOWN; // AKEYCODE_MEDIA_REWIND + KeyMap[90] = KEY_UNKNOWN; // AKEYCODE_MEDIA_FAST_FORWARD + KeyMap[91] = KEY_VOLUME_MUTE; // AKEYCODE_MUTE + KeyMap[92] = KEY_PRIOR; // AKEYCODE_PAGE_UP + KeyMap[93] = KEY_NEXT; // AKEYCODE_PAGE_DOWN + KeyMap[94] = KEY_UNKNOWN; // AKEYCODE_PICTSYMBOLS + KeyMap[95] = KEY_UNKNOWN; // AKEYCODE_SWITCH_CHARSET + + // following look like controller inputs + KeyMap[96] = KEY_UNKNOWN; // AKEYCODE_BUTTON_A + KeyMap[97] = KEY_UNKNOWN; // AKEYCODE_BUTTON_B + KeyMap[98] = KEY_UNKNOWN; // AKEYCODE_BUTTON_C + KeyMap[99] = KEY_UNKNOWN; // AKEYCODE_BUTTON_X + KeyMap[100] = KEY_UNKNOWN; // AKEYCODE_BUTTON_Y + KeyMap[101] = KEY_UNKNOWN; // AKEYCODE_BUTTON_Z + KeyMap[102] = KEY_UNKNOWN; // AKEYCODE_BUTTON_L1 + KeyMap[103] = KEY_UNKNOWN; // AKEYCODE_BUTTON_R1 + KeyMap[104] = KEY_UNKNOWN; // AKEYCODE_BUTTON_L2 + KeyMap[105] = KEY_UNKNOWN; // AKEYCODE_BUTTON_R2 + KeyMap[106] = KEY_UNKNOWN; // AKEYCODE_BUTTON_THUMBL + KeyMap[107] = KEY_UNKNOWN; // AKEYCODE_BUTTON_THUMBR + KeyMap[108] = KEY_UNKNOWN; // AKEYCODE_BUTTON_START + KeyMap[109] = KEY_UNKNOWN; // AKEYCODE_BUTTON_SELECT + KeyMap[110] = KEY_UNKNOWN; // AKEYCODE_BUTTON_MODE + + KeyMap[111] = KEY_ESCAPE; // AKEYCODE_ESCAPE + KeyMap[112] = KEY_DELETE; // AKEYCODE_FORWARD_DEL + KeyMap[113] = KEY_CONTROL; // AKEYCODE_CTRL_LEFT + KeyMap[114] = KEY_CONTROL; // AKEYCODE_CTRL_RIGHT + KeyMap[115] = KEY_CAPITAL; // AKEYCODE_CAPS_LOCK + KeyMap[116] = KEY_SCROLL; // AKEYCODE_SCROLL_LOCK + KeyMap[117] = KEY_UNKNOWN; // AKEYCODE_META_LEFT + KeyMap[118] = KEY_UNKNOWN; // AKEYCODE_META_RIGHT + KeyMap[119] = KEY_UNKNOWN; // AKEYCODE_FUNCTION + KeyMap[120] = KEY_SNAPSHOT; // AKEYCODE_SYSRQ + KeyMap[121] = KEY_PAUSE; // AKEYCODE_BREAK + KeyMap[122] = KEY_HOME; // AKEYCODE_MOVE_HOME + KeyMap[123] = KEY_END; // AKEYCODE_MOVE_END + KeyMap[124] = KEY_INSERT; // AKEYCODE_INSERT + KeyMap[125] = KEY_UNKNOWN; // AKEYCODE_FORWARD + KeyMap[126] = KEY_PLAY; // AKEYCODE_MEDIA_PLAY + KeyMap[127] = KEY_MEDIA_PLAY_PAUSE; // AKEYCODE_MEDIA_PAUSE + KeyMap[128] = KEY_UNKNOWN; // AKEYCODE_MEDIA_CLOSE + KeyMap[129] = KEY_UNKNOWN; // AKEYCODE_MEDIA_EJECT + KeyMap[130] = KEY_UNKNOWN; // AKEYCODE_MEDIA_RECORD + KeyMap[131] = KEY_F1; // AKEYCODE_F1 + KeyMap[132] = KEY_F2; // AKEYCODE_F2 + KeyMap[133] = KEY_F3; // AKEYCODE_F3 + KeyMap[134] = KEY_F4; // AKEYCODE_F4 + KeyMap[135] = KEY_F5; // AKEYCODE_F5 + KeyMap[136] = KEY_F6; // AKEYCODE_F6 + KeyMap[137] = KEY_F7; // AKEYCODE_F7 + KeyMap[138] = KEY_F8; // AKEYCODE_F8 + KeyMap[139] = KEY_F9; // AKEYCODE_F9 + KeyMap[140] = KEY_F10; // AKEYCODE_F10 + KeyMap[141] = KEY_F11; // AKEYCODE_F11 + KeyMap[142] = KEY_F12; // AKEYCODE_F12 + KeyMap[143] = KEY_NUMLOCK; // AKEYCODE_NUM_LOCK + KeyMap[144] = KEY_NUMPAD0; // AKEYCODE_NUMPAD_0 + KeyMap[145] = KEY_NUMPAD1; // AKEYCODE_NUMPAD_1 + KeyMap[146] = KEY_NUMPAD2; // AKEYCODE_NUMPAD_2 + KeyMap[147] = KEY_NUMPAD3; // AKEYCODE_NUMPAD_3 + KeyMap[148] = KEY_NUMPAD4; // AKEYCODE_NUMPAD_4 + KeyMap[149] = KEY_NUMPAD5; // AKEYCODE_NUMPAD_5 + KeyMap[150] = KEY_NUMPAD6; // AKEYCODE_NUMPAD_6 + KeyMap[151] = KEY_NUMPAD7; // AKEYCODE_NUMPAD_7 + KeyMap[152] = KEY_NUMPAD8; // AKEYCODE_NUMPAD_8 + KeyMap[153] = KEY_NUMPAD9; // AKEYCODE_NUMPAD_9 + KeyMap[154] = KEY_DIVIDE; // AKEYCODE_NUMPAD_DIVIDE + KeyMap[155] = KEY_MULTIPLY; // AKEYCODE_NUMPAD_MULTIPLY + KeyMap[156] = KEY_SUBTRACT; // AKEYCODE_NUMPAD_SUBTRACT + KeyMap[157] = KEY_ADD; // AKEYCODE_NUMPAD_ADD + KeyMap[158] = KEY_UNKNOWN; // AKEYCODE_NUMPAD_DOT + KeyMap[159] = KEY_COMMA; // AKEYCODE_NUMPAD_COMMA + KeyMap[160] = KEY_RETURN; // AKEYCODE_NUMPAD_ENTER + KeyMap[161] = KEY_UNKNOWN; // AKEYCODE_NUMPAD_EQUALS + KeyMap[162] = KEY_UNKNOWN; // AKEYCODE_NUMPAD_LEFT_PAREN + KeyMap[163] = KEY_UNKNOWN; // AKEYCODE_NUMPAD_RIGHT_PAREN + KeyMap[164] = KEY_VOLUME_MUTE; // AKEYCODE_VOLUME_MUTE + KeyMap[165] = KEY_UNKNOWN; // AKEYCODE_INFO + KeyMap[166] = KEY_UNKNOWN; // AKEYCODE_CHANNEL_UP + KeyMap[167] = KEY_UNKNOWN; // AKEYCODE_CHANNEL_DOWN + KeyMap[168] = KEY_ZOOM; // AKEYCODE_ZOOM_IN + KeyMap[169] = KEY_UNKNOWN; // AKEYCODE_ZOOM_OUT + KeyMap[170] = KEY_UNKNOWN; // AKEYCODE_TV + KeyMap[171] = KEY_UNKNOWN; // AKEYCODE_WINDOW + KeyMap[172] = KEY_UNKNOWN; // AKEYCODE_GUIDE + KeyMap[173] = KEY_UNKNOWN; // AKEYCODE_DVR + KeyMap[174] = KEY_UNKNOWN; // AKEYCODE_BOOKMARK + KeyMap[175] = KEY_UNKNOWN; // AKEYCODE_CAPTIONS + KeyMap[176] = KEY_UNKNOWN; // AKEYCODE_SETTINGS + KeyMap[177] = KEY_UNKNOWN; // AKEYCODE_TV_POWER + KeyMap[178] = KEY_UNKNOWN; // AKEYCODE_TV_INPUT + KeyMap[179] = KEY_UNKNOWN; // AKEYCODE_STB_POWER + KeyMap[180] = KEY_UNKNOWN; // AKEYCODE_STB_INPUT + KeyMap[181] = KEY_UNKNOWN; // AKEYCODE_AVR_POWER + KeyMap[182] = KEY_UNKNOWN; // AKEYCODE_AVR_INPUT + KeyMap[183] = KEY_UNKNOWN; // AKEYCODE_PROG_RED + KeyMap[184] = KEY_UNKNOWN; // AKEYCODE_PROG_GREEN + KeyMap[185] = KEY_UNKNOWN; // AKEYCODE_PROG_YELLOW + KeyMap[186] = KEY_UNKNOWN; // AKEYCODE_PROG_BLUE + KeyMap[187] = KEY_UNKNOWN; // AKEYCODE_APP_SWITCH + KeyMap[188] = KEY_UNKNOWN; // AKEYCODE_BUTTON_1 + KeyMap[189] = KEY_UNKNOWN; // AKEYCODE_BUTTON_2 + KeyMap[190] = KEY_UNKNOWN; // AKEYCODE_BUTTON_3 + KeyMap[191] = KEY_UNKNOWN; // AKEYCODE_BUTTON_4 + KeyMap[192] = KEY_UNKNOWN; // AKEYCODE_BUTTON_5 + KeyMap[193] = KEY_UNKNOWN; // AKEYCODE_BUTTON_6 + KeyMap[194] = KEY_UNKNOWN; // AKEYCODE_BUTTON_7 + KeyMap[195] = KEY_UNKNOWN; // AKEYCODE_BUTTON_8 + KeyMap[196] = KEY_UNKNOWN; // AKEYCODE_BUTTON_9 + KeyMap[197] = KEY_UNKNOWN; // AKEYCODE_BUTTON_10 + KeyMap[198] = KEY_UNKNOWN; // AKEYCODE_BUTTON_11 + KeyMap[199] = KEY_UNKNOWN; // AKEYCODE_BUTTON_12 + KeyMap[200] = KEY_UNKNOWN; // AKEYCODE_BUTTON_13 + KeyMap[201] = KEY_UNKNOWN; // AKEYCODE_BUTTON_14 + KeyMap[202] = KEY_UNKNOWN; // AKEYCODE_BUTTON_15 + KeyMap[203] = KEY_UNKNOWN; // AKEYCODE_BUTTON_16 + KeyMap[204] = KEY_UNKNOWN; // AKEYCODE_LANGUAGE_SWITCH + KeyMap[205] = KEY_UNKNOWN; // AKEYCODE_MANNER_MODE + KeyMap[206] = KEY_UNKNOWN; // AKEYCODE_3D_MODE + KeyMap[207] = KEY_UNKNOWN; // AKEYCODE_CONTACTS + KeyMap[208] = KEY_UNKNOWN; // AKEYCODE_CALENDAR + KeyMap[209] = KEY_UNKNOWN; // AKEYCODE_MUSIC + KeyMap[210] = KEY_UNKNOWN; // AKEYCODE_CALCULATOR + KeyMap[211] = KEY_UNKNOWN; // AKEYCODE_ZENKAKU_HANKAKU + KeyMap[212] = KEY_UNKNOWN; // AKEYCODE_EISU + KeyMap[213] = KEY_UNKNOWN; // AKEYCODE_MUHENKAN + KeyMap[214] = KEY_UNKNOWN; // AKEYCODE_HENKAN + KeyMap[215] = KEY_UNKNOWN; // AKEYCODE_KATAKANA_HIRAGANA + KeyMap[216] = KEY_UNKNOWN; // AKEYCODE_YEN + KeyMap[217] = KEY_UNKNOWN; // AKEYCODE_RO + KeyMap[218] = KEY_UNKNOWN; // AKEYCODE_KANA + KeyMap[219] = KEY_UNKNOWN; // AKEYCODE_ASSIST + KeyMap[220] = KEY_UNKNOWN; // AKEYCODE_BRIGHTNESS_DOWN + KeyMap[221] = KEY_UNKNOWN; // AKEYCODE_BRIGHTNESS_UP , + KeyMap[222] = KEY_UNKNOWN; // AKEYCODE_MEDIA_AUDIO_TRACK +} + +bool CIrrDeviceAndroid::activateAccelerometer(float updateInterval) +{ + if (!isAccelerometerAvailable()) + return false; + + ASensorEventQueue_enableSensor(SensorEventQueue, Accelerometer); + ASensorEventQueue_setEventRate(SensorEventQueue, Accelerometer, (int32_t)(updateInterval * 1000.f * 1000.f)); // in microseconds + + os::Printer::log("Activated accelerometer", ELL_DEBUG); + return true; +} + +bool CIrrDeviceAndroid::deactivateAccelerometer() +{ + if (Accelerometer) { + ASensorEventQueue_disableSensor(SensorEventQueue, Accelerometer); + Accelerometer = 0; + os::Printer::log("Deactivated accelerometer", ELL_DEBUG); + return true; + } + + return false; +} + +bool CIrrDeviceAndroid::isAccelerometerActive() +{ + return (Accelerometer != 0); +} + +bool CIrrDeviceAndroid::isAccelerometerAvailable() +{ + if (!Accelerometer) + Accelerometer = ASensorManager_getDefaultSensor(SensorManager, ASENSOR_TYPE_ACCELEROMETER); + + return (Accelerometer != 0); +} + +bool CIrrDeviceAndroid::activateGyroscope(float updateInterval) +{ + if (!isGyroscopeAvailable()) + return false; + + ASensorEventQueue_enableSensor(SensorEventQueue, Gyroscope); + ASensorEventQueue_setEventRate(SensorEventQueue, Gyroscope, (int32_t)(updateInterval * 1000.f * 1000.f)); // in microseconds + + os::Printer::log("Activated gyroscope", ELL_DEBUG); + return true; +} + +bool CIrrDeviceAndroid::deactivateGyroscope() +{ + if (Gyroscope) { + ASensorEventQueue_disableSensor(SensorEventQueue, Gyroscope); + Gyroscope = 0; + os::Printer::log("Deactivated gyroscope", ELL_DEBUG); + return true; + } + + return false; +} + +bool CIrrDeviceAndroid::isGyroscopeActive() +{ + return (Gyroscope != 0); +} + +bool CIrrDeviceAndroid::isGyroscopeAvailable() +{ + if (!Gyroscope) + Gyroscope = ASensorManager_getDefaultSensor(SensorManager, ASENSOR_TYPE_GYROSCOPE); + + return (Gyroscope != 0); +} + +} // end namespace irr diff --git a/irr/src/Android/CIrrDeviceAndroid.h b/irr/src/Android/CIrrDeviceAndroid.h new file mode 100644 index 000000000..19a35b152 --- /dev/null +++ b/irr/src/Android/CIrrDeviceAndroid.h @@ -0,0 +1,98 @@ +// Copyright (C) 2002-2011 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "CIrrDeviceStub.h" +#include "IrrlichtDevice.h" +#include "ICursorControl.h" + +#include +#include + +namespace irr +{ +class CIrrDeviceAndroid : public CIrrDeviceStub +{ +public: + CIrrDeviceAndroid(const SIrrlichtCreationParameters ¶m); + + virtual ~CIrrDeviceAndroid(); + + virtual bool run(); + + virtual void yield(); + + virtual void sleep(u32 timeMs, bool pauseTimer = false); + + virtual void setWindowCaption(const wchar_t *text); + + virtual bool isWindowActive() const; + + virtual bool isWindowFocused() const; + + virtual bool isWindowMinimized() const; + + virtual bool isWindowVisible() const; + + virtual void closeDevice(); + + virtual void setResizable(bool resize = false); + + virtual void minimizeWindow(); + + virtual void maximizeWindow(); + + virtual void restoreWindow(); + + virtual core::position2di getWindowPosition(); + + virtual E_DEVICE_TYPE getType() const; + + virtual bool activateAccelerometer(float updateInterval); + + virtual bool deactivateAccelerometer(); + + virtual bool isAccelerometerActive(); + + virtual bool isAccelerometerAvailable(); + + virtual bool activateGyroscope(float updateInterval); + + virtual bool deactivateGyroscope(); + + virtual bool isGyroscopeActive(); + + virtual bool isGyroscopeAvailable(); + +private: + static void handleAndroidCommand(android_app *app, int32_t cmd); + + static s32 handleInput(android_app *app, AInputEvent *event); + + void createDriver(); + + void createKeyMap(); + + video::SExposedVideoData &getExposedVideoData(); + + android_app *Android; + ASensorManager *SensorManager; + ASensorEventQueue *SensorEventQueue; + const ASensor *Accelerometer; + const ASensor *Gyroscope; + + bool Initialized; + bool Stopped; + bool Paused; + bool Focused; + + JNIEnv *JNIEnvAttachedToVM; + + video::SExposedVideoData ExposedVideoData; + + core::array KeyMap; +}; + +} // end namespace irr diff --git a/irr/src/Android/CKeyEventWrapper.cpp b/irr/src/Android/CKeyEventWrapper.cpp new file mode 100644 index 000000000..4008c29c2 --- /dev/null +++ b/irr/src/Android/CKeyEventWrapper.cpp @@ -0,0 +1,52 @@ +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CKeyEventWrapper.h" + +#include "os.h" + +namespace irr +{ +namespace jni +{ + +jclass CKeyEventWrapper::Class_KeyEvent = 0; +jmethodID CKeyEventWrapper::Method_constructor = 0; +jmethodID CKeyEventWrapper::Method_getUnicodeChar = 0; + +CKeyEventWrapper::CKeyEventWrapper(JNIEnv *jniEnv, int action, int code) : + JniEnv(jniEnv), JniKeyEvent(0) +{ + if (JniEnv) { + if (!Class_KeyEvent) { + // Find java classes & functions on first call + os::Printer::log("CKeyEventWrapper first initialize", ELL_DEBUG); + jclass localClass = JniEnv->FindClass("android/view/KeyEvent"); + if (localClass) { + Class_KeyEvent = reinterpret_cast(JniEnv->NewGlobalRef(localClass)); + } + + Method_constructor = JniEnv->GetMethodID(Class_KeyEvent, "", "(II)V"); + Method_getUnicodeChar = JniEnv->GetMethodID(Class_KeyEvent, "getUnicodeChar", "(I)I"); + } + + if (Class_KeyEvent && Method_constructor) { + JniKeyEvent = JniEnv->NewObject(Class_KeyEvent, Method_constructor, action, code); + } else { + os::Printer::log("CKeyEventWrapper didn't find JNI classes/methods", ELL_WARNING); + } + } +} + +CKeyEventWrapper::~CKeyEventWrapper() +{ + JniEnv->DeleteLocalRef(JniKeyEvent); +} + +int CKeyEventWrapper::getUnicodeChar(int metaState) +{ + return JniEnv->CallIntMethod(JniKeyEvent, Method_getUnicodeChar, metaState); +} + +} // namespace jni +} // namespace irr diff --git a/irr/src/Android/CKeyEventWrapper.h b/irr/src/Android/CKeyEventWrapper.h new file mode 100644 index 000000000..9eb68697a --- /dev/null +++ b/irr/src/Android/CKeyEventWrapper.h @@ -0,0 +1,35 @@ +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include + +struct android_app; + +namespace irr +{ +namespace jni +{ + +//! Minimal JNI wrapper class around android.view.KeyEvent +//! NOTE: Only functions we actually use in the engine are wrapped +//! This is currently not written to support multithreading - meaning threads are not attached/detached to the Java VM (to be discussed) +class CKeyEventWrapper +{ +public: + CKeyEventWrapper(JNIEnv *jniEnv, int action, int code); + ~CKeyEventWrapper(); + + int getUnicodeChar(int metaState); + +private: + static jclass Class_KeyEvent; + static jmethodID Method_getUnicodeChar; + static jmethodID Method_constructor; + JNIEnv *JniEnv; + jobject JniKeyEvent; // this object in java +}; + +} // namespace jni +} // namespace irr diff --git a/irr/src/BuiltInFont.h b/irr/src/BuiltInFont.h new file mode 100644 index 000000000..1df5b7da4 --- /dev/null +++ b/irr/src/BuiltInFont.h @@ -0,0 +1,135 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +// header file generated by xxd +// for the source bitmap, see builtInFont.png + +namespace irr +{ +namespace gui +{ +const u8 BuiltInFontData[] = { + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, + 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, + 0x04, 0x03, 0x00, 0x00, 0x00, 0x31, 0x10, 0x7c, 0xf8, 0x00, 0x00, 0x00, + 0x0f, 0x50, 0x4c, 0x54, 0x45, 0x18, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbd, 0xc8, 0xc8, 0xae, + 0x00, 0x00, 0x05, 0x11, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0x62, 0x50, + 0x06, 0xf0, 0x62, 0x06, 0xb6, 0xed, 0xf4, 0x3a, 0x0c, 0xff, 0xf1, 0xba, + 0x00, 0xb9, 0x41, 0xde, 0x06, 0xd9, 0x7f, 0xba, 0x07, 0x98, 0x10, 0x6a, + 0x1f, 0xd2, 0xe2, 0x9f, 0xa0, 0xf8, 0x74, 0xaa, 0x65, 0xc9, 0x32, 0x23, + 0x39, 0xc4, 0xc1, 0xe9, 0xc5, 0x83, 0x0b, 0xd6, 0x58, 0x7d, 0xf4, 0xe9, + 0xec, 0x6a, 0xac, 0x6b, 0xd5, 0xc7, 0x9e, 0xfc, 0x17, 0x62, 0x09, 0x09, + 0x4c, 0x60, 0x59, 0x0b, 0x99, 0x0a, 0x6b, 0xde, 0xc1, 0x60, 0x62, 0x82, + 0xd2, 0xc0, 0x00, 0x90, 0x58, 0x21, 0xc2, 0xc6, 0x02, 0xef, 0x00, 0x16, + 0xc1, 0x2a, 0x2e, 0x46, 0x13, 0xb5, 0x0a, 0x00, 0x48, 0xc5, 0xef, 0x62, + 0x63, 0xde, 0x00, 0xd4, 0x28, 0xea, 0xc7, 0x77, 0x8a, 0x82, 0x07, 0xa0, + 0xcb, 0xe0, 0x0c, 0x80, 0x42, 0x41, 0x0b, 0x20, 0x83, 0xb0, 0xc1, 0xc2, + 0x8d, 0x22, 0x46, 0x12, 0x13, 0x1c, 0xec, 0x5b, 0x05, 0x03, 0xd0, 0x9d, + 0xc9, 0x00, 0xbc, 0x68, 0x21, 0x10, 0xa4, 0x01, 0xe8, 0x8a, 0x68, 0xb1, + 0x24, 0x73, 0x88, 0x30, 0x2d, 0xc8, 0x98, 0x11, 0x66, 0x7e, 0x02, 0x7c, + 0x26, 0x16, 0x6f, 0xc8, 0xf3, 0x0b, 0x9e, 0xd0, 0xf1, 0xb9, 0xfc, 0x3e, + 0x9d, 0x3d, 0x79, 0xd2, 0x61, 0xf4, 0xeb, 0x4c, 0x7e, 0x2c, 0x6e, 0x0e, + 0x41, 0x29, 0xab, 0x37, 0x53, 0xed, 0xf2, 0x46, 0xe3, 0x59, 0xfd, 0x53, + 0x09, 0x28, 0x80, 0x51, 0x8c, 0xb2, 0x4c, 0x42, 0xca, 0xdc, 0x32, 0xb4, + 0x26, 0xc8, 0xb2, 0x9a, 0x0f, 0xee, 0x2e, 0x8c, 0x29, 0x1d, 0xeb, 0xd4, + 0x54, 0x3d, 0x00, 0x62, 0x03, 0x70, 0x93, 0xfb, 0x01, 0xdd, 0xa6, 0x52, + 0xc2, 0xb8, 0x81, 0x98, 0x3a, 0x4a, 0x01, 0xca, 0x57, 0xdb, 0x92, 0xf0, + 0x37, 0xe3, 0x0a, 0x26, 0x15, 0x0d, 0x0d, 0x80, 0x59, 0x2a, 0x8b, 0x1f, + 0x01, 0xa6, 0x02, 0x50, 0x3f, 0xcd, 0x3f, 0xb6, 0xe0, 0xb6, 0x40, 0xbd, + 0x60, 0x8a, 0x47, 0xb3, 0x66, 0xe6, 0xf3, 0x10, 0xa7, 0x7e, 0x8b, 0x9e, + 0x65, 0x18, 0x4f, 0x01, 0xb1, 0x89, 0xc2, 0x7f, 0x2f, 0xe5, 0xe6, 0x10, + 0xb4, 0xac, 0xde, 0x4d, 0xb5, 0xcb, 0xdf, 0x34, 0xde, 0x92, 0x1e, 0x1b, + 0x73, 0x0f, 0xe7, 0xa0, 0x73, 0x9f, 0x26, 0x94, 0xcb, 0x75, 0x3e, 0x11, + 0xdd, 0xfd, 0x40, 0x4f, 0x9b, 0x90, 0x7c, 0x7f, 0x85, 0x63, 0x45, 0x42, + 0x30, 0x41, 0x1b, 0x71, 0x67, 0x8a, 0x98, 0x3d, 0x6b, 0x60, 0x07, 0x90, + 0xc0, 0x86, 0x59, 0xb1, 0xa9, 0xbc, 0x06, 0x28, 0x11, 0xc4, 0x6c, 0x5c, + 0x2e, 0x02, 0x3c, 0x8c, 0xa9, 0xc8, 0xc4, 0x1d, 0xdb, 0x82, 0x24, 0x12, + 0xd0, 0x4b, 0x80, 0x2d, 0x3e, 0x52, 0x56, 0x96, 0xa7, 0x4d, 0xf0, 0xd1, + 0x42, 0x37, 0xaa, 0x7f, 0xf5, 0x0e, 0x00, 0xdd, 0x01, 0x48, 0xf7, 0x06, + 0x0c, 0xf1, 0x00, 0x4c, 0xe1, 0xc9, 0x09, 0x40, 0xf6, 0x16, 0xfe, 0x4d, + 0x32, 0x7f, 0x31, 0x7f, 0x2f, 0x43, 0xca, 0xd1, 0x3a, 0x27, 0x9d, 0xfb, + 0x34, 0xa1, 0x5c, 0xae, 0xd3, 0x7b, 0xc5, 0x30, 0xf3, 0x5a, 0xce, 0xa3, + 0x0e, 0xa3, 0xcd, 0x68, 0x62, 0xc7, 0x46, 0xba, 0xc2, 0x9f, 0x88, 0x00, + 0x3c, 0xef, 0x5d, 0xfe, 0x49, 0xe6, 0xf5, 0x69, 0x60, 0x1b, 0x7e, 0x02, + 0xf0, 0x6b, 0x00, 0x97, 0xbd, 0x04, 0x85, 0xac, 0x98, 0xb0, 0x62, 0x42, + 0x83, 0xc4, 0x32, 0x21, 0x78, 0xad, 0xb9, 0xa3, 0x9a, 0x5c, 0x68, 0x09, + 0x17, 0x4d, 0x58, 0xc6, 0x52, 0x9d, 0xd1, 0x96, 0x35, 0x00, 0x6b, 0x3a, + 0xdc, 0x2d, 0x00, 0x3b, 0x80, 0x5e, 0x00, 0x34, 0xdd, 0x18, 0x0d, 0x16, + 0x5b, 0x05, 0x04, 0xa3, 0xdc, 0x01, 0x98, 0x16, 0xe6, 0x92, 0x56, 0x80, + 0xa5, 0x1c, 0x2d, 0x54, 0xf4, 0xe2, 0xac, 0x8e, 0x84, 0x5b, 0x7c, 0x00, + 0x46, 0xe4, 0x37, 0x00, 0xcc, 0x4d, 0x9e, 0xc3, 0xcc, 0x67, 0x2f, 0x15, + 0x75, 0x46, 0xcb, 0xdc, 0x67, 0x4d, 0xc7, 0x46, 0xd6, 0x4a, 0x2f, 0x18, + 0x6f, 0x6b, 0xb9, 0xff, 0x57, 0x4c, 0x16, 0x7e, 0x4b, 0xa9, 0x0c, 0x33, + 0x3e, 0x01, 0x30, 0x42, 0xc3, 0xaf, 0xcf, 0x2a, 0x08, 0xa2, 0x8c, 0xfe, + 0xac, 0x02, 0x41, 0xdc, 0x3e, 0xf8, 0x14, 0x40, 0x00, 0x9f, 0x56, 0x30, + 0x34, 0x07, 0x63, 0xde, 0x95, 0x73, 0xdb, 0xa7, 0x00, 0xf7, 0xbb, 0xf2, + 0xdb, 0x3a, 0xdc, 0x5f, 0xf3, 0xbe, 0x61, 0xfb, 0xf6, 0x5d, 0x5a, 0xa7, + 0x84, 0x5d, 0xbc, 0xdd, 0x7f, 0x00, 0x36, 0x75, 0xcc, 0x25, 0x7e, 0x90, + 0xe4, 0x8d, 0x76, 0x2c, 0xa1, 0x6c, 0xad, 0xcd, 0x09, 0xb3, 0x11, 0x07, + 0xd0, 0x18, 0x70, 0x43, 0x9d, 0xa9, 0x11, 0xcb, 0xf7, 0x53, 0x2e, 0x36, + 0xa0, 0x13, 0xc0, 0xcc, 0x25, 0xb3, 0x00, 0x06, 0x6c, 0x33, 0x32, 0x4e, + 0x13, 0x91, 0x86, 0x30, 0x54, 0x04, 0xe3, 0x22, 0x1d, 0x15, 0xd8, 0x8a, + 0x35, 0x15, 0x28, 0x34, 0x67, 0x66, 0x04, 0x1b, 0xec, 0x62, 0x18, 0x77, + 0x73, 0x26, 0x59, 0x83, 0x3d, 0xfd, 0x0d, 0x00, 0x01, 0xc6, 0x91, 0x8c, + 0x53, 0x43, 0x52, 0x90, 0x0a, 0x36, 0x23, 0x5b, 0x05, 0x36, 0xd9, 0x32, + 0x7a, 0x02, 0x35, 0x73, 0x0e, 0xbf, 0x4a, 0x8b, 0x7c, 0x99, 0x96, 0x77, + 0xee, 0x95, 0x32, 0x3f, 0xca, 0x93, 0x67, 0xdf, 0xbe, 0xd5, 0x27, 0x25, + 0xe9, 0x90, 0xfc, 0xfc, 0x01, 0xd8, 0xd5, 0x9a, 0x8e, 0x0f, 0x7c, 0x61, + 0x1e, 0xd2, 0x25, 0xf1, 0x10, 0x17, 0x94, 0xd3, 0xe6, 0xb1, 0x02, 0xff, + 0xc3, 0x8f, 0x4b, 0x97, 0x2f, 0x5d, 0xd0, 0x44, 0x66, 0x5b, 0x6b, 0x9c, + 0x1b, 0x29, 0x8c, 0x99, 0x05, 0x37, 0x80, 0x86, 0x53, 0x34, 0xe0, 0xd9, + 0x76, 0x12, 0x63, 0x8c, 0x62, 0x82, 0xe2, 0xd1, 0x01, 0x25, 0x41, 0x68, + 0xee, 0xd7, 0xca, 0x0f, 0x00, 0xe9, 0x47, 0xc2, 0xa6, 0x9e, 0x47, 0xd6, + 0x32, 0x8d, 0x41, 0x99, 0xa5, 0xdd, 0x90, 0x58, 0x1c, 0x15, 0x34, 0xd9, + 0x0a, 0x96, 0x7e, 0x05, 0x18, 0x53, 0x7d, 0x59, 0x01, 0x39, 0x01, 0x94, + 0x90, 0xf8, 0x30, 0xbf, 0xb6, 0x80, 0x6e, 0x00, 0xe8, 0x1e, 0x57, 0x4c, + 0x5e, 0xb5, 0xf0, 0xf2, 0x10, 0x7f, 0x27, 0xe0, 0xe7, 0x12, 0xde, 0x90, + 0xa1, 0xe7, 0x98, 0x65, 0x4f, 0x7d, 0xf6, 0x69, 0xc6, 0x69, 0x86, 0xc3, + 0x7d, 0xd1, 0x9a, 0x8b, 0x12, 0x5a, 0x2a, 0x5d, 0xa9, 0x3e, 0x8e, 0x61, + 0xa6, 0x77, 0xf2, 0x0e, 0x9d, 0x26, 0x26, 0x2a, 0x65, 0x98, 0xda, 0x98, + 0x26, 0x5f, 0x4b, 0xb7, 0xe3, 0x54, 0xfc, 0xe2, 0x2b, 0x99, 0x44, 0x63, + 0xab, 0x03, 0x95, 0xf3, 0x6b, 0x04, 0xac, 0x1b, 0x00, 0x36, 0x59, 0xe3, + 0x6f, 0x32, 0x7b, 0x84, 0x7d, 0x07, 0x10, 0x58, 0x94, 0x15, 0xc7, 0xd0, + 0x09, 0x47, 0x05, 0xfe, 0x11, 0xc0, 0x02, 0x73, 0x0e, 0xee, 0xa0, 0xa3, + 0x82, 0xf0, 0x02, 0x20, 0x73, 0x91, 0x3e, 0x86, 0x0c, 0xd4, 0x71, 0x88, + 0xc9, 0x38, 0x63, 0xe6, 0x95, 0x72, 0x6b, 0x80, 0x64, 0xa6, 0x7c, 0x24, + 0x7f, 0xcf, 0xf5, 0x72, 0xb2, 0xe3, 0xdd, 0x54, 0xf9, 0x3a, 0x87, 0x7d, + 0x5a, 0x4e, 0x5e, 0xf4, 0x59, 0xce, 0x5d, 0xef, 0x64, 0x9e, 0x2d, 0x70, + 0xfe, 0x23, 0xac, 0xae, 0x8c, 0x41, 0x55, 0x53, 0xa9, 0x77, 0xfe, 0xaa, + 0x50, 0x92, 0x00, 0xf3, 0x03, 0x47, 0x92, 0x00, 0xf6, 0xc3, 0xcf, 0x37, + 0x2e, 0x65, 0x8a, 0x8a, 0x82, 0xad, 0x01, 0x38, 0x44, 0xfe, 0xe7, 0x2f, + 0x40, 0x9a, 0x99, 0x37, 0x32, 0x62, 0xc2, 0x5d, 0x8d, 0x72, 0x52, 0xc9, + 0x0c, 0x0b, 0xa7, 0x85, 0x01, 0xe8, 0x12, 0xa7, 0x06, 0xdf, 0x00, 0x74, + 0x00, 0x80, 0x19, 0x00, 0x17, 0xed, 0x50, 0x4c, 0xf4, 0x0b, 0x00, 0x41, + 0x67, 0x05, 0xf7, 0x16, 0x20, 0x07, 0x99, 0x91, 0x11, 0x03, 0xf0, 0xbe, + 0x08, 0x51, 0xfd, 0x10, 0xc0, 0xed, 0x7a, 0x78, 0x40, 0x39, 0xf9, 0xec, + 0x53, 0xe7, 0xd4, 0x57, 0x64, 0xee, 0x16, 0x28, 0x95, 0xd9, 0xff, 0x4f, + 0x3c, 0x7f, 0x8f, 0x99, 0xcc, 0x7c, 0x72, 0xb8, 0x46, 0x47, 0x92, 0xf0, + 0xb9, 0x14, 0x40, 0xbe, 0x73, 0xd0, 0x2e, 0xdb, 0x5e, 0x81, 0x6b, 0x3d, + 0xe7, 0xa1, 0x84, 0x8c, 0xd3, 0x1c, 0x2f, 0x3f, 0xc4, 0x13, 0x40, 0x96, + 0x43, 0x20, 0xee, 0x32, 0x62, 0x0a, 0x40, 0x4d, 0x44, 0x41, 0x49, 0x88, + 0x63, 0x2d, 0x0f, 0x96, 0x4d, 0x48, 0x19, 0x53, 0x18, 0x17, 0x7f, 0x00, + 0x66, 0x4e, 0x62, 0x12, 0x2b, 0x4e, 0xe4, 0x34, 0xcd, 0x98, 0x44, 0x96, + 0x21, 0x64, 0x3a, 0x98, 0xae, 0x8d, 0x32, 0x15, 0x28, 0x09, 0x0a, 0xad, + 0x60, 0xcd, 0xc3, 0xb4, 0x30, 0x15, 0x30, 0x08, 0x61, 0x00, 0x20, 0xe3, + 0x35, 0xd2, 0x33, 0x88, 0xd9, 0xe5, 0x7e, 0x06, 0xb2, 0x06, 0xa0, 0x47, + 0x94, 0xec, 0x20, 0xfe, 0x91, 0xa7, 0x73, 0x06, 0xf9, 0x3e, 0x83, 0xf7, + 0xf8, 0xd0, 0x0e, 0xda, 0x4d, 0x65, 0xff, 0x3f, 0xf1, 0xfc, 0x7d, 0xcd, + 0x64, 0xe6, 0x93, 0x33, 0xf3, 0x21, 0xf2, 0x76, 0x53, 0x78, 0xfc, 0x7f, + 0x94, 0xa4, 0x46, 0x17, 0x17, 0x06, 0xca, 0x80, 0xa3, 0x88, 0x03, 0xa5, + 0x06, 0x88, 0x30, 0xb0, 0xb8, 0x90, 0x69, 0x88, 0x00, 0xd8, 0x00, 0x17, + 0x07, 0x17, 0x41, 0xf2, 0x3c, 0xc2, 0x08, 0x8a, 0x55, 0x47, 0x41, 0x41, + 0x07, 0x20, 0x16, 0x21, 0xdb, 0x05, 0x14, 0x19, 0xc0, 0x30, 0x28, 0x0c, + 0x70, 0x71, 0x01, 0x06, 0x22, 0x10, 0x90, 0x3d, 0x47, 0x82, 0x48, 0xa6, + 0x23, 0x13, 0x8c, 0x02, 0x00, 0xe7, 0xfb, 0x84, 0x1b, 0xf9, 0x8e, 0xc0, + 0x23, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, + 0x82 + }; + +const u32 BuiltInFontDataSize = sizeof(BuiltInFontData); +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CAnimatedMeshSceneNode.cpp b/irr/src/CAnimatedMeshSceneNode.cpp new file mode 100644 index 000000000..c3a71f943 --- /dev/null +++ b/irr/src/CAnimatedMeshSceneNode.cpp @@ -0,0 +1,755 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CAnimatedMeshSceneNode.h" +#include "IVideoDriver.h" +#include "ISceneManager.h" +#include "S3DVertex.h" +#include "os.h" +#include "CSkinnedMesh.h" +#include "IDummyTransformationSceneNode.h" +#include "IBoneSceneNode.h" +#include "IMaterialRenderer.h" +#include "IMesh.h" +#include "IMeshCache.h" +#include "IAnimatedMesh.h" +#include "IFileSystem.h" +#include "quaternion.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CAnimatedMeshSceneNode::CAnimatedMeshSceneNode(IAnimatedMesh *mesh, + ISceneNode *parent, ISceneManager *mgr, s32 id, + const core::vector3df &position, + const core::vector3df &rotation, + const core::vector3df &scale) : + IAnimatedMeshSceneNode(parent, mgr, id, position, rotation, scale), + Mesh(0), + StartFrame(0), EndFrame(0), FramesPerSecond(0.025f), + CurrentFrameNr(0.f), LastTimeMs(0), + TransitionTime(0), Transiting(0.f), TransitingBlend(0.f), + JointMode(EJUOR_NONE), JointsUsed(false), + Looping(true), ReadOnlyMaterials(false), RenderFromIdentity(false), + LoopCallBack(0), PassCount(0) +{ +#ifdef _DEBUG + setDebugName("CAnimatedMeshSceneNode"); +#endif + + setMesh(mesh); +} + +//! destructor +CAnimatedMeshSceneNode::~CAnimatedMeshSceneNode() +{ + if (LoopCallBack) + LoopCallBack->drop(); + if (Mesh) + Mesh->drop(); +} + +//! Sets the current frame. From now on the animation is played from this frame. +void CAnimatedMeshSceneNode::setCurrentFrame(f32 frame) +{ + // if you pass an out of range value, we just clamp it + CurrentFrameNr = core::clamp(frame, (f32)StartFrame, (f32)EndFrame); + + beginTransition(); // transit to this frame if enabled +} + +//! Returns the currently displayed frame number. +f32 CAnimatedMeshSceneNode::getFrameNr() const +{ + return CurrentFrameNr; +} + +//! Get CurrentFrameNr and update transiting settings +void CAnimatedMeshSceneNode::buildFrameNr(u32 timeMs) +{ + if (Transiting != 0.f) { + TransitingBlend += (f32)(timeMs)*Transiting; + if (TransitingBlend > 1.f) { + Transiting = 0.f; + TransitingBlend = 0.f; + } + } + + if (StartFrame == EndFrame) { + CurrentFrameNr = (f32)StartFrame; // Support for non animated meshes + } else if (Looping) { + // play animation looped + CurrentFrameNr += timeMs * FramesPerSecond; + + // We have no interpolation between EndFrame and StartFrame, + // the last frame must be identical to first one with our current solution. + if (FramesPerSecond > 0.f) { // forwards... + if (CurrentFrameNr > EndFrame) + CurrentFrameNr = StartFrame + fmodf(CurrentFrameNr - StartFrame, (f32)(EndFrame - StartFrame)); + } else // backwards... + { + if (CurrentFrameNr < StartFrame) + CurrentFrameNr = EndFrame - fmodf(EndFrame - CurrentFrameNr, (f32)(EndFrame - StartFrame)); + } + } else { + // play animation non looped + + CurrentFrameNr += timeMs * FramesPerSecond; + if (FramesPerSecond > 0.f) { // forwards... + if (CurrentFrameNr > (f32)EndFrame) { + CurrentFrameNr = (f32)EndFrame; + if (LoopCallBack) + LoopCallBack->OnAnimationEnd(this); + } + } else // backwards... + { + if (CurrentFrameNr < (f32)StartFrame) { + CurrentFrameNr = (f32)StartFrame; + if (LoopCallBack) + LoopCallBack->OnAnimationEnd(this); + } + } + } +} + +void CAnimatedMeshSceneNode::OnRegisterSceneNode() +{ + if (IsVisible && Mesh) { + // because this node supports rendering of mixed mode meshes consisting of + // transparent and solid material at the same time, we need to go through all + // materials, check of what type they are and register this node for the right + // render pass according to that. + + video::IVideoDriver *driver = SceneManager->getVideoDriver(); + + PassCount = 0; + int transparentCount = 0; + int solidCount = 0; + + // count transparent and solid materials in this scene node + const u32 numMaterials = ReadOnlyMaterials ? Mesh->getMeshBufferCount() : Materials.size(); + for (u32 i = 0; i < numMaterials; ++i) { + const video::SMaterial &material = ReadOnlyMaterials ? Mesh->getMeshBuffer(i)->getMaterial() : Materials[i]; + + if (driver->needsTransparentRenderPass(material)) + ++transparentCount; + else + ++solidCount; + + if (solidCount && transparentCount) + break; + } + + // register according to material types counted + + if (solidCount) + SceneManager->registerNodeForRendering(this, scene::ESNRP_SOLID); + + if (transparentCount) + SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT); + + ISceneNode::OnRegisterSceneNode(); + } +} + +IMesh *CAnimatedMeshSceneNode::getMeshForCurrentFrame() +{ + if (Mesh->getMeshType() != EAMT_SKINNED) { + s32 frameNr = (s32)getFrameNr(); + s32 frameBlend = (s32)(core::fract(getFrameNr()) * 1000.f); + return Mesh->getMesh(frameNr, frameBlend, StartFrame, EndFrame); + } else { + // As multiple scene nodes may be sharing the same skinned mesh, we have to + // re-animate it every frame to ensure that this node gets the mesh that it needs. + + CSkinnedMesh *skinnedMesh = static_cast(Mesh); + + if (JointMode == EJUOR_CONTROL) // write to mesh + skinnedMesh->transferJointsToMesh(JointChildSceneNodes); + else + skinnedMesh->animateMesh(getFrameNr(), 1.0f); + + // Update the skinned mesh for the current joint transforms. + skinnedMesh->skinMesh(); + + if (JointMode == EJUOR_READ) { // read from mesh + skinnedMesh->recoverJointsFromMesh(JointChildSceneNodes); + + //---slow--- + for (u32 n = 0; n < JointChildSceneNodes.size(); ++n) + if (JointChildSceneNodes[n]->getParent() == this) { + JointChildSceneNodes[n]->updateAbsolutePositionOfAllChildren(); // temp, should be an option + } + } + + if (JointMode == EJUOR_CONTROL) { + // For meshes other than EJUOR_CONTROL, this is done by calling animateMesh() + skinnedMesh->updateBoundingBox(); + } + + return skinnedMesh; + } +} + +//! OnAnimate() is called just before rendering the whole scene. +void CAnimatedMeshSceneNode::OnAnimate(u32 timeMs) +{ + if (LastTimeMs == 0) { // first frame + LastTimeMs = timeMs; + } + + // set CurrentFrameNr + buildFrameNr(timeMs - LastTimeMs); + LastTimeMs = timeMs; + + IAnimatedMeshSceneNode::OnAnimate(timeMs); +} + +//! renders the node. +void CAnimatedMeshSceneNode::render() +{ + video::IVideoDriver *driver = SceneManager->getVideoDriver(); + + if (!Mesh || !driver) + return; + + const bool isTransparentPass = + SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT; + + ++PassCount; + + scene::IMesh *m = getMeshForCurrentFrame(); + + if (m) { + Box = m->getBoundingBox(); + } else { +#ifdef _DEBUG + os::Printer::log("Animated Mesh returned no mesh to render.", Mesh->getDebugName(), ELL_WARNING); +#endif + return; + } + + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); + + for (u32 i = 0; i < m->getMeshBufferCount(); ++i) { + const bool transparent = driver->needsTransparentRenderPass(Materials[i]); + + // only render transparent buffer if this is the transparent render pass + // and solid only in solid pass + if (transparent == isTransparentPass) { + scene::IMeshBuffer *mb = m->getMeshBuffer(i); + const video::SMaterial &material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i]; + if (RenderFromIdentity) + driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); + else if (Mesh->getMeshType() == EAMT_SKINNED) + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((SSkinMeshBuffer *)mb)->Transformation); + + driver->setMaterial(material); + driver->drawMeshBuffer(mb); + } + } + + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); + + // for debug purposes only: + if (DebugDataVisible && PassCount == 1) { + video::SMaterial debug_mat; + debug_mat.Lighting = false; + debug_mat.AntiAliasing = 0; + driver->setMaterial(debug_mat); + // show normals + if (DebugDataVisible & scene::EDS_NORMALS) { + const f32 debugNormalLength = 1.f; + const video::SColor debugNormalColor = video::SColor(255, 34, 221, 221); + const u32 count = m->getMeshBufferCount(); + + // draw normals + for (u32 g = 0; g < count; ++g) { + scene::IMeshBuffer *mb = m->getMeshBuffer(g); + if (RenderFromIdentity) + driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); + else if (Mesh->getMeshType() == EAMT_SKINNED) + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((SSkinMeshBuffer *)mb)->Transformation); + + driver->drawMeshBufferNormals(mb, debugNormalLength, debugNormalColor); + } + } + + debug_mat.ZBuffer = video::ECFN_DISABLED; + debug_mat.Lighting = false; + driver->setMaterial(debug_mat); + + if (DebugDataVisible & scene::EDS_BBOX) + driver->draw3DBox(Box, video::SColor(255, 255, 255, 255)); + + // show bounding box + if (DebugDataVisible & scene::EDS_BBOX_BUFFERS) { + for (u32 g = 0; g < m->getMeshBufferCount(); ++g) { + const IMeshBuffer *mb = m->getMeshBuffer(g); + + if (Mesh->getMeshType() == EAMT_SKINNED) + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((SSkinMeshBuffer *)mb)->Transformation); + driver->draw3DBox(mb->getBoundingBox(), video::SColor(255, 190, 128, 128)); + } + } + + // show skeleton + if (DebugDataVisible & scene::EDS_SKELETON) { + if (Mesh->getMeshType() == EAMT_SKINNED) { + // draw skeleton + + for (u32 g = 0; g < ((ISkinnedMesh *)Mesh)->getAllJoints().size(); ++g) { + ISkinnedMesh::SJoint *joint = ((ISkinnedMesh *)Mesh)->getAllJoints()[g]; + + for (u32 n = 0; n < joint->Children.size(); ++n) { + driver->draw3DLine(joint->GlobalAnimatedMatrix.getTranslation(), + joint->Children[n]->GlobalAnimatedMatrix.getTranslation(), + video::SColor(255, 51, 66, 255)); + } + } + } + } + + // show mesh + if (DebugDataVisible & scene::EDS_MESH_WIRE_OVERLAY) { + debug_mat.Lighting = false; + debug_mat.Wireframe = true; + debug_mat.ZBuffer = video::ECFN_DISABLED; + driver->setMaterial(debug_mat); + + for (u32 g = 0; g < m->getMeshBufferCount(); ++g) { + const IMeshBuffer *mb = m->getMeshBuffer(g); + if (RenderFromIdentity) + driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); + else if (Mesh->getMeshType() == EAMT_SKINNED) + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((SSkinMeshBuffer *)mb)->Transformation); + driver->drawMeshBuffer(mb); + } + } + } +} + +//! Returns the current start frame number. +s32 CAnimatedMeshSceneNode::getStartFrame() const +{ + return StartFrame; +} + +//! Returns the current start frame number. +s32 CAnimatedMeshSceneNode::getEndFrame() const +{ + return EndFrame; +} + +//! sets the frames between the animation is looped. +//! the default is 0 - MaximalFrameCount of the mesh. +bool CAnimatedMeshSceneNode::setFrameLoop(s32 begin, s32 end) +{ + const s32 maxFrameCount = Mesh->getFrameCount() - 1; + if (end < begin) { + StartFrame = core::s32_clamp(end, 0, maxFrameCount); + EndFrame = core::s32_clamp(begin, StartFrame, maxFrameCount); + } else { + StartFrame = core::s32_clamp(begin, 0, maxFrameCount); + EndFrame = core::s32_clamp(end, StartFrame, maxFrameCount); + } + if (FramesPerSecond < 0) + setCurrentFrame((f32)EndFrame); + else + setCurrentFrame((f32)StartFrame); + + return true; +} + +//! sets the speed with witch the animation is played +void CAnimatedMeshSceneNode::setAnimationSpeed(f32 framesPerSecond) +{ + FramesPerSecond = framesPerSecond * 0.001f; +} + +f32 CAnimatedMeshSceneNode::getAnimationSpeed() const +{ + return FramesPerSecond * 1000.f; +} + +//! returns the axis aligned bounding box of this node +const core::aabbox3d &CAnimatedMeshSceneNode::getBoundingBox() const +{ + return Box; +} + +//! returns the material based on the zero based index i. +video::SMaterial &CAnimatedMeshSceneNode::getMaterial(u32 i) +{ + if (i >= Materials.size()) + return ISceneNode::getMaterial(i); + + return Materials[i]; +} + +//! returns amount of materials used by this scene node. +u32 CAnimatedMeshSceneNode::getMaterialCount() const +{ + return Materials.size(); +} + +//! Returns a pointer to a child node, which has the same transformation as +//! the corresponding joint, if the mesh in this scene node is a skinned mesh. +IBoneSceneNode *CAnimatedMeshSceneNode::getJointNode(const c8 *jointName) +{ + if (!Mesh || Mesh->getMeshType() != EAMT_SKINNED) { + os::Printer::log("No mesh, or mesh not of skinned mesh type", ELL_WARNING); + return 0; + } + + checkJoints(); + + ISkinnedMesh *skinnedMesh = (ISkinnedMesh *)Mesh; + + const std::optional number = skinnedMesh->getJointNumber(jointName); + + if (!number.has_value()) { + os::Printer::log("Joint with specified name not found in skinned mesh", jointName, ELL_DEBUG); + return 0; + } + + if (JointChildSceneNodes.size() <= *number) { + os::Printer::log("Joint was found in mesh, but is not loaded into node", jointName, ELL_WARNING); + return 0; + } + + return JointChildSceneNodes[*number]; +} + +//! Returns a pointer to a child node, which has the same transformation as +//! the corresponding joint, if the mesh in this scene node is a skinned mesh. +IBoneSceneNode *CAnimatedMeshSceneNode::getJointNode(u32 jointID) +{ + if (!Mesh || Mesh->getMeshType() != EAMT_SKINNED) { + os::Printer::log("No mesh, or mesh not of skinned mesh type", ELL_WARNING); + return 0; + } + + checkJoints(); + + if (JointChildSceneNodes.size() <= jointID) { + os::Printer::log("Joint not loaded into node", ELL_WARNING); + return 0; + } + + return JointChildSceneNodes[jointID]; +} + +//! Gets joint count. +u32 CAnimatedMeshSceneNode::getJointCount() const +{ + if (!Mesh || Mesh->getMeshType() != EAMT_SKINNED) + return 0; + + ISkinnedMesh *skinnedMesh = (ISkinnedMesh *)Mesh; + + return skinnedMesh->getJointCount(); +} + +//! Removes a child from this scene node. +//! Implemented here, to be able to remove the shadow properly, if there is one, +//! or to remove attached childs. +bool CAnimatedMeshSceneNode::removeChild(ISceneNode *child) +{ + if (ISceneNode::removeChild(child)) { + if (JointsUsed) { // stop weird bugs caused while changing parents as the joints are being created + for (u32 i = 0; i < JointChildSceneNodes.size(); ++i) { + if (JointChildSceneNodes[i] == child) { + JointChildSceneNodes[i] = 0; // remove link to child + break; + } + } + } + return true; + } + + return false; +} + +//! Sets looping mode which is on by default. If set to false, +//! animations will not be looped. +void CAnimatedMeshSceneNode::setLoopMode(bool playAnimationLooped) +{ + Looping = playAnimationLooped; +} + +//! returns the current loop mode +bool CAnimatedMeshSceneNode::getLoopMode() const +{ + return Looping; +} + +//! Sets a callback interface which will be called if an animation +//! playback has ended. Set this to 0 to disable the callback again. +void CAnimatedMeshSceneNode::setAnimationEndCallback(IAnimationEndCallBack *callback) +{ + if (callback == LoopCallBack) + return; + + if (LoopCallBack) + LoopCallBack->drop(); + + LoopCallBack = callback; + + if (LoopCallBack) + LoopCallBack->grab(); +} + +//! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. +void CAnimatedMeshSceneNode::setReadOnlyMaterials(bool readonly) +{ + ReadOnlyMaterials = readonly; +} + +//! Returns if the scene node should not copy the materials of the mesh but use them in a read only style +bool CAnimatedMeshSceneNode::isReadOnlyMaterials() const +{ + return ReadOnlyMaterials; +} + +//! Sets a new mesh +void CAnimatedMeshSceneNode::setMesh(IAnimatedMesh *mesh) +{ + if (!mesh) + return; // won't set null mesh + + if (Mesh != mesh) { + if (Mesh) + Mesh->drop(); + + Mesh = mesh; + + // grab the mesh (it's non-null!) + Mesh->grab(); + } + + // get materials and bounding box + Box = Mesh->getBoundingBox(); + + IMesh *m = Mesh->getMesh(0, 0); + if (m) { + Materials.clear(); + Materials.reallocate(m->getMeshBufferCount()); + + for (u32 i = 0; i < m->getMeshBufferCount(); ++i) { + IMeshBuffer *mb = m->getMeshBuffer(i); + if (mb) + Materials.push_back(mb->getMaterial()); + else + Materials.push_back(video::SMaterial()); + } + } + + // clean up joint nodes + if (JointsUsed) { + JointsUsed = false; + checkJoints(); + } + + // get start and begin time + setAnimationSpeed(Mesh->getAnimationSpeed()); // NOTE: This had been commented out (but not removed!) in r3526. Which caused meshloader-values for speed to be ignored unless users specified explicitly. Missing a test-case where this could go wrong so I put the code back in. + setFrameLoop(0, Mesh->getFrameCount() - 1); +} + +//! updates the absolute position based on the relative and the parents position +void CAnimatedMeshSceneNode::updateAbsolutePosition() +{ + IAnimatedMeshSceneNode::updateAbsolutePosition(); +} + +//! Set the joint update mode (0-unused, 1-get joints only, 2-set joints only, 3-move and set) +void CAnimatedMeshSceneNode::setJointMode(E_JOINT_UPDATE_ON_RENDER mode) +{ + checkJoints(); + JointMode = mode; +} + +//! Sets the transition time in seconds (note: This needs to enable joints, and setJointmode maybe set to 2) +//! you must call animateJoints(), or the mesh will not animate +void CAnimatedMeshSceneNode::setTransitionTime(f32 time) +{ + const u32 ttime = (u32)core::floor32(time * 1000.0f); + if (TransitionTime == ttime) + return; + TransitionTime = ttime; + if (ttime != 0) + setJointMode(EJUOR_CONTROL); + else + setJointMode(EJUOR_NONE); +} + +//! render mesh ignoring its transformation. Used with ragdolls. (culling is unaffected) +void CAnimatedMeshSceneNode::setRenderFromIdentity(bool enable) +{ + RenderFromIdentity = enable; +} + +//! updates the joint positions of this mesh +void CAnimatedMeshSceneNode::animateJoints(bool CalculateAbsolutePositions) +{ + if (Mesh && Mesh->getMeshType() == EAMT_SKINNED) { + checkJoints(); + const f32 frame = getFrameNr(); // old? + + CSkinnedMesh *skinnedMesh = static_cast(Mesh); + + skinnedMesh->transferOnlyJointsHintsToMesh(JointChildSceneNodes); + skinnedMesh->animateMesh(frame, 1.0f); + skinnedMesh->recoverJointsFromMesh(JointChildSceneNodes); + + //----------------------------------------- + // Transition + //----------------------------------------- + + if (Transiting != 0.f) { + // Init additional matrices + if (PretransitingSave.size() < JointChildSceneNodes.size()) { + for (u32 n = PretransitingSave.size(); n < JointChildSceneNodes.size(); ++n) + PretransitingSave.push_back(core::matrix4()); + } + + for (u32 n = 0; n < JointChildSceneNodes.size(); ++n) { + //------Position------ + + JointChildSceneNodes[n]->setPosition( + core::lerp( + PretransitingSave[n].getTranslation(), + JointChildSceneNodes[n]->getPosition(), + TransitingBlend)); + + //------Rotation------ + + // Code is slow, needs to be fixed up + + const core::quaternion RotationStart(PretransitingSave[n].getRotationDegrees() * core::DEGTORAD); + const core::quaternion RotationEnd(JointChildSceneNodes[n]->getRotation() * core::DEGTORAD); + + core::quaternion QRotation; + QRotation.slerp(RotationStart, RotationEnd, TransitingBlend); + + core::vector3df tmpVector; + QRotation.toEuler(tmpVector); + tmpVector *= core::RADTODEG; // convert from radians back to degrees + JointChildSceneNodes[n]->setRotation(tmpVector); + + //------Scale------ + + // JointChildSceneNodes[n]->setScale( + // core::lerp( + // PretransitingSave[n].getScale(), + // JointChildSceneNodes[n]->getScale(), + // TransitingBlend)); + } + } + + if (CalculateAbsolutePositions) { + //---slow--- + for (u32 n = 0; n < JointChildSceneNodes.size(); ++n) { + if (JointChildSceneNodes[n]->getParent() == this) { + JointChildSceneNodes[n]->updateAbsolutePositionOfAllChildren(); // temp, should be an option + } + } + } + } +} + +/*! + */ +void CAnimatedMeshSceneNode::checkJoints() +{ + if (!Mesh || Mesh->getMeshType() != EAMT_SKINNED) + return; + + if (!JointsUsed) { + for (u32 i = 0; i < JointChildSceneNodes.size(); ++i) + removeChild(JointChildSceneNodes[i]); + JointChildSceneNodes.clear(); + + // Create joints for SkinnedMesh + ((CSkinnedMesh *)Mesh)->addJoints(JointChildSceneNodes, this, SceneManager); + ((CSkinnedMesh *)Mesh)->recoverJointsFromMesh(JointChildSceneNodes); + + JointsUsed = true; + JointMode = EJUOR_READ; + } +} + +/*! + */ +void CAnimatedMeshSceneNode::beginTransition() +{ + if (!JointsUsed) + return; + + if (TransitionTime != 0) { + // Check the array is big enough + if (PretransitingSave.size() < JointChildSceneNodes.size()) { + for (u32 n = PretransitingSave.size(); n < JointChildSceneNodes.size(); ++n) + PretransitingSave.push_back(core::matrix4()); + } + + // Copy the position of joints + for (u32 n = 0; n < JointChildSceneNodes.size(); ++n) + PretransitingSave[n] = JointChildSceneNodes[n]->getRelativeTransformation(); + + Transiting = core::reciprocal((f32)TransitionTime); + } + TransitingBlend = 0.f; +} + +/*! + */ +ISceneNode *CAnimatedMeshSceneNode::clone(ISceneNode *newParent, ISceneManager *newManager) +{ + if (!newParent) + newParent = Parent; + if (!newManager) + newManager = SceneManager; + + CAnimatedMeshSceneNode *newNode = + new CAnimatedMeshSceneNode(Mesh, NULL, newManager, ID, RelativeTranslation, + RelativeRotation, RelativeScale); + + if (newParent) { + newNode->setParent(newParent); // not in constructor because virtual overload for updateAbsolutePosition won't be called + newNode->drop(); + } + + newNode->cloneMembers(this, newManager); + + newNode->Materials = Materials; + newNode->Box = Box; + newNode->Mesh = Mesh; + newNode->StartFrame = StartFrame; + newNode->EndFrame = EndFrame; + newNode->FramesPerSecond = FramesPerSecond; + newNode->CurrentFrameNr = CurrentFrameNr; + newNode->JointMode = JointMode; + newNode->JointsUsed = JointsUsed; + newNode->TransitionTime = TransitionTime; + newNode->Transiting = Transiting; + newNode->TransitingBlend = TransitingBlend; + newNode->Looping = Looping; + newNode->ReadOnlyMaterials = ReadOnlyMaterials; + newNode->LoopCallBack = LoopCallBack; + if (newNode->LoopCallBack) + newNode->LoopCallBack->grab(); + newNode->PassCount = PassCount; + newNode->JointChildSceneNodes = JointChildSceneNodes; + newNode->PretransitingSave = PretransitingSave; + newNode->RenderFromIdentity = RenderFromIdentity; + + return newNode; +} + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CAnimatedMeshSceneNode.h b/irr/src/CAnimatedMeshSceneNode.h new file mode 100644 index 000000000..0364ab527 --- /dev/null +++ b/irr/src/CAnimatedMeshSceneNode.h @@ -0,0 +1,177 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IAnimatedMeshSceneNode.h" +#include "IAnimatedMesh.h" + +#include "matrix4.h" + +namespace irr +{ +namespace scene +{ +class IDummyTransformationSceneNode; + +class CAnimatedMeshSceneNode : public IAnimatedMeshSceneNode +{ +public: + //! constructor + CAnimatedMeshSceneNode(IAnimatedMesh *mesh, ISceneNode *parent, ISceneManager *mgr, s32 id, + const core::vector3df &position = core::vector3df(0, 0, 0), + const core::vector3df &rotation = core::vector3df(0, 0, 0), + const core::vector3df &scale = core::vector3df(1.0f, 1.0f, 1.0f)); + + //! destructor + virtual ~CAnimatedMeshSceneNode(); + + //! sets the current frame. from now on the animation is played from this frame. + void setCurrentFrame(f32 frame) override; + + //! frame + void OnRegisterSceneNode() override; + + //! OnAnimate() is called just before rendering the whole scene. + void OnAnimate(u32 timeMs) override; + + //! renders the node. + void render() override; + + //! returns the axis aligned bounding box of this node + const core::aabbox3d &getBoundingBox() const override; + + //! sets the frames between the animation is looped. + //! the default is 0 - MaximalFrameCount of the mesh. + //! NOTE: setMesh will also change this value and set it to the full range of animations of the mesh + bool setFrameLoop(s32 begin, s32 end) override; + + //! Sets looping mode which is on by default. If set to false, + //! animations will not be looped. + void setLoopMode(bool playAnimationLooped) override; + + //! returns the current loop mode + bool getLoopMode() const override; + + //! Sets a callback interface which will be called if an animation + //! playback has ended. Set this to 0 to disable the callback again. + void setAnimationEndCallback(IAnimationEndCallBack *callback = 0) override; + + //! sets the speed with which the animation is played + //! NOTE: setMesh will also change this value and set it to the default speed of the mesh + void setAnimationSpeed(f32 framesPerSecond) override; + + //! gets the speed with which the animation is played + f32 getAnimationSpeed() const override; + + //! returns the material based on the zero based index i. To get the amount + //! of materials used by this scene node, use getMaterialCount(). + //! This function is needed for inserting the node into the scene hierarchy on a + //! optimal position for minimizing renderstate changes, but can also be used + //! to directly modify the material of a scene node. + video::SMaterial &getMaterial(u32 i) override; + + //! returns amount of materials used by this scene node. + u32 getMaterialCount() const override; + + //! Returns a pointer to a child node, which has the same transformation as + //! the corresponding joint, if the mesh in this scene node is a skinned mesh. + IBoneSceneNode *getJointNode(const c8 *jointName) override; + + //! same as getJointNode(const c8* jointName), but based on id + IBoneSceneNode *getJointNode(u32 jointID) override; + + //! Gets joint count. + u32 getJointCount() const override; + + //! Removes a child from this scene node. + //! Implemented here, to be able to remove the shadow properly, if there is one, + //! or to remove attached child. + bool removeChild(ISceneNode *child) override; + + //! Returns the current displayed frame number. + f32 getFrameNr() const override; + //! Returns the current start frame number. + s32 getStartFrame() const override; + //! Returns the current end frame number. + s32 getEndFrame() const override; + + //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. + /* In this way it is possible to change the materials a mesh causing all mesh scene nodes + referencing this mesh to change too. */ + void setReadOnlyMaterials(bool readonly) override; + + //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style + bool isReadOnlyMaterials() const override; + + //! Sets a new mesh + void setMesh(IAnimatedMesh *mesh) override; + + //! Returns the current mesh + IAnimatedMesh *getMesh(void) override { return Mesh; } + + //! Returns type of the scene node + ESCENE_NODE_TYPE getType() const override { return ESNT_ANIMATED_MESH; } + + //! updates the absolute position based on the relative and the parents position + void updateAbsolutePosition() override; + + //! Set the joint update mode (0-unused, 1-get joints only, 2-set joints only, 3-move and set) + void setJointMode(E_JOINT_UPDATE_ON_RENDER mode) override; + + //! Sets the transition time in seconds (note: This needs to enable joints, and setJointmode maybe set to 2) + //! you must call animateJoints(), or the mesh will not animate + void setTransitionTime(f32 Time) override; + + //! updates the joint positions of this mesh + void animateJoints(bool CalculateAbsolutePositions = true) override; + + //! render mesh ignoring its transformation. Used with ragdolls. (culling is unaffected) + void setRenderFromIdentity(bool On) override; + + //! Creates a clone of this scene node and its children. + /** \param newParent An optional new parent. + \param newManager An optional new scene manager. + \return The newly created clone of this node. */ + ISceneNode *clone(ISceneNode *newParent = 0, ISceneManager *newManager = 0) override; + +private: + //! Get a static mesh for the current frame of this animated mesh + IMesh *getMeshForCurrentFrame(); + + void buildFrameNr(u32 timeMs); + void checkJoints(); + void beginTransition(); + + core::array Materials; + core::aabbox3d Box; + IAnimatedMesh *Mesh; + + s32 StartFrame; + s32 EndFrame; + f32 FramesPerSecond; + f32 CurrentFrameNr; + + u32 LastTimeMs; + u32 TransitionTime; // Transition time in millisecs + f32 Transiting; // is mesh transiting (plus cache of TransitionTime) + f32 TransitingBlend; // 0-1, calculated on buildFrameNr + + // 0-unused, 1-get joints only, 2-set joints only, 3-move and set + E_JOINT_UPDATE_ON_RENDER JointMode; + bool JointsUsed; + + bool Looping; + bool ReadOnlyMaterials; + bool RenderFromIdentity; + + IAnimationEndCallBack *LoopCallBack; + s32 PassCount; + + core::array JointChildSceneNodes; + core::array PretransitingSave; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CAttributeImpl.h b/irr/src/CAttributeImpl.h new file mode 100644 index 000000000..9065a7342 --- /dev/null +++ b/irr/src/CAttributeImpl.h @@ -0,0 +1,144 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CAttributes.h" +#include "fast_atof.h" +#include "ITexture.h" +#include "IVideoDriver.h" + +namespace irr +{ +namespace io +{ + +/* + Basic types, check documentation in IAttribute.h to see how they generally work. +*/ + +// Attribute implemented for boolean values +class CBoolAttribute : public IAttribute +{ +public: + CBoolAttribute(const char *name, bool value) + { + Name = name; + setBool(value); + } + + s32 getInt() const override + { + return BoolValue ? 1 : 0; + } + + f32 getFloat() const override + { + return BoolValue ? 1.0f : 0.0f; + } + + bool getBool() const override + { + return BoolValue; + } + + void setInt(s32 intValue) override + { + BoolValue = (intValue != 0); + } + + void setFloat(f32 floatValue) override + { + BoolValue = (floatValue != 0); + } + + void setBool(bool boolValue) override + { + BoolValue = boolValue; + } + + E_ATTRIBUTE_TYPE getType() const override + { + return EAT_BOOL; + } + + bool BoolValue; +}; + +// Attribute implemented for integers +class CIntAttribute : public IAttribute +{ +public: + CIntAttribute(const char *name, s32 value) + { + Name = name; + setInt(value); + } + + s32 getInt() const override + { + return Value; + } + + f32 getFloat() const override + { + return (f32)Value; + } + + void setInt(s32 intValue) override + { + Value = intValue; + } + + void setFloat(f32 floatValue) override + { + Value = (s32)floatValue; + }; + + E_ATTRIBUTE_TYPE getType() const override + { + return EAT_INT; + } + + s32 Value; +}; + +// Attribute implemented for floats +class CFloatAttribute : public IAttribute +{ +public: + CFloatAttribute(const char *name, f32 value) + { + Name = name; + setFloat(value); + } + + s32 getInt() const override + { + return (s32)Value; + } + + f32 getFloat() const override + { + return Value; + } + + void setInt(s32 intValue) override + { + Value = (f32)intValue; + } + + void setFloat(f32 floatValue) override + { + Value = floatValue; + } + + E_ATTRIBUTE_TYPE getType() const override + { + return EAT_FLOAT; + } + + f32 Value; +}; + +} // end namespace io +} // end namespace irr diff --git a/irr/src/CAttributes.cpp b/irr/src/CAttributes.cpp new file mode 100644 index 000000000..2696d6bcf --- /dev/null +++ b/irr/src/CAttributes.cpp @@ -0,0 +1,249 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CAttributes.h" +#include "CAttributeImpl.h" +#include "ITexture.h" +#include "IVideoDriver.h" + +namespace irr +{ +namespace io +{ + +CAttributes::CAttributes(video::IVideoDriver *driver) : + Driver(driver) +{ +#ifdef _DEBUG + setDebugName("CAttributes"); +#endif + + if (Driver) + Driver->grab(); +} + +CAttributes::~CAttributes() +{ + clear(); + + if (Driver) + Driver->drop(); +} + +//! Removes all attributes +void CAttributes::clear() +{ + for (u32 i = 0; i < Attributes.size(); ++i) + Attributes[i]->drop(); + + Attributes.clear(); +} + +//! Returns attribute index from name, -1 if not found +s32 CAttributes::findAttribute(const c8 *attributeName) const +{ + for (u32 i = 0; i < Attributes.size(); ++i) + if (Attributes[i]->Name == attributeName) + return i; + + return -1; +} + +IAttribute *CAttributes::getAttributeP(const c8 *attributeName) const +{ + for (u32 i = 0; i < Attributes.size(); ++i) + if (Attributes[i]->Name == attributeName) + return Attributes[i]; + + return 0; +} + +//! Sets a attribute as boolean value +void CAttributes::setAttribute(const c8 *attributeName, bool value) +{ + IAttribute *att = getAttributeP(attributeName); + if (att) + att->setBool(value); + else { + Attributes.push_back(new CBoolAttribute(attributeName, value)); + } +} + +//! Gets a attribute as boolean value +//! \param attributeName: Name of the attribute to get. +//! \return Returns value of the attribute previously set by setAttribute() as bool +//! or 0 if attribute is not set. +bool CAttributes::getAttributeAsBool(const c8 *attributeName, bool defaultNotFound) const +{ + const IAttribute *att = getAttributeP(attributeName); + if (att) + return att->getBool(); + else + return defaultNotFound; +} + +//! Sets a attribute as integer value +void CAttributes::setAttribute(const c8 *attributeName, s32 value) +{ + IAttribute *att = getAttributeP(attributeName); + if (att) + att->setInt(value); + else { + Attributes.push_back(new CIntAttribute(attributeName, value)); + } +} + +//! Gets a attribute as integer value +//! \param attributeName: Name of the attribute to get. +//! \return Returns value of the attribute previously set by setAttribute() as integer +//! or 0 if attribute is not set. +s32 CAttributes::getAttributeAsInt(const c8 *attributeName, irr::s32 defaultNotFound) const +{ + const IAttribute *att = getAttributeP(attributeName); + if (att) + return att->getInt(); + else + return defaultNotFound; +} + +//! Sets a attribute as float value +void CAttributes::setAttribute(const c8 *attributeName, f32 value) +{ + IAttribute *att = getAttributeP(attributeName); + if (att) + att->setFloat(value); + else + Attributes.push_back(new CFloatAttribute(attributeName, value)); +} + +//! Gets a attribute as integer value +//! \param attributeName: Name of the attribute to get. +//! \return Returns value of the attribute previously set by setAttribute() as float value +//! or 0 if attribute is not set. +f32 CAttributes::getAttributeAsFloat(const c8 *attributeName, irr::f32 defaultNotFound) const +{ + const IAttribute *att = getAttributeP(attributeName); + if (att) + return att->getFloat(); + + return defaultNotFound; +} + +//! Returns amount of string attributes set in this scene manager. +u32 CAttributes::getAttributeCount() const +{ + return Attributes.size(); +} + +//! Returns string attribute name by index. +//! \param index: Index value, must be between 0 and getStringAttributeCount()-1. +const c8 *CAttributes::getAttributeName(s32 index) const +{ + if ((u32)index >= Attributes.size()) + return 0; + + return Attributes[index]->Name.c_str(); +} + +//! Returns the type of an attribute +E_ATTRIBUTE_TYPE CAttributes::getAttributeType(const c8 *attributeName) const +{ + E_ATTRIBUTE_TYPE ret = EAT_UNKNOWN; + + const IAttribute *att = getAttributeP(attributeName); + if (att) + ret = att->getType(); + + return ret; +} + +//! Returns attribute type by index. +//! \param index: Index value, must be between 0 and getAttributeCount()-1. +E_ATTRIBUTE_TYPE CAttributes::getAttributeType(s32 index) const +{ + if ((u32)index >= Attributes.size()) + return EAT_UNKNOWN; + + return Attributes[index]->getType(); +} + +//! Gets an attribute as integer value +//! \param index: Index value, must be between 0 and getAttributeCount()-1. +s32 CAttributes::getAttributeAsInt(s32 index) const +{ + if ((u32)index < Attributes.size()) + return Attributes[index]->getInt(); + else + return 0; +} + +//! Gets an attribute as float value +//! \param index: Index value, must be between 0 and getAttributeCount()-1. +f32 CAttributes::getAttributeAsFloat(s32 index) const +{ + if ((u32)index < Attributes.size()) + return Attributes[index]->getFloat(); + else + return 0.f; +} + +//! Gets an attribute as boolean value +//! \param index: Index value, must be between 0 and getAttributeCount()-1. +bool CAttributes::getAttributeAsBool(s32 index) const +{ + bool ret = false; + + if ((u32)index < Attributes.size()) + ret = Attributes[index]->getBool(); + + return ret; +} + +//! Adds an attribute as integer +void CAttributes::addInt(const c8 *attributeName, s32 value) +{ + Attributes.push_back(new CIntAttribute(attributeName, value)); +} + +//! Adds an attribute as float +void CAttributes::addFloat(const c8 *attributeName, f32 value) +{ + Attributes.push_back(new CFloatAttribute(attributeName, value)); +} + +//! Adds an attribute as bool +void CAttributes::addBool(const c8 *attributeName, bool value) +{ + Attributes.push_back(new CBoolAttribute(attributeName, value)); +} + +//! Returns if an attribute with a name exists +bool CAttributes::existsAttribute(const c8 *attributeName) const +{ + return getAttributeP(attributeName) != 0; +} + +//! Sets an attribute as boolean value +void CAttributes::setAttribute(s32 index, bool value) +{ + if ((u32)index < Attributes.size()) + Attributes[index]->setBool(value); +} + +//! Sets an attribute as integer value +void CAttributes::setAttribute(s32 index, s32 value) +{ + if ((u32)index < Attributes.size()) + Attributes[index]->setInt(value); +} + +//! Sets a attribute as float value +void CAttributes::setAttribute(s32 index, f32 value) +{ + if ((u32)index < Attributes.size()) + Attributes[index]->setFloat(value); +} + +} // end namespace io +} // end namespace irr diff --git a/irr/src/CAttributes.h b/irr/src/CAttributes.h new file mode 100644 index 000000000..0fe2739b6 --- /dev/null +++ b/irr/src/CAttributes.h @@ -0,0 +1,133 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IAttributes.h" +#include "IAttribute.h" + +namespace irr +{ +namespace video +{ +class ITexture; +class IVideoDriver; +} +namespace io +{ + +//! Implementation of the IAttributes interface +class CAttributes : public IAttributes +{ +public: + CAttributes(video::IVideoDriver *driver = 0); + ~CAttributes(); + + //! Returns amount of attributes in this collection of attributes. + u32 getAttributeCount() const override; + + //! Returns attribute name by index. + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + const c8 *getAttributeName(s32 index) const override; + + //! Returns the type of an attribute + //! \param attributeName: Name for the attribute + E_ATTRIBUTE_TYPE getAttributeType(const c8 *attributeName) const override; + + //! Returns attribute type by index. + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + E_ATTRIBUTE_TYPE getAttributeType(s32 index) const override; + + //! Returns if an attribute with a name exists + bool existsAttribute(const c8 *attributeName) const override; + + //! Returns attribute index from name, -1 if not found + s32 findAttribute(const c8 *attributeName) const override; + + //! Removes all attributes + void clear() override; + + /* + + Integer Attribute + + */ + + //! Adds an attribute as integer + void addInt(const c8 *attributeName, s32 value) override; + + //! Sets an attribute as integer value + void setAttribute(const c8 *attributeName, s32 value) override; + + //! Gets an attribute as integer value + //! \param attributeName: Name of the attribute to get. + //! \param defaultNotFound Value returned when attributeName was not found + //! \return Returns value of the attribute previously set by setAttribute() + s32 getAttributeAsInt(const c8 *attributeName, irr::s32 defaultNotFound = 0) const override; + + //! Gets an attribute as integer value + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + s32 getAttributeAsInt(s32 index) const override; + + //! Sets an attribute as integer value + void setAttribute(s32 index, s32 value) override; + + /* + + Float Attribute + + */ + + //! Adds an attribute as float + void addFloat(const c8 *attributeName, f32 value) override; + + //! Sets a attribute as float value + void setAttribute(const c8 *attributeName, f32 value) override; + + //! Gets an attribute as float value + //! \param attributeName: Name of the attribute to get. + //! \param defaultNotFound Value returned when attributeName was not found + //! \return Returns value of the attribute previously set by setAttribute() + f32 getAttributeAsFloat(const c8 *attributeName, irr::f32 defaultNotFound = 0.f) const override; + + //! Gets an attribute as float value + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + f32 getAttributeAsFloat(s32 index) const override; + + //! Sets an attribute as float value + void setAttribute(s32 index, f32 value) override; + + /* + Bool Attribute + */ + + //! Adds an attribute as bool + void addBool(const c8 *attributeName, bool value) override; + + //! Sets an attribute as boolean value + void setAttribute(const c8 *attributeName, bool value) override; + + //! Gets an attribute as boolean value + //! \param attributeName: Name of the attribute to get. + //! \param defaultNotFound Value returned when attributeName was not found + //! \return Returns value of the attribute previously set by setAttribute() + bool getAttributeAsBool(const c8 *attributeName, bool defaultNotFound = false) const override; + + //! Gets an attribute as boolean value + //! \param index: Index value, must be between 0 and getAttributeCount()-1. + bool getAttributeAsBool(s32 index) const override; + + //! Sets an attribute as boolean value + void setAttribute(s32 index, bool value) override; + +protected: + core::array Attributes; + + IAttribute *getAttributeP(const c8 *attributeName) const; + + video::IVideoDriver *Driver; +}; + +} // end namespace io +} // end namespace irr diff --git a/irr/src/CB3DMeshFileLoader.cpp b/irr/src/CB3DMeshFileLoader.cpp new file mode 100644 index 000000000..6ee24af0e --- /dev/null +++ b/irr/src/CB3DMeshFileLoader.cpp @@ -0,0 +1,949 @@ +// Copyright (C) 2006-2012 Luke Hoschke +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +// B3D Mesh loader +// File format designed by Mark Sibly for the Blitz3D engine and has been +// declared public domain + +#include "CB3DMeshFileLoader.h" + +#include "IVideoDriver.h" +#include "IFileSystem.h" +#include "os.h" + +#include + +#ifdef _DEBUG +#define _B3D_READER_DEBUG +#endif + +namespace irr +{ +namespace scene +{ + +//! Constructor +CB3DMeshFileLoader::CB3DMeshFileLoader(scene::ISceneManager *smgr) : + AnimatedMesh(0), B3DFile(0), VerticesStart(0), NormalsInFile(false), + HasVertexColors(false), ShowWarning(true) +{ +#ifdef _DEBUG + setDebugName("CB3DMeshFileLoader"); +#endif +} + +//! returns true if the file maybe is able to be loaded by this class +//! based on the file extension (e.g. ".bsp") +bool CB3DMeshFileLoader::isALoadableFileExtension(const io::path &filename) const +{ + return core::hasFileExtension(filename, "b3d"); +} + +//! creates/loads an animated mesh from the file. +//! \return Pointer to the created mesh. Returns 0 if loading failed. +//! If you no longer need the mesh, you should call IAnimatedMesh::drop(). +//! See IReferenceCounted::drop() for more information. +IAnimatedMesh *CB3DMeshFileLoader::createMesh(io::IReadFile *file) +{ + if (!file) + return 0; + + B3DFile = file; + AnimatedMesh = new scene::CSkinnedMesh(); + ShowWarning = true; // If true a warning is issued if too many textures are used + VerticesStart = 0; + + if (load()) { + AnimatedMesh->finalize(); + } else { + AnimatedMesh->drop(); + AnimatedMesh = 0; + } + + return AnimatedMesh; +} + +bool CB3DMeshFileLoader::load() +{ + B3dStack.clear(); + + NormalsInFile = false; + HasVertexColors = false; + + //------ Get header ------ + + SB3dChunkHeader header; + B3DFile->read(&header, sizeof(header)); +#ifdef __BIG_ENDIAN__ + header.size = os::Byteswap::byteswap(header.size); +#endif + + if (strncmp(header.name, "BB3D", 4) != 0) { + os::Printer::log("File is not a b3d file. Loading failed (No header found)", B3DFile->getFileName(), ELL_ERROR); + return false; + } + + // Add main chunk... + B3dStack.push_back(SB3dChunk(header, B3DFile->getPos() - 8)); + + // Get file version, but ignore it, as it's not important with b3d files... + s32 fileVersion; + B3DFile->read(&fileVersion, sizeof(fileVersion)); +#ifdef __BIG_ENDIAN__ + fileVersion = os::Byteswap::byteswap(fileVersion); +#endif + + //------ Read main chunk ------ + + while ((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) { + B3DFile->read(&header, sizeof(header)); +#ifdef __BIG_ENDIAN__ + header.size = os::Byteswap::byteswap(header.size); +#endif + B3dStack.push_back(SB3dChunk(header, B3DFile->getPos() - 8)); + + if (strncmp(B3dStack.getLast().name, "TEXS", 4) == 0) { + if (!readChunkTEXS()) + return false; + } else if (strncmp(B3dStack.getLast().name, "BRUS", 4) == 0) { + if (!readChunkBRUS()) + return false; + } else if (strncmp(B3dStack.getLast().name, "NODE", 4) == 0) { + if (!readChunkNODE((CSkinnedMesh::SJoint *)0)) + return false; + } else { + os::Printer::log("Unknown chunk found in mesh base - skipping"); + if (!B3DFile->seek(B3dStack.getLast().startposition + B3dStack.getLast().length)) + return false; + B3dStack.erase(B3dStack.size() - 1); + } + } + + B3dStack.clear(); + + BaseVertices.clear(); + AnimatedVertices_VertexID.clear(); + AnimatedVertices_BufferID.clear(); + + Materials.clear(); + Textures.clear(); + + return true; +} + +bool CB3DMeshFileLoader::readChunkNODE(CSkinnedMesh::SJoint *inJoint) +{ + CSkinnedMesh::SJoint *joint = AnimatedMesh->addJoint(inJoint); + joint->Name = readString(); + +#ifdef _B3D_READER_DEBUG + core::stringc logStr; + for (u32 i = 1; i < B3dStack.size(); ++i) + logStr += "-"; + logStr += "read ChunkNODE"; + os::Printer::log(logStr.c_str(), joint->Name.value_or("").c_str(), ELL_DEBUG); +#endif + + f32 position[3], scale[3], rotation[4]; + + readFloats(position, 3); + readFloats(scale, 3); + readFloats(rotation, 4); + + joint->Animatedposition = core::vector3df(position[0], position[1], position[2]); + joint->Animatedscale = core::vector3df(scale[0], scale[1], scale[2]); + joint->Animatedrotation = core::quaternion(rotation[1], rotation[2], rotation[3], rotation[0]); + + // Build LocalMatrix: + + core::matrix4 positionMatrix; + positionMatrix.setTranslation(joint->Animatedposition); + core::matrix4 scaleMatrix; + scaleMatrix.setScale(joint->Animatedscale); + core::matrix4 rotationMatrix; + joint->Animatedrotation.getMatrix_transposed(rotationMatrix); + + joint->LocalMatrix = positionMatrix * rotationMatrix * scaleMatrix; + + if (inJoint) + joint->GlobalMatrix = inJoint->GlobalMatrix * joint->LocalMatrix; + else + joint->GlobalMatrix = joint->LocalMatrix; + + while (B3dStack.getLast().startposition + B3dStack.getLast().length > B3DFile->getPos()) // this chunk repeats + { + SB3dChunkHeader header; + B3DFile->read(&header, sizeof(header)); +#ifdef __BIG_ENDIAN__ + header.size = os::Byteswap::byteswap(header.size); +#endif + + B3dStack.push_back(SB3dChunk(header, B3DFile->getPos() - 8)); + + if (strncmp(B3dStack.getLast().name, "NODE", 4) == 0) { + if (!readChunkNODE(joint)) + return false; + } else if (strncmp(B3dStack.getLast().name, "MESH", 4) == 0) { + VerticesStart = BaseVertices.size(); + if (!readChunkMESH(joint)) + return false; + } else if (strncmp(B3dStack.getLast().name, "BONE", 4) == 0) { + if (!readChunkBONE(joint)) + return false; + } else if (strncmp(B3dStack.getLast().name, "KEYS", 4) == 0) { + if (!readChunkKEYS(joint)) + return false; + } else if (strncmp(B3dStack.getLast().name, "ANIM", 4) == 0) { + if (!readChunkANIM()) + return false; + } else { + os::Printer::log("Unknown chunk found in node chunk - skipping"); + if (!B3DFile->seek(B3dStack.getLast().startposition + B3dStack.getLast().length)) + return false; + B3dStack.erase(B3dStack.size() - 1); + } + } + + B3dStack.erase(B3dStack.size() - 1); + + return true; +} + +bool CB3DMeshFileLoader::readChunkMESH(CSkinnedMesh::SJoint *inJoint) +{ +#ifdef _B3D_READER_DEBUG + core::stringc logStr; + for (u32 i = 1; i < B3dStack.size(); ++i) + logStr += "-"; + logStr += "read ChunkMESH"; + os::Printer::log(logStr.c_str(), ELL_DEBUG); +#endif + + s32 brushID; + B3DFile->read(&brushID, sizeof(brushID)); +#ifdef __BIG_ENDIAN__ + brushID = os::Byteswap::byteswap(brushID); +#endif + + NormalsInFile = false; + HasVertexColors = false; + + while ((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) // this chunk repeats + { + SB3dChunkHeader header; + B3DFile->read(&header, sizeof(header)); +#ifdef __BIG_ENDIAN__ + header.size = os::Byteswap::byteswap(header.size); +#endif + + B3dStack.push_back(SB3dChunk(header, B3DFile->getPos() - 8)); + + if (strncmp(B3dStack.getLast().name, "VRTS", 4) == 0) { + if (!readChunkVRTS(inJoint)) + return false; + } else if (strncmp(B3dStack.getLast().name, "TRIS", 4) == 0) { + scene::SSkinMeshBuffer *meshBuffer = AnimatedMesh->addMeshBuffer(); + + if (brushID == -1) { /* ok */ + } else if (brushID < 0 || (u32)brushID >= Materials.size()) { + os::Printer::log("Illegal brush ID found", B3DFile->getFileName(), ELL_ERROR); + return false; + } else { + meshBuffer->Material = Materials[brushID].Material; + } + + if (readChunkTRIS(meshBuffer, AnimatedMesh->getMeshBuffers().size() - 1, VerticesStart) == false) + return false; + + if (!NormalsInFile) { + s32 i; + + for (i = 0; i < (s32)meshBuffer->Indices.size(); i += 3) { + core::plane3df p(meshBuffer->getVertex(meshBuffer->Indices[i + 0])->Pos, + meshBuffer->getVertex(meshBuffer->Indices[i + 1])->Pos, + meshBuffer->getVertex(meshBuffer->Indices[i + 2])->Pos); + + meshBuffer->getVertex(meshBuffer->Indices[i + 0])->Normal += p.Normal; + meshBuffer->getVertex(meshBuffer->Indices[i + 1])->Normal += p.Normal; + meshBuffer->getVertex(meshBuffer->Indices[i + 2])->Normal += p.Normal; + } + + for (i = 0; i < (s32)meshBuffer->getVertexCount(); ++i) { + meshBuffer->getVertex(i)->Normal.normalize(); + BaseVertices[VerticesStart + i].Normal = meshBuffer->getVertex(i)->Normal; + } + } + } else { + os::Printer::log("Unknown chunk found in mesh - skipping"); + if (!B3DFile->seek(B3dStack.getLast().startposition + B3dStack.getLast().length)) + return false; + B3dStack.erase(B3dStack.size() - 1); + } + } + + B3dStack.erase(B3dStack.size() - 1); + + return true; +} + +/* +VRTS: + int flags ;1=normal values present, 2=rgba values present + int tex_coord_sets ;texture coords per vertex (eg: 1 for simple U/V) max=8 + but we only support 3 + int tex_coord_set_size ;components per set (eg: 2 for simple U/V) max=4 + { + float x,y,z ;always present + float nx,ny,nz ;vertex normal: present if (flags&1) + float red,green,blue,alpha ;vertex color: present if (flags&2) + float tex_coords[tex_coord_sets][tex_coord_set_size] ;tex coords + } +*/ +bool CB3DMeshFileLoader::readChunkVRTS(CSkinnedMesh::SJoint *inJoint) +{ +#ifdef _B3D_READER_DEBUG + core::stringc logStr; + for (u32 i = 1; i < B3dStack.size(); ++i) + logStr += "-"; + logStr += "ChunkVRTS"; + os::Printer::log(logStr.c_str(), ELL_DEBUG); +#endif + + const s32 max_tex_coords = 3; + s32 flags, tex_coord_sets, tex_coord_set_size; + + B3DFile->read(&flags, sizeof(flags)); + B3DFile->read(&tex_coord_sets, sizeof(tex_coord_sets)); + B3DFile->read(&tex_coord_set_size, sizeof(tex_coord_set_size)); +#ifdef __BIG_ENDIAN__ + flags = os::Byteswap::byteswap(flags); + tex_coord_sets = os::Byteswap::byteswap(tex_coord_sets); + tex_coord_set_size = os::Byteswap::byteswap(tex_coord_set_size); +#endif + + if (tex_coord_sets < 0 || tex_coord_set_size < 0 || + tex_coord_sets >= max_tex_coords || tex_coord_set_size >= 4) // Something is wrong + { + os::Printer::log("tex_coord_sets or tex_coord_set_size too big", B3DFile->getFileName(), ELL_ERROR); + return false; + } + + //------ Allocate Memory, for speed -----------// + + s32 numberOfReads = 3; + + if (flags & 1) { + NormalsInFile = true; + numberOfReads += 3; + } + if (flags & 2) { + numberOfReads += 4; + HasVertexColors = true; + } + + numberOfReads += tex_coord_sets * tex_coord_set_size; + + const s32 memoryNeeded = (B3dStack.getLast().length / sizeof(f32)) / numberOfReads; + + BaseVertices.reallocate(memoryNeeded + BaseVertices.size() + 1); + AnimatedVertices_VertexID.reallocate(memoryNeeded + AnimatedVertices_VertexID.size() + 1); + + //--------------------------------------------// + + while ((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) // this chunk repeats + { + f32 position[3]; + f32 normal[3] = {0.f, 0.f, 0.f}; + f32 color[4] = {1.0f, 1.0f, 1.0f, 1.0f}; + f32 tex_coords[max_tex_coords][4]; + + readFloats(position, 3); + + if (flags & 1) + readFloats(normal, 3); + if (flags & 2) + readFloats(color, 4); + + for (s32 i = 0; i < tex_coord_sets; ++i) + readFloats(tex_coords[i], tex_coord_set_size); + + f32 tu = 0.0f, tv = 0.0f; + if (tex_coord_sets >= 1 && tex_coord_set_size >= 2) { + tu = tex_coords[0][0]; + tv = tex_coords[0][1]; + } + + f32 tu2 = 0.0f, tv2 = 0.0f; + if (tex_coord_sets > 1 && tex_coord_set_size > 1) { + tu2 = tex_coords[1][0]; + tv2 = tex_coords[1][1]; + } + + // Create Vertex... + video::S3DVertex2TCoords Vertex(position[0], position[1], position[2], + normal[0], normal[1], normal[2], + video::SColorf(color[0], color[1], color[2], color[3]).toSColor(), + tu, tv, tu2, tv2); + + // Transform the Vertex position by nested node... + inJoint->GlobalMatrix.transformVect(Vertex.Pos); + inJoint->GlobalMatrix.rotateVect(Vertex.Normal); + + // Add it... + BaseVertices.push_back(Vertex); + + AnimatedVertices_VertexID.push_back(-1); + AnimatedVertices_BufferID.push_back(-1); + } + + B3dStack.erase(B3dStack.size() - 1); + + return true; +} + +bool CB3DMeshFileLoader::readChunkTRIS(scene::SSkinMeshBuffer *meshBuffer, u32 meshBufferID, s32 vertices_Start) +{ +#ifdef _B3D_READER_DEBUG + core::stringc logStr; + for (u32 i = 1; i < B3dStack.size(); ++i) + logStr += "-"; + logStr += "ChunkTRIS"; + os::Printer::log(logStr.c_str(), ELL_DEBUG); +#endif + + bool showVertexWarning = false; + + s32 triangle_brush_id; // Note: Irrlicht can't have different brushes for each triangle (using a workaround) + B3DFile->read(&triangle_brush_id, sizeof(triangle_brush_id)); +#ifdef __BIG_ENDIAN__ + triangle_brush_id = os::Byteswap::byteswap(triangle_brush_id); +#endif + + SB3dMaterial *B3dMaterial; + + if (triangle_brush_id == -1) + B3dMaterial = 0; + else if (triangle_brush_id < 0 || (u32)triangle_brush_id >= Materials.size()) { + os::Printer::log("Illegal material index found", B3DFile->getFileName(), ELL_ERROR); + return false; + } else { + B3dMaterial = &Materials[triangle_brush_id]; + meshBuffer->Material = B3dMaterial->Material; + } + + const s32 memoryNeeded = B3dStack.getLast().length / sizeof(s32); + meshBuffer->Indices.reallocate(memoryNeeded + meshBuffer->Indices.size() + 1); + + while ((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) // this chunk repeats + { + s32 vertex_id[3]; + + B3DFile->read(vertex_id, 3 * sizeof(s32)); +#ifdef __BIG_ENDIAN__ + vertex_id[0] = os::Byteswap::byteswap(vertex_id[0]); + vertex_id[1] = os::Byteswap::byteswap(vertex_id[1]); + vertex_id[2] = os::Byteswap::byteswap(vertex_id[2]); +#endif + + // Make Ids global: + vertex_id[0] += vertices_Start; + vertex_id[1] += vertices_Start; + vertex_id[2] += vertices_Start; + + for (s32 i = 0; i < 3; ++i) { + if ((u32)vertex_id[i] >= AnimatedVertices_VertexID.size()) { + os::Printer::log("Illegal vertex index found", B3DFile->getFileName(), ELL_ERROR); + return false; + } + + if (AnimatedVertices_VertexID[vertex_id[i]] != -1) { + if (AnimatedVertices_BufferID[vertex_id[i]] != (s32)meshBufferID) { // If this vertex is linked in a different meshbuffer + AnimatedVertices_VertexID[vertex_id[i]] = -1; + AnimatedVertices_BufferID[vertex_id[i]] = -1; + showVertexWarning = true; + } + } + if (AnimatedVertices_VertexID[vertex_id[i]] == -1) { // If this vertex is not in the meshbuffer + // Check for lightmapping: + if (BaseVertices[vertex_id[i]].TCoords2 != core::vector2df(0.f, 0.f)) + meshBuffer->convertTo2TCoords(); // Will only affect the meshbuffer the first time this is called + + // Add the vertex to the meshbuffer: + if (meshBuffer->VertexType == video::EVT_STANDARD) + meshBuffer->Vertices_Standard.push_back(BaseVertices[vertex_id[i]]); + else + meshBuffer->Vertices_2TCoords.push_back(BaseVertices[vertex_id[i]]); + + // create vertex id to meshbuffer index link: + AnimatedVertices_VertexID[vertex_id[i]] = meshBuffer->getVertexCount() - 1; + AnimatedVertices_BufferID[vertex_id[i]] = meshBufferID; + + if (B3dMaterial) { + // Apply Material/Color/etc... + video::S3DVertex *Vertex = meshBuffer->getVertex(meshBuffer->getVertexCount() - 1); + + if (!HasVertexColors) + Vertex->Color = B3dMaterial->Material.DiffuseColor; + else if (Vertex->Color.getAlpha() == 255) + Vertex->Color.setAlpha((s32)(B3dMaterial->alpha * 255.0f)); + + // Use texture's scale + if (B3dMaterial->Textures[0]) { + Vertex->TCoords.X *= B3dMaterial->Textures[0]->Xscale; + Vertex->TCoords.Y *= B3dMaterial->Textures[0]->Yscale; + } + /* + if (B3dMaterial->Textures[1]) + { + Vertex->TCoords2.X *=B3dMaterial->Textures[1]->Xscale; + Vertex->TCoords2.Y *=B3dMaterial->Textures[1]->Yscale; + } + */ + } + } + } + + meshBuffer->Indices.push_back(AnimatedVertices_VertexID[vertex_id[0]]); + meshBuffer->Indices.push_back(AnimatedVertices_VertexID[vertex_id[1]]); + meshBuffer->Indices.push_back(AnimatedVertices_VertexID[vertex_id[2]]); + } + + B3dStack.erase(B3dStack.size() - 1); + + if (showVertexWarning) + os::Printer::log("B3dMeshLoader: Warning, different meshbuffers linking to the same vertex, this will cause problems with animated meshes"); + + return true; +} + +bool CB3DMeshFileLoader::readChunkBONE(CSkinnedMesh::SJoint *inJoint) +{ +#ifdef _B3D_READER_DEBUG + core::stringc logStr; + for (u32 i = 1; i < B3dStack.size(); ++i) + logStr += "-"; + logStr += "read ChunkBONE"; + os::Printer::log(logStr.c_str(), ELL_DEBUG); +#endif + + if (B3dStack.getLast().length > 8) { + while ((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) // this chunk repeats + { + u32 globalVertexID; + f32 strength; + B3DFile->read(&globalVertexID, sizeof(globalVertexID)); + B3DFile->read(&strength, sizeof(strength)); +#ifdef __BIG_ENDIAN__ + globalVertexID = os::Byteswap::byteswap(globalVertexID); + strength = os::Byteswap::byteswap(strength); +#endif + globalVertexID += VerticesStart; + + if (globalVertexID >= AnimatedVertices_VertexID.size()) { + os::Printer::log("Illegal vertex index found", B3DFile->getFileName(), ELL_ERROR); + return false; + } + + if (AnimatedVertices_VertexID[globalVertexID] == -1) { + os::Printer::log("B3dMeshLoader: Weight has bad vertex id (no link to meshbuffer index found)"); + } else if (strength > 0) { + CSkinnedMesh::SWeight *weight = AnimatedMesh->addWeight(inJoint); + weight->strength = strength; + // Find the meshbuffer and Vertex index from the Global Vertex ID: + weight->vertex_id = AnimatedVertices_VertexID[globalVertexID]; + weight->buffer_id = AnimatedVertices_BufferID[globalVertexID]; + } + } + } + + B3dStack.erase(B3dStack.size() - 1); + return true; +} + +bool CB3DMeshFileLoader::readChunkKEYS(CSkinnedMesh::SJoint *inJoint) +{ +#ifdef _B3D_READER_DEBUG + // Only print first, that's just too much output otherwise + if (!inJoint || (inJoint->PositionKeys.empty() && inJoint->ScaleKeys.empty() && inJoint->RotationKeys.empty())) { + core::stringc logStr; + for (u32 i = 1; i < B3dStack.size(); ++i) + logStr += "-"; + logStr += "read ChunkKEYS"; + os::Printer::log(logStr.c_str(), ELL_DEBUG); + } +#endif + + s32 flags; + B3DFile->read(&flags, sizeof(flags)); +#ifdef __BIG_ENDIAN__ + flags = os::Byteswap::byteswap(flags); +#endif + + CSkinnedMesh::SPositionKey *oldPosKey = 0; + core::vector3df oldPos[2]; + CSkinnedMesh::SScaleKey *oldScaleKey = 0; + core::vector3df oldScale[2]; + CSkinnedMesh::SRotationKey *oldRotKey = 0; + core::quaternion oldRot[2]; + bool isFirst[3] = {true, true, true}; + while ((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) // this chunk repeats + { + s32 frame; + + B3DFile->read(&frame, sizeof(frame)); +#ifdef __BIG_ENDIAN__ + frame = os::Byteswap::byteswap(frame); +#endif + + // Add key frames, frames in Irrlicht are zero-based + f32 data[4]; + if (flags & 1) { + readFloats(data, 3); + if ((oldPosKey != 0) && (oldPos[0] == oldPos[1])) { + const core::vector3df pos(data[0], data[1], data[2]); + if (oldPos[1] == pos) + oldPosKey->frame = (f32)frame - 1; + else { + oldPos[0] = oldPos[1]; + oldPosKey = AnimatedMesh->addPositionKey(inJoint); + oldPosKey->frame = (f32)frame - 1; + oldPos[1].set(oldPosKey->position.set(pos)); + } + } else if (oldPosKey == 0 && isFirst[0]) { + oldPosKey = AnimatedMesh->addPositionKey(inJoint); + oldPosKey->frame = (f32)frame - 1; + oldPos[0].set(oldPosKey->position.set(data[0], data[1], data[2])); + oldPosKey = 0; + isFirst[0] = false; + } else { + if (oldPosKey != 0) + oldPos[0] = oldPos[1]; + oldPosKey = AnimatedMesh->addPositionKey(inJoint); + oldPosKey->frame = (f32)frame - 1; + oldPos[1].set(oldPosKey->position.set(data[0], data[1], data[2])); + } + } + if (flags & 2) { + readFloats(data, 3); + if ((oldScaleKey != 0) && (oldScale[0] == oldScale[1])) { + const core::vector3df scale(data[0], data[1], data[2]); + if (oldScale[1] == scale) + oldScaleKey->frame = (f32)frame - 1; + else { + oldScale[0] = oldScale[1]; + oldScaleKey = AnimatedMesh->addScaleKey(inJoint); + oldScaleKey->frame = (f32)frame - 1; + oldScale[1].set(oldScaleKey->scale.set(scale)); + } + } else if (oldScaleKey == 0 && isFirst[1]) { + oldScaleKey = AnimatedMesh->addScaleKey(inJoint); + oldScaleKey->frame = (f32)frame - 1; + oldScale[0].set(oldScaleKey->scale.set(data[0], data[1], data[2])); + oldScaleKey = 0; + isFirst[1] = false; + } else { + if (oldScaleKey != 0) + oldScale[0] = oldScale[1]; + oldScaleKey = AnimatedMesh->addScaleKey(inJoint); + oldScaleKey->frame = (f32)frame - 1; + oldScale[1].set(oldScaleKey->scale.set(data[0], data[1], data[2])); + } + } + if (flags & 4) { + readFloats(data, 4); + if ((oldRotKey != 0) && (oldRot[0] == oldRot[1])) { + // meant to be in this order since b3d stores W first + const core::quaternion rot(data[1], data[2], data[3], data[0]); + if (oldRot[1] == rot) + oldRotKey->frame = (f32)frame - 1; + else { + oldRot[0] = oldRot[1]; + oldRotKey = AnimatedMesh->addRotationKey(inJoint); + oldRotKey->frame = (f32)frame - 1; + oldRot[1].set(oldRotKey->rotation.set(data[1], data[2], data[3], data[0])); + oldRot[1].normalize(); + } + } else if (oldRotKey == 0 && isFirst[2]) { + oldRotKey = AnimatedMesh->addRotationKey(inJoint); + oldRotKey->frame = (f32)frame - 1; + // meant to be in this order since b3d stores W first + oldRot[0].set(oldRotKey->rotation.set(data[1], data[2], data[3], data[0])); + oldRot[0].normalize(); + oldRotKey = 0; + isFirst[2] = false; + } else { + if (oldRotKey != 0) + oldRot[0] = oldRot[1]; + oldRotKey = AnimatedMesh->addRotationKey(inJoint); + oldRotKey->frame = (f32)frame - 1; + // meant to be in this order since b3d stores W first + oldRot[1].set(oldRotKey->rotation.set(data[1], data[2], data[3], data[0])); + oldRot[1].normalize(); + } + } + } + + B3dStack.erase(B3dStack.size() - 1); + return true; +} + +bool CB3DMeshFileLoader::readChunkANIM() +{ +#ifdef _B3D_READER_DEBUG + core::stringc logStr; + for (u32 i = 1; i < B3dStack.size(); ++i) + logStr += "-"; + logStr += "read ChunkANIM"; + os::Printer::log(logStr.c_str(), ELL_DEBUG); +#endif + + s32 animFlags; // not stored\used + s32 animFrames; // not stored\used + f32 animFPS; // not stored\used + + B3DFile->read(&animFlags, sizeof(s32)); + B3DFile->read(&animFrames, sizeof(s32)); + readFloats(&animFPS, 1); + if (animFPS > 0.f) + AnimatedMesh->setAnimationSpeed(animFPS); + os::Printer::log("FPS", io::path((double)animFPS), ELL_DEBUG); + +#ifdef __BIG_ENDIAN__ + animFlags = os::Byteswap::byteswap(animFlags); + animFrames = os::Byteswap::byteswap(animFrames); +#endif + + B3dStack.erase(B3dStack.size() - 1); + return true; +} + +bool CB3DMeshFileLoader::readChunkTEXS() +{ +#ifdef _B3D_READER_DEBUG + core::stringc logStr; + for (u32 i = 1; i < B3dStack.size(); ++i) + logStr += "-"; + logStr += "read ChunkTEXS"; + os::Printer::log(logStr.c_str(), ELL_DEBUG); +#endif + + while ((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) // this chunk repeats + { + Textures.push_back(SB3dTexture()); + SB3dTexture &B3dTexture = Textures.getLast(); + + B3dTexture.TextureName = readString(); + std::replace(B3dTexture.TextureName.begin(), B3dTexture.TextureName.end(), '\\', '/'); +#ifdef _B3D_READER_DEBUG + os::Printer::log("read Texture", B3dTexture.TextureName.c_str(), ELL_DEBUG); +#endif + + B3DFile->read(&B3dTexture.Flags, sizeof(s32)); + B3DFile->read(&B3dTexture.Blend, sizeof(s32)); +#ifdef __BIG_ENDIAN__ + B3dTexture.Flags = os::Byteswap::byteswap(B3dTexture.Flags); + B3dTexture.Blend = os::Byteswap::byteswap(B3dTexture.Blend); +#endif +#ifdef _B3D_READER_DEBUG + os::Printer::log("Flags", core::stringc(B3dTexture.Flags).c_str(), ELL_DEBUG); + os::Printer::log("Blend", core::stringc(B3dTexture.Blend).c_str(), ELL_DEBUG); +#endif + readFloats(&B3dTexture.Xpos, 1); + readFloats(&B3dTexture.Ypos, 1); + readFloats(&B3dTexture.Xscale, 1); + readFloats(&B3dTexture.Yscale, 1); + readFloats(&B3dTexture.Angle, 1); + } + + B3dStack.erase(B3dStack.size() - 1); + + return true; +} + +bool CB3DMeshFileLoader::readChunkBRUS() +{ +#ifdef _B3D_READER_DEBUG + core::stringc logStr; + for (u32 i = 1; i < B3dStack.size(); ++i) + logStr += "-"; + logStr += "read ChunkBRUS"; + os::Printer::log(logStr.c_str(), ELL_DEBUG); +#endif + + u32 n_texs; + B3DFile->read(&n_texs, sizeof(u32)); +#ifdef __BIG_ENDIAN__ + n_texs = os::Byteswap::byteswap(n_texs); +#endif + + // number of texture ids read for Irrlicht + const u32 num_textures = core::min_(n_texs, video::MATERIAL_MAX_TEXTURES); + // number of bytes to skip (for ignored texture ids) + const u32 n_texs_offset = (num_textures < n_texs) ? (n_texs - num_textures) : 0; + + while ((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) // this chunk repeats + { + // This is what blitz basic calls a brush, like a Irrlicht Material + + auto name = readString(); +#ifdef _B3D_READER_DEBUG + os::Printer::log("read Material", name.c_str(), ELL_DEBUG); +#endif + Materials.push_back(SB3dMaterial()); + SB3dMaterial &B3dMaterial = Materials.getLast(); + + readFloats(&B3dMaterial.red, 1); + readFloats(&B3dMaterial.green, 1); + readFloats(&B3dMaterial.blue, 1); + readFloats(&B3dMaterial.alpha, 1); + readFloats(&B3dMaterial.shininess, 1); + + B3DFile->read(&B3dMaterial.blend, sizeof(B3dMaterial.blend)); + B3DFile->read(&B3dMaterial.fx, sizeof(B3dMaterial.fx)); +#ifdef __BIG_ENDIAN__ + B3dMaterial.blend = os::Byteswap::byteswap(B3dMaterial.blend); + B3dMaterial.fx = os::Byteswap::byteswap(B3dMaterial.fx); +#endif +#ifdef _B3D_READER_DEBUG + os::Printer::log("Blend", core::stringc(B3dMaterial.blend).c_str(), ELL_DEBUG); + os::Printer::log("FX", core::stringc(B3dMaterial.fx).c_str(), ELL_DEBUG); +#endif + + u32 i; + for (i = 0; i < num_textures; ++i) { + s32 texture_id = -1; + B3DFile->read(&texture_id, sizeof(s32)); +#ifdef __BIG_ENDIAN__ + texture_id = os::Byteswap::byteswap(texture_id); +#endif + //--- Get pointers to the texture, based on the IDs --- + if ((u32)texture_id < Textures.size()) { + B3dMaterial.Textures[i] = &Textures[texture_id]; +#ifdef _B3D_READER_DEBUG + os::Printer::log("Layer", core::stringc(i).c_str(), ELL_DEBUG); + os::Printer::log("using texture", Textures[texture_id].TextureName.c_str(), ELL_DEBUG); +#endif + } else + B3dMaterial.Textures[i] = 0; + } + // skip other texture ids + for (i = 0; i < n_texs_offset; ++i) { + s32 texture_id = -1; + B3DFile->read(&texture_id, sizeof(s32)); +#ifdef __BIG_ENDIAN__ + texture_id = os::Byteswap::byteswap(texture_id); +#endif + if (ShowWarning && (texture_id != -1) && (n_texs > video::MATERIAL_MAX_TEXTURES)) { + os::Printer::log("Too many textures used in one material", B3DFile->getFileName(), ELL_WARNING); + ShowWarning = false; + } + } + + // Fixes problems when the lightmap is on the first texture: + if (B3dMaterial.Textures[0] != 0) { + if (B3dMaterial.Textures[0]->Flags & 65536) { // 65536 = secondary UV + SB3dTexture *TmpTexture; + TmpTexture = B3dMaterial.Textures[1]; + B3dMaterial.Textures[1] = B3dMaterial.Textures[0]; + B3dMaterial.Textures[0] = TmpTexture; + } + } + + // If a preceeding texture slot is empty move the others down: + for (i = num_textures; i > 0; --i) { + for (u32 j = i - 1; j < num_textures - 1; ++j) { + if (B3dMaterial.Textures[j + 1] != 0 && B3dMaterial.Textures[j] == 0) { + B3dMaterial.Textures[j] = B3dMaterial.Textures[j + 1]; + B3dMaterial.Textures[j + 1] = 0; + } + } + } + + //------ Convert blitz flags/blend to irrlicht ------- + + // Two textures: + if (B3dMaterial.Textures[1]) { + B3dMaterial.Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; + B3dMaterial.Material.ZWriteEnable = video::EZW_OFF; + } else if (B3dMaterial.Textures[0]) { // One texture: + // Flags & 0x1 is usual SOLID, 0x8 is mipmap (handled before) + if (B3dMaterial.Textures[0]->Flags & 0x2) { // (Alpha mapped) + B3dMaterial.Material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; + B3dMaterial.Material.ZWriteEnable = video::EZW_OFF; + } else if (B3dMaterial.Textures[0]->Flags & 0x4) //(Masked) + B3dMaterial.Material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; // TODO: create color key texture + else if (B3dMaterial.alpha == 1.f) + B3dMaterial.Material.MaterialType = video::EMT_SOLID; + else { + B3dMaterial.Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; + B3dMaterial.Material.ZWriteEnable = video::EZW_OFF; + } + } else // No texture: + { + if (B3dMaterial.alpha == 1.f) + B3dMaterial.Material.MaterialType = video::EMT_SOLID; + else { + B3dMaterial.Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; + B3dMaterial.Material.ZWriteEnable = video::EZW_OFF; + } + } + + B3dMaterial.Material.DiffuseColor = video::SColorf(B3dMaterial.red, B3dMaterial.green, B3dMaterial.blue, B3dMaterial.alpha).toSColor(); + B3dMaterial.Material.ColorMaterial = video::ECM_NONE; + + //------ Material fx ------ + + if (B3dMaterial.fx & 1) { // full-bright + B3dMaterial.Material.AmbientColor = video::SColor(255, 255, 255, 255); + B3dMaterial.Material.Lighting = false; + } else + B3dMaterial.Material.AmbientColor = B3dMaterial.Material.DiffuseColor; + + if (B3dMaterial.fx & 2) // use vertex colors instead of brush color + B3dMaterial.Material.ColorMaterial = video::ECM_DIFFUSE_AND_AMBIENT; + + if (B3dMaterial.fx & 4) // flatshaded + B3dMaterial.Material.GouraudShading = false; + + if (B3dMaterial.fx & 16) // disable backface culling + B3dMaterial.Material.BackfaceCulling = false; + + if (B3dMaterial.fx & 32) { // force vertex alpha-blending + B3dMaterial.Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; + B3dMaterial.Material.ZWriteEnable = video::EZW_OFF; + } + + B3dMaterial.Material.Shininess = B3dMaterial.shininess; + } + + B3dStack.erase(B3dStack.size() - 1); + + return true; +} + +std::string CB3DMeshFileLoader::readString() +{ + std::string newstring = ""; + while (true) { + c8 character; + if (B3DFile->read(&character, sizeof(character)) == 0) + break; // eof + if (character == 0) + break; + newstring.push_back(character); + } + return newstring; +} + +void CB3DMeshFileLoader::readFloats(f32 *vec, u32 count) +{ + B3DFile->read(vec, count * sizeof(f32)); +#ifdef __BIG_ENDIAN__ + for (u32 n = 0; n < count; ++n) + vec[n] = os::Byteswap::byteswap(vec[n]); +#endif +} + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CB3DMeshFileLoader.h b/irr/src/CB3DMeshFileLoader.h new file mode 100644 index 000000000..808b68170 --- /dev/null +++ b/irr/src/CB3DMeshFileLoader.h @@ -0,0 +1,79 @@ +// Copyright (C) 2006-2012 Luke Hoschke +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +// B3D Mesh loader +// File format designed by Mark Sibly for the Blitz3D engine and has been +// declared public domain + +#pragma once + +#include "IMeshLoader.h" +#include "ISceneManager.h" +#include "CSkinnedMesh.h" +#include "SB3DStructs.h" +#include "IReadFile.h" + +namespace irr +{ + +namespace scene +{ + +//! Meshloader for B3D format +class CB3DMeshFileLoader : public IMeshLoader +{ +public: + //! Constructor + CB3DMeshFileLoader(scene::ISceneManager *smgr); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".bsp") + bool isALoadableFileExtension(const io::path &filename) const override; + + //! creates/loads an animated mesh from the file. + //! \return Pointer to the created mesh. Returns 0 if loading failed. + //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). + //! See IReferenceCounted::drop() for more information. + IAnimatedMesh *createMesh(io::IReadFile *file) override; + +private: + bool load(); + bool readChunkNODE(CSkinnedMesh::SJoint *InJoint); + bool readChunkMESH(CSkinnedMesh::SJoint *InJoint); + bool readChunkVRTS(CSkinnedMesh::SJoint *InJoint); + bool readChunkTRIS(scene::SSkinMeshBuffer *MeshBuffer, u32 MeshBufferID, s32 Vertices_Start); + bool readChunkBONE(CSkinnedMesh::SJoint *InJoint); + bool readChunkKEYS(CSkinnedMesh::SJoint *InJoint); + bool readChunkANIM(); + bool readChunkTEXS(); + bool readChunkBRUS(); + + std::string readString(); + void readFloats(f32 *vec, u32 count); + + core::array B3dStack; + + core::array Materials; + core::array Textures; + + core::array AnimatedVertices_VertexID; + + core::array AnimatedVertices_BufferID; + + core::array BaseVertices; + + CSkinnedMesh *AnimatedMesh; + io::IReadFile *B3DFile; + + // B3Ds have Vertex ID's local within the mesh I don't want this + // Variable needs to be class member due to recursion in calls + u32 VerticesStart; + + bool NormalsInFile; + bool HasVertexColors; + bool ShowWarning; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CBillboardSceneNode.cpp b/irr/src/CBillboardSceneNode.cpp new file mode 100644 index 000000000..ddb9d465a --- /dev/null +++ b/irr/src/CBillboardSceneNode.cpp @@ -0,0 +1,266 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CBillboardSceneNode.h" +#include "IVideoDriver.h" +#include "ISceneManager.h" +#include "ICameraSceneNode.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CBillboardSceneNode::CBillboardSceneNode(ISceneNode *parent, ISceneManager *mgr, s32 id, + const core::vector3df &position, const core::dimension2d &size, + video::SColor colorTop, video::SColor colorBottom) : + IBillboardSceneNode(parent, mgr, id, position), + Buffer(new SMeshBuffer()) +{ +#ifdef _DEBUG + setDebugName("CBillboardSceneNode"); +#endif + + setSize(size); + + Buffer->Vertices.set_used(4); + Buffer->Indices.set_used(6); + + Buffer->Indices[0] = 0; + Buffer->Indices[1] = 2; + Buffer->Indices[2] = 1; + Buffer->Indices[3] = 0; + Buffer->Indices[4] = 3; + Buffer->Indices[5] = 2; + + Buffer->Vertices[0].TCoords.set(1.0f, 1.0f); + Buffer->Vertices[0].Color = colorBottom; + + Buffer->Vertices[1].TCoords.set(1.0f, 0.0f); + Buffer->Vertices[1].Color = colorTop; + + Buffer->Vertices[2].TCoords.set(0.0f, 0.0f); + Buffer->Vertices[2].Color = colorTop; + + Buffer->Vertices[3].TCoords.set(0.0f, 1.0f); + Buffer->Vertices[3].Color = colorBottom; +} + +CBillboardSceneNode::~CBillboardSceneNode() +{ + Buffer->drop(); +} + +//! pre render event +void CBillboardSceneNode::OnRegisterSceneNode() +{ + if (IsVisible) + SceneManager->registerNodeForRendering(this); + + ISceneNode::OnRegisterSceneNode(); +} + +//! render +void CBillboardSceneNode::render() +{ + video::IVideoDriver *driver = SceneManager->getVideoDriver(); + ICameraSceneNode *camera = SceneManager->getActiveCamera(); + + if (!camera || !driver) + return; + + // make billboard look to camera + updateMesh(camera); + + driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); + driver->setMaterial(Buffer->Material); + driver->drawMeshBuffer(Buffer); + + if (DebugDataVisible & scene::EDS_BBOX) { + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); + video::SMaterial m; + m.Lighting = false; + driver->setMaterial(m); + driver->draw3DBox(BBoxSafe, video::SColor(0, 208, 195, 152)); + } +} + +void CBillboardSceneNode::updateMesh(const irr::scene::ICameraSceneNode *camera) +{ + // billboard looks toward camera + core::vector3df pos = getAbsolutePosition(); + + core::vector3df campos = camera->getAbsolutePosition(); + core::vector3df target = camera->getTarget(); + core::vector3df up = camera->getUpVector(); + core::vector3df view = target - campos; + view.normalize(); + + core::vector3df horizontal = up.crossProduct(view); + if (horizontal.getLength() == 0) { + horizontal.set(up.Y, up.X, up.Z); + } + horizontal.normalize(); + core::vector3df topHorizontal = horizontal * 0.5f * TopEdgeWidth; + horizontal *= 0.5f * Size.Width; + + // pointing down! + core::vector3df vertical = horizontal.crossProduct(view); + vertical.normalize(); + vertical *= 0.5f * Size.Height; + + view *= -1.0f; + + core::array &vertices = Buffer->Vertices; + + for (s32 i = 0; i < 4; ++i) + vertices[i].Normal = view; + + /* Vertices are: + 2--1 + |\ | + | \| + 3--0 + */ + vertices[0].Pos = pos + horizontal + vertical; + vertices[1].Pos = pos + topHorizontal - vertical; + vertices[2].Pos = pos - topHorizontal - vertical; + vertices[3].Pos = pos - horizontal + vertical; + + Buffer->setDirty(EBT_VERTEX); + Buffer->recalculateBoundingBox(); +} + +//! returns the axis aligned bounding box of this node +const core::aabbox3d &CBillboardSceneNode::getBoundingBox() const +{ + // Really wrong when scaled (as the node does not scale it's vertices - maybe it should?) + return BBoxSafe; +} + +const core::aabbox3d &CBillboardSceneNode::getTransformedBillboardBoundingBox(const irr::scene::ICameraSceneNode *camera) +{ + updateMesh(camera); + return Buffer->BoundingBox; +} + +void CBillboardSceneNode::setSize(const core::dimension2d &size) +{ + Size = size; + + if (core::equals(Size.Width, 0.0f)) + Size.Width = 1.0f; + TopEdgeWidth = Size.Width; + + if (core::equals(Size.Height, 0.0f)) + Size.Height = 1.0f; + + const f32 extent = 0.5f * sqrtf(Size.Width * Size.Width + Size.Height * Size.Height); + BBoxSafe.MinEdge.set(-extent, -extent, -extent); + BBoxSafe.MaxEdge.set(extent, extent, extent); +} + +void CBillboardSceneNode::setSize(f32 height, f32 bottomEdgeWidth, f32 topEdgeWidth) +{ + Size.set(bottomEdgeWidth, height); + TopEdgeWidth = topEdgeWidth; + + if (core::equals(Size.Height, 0.0f)) + Size.Height = 1.0f; + + if (core::equals(Size.Width, 0.f) && core::equals(TopEdgeWidth, 0.f)) { + Size.Width = 1.0f; + TopEdgeWidth = 1.0f; + } + + const f32 extent = 0.5f * sqrtf(Size.Width * Size.Width + Size.Height * Size.Height); + BBoxSafe.MinEdge.set(-extent, -extent, -extent); + BBoxSafe.MaxEdge.set(extent, extent, extent); +} + +video::SMaterial &CBillboardSceneNode::getMaterial(u32 i) +{ + return Buffer->Material; +} + +//! returns amount of materials used by this scene node. +u32 CBillboardSceneNode::getMaterialCount() const +{ + return 1; +} + +//! gets the size of the billboard +const core::dimension2d &CBillboardSceneNode::getSize() const +{ + return Size; +} + +//! Gets the widths of the top and bottom edges of the billboard. +void CBillboardSceneNode::getSize(f32 &height, f32 &bottomEdgeWidth, + f32 &topEdgeWidth) const +{ + height = Size.Height; + bottomEdgeWidth = Size.Width; + topEdgeWidth = TopEdgeWidth; +} + +//! Set the color of all vertices of the billboard +//! \param overallColor: the color to set +void CBillboardSceneNode::setColor(const video::SColor &overallColor) +{ + for (u32 vertex = 0; vertex < 4; ++vertex) + Buffer->Vertices[vertex].Color = overallColor; +} + +//! Set the color of the top and bottom vertices of the billboard +//! \param topColor: the color to set the top vertices +//! \param bottomColor: the color to set the bottom vertices +void CBillboardSceneNode::setColor(const video::SColor &topColor, + const video::SColor &bottomColor) +{ + Buffer->Vertices[0].Color = bottomColor; + Buffer->Vertices[1].Color = topColor; + Buffer->Vertices[2].Color = topColor; + Buffer->Vertices[3].Color = bottomColor; +} + +//! Gets the color of the top and bottom vertices of the billboard +//! \param[out] topColor: stores the color of the top vertices +//! \param[out] bottomColor: stores the color of the bottom vertices +void CBillboardSceneNode::getColor(video::SColor &topColor, + video::SColor &bottomColor) const +{ + bottomColor = Buffer->Vertices[0].Color; + topColor = Buffer->Vertices[1].Color; +} + +//! Creates a clone of this scene node and its children. +ISceneNode *CBillboardSceneNode::clone(ISceneNode *newParent, ISceneManager *newManager) +{ + if (!newParent) + newParent = Parent; + if (!newManager) + newManager = SceneManager; + + CBillboardSceneNode *nb = new CBillboardSceneNode(newParent, + newManager, ID, RelativeTranslation, Size); + + nb->cloneMembers(this, newManager); + nb->Buffer->Material = Buffer->Material; + nb->Size = Size; + nb->TopEdgeWidth = this->TopEdgeWidth; + + video::SColor topColor, bottomColor; + getColor(topColor, bottomColor); + nb->setColor(topColor, bottomColor); + + if (newParent) + nb->drop(); + return nb; +} + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CBillboardSceneNode.h b/irr/src/CBillboardSceneNode.h new file mode 100644 index 000000000..f0d7f9dcf --- /dev/null +++ b/irr/src/CBillboardSceneNode.h @@ -0,0 +1,113 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IBillboardSceneNode.h" +#include "SMeshBuffer.h" + +namespace irr +{ +namespace scene +{ + +//! Scene node which is a billboard. A billboard is like a 3d sprite: A 2d element, +//! which always looks to the camera. +class CBillboardSceneNode : virtual public IBillboardSceneNode +{ +public: + //! constructor + CBillboardSceneNode(ISceneNode *parent, ISceneManager *mgr, s32 id, + const core::vector3df &position, const core::dimension2d &size, + video::SColor colorTop = video::SColor(0xFFFFFFFF), + video::SColor colorBottom = video::SColor(0xFFFFFFFF)); + + virtual ~CBillboardSceneNode(); + + //! pre render event + void OnRegisterSceneNode() override; + + //! render + void render() override; + + //! returns the axis aligned bounding box of this node + const core::aabbox3d &getBoundingBox() const override; + + //! sets the size of the billboard + void setSize(const core::dimension2d &size) override; + + //! Sets the widths of the top and bottom edges of the billboard independently. + void setSize(f32 height, f32 bottomEdgeWidth, f32 topEdgeWidth) override; + + //! gets the size of the billboard + const core::dimension2d &getSize() const override; + + //! Gets the widths of the top and bottom edges of the billboard. + void getSize(f32 &height, f32 &bottomEdgeWidth, f32 &topEdgeWidth) const override; + + video::SMaterial &getMaterial(u32 i) override; + + //! returns amount of materials used by this scene node. + u32 getMaterialCount() const override; + + //! Set the color of all vertices of the billboard + //! \param overallColor: the color to set + void setColor(const video::SColor &overallColor) override; + + //! Set the color of the top and bottom vertices of the billboard + //! \param topColor: the color to set the top vertices + //! \param bottomColor: the color to set the bottom vertices + virtual void setColor(const video::SColor &topColor, + const video::SColor &bottomColor) override; + + //! Gets the color of the top and bottom vertices of the billboard + //! \param[out] topColor: stores the color of the top vertices + //! \param[out] bottomColor: stores the color of the bottom vertices + virtual void getColor(video::SColor &topColor, + video::SColor &bottomColor) const override; + + //! Get the real boundingbox used by the billboard (which depends on the active camera) + const core::aabbox3d &getTransformedBillboardBoundingBox(const irr::scene::ICameraSceneNode *camera) override; + + //! Get the amount of mesh buffers. + u32 getMeshBufferCount() const override + { + return Buffer ? 1 : 0; + } + + //! Get pointer to the mesh buffer. + IMeshBuffer *getMeshBuffer(u32 nr) const override + { + if (nr == 0) + return Buffer; + return 0; + } + + //! Returns type of the scene node + ESCENE_NODE_TYPE getType() const override { return ESNT_BILLBOARD; } + + //! Creates a clone of this scene node and its children. + ISceneNode *clone(ISceneNode *newParent = 0, ISceneManager *newManager = 0) override; + +protected: + void updateMesh(const irr::scene::ICameraSceneNode *camera); + +private: + //! Size.Width is the bottom edge width + core::dimension2d Size; + f32 TopEdgeWidth; + + //! BoundingBox which is large enough to contain the billboard independent of the camera + // TODO: BUG - still can be wrong with scaling < 1. Billboards should calculate relative coordinates for their mesh + // and then use the node-scaling. But needs some work... + /** Note that we can't use the real boundingbox for culling because at that point + the camera which is used to calculate the billboard is not yet updated. So we only + know the real boundingbox after rendering - which is too late for culling. */ + core::aabbox3d BBoxSafe; + + scene::SMeshBuffer *Buffer; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CBlit.h b/irr/src/CBlit.h new file mode 100644 index 000000000..90450ec2f --- /dev/null +++ b/irr/src/CBlit.h @@ -0,0 +1,942 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "SoftwareDriver2_helper.h" + +namespace irr +{ + +//! f18 - fixpoint 14.18 limit to 16k Textures +#define CBLIT_USE_FIXPOINT18 + +#if defined(CBLIT_USE_FIXPOINT18) +typedef int f18; +#define f18_one 262144 +#define f18_zero 0 +#define f32_to_f18(x) ((f18)floorf(((x) * 262144.f) + 0.f)) +#define f32_to_f32(x) (x) +#define f18_floor(x) ((x) >> 18) +#define f18_round(x) ((x + 131.072) >> 18) +#else +typedef float f18; +#define f18_one 1.f +#define f18_zero_dot_five 0.5f +#define f18_zero 0.f +#define f32_to_f18(x) (x) +#define f32_to_f32(x) (x) +#define f18_floor(x) ((int)(x)) +#define f18_round(x) ((int)(x + 0.5f)) +#endif + +struct SBlitJob +{ + AbsRectangle Dest; + AbsRectangle Source; + + u32 argb; + + const void *src; + void *dst; + + u32 width; // draw size + u32 height; + + u32 srcPixelMul; // pixel byte size + u32 dstPixelMul; + + int srcPitch; // scanline byte size. allow negative for mirror + u32 dstPitch; + + bool stretch; + f32 x_stretch; + f32 y_stretch; +}; + +// Bitfields Cohen Sutherland +enum eClipCode +{ + CLIPCODE_EMPTY = 0, + CLIPCODE_BOTTOM = 1, + CLIPCODE_TOP = 2, + CLIPCODE_LEFT = 4, + CLIPCODE_RIGHT = 8 +}; + +inline u32 GetClipCode(const AbsRectangle &r, const core::position2d &p) +{ + u32 code = CLIPCODE_EMPTY; + + if (p.X < r.x0) + code = CLIPCODE_LEFT; + else if (p.X > r.x1) + code = CLIPCODE_RIGHT; + + if (p.Y < r.y0) + code |= CLIPCODE_TOP; + else if (p.Y > r.y1) + code |= CLIPCODE_BOTTOM; + + return code; +} + +/* + */ +inline void GetClip(AbsRectangle &clipping, video::IImage *t) +{ + clipping.x0 = 0; + clipping.y0 = 0; + clipping.x1 = t->getDimension().Width - 1; + clipping.y1 = t->getDimension().Height - 1; +} + +/* + return alpha in [0;256] Granularity from 32-Bit ARGB + add highbit alpha ( alpha > 127 ? + 1 ) +*/ +static inline u32 extractAlpha(const u32 c) +{ + return (c >> 24) + (c >> 31); +} + +/* + return alpha in [0;255] Granularity and 32-Bit ARGB + add highbit alpha ( alpha > 127 ? + 1 ) +*/ +static inline u32 packAlpha(const u32 c) +{ + return (c > 127 ? c - 1 : c) << 24; +} + +/*! + Scale Color by (1/value) + value 0 - 256 ( alpha ) +*/ +inline u32 PixelLerp32(const u32 source, const u32 value) +{ + u32 srcRB = source & 0x00FF00FF; + u32 srcXG = (source & 0xFF00FF00) >> 8; + + srcRB *= value; + srcXG *= value; + + srcRB >>= 8; + // srcXG >>= 8; + + srcXG &= 0xFF00FF00; + srcRB &= 0x00FF00FF; + + return srcRB | srcXG; +} + +/*! + */ +static void executeBlit_TextureCopy_x_to_x(const SBlitJob *job) +{ + if (job->stretch) { + const f18 wscale = f32_to_f18(job->x_stretch); + const f18 hscale = f32_to_f18(job->y_stretch); + + f18 src_y = f18_zero; + + if (job->srcPixelMul == 4) { + const u32 *src = (u32 *)(job->src); + u32 *dst = (u32 *)(job->dst); + + for (u32 dy = 0; dy < job->height; ++dy, src_y += hscale) { + src = (u32 *)((u8 *)(job->src) + job->srcPitch * f18_floor(src_y)); + + f18 src_x = f18_zero; + for (u32 dx = 0; dx < job->width; ++dx, src_x += wscale) { + dst[dx] = src[f18_floor(src_x)]; + } + dst = (u32 *)((u8 *)(dst) + job->dstPitch); + } + } else if (job->srcPixelMul == 2) { + const u16 *src = (u16 *)(job->src); + u16 *dst = (u16 *)(job->dst); + + for (u32 dy = 0; dy < job->height; ++dy, src_y += hscale) { + src = (u16 *)((u8 *)(job->src) + job->srcPitch * f18_floor(src_y)); + + f18 src_x = f18_zero; + for (u32 dx = 0; dx < job->width; ++dx, src_x += wscale) { + dst[dx] = src[f18_floor(src_x)]; + } + dst = (u16 *)((u8 *)(dst) + job->dstPitch); + } + } + } else { + const size_t widthPitch = job->width * job->dstPixelMul; + const void *src = (void *)job->src; + void *dst = (void *)job->dst; + + for (u32 dy = 0; dy < job->height; ++dy) { + memcpy(dst, src, widthPitch); + + src = (void *)((u8 *)(src) + job->srcPitch); + dst = (void *)((u8 *)(dst) + job->dstPitch); + } + } +} + +/*! + */ +static void executeBlit_TextureCopy_32_to_16(const SBlitJob *job) +{ + const u32 w = job->width; + const u32 h = job->height; + const u32 *src = static_cast(job->src); + u16 *dst = static_cast(job->dst); + + if (job->stretch) { + const float wscale = job->x_stretch; + const float hscale = job->y_stretch; + + for (u32 dy = 0; dy < h; ++dy) { + const u32 src_y = (u32)(dy * hscale); + src = (u32 *)((u8 *)(job->src) + job->srcPitch * src_y); + + for (u32 dx = 0; dx < w; ++dx) { + const u32 src_x = (u32)(dx * wscale); + // 16 bit Blitter depends on pre-multiplied color + const u32 s = PixelLerp32(src[src_x] | 0xFF000000, extractAlpha(src[src_x])); + dst[dx] = video::A8R8G8B8toA1R5G5B5(s); + } + dst = (u16 *)((u8 *)(dst) + job->dstPitch); + } + } else { + for (u32 dy = 0; dy != h; ++dy) { + for (u32 dx = 0; dx != w; ++dx) { + // 16 bit Blitter depends on pre-multiplied color + const u32 s = PixelLerp32(src[dx] | 0xFF000000, extractAlpha(src[dx])); + dst[dx] = video::A8R8G8B8toA1R5G5B5(s); + } + + src = (u32 *)((u8 *)(src) + job->srcPitch); + dst = (u16 *)((u8 *)(dst) + job->dstPitch); + } + } +} + +/*! + */ +static void executeBlit_TextureCopy_24_to_16(const SBlitJob *job) +{ + const u32 w = job->width; + const u32 h = job->height; + const u8 *src = static_cast(job->src); + u16 *dst = static_cast(job->dst); + + if (job->stretch) { + const float wscale = job->x_stretch * 3.f; + const float hscale = job->y_stretch; + + for (u32 dy = 0; dy < h; ++dy) { + const u32 src_y = (u32)(dy * hscale); + src = (u8 *)(job->src) + job->srcPitch * src_y; + + for (u32 dx = 0; dx < w; ++dx) { + const u8 *src_x = src + (u32)(dx * wscale); + dst[dx] = video::RGBA16(src_x[0], src_x[1], src_x[2]); + } + dst = (u16 *)((u8 *)(dst) + job->dstPitch); + } + } else { + for (u32 dy = 0; dy != h; ++dy) { + const u8 *s = src; + for (u32 dx = 0; dx != w; ++dx) { + dst[dx] = video::RGBA16(s[0], s[1], s[2]); + s += 3; + } + + src = src + job->srcPitch; + dst = (u16 *)((u8 *)(dst) + job->dstPitch); + } + } +} + +/*! + */ +static void executeBlit_TextureCopy_16_to_32(const SBlitJob *job) +{ + const u32 w = job->width; + const u32 h = job->height; + const u16 *src = static_cast(job->src); + u32 *dst = static_cast(job->dst); + + if (job->stretch) { + const float wscale = job->x_stretch; + const float hscale = job->y_stretch; + + for (u32 dy = 0; dy < h; ++dy) { + const u32 src_y = (u32)(dy * hscale); + src = (u16 *)((u8 *)(job->src) + job->srcPitch * src_y); + + for (u32 dx = 0; dx < w; ++dx) { + const u32 src_x = (u32)(dx * wscale); + dst[dx] = video::A1R5G5B5toA8R8G8B8(src[src_x]); + } + dst = (u32 *)((u8 *)(dst) + job->dstPitch); + } + } else { + for (u32 dy = 0; dy != h; ++dy) { + for (u32 dx = 0; dx != w; ++dx) { + dst[dx] = video::A1R5G5B5toA8R8G8B8(src[dx]); + } + + src = (u16 *)((u8 *)(src) + job->srcPitch); + dst = (u32 *)((u8 *)(dst) + job->dstPitch); + } + } +} + +static void executeBlit_TextureCopy_16_to_24(const SBlitJob *job) +{ + const u32 w = job->width; + const u32 h = job->height; + const u16 *src = static_cast(job->src); + u8 *dst = static_cast(job->dst); + + if (job->stretch) { + const float wscale = job->x_stretch; + const float hscale = job->y_stretch; + + for (u32 dy = 0; dy < h; ++dy) { + const u32 src_y = (u32)(dy * hscale); + src = (u16 *)((u8 *)(job->src) + job->srcPitch * src_y); + + for (u32 dx = 0; dx < w; ++dx) { + const u32 src_x = (u32)(dx * wscale); + u32 color = video::A1R5G5B5toA8R8G8B8(src[src_x]); + u8 *writeTo = &dst[dx * 3]; + *writeTo++ = (color >> 16) & 0xFF; + *writeTo++ = (color >> 8) & 0xFF; + *writeTo++ = color & 0xFF; + } + dst += job->dstPitch; + } + } else { + for (u32 dy = 0; dy != h; ++dy) { + for (u32 dx = 0; dx != w; ++dx) { + u32 color = video::A1R5G5B5toA8R8G8B8(src[dx]); + u8 *writeTo = &dst[dx * 3]; + *writeTo++ = (color >> 16) & 0xFF; + *writeTo++ = (color >> 8) & 0xFF; + *writeTo++ = color & 0xFF; + } + + src = (u16 *)((u8 *)(src) + job->srcPitch); + dst += job->dstPitch; + } + } +} + +/*! + */ +static void executeBlit_TextureCopy_24_to_32(const SBlitJob *job) +{ + const u32 w = job->width; + const u32 h = job->height; + const u8 *src = static_cast(job->src); + u32 *dst = static_cast(job->dst); + + if (job->stretch) { + const float wscale = job->x_stretch * 3.f; + const float hscale = job->y_stretch; + + for (u32 dy = 0; dy < h; ++dy) { + const u32 src_y = (u32)(dy * hscale); + src = (const u8 *)job->src + (job->srcPitch * src_y); + + for (u32 dx = 0; dx < w; ++dx) { + const u8 *s = src + (u32)(dx * wscale); + dst[dx] = 0xFF000000 | s[0] << 16 | s[1] << 8 | s[2]; + } + dst = (u32 *)((u8 *)(dst) + job->dstPitch); + } + } else { + for (u32 dy = 0; dy < job->height; ++dy) { + const u8 *s = src; + + for (u32 dx = 0; dx < job->width; ++dx) { + dst[dx] = 0xFF000000 | s[0] << 16 | s[1] << 8 | s[2]; + s += 3; + } + + src = src + job->srcPitch; + dst = (u32 *)((u8 *)(dst) + job->dstPitch); + } + } +} + +static void executeBlit_TextureCopy_32_to_24(const SBlitJob *job) +{ + const u32 w = job->width; + const u32 h = job->height; + const u32 *src = static_cast(job->src); + u8 *dst = static_cast(job->dst); + + if (job->stretch) { + const float wscale = job->x_stretch; + const float hscale = job->y_stretch; + + for (u32 dy = 0; dy < h; ++dy) { + const u32 src_y = (u32)(dy * hscale); + src = (u32 *)((u8 *)(job->src) + job->srcPitch * src_y); + + for (u32 dx = 0; dx < w; ++dx) { + const u32 src_x = src[(u32)(dx * wscale)]; + u8 *writeTo = &dst[dx * 3]; + *writeTo++ = (src_x >> 16) & 0xFF; + *writeTo++ = (src_x >> 8) & 0xFF; + *writeTo++ = src_x & 0xFF; + } + dst += job->dstPitch; + } + } else { + for (u32 dy = 0; dy != h; ++dy) { + for (u32 dx = 0; dx != w; ++dx) { + u8 *writeTo = &dst[dx * 3]; + *writeTo++ = (src[dx] >> 16) & 0xFF; + *writeTo++ = (src[dx] >> 8) & 0xFF; + *writeTo++ = src[dx] & 0xFF; + } + + src = (u32 *)((u8 *)(src) + job->srcPitch); + dst += job->dstPitch; + } + } +} + +/*! + */ +static void executeBlit_TextureBlend_16_to_16(const SBlitJob *job) +{ + const f18 wscale = f32_to_f18(job->x_stretch); + const f18 hscale = f32_to_f18(job->y_stretch); + + f18 src_y = f18_zero; + u16 *dst = (u16 *)job->dst; + + for (u32 dy = 0; dy < job->height; ++dy, src_y += hscale) { + const u16 *src = (u16 *)((u8 *)(job->src) + job->srcPitch * f18_floor(src_y)); + f18 src_x = f18_zero; + for (u32 dx = 0; dx < job->width; ++dx, src_x += wscale) { + dst[dx] = PixelBlend16(dst[dx], src[f18_floor(src_x)]); + } + dst = (u16 *)((u8 *)(dst) + job->dstPitch); + } +} + +/*! + */ +static void executeBlit_TextureBlend_32_to_32(const SBlitJob *job) +{ + const f18 wscale = f32_to_f18(job->x_stretch); + const f18 hscale = f32_to_f18(job->y_stretch); + + f18 src_y = f18_zero; + u32 *dst = (u32 *)job->dst; + for (u32 dy = 0; dy < job->height; ++dy, src_y += hscale) { + const u32 *src = (u32 *)((u8 *)(job->src) + job->srcPitch * f18_floor(src_y)); + + f18 src_x = f18_zero; + for (u32 dx = 0; dx < job->width; ++dx, src_x += wscale) { + dst[dx] = PixelBlend32(dst[dx], src[f18_floor(src_x)]); + } + dst = (u32 *)((u8 *)(dst) + job->dstPitch); + } +} + +/*! + */ +static void executeBlit_TextureBlendColor_16_to_16(const SBlitJob *job) +{ + const u16 blend = video::A8R8G8B8toA1R5G5B5(job->argb); + + const f18 wscale = f32_to_f18(job->x_stretch); + const f18 hscale = f32_to_f18(job->y_stretch); + + f18 src_y = f18_zero; + u16 *dst = (u16 *)job->dst; + for (u32 dy = 0; dy < job->height; ++dy, src_y += hscale) { + const u16 *src = (u16 *)((u8 *)(job->src) + job->srcPitch * f18_floor(src_y)); + f18 src_x = f18_zero; + for (u32 dx = 0; dx < job->width; ++dx, src_x += wscale) { + u16 c0 = src[f18_floor(src_x)]; + if (0 == (c0 & 0x8000)) + continue; + + dst[dx] = PixelMul16_2(c0, blend); + } + dst = (u16 *)((u8 *)(dst) + job->dstPitch); + } +} + +/*! + */ +static void executeBlit_TextureBlendColor_32_to_32(const SBlitJob *job) +{ + const f18 wscale = f32_to_f18(job->x_stretch); + const f18 hscale = f32_to_f18(job->y_stretch); + + u32 *dst = (u32 *)job->dst; + f18 src_y = f18_zero; + for (u32 dy = 0; dy < job->height; ++dy, src_y += hscale) { + const u32 *src = (u32 *)((u8 *)(job->src) + job->srcPitch * f18_floor(src_y)); + + f18 src_x = f18_zero; + for (u32 dx = 0; dx < job->width; ++dx, src_x += wscale) { + dst[dx] = PixelBlend32(dst[dx], PixelMul32_2(src[f18_floor(src_x)], job->argb)); + } + dst = (u32 *)((u8 *)(dst) + job->dstPitch); + } +} + +/*! + */ +static void executeBlit_Color_16_to_16(const SBlitJob *job) +{ + const u16 c = video::A8R8G8B8toA1R5G5B5(job->argb); + u16 *dst = (u16 *)job->dst; + + for (u32 dy = 0; dy < job->height; ++dy) { + memset16(dst, c, job->srcPitch); + dst = (u16 *)((u8 *)(dst) + job->dstPitch); + } +} + +/*! + */ +static void executeBlit_Color_32_to_32(const SBlitJob *job) +{ + u32 *dst = (u32 *)job->dst; + + for (u32 dy = 0; dy < job->height; ++dy) { + memset32(dst, job->argb, job->srcPitch); + dst = (u32 *)((u8 *)(dst) + job->dstPitch); + } +} + +/*! + */ +static void executeBlit_ColorAlpha_16_to_16(const SBlitJob *job) +{ + u16 *dst = (u16 *)job->dst; + + const u16 alpha = extractAlpha(job->argb) >> 3; + if (0 == alpha) + return; + const u32 src = video::A8R8G8B8toA1R5G5B5(job->argb); + + for (u32 dy = 0; dy != job->height; ++dy) { + for (u32 dx = 0; dx != job->width; ++dx) { + dst[dx] = PixelBlend16(dst[dx], src, alpha); + } + dst = (u16 *)((u8 *)(dst) + job->dstPitch); + } +} + +/*! + */ +static void executeBlit_ColorAlpha_32_to_32(const SBlitJob *job) +{ + const u32 alpha = extractAlpha(job->argb); + if (0 == alpha) + return; + + u32 *dst = (u32 *)job->dst; + for (u32 dy = 0; dy < job->height; ++dy) { + for (u32 dx = 0; dx < job->width; ++dx) { + dst[dx] = PixelBlend32(dst[dx], job->argb, alpha); + } + dst = (u32 *)((u8 *)(dst) + job->dstPitch); + } +} + +/*! + Pixel => + color = sourceAlpha > 0 ? source, else dest + alpha = max(destAlpha, sourceAlpha) +*/ +inline u16 PixelCombine16(const u16 c2, const u16 c1) +{ + if (video::getAlpha(c1) > 0) + return c1; + else + return c2; +} + +/*! + Combine alpha channels (increases alpha / reduces transparency) +*/ +static void executeBlit_TextureCombineColor_16_to_16(const SBlitJob *job) +{ + const u32 w = job->width * 2; + const u32 h = job->height * 2; + u16 *src = (u16 *)job->src; + u16 *dst = (u16 *)job->dst; + + const u16 jobColor = video::A8R8G8B8toA1R5G5B5(job->argb); + + /* + Stretch not supported. + */ + for (u32 dy = 0; dy != h; dy++) { + for (u32 dx = 0; dx != w; dx++) { + const u16 src_x = src[dx]; + const u16 dst_x = dst[dx]; + dst[dx] = PixelCombine16(dst_x, PixelMul16_2(src_x, jobColor)); + } + src = (u16 *)((u8 *)(src) + job->srcPitch); + dst = (u16 *)((u8 *)(dst) + job->dstPitch); + } +} + +/*! + Combine alpha channels (increases alpha / reduces transparency) +*/ +static void executeBlit_TextureCombineColor_16_to_24(const SBlitJob *job) +{ + const u32 w = job->width; + const u32 h = job->height; + const u16 *src = static_cast(job->src); + u8 *dst = static_cast(job->dst); + + const u16 jobColor = video::A8R8G8B8toA1R5G5B5(job->argb); + + if (job->stretch) { + const float wscale = job->x_stretch; + const float hscale = job->y_stretch; + + for (u32 dy = 0; dy < h; ++dy) { + const u32 src_y = (u32)(dy * hscale); + src = (u16 *)((u8 *)(job->src) + job->srcPitch * src_y); + + for (u32 dx = 0; dx < w; ++dx) { + const u32 src_x = (u32)(dx * wscale); + u32 color = PixelMul16_2(video::A1R5G5B5toA8R8G8B8(src[src_x]), jobColor); + u8 *writeTo = &dst[dx * 3]; + if (video::getAlpha(src[src_x]) > 0) { // only overlay if source has visible alpha (alpha == 1) + *writeTo++ = (color >> 16) & 0xFF; + *writeTo++ = (color >> 8) & 0xFF; + *writeTo++ = color & 0xFF; + } + } + dst += job->dstPitch; + } + } else { + for (u32 dy = 0; dy != h; ++dy) { + for (u32 dx = 0; dx != w; ++dx) { + u32 color = PixelMul16_2(video::A1R5G5B5toA8R8G8B8(src[dx]), jobColor); + u8 *writeTo = &dst[dx * 3]; + if (video::getAlpha(src[dx]) > 0) { // only overlay if source has visible alpha (alpha == 1) + *writeTo++ = (color >> 16) & 0xFF; + *writeTo++ = (color >> 8) & 0xFF; + *writeTo++ = color & 0xFF; + } + } + + src = (u16 *)((u8 *)(src) + job->srcPitch); + dst += job->dstPitch; + } + } +} + +/*! + Pixel => + color = dest * ( 1 - SourceAlpha ) + source * SourceAlpha, + alpha = destAlpha * ( 1 - SourceAlpha ) + sourceAlpha + + where "1" means "full scale" (255) +*/ +inline u32 PixelCombine32(const u32 c2, const u32 c1) +{ + // alpha test + u32 alpha = c1 & 0xFF000000; + + if (0 == alpha) + return c2; + if (0xFF000000 == alpha) { + return c1; + } + + alpha >>= 24; + + // add highbit alpha, if ( alpha > 127 ) alpha += 1; + // stretches [0;255] to [0;256] to avoid division by 255. use division 256 == shr 8 + alpha += (alpha >> 7); + + u32 srcRB = c1 & 0x00FF00FF; + u32 srcXG = c1 & 0x0000FF00; + + u32 dstRB = c2 & 0x00FF00FF; + u32 dstXG = c2 & 0x0000FF00; + + u32 rb = srcRB - dstRB; + u32 xg = srcXG - dstXG; + + rb *= alpha; + xg *= alpha; + rb >>= 8; + xg >>= 8; + + rb += dstRB; + xg += dstXG; + + rb &= 0x00FF00FF; + xg &= 0x0000FF00; + + u32 sa = c1 >> 24; + u32 da = c2 >> 24; + u32 blendAlpha_fix8 = (sa * 256 + da * (256 - alpha)) >> 8; + return blendAlpha_fix8 << 24 | rb | xg; +} + +/*! + Combine alpha channels (increases alpha / reduces transparency) + Destination alpha is treated as full 255 +*/ +static void executeBlit_TextureCombineColor_32_to_24(const SBlitJob *job) +{ + const u32 w = job->width; + const u32 h = job->height; + const u32 *src = static_cast(job->src); + u8 *dst = static_cast(job->dst); + + if (job->stretch) { + const float wscale = job->x_stretch; + const float hscale = job->y_stretch; + + for (u32 dy = 0; dy < h; ++dy) { + const u32 src_y = (u32)(dy * hscale); + src = (u32 *)((u8 *)(job->src) + job->srcPitch * src_y); + + for (u32 dx = 0; dx < w; ++dx) { + const u32 src_x = src[(u32)(dx * wscale)]; + u8 *writeTo = &dst[dx * 3]; + const u32 dst_x = 0xFF000000 | writeTo[0] << 16 | writeTo[1] << 8 | writeTo[2]; + const u32 combo = PixelCombine32(dst_x, PixelMul32_2(src_x, job->argb)); + *writeTo++ = (combo >> 16) & 0xFF; + *writeTo++ = (combo >> 8) & 0xFF; + *writeTo++ = combo & 0xFF; + } + dst += job->dstPitch; + } + } else { + for (u32 dy = 0; dy != h; ++dy) { + for (u32 dx = 0; dx != w; ++dx) { + u8 *writeTo = &dst[dx * 3]; + const u32 dst_x = 0xFF000000 | writeTo[0] << 16 | writeTo[1] << 8 | writeTo[2]; + const u32 combo = PixelCombine32(dst_x, PixelMul32_2(src[dx], job->argb)); + *writeTo++ = (combo >> 16) & 0xFF; + *writeTo++ = (combo >> 8) & 0xFF; + *writeTo++ = combo & 0xFF; + } + + src = (u32 *)((u8 *)(src) + job->srcPitch); + dst += job->dstPitch; + } + } +} + +/*! + Combine alpha channels (increases alpha / reduces transparency) +*/ +static void executeBlit_TextureCombineColor_32_to_32(const SBlitJob *job) +{ + u32 *src = (u32 *)job->src; + u32 *dst = (u32 *)job->dst; + + for (u32 dy = 0; dy != job->height; ++dy) { + for (u32 dx = 0; dx != job->width; ++dx) { + dst[dx] = PixelCombine32(dst[dx], PixelMul32_2(src[dx], job->argb)); + } + src = (u32 *)((u8 *)(src) + job->srcPitch); + dst = (u32 *)((u8 *)(dst) + job->dstPitch); + } +} + +// Blitter Operation +enum eBlitter +{ + BLITTER_INVALID = 0, + BLITTER_COLOR, + BLITTER_COLOR_ALPHA, + BLITTER_TEXTURE, + BLITTER_TEXTURE_ALPHA_BLEND, + BLITTER_TEXTURE_ALPHA_COLOR_BLEND, + BLITTER_TEXTURE_COMBINE_ALPHA, +}; + +typedef void (*tExecuteBlit)(const SBlitJob *job); + +/*! + */ +struct blitterTable +{ + eBlitter operation; + s32 destFormat; + s32 sourceFormat; + tExecuteBlit func; +}; + +static const blitterTable blitTable[] = { + {BLITTER_TEXTURE, -2, -2, executeBlit_TextureCopy_x_to_x}, + {BLITTER_TEXTURE, video::ECF_A1R5G5B5, video::ECF_A8R8G8B8, executeBlit_TextureCopy_32_to_16}, + {BLITTER_TEXTURE, video::ECF_A1R5G5B5, video::ECF_R8G8B8, executeBlit_TextureCopy_24_to_16}, + {BLITTER_TEXTURE, video::ECF_A8R8G8B8, video::ECF_A1R5G5B5, executeBlit_TextureCopy_16_to_32}, + {BLITTER_TEXTURE, video::ECF_A8R8G8B8, video::ECF_R8G8B8, executeBlit_TextureCopy_24_to_32}, + {BLITTER_TEXTURE, video::ECF_R8G8B8, video::ECF_A1R5G5B5, executeBlit_TextureCopy_16_to_24}, + {BLITTER_TEXTURE, video::ECF_R8G8B8, video::ECF_A8R8G8B8, executeBlit_TextureCopy_32_to_24}, + {BLITTER_TEXTURE_ALPHA_BLEND, video::ECF_A1R5G5B5, video::ECF_A1R5G5B5, executeBlit_TextureBlend_16_to_16}, + {BLITTER_TEXTURE_ALPHA_BLEND, video::ECF_A8R8G8B8, video::ECF_A8R8G8B8, executeBlit_TextureBlend_32_to_32}, + {BLITTER_TEXTURE_ALPHA_COLOR_BLEND, video::ECF_A1R5G5B5, video::ECF_A1R5G5B5, executeBlit_TextureBlendColor_16_to_16}, + {BLITTER_TEXTURE_ALPHA_COLOR_BLEND, video::ECF_A8R8G8B8, video::ECF_A8R8G8B8, executeBlit_TextureBlendColor_32_to_32}, + {BLITTER_COLOR, video::ECF_A1R5G5B5, -1, executeBlit_Color_16_to_16}, + {BLITTER_COLOR, video::ECF_A8R8G8B8, -1, executeBlit_Color_32_to_32}, + {BLITTER_COLOR_ALPHA, video::ECF_A1R5G5B5, -1, executeBlit_ColorAlpha_16_to_16}, + {BLITTER_COLOR_ALPHA, video::ECF_A8R8G8B8, -1, executeBlit_ColorAlpha_32_to_32}, + {BLITTER_TEXTURE_COMBINE_ALPHA, video::ECF_A8R8G8B8, video::ECF_A8R8G8B8, executeBlit_TextureCombineColor_32_to_32}, + {BLITTER_TEXTURE_COMBINE_ALPHA, video::ECF_A8R8G8B8, video::ECF_R8G8B8, executeBlit_TextureCopy_24_to_32}, + {BLITTER_TEXTURE_COMBINE_ALPHA, video::ECF_R8G8B8, video::ECF_A8R8G8B8, executeBlit_TextureCombineColor_32_to_24}, + {BLITTER_TEXTURE_COMBINE_ALPHA, video::ECF_R8G8B8, video::ECF_R8G8B8, executeBlit_TextureCopy_x_to_x}, + {BLITTER_TEXTURE_COMBINE_ALPHA, video::ECF_A1R5G5B5, video::ECF_R8G8B8, executeBlit_TextureCopy_24_to_16}, + {BLITTER_TEXTURE_COMBINE_ALPHA, video::ECF_A1R5G5B5, video::ECF_A1R5G5B5, executeBlit_TextureCombineColor_16_to_16}, + {BLITTER_TEXTURE_COMBINE_ALPHA, video::ECF_A1R5G5B5, video::ECF_R8G8B8, executeBlit_TextureCopy_24_to_16}, + {BLITTER_TEXTURE_COMBINE_ALPHA, video::ECF_R8G8B8, video::ECF_A1R5G5B5, executeBlit_TextureCombineColor_16_to_24}, + {BLITTER_INVALID, -1, -1, 0}, + }; + +static inline tExecuteBlit getBlitter2(eBlitter operation, const video::IImage *dest, const video::IImage *source) +{ + video::ECOLOR_FORMAT sourceFormat = (video::ECOLOR_FORMAT)(source ? source->getColorFormat() : -1); + video::ECOLOR_FORMAT destFormat = (video::ECOLOR_FORMAT)(dest ? dest->getColorFormat() : -1); + + const blitterTable *b = blitTable; + + while (b->operation != BLITTER_INVALID) { + if (b->operation == operation) { + if ((b->destFormat == -1 || b->destFormat == destFormat) && + (b->sourceFormat == -1 || b->sourceFormat == sourceFormat)) + return b->func; + else if (b->destFormat == -2 && (sourceFormat == destFormat)) + return b->func; + } + b += 1; + } + return 0; +} + +// bounce clipping to texture +inline void setClip(AbsRectangle &out, const core::rect *clip, + const video::IImage *tex, s32 passnative, const core::dimension2d *tex_org) +{ + if (0 == tex) { + if (clip && passnative) { + out.x0 = clip->UpperLeftCorner.X; + out.x1 = clip->LowerRightCorner.X; + out.y0 = clip->UpperLeftCorner.Y; + out.y1 = clip->LowerRightCorner.Y; + } else { + out.x0 = 0; + out.x1 = 0; + out.y0 = 0; + out.y1 = 0; + } + return; + } + + const s32 w = tex->getDimension().Width; + const s32 h = tex->getDimension().Height; + + // driver could have changed texture size. + if (clip && tex_org && ((u32)w != tex_org->Width || (u32)h != tex_org->Height)) { + out.x0 = core::s32_clamp((clip->UpperLeftCorner.X * w) / tex_org->Width, 0, w - 1); + out.x1 = core::s32_clamp((clip->LowerRightCorner.X * w) / tex_org->Width, out.x0, w); + out.y0 = core::s32_clamp((clip->UpperLeftCorner.Y * h) / tex_org->Height, 0, h - 1); + out.y1 = core::s32_clamp((clip->LowerRightCorner.Y * h) / tex_org->Height, out.y0, h); + } else if (clip) { + // y-1 to prevent starting on illegal memory (not ideal!). + out.x0 = core::s32_clamp(clip->UpperLeftCorner.X, 0, w - 1); + out.x1 = core::s32_clamp(clip->LowerRightCorner.X, passnative ? 0 : out.x0, w); + out.y0 = core::s32_clamp(clip->UpperLeftCorner.Y, 0, h - 1); + out.y1 = core::s32_clamp(clip->LowerRightCorner.Y, passnative ? 0 : out.y0, h); + } else { + out.x0 = 0; + out.y0 = 0; + out.x1 = w; + out.y1 = h; + } +} + +/*! + a generic 2D Blitter +*/ +static s32 Blit(eBlitter operation, + video::IImage *dest, + const core::rect *destClipping, + const core::position2d *destPos, + video::IImage *const source, + const core::rect *sourceClipping, + u32 argb) +{ + tExecuteBlit blitter = getBlitter2(operation, dest, source); + if (0 == blitter) { + return 0; + } + + // Clipping + AbsRectangle sourceClip; + AbsRectangle destClip; + AbsRectangle v; + + SBlitJob job; + + setClip(sourceClip, sourceClipping, source, 1, 0); + setClip(destClip, destClipping, dest, 0, 0); + + v.x0 = destPos ? destPos->X : 0; + v.y0 = destPos ? destPos->Y : 0; + v.x1 = v.x0 + (sourceClip.x1 - sourceClip.x0); + v.y1 = v.y0 + (sourceClip.y1 - sourceClip.y0); + + if (!intersect(job.Dest, destClip, v)) + return 0; + + job.width = job.Dest.x1 - job.Dest.x0; + job.height = job.Dest.y1 - job.Dest.y0; + + job.Source.x0 = sourceClip.x0 + (job.Dest.x0 - v.x0); + job.Source.x1 = job.Source.x0 + job.width; + job.Source.y0 = sourceClip.y0 + (job.Dest.y0 - v.y0); + job.Source.y1 = job.Source.y0 + job.height; + + job.argb = argb; + + job.stretch = false; + job.x_stretch = 1.f; + job.y_stretch = 1.f; + + if (source) { + job.srcPitch = source->getPitch(); + job.srcPixelMul = source->getBytesPerPixel(); + job.src = (void *)((u8 *)source->getData() + (job.Source.y0 * job.srcPitch) + (job.Source.x0 * job.srcPixelMul)); + } else { + // use srcPitch for color operation on dest + job.srcPitch = job.width * dest->getBytesPerPixel(); + } + + job.dstPitch = dest->getPitch(); + job.dstPixelMul = dest->getBytesPerPixel(); + job.dst = (void *)((u8 *)dest->getData() + (job.Dest.y0 * job.dstPitch) + (job.Dest.x0 * job.dstPixelMul)); + + blitter(&job); + + return 1; +} + +} diff --git a/irr/src/CBoneSceneNode.cpp b/irr/src/CBoneSceneNode.cpp new file mode 100644 index 000000000..b9eb8892e --- /dev/null +++ b/irr/src/CBoneSceneNode.cpp @@ -0,0 +1,89 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CBoneSceneNode.h" + +#include + +namespace irr +{ +namespace scene +{ + +//! constructor +CBoneSceneNode::CBoneSceneNode(ISceneNode *parent, ISceneManager *mgr, s32 id, + u32 boneIndex, const std::optional &boneName) : + IBoneSceneNode(parent, mgr, id), + BoneIndex(boneIndex), + AnimationMode(EBAM_AUTOMATIC), SkinningSpace(EBSS_LOCAL) +{ +#ifdef _DEBUG + setDebugName("CBoneSceneNode"); +#endif + setName(boneName); +} + +//! Returns the index of the bone +u32 CBoneSceneNode::getBoneIndex() const +{ + return BoneIndex; +} + +//! Sets the animation mode of the bone. Returns true if successful. +bool CBoneSceneNode::setAnimationMode(E_BONE_ANIMATION_MODE mode) +{ + AnimationMode = mode; + return true; +} + +//! Gets the current animation mode of the bone +E_BONE_ANIMATION_MODE CBoneSceneNode::getAnimationMode() const +{ + return AnimationMode; +} + +//! returns the axis aligned bounding box of this node +const core::aabbox3d &CBoneSceneNode::getBoundingBox() const +{ + return Box; +} + +/* +//! Returns the relative transformation of the scene node. +core::matrix4 CBoneSceneNode::getRelativeTransformation() const +{ + return core::matrix4(); // RelativeTransformation; +} +*/ + +void CBoneSceneNode::OnAnimate(u32 timeMs) +{ + if (IsVisible) { + // update absolute position + // updateAbsolutePosition(); + + // perform the post render process on all children + ISceneNodeList::iterator it = Children.begin(); + for (; it != Children.end(); ++it) + (*it)->OnAnimate(timeMs); + } +} + +void CBoneSceneNode::helper_updateAbsolutePositionOfAllChildren(ISceneNode *Node) +{ + Node->updateAbsolutePosition(); + + ISceneNodeList::const_iterator it = Node->getChildren().begin(); + for (; it != Node->getChildren().end(); ++it) { + helper_updateAbsolutePositionOfAllChildren((*it)); + } +} + +void CBoneSceneNode::updateAbsolutePositionOfAllChildren() +{ + helper_updateAbsolutePositionOfAllChildren(this); +} + +} // namespace scene +} // namespace irr diff --git a/irr/src/CBoneSceneNode.h b/irr/src/CBoneSceneNode.h new file mode 100644 index 000000000..8e1a0f7a1 --- /dev/null +++ b/irr/src/CBoneSceneNode.h @@ -0,0 +1,70 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +// Used with SkinnedMesh and IAnimatedMeshSceneNode, for boned meshes + +#include "IBoneSceneNode.h" + +#include + +namespace irr +{ +namespace scene +{ + +class CBoneSceneNode : public IBoneSceneNode +{ +public: + //! constructor + CBoneSceneNode(ISceneNode *parent, ISceneManager *mgr, + s32 id = -1, u32 boneIndex = 0, + const std::optional &boneName = std::nullopt); + + //! Returns the index of the bone + u32 getBoneIndex() const override; + + //! Sets the animation mode of the bone. Returns true if successful. + bool setAnimationMode(E_BONE_ANIMATION_MODE mode) override; + + //! Gets the current animation mode of the bone + E_BONE_ANIMATION_MODE getAnimationMode() const override; + + //! returns the axis aligned bounding box of this node + const core::aabbox3d &getBoundingBox() const override; + + /* + //! Returns the relative transformation of the scene node. + //core::matrix4 getRelativeTransformation() const override; + */ + + void OnAnimate(u32 timeMs) override; + + void updateAbsolutePositionOfAllChildren() override; + + //! How the relative transformation of the bone is used + void setSkinningSpace(E_BONE_SKINNING_SPACE space) override + { + SkinningSpace = space; + } + + E_BONE_SKINNING_SPACE getSkinningSpace() const override + { + return SkinningSpace; + } + +private: + void helper_updateAbsolutePositionOfAllChildren(ISceneNode *Node); + + u32 BoneIndex; + + core::aabbox3d Box; + + E_BONE_ANIMATION_MODE AnimationMode; + E_BONE_SKINNING_SPACE SkinningSpace; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CCameraSceneNode.cpp b/irr/src/CCameraSceneNode.cpp new file mode 100644 index 000000000..f8899e5ff --- /dev/null +++ b/irr/src/CCameraSceneNode.cpp @@ -0,0 +1,314 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CCameraSceneNode.h" +#include "ISceneManager.h" +#include "IVideoDriver.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CCameraSceneNode::CCameraSceneNode(ISceneNode *parent, ISceneManager *mgr, s32 id, + const core::vector3df &position, const core::vector3df &lookat) : + ICameraSceneNode(parent, mgr, id, position), + BoundingBox(core::vector3df(0, 0, 0)), // Camera has no size. Still not sure if FLT_MAX might be the better variant + Target(lookat), UpVector(0.0f, 1.0f, 0.0f), ZNear(1.0f), ZFar(3000.0f), + InputReceiverEnabled(true), TargetAndRotationAreBound(false) +{ +#ifdef _DEBUG + setDebugName("CCameraSceneNode"); +#endif + + // set default projection + Fovy = core::PI / 2.5f; // Field of view, in radians. + Aspect = 4.0f / 3.0f; // Aspect ratio. + + const video::IVideoDriver *const d = mgr ? mgr->getVideoDriver() : 0; + if (d) { + if (d->getCurrentRenderTargetSize().Height) + Aspect = (f32)d->getCurrentRenderTargetSize().Width / + (f32)d->getCurrentRenderTargetSize().Height; + } + + ViewArea.setFarNearDistance(ZFar - ZNear); + recalculateProjectionMatrix(); + recalculateViewArea(); +} + +//! Disables or enables the camera to get key or mouse inputs. +void CCameraSceneNode::setInputReceiverEnabled(bool enabled) +{ + InputReceiverEnabled = enabled; +} + +//! Returns if the input receiver of the camera is currently enabled. +bool CCameraSceneNode::isInputReceiverEnabled() const +{ + return InputReceiverEnabled; +} + +//! Sets the projection matrix of the camera. +/** The core::matrix4 class has some methods +to build a projection matrix. e.g: core::matrix4::buildProjectionMatrixPerspectiveFovLH +\param projection: The new projection matrix of the camera. */ +void CCameraSceneNode::setProjectionMatrix(const core::matrix4 &projection, bool isOrthogonal) +{ + IsOrthogonal = isOrthogonal; + ViewArea.getTransform(video::ETS_PROJECTION) = projection; +} + +//! Gets the current projection matrix of the camera +//! \return Returns the current projection matrix of the camera. +const core::matrix4 &CCameraSceneNode::getProjectionMatrix() const +{ + return ViewArea.getTransform(video::ETS_PROJECTION); +} + +//! Gets the current view matrix of the camera +//! \return Returns the current view matrix of the camera. +const core::matrix4 &CCameraSceneNode::getViewMatrix() const +{ + return ViewArea.getTransform(video::ETS_VIEW); +} + +//! Sets a custom view matrix affector. The matrix passed here, will be +//! multiplied with the view matrix when it gets updated. +//! This allows for custom camera setups like, for example, a reflection camera. +/** \param affector: The affector matrix. */ +void CCameraSceneNode::setViewMatrixAffector(const core::matrix4 &affector) +{ + Affector = affector; +} + +//! Gets the custom view matrix affector. +const core::matrix4 &CCameraSceneNode::getViewMatrixAffector() const +{ + return Affector; +} + +//! It is possible to send mouse and key events to the camera. Most cameras +//! may ignore this input, but camera scene nodes which are created for +//! example with scene::ISceneManager::addMayaCameraSceneNode or +//! scene::ISceneManager::addFPSCameraSceneNode, may want to get this input +//! for changing their position, look at target or whatever. +bool CCameraSceneNode::OnEvent(const SEvent &event) +{ + // animators have been deleted; nothing happens here now! + return false; +} + +//! sets the look at target of the camera +//! \param pos: Look at target of the camera. +void CCameraSceneNode::setTarget(const core::vector3df &pos) +{ + Target = pos; + + if (TargetAndRotationAreBound) { + const core::vector3df toTarget = Target - getAbsolutePosition(); + ISceneNode::setRotation(toTarget.getHorizontalAngle()); + } +} + +//! Sets the rotation of the node. +/** This only modifies the relative rotation of the node. +If the camera's target and rotation are bound ( @see bindTargetAndRotation() ) +then calling this will also change the camera's target to match the rotation. +\param rotation New rotation of the node in degrees. */ +void CCameraSceneNode::setRotation(const core::vector3df &rotation) +{ + if (TargetAndRotationAreBound) + Target = getAbsolutePosition() + rotation.rotationToDirection(); + + ISceneNode::setRotation(rotation); +} + +//! Gets the current look at target of the camera +//! \return Returns the current look at target of the camera +const core::vector3df &CCameraSceneNode::getTarget() const +{ + return Target; +} + +//! sets the up vector of the camera +//! \param pos: New upvector of the camera. +void CCameraSceneNode::setUpVector(const core::vector3df &pos) +{ + UpVector = pos; +} + +//! Gets the up vector of the camera. +//! \return Returns the up vector of the camera. +const core::vector3df &CCameraSceneNode::getUpVector() const +{ + return UpVector; +} + +f32 CCameraSceneNode::getNearValue() const +{ + return ZNear; +} + +f32 CCameraSceneNode::getFarValue() const +{ + return ZFar; +} + +f32 CCameraSceneNode::getAspectRatio() const +{ + return Aspect; +} + +f32 CCameraSceneNode::getFOV() const +{ + return Fovy; +} + +void CCameraSceneNode::setNearValue(f32 f) +{ + ZNear = f; + recalculateProjectionMatrix(); + ViewArea.setFarNearDistance(ZFar - ZNear); +} + +void CCameraSceneNode::setFarValue(f32 f) +{ + ZFar = f; + recalculateProjectionMatrix(); + ViewArea.setFarNearDistance(ZFar - ZNear); +} + +void CCameraSceneNode::setAspectRatio(f32 f) +{ + Aspect = f; + recalculateProjectionMatrix(); +} + +void CCameraSceneNode::setFOV(f32 f) +{ + Fovy = f; + recalculateProjectionMatrix(); +} + +void CCameraSceneNode::recalculateProjectionMatrix() +{ + ViewArea.getTransform(video::ETS_PROJECTION).buildProjectionMatrixPerspectiveFovLH(Fovy, Aspect, ZNear, ZFar, false); + IsOrthogonal = false; +} + +//! prerender +void CCameraSceneNode::OnRegisterSceneNode() +{ + if (SceneManager->getActiveCamera() == this) + SceneManager->registerNodeForRendering(this, ESNRP_CAMERA); + + ISceneNode::OnRegisterSceneNode(); +} + +//! render +void CCameraSceneNode::render() +{ + updateMatrices(); + + video::IVideoDriver *driver = SceneManager->getVideoDriver(); + if (driver) { + driver->setTransform(video::ETS_PROJECTION, ViewArea.getTransform(video::ETS_PROJECTION)); + driver->setTransform(video::ETS_VIEW, ViewArea.getTransform(video::ETS_VIEW)); + } +} + +//! update +void CCameraSceneNode::updateMatrices() +{ + core::vector3df pos = getAbsolutePosition(); + core::vector3df tgtv = Target - pos; + tgtv.normalize(); + + // if upvector and vector to the target are the same, we have a + // problem. so solve this problem: + core::vector3df up = UpVector; + up.normalize(); + + f32 dp = tgtv.dotProduct(up); + + if (core::equals(core::abs_(dp), 1.f)) { + up.X += 0.5f; + } + + ViewArea.getTransform(video::ETS_VIEW).buildCameraLookAtMatrixLH(pos, Target, up); + ViewArea.getTransform(video::ETS_VIEW) *= Affector; + recalculateViewArea(); +} + +//! returns the axis aligned bounding box of this node +const core::aabbox3d &CCameraSceneNode::getBoundingBox() const +{ + return BoundingBox; +} + +//! returns the view frustum. +const SViewFrustum *CCameraSceneNode::getViewFrustum() const +{ + return &ViewArea; +} + +void CCameraSceneNode::recalculateViewArea() +{ + ViewArea.cameraPosition = getAbsolutePosition(); + + core::matrix4 m(core::matrix4::EM4CONST_NOTHING); + m.setbyproduct_nocheck(ViewArea.getTransform(video::ETS_PROJECTION), + ViewArea.getTransform(video::ETS_VIEW)); + ViewArea.setFrom(m, false); +} + +//! Set the binding between the camera's rotation adn target. +void CCameraSceneNode::bindTargetAndRotation(bool bound) +{ + TargetAndRotationAreBound = bound; +} + +//! Gets the binding between the camera's rotation and target. +bool CCameraSceneNode::getTargetAndRotationBinding(void) const +{ + return TargetAndRotationAreBound; +} + +//! Creates a clone of this scene node and its children. +ISceneNode *CCameraSceneNode::clone(ISceneNode *newParent, ISceneManager *newManager) +{ + ICameraSceneNode::clone(newParent, newManager); + + if (!newParent) + newParent = Parent; + if (!newManager) + newManager = SceneManager; + + CCameraSceneNode *nb = new CCameraSceneNode(newParent, + newManager, ID, RelativeTranslation, Target); + + nb->ISceneNode::cloneMembers(this, newManager); + nb->ICameraSceneNode::cloneMembers(this); + + nb->Target = Target; + nb->UpVector = UpVector; + nb->Fovy = Fovy; + nb->Aspect = Aspect; + nb->ZNear = ZNear; + nb->ZFar = ZFar; + nb->ViewArea = ViewArea; + nb->Affector = Affector; + nb->InputReceiverEnabled = InputReceiverEnabled; + nb->TargetAndRotationAreBound = TargetAndRotationAreBound; + + if (newParent) + nb->drop(); + return nb; +} + +} // end namespace +} // end namespace diff --git a/irr/src/CCameraSceneNode.h b/irr/src/CCameraSceneNode.h new file mode 100644 index 000000000..668756300 --- /dev/null +++ b/irr/src/CCameraSceneNode.h @@ -0,0 +1,165 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "ICameraSceneNode.h" +#include "SViewFrustum.h" + +namespace irr +{ +namespace scene +{ + +class CCameraSceneNode : public ICameraSceneNode +{ +public: + //! constructor + CCameraSceneNode(ISceneNode *parent, ISceneManager *mgr, s32 id, + const core::vector3df &position = core::vector3df(0, 0, 0), + const core::vector3df &lookat = core::vector3df(0, 0, 100)); + + //! Sets the projection matrix of the camera. + /** The core::matrix4 class has some methods + to build a projection matrix. e.g: core::matrix4::buildProjectionMatrixPerspectiveFovLH. + Note that the matrix will only stay as set by this method until one of + the following Methods are called: setNearValue, setFarValue, setAspectRatio, setFOV. + \param projection The new projection matrix of the camera. + \param isOrthogonal Set this to true if the matrix is an orthogonal one (e.g. + from matrix4::buildProjectionMatrixOrthoLH(). */ + void setProjectionMatrix(const core::matrix4 &projection, bool isOrthogonal = false) override; + + //! Gets the current projection matrix of the camera + //! \return Returns the current projection matrix of the camera. + const core::matrix4 &getProjectionMatrix() const override; + + //! Gets the current view matrix of the camera + //! \return Returns the current view matrix of the camera. + const core::matrix4 &getViewMatrix() const override; + + //! Sets a custom view matrix affector. + /** \param affector: The affector matrix. */ + void setViewMatrixAffector(const core::matrix4 &affector) override; + + //! Gets the custom view matrix affector. + const core::matrix4 &getViewMatrixAffector() const override; + + //! It is possible to send mouse and key events to the camera. Most cameras + //! may ignore this input, but camera scene nodes which are created for + //! example with scene::ISceneManager::addMayaCameraSceneNode or + //! scene::ISceneManager::addMeshViewerCameraSceneNode, may want to get this input + //! for changing their position, look at target or whatever. + bool OnEvent(const SEvent &event) override; + + //! Sets the look at target of the camera + /** If the camera's target and rotation are bound ( @see bindTargetAndRotation() ) + then calling this will also change the camera's scene node rotation to match the target. + \param pos: Look at target of the camera. */ + void setTarget(const core::vector3df &pos) override; + + //! Sets the rotation of the node. + /** This only modifies the relative rotation of the node. + If the camera's target and rotation are bound ( @see bindTargetAndRotation() ) + then calling this will also change the camera's target to match the rotation. + \param rotation New rotation of the node in degrees. */ + void setRotation(const core::vector3df &rotation) override; + + //! Gets the current look at target of the camera + /** \return The current look at target of the camera */ + const core::vector3df &getTarget() const override; + + //! Sets the up vector of the camera. + //! \param pos: New upvector of the camera. + void setUpVector(const core::vector3df &pos) override; + + //! Gets the up vector of the camera. + //! \return Returns the up vector of the camera. + const core::vector3df &getUpVector() const override; + + //! Gets distance from the camera to the near plane. + //! \return Value of the near plane of the camera. + f32 getNearValue() const override; + + //! Gets the distance from the camera to the far plane. + //! \return Value of the far plane of the camera. + f32 getFarValue() const override; + + //! Get the aspect ratio of the camera. + //! \return The aspect ratio of the camera. + f32 getAspectRatio() const override; + + //! Gets the field of view of the camera. + //! \return Field of view of the camera + f32 getFOV() const override; + + //! Sets the value of the near clipping plane. (default: 1.0f) + void setNearValue(f32 zn) override; + + //! Sets the value of the far clipping plane (default: 2000.0f) + void setFarValue(f32 zf) override; + + //! Sets the aspect ratio (default: 4.0f / 3.0f) + void setAspectRatio(f32 aspect) override; + + //! Sets the field of view (Default: PI / 3.5f) + void setFOV(f32 fovy) override; + + //! PreRender event + void OnRegisterSceneNode() override; + + //! Render + void render() override; + + //! Update + void updateMatrices() override; + + //! Returns the axis aligned bounding box of this node + const core::aabbox3d &getBoundingBox() const override; + + //! Returns the view area. + const SViewFrustum *getViewFrustum() const override; + + //! Disables or enables the camera to get key or mouse inputs. + //! If this is set to true, the camera will respond to key inputs + //! otherwise not. + void setInputReceiverEnabled(bool enabled) override; + + //! Returns if the input receiver of the camera is currently enabled. + bool isInputReceiverEnabled() const override; + + //! Returns type of the scene node + ESCENE_NODE_TYPE getType() const override { return ESNT_CAMERA; } + + //! Binds the camera scene node's rotation to its target position and vice versa, or unbinds them. + void bindTargetAndRotation(bool bound) override; + + //! Queries if the camera scene node's rotation and its target position are bound together. + bool getTargetAndRotationBinding(void) const override; + + //! Creates a clone of this scene node and its children. + ISceneNode *clone(ISceneNode *newParent = 0, ISceneManager *newManager = 0) override; + +protected: + void recalculateProjectionMatrix(); + void recalculateViewArea(); + + core::aabbox3d BoundingBox; + + core::vector3df Target; + core::vector3df UpVector; + + f32 Fovy; // Field of view, in radians. + f32 Aspect; // Aspect ratio. + f32 ZNear; // value of the near view-plane. + f32 ZFar; // Z-value of the far view-plane. + + SViewFrustum ViewArea; + core::matrix4 Affector; + + bool InputReceiverEnabled; + bool TargetAndRotationAreBound; +}; + +} // end namespace +} // end namespace diff --git a/irr/src/CColorConverter.cpp b/irr/src/CColorConverter.cpp new file mode 100644 index 000000000..96b22c544 --- /dev/null +++ b/irr/src/CColorConverter.cpp @@ -0,0 +1,760 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CColorConverter.h" +#include "SColor.h" +#include "os.h" +#include "irrString.h" + +namespace irr +{ +namespace video +{ + +//! converts a monochrome bitmap to A1R5G5B5 data +void CColorConverter::convert1BitTo16Bit(const u8 *in, s16 *out, s32 width, s32 height, s32 linepad, bool flip) +{ + if (!in || !out) + return; + + if (flip) + out += width * height; + + for (s32 y = 0; y < height; ++y) { + s32 shift = 7; + if (flip) + out -= width; + + for (s32 x = 0; x < width; ++x) { + out[x] = *in >> shift & 0x01 ? (s16)0xffff : (s16)0x8000; + + if ((--shift) < 0) { // 8 pixel done + shift = 7; + ++in; + } + } + + if (shift != 7) // width did not fill last byte + ++in; + + if (!flip) + out += width; + in += linepad; + } +} + +//! converts a 4 bit palettized image to A1R5G5B5 +void CColorConverter::convert4BitTo16Bit(const u8 *in, s16 *out, s32 width, s32 height, const s32 *palette, s32 linepad, bool flip) +{ + if (!in || !out || !palette) + return; + + if (flip) + out += width * height; + + for (s32 y = 0; y < height; ++y) { + s32 shift = 4; + if (flip) + out -= width; + + for (s32 x = 0; x < width; ++x) { + out[x] = X8R8G8B8toA1R5G5B5(palette[(u8)((*in >> shift) & 0xf)]); + + if (shift == 0) { + shift = 4; + ++in; + } else + shift = 0; + } + + if (shift == 0) // odd width + ++in; + + if (!flip) + out += width; + in += linepad; + } +} + +//! converts a 8 bit palettized image into A1R5G5B5 +void CColorConverter::convert8BitTo16Bit(const u8 *in, s16 *out, s32 width, s32 height, const s32 *palette, s32 linepad, bool flip) +{ + if (!in || !out || !palette) + return; + + if (flip) + out += width * height; + + for (s32 y = 0; y < height; ++y) { + if (flip) + out -= width; // one line back + for (s32 x = 0; x < width; ++x) { + out[x] = X8R8G8B8toA1R5G5B5(palette[(u8)(*in)]); + ++in; + } + if (!flip) + out += width; + in += linepad; + } +} + +//! converts a 8 bit palettized or non palettized image (A8) into R8G8B8 +void CColorConverter::convert8BitTo24Bit(const u8 *in, u8 *out, s32 width, s32 height, const u8 *palette, s32 linepad, bool flip) +{ + if (!in || !out) + return; + + const s32 lineWidth = 3 * width; + if (flip) + out += lineWidth * height; + + for (s32 y = 0; y < height; ++y) { + if (flip) + out -= lineWidth; // one line back + for (s32 x = 0; x < lineWidth; x += 3) { + if (palette) { +#ifdef __BIG_ENDIAN__ + out[x + 0] = palette[(in[0] << 2) + 0]; + out[x + 1] = palette[(in[0] << 2) + 1]; + out[x + 2] = palette[(in[0] << 2) + 2]; +#else + out[x + 0] = palette[(in[0] << 2) + 2]; + out[x + 1] = palette[(in[0] << 2) + 1]; + out[x + 2] = palette[(in[0] << 2) + 0]; +#endif + } else { + out[x + 0] = in[0]; + out[x + 1] = in[0]; + out[x + 2] = in[0]; + } + ++in; + } + if (!flip) + out += lineWidth; + in += linepad; + } +} + +//! converts a 8 bit palettized or non palettized image (A8) into R8G8B8 +void CColorConverter::convert8BitTo32Bit(const u8 *in, u8 *out, s32 width, s32 height, const u8 *palette, s32 linepad, bool flip) +{ + if (!in || !out) + return; + + const u32 lineWidth = 4 * width; + if (flip) + out += lineWidth * height; + + u32 x; + u32 c; + for (u32 y = 0; y < (u32)height; ++y) { + if (flip) + out -= lineWidth; // one line back + + if (palette) { + for (x = 0; x < (u32)width; x += 1) { + c = in[x]; + ((u32 *)out)[x] = ((u32 *)palette)[c]; + } + } else { + for (x = 0; x < (u32)width; x += 1) { + c = in[x]; +#ifdef __BIG_ENDIAN__ + ((u32 *)out)[x] = c << 24 | c << 16 | c << 8 | 0x000000FF; +#else + ((u32 *)out)[x] = 0xFF000000 | c << 16 | c << 8 | c; +#endif + } + } + + if (!flip) + out += lineWidth; + in += width + linepad; + } +} + +//! converts 16bit data to 16bit data +void CColorConverter::convert16BitTo16Bit(const s16 *in, s16 *out, s32 width, s32 height, s32 linepad, bool flip) +{ + if (!in || !out) + return; + + if (flip) + out += width * height; + + for (s32 y = 0; y < height; ++y) { + if (flip) + out -= width; +#ifdef __BIG_ENDIAN__ + for (s32 x = 0; x < width; ++x) + out[x] = os::Byteswap::byteswap(in[x]); +#else + memcpy(out, in, width * sizeof(s16)); +#endif + if (!flip) + out += width; + in += width; + in += linepad; + } +} + +//! copies R8G8B8 24bit data to 24bit data +void CColorConverter::convert24BitTo24Bit(const u8 *in, u8 *out, s32 width, s32 height, s32 linepad, bool flip, bool bgr) +{ + if (!in || !out) + return; + + const s32 lineWidth = 3 * width; + if (flip) + out += lineWidth * height; + + for (s32 y = 0; y < height; ++y) { + if (flip) + out -= lineWidth; + if (bgr) { + for (s32 x = 0; x < lineWidth; x += 3) { + out[x + 0] = in[x + 2]; + out[x + 1] = in[x + 1]; + out[x + 2] = in[x + 0]; + } + } else { + memcpy(out, in, lineWidth); + } + if (!flip) + out += lineWidth; + in += lineWidth; + in += linepad; + } +} + +//! Resizes the surface to a new size and converts it at the same time +//! to an A8R8G8B8 format, returning the pointer to the new buffer. +void CColorConverter::convert16bitToA8R8G8B8andResize(const s16 *in, s32 *out, s32 newWidth, s32 newHeight, s32 currentWidth, s32 currentHeight) +{ + if (!newWidth || !newHeight) + return; + + // note: this is very very slow. (i didn't want to write a fast version. + // but hopefully, nobody wants to convert surfaces every frame. + + f32 sourceXStep = (f32)currentWidth / (f32)newWidth; + f32 sourceYStep = (f32)currentHeight / (f32)newHeight; + f32 sy; + s32 t; + + for (s32 x = 0; x < newWidth; ++x) { + sy = 0.0f; + + for (s32 y = 0; y < newHeight; ++y) { + t = in[(s32)(((s32)sy) * currentWidth + x * sourceXStep)]; + t = (((t >> 15) & 0x1) << 31) | (((t >> 10) & 0x1F) << 19) | + (((t >> 5) & 0x1F) << 11) | (t & 0x1F) << 3; + out[(s32)(y * newWidth + x)] = t; + + sy += sourceYStep; + } + } +} + +//! copies X8R8G8B8 32 bit data +void CColorConverter::convert32BitTo32Bit(const s32 *in, s32 *out, s32 width, s32 height, s32 linepad, bool flip) +{ + if (!in || !out) + return; + + if (flip) + out += width * height; + + for (s32 y = 0; y < height; ++y) { + if (flip) + out -= width; +#ifdef __BIG_ENDIAN__ + for (s32 x = 0; x < width; ++x) + out[x] = os::Byteswap::byteswap(in[x]); +#else + memcpy(out, in, width * sizeof(s32)); +#endif + if (!flip) + out += width; + in += width; + in += linepad; + } +} + +void CColorConverter::convert_A1R5G5B5toR8G8B8(const void *sP, s32 sN, void *dP) +{ + u16 *sB = (u16 *)sP; + u8 *dB = (u8 *)dP; + + for (s32 x = 0; x < sN; ++x) { + dB[2] = (*sB & 0x7c00) >> 7; + dB[1] = (*sB & 0x03e0) >> 2; + dB[0] = (*sB & 0x1f) << 3; + + sB += 1; + dB += 3; + } +} + +void CColorConverter::convert_A1R5G5B5toB8G8R8(const void *sP, s32 sN, void *dP) +{ + u16 *sB = (u16 *)sP; + u8 *dB = (u8 *)dP; + + for (s32 x = 0; x < sN; ++x) { + dB[0] = (*sB & 0x7c00) >> 7; + dB[1] = (*sB & 0x03e0) >> 2; + dB[2] = (*sB & 0x1f) << 3; + + sB += 1; + dB += 3; + } +} + +void CColorConverter::convert_A1R5G5B5toR5G5B5A1(const void *sP, s32 sN, void *dP) +{ + const u16 *sB = (const u16 *)sP; + u16 *dB = (u16 *)dP; + + for (s32 x = 0; x < sN; ++x) { + *dB = (*sB << 1) | (*sB >> 15); + ++sB; + ++dB; + } +} + +void CColorConverter::convert_A1R5G5B5toA8R8G8B8(const void *sP, s32 sN, void *dP) +{ + u16 *sB = (u16 *)sP; + u32 *dB = (u32 *)dP; + + for (s32 x = 0; x < sN; ++x) + *dB++ = A1R5G5B5toA8R8G8B8(*sB++); +} + +void CColorConverter::convert_A1R5G5B5toA1R5G5B5(const void *sP, s32 sN, void *dP) +{ + memcpy(dP, sP, sN * 2); +} + +void CColorConverter::convert_A1R5G5B5toR5G6B5(const void *sP, s32 sN, void *dP) +{ + u16 *sB = (u16 *)sP; + u16 *dB = (u16 *)dP; + + for (s32 x = 0; x < sN; ++x) + *dB++ = A1R5G5B5toR5G6B5(*sB++); +} + +void CColorConverter::convert_A8R8G8B8toR8G8B8(const void *sP, s32 sN, void *dP) +{ + u8 *sB = (u8 *)sP; + u8 *dB = (u8 *)dP; + + for (s32 x = 0; x < sN; ++x) { + // sB[3] is alpha + dB[0] = sB[2]; + dB[1] = sB[1]; + dB[2] = sB[0]; + + sB += 4; + dB += 3; + } +} + +void CColorConverter::convert_A8R8G8B8toB8G8R8(const void *sP, s32 sN, void *dP) +{ + u8 *sB = (u8 *)sP; + u8 *dB = (u8 *)dP; + + for (s32 x = 0; x < sN; ++x) { + // sB[3] is alpha + dB[0] = sB[0]; + dB[1] = sB[1]; + dB[2] = sB[2]; + + sB += 4; + dB += 3; + } +} + +void CColorConverter::convert_A8R8G8B8toA8R8G8B8(const void *sP, s32 sN, void *dP) +{ + memcpy(dP, sP, sN * 4); +} + +void CColorConverter::convert_A8R8G8B8toA1R5G5B5(const void *sP, s32 sN, void *dP) +{ + u32 *sB = (u32 *)sP; + u16 *dB = (u16 *)dP; + + for (s32 x = 0; x < sN; ++x) + *dB++ = A8R8G8B8toA1R5G5B5(*sB++); +} + +void CColorConverter::convert_A8R8G8B8toA1B5G5R5(const void *sP, s32 sN, void *dP) +{ + u8 *sB = (u8 *)sP; + u16 *dB = (u16 *)dP; + + for (s32 x = 0; x < sN; ++x) { + s32 r = sB[0] >> 3; + s32 g = sB[1] >> 3; + s32 b = sB[2] >> 3; + s32 a = sB[3] >> 3; + + dB[0] = (a << 15) | (r << 10) | (g << 5) | (b); + + sB += 4; + dB += 1; + } +} + +void CColorConverter::convert_A8R8G8B8toR5G6B5(const void *sP, s32 sN, void *dP) +{ + u8 *sB = (u8 *)sP; + u16 *dB = (u16 *)dP; + + for (s32 x = 0; x < sN; ++x) { + s32 r = sB[2] >> 3; + s32 g = sB[1] >> 2; + s32 b = sB[0] >> 3; + + dB[0] = (r << 11) | (g << 5) | (b); + + sB += 4; + dB += 1; + } +} + +void CColorConverter::convert_A8R8G8B8toR3G3B2(const void *sP, s32 sN, void *dP) +{ + u8 *sB = (u8 *)sP; + u8 *dB = (u8 *)dP; + + for (s32 x = 0; x < sN; ++x) { + u8 r = sB[2] & 0xe0; + u8 g = (sB[1] & 0xe0) >> 3; + u8 b = (sB[0] & 0xc0) >> 6; + + dB[0] = (r | g | b); + + sB += 4; + dB += 1; + } +} + +void CColorConverter::convert_R8G8B8toR8G8B8(const void *sP, s32 sN, void *dP) +{ + memcpy(dP, sP, sN * 3); +} + +void CColorConverter::convert_R8G8B8toA8R8G8B8(const void *sP, s32 sN, void *dP) +{ + u8 *sB = (u8 *)sP; + u32 *dB = (u32 *)dP; + + for (s32 x = 0; x < sN; ++x) { + *dB = 0xff000000 | (sB[0] << 16) | (sB[1] << 8) | sB[2]; + + sB += 3; + ++dB; + } +} + +void CColorConverter::convert_R8G8B8toA1R5G5B5(const void *sP, s32 sN, void *dP) +{ + u8 *sB = (u8 *)sP; + u16 *dB = (u16 *)dP; + + for (s32 x = 0; x < sN; ++x) { + s32 r = sB[0] >> 3; + s32 g = sB[1] >> 3; + s32 b = sB[2] >> 3; + + dB[0] = (0x8000) | (r << 10) | (g << 5) | (b); + + sB += 3; + dB += 1; + } +} + +void CColorConverter::convert_B8G8R8toA8R8G8B8(const void *sP, s32 sN, void *dP) +{ + u8 *sB = (u8 *)sP; + u32 *dB = (u32 *)dP; + + for (s32 x = 0; x < sN; ++x) { + *dB = 0xff000000 | (sB[2] << 16) | (sB[1] << 8) | sB[0]; + + sB += 3; + ++dB; + } +} + +void CColorConverter::convert_A8R8G8B8toR8G8B8A8(const void *sP, s32 sN, void *dP) +{ + const u32 *sB = (const u32 *)sP; + u32 *dB = (u32 *)dP; + + for (s32 x = 0; x < sN; ++x) { + *dB++ = (*sB << 8) | (*sB >> 24); + ++sB; + } +} + +void CColorConverter::convert_A8R8G8B8toA8B8G8R8(const void *sP, s32 sN, void *dP) +{ + const u32 *sB = (const u32 *)sP; + u32 *dB = (u32 *)dP; + + for (s32 x = 0; x < sN; ++x) { + *dB++ = (*sB & 0xff00ff00) | ((*sB & 0x00ff0000) >> 16) | ((*sB & 0x000000ff) << 16); + ++sB; + } +} + +void CColorConverter::convert_B8G8R8A8toA8R8G8B8(const void *sP, s32 sN, void *dP) +{ + u8 *sB = (u8 *)sP; + u8 *dB = (u8 *)dP; + + for (s32 x = 0; x < sN; ++x) { + dB[0] = sB[3]; + dB[1] = sB[2]; + dB[2] = sB[1]; + dB[3] = sB[0]; + + sB += 4; + dB += 4; + } +} + +void CColorConverter::convert_R8G8B8toB8G8R8(const void *sP, s32 sN, void *dP) +{ + u8 *sB = (u8 *)sP; + u8 *dB = (u8 *)dP; + + for (s32 x = 0; x < sN; ++x) { + dB[2] = sB[0]; + dB[1] = sB[1]; + dB[0] = sB[2]; + + sB += 3; + dB += 3; + } +} + +void CColorConverter::convert_R8G8B8toR5G6B5(const void *sP, s32 sN, void *dP) +{ + u8 *sB = (u8 *)sP; + u16 *dB = (u16 *)dP; + + for (s32 x = 0; x < sN; ++x) { + s32 r = sB[0] >> 3; + s32 g = sB[1] >> 2; + s32 b = sB[2] >> 3; + + dB[0] = (r << 11) | (g << 5) | (b); + + sB += 3; + dB += 1; + } +} + +void CColorConverter::convert_R5G6B5toR5G6B5(const void *sP, s32 sN, void *dP) +{ + memcpy(dP, sP, sN * 2); +} + +void CColorConverter::convert_R5G6B5toR8G8B8(const void *sP, s32 sN, void *dP) +{ + u16 *sB = (u16 *)sP; + u8 *dB = (u8 *)dP; + + for (s32 x = 0; x < sN; ++x) { + dB[0] = (*sB & 0xf800) >> 8; + dB[1] = (*sB & 0x07e0) >> 3; + dB[2] = (*sB & 0x001f) << 3; + + sB += 1; + dB += 3; + } +} + +void CColorConverter::convert_R5G6B5toB8G8R8(const void *sP, s32 sN, void *dP) +{ + u16 *sB = (u16 *)sP; + u8 *dB = (u8 *)dP; + + for (s32 x = 0; x < sN; ++x) { + dB[2] = (*sB & 0xf800) >> 8; + dB[1] = (*sB & 0x07e0) >> 3; + dB[0] = (*sB & 0x001f) << 3; + + sB += 1; + dB += 3; + } +} + +void CColorConverter::convert_R5G6B5toA8R8G8B8(const void *sP, s32 sN, void *dP) +{ + u16 *sB = (u16 *)sP; + u32 *dB = (u32 *)dP; + + for (s32 x = 0; x < sN; ++x) + *dB++ = R5G6B5toA8R8G8B8(*sB++); +} + +void CColorConverter::convert_R5G6B5toA1R5G5B5(const void *sP, s32 sN, void *dP) +{ + u16 *sB = (u16 *)sP; + u16 *dB = (u16 *)dP; + + for (s32 x = 0; x < sN; ++x) + *dB++ = R5G6B5toA1R5G5B5(*sB++); +} + +bool CColorConverter::canConvertFormat(ECOLOR_FORMAT sourceFormat, ECOLOR_FORMAT destFormat) +{ + switch (sourceFormat) { + case ECF_A1R5G5B5: + switch (destFormat) { + case ECF_A1R5G5B5: + case ECF_R5G6B5: + case ECF_A8R8G8B8: + case ECF_R8G8B8: + return true; + default: + break; + } + break; + case ECF_R5G6B5: + switch (destFormat) { + case ECF_A1R5G5B5: + case ECF_R5G6B5: + case ECF_A8R8G8B8: + case ECF_R8G8B8: + return true; + default: + break; + } + break; + case ECF_A8R8G8B8: + switch (destFormat) { + case ECF_A1R5G5B5: + case ECF_R5G6B5: + case ECF_A8R8G8B8: + case ECF_R8G8B8: + return true; + default: + break; + } + break; + case ECF_R8G8B8: + switch (destFormat) { + case ECF_A1R5G5B5: + case ECF_R5G6B5: + case ECF_A8R8G8B8: + case ECF_R8G8B8: + return true; + default: + break; + } + break; + default: + break; + } + return false; +} + +void CColorConverter::convert_viaFormat(const void *sP, ECOLOR_FORMAT sF, s32 sN, + void *dP, ECOLOR_FORMAT dF) +{ + // please also update can_convert_viaFormat when adding new conversions + switch (sF) { + case ECF_A1R5G5B5: + switch (dF) { + case ECF_A1R5G5B5: + convert_A1R5G5B5toA1R5G5B5(sP, sN, dP); + break; + case ECF_R5G6B5: + convert_A1R5G5B5toR5G6B5(sP, sN, dP); + break; + case ECF_A8R8G8B8: + convert_A1R5G5B5toA8R8G8B8(sP, sN, dP); + break; + case ECF_R8G8B8: + convert_A1R5G5B5toR8G8B8(sP, sN, dP); + break; + + default: + break; + } + break; + case ECF_R5G6B5: + switch (dF) { + case ECF_A1R5G5B5: + convert_R5G6B5toA1R5G5B5(sP, sN, dP); + break; + case ECF_R5G6B5: + convert_R5G6B5toR5G6B5(sP, sN, dP); + break; + case ECF_A8R8G8B8: + convert_R5G6B5toA8R8G8B8(sP, sN, dP); + break; + case ECF_R8G8B8: + convert_R5G6B5toR8G8B8(sP, sN, dP); + break; + + default: + break; + } + break; + case ECF_A8R8G8B8: + switch (dF) { + case ECF_A1R5G5B5: + convert_A8R8G8B8toA1R5G5B5(sP, sN, dP); + break; + case ECF_R5G6B5: + convert_A8R8G8B8toR5G6B5(sP, sN, dP); + break; + case ECF_A8R8G8B8: + convert_A8R8G8B8toA8R8G8B8(sP, sN, dP); + break; + case ECF_R8G8B8: + convert_A8R8G8B8toR8G8B8(sP, sN, dP); + break; + + default: + break; + } + break; + case ECF_R8G8B8: + switch (dF) { + case ECF_A1R5G5B5: + convert_R8G8B8toA1R5G5B5(sP, sN, dP); + break; + case ECF_R5G6B5: + convert_R8G8B8toR5G6B5(sP, sN, dP); + break; + case ECF_A8R8G8B8: + convert_R8G8B8toA8R8G8B8(sP, sN, dP); + break; + case ECF_R8G8B8: + convert_R8G8B8toR8G8B8(sP, sN, dP); + break; + + default: + break; + } + break; + + default: + break; + } +} + +} // end namespace video +} // end namespace irr diff --git a/irr/src/CColorConverter.h b/irr/src/CColorConverter.h new file mode 100644 index 000000000..7f1628297 --- /dev/null +++ b/irr/src/CColorConverter.h @@ -0,0 +1,94 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" +#include "IImage.h" + +namespace irr +{ +namespace video +{ + +class CColorConverter +{ +public: + //! converts a monochrome bitmap to A1R5G5B5 + static void convert1BitTo16Bit(const u8 *in, s16 *out, s32 width, s32 height, s32 linepad = 0, bool flip = false); + + //! converts a 4 bit palettized image to A1R5G5B5 + static void convert4BitTo16Bit(const u8 *in, s16 *out, s32 width, s32 height, const s32 *palette, s32 linepad = 0, bool flip = false); + + //! converts a 8 bit palettized image to A1R5G5B5 + static void convert8BitTo16Bit(const u8 *in, s16 *out, s32 width, s32 height, const s32 *palette, s32 linepad = 0, bool flip = false); + + //! converts a 8 bit palettized or non palettized image (A8) into R8G8B8 + static void convert8BitTo24Bit(const u8 *in, u8 *out, s32 width, s32 height, const u8 *palette, s32 linepad = 0, bool flip = false); + + //! converts a 8 bit palettized or non palettized image (A8) into A8R8G8B8 + static void convert8BitTo32Bit(const u8 *in, u8 *out, s32 width, s32 height, const u8 *palette, s32 linepad = 0, bool flip = false); + + //! converts R8G8B8 16 bit data to A1R5G5B5 data + static void convert16BitTo16Bit(const s16 *in, s16 *out, s32 width, s32 height, s32 linepad = 0, bool flip = false); + + //! copies R8G8B8 24 bit data to 24 data, and flips and + //! mirrors the image during the process. + static void convert24BitTo24Bit(const u8 *in, u8 *out, s32 width, s32 height, s32 linepad = 0, bool flip = false, bool bgr = false); + + //! Resizes the surface to a new size and converts it at the same time + //! to an A8R8G8B8 format, returning the pointer to the new buffer. + static void convert16bitToA8R8G8B8andResize(const s16 *in, s32 *out, s32 newWidth, s32 newHeight, s32 currentWidth, s32 currentHeight); + + //! copies X8R8G8B8 32 bit data, and flips and + //! mirrors the image during the process. + static void convert32BitTo32Bit(const s32 *in, s32 *out, s32 width, s32 height, s32 linepad, bool flip = false); + + //! Functions for converting one image format to another efficiently + //! and hopefully correctly. + //! Note that the format descriptions refer to the ECOLOR_FORMAT's and not to memory layout. + //! Reasons for that go back to DX9 naming which tended to flip 32-bit and 16-bit byte orders so ARGB usually means BGRA. + //! + //! \param sP pointer to source pixel data + //! \param sN number of source pixels to copy + //! \param dP pointer to destination data buffer. must be big enough + //! to hold sN pixels in the output format. + static void convert_A1R5G5B5toR8G8B8(const void *sP, s32 sN, void *dP); + static void convert_A1R5G5B5toB8G8R8(const void *sP, s32 sN, void *dP); + static void convert_A1R5G5B5toA8R8G8B8(const void *sP, s32 sN, void *dP); + static void convert_A1R5G5B5toA1R5G5B5(const void *sP, s32 sN, void *dP); + static void convert_A1R5G5B5toR5G5B5A1(const void *sP, s32 sN, void *dP); + static void convert_A1R5G5B5toR5G6B5(const void *sP, s32 sN, void *dP); + + static void convert_A8R8G8B8toR8G8B8(const void *sP, s32 sN, void *dP); + static void convert_A8R8G8B8toB8G8R8(const void *sP, s32 sN, void *dP); + static void convert_A8R8G8B8toA8R8G8B8(const void *sP, s32 sN, void *dP); + static void convert_A8R8G8B8toA1R5G5B5(const void *sP, s32 sN, void *dP); + static void convert_A8R8G8B8toA1B5G5R5(const void *sP, s32 sN, void *dP); + static void convert_A8R8G8B8toR5G6B5(const void *sP, s32 sN, void *dP); + + static void convert_A8R8G8B8toR3G3B2(const void *sP, s32 sN, void *dP); + static void convert_R8G8B8toR8G8B8(const void *sP, s32 sN, void *dP); + static void convert_R8G8B8toA8R8G8B8(const void *sP, s32 sN, void *dP); + static void convert_R8G8B8toA1R5G5B5(const void *sP, s32 sN, void *dP); + static void convert_R8G8B8toB8G8R8(const void *sP, s32 sN, void *dP); + static void convert_R8G8B8toR5G6B5(const void *sP, s32 sN, void *dP); + static void convert_B8G8R8toA8R8G8B8(const void *sP, s32 sN, void *dP); + static void convert_B8G8R8A8toA8R8G8B8(const void *sP, s32 sN, void *dP); + static void convert_A8R8G8B8toR8G8B8A8(const void *sP, s32 sN, void *dP); + static void convert_A8R8G8B8toA8B8G8R8(const void *sP, s32 sN, void *dP); + + static void convert_R5G6B5toR5G6B5(const void *sP, s32 sN, void *dP); + static void convert_R5G6B5toR8G8B8(const void *sP, s32 sN, void *dP); + static void convert_R5G6B5toB8G8R8(const void *sP, s32 sN, void *dP); + static void convert_R5G6B5toA8R8G8B8(const void *sP, s32 sN, void *dP); + static void convert_R5G6B5toA1R5G5B5(const void *sP, s32 sN, void *dP); + static void convert_viaFormat(const void *sP, ECOLOR_FORMAT sF, s32 sN, + void *dP, ECOLOR_FORMAT dF); + // Check if convert_viaFormat is usable + static bool canConvertFormat(ECOLOR_FORMAT sourceFormat, ECOLOR_FORMAT destFormat); +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/src/CDummyTransformationSceneNode.cpp b/irr/src/CDummyTransformationSceneNode.cpp new file mode 100644 index 000000000..73953dd38 --- /dev/null +++ b/irr/src/CDummyTransformationSceneNode.cpp @@ -0,0 +1,102 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CDummyTransformationSceneNode.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CDummyTransformationSceneNode::CDummyTransformationSceneNode( + ISceneNode *parent, ISceneManager *mgr, s32 id) : + IDummyTransformationSceneNode(parent, mgr, id) +{ +#ifdef _DEBUG + setDebugName("CDummyTransformationSceneNode"); +#endif + + setAutomaticCulling(scene::EAC_OFF); +} + +//! returns the axis aligned bounding box of this node +const core::aabbox3d &CDummyTransformationSceneNode::getBoundingBox() const +{ + return Box; +} + +//! Returns a reference to the current relative transformation matrix. +//! This is the matrix, this scene node uses instead of scale, translation +//! and rotation. +core::matrix4 &CDummyTransformationSceneNode::getRelativeTransformationMatrix() +{ + return RelativeTransformationMatrix; +} + +//! Returns the relative transformation of the scene node. +core::matrix4 CDummyTransformationSceneNode::getRelativeTransformation() const +{ + return RelativeTransformationMatrix; +} + +//! Creates a clone of this scene node and its children. +ISceneNode *CDummyTransformationSceneNode::clone(ISceneNode *newParent, ISceneManager *newManager) +{ + if (!newParent) + newParent = Parent; + if (!newManager) + newManager = SceneManager; + + CDummyTransformationSceneNode *nb = new CDummyTransformationSceneNode(newParent, + newManager, ID); + + nb->cloneMembers(this, newManager); + nb->RelativeTransformationMatrix = RelativeTransformationMatrix; + nb->Box = Box; + + if (newParent) + nb->drop(); + return nb; +} + +const core::vector3df &CDummyTransformationSceneNode::getScale() const +{ + os::Printer::log("CDummyTransformationSceneNode::getScale() does not contain the relative transformation.", ELL_DEBUG); + return RelativeScale; +} + +void CDummyTransformationSceneNode::setScale(const core::vector3df &scale) +{ + os::Printer::log("CDummyTransformationSceneNode::setScale() does not affect the relative transformation.", ELL_DEBUG); + RelativeScale = scale; +} + +const core::vector3df &CDummyTransformationSceneNode::getRotation() const +{ + os::Printer::log("CDummyTransformationSceneNode::getRotation() does not contain the relative transformation.", ELL_DEBUG); + return RelativeRotation; +} + +void CDummyTransformationSceneNode::setRotation(const core::vector3df &rotation) +{ + os::Printer::log("CDummyTransformationSceneNode::setRotation() does not affect the relative transformation.", ELL_DEBUG); + RelativeRotation = rotation; +} + +const core::vector3df &CDummyTransformationSceneNode::getPosition() const +{ + os::Printer::log("CDummyTransformationSceneNode::getPosition() does not contain the relative transformation.", ELL_DEBUG); + return RelativeTranslation; +} + +void CDummyTransformationSceneNode::setPosition(const core::vector3df &newpos) +{ + os::Printer::log("CDummyTransformationSceneNode::setPosition() does not affect the relative transformation.", ELL_DEBUG); + RelativeTranslation = newpos; +} + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CDummyTransformationSceneNode.h b/irr/src/CDummyTransformationSceneNode.h new file mode 100644 index 000000000..86fda3639 --- /dev/null +++ b/irr/src/CDummyTransformationSceneNode.h @@ -0,0 +1,55 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IDummyTransformationSceneNode.h" + +namespace irr +{ +namespace scene +{ + +class CDummyTransformationSceneNode : public IDummyTransformationSceneNode +{ +public: + //! constructor + CDummyTransformationSceneNode(ISceneNode *parent, ISceneManager *mgr, s32 id); + + //! returns the axis aligned bounding box of this node + const core::aabbox3d &getBoundingBox() const override; + + //! Returns a reference to the current relative transformation matrix. + //! This is the matrix, this scene node uses instead of scale, translation + //! and rotation. + core::matrix4 &getRelativeTransformationMatrix() override; + + //! Returns the relative transformation of the scene node. + core::matrix4 getRelativeTransformation() const override; + + //! does nothing. + void render() override {} + + //! Returns type of the scene node + ESCENE_NODE_TYPE getType() const override { return ESNT_DUMMY_TRANSFORMATION; } + + //! Creates a clone of this scene node and its children. + ISceneNode *clone(ISceneNode *newParent = 0, ISceneManager *newManager = 0) override; + +private: + // TODO: We can add least add some warnings to find troubles faster until we have + // fixed bug id 2318691. + const core::vector3df &getScale() const override; + void setScale(const core::vector3df &scale) override; + const core::vector3df &getRotation() const override; + void setRotation(const core::vector3df &rotation) override; + const core::vector3df &getPosition() const override; + void setPosition(const core::vector3df &newpos) override; + + core::matrix4 RelativeTransformationMatrix; + core::aabbox3d Box; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CEGLManager.cpp b/irr/src/CEGLManager.cpp new file mode 100644 index 000000000..971b39359 --- /dev/null +++ b/irr/src/CEGLManager.cpp @@ -0,0 +1,611 @@ +// Copyright (C) 2013 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#include "CEGLManager.h" + +#ifdef _IRR_COMPILE_WITH_EGL_MANAGER_ + +#include "irrString.h" +#include "irrArray.h" +#include "os.h" + +#if defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_) +#include +#endif + +namespace irr +{ +namespace video +{ + +CEGLManager::CEGLManager() : + IContextManager(), EglWindow(0), EglDisplay(EGL_NO_DISPLAY), + EglSurface(EGL_NO_SURFACE), EglContext(EGL_NO_CONTEXT), EglConfig(0), MajorVersion(0), MinorVersion(0) +{ +#ifdef _DEBUG + setDebugName("CEGLManager"); +#endif +} + +CEGLManager::~CEGLManager() +{ + destroyContext(); + destroySurface(); + terminate(); +} + +bool CEGLManager::initialize(const SIrrlichtCreationParameters ¶ms, const SExposedVideoData &data) +{ + // store new data + Params = params; + Data = data; + + if (EglWindow != 0 && EglDisplay != EGL_NO_DISPLAY) + return true; + + // Window is depend on platform. +#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) + EglWindow = (NativeWindowType)Data.OpenGLWin32.HWnd; + Data.OpenGLWin32.HDc = GetDC((HWND)EglWindow); + EglDisplay = eglGetDisplay((NativeDisplayType)Data.OpenGLWin32.HDc); +#elif defined(_IRR_EMSCRIPTEN_PLATFORM_) + EglWindow = 0; + EglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); +#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) + EglWindow = (NativeWindowType)Data.OpenGLLinux.X11Window; + EglDisplay = eglGetDisplay((NativeDisplayType)Data.OpenGLLinux.X11Display); +#elif defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_) + EglWindow = (ANativeWindow *)Data.OGLESAndroid.Window; + EglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); +#elif defined(_IRR_COMPILE_WITH_FB_DEVICE_) + EglWindow = (NativeWindowType)Data.OpenGLFB.Window; + EglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); +#endif + + // We must check if EGL display is valid. + if (EglDisplay == EGL_NO_DISPLAY) { + os::Printer::log("Could not get EGL display."); + terminate(); + return false; + } + + // Initialize EGL here. + if (!eglInitialize(EglDisplay, &MajorVersion, &MinorVersion)) { + os::Printer::log("Could not initialize EGL display."); + + EglDisplay = EGL_NO_DISPLAY; + terminate(); + return false; + } else + os::Printer::log("EGL version", core::stringc(MajorVersion + (MinorVersion * 0.1f)).c_str()); + + return true; +} + +void CEGLManager::terminate() +{ + if (EglWindow == 0 && EglDisplay == EGL_NO_DISPLAY) + return; + + if (EglDisplay != EGL_NO_DISPLAY) { + // We should unbind current EGL context before terminate EGL. + eglMakeCurrent(EglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + + eglTerminate(EglDisplay); + EglDisplay = EGL_NO_DISPLAY; + } + +#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) + if (Data.OpenGLWin32.HDc) { + ReleaseDC((HWND)EglWindow, (HDC)Data.OpenGLWin32.HDc); + Data.OpenGLWin32.HDc = 0; + } +#endif + + MajorVersion = 0; + MinorVersion = 0; +} + +bool CEGLManager::generateSurface() +{ + if (EglDisplay == EGL_NO_DISPLAY) + return false; + + if (EglSurface != EGL_NO_SURFACE) + return true; + + // We should assign new WindowID on platforms, where WindowID may change at runtime, + // at this time only Android support this feature. + // this needs an update method instead! + +#if defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_) + EglWindow = (ANativeWindow *)Data.OGLESAndroid.Window; +#endif + +#if defined(_IRR_EMSCRIPTEN_PLATFORM_) + // eglChooseConfig is currently only implemented as stub in emscripten (version 1.37.22 at point of writing) + // But the other solution would also be fine as it also only generates a single context so there is not much to choose from. + EglConfig = chooseConfig(ECS_IRR_CHOOSE); +#else + EglConfig = chooseConfig(ECS_EGL_CHOOSE_FIRST_LOWER_EXPECTATIONS); +#endif + + if (EglConfig == 0) { + os::Printer::log("Could not get config for EGL display."); + return false; + } + +#if defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_) + EGLint Format = 0; + eglGetConfigAttrib(EglDisplay, EglConfig, EGL_NATIVE_VISUAL_ID, &Format); + + ANativeWindow_setBuffersGeometry(EglWindow, 0, 0, Format); +#endif + + // Now we are able to create EGL surface. + EglSurface = eglCreateWindowSurface(EglDisplay, EglConfig, EglWindow, 0); + + if (EGL_NO_SURFACE == EglSurface) + EglSurface = eglCreateWindowSurface(EglDisplay, EglConfig, 0, 0); + + if (EGL_NO_SURFACE == EglSurface) + os::Printer::log("Could not create EGL surface."); + +#ifdef EGL_VERSION_1_2 + if (MinorVersion > 1) + eglBindAPI(EGL_OPENGL_ES_API); +#endif + + if (Params.Vsync) + eglSwapInterval(EglDisplay, 1); + + return true; +} + +EGLConfig CEGLManager::chooseConfig(EConfigStyle confStyle) +{ + EGLConfig configResult = 0; + + // Find proper OpenGL BIT. + EGLint eglOpenGLBIT = 0; + switch (Params.DriverType) { + case EDT_OGLES1: + eglOpenGLBIT = EGL_OPENGL_ES_BIT; + break; + case EDT_OGLES2: + case EDT_WEBGL1: + eglOpenGLBIT = EGL_OPENGL_ES2_BIT; + break; + default: + break; + } + + if (confStyle == ECS_EGL_CHOOSE_FIRST_LOWER_EXPECTATIONS) { + EGLint Attribs[] = { + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, Params.WithAlphaChannel ? 1 : 0, + EGL_BUFFER_SIZE, Params.Bits, + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_DEPTH_SIZE, Params.ZBufferBits, + EGL_STENCIL_SIZE, Params.Stencilbuffer, + EGL_SAMPLE_BUFFERS, Params.AntiAlias ? 1 : 0, + EGL_SAMPLES, Params.AntiAlias, +#ifdef EGL_VERSION_1_3 + EGL_RENDERABLE_TYPE, eglOpenGLBIT, +#endif + EGL_NONE, 0, + }; + + EGLint numConfigs = 0; + u32 steps = 5; + + // Choose the best EGL config. + // TODO: We should also have a confStyle ECS_EGL_CHOOSE_CLOSEST + // which doesn't take first result of eglChooseConfigs, + // but the closest to requested parameters. eglChooseConfigs + // can return more than 1 result and first one might have + // "better" values than requested (more bits per pixel etc). + // So this returns the config which can do most, not the + // config which is closest to the requested parameters. + // + while (!eglChooseConfig(EglDisplay, Attribs, &configResult, 1, &numConfigs) || !numConfigs) { + switch (steps) { + case 5: // samples + if (Attribs[19] > 2) // Params.AntiAlias + --Attribs[19]; + else { + Attribs[17] = 0; // Params.Stencilbuffer + Attribs[19] = 0; // Params.AntiAlias + --steps; + } + break; + case 4: // alpha + if (Attribs[7]) { // Params.WithAlphaChannel + Attribs[7] = 0; + + if (Params.AntiAlias) { + Attribs[17] = 1; + Attribs[19] = Params.AntiAlias; + steps = 5; + } + } else + --steps; + break; + case 3: // stencil + if (Attribs[15]) { // Params.Stencilbuffer + Attribs[15] = 0; + + if (Params.AntiAlias) { + Attribs[17] = 1; + Attribs[19] = Params.AntiAlias; + steps = 5; + } + } else + --steps; + break; + case 2: // depth size + if (Attribs[13] > 16) { // Params.ZBufferBits + Attribs[13] -= 8; + } else + --steps; + break; + case 1: // buffer size + if (Attribs[9] > 16) { // Params.Bits + Attribs[9] -= 8; + } else + --steps; + break; + default: + return 0; + } + } + + if (Params.AntiAlias && !Attribs[17]) + os::Printer::log("No multisampling."); + + if (Params.WithAlphaChannel && !Attribs[7]) + os::Printer::log("No alpha."); + + if (Params.Stencilbuffer && !Attribs[15]) + os::Printer::log("No stencil buffer."); + + if (Params.ZBufferBits > Attribs[13]) + os::Printer::log("No full depth buffer."); + + if (Params.Bits > Attribs[9]) + os::Printer::log("No full color buffer."); + } else if (confStyle == ECS_IRR_CHOOSE) { + // find number of available configs + EGLint numConfigs; + if (eglGetConfigs(EglDisplay, NULL, 0, &numConfigs) == EGL_FALSE) { + testEGLError(); + return 0; + } + + if (numConfigs <= 0) + return 0; + + // Get all available configs. + EGLConfig *configs = new EGLConfig[numConfigs]; + if (eglGetConfigs(EglDisplay, configs, numConfigs, &numConfigs) == EGL_FALSE) { + testEGLError(); + return 0; + } + + // Find the best one. + core::array ratings((u32)numConfigs); + for (u32 i = 0; i < (u32)numConfigs; ++i) { + SConfigRating r; + r.config = configs[i]; + r.rating = rateConfig(r.config, eglOpenGLBIT); + + if (r.rating >= 0) + ratings.push_back(r); + } + + if (ratings.size() > 0) { + ratings.sort(); + configResult = ratings[0].config; + + if (ratings[0].rating != 0) { + // This is just to print some log info (it also rates again while doing that, but rating is cheap enough, so that doesn't matter here). + rateConfig(ratings[0].config, eglOpenGLBIT, true); + } + } + + delete[] configs; + } + + return configResult; +} + +irr::s32 CEGLManager::rateConfig(EGLConfig config, EGLint eglOpenGLBIT, bool log) +{ + // some values must be there or we ignore the config +#ifdef EGL_VERSION_1_3 + EGLint attribRenderableType = 0; + eglGetConfigAttrib(EglDisplay, config, EGL_RENDERABLE_TYPE, &attribRenderableType); + if (attribRenderableType != eglOpenGLBIT) { + if (log) + os::Printer::log("EGL_RENDERABLE_TYPE != eglOpenGLBIT"); + return -1; + } +#endif + EGLint attribSurfaceType = 0; + eglGetConfigAttrib(EglDisplay, config, EGL_SURFACE_TYPE, &attribSurfaceType); + if (attribSurfaceType != EGL_WINDOW_BIT) { + if (log) + os::Printer::log("EGL_SURFACE_TYPE!= EGL_WINDOW_BIT"); + return -1; + } + + // Generally we give a really bad rating if attributes are worse than requested + // We give a slight worse rating if attributes are not exact as requested + // And we use some priorities which might make sense (but not really fine-tuned, + // so if you think other priorities would be better don't worry about changing the values. + int rating = 0; + + EGLint attribBufferSize = 0; + eglGetConfigAttrib(EglDisplay, config, EGL_BUFFER_SIZE, &attribBufferSize); + if (attribBufferSize < Params.Bits) { + if (log) + os::Printer::log("No full color buffer."); + rating += 100; + } + if (attribBufferSize > Params.Bits) { + if (log) + os::Printer::log("Larger color buffer.", ELL_DEBUG); + ++rating; + } + + EGLint attribRedSize = 0; + eglGetConfigAttrib(EglDisplay, config, EGL_RED_SIZE, &attribRedSize); + if (attribRedSize < 5 && Params.Bits >= 4) + rating += 100; + else if (attribRedSize < 8 && Params.Bits >= 24) + rating += 10; + else if (attribRedSize >= 8 && Params.Bits < 24) + rating++; + EGLint attribGreenSize = 0; + eglGetConfigAttrib(EglDisplay, config, EGL_GREEN_SIZE, &attribGreenSize); + if (attribGreenSize < 5 && Params.Bits >= 4) + rating += 100; + else if (attribGreenSize < 8 && Params.Bits >= 24) + rating += 10; + else if (attribGreenSize >= 8 && Params.Bits < 24) + rating++; + EGLint attribBlueSize = 0; + eglGetConfigAttrib(EglDisplay, config, EGL_BLUE_SIZE, &attribBlueSize); + if (attribBlueSize < 5 && Params.Bits >= 4) + rating += 100; + else if (attribBlueSize < 8 && Params.Bits >= 24) + rating += 10; + else if (attribBlueSize >= 8 && Params.Bits < 24) + rating++; + + EGLint attribAlphaSize = 0; + eglGetConfigAttrib(EglDisplay, config, EGL_ALPHA_SIZE, &attribAlphaSize); + if (Params.WithAlphaChannel && attribAlphaSize == 0) { + if (log) + os::Printer::log("No alpha."); + rating += 10; + } else if (!Params.WithAlphaChannel && attribAlphaSize > 0) { + if (log) + os::Printer::log("Got alpha (unrequested).", ELL_DEBUG); + rating++; + } + + EGLint attribStencilSize = 0; + eglGetConfigAttrib(EglDisplay, config, EGL_STENCIL_SIZE, &attribStencilSize); + if (Params.Stencilbuffer && attribStencilSize == 0) { + if (log) + os::Printer::log("No stencil buffer."); + rating += 10; + } else if (!Params.Stencilbuffer && attribStencilSize > 0) { + if (log) + os::Printer::log("Got a stencil buffer (unrequested).", ELL_DEBUG); + rating++; + } + + EGLint attribDepthSize = 0; + eglGetConfigAttrib(EglDisplay, config, EGL_DEPTH_SIZE, &attribDepthSize); + if (attribDepthSize < Params.ZBufferBits) { + if (log) { + if (attribDepthSize > 0) + os::Printer::log("No full depth buffer."); + else + os::Printer::log("No depth buffer."); + } + rating += 50; + } else if (attribDepthSize != Params.ZBufferBits) { + if (log) { + if (Params.ZBufferBits == 0) + os::Printer::log("Got a depth buffer (unrequested).", ELL_DEBUG); + else + os::Printer::log("Got a larger depth buffer.", ELL_DEBUG); + } + rating++; + } + + EGLint attribSampleBuffers = 0, attribSamples = 0; + eglGetConfigAttrib(EglDisplay, config, EGL_SAMPLE_BUFFERS, &attribSampleBuffers); + eglGetConfigAttrib(EglDisplay, config, EGL_SAMPLES, &attribSamples); + if (Params.AntiAlias && attribSampleBuffers == 0) { + if (log) + os::Printer::log("No multisampling."); + rating += 20; + } else if (Params.AntiAlias && attribSampleBuffers && attribSamples < Params.AntiAlias) { + if (log) + os::Printer::log("Multisampling with less samples than requested.", ELL_DEBUG); + rating += 10; + } else if (Params.AntiAlias && attribSampleBuffers && attribSamples > Params.AntiAlias) { + if (log) + os::Printer::log("Multisampling with more samples than requested.", ELL_DEBUG); + rating += 5; + } else if (!Params.AntiAlias && attribSampleBuffers > 0) { + if (log) + os::Printer::log("Got multisampling (unrequested).", ELL_DEBUG); + rating += 3; + } + + return rating; +} + +void CEGLManager::destroySurface() +{ + if (EglSurface == EGL_NO_SURFACE) + return; + + // We should unbind current EGL context before destroy EGL surface. + eglMakeCurrent(EglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + + eglDestroySurface(EglDisplay, EglSurface); + EglSurface = EGL_NO_SURFACE; +} + +bool CEGLManager::generateContext() +{ + if (EglDisplay == EGL_NO_DISPLAY || EglSurface == EGL_NO_SURFACE) + return false; + + if (EglContext != EGL_NO_CONTEXT) + return true; + + EGLint OpenGLESVersion = 0; + + switch (Params.DriverType) { + case EDT_OGLES1: + OpenGLESVersion = 1; + break; + case EDT_OGLES2: + case EDT_WEBGL1: + OpenGLESVersion = 2; + break; + default: + break; + } + + EGLint ContextAttrib[] = { +#ifdef EGL_VERSION_1_3 + EGL_CONTEXT_CLIENT_VERSION, OpenGLESVersion, +#endif + EGL_NONE, 0, + }; + + EglContext = eglCreateContext(EglDisplay, EglConfig, EGL_NO_CONTEXT, ContextAttrib); + + if (testEGLError()) { + os::Printer::log("Could not create EGL context.", ELL_ERROR); + return false; + } + + os::Printer::log("EGL context created with OpenGLESVersion: ", core::stringc((int)OpenGLESVersion), ELL_DEBUG); + + return true; +} + +void CEGLManager::destroyContext() +{ + if (EglContext == EGL_NO_CONTEXT) + return; + + // We must unbind current EGL context before destroy it. + eglMakeCurrent(EglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglDestroyContext(EglDisplay, EglContext); + + EglContext = EGL_NO_CONTEXT; +} + +bool CEGLManager::activateContext(const SExposedVideoData &videoData, bool restorePrimaryOnZero) +{ + eglMakeCurrent(EglDisplay, EglSurface, EglSurface, EglContext); + + if (testEGLError()) { + os::Printer::log("Could not make EGL context current."); + return false; + } + return true; +} + +const SExposedVideoData &CEGLManager::getContext() const +{ + return Data; +} + +void *CEGLManager::getProcAddress(const std::string &procName) +{ + return (void *)eglGetProcAddress(procName.c_str()); +} + +bool CEGLManager::swapBuffers() +{ + return (eglSwapBuffers(EglDisplay, EglSurface) == EGL_TRUE); +} + +bool CEGLManager::testEGLError() +{ +#if defined(EGL_VERSION_1_0) && defined(_DEBUG) + EGLint status = eglGetError(); + + switch (status) { + case EGL_SUCCESS: + return false; + case EGL_NOT_INITIALIZED: + os::Printer::log("Not Initialized", ELL_ERROR); + break; + case EGL_BAD_ACCESS: + os::Printer::log("Bad Access", ELL_ERROR); + break; + case EGL_BAD_ALLOC: + os::Printer::log("Bad Alloc", ELL_ERROR); + break; + case EGL_BAD_ATTRIBUTE: + os::Printer::log("Bad Attribute", ELL_ERROR); + break; + case EGL_BAD_CONTEXT: + os::Printer::log("Bad Context", ELL_ERROR); + break; + case EGL_BAD_CONFIG: + os::Printer::log("Bad Config", ELL_ERROR); + break; + case EGL_BAD_CURRENT_SURFACE: + os::Printer::log("Bad Current Surface", ELL_ERROR); + break; + case EGL_BAD_DISPLAY: + os::Printer::log("Bad Display", ELL_ERROR); + break; + case EGL_BAD_SURFACE: + os::Printer::log("Bad Surface", ELL_ERROR); + break; + case EGL_BAD_MATCH: + os::Printer::log("Bad Match", ELL_ERROR); + break; + case EGL_BAD_PARAMETER: + os::Printer::log("Bad Parameter", ELL_ERROR); + break; + case EGL_BAD_NATIVE_PIXMAP: + os::Printer::log("Bad Native Pixmap", ELL_ERROR); + break; + case EGL_BAD_NATIVE_WINDOW: + os::Printer::log("Bad Native Window", ELL_ERROR); + break; + case EGL_CONTEXT_LOST: + os::Printer::log("Context Lost", ELL_ERROR); + break; + default: + break; + }; + + return true; +#else + return false; +#endif +} + +} +} + +#endif diff --git a/irr/src/CEGLManager.h b/irr/src/CEGLManager.h new file mode 100644 index 000000000..49371e469 --- /dev/null +++ b/irr/src/CEGLManager.h @@ -0,0 +1,114 @@ +// Copyright (C) 2013 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#pragma once + +#ifdef _IRR_COMPILE_WITH_EGL_MANAGER_ + +#include + +#include "SIrrCreationParameters.h" +#include "SExposedVideoData.h" +#include "IContextManager.h" + +namespace irr +{ +namespace video +{ +// EGL manager. +class CEGLManager : public IContextManager +{ +public: + //! Constructor. + CEGLManager(); + + //! Destructor. + virtual ~CEGLManager(); + + // Initialize EGL. + /* This method initialize EGLand create EGL display, anyway surface and context + aren't create. */ + bool initialize(const SIrrlichtCreationParameters ¶ms, const SExposedVideoData &data) override; + + // Terminate EGL. + /* Terminate EGL context. This method break both existed surface and context. */ + void terminate() override; + + // Create EGL surface. + /* This method create EGL surface. On some platforms eg. Android, we must + recreate surface on each resume, because WindowID may change, so existed + surface may not be valid. If EGL context already exist, this method + automatically activates it. */ + bool generateSurface() override; + + // Destroy EGL surface. + /* This method destroy EGL. On some platforms eg. Android, we should call + this method on each pause, because after resume this surface may not be valid. + Hovewer this method doesn'r break EGL context. */ + void destroySurface() override; + + // Create EGL context. + /* This method create and activate EGL context. */ + bool generateContext() override; + + // Destroy EGL context. + /* This method destroy EGL context. */ + void destroyContext() override; + + const SExposedVideoData &getContext() const override; + + bool activateContext(const SExposedVideoData &videoData, bool restorePrimaryOnZero) override; + + // Get procedure address. + void *getProcAddress(const std::string &procName) override; + + // Swap buffers. + bool swapBuffers() override; + +protected: + enum EConfigStyle + { + //! Get first result of eglChooseConfigs and if that fails try again by requesting simpler attributes + ECS_EGL_CHOOSE_FIRST_LOWER_EXPECTATIONS, + + //! We select our own best fit and avoid using eglChooseConfigs + ECS_IRR_CHOOSE, + }; + + EGLConfig chooseConfig(EConfigStyle confStyle); + + //! Check how close this config is to the parameters we requested + //! returns 0 is perfect, larger values are worse and < 0 is unusable. + irr::s32 rateConfig(EGLConfig config, EGLint eglOpenGLBIT, bool log = false); + + // Helper to sort EGLConfig's. (because we got no std::pair....) + struct SConfigRating + { + EGLConfig config; + irr::s32 rating; + bool operator<(const SConfigRating &other) const + { + return rating < other.rating; + } + }; + +private: + bool testEGLError(); + + NativeWindowType EglWindow; + EGLDisplay EglDisplay; + EGLSurface EglSurface; + EGLContext EglContext; + + EGLConfig EglConfig; + + SIrrlichtCreationParameters Params; + SExposedVideoData Data; + + EGLint MajorVersion; + EGLint MinorVersion; +}; +} +} +#endif diff --git a/irr/src/CEmptySceneNode.cpp b/irr/src/CEmptySceneNode.cpp new file mode 100644 index 000000000..2b965a198 --- /dev/null +++ b/irr/src/CEmptySceneNode.cpp @@ -0,0 +1,65 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CEmptySceneNode.h" +#include "ISceneManager.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CEmptySceneNode::CEmptySceneNode(ISceneNode *parent, ISceneManager *mgr, s32 id) : + ISceneNode(parent, mgr, id) +{ +#ifdef _DEBUG + setDebugName("CEmptySceneNode"); +#endif + + setAutomaticCulling(scene::EAC_OFF); +} + +//! pre render event +void CEmptySceneNode::OnRegisterSceneNode() +{ + if (IsVisible) + SceneManager->registerNodeForRendering(this); + + ISceneNode::OnRegisterSceneNode(); +} + +//! render +void CEmptySceneNode::render() +{ + // do nothing +} + +//! returns the axis aligned bounding box of this node +const core::aabbox3d &CEmptySceneNode::getBoundingBox() const +{ + return Box; +} + +//! Creates a clone of this scene node and its children. +ISceneNode *CEmptySceneNode::clone(ISceneNode *newParent, ISceneManager *newManager) +{ + if (!newParent) + newParent = Parent; + if (!newManager) + newManager = SceneManager; + + CEmptySceneNode *nb = new CEmptySceneNode(newParent, + newManager, ID); + + nb->cloneMembers(this, newManager); + nb->Box = Box; + + if (newParent) + nb->drop(); + return nb; +} + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CEmptySceneNode.h b/irr/src/CEmptySceneNode.h new file mode 100644 index 000000000..c89ad59ae --- /dev/null +++ b/irr/src/CEmptySceneNode.h @@ -0,0 +1,40 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "ISceneNode.h" + +namespace irr +{ +namespace scene +{ + +class CEmptySceneNode : public ISceneNode +{ +public: + //! constructor + CEmptySceneNode(ISceneNode *parent, ISceneManager *mgr, s32 id); + + //! returns the axis aligned bounding box of this node + const core::aabbox3d &getBoundingBox() const override; + + //! This method is called just before the rendering process of the whole scene. + void OnRegisterSceneNode() override; + + //! does nothing. + void render() override; + + //! Returns type of the scene node + ESCENE_NODE_TYPE getType() const override { return ESNT_EMPTY; } + + //! Creates a clone of this scene node and its children. + ISceneNode *clone(ISceneNode *newParent = 0, ISceneManager *newManager = 0) override; + +private: + core::aabbox3d Box; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CFPSCounter.cpp b/irr/src/CFPSCounter.cpp new file mode 100644 index 000000000..6717df5c9 --- /dev/null +++ b/irr/src/CFPSCounter.cpp @@ -0,0 +1,66 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CFPSCounter.h" +#include "irrMath.h" + +namespace irr +{ +namespace video +{ + +CFPSCounter::CFPSCounter() : + FPS(60), Primitive(0), StartTime(0), FramesCounted(0), + PrimitivesCounted(0), PrimitiveAverage(0), PrimitiveTotal(0) +{ +} + +//! returns current fps +s32 CFPSCounter::getFPS() const +{ + return FPS; +} + +//! returns current primitive count +u32 CFPSCounter::getPrimitive() const +{ + return Primitive; +} + +//! returns average primitive count of last period +u32 CFPSCounter::getPrimitiveAverage() const +{ + return PrimitiveAverage; +} + +//! returns accumulated primitive count since start +u32 CFPSCounter::getPrimitiveTotal() const +{ + return PrimitiveTotal; +} + +//! to be called every frame +void CFPSCounter::registerFrame(u32 now, u32 primitivesDrawn) +{ + ++FramesCounted; + PrimitiveTotal += primitivesDrawn; + PrimitivesCounted += primitivesDrawn; + Primitive = primitivesDrawn; + + const u32 milliseconds = now - StartTime; + + if (milliseconds >= 1500) { + const f32 invMilli = core::reciprocal((f32)milliseconds); + + FPS = core::ceil32((1000 * FramesCounted) * invMilli); + PrimitiveAverage = core::ceil32((1000 * PrimitivesCounted) * invMilli); + + FramesCounted = 0; + PrimitivesCounted = 0; + StartTime = now; + } +} + +} // end namespace video +} // end namespace irr diff --git a/irr/src/CFPSCounter.h b/irr/src/CFPSCounter.h new file mode 100644 index 000000000..e73afb049 --- /dev/null +++ b/irr/src/CFPSCounter.h @@ -0,0 +1,46 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" + +namespace irr +{ +namespace video +{ + +class CFPSCounter +{ +public: + CFPSCounter(); + + //! returns current fps + s32 getFPS() const; + + //! returns primitive count + u32 getPrimitive() const; + + //! returns average primitive count of last period + u32 getPrimitiveAverage() const; + + //! returns accumulated primitive count since start + u32 getPrimitiveTotal() const; + + //! to be called every frame + void registerFrame(u32 now, u32 primitive); + +private: + s32 FPS; + u32 Primitive; + u32 StartTime; + + u32 FramesCounted; + u32 PrimitivesCounted; + u32 PrimitiveAverage; + u32 PrimitiveTotal; +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/src/CFileList.cpp b/irr/src/CFileList.cpp new file mode 100644 index 000000000..dde8e75ac --- /dev/null +++ b/irr/src/CFileList.cpp @@ -0,0 +1,155 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CFileList.h" +#include "irrArray.h" +#include "coreutil.h" + +#include "os.h" + +namespace irr +{ +namespace io +{ + +static const io::path emptyFileListEntry; + +CFileList::CFileList(const io::path &path, bool ignoreCase, bool ignorePaths) : + IgnorePaths(ignorePaths), IgnoreCase(ignoreCase), Path(path) +{ +#ifdef _DEBUG + setDebugName("CFileList"); +#endif + + Path.replace('\\', '/'); +} + +CFileList::~CFileList() +{ + Files.clear(); +} + +u32 CFileList::getFileCount() const +{ + return Files.size(); +} + +void CFileList::sort() +{ + Files.sort(); +} + +const io::path &CFileList::getFileName(u32 index) const +{ + if (index >= Files.size()) + return emptyFileListEntry; + + return Files[index].Name; +} + +//! Gets the full name of a file in the list, path included, based on an index. +const io::path &CFileList::getFullFileName(u32 index) const +{ + if (index >= Files.size()) + return emptyFileListEntry; + + return Files[index].FullName; +} + +//! adds a file or folder +u32 CFileList::addItem(const io::path &fullPath, u32 offset, u32 size, bool isDirectory, u32 id) +{ + SFileListEntry entry; + entry.ID = id ? id : Files.size(); + entry.Offset = offset; + entry.Size = size; + entry.Name = fullPath; + entry.Name.replace('\\', '/'); + entry.IsDirectory = isDirectory; + + // remove trailing slash + if (entry.Name.lastChar() == '/') { + entry.IsDirectory = true; + entry.Name[entry.Name.size() - 1] = 0; + entry.Name.validate(); + } + + if (IgnoreCase) + entry.Name.make_lower(); + + entry.FullName = entry.Name; + + core::deletePathFromFilename(entry.Name); + + if (IgnorePaths) + entry.FullName = entry.Name; + + // os::Printer::log(Path.c_str(), entry.FullName); + + Files.push_back(entry); + + return Files.size() - 1; +} + +//! Returns the ID of a file in the file list, based on an index. +u32 CFileList::getID(u32 index) const +{ + return index < Files.size() ? Files[index].ID : 0; +} + +bool CFileList::isDirectory(u32 index) const +{ + bool ret = false; + if (index < Files.size()) + ret = Files[index].IsDirectory; + + return ret; +} + +//! Returns the size of a file +u32 CFileList::getFileSize(u32 index) const +{ + return index < Files.size() ? Files[index].Size : 0; +} + +u32 CFileList::getFileOffset(u32 index) const +{ + return index < Files.size() ? Files[index].Offset : 0; +} + +//! Searches for a file or folder within the list, returns the index +s32 CFileList::findFile(const io::path &filename, bool isDirectory = false) const +{ + SFileListEntry entry; + // we only need FullName to be set for the search + entry.FullName = filename; + entry.IsDirectory = isDirectory; + + // exchange + entry.FullName.replace('\\', '/'); + + // remove trailing slash + if (entry.FullName.lastChar() == '/') { + entry.IsDirectory = true; + entry.FullName[entry.FullName.size() - 1] = 0; + entry.FullName.validate(); + } + + if (IgnoreCase) + entry.FullName.make_lower(); + + if (IgnorePaths) + core::deletePathFromFilename(entry.FullName); + + return Files.binary_search(entry); +} + +//! Returns the base path of the file list +const io::path &CFileList::getPath() const +{ + return Path; +} + +} // end namespace irr +} // end namespace io diff --git a/irr/src/CFileList.h b/irr/src/CFileList.h new file mode 100644 index 000000000..1af975b22 --- /dev/null +++ b/irr/src/CFileList.h @@ -0,0 +1,128 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IFileList.h" +#include "irrString.h" +#include "irrArray.h" + +namespace irr +{ +namespace io +{ + +//! An entry in a list of files, can be a folder or a file. +struct SFileListEntry +{ + //! The name of the file + /** If this is a file or folder in the virtual filesystem and the archive + was created with the ignoreCase flag then the file name will be lower case. */ + io::path Name; + + //! The name of the file including the path + /** If this is a file or folder in the virtual filesystem and the archive was + created with the ignoreDirs flag then it will be the same as Name. */ + io::path FullName; + + //! The size of the file in bytes + u32 Size; + + //! The ID of the file in an archive + /** This is used to link the FileList entry to extra info held about this + file in an archive, which can hold things like data offset and CRC. */ + u32 ID; + + //! FileOffset inside an archive + u32 Offset; + + //! True if this is a folder, false if not. + bool IsDirectory; + + //! The == operator is provided so that CFileList can slowly search the list! + bool operator==(const struct SFileListEntry &other) const + { + if (IsDirectory != other.IsDirectory) + return false; + + return FullName.equals_ignore_case(other.FullName); + } + + //! The < operator is provided so that CFileList can sort and quickly search the list. + bool operator<(const struct SFileListEntry &other) const + { + if (IsDirectory != other.IsDirectory) + return IsDirectory; + + return FullName.lower_ignore_case(other.FullName); + } +}; + +//! Implementation of a file list +class CFileList : public IFileList +{ +public: + // CFileList methods + + //! Constructor + /** \param path The path of this file archive */ + CFileList(const io::path &path, bool ignoreCase, bool ignorePaths); + + //! Destructor + virtual ~CFileList(); + + //! Add as a file or folder to the list + /** \param fullPath The file name including path, up to the root of the file list. + \param isDirectory True if this is a directory rather than a file. + \param offset The offset where the file is stored in an archive + \param size The size of the file in bytes. + \param id The ID of the file in the archive which owns it */ + u32 addItem(const io::path &fullPath, u32 offset, u32 size, bool isDirectory, u32 id = 0) override; + + //! Sorts the file list. You should call this after adding any items to the file list + void sort() override; + + //! Returns the amount of files in the filelist. + u32 getFileCount() const override; + + //! Gets the name of a file in the list, based on an index. + const io::path &getFileName(u32 index) const override; + + //! Gets the full name of a file in the list, path included, based on an index. + const io::path &getFullFileName(u32 index) const override; + + //! Returns the ID of a file in the file list, based on an index. + u32 getID(u32 index) const override; + + //! Returns true if the file is a directory + bool isDirectory(u32 index) const override; + + //! Returns the size of a file + u32 getFileSize(u32 index) const override; + + //! Returns the offset of a file + u32 getFileOffset(u32 index) const override; + + //! Searches for a file or folder within the list, returns the index + s32 findFile(const io::path &filename, bool isFolder) const override; + + //! Returns the base path of the file list + const io::path &getPath() const override; + +protected: + //! Ignore paths when adding or searching for files + bool IgnorePaths; + + //! Ignore case when adding or searching for files + bool IgnoreCase; + + //! Path to the file list + io::path Path; + + //! List of files + core::array Files; +}; + +} // end namespace irr +} // end namespace io diff --git a/irr/src/CFileSystem.cpp b/irr/src/CFileSystem.cpp new file mode 100644 index 000000000..bffb703dd --- /dev/null +++ b/irr/src/CFileSystem.cpp @@ -0,0 +1,762 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CFileSystem.h" +#include "IReadFile.h" +#include "IWriteFile.h" +#include "CZipReader.h" +#include "CFileList.h" +#include "stdio.h" +#include "os.h" +#include "CReadFile.h" +#include "CMemoryFile.h" +#include "CLimitReadFile.h" +#include "CWriteFile.h" +#include + +#if defined(__STRICT_ANSI__) +#error Compiling with __STRICT_ANSI__ not supported. g++ does set this when compiling with -std=c++11 or -std=c++0x. Use instead -std=gnu++11 or -std=gnu++0x. Or use -U__STRICT_ANSI__ to disable strict ansi. +#endif + +#if defined(_IRR_WINDOWS_API_) +#include // for _chdir +#include // for _access +#include +#elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_) || defined(_IRR_ANDROID_PLATFORM_)) +#include +#include +#include +#include +#include +#include +#include +#include +#elif defined(_IRR_EMSCRIPTEN_PLATFORM_) +#include +#endif + +namespace irr +{ +namespace io +{ + +//! constructor +CFileSystem::CFileSystem() +{ +#ifdef _DEBUG + setDebugName("CFileSystem"); +#endif + + setFileListSystem(FILESYSTEM_NATIVE); + //! reset current working directory + getWorkingDirectory(); + + ArchiveLoader.push_back(new CArchiveLoaderZIP(this)); +} + +//! destructor +CFileSystem::~CFileSystem() +{ + u32 i; + + for (i = 0; i < FileArchives.size(); ++i) { + FileArchives[i]->drop(); + } + + for (i = 0; i < ArchiveLoader.size(); ++i) { + ArchiveLoader[i]->drop(); + } +} + +//! opens a file for read access +IReadFile *CFileSystem::createAndOpenFile(const io::path &filename) +{ + if (filename.empty()) + return 0; + + IReadFile *file = 0; + u32 i; + + for (i = 0; i < FileArchives.size(); ++i) { + file = FileArchives[i]->createAndOpenFile(filename); + if (file) + return file; + } + + // Create the file using an absolute path so that it matches + // the scheme used by CNullDriver::getTexture(). + return CReadFile::createReadFile(getAbsolutePath(filename)); +} + +//! Creates an IReadFile interface for treating memory like a file. +IReadFile *CFileSystem::createMemoryReadFile(const void *memory, s32 len, + const io::path &fileName, bool deleteMemoryWhenDropped) +{ + if (!memory) + return 0; + else + return new CMemoryReadFile(memory, len, fileName, deleteMemoryWhenDropped); +} + +//! Creates an IReadFile interface for reading files inside files +IReadFile *CFileSystem::createLimitReadFile(const io::path &fileName, + IReadFile *alreadyOpenedFile, long pos, long areaSize) +{ + if (!alreadyOpenedFile) + return 0; + else + return new CLimitReadFile(alreadyOpenedFile, pos, areaSize, fileName); +} + +//! Creates an IReadFile interface for treating memory like a file. +IWriteFile *CFileSystem::createMemoryWriteFile(void *memory, s32 len, + const io::path &fileName, bool deleteMemoryWhenDropped) +{ + if (!memory) + return 0; + else + return new CMemoryWriteFile(memory, len, fileName, deleteMemoryWhenDropped); +} + +//! Opens a file for write access. +IWriteFile *CFileSystem::createAndWriteFile(const io::path &filename, bool append) +{ + return CWriteFile::createWriteFile(filename, append); +} + +//! Adds an external archive loader to the engine. +void CFileSystem::addArchiveLoader(IArchiveLoader *loader) +{ + if (!loader) + return; + + loader->grab(); + ArchiveLoader.push_back(loader); +} + +//! Returns the total number of archive loaders added. +u32 CFileSystem::getArchiveLoaderCount() const +{ + return ArchiveLoader.size(); +} + +//! Gets the archive loader by index. +IArchiveLoader *CFileSystem::getArchiveLoader(u32 index) const +{ + if (index < ArchiveLoader.size()) + return ArchiveLoader[index]; + else + return 0; +} + +//! move the hirarchy of the filesystem. moves sourceIndex relative up or down +bool CFileSystem::moveFileArchive(u32 sourceIndex, s32 relative) +{ + bool r = false; + const s32 dest = (s32)sourceIndex + relative; + const s32 dir = relative < 0 ? -1 : 1; + const s32 sourceEnd = ((s32)FileArchives.size()) - 1; + IFileArchive *t; + + for (s32 s = (s32)sourceIndex; s != dest; s += dir) { + if (s < 0 || s > sourceEnd || s + dir < 0 || s + dir > sourceEnd) + continue; + + t = FileArchives[s + dir]; + FileArchives[s + dir] = FileArchives[s]; + FileArchives[s] = t; + r = true; + } + return r; +} + +//! Adds an archive to the file system. +bool CFileSystem::addFileArchive(const io::path &filename, bool ignoreCase, + bool ignorePaths, E_FILE_ARCHIVE_TYPE archiveType, + const core::stringc &password, + IFileArchive **retArchive) +{ + IFileArchive *archive = 0; + bool ret = false; + + // see if archive is already added + + s32 i; + + // do we know what type it should be? + if (archiveType == EFAT_UNKNOWN) { + // try to load archive based on file name + for (i = ArchiveLoader.size() - 1; i >= 0; --i) { + if (ArchiveLoader[i]->isALoadableFileFormat(filename)) { + archive = ArchiveLoader[i]->createArchive(filename, ignoreCase, ignorePaths); + if (archive) + break; + } + } + + // try to load archive based on content + if (!archive) { + io::IReadFile *file = createAndOpenFile(filename); + if (file) { + for (i = ArchiveLoader.size() - 1; i >= 0; --i) { + file->seek(0); + if (ArchiveLoader[i]->isALoadableFileFormat(file)) { + file->seek(0); + archive = ArchiveLoader[i]->createArchive(file, ignoreCase, ignorePaths); + if (archive) + break; + } + } + file->drop(); + } + } + } else { + // try to open archive based on archive loader type + + io::IReadFile *file = 0; + + for (i = ArchiveLoader.size() - 1; i >= 0; --i) { + if (ArchiveLoader[i]->isALoadableFileFormat(archiveType)) { + // attempt to open file + if (!file) + file = createAndOpenFile(filename); + + // is the file open? + if (file) { + // attempt to open archive + file->seek(0); + if (ArchiveLoader[i]->isALoadableFileFormat(file)) { + file->seek(0); + archive = ArchiveLoader[i]->createArchive(file, ignoreCase, ignorePaths); + if (archive) + break; + } + } else { + // couldn't open file + break; + } + } + } + + // if open, close the file + if (file) + file->drop(); + } + + if (archive) { + FileArchives.push_back(archive); + if (password.size()) + archive->Password = password; + if (retArchive) + *retArchive = archive; + ret = true; + } else { + os::Printer::log("Could not create archive for", filename, ELL_ERROR); + } + + return ret; +} + +bool CFileSystem::addFileArchive(IReadFile *file, bool ignoreCase, + bool ignorePaths, E_FILE_ARCHIVE_TYPE archiveType, + const core::stringc &password, IFileArchive **retArchive) +{ + if (!file) + return false; + + if (file) { + IFileArchive *archive = 0; + s32 i; + + if (archiveType == EFAT_UNKNOWN) { + // try to load archive based on file name + for (i = ArchiveLoader.size() - 1; i >= 0; --i) { + if (ArchiveLoader[i]->isALoadableFileFormat(file->getFileName())) { + archive = ArchiveLoader[i]->createArchive(file, ignoreCase, ignorePaths); + if (archive) + break; + } + } + + // try to load archive based on content + if (!archive) { + for (i = ArchiveLoader.size() - 1; i >= 0; --i) { + file->seek(0); + if (ArchiveLoader[i]->isALoadableFileFormat(file)) { + file->seek(0); + archive = ArchiveLoader[i]->createArchive(file, ignoreCase, ignorePaths); + if (archive) + break; + } + } + } + } else { + // try to open archive based on archive loader type + for (i = ArchiveLoader.size() - 1; i >= 0; --i) { + if (ArchiveLoader[i]->isALoadableFileFormat(archiveType)) { + // attempt to open archive + file->seek(0); + if (ArchiveLoader[i]->isALoadableFileFormat(file)) { + file->seek(0); + archive = ArchiveLoader[i]->createArchive(file, ignoreCase, ignorePaths); + if (archive) + break; + } + } + } + } + + if (archive) { + FileArchives.push_back(archive); + if (password.size()) + archive->Password = password; + if (retArchive) + *retArchive = archive; + return true; + } else { + os::Printer::log("Could not create archive for", file->getFileName(), ELL_ERROR); + } + } + + return false; +} + +//! Adds an archive to the file system. +bool CFileSystem::addFileArchive(IFileArchive *archive) +{ + if (archive) { + for (u32 i = 0; i < FileArchives.size(); ++i) { + if (archive == FileArchives[i]) { + return false; + } + } + FileArchives.push_back(archive); + archive->grab(); + + return true; + } + + return false; +} + +//! removes an archive from the file system. +bool CFileSystem::removeFileArchive(u32 index) +{ + bool ret = false; + if (index < FileArchives.size()) { + FileArchives[index]->drop(); + FileArchives.erase(index); + ret = true; + } + return ret; +} + +//! removes an archive from the file system. +bool CFileSystem::removeFileArchive(const io::path &filename) +{ + const path absPath = getAbsolutePath(filename); + for (u32 i = 0; i < FileArchives.size(); ++i) { + if (absPath == FileArchives[i]->getFileList()->getPath()) + return removeFileArchive(i); + } + return false; +} + +//! Removes an archive from the file system. +bool CFileSystem::removeFileArchive(const IFileArchive *archive) +{ + for (u32 i = 0; i < FileArchives.size(); ++i) { + if (archive == FileArchives[i]) { + return removeFileArchive(i); + } + } + return false; +} + +//! gets an archive +u32 CFileSystem::getFileArchiveCount() const +{ + return FileArchives.size(); +} + +IFileArchive *CFileSystem::getFileArchive(u32 index) +{ + return index < getFileArchiveCount() ? FileArchives[index] : 0; +} + +//! Returns the string of the current working directory +const io::path &CFileSystem::getWorkingDirectory() +{ + EFileSystemType type = FileSystemType; + + if (type != FILESYSTEM_NATIVE) { + type = FILESYSTEM_VIRTUAL; + } else { +#if defined(_IRR_WINDOWS_API_) + fschar_t tmp[_MAX_PATH]; + _getcwd(tmp, _MAX_PATH); + WorkingDirectory[FILESYSTEM_NATIVE] = tmp; + WorkingDirectory[FILESYSTEM_NATIVE].replace('\\', '/'); +#endif + +#if (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_)) + + // getting the CWD is rather complex as we do not know the size + // so try it until the call was successful + // Note that neither the first nor the second parameter may be 0 according to POSIX + + u32 pathSize = 256; + char *tmpPath = new char[pathSize]; + while ((pathSize < (1 << 16)) && !(getcwd(tmpPath, pathSize))) { + delete[] tmpPath; + pathSize *= 2; + tmpPath = new char[pathSize]; + } + if (tmpPath) { + WorkingDirectory[FILESYSTEM_NATIVE] = tmpPath; + delete[] tmpPath; + } +#endif + + WorkingDirectory[type].validate(); + } + + return WorkingDirectory[type]; +} + +//! Changes the current Working Directory to the given string. +bool CFileSystem::changeWorkingDirectoryTo(const io::path &newDirectory) +{ + bool success = false; + + if (FileSystemType != FILESYSTEM_NATIVE) { + WorkingDirectory[FILESYSTEM_VIRTUAL] = newDirectory; + // is this empty string constant really intended? + flattenFilename(WorkingDirectory[FILESYSTEM_VIRTUAL], _IRR_TEXT("")); + success = true; + } else { + WorkingDirectory[FILESYSTEM_NATIVE] = newDirectory; + +#if defined(_MSC_VER) + success = (_chdir(newDirectory.c_str()) == 0); +#else + success = (chdir(newDirectory.c_str()) == 0); +#endif + } + + return success; +} + +io::path CFileSystem::getAbsolutePath(const io::path &filename) const +{ + if (filename.empty()) + return filename; +#if defined(_IRR_WINDOWS_API_) + fschar_t *p = 0; + fschar_t fpath[_MAX_PATH]; + p = _fullpath(fpath, filename.c_str(), _MAX_PATH); + core::stringc tmp(p); + tmp.replace('\\', '/'); + return tmp; +#elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_)) + c8 *p = 0; + c8 fpath[4096]; + fpath[0] = 0; + p = realpath(filename.c_str(), fpath); + if (!p) { + // content in fpath is unclear at this point + if (!fpath[0]) { // seems like fpath wasn't altered, use our best guess + io::path tmp(filename); + return flattenFilename(tmp); + } else + return io::path(fpath); + } + if (filename[filename.size() - 1] == '/') + return io::path(p) + _IRR_TEXT("/"); + else + return io::path(p); +#else + return io::path(filename); +#endif +} + +//! returns the directory part of a filename, i.e. all until the first +//! slash or backslash, excluding it. If no directory path is prefixed, a '.' +//! is returned. +io::path CFileSystem::getFileDir(const io::path &filename) const +{ + // find last forward or backslash + s32 lastSlash = filename.findLast('/'); + const s32 lastBackSlash = filename.findLast('\\'); + lastSlash = lastSlash > lastBackSlash ? lastSlash : lastBackSlash; + + if ((u32)lastSlash < filename.size()) + return filename.subString(0, lastSlash); + else + return _IRR_TEXT("."); +} + +//! returns the base part of a filename, i.e. all except for the directory +//! part. If no directory path is prefixed, the full name is returned. +io::path CFileSystem::getFileBasename(const io::path &filename, bool keepExtension) const +{ + // find last forward or backslash + s32 lastSlash = filename.findLast('/'); + const s32 lastBackSlash = filename.findLast('\\'); + lastSlash = core::max_(lastSlash, lastBackSlash); + + // get number of chars after last dot + s32 end = 0; + if (!keepExtension) { + // take care to search only after last slash to check only for + // dots in the filename + end = filename.findLast('.'); + if (end == -1 || end < lastSlash) + end = 0; + else + end = filename.size() - end; + } + + if ((u32)lastSlash < filename.size()) + return filename.subString(lastSlash + 1, filename.size() - lastSlash - 1 - end); + else if (end != 0) + return filename.subString(0, filename.size() - end); + else + return filename; +} + +//! flatten a path and file name for example: "/you/me/../." becomes "/you" +io::path &CFileSystem::flattenFilename(io::path &directory, const io::path &root) const +{ + directory.replace('\\', '/'); + if (directory.lastChar() != '/') + directory.append('/'); + + io::path dir; + io::path subdir; + + s32 lastpos = 0; + s32 pos = 0; + bool lastWasRealDir = false; + + while ((pos = directory.findNext('/', lastpos)) >= 0) { + subdir = directory.subString(lastpos, pos - lastpos + 1); + + if (subdir == _IRR_TEXT("../")) { + if (lastWasRealDir) { + deletePathFromPath(dir, 2); + lastWasRealDir = (dir.size() != 0); + } else { + dir.append(subdir); + lastWasRealDir = false; + } + } else if (subdir == _IRR_TEXT("/")) { + dir = root; + } else if (subdir != _IRR_TEXT("./")) { + dir.append(subdir); + lastWasRealDir = true; + } + + lastpos = pos + 1; + } + directory = dir; + return directory; +} + +//! Get the relative filename, relative to the given directory +path CFileSystem::getRelativeFilename(const path &filename, const path &directory) const +{ + if (filename.empty() || directory.empty()) + return filename; + + io::path path1, file, ext; + core::splitFilename(getAbsolutePath(filename), &path1, &file, &ext); + io::path path2(getAbsolutePath(directory)); + std::list list1, list2; + path1.split(list1, _IRR_TEXT("/\\"), 2); + path2.split(list2, _IRR_TEXT("/\\"), 2); + std::list::const_iterator it1, it2; + it1 = list1.begin(); + it2 = list2.begin(); + +#if defined(_IRR_WINDOWS_API_) + fschar_t partition1 = 0, partition2 = 0; + io::path prefix1, prefix2; + if (it1 != list1.end()) + prefix1 = *it1; + if (it2 != list2.end()) + prefix2 = *it2; + if (prefix1.size() > 1 && prefix1[1] == _IRR_TEXT(':')) + partition1 = core::locale_lower(prefix1[0]); + if (prefix2.size() > 1 && prefix2[1] == _IRR_TEXT(':')) + partition2 = core::locale_lower(prefix2[0]); + + // must have the same prefix or we can't resolve it to a relative filename + if (partition1 != partition2) { + return filename; + } +#endif + + for (; it1 != list1.end() && it2 != list2.end() +#if defined(_IRR_WINDOWS_API_) + && (io::path(*it1).make_lower() == io::path(*it2).make_lower()) +#else + && (*it1 == *it2) +#endif + ;) { + ++it1; + ++it2; + } + path1 = _IRR_TEXT(""); + for (; it2 != list2.end(); ++it2) + path1 += _IRR_TEXT("../"); + while (it1 != list1.end()) { + path1 += *it1++; + path1 += _IRR_TEXT('/'); + } + path1 += file; + if (ext.size()) { + path1 += _IRR_TEXT('.'); + path1 += ext; + } + return path1; +} + +//! Sets the current file systen type +EFileSystemType CFileSystem::setFileListSystem(EFileSystemType listType) +{ + EFileSystemType current = FileSystemType; + FileSystemType = listType; + return current; +} + +//! Creates a list of files and directories in the current working directory +IFileList *CFileSystem::createFileList() +{ + CFileList *r = 0; + io::path Path = getWorkingDirectory(); + Path.replace('\\', '/'); + if (!Path.empty() && Path.lastChar() != '/') + Path.append('/'); + + //! Construct from native filesystem + if (FileSystemType == FILESYSTEM_NATIVE) { +// -------------------------------------------- +//! Windows version +#ifdef _IRR_WINDOWS_API_ + + r = new CFileList(Path, true, false); + + // intptr_t is optional but supported by MinGW since 2007 or earlier. + intptr_t hFile; + struct _tfinddata_t c_file; + if ((hFile = _tfindfirst(_T("*"), &c_file)) != (intptr_t)(-1L)) { + do { + r->addItem(Path + c_file.name, 0, c_file.size, (_A_SUBDIR & c_file.attrib) != 0, 0); + } while (_tfindnext(hFile, &c_file) == 0); + + _findclose(hFile); + } + +#endif + +// -------------------------------------------- +//! Linux version +#if (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_)) + + r = new CFileList(Path, false, false); + + r->addItem(Path + _IRR_TEXT(".."), 0, 0, true, 0); + + //! We use the POSIX compliant methods instead of scandir + DIR *dirHandle = opendir(Path.c_str()); + if (dirHandle) { + struct dirent *dirEntry; + while ((dirEntry = readdir(dirHandle))) { + u32 size = 0; + bool isDirectory = false; + + if ((strcmp(dirEntry->d_name, ".") == 0) || + (strcmp(dirEntry->d_name, "..") == 0)) { + continue; + } + struct stat buf; + if (stat(dirEntry->d_name, &buf) == 0) { + size = buf.st_size; + isDirectory = S_ISDIR(buf.st_mode); + } +#if !defined(_IRR_SOLARIS_PLATFORM_) && !defined(__CYGWIN__) && !defined(__HAIKU__) + // only available on some systems + else { + isDirectory = dirEntry->d_type == DT_DIR; + } +#endif + + r->addItem(Path + dirEntry->d_name, 0, size, isDirectory, 0); + } + closedir(dirHandle); + } +#endif + } else { + //! create file list for the virtual filesystem + r = new CFileList(Path, false, false); + + //! add relative navigation + SFileListEntry e2; + SFileListEntry e3; + + //! PWD + r->addItem(Path + _IRR_TEXT("."), 0, 0, true, 0); + + //! parent + r->addItem(Path + _IRR_TEXT(".."), 0, 0, true, 0); + + //! merge archives + for (u32 i = 0; i < FileArchives.size(); ++i) { + const IFileList *merge = FileArchives[i]->getFileList(); + + for (u32 j = 0; j < merge->getFileCount(); ++j) { + if (core::isInSameDirectory(Path, merge->getFullFileName(j)) == 0) { + r->addItem(merge->getFullFileName(j), merge->getFileOffset(j), merge->getFileSize(j), merge->isDirectory(j), 0); + } + } + } + } + + if (r) + r->sort(); + return r; +} + +//! Creates an empty filelist +IFileList *CFileSystem::createEmptyFileList(const io::path &path, bool ignoreCase, bool ignorePaths) +{ + return new CFileList(path, ignoreCase, ignorePaths); +} + +//! determines if a file exists and would be able to be opened. +bool CFileSystem::existFile(const io::path &filename) const +{ + for (u32 i = 0; i < FileArchives.size(); ++i) + if (FileArchives[i]->getFileList()->findFile(filename) != -1) + return true; + +#if defined(_MSC_VER) + return (_access(filename.c_str(), 0) != -1); +#elif defined(F_OK) + return (access(filename.c_str(), F_OK) != -1); +#else + return (access(filename.c_str(), 0) != -1); +#endif +} + +//! creates a filesystem which is able to open files from the ordinary file system, +//! and out of zipfiles, which are able to be added to the filesystem. +IFileSystem *createFileSystem() +{ + return new CFileSystem(); +} + +} // end namespace irr +} // end namespace io diff --git a/irr/src/CFileSystem.h b/irr/src/CFileSystem.h new file mode 100644 index 000000000..18bc7ff3f --- /dev/null +++ b/irr/src/CFileSystem.h @@ -0,0 +1,138 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IFileSystem.h" +#include "irrArray.h" + +namespace irr +{ +namespace io +{ + +class CZipReader; + +/*! + FileSystem which uses normal files and one zipfile +*/ +class CFileSystem : public IFileSystem +{ +public: + //! constructor + CFileSystem(); + + //! destructor + virtual ~CFileSystem(); + + //! opens a file for read access + IReadFile *createAndOpenFile(const io::path &filename) override; + + //! Creates an IReadFile interface for accessing memory like a file. + IReadFile *createMemoryReadFile(const void *memory, s32 len, const io::path &fileName, bool deleteMemoryWhenDropped = false) override; + + //! Creates an IReadFile interface for accessing files inside files + IReadFile *createLimitReadFile(const io::path &fileName, IReadFile *alreadyOpenedFile, long pos, long areaSize) override; + + //! Creates an IWriteFile interface for accessing memory like a file. + IWriteFile *createMemoryWriteFile(void *memory, s32 len, const io::path &fileName, bool deleteMemoryWhenDropped = false) override; + + //! Opens a file for write access. + IWriteFile *createAndWriteFile(const io::path &filename, bool append = false) override; + + //! Adds an archive to the file system. + virtual bool addFileArchive(const io::path &filename, + bool ignoreCase = true, bool ignorePaths = true, + E_FILE_ARCHIVE_TYPE archiveType = EFAT_UNKNOWN, + const core::stringc &password = "", + IFileArchive **retArchive = 0) override; + + //! Adds an archive to the file system. + virtual bool addFileArchive(IReadFile *file, bool ignoreCase = true, + bool ignorePaths = true, + E_FILE_ARCHIVE_TYPE archiveType = EFAT_UNKNOWN, + const core::stringc &password = "", + IFileArchive **retArchive = 0) override; + + //! Adds an archive to the file system. + bool addFileArchive(IFileArchive *archive) override; + + //! move the hirarchy of the filesystem. moves sourceIndex relative up or down + bool moveFileArchive(u32 sourceIndex, s32 relative) override; + + //! Adds an external archive loader to the engine. + void addArchiveLoader(IArchiveLoader *loader) override; + + //! Returns the total number of archive loaders added. + u32 getArchiveLoaderCount() const override; + + //! Gets the archive loader by index. + IArchiveLoader *getArchiveLoader(u32 index) const override; + + //! gets the file archive count + u32 getFileArchiveCount() const override; + + //! gets an archive + IFileArchive *getFileArchive(u32 index) override; + + //! removes an archive from the file system. + bool removeFileArchive(u32 index) override; + + //! removes an archive from the file system. + bool removeFileArchive(const io::path &filename) override; + + //! Removes an archive from the file system. + bool removeFileArchive(const IFileArchive *archive) override; + + //! Returns the string of the current working directory + const io::path &getWorkingDirectory() override; + + //! Changes the current Working Directory to the string given. + //! The string is operating system dependent. Under Windows it will look + //! like this: "drive:\directory\sudirectory\" + bool changeWorkingDirectoryTo(const io::path &newDirectory) override; + + //! Converts a relative path to an absolute (unique) path, resolving symbolic links + io::path getAbsolutePath(const io::path &filename) const override; + + //! Returns the directory a file is located in. + /** \param filename: The file to get the directory from */ + io::path getFileDir(const io::path &filename) const override; + + //! Returns the base part of a filename, i.e. the name without the directory + //! part. If no directory is prefixed, the full name is returned. + /** \param filename: The file to get the basename from */ + io::path getFileBasename(const io::path &filename, bool keepExtension = true) const override; + + //! flatten a path and file name for example: "/you/me/../." becomes "/you" + io::path &flattenFilename(io::path &directory, const io::path &root = "/") const override; + + //! Get the relative filename, relative to the given directory + path getRelativeFilename(const path &filename, const path &directory) const override; + + EFileSystemType setFileListSystem(EFileSystemType listType) override; + + //! Creates a list of files and directories in the current working directory + //! and returns it. + IFileList *createFileList() override; + + //! Creates an empty filelist + IFileList *createEmptyFileList(const io::path &path, bool ignoreCase, bool ignorePaths) override; + + //! determines if a file exists and would be able to be opened. + bool existFile(const io::path &filename) const override; + +private: + //! Currently used FileSystemType + EFileSystemType FileSystemType; + //! WorkingDirectory for Native and Virtual filesystems + io::path WorkingDirectory[2]; + //! currently attached ArchiveLoaders + core::array ArchiveLoader; + //! currently attached Archives + core::array FileArchives; +}; + +} // end namespace irr +} // end namespace io diff --git a/irr/src/CGLXManager.cpp b/irr/src/CGLXManager.cpp new file mode 100644 index 000000000..8593621b7 --- /dev/null +++ b/irr/src/CGLXManager.cpp @@ -0,0 +1,401 @@ +// Copyright (C) 2013 Christian Stehno +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#include "CGLXManager.h" + +#ifdef _IRR_COMPILE_WITH_GLX_MANAGER_ + +#include "os.h" + +#define GL_GLEXT_LEGACY 1 +#define GLX_GLXEXT_LEGACY 1 +#include +#include +#include +#include + +namespace irr +{ +namespace video +{ + +CGLXManager::CGLXManager(const SIrrlichtCreationParameters ¶ms, const SExposedVideoData &videodata, int screennr) : + Params(params), PrimaryContext(videodata), VisualInfo(0), glxFBConfig(0), GlxWin(0) +{ +#ifdef _DEBUG + setDebugName("CGLXManager"); +#endif + + CurrentContext.OpenGLLinux.X11Display = PrimaryContext.OpenGLLinux.X11Display; + + int major, minor; + Display *display = (Display *)PrimaryContext.OpenGLLinux.X11Display; + const bool isAvailableGLX = glXQueryExtension(display, &major, &minor); + + if (isAvailableGLX && glXQueryVersion(display, &major, &minor)) { +#if defined(GLX_VERSION_1_3) + typedef GLXFBConfig *(*PFNGLXCHOOSEFBCONFIGPROC)(Display *dpy, int screen, const int *attrib_list, int *nelements); + + PFNGLXCHOOSEFBCONFIGPROC glxChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)glXGetProcAddress(reinterpret_cast("glXChooseFBConfig")); + if (major == 1 && minor > 2 && glxChooseFBConfig) { + os::Printer::log("GLX >= 1.3", ELL_DEBUG); + // attribute array for the draw buffer + int visualAttrBuffer[] = { + GLX_RENDER_TYPE, + GLX_RGBA_BIT, + GLX_RED_SIZE, + 4, + GLX_GREEN_SIZE, + 4, + GLX_BLUE_SIZE, + 4, + GLX_ALPHA_SIZE, + Params.WithAlphaChannel ? 1 : 0, + GLX_DEPTH_SIZE, + Params.ZBufferBits, // 10,11 + GLX_DOUBLEBUFFER, + Params.Doublebuffer ? True : False, + GLX_STENCIL_SIZE, + Params.Stencilbuffer ? 1 : 0, +#if defined(GLX_VERSION_1_4) && defined(GLX_SAMPLE_BUFFERS) // we need to check the extension string! + GLX_SAMPLE_BUFFERS, + 1, + GLX_SAMPLES, + Params.AntiAlias, // 18,19 +#elif defined(GLX_ARB_multisample) + GLX_SAMPLE_BUFFERS_ARB, + 1, + GLX_SAMPLES_ARB, + Params.AntiAlias, // 18,19 +#elif defined(GLX_SGIS_multisample) + GLX_SAMPLE_BUFFERS_SGIS, + 1, + GLX_SAMPLES_SGIS, + Params.AntiAlias, // 18,19 +#endif + GLX_STEREO, + Params.Stereobuffer ? True : False, + None, + }; + + GLXFBConfig *configList = 0; + int nitems = 0; + if (Params.AntiAlias < 2) { + visualAttrBuffer[17] = 0; + visualAttrBuffer[19] = 0; + } + // first round with unchanged values + { + configList = glxChooseFBConfig(display, screennr, visualAttrBuffer, &nitems); + if (!configList && Params.AntiAlias) { + while (!configList && (visualAttrBuffer[19] > 1)) { + visualAttrBuffer[19] -= 1; + configList = glxChooseFBConfig(display, screennr, visualAttrBuffer, &nitems); + } + if (!configList) { + visualAttrBuffer[17] = 0; + visualAttrBuffer[19] = 0; + configList = glxChooseFBConfig(display, screennr, visualAttrBuffer, &nitems); + if (configList) { + os::Printer::log("No FSAA available.", ELL_WARNING); + Params.AntiAlias = 0; + } else { + // reenable multisampling + visualAttrBuffer[17] = 1; + visualAttrBuffer[19] = Params.AntiAlias; + } + } + } + } + // Next try with flipped stencil buffer value + // If the first round was with stencil flag it's now without + // Other way round also makes sense because some configs + // only have depth buffer combined with stencil buffer + if (!configList) { + if (Params.Stencilbuffer) + os::Printer::log("No stencilbuffer available, disabling stencil shadows.", ELL_WARNING); + Params.Stencilbuffer = !Params.Stencilbuffer; + visualAttrBuffer[15] = Params.Stencilbuffer ? 1 : 0; + + configList = glxChooseFBConfig(display, screennr, visualAttrBuffer, &nitems); + if (!configList && Params.AntiAlias) { + while (!configList && (visualAttrBuffer[19] > 1)) { + visualAttrBuffer[19] -= 1; + configList = glxChooseFBConfig(display, screennr, visualAttrBuffer, &nitems); + } + if (!configList) { + visualAttrBuffer[17] = 0; + visualAttrBuffer[19] = 0; + configList = glxChooseFBConfig(display, screennr, visualAttrBuffer, &nitems); + if (configList) { + os::Printer::log("No FSAA available.", ELL_WARNING); + Params.AntiAlias = 0; + } else { + // reenable multisampling + visualAttrBuffer[17] = 1; + visualAttrBuffer[19] = Params.AntiAlias; + } + } + } + } + // Next try without double buffer + if (!configList && Params.Doublebuffer) { + os::Printer::log("No doublebuffering available.", ELL_WARNING); + Params.Doublebuffer = false; + visualAttrBuffer[13] = GLX_DONT_CARE; + Params.Stencilbuffer = false; + visualAttrBuffer[15] = 0; + configList = glxChooseFBConfig(display, screennr, visualAttrBuffer, &nitems); + if (!configList && Params.AntiAlias) { + while (!configList && (visualAttrBuffer[19] > 1)) { + visualAttrBuffer[19] -= 1; + configList = glxChooseFBConfig(display, screennr, visualAttrBuffer, &nitems); + } + if (!configList) { + visualAttrBuffer[17] = 0; + visualAttrBuffer[19] = 0; + configList = glxChooseFBConfig(display, screennr, visualAttrBuffer, &nitems); + if (configList) { + os::Printer::log("No FSAA available.", ELL_WARNING); + Params.AntiAlias = 0; + } else { + // reenable multisampling + visualAttrBuffer[17] = 1; + visualAttrBuffer[19] = Params.AntiAlias; + } + } + } + } + if (configList) { + glxFBConfig = configList[0]; + XFree(configList); + typedef XVisualInfo *(*PFNGLXGETVISUALFROMFBCONFIGPROC)(Display *dpy, GLXFBConfig config); + PFNGLXGETVISUALFROMFBCONFIGPROC glxGetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC)glXGetProcAddress(reinterpret_cast("glXGetVisualFromFBConfig")); + if (glxGetVisualFromFBConfig) + VisualInfo = glxGetVisualFromFBConfig(display, (GLXFBConfig)glxFBConfig); + } + } else +#endif + { + // attribute array for the draw buffer + int visualAttrBuffer[] = { + GLX_RGBA, GLX_USE_GL, + GLX_RED_SIZE, 4, + GLX_GREEN_SIZE, 4, + GLX_BLUE_SIZE, 4, + GLX_ALPHA_SIZE, Params.WithAlphaChannel ? 1 : 0, + GLX_DEPTH_SIZE, Params.ZBufferBits, + GLX_STENCIL_SIZE, Params.Stencilbuffer ? 1 : 0, // 12,13 + // The following attributes have no flags, but are + // either present or not. As a no-op we use + // GLX_USE_GL, which is silently ignored by glXChooseVisual + Params.Doublebuffer ? GLX_DOUBLEBUFFER : GLX_USE_GL, // 14 + Params.Stereobuffer ? GLX_STEREO : GLX_USE_GL, // 15 + None, + }; + + VisualInfo = glXChooseVisual(display, screennr, visualAttrBuffer); + if (!VisualInfo) { + if (Params.Stencilbuffer) + os::Printer::log("No stencilbuffer available, disabling.", ELL_WARNING); + Params.Stencilbuffer = !Params.Stencilbuffer; + visualAttrBuffer[13] = Params.Stencilbuffer ? 1 : 0; + + VisualInfo = glXChooseVisual(display, screennr, visualAttrBuffer); + if (!VisualInfo && Params.Doublebuffer) { + os::Printer::log("No doublebuffering available.", ELL_WARNING); + Params.Doublebuffer = false; + visualAttrBuffer[14] = GLX_USE_GL; + VisualInfo = glXChooseVisual(display, screennr, visualAttrBuffer); + } + } + } + } else + os::Printer::log("No GLX support available. OpenGL driver will not work.", ELL_WARNING); +} + +CGLXManager::~CGLXManager() +{ +} + +bool CGLXManager::initialize(const SIrrlichtCreationParameters ¶ms, const SExposedVideoData &videodata) +{ + // store params + Params = params; + + // set display + CurrentContext.OpenGLLinux.X11Display = videodata.OpenGLLinux.X11Display; + + // now get new window + CurrentContext.OpenGLLinux.X11Window = videodata.OpenGLLinux.X11Window; + if (!PrimaryContext.OpenGLLinux.X11Window) { + PrimaryContext.OpenGLLinux.X11Window = CurrentContext.OpenGLLinux.X11Window; + } + + return true; +} + +void CGLXManager::terminate() +{ + memset((void *)&CurrentContext, 0, sizeof(CurrentContext)); +} + +bool CGLXManager::generateSurface() +{ + if (glxFBConfig) { + GlxWin = glXCreateWindow((Display *)CurrentContext.OpenGLLinux.X11Display, (GLXFBConfig)glxFBConfig, CurrentContext.OpenGLLinux.X11Window, NULL); + if (!GlxWin) { + os::Printer::log("Could not create GLX window.", ELL_WARNING); + return false; + } + + CurrentContext.OpenGLLinux.GLXWindow = GlxWin; + } else { + CurrentContext.OpenGLLinux.GLXWindow = CurrentContext.OpenGLLinux.X11Window; + } + return true; +} + +void CGLXManager::destroySurface() +{ + if (GlxWin) + glXDestroyWindow((Display *)CurrentContext.OpenGLLinux.X11Display, GlxWin); +} + +#if defined(GLX_ARB_create_context) +static int IrrIgnoreError(Display *display, XErrorEvent *event) +{ + char msg[256]; + XGetErrorText(display, event->error_code, msg, 256); + os::Printer::log("Ignoring an X error", msg, ELL_DEBUG); + return 0; +} +#endif + +bool CGLXManager::generateContext() +{ + GLXContext context = 0; + + if (glxFBConfig) { + if (GlxWin) { +#if defined(GLX_ARB_create_context) + + PFNGLXCREATECONTEXTATTRIBSARBPROC glxCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress(reinterpret_cast("glXCreateContextAttribsARB")); + + if (glxCreateContextAttribsARB) { + os::Printer::log("GLX with GLX_ARB_create_context", ELL_DEBUG); + int contextAttrBuffer[] = { + GLX_CONTEXT_MAJOR_VERSION_ARB, 3, + GLX_CONTEXT_MINOR_VERSION_ARB, 0, + // GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, + None}; + XErrorHandler old = XSetErrorHandler(IrrIgnoreError); + context = glxCreateContextAttribsARB((Display *)CurrentContext.OpenGLLinux.X11Display, (GLXFBConfig)glxFBConfig, NULL, True, contextAttrBuffer); + XSetErrorHandler(old); + // transparently fall back to legacy call + } + if (!context) +#endif + { + // create glx context + context = glXCreateNewContext((Display *)CurrentContext.OpenGLLinux.X11Display, (GLXFBConfig)glxFBConfig, GLX_RGBA_TYPE, NULL, True); + if (!context) { + os::Printer::log("Could not create GLX rendering context.", ELL_WARNING); + return false; + } + } + } else { + os::Printer::log("GLX window was not properly created.", ELL_WARNING); + return false; + } + } else { + context = glXCreateContext((Display *)CurrentContext.OpenGLLinux.X11Display, VisualInfo, NULL, True); + if (!context) { + os::Printer::log("Could not create GLX rendering context.", ELL_WARNING); + return false; + } + } + CurrentContext.OpenGLLinux.X11Context = context; + return true; +} + +const SExposedVideoData &CGLXManager::getContext() const +{ + return CurrentContext; +} + +bool CGLXManager::activateContext(const SExposedVideoData &videoData, bool restorePrimaryOnZero) +{ + // TODO: handle restorePrimaryOnZero + + if (videoData.OpenGLLinux.X11Window) { + if (videoData.OpenGLLinux.X11Display && videoData.OpenGLLinux.X11Context) { + if (!glXMakeCurrent((Display *)videoData.OpenGLLinux.X11Display, videoData.OpenGLLinux.GLXWindow, (GLXContext)videoData.OpenGLLinux.X11Context)) { + os::Printer::log("Context activation failed."); + return false; + } else { + CurrentContext.OpenGLLinux.GLXWindow = videoData.OpenGLLinux.GLXWindow; + CurrentContext.OpenGLLinux.X11Window = videoData.OpenGLLinux.X11Window; + CurrentContext.OpenGLLinux.X11Display = videoData.OpenGLLinux.X11Display; + } + } else { + // in case we only got a window ID, try with the existing values for display and context + if (!glXMakeCurrent((Display *)PrimaryContext.OpenGLLinux.X11Display, videoData.OpenGLLinux.GLXWindow, (GLXContext)PrimaryContext.OpenGLLinux.X11Context)) { + os::Printer::log("Context activation failed."); + return false; + } else { + CurrentContext.OpenGLLinux.GLXWindow = videoData.OpenGLLinux.GLXWindow; + CurrentContext.OpenGLLinux.X11Window = videoData.OpenGLLinux.X11Window; + CurrentContext.OpenGLLinux.X11Display = PrimaryContext.OpenGLLinux.X11Display; + } + } + } else if (!restorePrimaryOnZero && !videoData.OpenGLLinux.X11Window && !videoData.OpenGLLinux.X11Display) { + if (!glXMakeCurrent((Display *)PrimaryContext.OpenGLLinux.X11Display, None, NULL)) { + os::Printer::log("Render Context reset failed."); + return false; + } + CurrentContext.OpenGLLinux.X11Window = 0; + CurrentContext.OpenGLLinux.X11Display = 0; + } + // set back to main context + else if (CurrentContext.OpenGLLinux.X11Display != PrimaryContext.OpenGLLinux.X11Display) { + if (!glXMakeCurrent((Display *)PrimaryContext.OpenGLLinux.X11Display, PrimaryContext.OpenGLLinux.X11Window, (GLXContext)PrimaryContext.OpenGLLinux.X11Context)) { + os::Printer::log("Context activation failed."); + return false; + } else { + CurrentContext = PrimaryContext; + } + } + return true; +} + +void CGLXManager::destroyContext() +{ + if (CurrentContext.OpenGLLinux.X11Context) { + if (GlxWin) { + if (!glXMakeContextCurrent((Display *)CurrentContext.OpenGLLinux.X11Display, None, None, NULL)) + os::Printer::log("Could not release glx context.", ELL_WARNING); + } else { + if (!glXMakeCurrent((Display *)CurrentContext.OpenGLLinux.X11Display, None, NULL)) + os::Printer::log("Could not release glx context.", ELL_WARNING); + } + glXDestroyContext((Display *)CurrentContext.OpenGLLinux.X11Display, (GLXContext)CurrentContext.OpenGLLinux.X11Context); + } +} + +void *CGLXManager::getProcAddress(const std::string &procName) +{ + return (void *)glXGetProcAddressARB(reinterpret_cast(procName.c_str())); +} + +bool CGLXManager::swapBuffers() +{ + glXSwapBuffers((Display *)CurrentContext.OpenGLLinux.X11Display, CurrentContext.OpenGLLinux.GLXWindow); + return true; +} + +} +} + +#endif diff --git a/irr/src/CGLXManager.h b/irr/src/CGLXManager.h new file mode 100644 index 000000000..f940d4316 --- /dev/null +++ b/irr/src/CGLXManager.h @@ -0,0 +1,76 @@ +// Copyright (C) 2013 Christian Stehno +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#pragma once + +#ifdef _IRR_COMPILE_WITH_GLX_MANAGER_ + +#include "SIrrCreationParameters.h" +#include "SExposedVideoData.h" +#include "IContextManager.h" +#include "SColor.h" +#include +#include + +// we can't include glx.h here, because gl.h has incompatible types with ogl es headers and it +// cause redefinition errors, thats why we use ugly trick with void* types and casts. + +namespace irr +{ +namespace video +{ +// GLX manager. +class CGLXManager : public IContextManager +{ +public: + //! Constructor. + CGLXManager(const SIrrlichtCreationParameters ¶ms, const SExposedVideoData &videodata, int screennr); + + //! Destructor + ~CGLXManager(); + + // Initialize + bool initialize(const SIrrlichtCreationParameters ¶ms, const SExposedVideoData &data) override; + + // Terminate + void terminate() override; + + // Create surface. + bool generateSurface() override; + + // Destroy surface. + void destroySurface() override; + + // Create context. + bool generateContext() override; + + // Destroy context. + void destroyContext() override; + + //! Get current context + const SExposedVideoData &getContext() const override; + + //! Change render context, disable old and activate new defined by videoData + bool activateContext(const SExposedVideoData &videoData, bool restorePrimaryOnZero) override; + + // Get procedure address. + void *getProcAddress(const std::string &procName) override; + + // Swap buffers. + bool swapBuffers() override; + + XVisualInfo *getVisual() const { return VisualInfo; } // return XVisualInfo + +private: + SIrrlichtCreationParameters Params; + SExposedVideoData PrimaryContext; + SExposedVideoData CurrentContext; + XVisualInfo *VisualInfo; + void *glxFBConfig; // GLXFBConfig + XID GlxWin; // GLXWindow +}; +} +} + +#endif diff --git a/irr/src/CGUIButton.cpp b/irr/src/CGUIButton.cpp new file mode 100644 index 000000000..f023024f9 --- /dev/null +++ b/irr/src/CGUIButton.cpp @@ -0,0 +1,500 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIButton.h" + +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "IGUIFont.h" +#include "os.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIButton::CGUIButton(IGUIEnvironment *environment, IGUIElement *parent, + s32 id, core::rect rectangle, bool noclip) : + IGUIButton(environment, parent, id, rectangle), + SpriteBank(0), OverrideFont(0), + OverrideColorEnabled(false), OverrideColor(video::SColor(101, 255, 255, 255)), + ClickTime(0), HoverTime(0), FocusTime(0), + ClickShiftState(false), ClickControlState(false), + IsPushButton(false), Pressed(false), + UseAlphaChannel(false), DrawBorder(true), ScaleImage(false) +{ +#ifdef _DEBUG + setDebugName("CGUIButton"); +#endif + setNotClipped(noclip); + + // This element can be tabbed. + setTabStop(true); + setTabOrder(-1); +} + +//! destructor +CGUIButton::~CGUIButton() +{ + if (OverrideFont) + OverrideFont->drop(); + + if (SpriteBank) + SpriteBank->drop(); +} + +//! Sets if the images should be scaled to fit the button +void CGUIButton::setScaleImage(bool scaleImage) +{ + ScaleImage = scaleImage; +} + +//! Returns whether the button scale the used images +bool CGUIButton::isScalingImage() const +{ + return ScaleImage; +} + +//! Sets if the button should use the skin to draw its border +void CGUIButton::setDrawBorder(bool border) +{ + DrawBorder = border; +} + +void CGUIButton::setSpriteBank(IGUISpriteBank *sprites) +{ + if (sprites) + sprites->grab(); + + if (SpriteBank) + SpriteBank->drop(); + + SpriteBank = sprites; +} + +void CGUIButton::setSprite(EGUI_BUTTON_STATE state, s32 index, video::SColor color, bool loop, bool scale) +{ + ButtonSprites[(u32)state].Index = index; + ButtonSprites[(u32)state].Color = color; + ButtonSprites[(u32)state].Loop = loop; + ButtonSprites[(u32)state].Scale = scale; +} + +//! Get the sprite-index for the given state or -1 when no sprite is set +s32 CGUIButton::getSpriteIndex(EGUI_BUTTON_STATE state) const +{ + return ButtonSprites[(u32)state].Index; +} + +//! Get the sprite color for the given state. Color is only used when a sprite is set. +video::SColor CGUIButton::getSpriteColor(EGUI_BUTTON_STATE state) const +{ + return ButtonSprites[(u32)state].Color; +} + +//! Returns if the sprite in the given state does loop +bool CGUIButton::getSpriteLoop(EGUI_BUTTON_STATE state) const +{ + return ButtonSprites[(u32)state].Loop; +} + +//! Returns if the sprite in the given state is scaled +bool CGUIButton::getSpriteScale(EGUI_BUTTON_STATE state) const +{ + return ButtonSprites[(u32)state].Scale; +} + +//! called if an event happened. +bool CGUIButton::OnEvent(const SEvent &event) +{ + if (!isEnabled()) + return IGUIElement::OnEvent(event); + + switch (event.EventType) { + case EET_KEY_INPUT_EVENT: + if (event.KeyInput.PressedDown && + (event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE)) { + if (!IsPushButton) + setPressed(true); + else + setPressed(!Pressed); + + return true; + } + if (Pressed && !IsPushButton && event.KeyInput.PressedDown && event.KeyInput.Key == KEY_ESCAPE) { + setPressed(false); + return true; + } else if (!event.KeyInput.PressedDown && Pressed && + (event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE)) { + + if (!IsPushButton) + setPressed(false); + + if (Parent) { + ClickShiftState = event.KeyInput.Shift; + ClickControlState = event.KeyInput.Control; + + SEvent newEvent; + newEvent.EventType = EET_GUI_EVENT; + newEvent.GUIEvent.Caller = this; + newEvent.GUIEvent.Element = 0; + newEvent.GUIEvent.EventType = EGET_BUTTON_CLICKED; + Parent->OnEvent(newEvent); + } + return true; + } + break; + case EET_GUI_EVENT: + if (event.GUIEvent.Caller == this) { + if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) { + if (!IsPushButton) + setPressed(false); + FocusTime = os::Timer::getTime(); + } else if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUSED) { + FocusTime = os::Timer::getTime(); + } else if (event.GUIEvent.EventType == EGET_ELEMENT_HOVERED || event.GUIEvent.EventType == EGET_ELEMENT_LEFT) { + HoverTime = os::Timer::getTime(); + } + } + break; + case EET_MOUSE_INPUT_EVENT: + if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) { + if (!IsPushButton) + setPressed(true); + + return true; + } else if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) { + bool wasPressed = Pressed; + + if (!AbsoluteClippingRect.isPointInside(core::position2d(event.MouseInput.X, event.MouseInput.Y))) { + if (!IsPushButton) + setPressed(false); + return true; + } + + if (!IsPushButton) + setPressed(false); + else { + setPressed(!Pressed); + } + + if ((!IsPushButton && wasPressed && Parent) || + (IsPushButton && wasPressed != Pressed)) { + ClickShiftState = event.MouseInput.Shift; + ClickControlState = event.MouseInput.Control; + + SEvent newEvent; + newEvent.EventType = EET_GUI_EVENT; + newEvent.GUIEvent.Caller = this; + newEvent.GUIEvent.Element = 0; + newEvent.GUIEvent.EventType = EGET_BUTTON_CLICKED; + Parent->OnEvent(newEvent); + } + + return true; + } + break; + default: + break; + } + + return Parent ? Parent->OnEvent(event) : false; +} + +//! draws the element and its children +void CGUIButton::draw() +{ + if (!IsVisible) + return; + + IGUISkin *skin = Environment->getSkin(); + video::IVideoDriver *driver = Environment->getVideoDriver(); + + if (DrawBorder) { + if (!Pressed) { + skin->draw3DButtonPaneStandard(this, AbsoluteRect, &AbsoluteClippingRect); + } else { + skin->draw3DButtonPanePressed(this, AbsoluteRect, &AbsoluteClippingRect); + } + } + + const core::position2di buttonCenter(AbsoluteRect.getCenter()); + + EGUI_BUTTON_IMAGE_STATE imageState = getImageState(Pressed); + if (ButtonImages[(u32)imageState].Texture) { + core::position2d pos(buttonCenter); + core::rect sourceRect(ButtonImages[(u32)imageState].SourceRect); + if (sourceRect.getWidth() == 0 && sourceRect.getHeight() == 0) + sourceRect = core::rect(core::position2di(0, 0), ButtonImages[(u32)imageState].Texture->getOriginalSize()); + + pos.X -= sourceRect.getWidth() / 2; + pos.Y -= sourceRect.getHeight() / 2; + + if (Pressed) { + // Create a pressed-down effect by moving the image when it looks identical to the unpressed state image + EGUI_BUTTON_IMAGE_STATE unpressedState = getImageState(false); + if (unpressedState == imageState || ButtonImages[(u32)imageState] == ButtonImages[(u32)unpressedState]) { + pos.X += skin->getSize(EGDS_BUTTON_PRESSED_IMAGE_OFFSET_X); + pos.Y += skin->getSize(EGDS_BUTTON_PRESSED_IMAGE_OFFSET_Y); + } + } + + driver->draw2DImage(ButtonImages[(u32)imageState].Texture, + ScaleImage ? AbsoluteRect : core::rect(pos, sourceRect.getSize()), + sourceRect, &AbsoluteClippingRect, + 0, UseAlphaChannel); + } + + if (SpriteBank) { + core::position2di pos(buttonCenter); + if (Pressed) { + pos.X += skin->getSize(EGDS_BUTTON_PRESSED_SPRITE_OFFSET_X); + pos.Y += skin->getSize(EGDS_BUTTON_PRESSED_SPRITE_OFFSET_Y); + } + + if (isEnabled()) { + // pressed / unpressed animation + EGUI_BUTTON_STATE state = Pressed ? EGBS_BUTTON_DOWN : EGBS_BUTTON_UP; + drawSprite(state, ClickTime, pos); + + // focused / unfocused animation + state = Environment->hasFocus(this) ? EGBS_BUTTON_FOCUSED : EGBS_BUTTON_NOT_FOCUSED; + drawSprite(state, FocusTime, pos); + + // mouse over / off animation + state = Environment->getHovered() == this ? EGBS_BUTTON_MOUSE_OVER : EGBS_BUTTON_MOUSE_OFF; + drawSprite(state, HoverTime, pos); + } else { + // draw disabled + drawSprite(EGBS_BUTTON_DISABLED, 0, pos); + } + } + + if (Text.size()) { + IGUIFont *font = getActiveFont(); + + core::rect rect = AbsoluteRect; + if (Pressed) { + rect.UpperLeftCorner.X += skin->getSize(EGDS_BUTTON_PRESSED_TEXT_OFFSET_X); + rect.UpperLeftCorner.Y += skin->getSize(EGDS_BUTTON_PRESSED_TEXT_OFFSET_Y); + } + + if (font) + font->draw(Text.c_str(), rect, + getActiveColor(), + true, true, &AbsoluteClippingRect); + } + + IGUIElement::draw(); +} + +void CGUIButton::drawSprite(EGUI_BUTTON_STATE state, u32 startTime, const core::position2di ¢er) +{ + u32 stateIdx = (u32)state; + + if (ButtonSprites[stateIdx].Index != -1) { + if (ButtonSprites[stateIdx].Scale) { + const video::SColor colors[] = {ButtonSprites[stateIdx].Color, ButtonSprites[stateIdx].Color, ButtonSprites[stateIdx].Color, ButtonSprites[stateIdx].Color}; + SpriteBank->draw2DSprite(ButtonSprites[stateIdx].Index, AbsoluteRect, + &AbsoluteClippingRect, colors, + os::Timer::getTime() - startTime, ButtonSprites[stateIdx].Loop); + } else { + SpriteBank->draw2DSprite(ButtonSprites[stateIdx].Index, center, + &AbsoluteClippingRect, ButtonSprites[stateIdx].Color, startTime, os::Timer::getTime(), + ButtonSprites[stateIdx].Loop, true); + } + } +} + +EGUI_BUTTON_IMAGE_STATE CGUIButton::getImageState(bool pressed) const +{ + // figure state we should have + EGUI_BUTTON_IMAGE_STATE state = EGBIS_IMAGE_DISABLED; + bool focused = Environment->hasFocus(this); + bool mouseOver = static_cast(Environment->getHovered()) == this; // (static cast for Borland) + if (isEnabled()) { + if (pressed) { + if (focused && mouseOver) + state = EGBIS_IMAGE_DOWN_FOCUSED_MOUSEOVER; + else if (focused) + state = EGBIS_IMAGE_DOWN_FOCUSED; + else if (mouseOver) + state = EGBIS_IMAGE_DOWN_MOUSEOVER; + else + state = EGBIS_IMAGE_DOWN; + } else // !pressed + { + if (focused && mouseOver) + state = EGBIS_IMAGE_UP_FOCUSED_MOUSEOVER; + else if (focused) + state = EGBIS_IMAGE_UP_FOCUSED; + else if (mouseOver) + state = EGBIS_IMAGE_UP_MOUSEOVER; + else + state = EGBIS_IMAGE_UP; + } + } + + // find a compatible state that has images + while (state != EGBIS_IMAGE_UP && !ButtonImages[(u32)state].Texture) { + switch (state) { + case EGBIS_IMAGE_UP_FOCUSED: + state = EGBIS_IMAGE_UP_MOUSEOVER; + break; + case EGBIS_IMAGE_UP_FOCUSED_MOUSEOVER: + state = EGBIS_IMAGE_UP_FOCUSED; + break; + case EGBIS_IMAGE_DOWN_MOUSEOVER: + state = EGBIS_IMAGE_DOWN; + break; + case EGBIS_IMAGE_DOWN_FOCUSED: + state = EGBIS_IMAGE_DOWN_MOUSEOVER; + break; + case EGBIS_IMAGE_DOWN_FOCUSED_MOUSEOVER: + state = EGBIS_IMAGE_DOWN_FOCUSED; + break; + case EGBIS_IMAGE_DISABLED: + if (pressed) + state = EGBIS_IMAGE_DOWN; + else + state = EGBIS_IMAGE_UP; + break; + default: + state = EGBIS_IMAGE_UP; + } + } + + return state; +} + +//! sets another skin independent font. if this is set to zero, the button uses the font of the skin. +void CGUIButton::setOverrideFont(IGUIFont *font) +{ + if (OverrideFont == font) + return; + + if (OverrideFont) + OverrideFont->drop(); + + OverrideFont = font; + + if (OverrideFont) + OverrideFont->grab(); +} + +//! Gets the override font (if any) +IGUIFont *CGUIButton::getOverrideFont() const +{ + return OverrideFont; +} + +//! Get the font which is used right now for drawing +IGUIFont *CGUIButton::getActiveFont() const +{ + if (OverrideFont) + return OverrideFont; + IGUISkin *skin = Environment->getSkin(); + if (skin) + return skin->getFont(EGDF_BUTTON); + return 0; +} + +//! Sets another color for the text. +void CGUIButton::setOverrideColor(video::SColor color) +{ + OverrideColor = color; + OverrideColorEnabled = true; +} + +video::SColor CGUIButton::getOverrideColor() const +{ + return OverrideColor; +} + +irr::video::SColor CGUIButton::getActiveColor() const +{ + if (OverrideColorEnabled) + return OverrideColor; + IGUISkin *skin = Environment->getSkin(); + if (skin) + return OverrideColorEnabled ? OverrideColor : skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT); + return OverrideColor; +} + +void CGUIButton::enableOverrideColor(bool enable) +{ + OverrideColorEnabled = enable; +} + +bool CGUIButton::isOverrideColorEnabled() const +{ + return OverrideColorEnabled; +} + +void CGUIButton::setImage(EGUI_BUTTON_IMAGE_STATE state, video::ITexture *image, const core::rect &sourceRect) +{ + if (state >= EGBIS_COUNT) + return; + + if (image) + image->grab(); + + u32 stateIdx = (u32)state; + if (ButtonImages[stateIdx].Texture) + ButtonImages[stateIdx].Texture->drop(); + + ButtonImages[stateIdx].Texture = image; + ButtonImages[stateIdx].SourceRect = sourceRect; +} + +//! Sets if the button should behave like a push button. Which means it +//! can be in two states: Normal or Pressed. With a click on the button, +//! the user can change the state of the button. +void CGUIButton::setIsPushButton(bool isPushButton) +{ + IsPushButton = isPushButton; +} + +//! Returns if the button is currently pressed +bool CGUIButton::isPressed() const +{ + return Pressed; +} + +//! Sets the pressed state of the button if this is a pushbutton +void CGUIButton::setPressed(bool pressed) +{ + if (Pressed != pressed) { + ClickTime = os::Timer::getTime(); + Pressed = pressed; + } +} + +//! Returns whether the button is a push button +bool CGUIButton::isPushButton() const +{ + return IsPushButton; +} + +//! Sets if the alpha channel should be used for drawing images on the button (default is false) +void CGUIButton::setUseAlphaChannel(bool useAlphaChannel) +{ + UseAlphaChannel = useAlphaChannel; +} + +//! Returns if the alpha channel should be used for drawing images on the button +bool CGUIButton::isAlphaChannelUsed() const +{ + return UseAlphaChannel; +} + +bool CGUIButton::isDrawingBorder() const +{ + return DrawBorder; +} + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIButton.h b/irr/src/CGUIButton.h new file mode 100644 index 000000000..8ff36c9a7 --- /dev/null +++ b/irr/src/CGUIButton.h @@ -0,0 +1,241 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIButton.h" +#include "IGUISpriteBank.h" +#include "ITexture.h" +#include "SColor.h" + +namespace irr +{ +namespace gui +{ + +class CGUIButton : public IGUIButton +{ +public: + //! constructor + CGUIButton(IGUIEnvironment *environment, IGUIElement *parent, + s32 id, core::rect rectangle, bool noclip = false); + + //! destructor + virtual ~CGUIButton(); + + //! called if an event happened. + bool OnEvent(const SEvent &event) override; + + //! draws the element and its children + void draw() override; + + //! sets another skin independent font. if this is set to zero, the button uses the font of the skin. + void setOverrideFont(IGUIFont *font = 0) override; + + //! Gets the override font (if any) + IGUIFont *getOverrideFont() const override; + + //! Get the font which is used right now for drawing + IGUIFont *getActiveFont() const override; + + //! Sets another color for the button text. + void setOverrideColor(video::SColor color) override; + + //! Gets the override color + video::SColor getOverrideColor(void) const override; + + //! Gets the currently used text color + video::SColor getActiveColor() const override; + + //! Sets if the button text should use the override color or the color in the gui skin. + void enableOverrideColor(bool enable) override; + + //! Checks if an override color is enabled + bool isOverrideColorEnabled(void) const override; + + //! Sets an image which should be displayed on the button when it is in the given state. + void setImage(EGUI_BUTTON_IMAGE_STATE state, video::ITexture *image = 0, const core::rect &sourceRect = core::rect(0, 0, 0, 0)) override; + + //! Sets an image which should be displayed on the button when it is in normal state. + void setImage(video::ITexture *image = 0) override + { + setImage(EGBIS_IMAGE_UP, image); + } + + //! Sets an image which should be displayed on the button when it is in normal state. + void setImage(video::ITexture *image, const core::rect &pos) override + { + setImage(EGBIS_IMAGE_UP, image, pos); + } + + //! Sets an image which should be displayed on the button when it is in pressed state. + void setPressedImage(video::ITexture *image = 0) override + { + setImage(EGBIS_IMAGE_DOWN, image); + } + + //! Sets an image which should be displayed on the button when it is in pressed state. + void setPressedImage(video::ITexture *image, const core::rect &pos) override + { + setImage(EGBIS_IMAGE_DOWN, image, pos); + } + + //! Sets the sprite bank used by the button + void setSpriteBank(IGUISpriteBank *bank = 0) override; + + //! Sets the animated sprite for a specific button state + /** \param index: Number of the sprite within the sprite bank, use -1 for no sprite + \param state: State of the button to set the sprite for + \param index: The sprite number from the current sprite bank + \param color: The color of the sprite + */ + virtual void setSprite(EGUI_BUTTON_STATE state, s32 index, + video::SColor color = video::SColor(255, 255, 255, 255), + bool loop = false, bool scale = false) override; + + //! Get the sprite-index for the given state or -1 when no sprite is set + s32 getSpriteIndex(EGUI_BUTTON_STATE state) const override; + + //! Get the sprite color for the given state. Color is only used when a sprite is set. + video::SColor getSpriteColor(EGUI_BUTTON_STATE state) const override; + + //! Returns if the sprite in the given state does loop + bool getSpriteLoop(EGUI_BUTTON_STATE state) const override; + + //! Returns if the sprite in the given state is scaled + bool getSpriteScale(EGUI_BUTTON_STATE state) const override; + + //! Sets if the button should behave like a push button. Which means it + //! can be in two states: Normal or Pressed. With a click on the button, + //! the user can change the state of the button. + void setIsPushButton(bool isPushButton = true) override; + + //! Checks whether the button is a push button + bool isPushButton() const override; + + //! Sets the pressed state of the button if this is a pushbutton + void setPressed(bool pressed = true) override; + + //! Returns if the button is currently pressed + bool isPressed() const override; + + //! Sets if the button should use the skin to draw its border + void setDrawBorder(bool border = true) override; + + //! Checks if the button face and border are being drawn + bool isDrawingBorder() const override; + + //! Sets if the alpha channel should be used for drawing images on the button (default is false) + void setUseAlphaChannel(bool useAlphaChannel = true) override; + + //! Checks if the alpha channel should be used for drawing images on the button + bool isAlphaChannelUsed() const override; + + //! Sets if the button should scale the button images to fit + void setScaleImage(bool scaleImage = true) override; + + //! Checks whether the button scales the used images + bool isScalingImage() const override; + + //! Get if the shift key was pressed in last EGET_BUTTON_CLICKED event + bool getClickShiftState() const override + { + return ClickShiftState; + } + + //! Get if the control key was pressed in last EGET_BUTTON_CLICKED event + bool getClickControlState() const override + { + return ClickControlState; + } + +protected: + void drawSprite(EGUI_BUTTON_STATE state, u32 startTime, const core::position2di ¢er); + EGUI_BUTTON_IMAGE_STATE getImageState(bool pressed) const; + +private: + struct ButtonSprite + { + ButtonSprite() : + Index(-1), Loop(false), Scale(false) + { + } + + bool operator==(const ButtonSprite &other) const + { + return Index == other.Index && Color == other.Color && Loop == other.Loop && Scale == other.Scale; + } + + s32 Index; + video::SColor Color; + bool Loop; + bool Scale; + }; + + ButtonSprite ButtonSprites[EGBS_COUNT]; + IGUISpriteBank *SpriteBank; + + struct ButtonImage + { + ButtonImage() : + Texture(0), SourceRect(core::rect(0, 0, 0, 0)) + { + } + + ButtonImage(const ButtonImage &other) : + Texture(0), SourceRect(core::rect(0, 0, 0, 0)) + { + *this = other; + } + + ~ButtonImage() + { + if (Texture) + Texture->drop(); + } + + ButtonImage &operator=(const ButtonImage &other) + { + if (this == &other) + return *this; + + if (other.Texture) + other.Texture->grab(); + if (Texture) + Texture->drop(); + Texture = other.Texture; + SourceRect = other.SourceRect; + return *this; + } + + bool operator==(const ButtonImage &other) const + { + return Texture == other.Texture && SourceRect == other.SourceRect; + } + + video::ITexture *Texture; + core::rect SourceRect; + }; + + ButtonImage ButtonImages[EGBIS_COUNT]; + + IGUIFont *OverrideFont; + + bool OverrideColorEnabled; + video::SColor OverrideColor; + + u32 ClickTime, HoverTime, FocusTime; + + bool ClickShiftState; + bool ClickControlState; + + bool IsPushButton; + bool Pressed; + bool UseAlphaChannel; + bool DrawBorder; + bool ScaleImage; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUICheckBox.cpp b/irr/src/CGUICheckBox.cpp new file mode 100644 index 000000000..18dd6856a --- /dev/null +++ b/irr/src/CGUICheckBox.cpp @@ -0,0 +1,198 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUICheckBox.h" + +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "IGUIFont.h" +#include "os.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUICheckBox::CGUICheckBox(bool checked, IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect rectangle) : + IGUICheckBox(environment, parent, id, rectangle), CheckTime(0), Pressed(false), Checked(checked), Border(false), Background(false) +{ +#ifdef _DEBUG + setDebugName("CGUICheckBox"); +#endif + + // this element can be tabbed into + setTabStop(true); + setTabOrder(-1); +} + +//! called if an event happened. +bool CGUICheckBox::OnEvent(const SEvent &event) +{ + if (isEnabled()) { + switch (event.EventType) { + case EET_KEY_INPUT_EVENT: + if (event.KeyInput.PressedDown && + (event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE)) { + Pressed = true; + return true; + } else if (Pressed && event.KeyInput.PressedDown && event.KeyInput.Key == KEY_ESCAPE) { + Pressed = false; + return true; + } else if (!event.KeyInput.PressedDown && Pressed && + (event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE)) { + Pressed = false; + if (Parent) { + SEvent newEvent; + newEvent.EventType = EET_GUI_EVENT; + newEvent.GUIEvent.Caller = this; + newEvent.GUIEvent.Element = 0; + Checked = !Checked; + newEvent.GUIEvent.EventType = EGET_CHECKBOX_CHANGED; + Parent->OnEvent(newEvent); + } + return true; + } + break; + case EET_GUI_EVENT: + if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) { + if (event.GUIEvent.Caller == this) + Pressed = false; + } + break; + case EET_MOUSE_INPUT_EVENT: + if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) { + Pressed = true; + CheckTime = os::Timer::getTime(); + return true; + } else if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) { + bool wasPressed = Pressed; + Pressed = false; + + if (wasPressed && Parent) { + if (!AbsoluteClippingRect.isPointInside(core::position2d(event.MouseInput.X, event.MouseInput.Y))) { + Pressed = false; + return true; + } + + SEvent newEvent; + newEvent.EventType = EET_GUI_EVENT; + newEvent.GUIEvent.Caller = this; + newEvent.GUIEvent.Element = 0; + Checked = !Checked; + newEvent.GUIEvent.EventType = EGET_CHECKBOX_CHANGED; + Parent->OnEvent(newEvent); + } + + return true; + } + break; + default: + break; + } + } + + return IGUIElement::OnEvent(event); +} + +//! draws the element and its children +void CGUICheckBox::draw() +{ + if (!IsVisible) + return; + + IGUISkin *skin = Environment->getSkin(); + if (skin) { + video::IVideoDriver *driver = Environment->getVideoDriver(); + core::rect frameRect(AbsoluteRect); + + // draw background + if (Background) { + video::SColor bgColor = skin->getColor(gui::EGDC_3D_FACE); + driver->draw2DRectangle(bgColor, frameRect, &AbsoluteClippingRect); + } + + // draw the border + if (Border) { + skin->draw3DSunkenPane(this, 0, true, false, frameRect, &AbsoluteClippingRect); + frameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X); + frameRect.LowerRightCorner.X -= skin->getSize(EGDS_TEXT_DISTANCE_X); + } + + const s32 height = skin->getSize(EGDS_CHECK_BOX_WIDTH); + + // the rectangle around the "checked" area. + core::rect checkRect(frameRect.UpperLeftCorner.X, + ((frameRect.getHeight() - height) / 2) + frameRect.UpperLeftCorner.Y, + 0, 0); + + checkRect.LowerRightCorner.X = checkRect.UpperLeftCorner.X + height; + checkRect.LowerRightCorner.Y = checkRect.UpperLeftCorner.Y + height; + + EGUI_DEFAULT_COLOR col = EGDC_GRAY_EDITABLE; + if (isEnabled()) + col = Pressed ? EGDC_FOCUSED_EDITABLE : EGDC_EDITABLE; + skin->draw3DSunkenPane(this, skin->getColor(col), + false, true, checkRect, &AbsoluteClippingRect); + + // the checked icon + if (Checked) { + skin->drawIcon(this, EGDI_CHECK_BOX_CHECKED, checkRect.getCenter(), + CheckTime, os::Timer::getTime(), false, &AbsoluteClippingRect); + } + + // associated text + if (Text.size()) { + checkRect = frameRect; + checkRect.UpperLeftCorner.X += height + 5; + + IGUIFont *font = skin->getFont(); + if (font) { + font->draw(Text.c_str(), checkRect, + skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), false, true, &AbsoluteClippingRect); + } + } + } + IGUIElement::draw(); +} + +//! set if box is checked +void CGUICheckBox::setChecked(bool checked) +{ + Checked = checked; +} + +//! returns if box is checked +bool CGUICheckBox::isChecked() const +{ + return Checked; +} + +//! Sets whether to draw the background +void CGUICheckBox::setDrawBackground(bool draw) +{ + Background = draw; +} + +//! Checks if background drawing is enabled +bool CGUICheckBox::isDrawBackgroundEnabled() const +{ + return Background; +} + +//! Sets whether to draw the border +void CGUICheckBox::setDrawBorder(bool draw) +{ + Border = draw; +} + +//! Checks if border drawing is enabled +bool CGUICheckBox::isDrawBorderEnabled() const +{ + return Border; +} + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUICheckBox.h b/irr/src/CGUICheckBox.h new file mode 100644 index 000000000..2c2a98f04 --- /dev/null +++ b/irr/src/CGUICheckBox.h @@ -0,0 +1,55 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUICheckBox.h" + +namespace irr +{ +namespace gui +{ + +class CGUICheckBox : public IGUICheckBox +{ +public: + //! constructor + CGUICheckBox(bool checked, IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect rectangle); + + //! set if box is checked + void setChecked(bool checked) override; + + //! returns if box is checked + bool isChecked() const override; + + //! Sets whether to draw the background + void setDrawBackground(bool draw) override; + + //! Checks if background drawing is enabled + /** \return true if background drawing is enabled, false otherwise */ + bool isDrawBackgroundEnabled() const override; + + //! Sets whether to draw the border + void setDrawBorder(bool draw) override; + + //! Checks if border drawing is enabled + /** \return true if border drawing is enabled, false otherwise */ + bool isDrawBorderEnabled() const override; + + //! called if an event happened. + bool OnEvent(const SEvent &event) override; + + //! draws the element and its children + void draw() override; + +private: + u32 CheckTime; + bool Pressed; + bool Checked; + bool Border; + bool Background; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIComboBox.cpp b/irr/src/CGUIComboBox.cpp new file mode 100644 index 000000000..0088641b5 --- /dev/null +++ b/irr/src/CGUIComboBox.cpp @@ -0,0 +1,463 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIComboBox.h" + +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IGUIFont.h" +#include "IGUIButton.h" +#include "CGUIListBox.h" +#include "os.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIComboBox::CGUIComboBox(IGUIEnvironment *environment, IGUIElement *parent, + s32 id, core::rect rectangle) : + IGUIComboBox(environment, parent, id, rectangle), + ListButton(nullptr), SelectedText(nullptr), ListBox(nullptr), LastFocus(nullptr), + Selected(-1), HAlign(EGUIA_UPPERLEFT), VAlign(EGUIA_CENTER), MaxSelectionRows(5), HasFocus(false), + ActiveFont(nullptr) +{ +#ifdef _DEBUG + setDebugName("CGUIComboBox"); +#endif + + IGUISkin *skin = Environment->getSkin(); + + ListButton = Environment->addButton(core::recti(0, 0, 1, 1), this, -1, L""); + if (skin && skin->getSpriteBank()) { + ListButton->setSpriteBank(skin->getSpriteBank()); + ListButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_DOWN), skin->getColor(EGDC_WINDOW_SYMBOL)); + ListButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_DOWN), skin->getColor(EGDC_WINDOW_SYMBOL)); + } + ListButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + ListButton->setSubElement(true); + ListButton->setTabStop(false); + + SelectedText = Environment->addStaticText(L"", core::recti(0, 0, 1, 1), false, false, this, -1, false); + SelectedText->setSubElement(true); + SelectedText->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + SelectedText->setTextAlignment(EGUIA_UPPERLEFT, EGUIA_CENTER); + if (skin) + SelectedText->setOverrideColor(skin->getColor(EGDC_BUTTON_TEXT)); + SelectedText->enableOverrideColor(true); + + updateListButtonWidth(skin ? skin->getSize(EGDS_SCROLLBAR_SIZE) : 15); + + // this element can be tabbed to + setTabStop(true); + setTabOrder(-1); +} + +void CGUIComboBox::setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) +{ + HAlign = horizontal; + VAlign = vertical; + SelectedText->setTextAlignment(horizontal, vertical); +} + +//! Set the maximal number of rows for the selection listbox +void CGUIComboBox::setMaxSelectionRows(u32 max) +{ + MaxSelectionRows = max; + + // force recalculation of open listbox + if (ListBox) { + openCloseMenu(); + openCloseMenu(); + } +} + +//! Get the maximal number of rows for the selection listbox +u32 CGUIComboBox::getMaxSelectionRows() const +{ + return MaxSelectionRows; +} + +//! Returns amount of items in box +u32 CGUIComboBox::getItemCount() const +{ + return Items.size(); +} + +//! returns string of an item. the idx may be a value from 0 to itemCount-1 +const wchar_t *CGUIComboBox::getItem(u32 idx) const +{ + if (idx >= Items.size()) + return 0; + + return Items[idx].Name.c_str(); +} + +//! returns string of an item. the idx may be a value from 0 to itemCount-1 +u32 CGUIComboBox::getItemData(u32 idx) const +{ + if (idx >= Items.size()) + return 0; + + return Items[idx].Data; +} + +//! Returns index based on item data +s32 CGUIComboBox::getIndexForItemData(u32 data) const +{ + for (u32 i = 0; i < Items.size(); ++i) { + if (Items[i].Data == data) + return i; + } + return -1; +} + +//! Removes an item from the combo box. +void CGUIComboBox::removeItem(u32 idx) +{ + if (idx >= Items.size()) + return; + + if (Selected == (s32)idx) + setSelected(-1); + + Items.erase(idx); +} + +//! Returns caption of this element. +const wchar_t *CGUIComboBox::getText() const +{ + return getItem(Selected); +} + +//! adds an item and returns the index of it +u32 CGUIComboBox::addItem(const wchar_t *text, u32 data) +{ + Items.push_back(SComboData(text, data)); + + if (Selected == -1) + setSelected(0); + + return Items.size() - 1; +} + +//! deletes all items in the combo box +void CGUIComboBox::clear() +{ + Items.clear(); + setSelected(-1); +} + +//! returns id of selected item. returns -1 if no item is selected. +s32 CGUIComboBox::getSelected() const +{ + return Selected; +} + +//! sets the selected item. Set this to -1 if no item should be selected +void CGUIComboBox::setSelected(s32 idx) +{ + if (idx < -1 || idx >= (s32)Items.size()) + return; + + Selected = idx; + if (Selected == -1) + SelectedText->setText(L""); + else + SelectedText->setText(Items[Selected].Name.c_str()); +} + +//! Sets the selected item and emits a change event. +/** Set this to -1 if no item should be selected */ +void CGUIComboBox::setAndSendSelected(s32 idx) +{ + setSelected(idx); + sendSelectionChangedEvent(); +} + +//! called if an event happened. +bool CGUIComboBox::OnEvent(const SEvent &event) +{ + if (isEnabled()) { + switch (event.EventType) { + + case EET_KEY_INPUT_EVENT: + if (ListBox && event.KeyInput.PressedDown && event.KeyInput.Key == KEY_ESCAPE) { + // hide list box + openCloseMenu(); + return true; + } else if (event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE) { + if (!event.KeyInput.PressedDown) { + openCloseMenu(); + } + + ListButton->setPressed(ListBox == nullptr); + + return true; + } else if (event.KeyInput.PressedDown) { + s32 oldSelected = Selected; + bool absorb = true; + switch (event.KeyInput.Key) { + case KEY_DOWN: + setSelected(Selected + 1); + break; + case KEY_UP: + setSelected(Selected - 1); + break; + case KEY_HOME: + case KEY_PRIOR: + setSelected(0); + break; + case KEY_END: + case KEY_NEXT: + setSelected((s32)Items.size() - 1); + break; + default: + absorb = false; + } + + if (Selected < 0) + setSelected(0); + + if (Selected >= (s32)Items.size()) + setSelected((s32)Items.size() - 1); + + if (Selected != oldSelected) { + sendSelectionChangedEvent(); + return true; + } + + if (absorb) + return true; + } + break; + + case EET_GUI_EVENT: + + switch (event.GUIEvent.EventType) { + case EGET_ELEMENT_FOCUS_LOST: + if (ListBox && + (Environment->hasFocus(ListBox) || ListBox->isMyChild(event.GUIEvent.Caller)) && + event.GUIEvent.Element != this && + !isMyChild(event.GUIEvent.Element) && + !ListBox->isMyChild(event.GUIEvent.Element)) { + openCloseMenu(); + } + break; + case EGET_BUTTON_CLICKED: + if (event.GUIEvent.Caller == ListButton) { + openCloseMenu(); + return true; + } + break; + case EGET_LISTBOX_SELECTED_AGAIN: + case EGET_LISTBOX_CHANGED: + if (event.GUIEvent.Caller == ListBox) { + setSelected(ListBox->getSelected()); + if (Selected < 0 || Selected >= (s32)Items.size()) + setSelected(-1); + openCloseMenu(); + + sendSelectionChangedEvent(); + } + return true; + default: + break; + } + break; + case EET_MOUSE_INPUT_EVENT: + + switch (event.MouseInput.Event) { + case EMIE_LMOUSE_PRESSED_DOWN: { + core::position2d p(event.MouseInput.X, event.MouseInput.Y); + + // send to list box + if (ListBox && ListBox->isPointInside(p) && ListBox->OnEvent(event)) + return true; + + return true; + } + case EMIE_LMOUSE_LEFT_UP: { + core::position2d p(event.MouseInput.X, event.MouseInput.Y); + + // send to list box + if (!(ListBox && + ListBox->getAbsolutePosition().isPointInside(p) && + ListBox->OnEvent(event))) { + openCloseMenu(); + } + return true; + } + case EMIE_MOUSE_WHEEL: { + // Try scrolling parent first + if (IGUIElement::OnEvent(event)) + return true; + + s32 oldSelected = Selected; + setSelected(Selected + ((event.MouseInput.Wheel < 0) ? 1 : -1)); + + if (Selected < 0) + setSelected(0); + + if (Selected >= (s32)Items.size()) + setSelected((s32)Items.size() - 1); + + if (Selected != oldSelected) { + sendSelectionChangedEvent(); + return true; + } + + return false; + } + default: + break; + } + break; + default: + break; + } + } + + return IGUIElement::OnEvent(event); +} + +void CGUIComboBox::sendSelectionChangedEvent() +{ + if (Parent) { + SEvent event; + + event.EventType = EET_GUI_EVENT; + event.GUIEvent.Caller = this; + event.GUIEvent.Element = nullptr; + event.GUIEvent.EventType = EGET_COMBO_BOX_CHANGED; + Parent->OnEvent(event); + } +} + +void CGUIComboBox::updateListButtonWidth(s32 width) +{ + if (ListButton->getRelativePosition().getWidth() != width) { + core::rect r; + r.UpperLeftCorner.X = RelativeRect.getWidth() - width - 2; + r.LowerRightCorner.X = RelativeRect.getWidth() - 2; + r.UpperLeftCorner.Y = 2; + r.LowerRightCorner.Y = RelativeRect.getHeight() - 2; + ListButton->setRelativePosition(r); + + r.UpperLeftCorner.X = 2; + r.UpperLeftCorner.Y = 2; + r.LowerRightCorner.X = RelativeRect.getWidth() - (width + 2); + r.LowerRightCorner.Y = RelativeRect.getHeight() - 2; + SelectedText->setRelativePosition(r); + } +} + +//! draws the element and its children +void CGUIComboBox::draw() +{ + if (!IsVisible) + return; + + IGUISkin *skin = Environment->getSkin(); + + updateListButtonWidth(skin->getSize(EGDS_SCROLLBAR_SIZE)); + + // font changed while the listbox is open? + if (ActiveFont != skin->getFont() && ListBox) { + // close and re-open to use new font-size + openCloseMenu(); + openCloseMenu(); + } + + IGUIElement *currentFocus = Environment->getFocus(); + if (currentFocus != LastFocus) { + HasFocus = currentFocus == this || isMyChild(currentFocus); + LastFocus = currentFocus; + } + + // set colors each time as skin-colors can be changed + SelectedText->setBackgroundColor(skin->getColor(EGDC_HIGH_LIGHT)); + if (isEnabled()) { + SelectedText->setDrawBackground(HasFocus); + SelectedText->setOverrideColor(skin->getColor(HasFocus ? EGDC_HIGH_LIGHT_TEXT : EGDC_BUTTON_TEXT)); + } else { + SelectedText->setDrawBackground(false); + SelectedText->setOverrideColor(skin->getColor(EGDC_GRAY_TEXT)); + } + ListButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_DOWN), skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL)); + ListButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_DOWN), skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL)); + + core::rect frameRect(AbsoluteRect); + + // draw the border + + skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_HIGH_LIGHT), + true, true, frameRect, &AbsoluteClippingRect); + + // draw children + IGUIElement::draw(); +} + +void CGUIComboBox::openCloseMenu() +{ + if (ListBox) { + // close list box + Environment->setFocus(this); + ListBox->remove(); + ListBox = nullptr; + } else { + if (Parent) { + SEvent event; + event.EventType = EET_GUI_EVENT; + event.GUIEvent.Caller = this; + event.GUIEvent.Element = nullptr; + event.GUIEvent.EventType = EGET_LISTBOX_OPENED; + + // Allow to prevent the listbox from opening. + if (Parent->OnEvent(event)) + return; + + Parent->bringToFront(this); + } + + IGUISkin *skin = Environment->getSkin(); + u32 h = Items.size(); + + if (h > getMaxSelectionRows()) + h = getMaxSelectionRows(); + if (h == 0) + h = 1; + + ActiveFont = skin->getFont(); + if (ActiveFont) + h *= (ActiveFont->getDimension(L"A").Height + 4); + + // open list box + core::rect r(0, AbsoluteRect.getHeight(), + AbsoluteRect.getWidth(), AbsoluteRect.getHeight() + h); + + ListBox = new CGUIListBox(Environment, this, -1, r, false, true, true); + ListBox->setSubElement(true); + ListBox->setNotClipped(true); + ListBox->drop(); + + // ensure that list box is always completely visible + if (ListBox->getAbsolutePosition().LowerRightCorner.Y > Environment->getRootGUIElement()->getAbsolutePosition().getHeight()) + ListBox->setRelativePosition(core::rect(0, -ListBox->getAbsolutePosition().getHeight(), AbsoluteRect.getWidth(), 0)); + + for (s32 i = 0; i < (s32)Items.size(); ++i) + ListBox->addItem(Items[i].Name.c_str()); + + ListBox->setSelected(Selected); + + // set focus + Environment->setFocus(ListBox); + } +} + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIComboBox.h b/irr/src/CGUIComboBox.h new file mode 100644 index 000000000..77f1eca1a --- /dev/null +++ b/irr/src/CGUIComboBox.h @@ -0,0 +1,104 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIComboBox.h" +#include "IGUIStaticText.h" +#include "irrString.h" +#include "irrArray.h" + +namespace irr +{ +namespace gui +{ +class IGUIButton; +class IGUIListBox; + +//! Single line edit box for editing simple text. +class CGUIComboBox : public IGUIComboBox +{ +public: + //! constructor + CGUIComboBox(IGUIEnvironment *environment, IGUIElement *parent, + s32 id, core::rect rectangle); + + //! Returns amount of items in box + u32 getItemCount() const override; + + //! returns string of an item. the idx may be a value from 0 to itemCount-1 + const wchar_t *getItem(u32 idx) const override; + + //! Returns item data of an item. the idx may be a value from 0 to itemCount-1 + u32 getItemData(u32 idx) const override; + + //! Returns index based on item data + s32 getIndexForItemData(u32 data) const override; + + //! adds an item and returns the index of it + u32 addItem(const wchar_t *text, u32 data) override; + + //! Removes an item from the combo box. + void removeItem(u32 id) override; + + //! deletes all items in the combo box + void clear() override; + + //! returns the text of the currently selected item + const wchar_t *getText() const override; + + //! returns id of selected item. returns -1 if no item is selected. + s32 getSelected() const override; + + //! sets the selected item. Set this to -1 if no item should be selected + void setSelected(s32 idx) override; + + //! Sets the selected item and emits a change event. + /** Set this to -1 if no item should be selected */ + void setAndSendSelected(s32 idx) override; + + //! sets the text alignment of the text part + void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) override; + + //! Set the maximal number of rows for the selection listbox + void setMaxSelectionRows(u32 max) override; + + //! Get the maximal number of rows for the selection listbox + u32 getMaxSelectionRows() const override; + + //! called if an event happened. + bool OnEvent(const SEvent &event) override; + + //! draws the element and its children + void draw() override; + +private: + void openCloseMenu(); + void sendSelectionChangedEvent(); + void updateListButtonWidth(s32 width); + + IGUIButton *ListButton; + IGUIStaticText *SelectedText; + IGUIListBox *ListBox; + IGUIElement *LastFocus; + + struct SComboData + { + SComboData(const wchar_t *text, u32 data) : + Name(text), Data(data) {} + + core::stringw Name; + u32 Data; + }; + core::array Items; + + s32 Selected; + EGUI_ALIGNMENT HAlign, VAlign; + u32 MaxSelectionRows; + bool HasFocus; + IGUIFont *ActiveFont; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIEditBox.cpp b/irr/src/CGUIEditBox.cpp new file mode 100644 index 000000000..8d03caf4a --- /dev/null +++ b/irr/src/CGUIEditBox.cpp @@ -0,0 +1,1495 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIEditBox.h" + +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IGUIFont.h" +#include "IVideoDriver.h" +#include "rect.h" +#include "os.h" +#include "Keycodes.h" + +/* + todo: + optional scrollbars + ctrl+left/right to select word + double click/ctrl click: word select + drag to select whole words, triple click to select line + optional? dragging selected text + numerical +*/ + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIEditBox::CGUIEditBox(const wchar_t *text, bool border, + IGUIEnvironment *environment, IGUIElement *parent, s32 id, + const core::rect &rectangle) : + IGUIEditBox(environment, parent, id, rectangle), + OverwriteMode(false), MouseMarking(false), + Border(border), Background(true), OverrideColorEnabled(false), MarkBegin(0), MarkEnd(0), + OverrideColor(video::SColor(101, 255, 255, 255)), OverrideFont(0), LastBreakFont(0), + Operator(0), BlinkStartTime(0), CursorBlinkTime(350), CursorChar(L"_"), CursorPos(0), HScrollPos(0), VScrollPos(0), Max(0), + WordWrap(false), MultiLine(false), AutoScroll(true), PasswordBox(false), + PasswordChar(L'*'), HAlign(EGUIA_UPPERLEFT), VAlign(EGUIA_CENTER), + CurrentTextRect(0, 0, 1, 1), FrameRect(rectangle) +{ +#ifdef _DEBUG + setDebugName("CGUIEditBox"); +#endif + + Text = text; + + if (Environment) + Operator = Environment->getOSOperator(); + + if (Operator) + Operator->grab(); + + // this element can be tabbed to + setTabStop(true); + setTabOrder(-1); + + calculateFrameRect(); + breakText(); + + calculateScrollPos(); +} + +//! destructor +CGUIEditBox::~CGUIEditBox() +{ + if (OverrideFont) + OverrideFont->drop(); + + if (Operator) + Operator->drop(); +} + +//! Sets another skin independent font. +void CGUIEditBox::setOverrideFont(IGUIFont *font) +{ + if (OverrideFont == font) + return; + + if (OverrideFont) + OverrideFont->drop(); + + OverrideFont = font; + + if (OverrideFont) + OverrideFont->grab(); + + breakText(); +} + +//! Gets the override font (if any) +IGUIFont *CGUIEditBox::getOverrideFont() const +{ + return OverrideFont; +} + +//! Get the font which is used right now for drawing +IGUIFont *CGUIEditBox::getActiveFont() const +{ + if (OverrideFont) + return OverrideFont; + IGUISkin *skin = Environment->getSkin(); + if (skin) + return skin->getFont(); + return 0; +} + +//! Sets another color for the text. +void CGUIEditBox::setOverrideColor(video::SColor color) +{ + OverrideColor = color; + OverrideColorEnabled = true; +} + +video::SColor CGUIEditBox::getOverrideColor() const +{ + return OverrideColor; +} + +//! Turns the border on or off +void CGUIEditBox::setDrawBorder(bool border) +{ + Border = border; +} + +//! Checks if border drawing is enabled +bool CGUIEditBox::isDrawBorderEnabled() const +{ + return Border; +} + +//! Sets whether to draw the background +void CGUIEditBox::setDrawBackground(bool draw) +{ + Background = draw; +} + +//! Checks if background drawing is enabled +bool CGUIEditBox::isDrawBackgroundEnabled() const +{ + return Background; +} + +//! Sets if the text should use the override color or the color in the gui skin. +void CGUIEditBox::enableOverrideColor(bool enable) +{ + OverrideColorEnabled = enable; +} + +bool CGUIEditBox::isOverrideColorEnabled() const +{ + return OverrideColorEnabled; +} + +//! Enables or disables word wrap +void CGUIEditBox::setWordWrap(bool enable) +{ + WordWrap = enable; + breakText(); +} + +void CGUIEditBox::updateAbsolutePosition() +{ + core::rect oldAbsoluteRect(AbsoluteRect); + IGUIElement::updateAbsolutePosition(); + if (oldAbsoluteRect != AbsoluteRect) { + calculateFrameRect(); + breakText(); + calculateScrollPos(); + } +} + +//! Checks if word wrap is enabled +bool CGUIEditBox::isWordWrapEnabled() const +{ + return WordWrap; +} + +//! Enables or disables newlines. +void CGUIEditBox::setMultiLine(bool enable) +{ + MultiLine = enable; + breakText(); +} + +//! Checks if multi line editing is enabled +bool CGUIEditBox::isMultiLineEnabled() const +{ + return MultiLine; +} + +void CGUIEditBox::setPasswordBox(bool passwordBox, wchar_t passwordChar) +{ + PasswordBox = passwordBox; + if (PasswordBox) { + PasswordChar = passwordChar; + setMultiLine(false); + setWordWrap(false); + BrokenText.clear(); + } +} + +bool CGUIEditBox::isPasswordBox() const +{ + return PasswordBox; +} + +//! Sets text justification +void CGUIEditBox::setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) +{ + HAlign = horizontal; + VAlign = vertical; +} + +//! called if an event happened. +bool CGUIEditBox::OnEvent(const SEvent &event) +{ + if (isEnabled()) { + + switch (event.EventType) { + case EET_GUI_EVENT: + if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) { + if (event.GUIEvent.Caller == this) { + MouseMarking = false; + setTextMarkers(0, 0); + } + } + break; + case EET_KEY_INPUT_EVENT: + if (processKey(event)) + return true; + break; + case EET_MOUSE_INPUT_EVENT: + if (processMouse(event)) + return true; + break; + case EET_STRING_INPUT_EVENT: + inputString(*event.StringInput.Str); + return true; + break; + default: + break; + } + } + + return IGUIElement::OnEvent(event); +} + +bool CGUIEditBox::processKey(const SEvent &event) +{ + if (!event.KeyInput.PressedDown) + return false; + + bool textChanged = false; + s32 newMarkBegin = MarkBegin; + s32 newMarkEnd = MarkEnd; + + // control shortcut handling + + if (event.KeyInput.Control) { + // german backlash '\' entered with control + '?' + if (event.KeyInput.Char == '\\') { + inputChar(event.KeyInput.Char); + return true; + } + + switch (event.KeyInput.Key) { + case KEY_KEY_A: + // select all + newMarkBegin = 0; + newMarkEnd = Text.size(); + break; + case KEY_KEY_C: + // copy to clipboard + if (!PasswordBox && Operator && MarkBegin != MarkEnd) { + const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + + core::stringc s; + wStringToUTF8(s, Text.subString(realmbgn, realmend - realmbgn)); + Operator->copyToClipboard(s.c_str()); + } + break; + case KEY_KEY_X: + // cut to the clipboard + if (!PasswordBox && Operator && MarkBegin != MarkEnd) { + const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + + // copy + core::stringc sc; + wStringToUTF8(sc, Text.subString(realmbgn, realmend - realmbgn)); + Operator->copyToClipboard(sc.c_str()); + + if (isEnabled()) { + // delete + core::stringw s; + s = Text.subString(0, realmbgn); + s.append(Text.subString(realmend, Text.size() - realmend)); + Text = s; + + CursorPos = realmbgn; + newMarkBegin = 0; + newMarkEnd = 0; + textChanged = true; + } + } + break; + case KEY_KEY_V: + if (!isEnabled()) + break; + + // paste from the clipboard + if (Operator) { + const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + + // add the string + const c8 *p = Operator->getTextFromClipboard(); + if (p) { + irr::core::stringw widep; + core::utf8ToWString(widep, p); + + if (MarkBegin == MarkEnd) { + // insert text + core::stringw s = Text.subString(0, CursorPos); + s.append(widep); + s.append(Text.subString(CursorPos, Text.size() - CursorPos)); + + if (!Max || s.size() <= Max) { // thx to Fish FH for fix + Text = s; + s = widep; + CursorPos += s.size(); + } + } else { + // replace text + + core::stringw s = Text.subString(0, realmbgn); + s.append(widep); + s.append(Text.subString(realmend, Text.size() - realmend)); + + if (!Max || s.size() <= Max) { // thx to Fish FH for fix + Text = s; + s = widep; + CursorPos = realmbgn + s.size(); + } + } + } + + newMarkBegin = 0; + newMarkEnd = 0; + textChanged = true; + } + break; + case KEY_HOME: + // move/highlight to start of text + if (event.KeyInput.Shift) { + newMarkEnd = CursorPos; + newMarkBegin = 0; + CursorPos = 0; + } else { + CursorPos = 0; + newMarkBegin = 0; + newMarkEnd = 0; + } + break; + case KEY_END: + // move/highlight to end of text + if (event.KeyInput.Shift) { + newMarkBegin = CursorPos; + newMarkEnd = Text.size(); + CursorPos = 0; + } else { + CursorPos = Text.size(); + newMarkBegin = 0; + newMarkEnd = 0; + } + break; + default: + return false; + } + } + // Some special keys - but only handle them if KeyInput.Char is null as on some systems (X11) they might have same key-code as ansi-keys otherwise + else if (event.KeyInput.Char == 0) { + switch (event.KeyInput.Key) { + case KEY_END: { + s32 p = Text.size(); + if (WordWrap || MultiLine) { + p = getLineFromPos(CursorPos); + p = BrokenTextPositions[p] + (s32)BrokenText[p].size(); + if (p > 0 && (Text[p - 1] == L'\r' || Text[p - 1] == L'\n')) + p -= 1; + } + + if (event.KeyInput.Shift) { + if (MarkBegin == MarkEnd) + newMarkBegin = CursorPos; + + newMarkEnd = p; + } else { + newMarkBegin = 0; + newMarkEnd = 0; + } + CursorPos = p; + BlinkStartTime = os::Timer::getTime(); + } break; + case KEY_HOME: { + + s32 p = 0; + if (WordWrap || MultiLine) { + p = getLineFromPos(CursorPos); + p = BrokenTextPositions[p]; + } + + if (event.KeyInput.Shift) { + if (MarkBegin == MarkEnd) + newMarkBegin = CursorPos; + newMarkEnd = p; + } else { + newMarkBegin = 0; + newMarkEnd = 0; + } + CursorPos = p; + BlinkStartTime = os::Timer::getTime(); + } break; + case KEY_LEFT: + + if (event.KeyInput.Shift) { + if (CursorPos > 0) { + if (MarkBegin == MarkEnd) + newMarkBegin = CursorPos; + + newMarkEnd = CursorPos - 1; + } + } else { + newMarkBegin = 0; + newMarkEnd = 0; + } + + if (CursorPos > 0) + CursorPos--; + BlinkStartTime = os::Timer::getTime(); + break; + + case KEY_RIGHT: + if (event.KeyInput.Shift) { + if (Text.size() > (u32)CursorPos) { + if (MarkBegin == MarkEnd) + newMarkBegin = CursorPos; + + newMarkEnd = CursorPos + 1; + } + } else { + newMarkBegin = 0; + newMarkEnd = 0; + } + + if (Text.size() > (u32)CursorPos) + CursorPos++; + BlinkStartTime = os::Timer::getTime(); + break; + case KEY_UP: + if (MultiLine || (WordWrap && BrokenText.size() > 1)) { + s32 lineNo = getLineFromPos(CursorPos); + s32 mb = (MarkBegin == MarkEnd) ? CursorPos : (MarkBegin > MarkEnd ? MarkBegin : MarkEnd); + if (lineNo > 0) { + s32 cp = CursorPos - BrokenTextPositions[lineNo]; + if ((s32)BrokenText[lineNo - 1].size() < cp) + CursorPos = BrokenTextPositions[lineNo - 1] + core::max_((u32)1, BrokenText[lineNo - 1].size()) - 1; + else + CursorPos = BrokenTextPositions[lineNo - 1] + cp; + } + + if (event.KeyInput.Shift) { + newMarkBegin = mb; + newMarkEnd = CursorPos; + } else { + newMarkBegin = 0; + newMarkEnd = 0; + } + + } else { + return false; + } + break; + case KEY_DOWN: + if (MultiLine || (WordWrap && BrokenText.size() > 1)) { + s32 lineNo = getLineFromPos(CursorPos); + s32 mb = (MarkBegin == MarkEnd) ? CursorPos : (MarkBegin < MarkEnd ? MarkBegin : MarkEnd); + if (lineNo < (s32)BrokenText.size() - 1) { + s32 cp = CursorPos - BrokenTextPositions[lineNo]; + if ((s32)BrokenText[lineNo + 1].size() < cp) + CursorPos = BrokenTextPositions[lineNo + 1] + core::max_((u32)1, BrokenText[lineNo + 1].size()) - 1; + else + CursorPos = BrokenTextPositions[lineNo + 1] + cp; + } + + if (event.KeyInput.Shift) { + newMarkBegin = mb; + newMarkEnd = CursorPos; + } else { + newMarkBegin = 0; + newMarkEnd = 0; + } + + } else { + return false; + } + break; + case KEY_INSERT: + if (!isEnabled()) + break; + + OverwriteMode = !OverwriteMode; + break; + case KEY_DELETE: + if (!isEnabled()) + break; + + if (keyDelete()) { + BlinkStartTime = os::Timer::getTime(); + newMarkBegin = 0; + newMarkEnd = 0; + textChanged = true; + } + break; + default: + return false; + } + } else { + // default keyboard handling + switch (event.KeyInput.Key) { + case KEY_RETURN: + if (MultiLine) { + inputChar(L'\n'); + } else { + calculateScrollPos(); + sendGuiEvent(EGET_EDITBOX_ENTER); + } + return true; + + case KEY_BACK: + if (!isEnabled()) + break; + + if (Text.size()) { + core::stringw s; + + if (MarkBegin != MarkEnd) { + // delete marked text + const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + + s = Text.subString(0, realmbgn); + s.append(Text.subString(realmend, Text.size() - realmend)); + Text = s; + + CursorPos = realmbgn; + } else { + // delete text behind cursor + if (CursorPos > 0) + s = Text.subString(0, CursorPos - 1); + else + s = L""; + s.append(Text.subString(CursorPos, Text.size() - CursorPos)); + Text = s; + --CursorPos; + } + + if (CursorPos < 0) + CursorPos = 0; + BlinkStartTime = os::Timer::getTime(); + newMarkBegin = 0; + newMarkEnd = 0; + textChanged = true; + } + break; + + case KEY_DELETE: + + // At least on X11 we get a char with 127 when the delete key is pressed. + // We get no char when the delete key on numkeys is pressed with numlock off (handled in the other case calling keyDelete as Char is then 0). + // We get a keykode != 127 when delete key on numlock is pressed with numlock on. + if (event.KeyInput.Char == 127) { + if (!isEnabled()) + break; + + if (keyDelete()) { + BlinkStartTime = os::Timer::getTime(); + newMarkBegin = 0; + newMarkEnd = 0; + textChanged = true; + } + break; + } else { + inputChar(event.KeyInput.Char); + return true; + } + + case KEY_ESCAPE: + case KEY_TAB: + case KEY_SHIFT: + case KEY_F1: + case KEY_F2: + case KEY_F3: + case KEY_F4: + case KEY_F5: + case KEY_F6: + case KEY_F7: + case KEY_F8: + case KEY_F9: + case KEY_F10: + case KEY_F11: + case KEY_F12: + case KEY_F13: + case KEY_F14: + case KEY_F15: + case KEY_F16: + case KEY_F17: + case KEY_F18: + case KEY_F19: + case KEY_F20: + case KEY_F21: + case KEY_F22: + case KEY_F23: + case KEY_F24: + // ignore these keys + return false; + + default: + inputChar(event.KeyInput.Char); + return true; + } + } + + // Set new text markers + setTextMarkers(newMarkBegin, newMarkEnd); + + // break the text if it has changed + if (textChanged) { + breakText(); + calculateScrollPos(); + sendGuiEvent(EGET_EDITBOX_CHANGED); + } else { + calculateScrollPos(); + } + + return true; +} + +bool CGUIEditBox::keyDelete() +{ + if (Text.size() != 0) { + core::stringw s; + + if (MarkBegin != MarkEnd) { + // delete marked text + const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + + s = Text.subString(0, realmbgn); + s.append(Text.subString(realmend, Text.size() - realmend)); + Text = s; + + CursorPos = realmbgn; + } else { + // delete text before cursor + s = Text.subString(0, CursorPos); + s.append(Text.subString(CursorPos + 1, Text.size() - CursorPos - 1)); + Text = s; + } + + if (CursorPos > (s32)Text.size()) + CursorPos = (s32)Text.size(); + + return true; + } + + return false; +} + +//! draws the element and its children +void CGUIEditBox::draw() +{ + if (!IsVisible) + return; + + const bool focus = Environment->hasFocus(this); + + IGUISkin *skin = Environment->getSkin(); + if (!skin) + return; + + EGUI_DEFAULT_COLOR bgCol = EGDC_GRAY_EDITABLE; + if (isEnabled()) + bgCol = focus ? EGDC_FOCUSED_EDITABLE : EGDC_EDITABLE; + + if (!Border && Background) { + skin->draw2DRectangle(this, skin->getColor(bgCol), AbsoluteRect, &AbsoluteClippingRect); + } + + if (Border) { + // draw the border + skin->draw3DSunkenPane(this, skin->getColor(bgCol), false, Background, AbsoluteRect, &AbsoluteClippingRect); + + calculateFrameRect(); + } + + core::rect localClipRect = FrameRect; + localClipRect.clipAgainst(AbsoluteClippingRect); + + // draw the text + + IGUIFont *font = getActiveFont(); + + s32 cursorLine = 0; + s32 charcursorpos = 0; + + if (font) { + if (LastBreakFont != font) { + breakText(); + } + + // calculate cursor pos + + core::stringw *txtLine = &Text; + s32 startPos = 0; + + core::stringw s, s2; + + // get mark position + const bool ml = (!PasswordBox && (WordWrap || MultiLine)); + const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + const s32 hlineStart = ml ? getLineFromPos(realmbgn) : 0; + const s32 hlineCount = ml ? getLineFromPos(realmend) - hlineStart + 1 : 1; + const s32 lineCount = ml ? BrokenText.size() : 1; + + // Save the override color information. + // Then, alter it if the edit box is disabled. + const bool prevOver = OverrideColorEnabled; + const video::SColor prevColor = OverrideColor; + + if (Text.size()) { + if (!isEnabled() && !OverrideColorEnabled) { + OverrideColorEnabled = true; + OverrideColor = skin->getColor(EGDC_GRAY_TEXT); + } + + for (s32 i = 0; i < lineCount; ++i) { + setTextRect(i); + + // clipping test - don't draw anything outside the visible area + core::rect c = localClipRect; + c.clipAgainst(CurrentTextRect); + if (!c.isValid()) + continue; + + // get current line + if (PasswordBox) { + if (BrokenText.size() != 1) { + BrokenText.clear(); + BrokenText.push_back(core::stringw()); + } + if (BrokenText[0].size() != Text.size()) { + BrokenText[0] = Text; + for (u32 q = 0; q < Text.size(); ++q) { + BrokenText[0][q] = PasswordChar; + } + } + txtLine = &BrokenText[0]; + startPos = 0; + } else { + txtLine = ml ? &BrokenText[i] : &Text; + startPos = ml ? BrokenTextPositions[i] : 0; + } + + // draw normal text + font->draw(txtLine->c_str(), CurrentTextRect, + OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT), + false, true, &localClipRect); + + // draw mark and marked text + if (focus && MarkBegin != MarkEnd && i >= hlineStart && i < hlineStart + hlineCount) { + + s32 mbegin = 0, mend = 0; + s32 lineStartPos = 0, lineEndPos = txtLine->size(); + + if (i == hlineStart) { + // highlight start is on this line + s = txtLine->subString(0, realmbgn - startPos); + mbegin = font->getDimension(s.c_str()).Width; + + // deal with kerning + mbegin += font->getKerningWidth( + &((*txtLine)[realmbgn - startPos]), + realmbgn - startPos > 0 ? &((*txtLine)[realmbgn - startPos - 1]) : 0); + + lineStartPos = realmbgn - startPos; + } + if (i == hlineStart + hlineCount - 1) { + // highlight end is on this line + s2 = txtLine->subString(0, realmend - startPos); + mend = font->getDimension(s2.c_str()).Width; + lineEndPos = (s32)s2.size(); + } else + mend = font->getDimension(txtLine->c_str()).Width; + + CurrentTextRect.UpperLeftCorner.X += mbegin; + CurrentTextRect.LowerRightCorner.X = CurrentTextRect.UpperLeftCorner.X + mend - mbegin; + + // draw mark + skin->draw2DRectangle(this, skin->getColor(EGDC_HIGH_LIGHT), CurrentTextRect, &localClipRect); + + // draw marked text + s = txtLine->subString(lineStartPos, lineEndPos - lineStartPos); + + if (s.size()) + font->draw(s.c_str(), CurrentTextRect, + OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_HIGH_LIGHT_TEXT), + false, true, &localClipRect); + } + } + + // Return the override color information to its previous settings. + OverrideColorEnabled = prevOver; + OverrideColor = prevColor; + } + + // draw cursor + if (isEnabled()) { + if (WordWrap || MultiLine) { + cursorLine = getLineFromPos(CursorPos); + txtLine = &BrokenText[cursorLine]; + startPos = BrokenTextPositions[cursorLine]; + } + s = txtLine->subString(0, CursorPos - startPos); + charcursorpos = font->getDimension(s.c_str()).Width + + font->getKerningWidth(CursorChar.c_str(), CursorPos - startPos > 0 ? &((*txtLine)[CursorPos - startPos - 1]) : 0); + + if (focus && (CursorBlinkTime == 0 || (os::Timer::getTime() - BlinkStartTime) % (2 * CursorBlinkTime) < CursorBlinkTime)) { + setTextRect(cursorLine); + CurrentTextRect.UpperLeftCorner.X += charcursorpos; + + if (OverwriteMode) { + core::stringw character = Text.subString(CursorPos, 1); + s32 mend = font->getDimension(character.c_str()).Width; + // Make sure the cursor box has at least some width to it + if (mend <= 0) + mend = font->getDimension(CursorChar.c_str()).Width; + CurrentTextRect.LowerRightCorner.X = CurrentTextRect.UpperLeftCorner.X + mend; + skin->draw2DRectangle(this, skin->getColor(EGDC_HIGH_LIGHT), CurrentTextRect, &localClipRect); + font->draw(character.c_str(), CurrentTextRect, + OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_HIGH_LIGHT_TEXT), + false, true, &localClipRect); + } else { + font->draw(CursorChar, CurrentTextRect, + OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT), + false, true, &localClipRect); + } + } + } + } + + // draw children + IGUIElement::draw(); +} + +//! Sets the new caption of this element. +void CGUIEditBox::setText(const wchar_t *text) +{ + Text = text; + if (u32(CursorPos) > Text.size()) + CursorPos = Text.size(); + HScrollPos = 0; + breakText(); +} + +//! Enables or disables automatic scrolling with cursor position +//! \param enable: If set to true, the text will move around with the cursor position +void CGUIEditBox::setAutoScroll(bool enable) +{ + AutoScroll = enable; +} + +//! Checks to see if automatic scrolling is enabled +//! \return true if automatic scrolling is enabled, false if not +bool CGUIEditBox::isAutoScrollEnabled() const +{ + return AutoScroll; +} + +//! Gets the area of the text in the edit box +//! \return Returns the size in pixels of the text +core::dimension2du CGUIEditBox::getTextDimension() +{ + core::rect ret; + + setTextRect(0); + ret = CurrentTextRect; + + for (u32 i = 1; i < BrokenText.size(); ++i) { + setTextRect(i); + ret.addInternalPoint(CurrentTextRect.UpperLeftCorner); + ret.addInternalPoint(CurrentTextRect.LowerRightCorner); + } + + return core::dimension2du(ret.getSize()); +} + +//! Sets the maximum amount of characters which may be entered in the box. +//! \param max: Maximum amount of characters. If 0, the character amount is +//! infinity. +void CGUIEditBox::setMax(u32 max) +{ + Max = max; + + if (Text.size() > Max && Max != 0) + Text = Text.subString(0, Max); +} + +//! Returns maximum amount of characters, previously set by setMax(); +u32 CGUIEditBox::getMax() const +{ + return Max; +} + +//! Set the character used for the cursor. +/** By default it's "_" */ +void CGUIEditBox::setCursorChar(const wchar_t cursorChar) +{ + CursorChar[0] = cursorChar; +} + +//! Get the character used for the cursor. +wchar_t CGUIEditBox::getCursorChar() const +{ + return CursorChar[0]; +} + +//! Set the blinktime for the cursor. 2x blinktime is one full cycle. +void CGUIEditBox::setCursorBlinkTime(irr::u32 timeMs) +{ + CursorBlinkTime = timeMs; +} + +//! Get the cursor blinktime +irr::u32 CGUIEditBox::getCursorBlinkTime() const +{ + return CursorBlinkTime; +} + +bool CGUIEditBox::processMouse(const SEvent &event) +{ + switch (event.MouseInput.Event) { + case irr::EMIE_LMOUSE_LEFT_UP: + if (Environment->hasFocus(this)) { + CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); + if (MouseMarking) { + setTextMarkers(MarkBegin, CursorPos); + } + MouseMarking = false; + calculateScrollPos(); + return true; + } + break; + case irr::EMIE_MOUSE_MOVED: { + if (MouseMarking) { + CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); + setTextMarkers(MarkBegin, CursorPos); + calculateScrollPos(); + return true; + } + } break; + case EMIE_LMOUSE_PRESSED_DOWN: + if (!Environment->hasFocus(this)) { // can happen when events are manually send to the element + BlinkStartTime = os::Timer::getTime(); + MouseMarking = true; + CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); + setTextMarkers(CursorPos, CursorPos); + calculateScrollPos(); + return true; + } else { + if (!AbsoluteClippingRect.isPointInside( + core::position2d(event.MouseInput.X, event.MouseInput.Y))) { + return false; + } else { + // move cursor + CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); + + s32 newMarkBegin = MarkBegin; + if (!MouseMarking) + newMarkBegin = CursorPos; + + MouseMarking = true; + setTextMarkers(newMarkBegin, CursorPos); + calculateScrollPos(); + return true; + } + } + case EMIE_MMOUSE_PRESSED_DOWN: { + if (!AbsoluteClippingRect.isPointInside(core::position2d( + event.MouseInput.X, event.MouseInput.Y))) + return false; + + if (!Environment->hasFocus(this)) { + BlinkStartTime = os::Timer::getTime(); + } + + // move cursor and disable marking + CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); + MouseMarking = false; + setTextMarkers(CursorPos, CursorPos); + + // paste from the primary selection + inputString([&] { + irr::core::stringw inserted_text; + if (!Operator) + return inserted_text; + const c8 *inserted_text_utf8 = Operator->getTextFromPrimarySelection(); + if (!inserted_text_utf8) + return inserted_text; + core::utf8ToWString(inserted_text, inserted_text_utf8); + return inserted_text; + }()); + + return true; + } + default: + break; + } + + return false; +} + +s32 CGUIEditBox::getCursorPos(s32 x, s32 y) +{ + IGUIFont *font = getActiveFont(); + + const u32 lineCount = (WordWrap || MultiLine) ? BrokenText.size() : 1; + + core::stringw *txtLine = 0; + s32 startPos = 0; + x += 3; + + for (u32 i = 0; i < lineCount; ++i) { + setTextRect(i); + if (i == 0 && y < CurrentTextRect.UpperLeftCorner.Y) + y = CurrentTextRect.UpperLeftCorner.Y; + if (i == lineCount - 1 && y > CurrentTextRect.LowerRightCorner.Y) + y = CurrentTextRect.LowerRightCorner.Y; + + // is it inside this region? + if (y >= CurrentTextRect.UpperLeftCorner.Y && y <= CurrentTextRect.LowerRightCorner.Y) { + // we've found the clicked line + txtLine = (WordWrap || MultiLine) ? &BrokenText[i] : &Text; + startPos = (WordWrap || MultiLine) ? BrokenTextPositions[i] : 0; + break; + } + } + + if (x < CurrentTextRect.UpperLeftCorner.X) + x = CurrentTextRect.UpperLeftCorner.X; + + if (!txtLine) + return 0; + + s32 idx = font->getCharacterFromPos(txtLine->c_str(), x - CurrentTextRect.UpperLeftCorner.X); + + // click was on or left of the line + if (idx != -1) + return idx + startPos; + + // click was off the right edge of the line, go to end. + return txtLine->size() + startPos; +} + +//! Breaks the single text line. +void CGUIEditBox::breakText() +{ + if ((!WordWrap && !MultiLine)) + return; + + BrokenText.clear(); // need to reallocate :/ + BrokenTextPositions.set_used(0); + + IGUIFont *font = getActiveFont(); + if (!font) + return; + + LastBreakFont = font; + + core::stringw line; + core::stringw word; + core::stringw whitespace; + s32 lastLineStart = 0; + s32 size = Text.size(); + s32 length = 0; + s32 elWidth = RelativeRect.getWidth() - 6; + wchar_t c; + + for (s32 i = 0; i < size; ++i) { + c = Text[i]; + bool lineBreak = false; + + if (c == L'\r') { // Mac or Windows breaks + lineBreak = true; + c = 0; + if (Text[i + 1] == L'\n') { // Windows breaks + // TODO: I (Michael) think that we shouldn't change the text given by the user for whatever reason. + // Instead rework the cursor positioning to be able to handle this (but not in stable release + // branch as users might already expect this behavior). + Text.erase(i + 1); + --size; + if (CursorPos > i) + --CursorPos; + } + } else if (c == L'\n') { // Unix breaks + lineBreak = true; + c = 0; + } + + // don't break if we're not a multi-line edit box + if (!MultiLine) + lineBreak = false; + + if (c == L' ' || c == 0 || i == (size - 1)) { + // here comes the next whitespace, look if + // we can break the last word to the next line + // We also break whitespace, otherwise cursor would vanish beside the right border. + s32 whitelgth = font->getDimension(whitespace.c_str()).Width; + s32 worldlgth = font->getDimension(word.c_str()).Width; + + if (WordWrap && length + worldlgth + whitelgth > elWidth && line.size() > 0) { + // break to next line + length = worldlgth; + BrokenText.push_back(line); + BrokenTextPositions.push_back(lastLineStart); + lastLineStart = i - (s32)word.size(); + line = word; + } else { + // add word to line + line += whitespace; + line += word; + length += whitelgth + worldlgth; + } + + word = L""; + whitespace = L""; + + if (c) + whitespace += c; + + // compute line break + if (lineBreak) { + line += whitespace; + line += word; + BrokenText.push_back(line); + BrokenTextPositions.push_back(lastLineStart); + lastLineStart = i + 1; + line = L""; + word = L""; + whitespace = L""; + length = 0; + } + } else { + // yippee this is a word.. + word += c; + } + } + + line += whitespace; + line += word; + BrokenText.push_back(line); + BrokenTextPositions.push_back(lastLineStart); +} + +// TODO: that function does interpret VAlign according to line-index (indexed line is placed on top-center-bottom) +// but HAlign according to line-width (pixels) and not by row. +// Intuitively I suppose HAlign handling is better as VScrollPos should handle the line-scrolling. +// But please no one change this without also rewriting (and this time fucking testing!!!) autoscrolling (I noticed this when fixing the old autoscrolling). +void CGUIEditBox::setTextRect(s32 line) +{ + if (line < 0) + return; + + IGUIFont *font = getActiveFont(); + if (!font) + return; + + core::dimension2du d; + + // get text dimension + const u32 lineCount = (WordWrap || MultiLine) ? BrokenText.size() : 1; + if (WordWrap || MultiLine) { + d = font->getDimension(BrokenText[line].c_str()); + } else { + d = font->getDimension(Text.c_str()); + d.Height = AbsoluteRect.getHeight(); + } + d.Height += font->getKerningHeight(); + + // justification + switch (HAlign) { + case EGUIA_CENTER: + // align to h centre + CurrentTextRect.UpperLeftCorner.X = (FrameRect.getWidth() / 2) - (d.Width / 2); + CurrentTextRect.LowerRightCorner.X = (FrameRect.getWidth() / 2) + (d.Width / 2); + break; + case EGUIA_LOWERRIGHT: + // align to right edge + CurrentTextRect.UpperLeftCorner.X = FrameRect.getWidth() - d.Width; + CurrentTextRect.LowerRightCorner.X = FrameRect.getWidth(); + break; + default: + // align to left edge + CurrentTextRect.UpperLeftCorner.X = 0; + CurrentTextRect.LowerRightCorner.X = d.Width; + } + + switch (VAlign) { + case EGUIA_CENTER: + // align to v centre + CurrentTextRect.UpperLeftCorner.Y = + (FrameRect.getHeight() / 2) - (lineCount * d.Height) / 2 + d.Height * line; + break; + case EGUIA_LOWERRIGHT: + // align to bottom edge + CurrentTextRect.UpperLeftCorner.Y = + FrameRect.getHeight() - lineCount * d.Height + d.Height * line; + break; + default: + // align to top edge + CurrentTextRect.UpperLeftCorner.Y = d.Height * line; + break; + } + + CurrentTextRect.UpperLeftCorner.X -= HScrollPos; + CurrentTextRect.LowerRightCorner.X -= HScrollPos; + CurrentTextRect.UpperLeftCorner.Y -= VScrollPos; + CurrentTextRect.LowerRightCorner.Y = CurrentTextRect.UpperLeftCorner.Y + d.Height; + + CurrentTextRect += FrameRect.UpperLeftCorner; +} + +s32 CGUIEditBox::getLineFromPos(s32 pos) +{ + if (!WordWrap && !MultiLine) + return 0; + + s32 i = 0; + while (i < (s32)BrokenTextPositions.size()) { + if (BrokenTextPositions[i] > pos) + return i - 1; + ++i; + } + return (s32)BrokenTextPositions.size() - 1; +} + +void CGUIEditBox::inputChar(wchar_t c) +{ + if (c == 0) + return; + core::stringw s(&c, 1); + inputString(s); +} + +void CGUIEditBox::inputString(const core::stringw &str) +{ + if (!isEnabled()) + return; + + core::stringw s; + u32 len = str.size(); + + if (MarkBegin != MarkEnd) { + // replace marked text + const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + + s = Text.subString(0, realmbgn); + s.append(str); + s.append(Text.subString(realmend, Text.size() - realmend)); + Text = s; + CursorPos = realmbgn + len; + } else if (OverwriteMode) { + // check to see if we are at the end of the text + if ((u32)CursorPos + len < Text.size()) { + bool isEOL = false; + s32 EOLPos; + for (u32 i = CursorPos; i < CursorPos + len && i < Max; i++) { + if (Text[i] == L'\n' || Text[i] == L'\r') { + isEOL = true; + EOLPos = i; + break; + } + } + if (!isEOL || Text.size() + len <= Max || Max == 0) { + s = Text.subString(0, CursorPos); + s.append(str); + if (isEOL) { + // just keep appending to the current line + // This follows the behavior of other gui libraries behaviors + s.append(Text.subString(EOLPos, Text.size() - EOLPos)); + } else { + // replace the next character + s.append(Text.subString(CursorPos + len, Text.size() - CursorPos - len)); + } + Text = s; + CursorPos += len; + } + } else if (Text.size() + len <= Max || Max == 0) { + // add new character because we are at the end of the string + s = Text.subString(0, CursorPos); + s.append(str); + s.append(Text.subString(CursorPos + len, Text.size() - CursorPos - len)); + Text = s; + CursorPos += len; + } + } else if (Text.size() + len <= Max || Max == 0) { + // add new character + s = Text.subString(0, CursorPos); + s.append(str); + s.append(Text.subString(CursorPos, Text.size() - CursorPos)); + Text = s; + CursorPos += len; + } + + BlinkStartTime = os::Timer::getTime(); + setTextMarkers(0, 0); + + breakText(); + calculateScrollPos(); + sendGuiEvent(EGET_EDITBOX_CHANGED); +} + +// calculate autoscroll +void CGUIEditBox::calculateScrollPos() +{ + if (!AutoScroll) + return; + + IGUIFont *font = getActiveFont(); + if (!font) + return; + + s32 cursLine = getLineFromPos(CursorPos); + if (cursLine < 0) + return; + setTextRect(cursLine); + const bool hasBrokenText = MultiLine || WordWrap; + + // Check horizonal scrolling + // NOTE: Calculations different to vertical scrolling because setTextRect interprets VAlign relative to line but HAlign not relative to row + { + // get cursor position + // get cursor area + irr::u32 cursorWidth = font->getDimension(CursorChar.c_str()).Width; + core::stringw *txtLine = hasBrokenText ? &BrokenText[cursLine] : &Text; + s32 cPos = hasBrokenText ? CursorPos - BrokenTextPositions[cursLine] : CursorPos; // column + s32 cStart = font->getDimension(txtLine->subString(0, cPos).c_str()).Width; // pixels from text-start + s32 cEnd = cStart + cursorWidth; + s32 txtWidth = font->getDimension(txtLine->c_str()).Width; + + if (txtWidth < FrameRect.getWidth()) { + // TODO: Needs a clean left and right gap removal depending on HAlign, similar to vertical scrolling tests for top/bottom. + // This check just fixes the case where it was most noticable (text smaller than clipping area). + + HScrollPos = 0; + setTextRect(cursLine); + } + + if (CurrentTextRect.UpperLeftCorner.X + cStart < FrameRect.UpperLeftCorner.X) { + // cursor to the left of the clipping area + HScrollPos -= FrameRect.UpperLeftCorner.X - (CurrentTextRect.UpperLeftCorner.X + cStart); + setTextRect(cursLine); + + // TODO: should show more characters to the left when we're scrolling left + // and the cursor reaches the border. + } else if (CurrentTextRect.UpperLeftCorner.X + cEnd > FrameRect.LowerRightCorner.X) { + // cursor to the right of the clipping area + HScrollPos += (CurrentTextRect.UpperLeftCorner.X + cEnd) - FrameRect.LowerRightCorner.X; + setTextRect(cursLine); + } + } + + // calculate vertical scrolling + if (hasBrokenText) { + irr::u32 lineHeight = font->getDimension(L"A").Height + font->getKerningHeight(); + // only up to 1 line fits? + if (lineHeight >= (irr::u32)FrameRect.getHeight()) { + VScrollPos = 0; + setTextRect(cursLine); + s32 unscrolledPos = CurrentTextRect.UpperLeftCorner.Y; + s32 pivot = FrameRect.UpperLeftCorner.Y; + switch (VAlign) { + case EGUIA_CENTER: + pivot += FrameRect.getHeight() / 2; + unscrolledPos += lineHeight / 2; + break; + case EGUIA_LOWERRIGHT: + pivot += FrameRect.getHeight(); + unscrolledPos += lineHeight; + break; + default: + break; + } + VScrollPos = unscrolledPos - pivot; + setTextRect(cursLine); + } else { + // First 2 checks are necessary when people delete lines + setTextRect(0); + if (CurrentTextRect.UpperLeftCorner.Y > FrameRect.UpperLeftCorner.Y && VAlign != EGUIA_LOWERRIGHT) { + // first line is leaving a gap on top + VScrollPos = 0; + } else if (VAlign != EGUIA_UPPERLEFT) { + u32 lastLine = BrokenTextPositions.empty() ? 0 : BrokenTextPositions.size() - 1; + setTextRect(lastLine); + if (CurrentTextRect.LowerRightCorner.Y < FrameRect.LowerRightCorner.Y) { + // last line is leaving a gap on bottom + VScrollPos -= FrameRect.LowerRightCorner.Y - CurrentTextRect.LowerRightCorner.Y; + } + } + + setTextRect(cursLine); + if (CurrentTextRect.UpperLeftCorner.Y < FrameRect.UpperLeftCorner.Y) { + // text above valid area + VScrollPos -= FrameRect.UpperLeftCorner.Y - CurrentTextRect.UpperLeftCorner.Y; + setTextRect(cursLine); + } else if (CurrentTextRect.LowerRightCorner.Y > FrameRect.LowerRightCorner.Y) { + // text below valid area + VScrollPos += CurrentTextRect.LowerRightCorner.Y - FrameRect.LowerRightCorner.Y; + setTextRect(cursLine); + } + } + } +} + +void CGUIEditBox::calculateFrameRect() +{ + FrameRect = AbsoluteRect; + IGUISkin *skin = 0; + if (Environment) + skin = Environment->getSkin(); + if (Border && skin) { + FrameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X) + 1; + FrameRect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y) + 1; + FrameRect.LowerRightCorner.X -= skin->getSize(EGDS_TEXT_DISTANCE_X) + 1; + FrameRect.LowerRightCorner.Y -= skin->getSize(EGDS_TEXT_DISTANCE_Y) + 1; + } +} + +//! set text markers +void CGUIEditBox::setTextMarkers(s32 begin, s32 end) +{ + if (begin != MarkBegin || end != MarkEnd) { + MarkBegin = begin; + MarkEnd = end; + + if (!PasswordBox && Operator && MarkBegin != MarkEnd) { + // copy to primary selection + const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + + core::stringc s; + wStringToUTF8(s, Text.subString(realmbgn, realmend - realmbgn)); + Operator->copyToPrimarySelection(s.c_str()); + } + + sendGuiEvent(EGET_EDITBOX_MARKING_CHANGED); + } +} + +//! send some gui event to parent +void CGUIEditBox::sendGuiEvent(EGUI_EVENT_TYPE type) +{ + if (Parent) { + SEvent e; + e.EventType = EET_GUI_EVENT; + e.GUIEvent.Caller = this; + e.GUIEvent.Element = 0; + e.GUIEvent.EventType = type; + + Parent->OnEvent(e); + } +} + +//! Returns whether the element takes input from the IME +bool CGUIEditBox::acceptsIME() +{ + return isEnabled(); +} + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIEditBox.h b/irr/src/CGUIEditBox.h new file mode 100644 index 000000000..35ab5f73e --- /dev/null +++ b/irr/src/CGUIEditBox.h @@ -0,0 +1,196 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIEditBox.h" +#include "irrArray.h" +#include "IOSOperator.h" + +namespace irr +{ +namespace gui +{ +class CGUIEditBox : public IGUIEditBox +{ +public: + //! constructor + CGUIEditBox(const wchar_t *text, bool border, IGUIEnvironment *environment, + IGUIElement *parent, s32 id, const core::rect &rectangle); + + //! destructor + virtual ~CGUIEditBox(); + + //! Sets another skin independent font. + void setOverrideFont(IGUIFont *font = 0) override; + + //! Gets the override font (if any) + /** \return The override font (may be 0) */ + IGUIFont *getOverrideFont() const override; + + //! Get the font which is used right now for drawing + /** Currently this is the override font when one is set and the + font of the active skin otherwise */ + IGUIFont *getActiveFont() const override; + + //! Sets another color for the text. + void setOverrideColor(video::SColor color) override; + + //! Gets the override color + video::SColor getOverrideColor() const override; + + //! Sets if the text should use the override color or the + //! color in the gui skin. + void enableOverrideColor(bool enable) override; + + //! Checks if an override color is enabled + /** \return true if the override color is enabled, false otherwise */ + bool isOverrideColorEnabled(void) const override; + + //! Sets whether to draw the background + void setDrawBackground(bool draw) override; + + //! Checks if background drawing is enabled + bool isDrawBackgroundEnabled() const override; + + //! Turns the border on or off + void setDrawBorder(bool border) override; + + //! Checks if border drawing is enabled + bool isDrawBorderEnabled() const override; + + //! Enables or disables word wrap for using the edit box as multiline text editor. + void setWordWrap(bool enable) override; + + //! Checks if word wrap is enabled + //! \return true if word wrap is enabled, false otherwise + bool isWordWrapEnabled() const override; + + //! Enables or disables newlines. + /** \param enable: If set to true, the EGET_EDITBOX_ENTER event will not be fired, + instead a newline character will be inserted. */ + void setMultiLine(bool enable) override; + + //! Checks if multi line editing is enabled + //! \return true if mult-line is enabled, false otherwise + bool isMultiLineEnabled() const override; + + //! Enables or disables automatic scrolling with cursor position + //! \param enable: If set to true, the text will move around with the cursor position + void setAutoScroll(bool enable) override; + + //! Checks to see if automatic scrolling is enabled + //! \return true if automatic scrolling is enabled, false if not + bool isAutoScrollEnabled() const override; + + //! Gets the size area of the text in the edit box + //! \return Returns the size in pixels of the text + core::dimension2du getTextDimension() override; + + //! Sets text justification + void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) override; + + //! called if an event happened. + bool OnEvent(const SEvent &event) override; + + //! draws the element and its children + void draw() override; + + //! Sets the new caption of this element. + void setText(const wchar_t *text) override; + + //! Sets the maximum amount of characters which may be entered in the box. + //! \param max: Maximum amount of characters. If 0, the character amount is + //! infinity. + void setMax(u32 max) override; + + //! Returns maximum amount of characters, previously set by setMax(); + u32 getMax() const override; + + //! Set the character used for the cursor. + /** By default it's "_" */ + void setCursorChar(const wchar_t cursorChar) override; + + //! Get the character used for the cursor. + wchar_t getCursorChar() const override; + + //! Set the blinktime for the cursor. 2x blinktime is one full cycle. + //** \param timeMs Blinktime in milliseconds. When set to 0 the cursor is constantly on without blinking */ + void setCursorBlinkTime(irr::u32 timeMs) override; + + //! Get the cursor blinktime + irr::u32 getCursorBlinkTime() const override; + + //! Sets whether the edit box is a password box. Setting this to true will + /** disable MultiLine, WordWrap and the ability to copy with ctrl+c or ctrl+x + \param passwordBox: true to enable password, false to disable + \param passwordChar: the character that is displayed instead of letters */ + void setPasswordBox(bool passwordBox, wchar_t passwordChar = L'*') override; + + //! Returns true if the edit box is currently a password box. + bool isPasswordBox() const override; + + //! Updates the absolute position, splits text if required + void updateAbsolutePosition() override; + + //! Returns whether the element takes input from the IME + bool acceptsIME() override; + +protected: + //! Breaks the single text line. + void breakText(); + //! sets the area of the given line + void setTextRect(s32 line); + //! returns the line number that the cursor is on + s32 getLineFromPos(s32 pos); + //! adds a letter to the edit box + void inputChar(wchar_t c); + //! adds a string to the edit box + void inputString(const core::stringw &str); + //! calculates the current scroll position + void calculateScrollPos(); + //! calculated the FrameRect + void calculateFrameRect(); + //! send some gui event to parent + void sendGuiEvent(EGUI_EVENT_TYPE type); + //! set text markers + void setTextMarkers(s32 begin, s32 end); + //! delete current selection or next char + bool keyDelete(); + + bool processKey(const SEvent &event); + bool processMouse(const SEvent &event); + s32 getCursorPos(s32 x, s32 y); + + bool OverwriteMode; + bool MouseMarking; + bool Border; + bool Background; + bool OverrideColorEnabled; + s32 MarkBegin; + s32 MarkEnd; + + video::SColor OverrideColor; + gui::IGUIFont *OverrideFont, *LastBreakFont; + IOSOperator *Operator; + + u32 BlinkStartTime; + irr::u32 CursorBlinkTime; + core::stringw CursorChar; // IGUIFont::draw needs stringw instead of wchar_t + s32 CursorPos; + s32 HScrollPos, VScrollPos; // scroll position in characters + u32 Max; + + bool WordWrap, MultiLine, AutoScroll, PasswordBox; + wchar_t PasswordChar; + EGUI_ALIGNMENT HAlign, VAlign; + + core::array BrokenText; + core::array BrokenTextPositions; + + core::rect CurrentTextRect, FrameRect; // temporary values +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIEnvironment.cpp b/irr/src/CGUIEnvironment.cpp new file mode 100644 index 000000000..80115ab11 --- /dev/null +++ b/irr/src/CGUIEnvironment.cpp @@ -0,0 +1,999 @@ + +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIEnvironment.h" + +#include "IVideoDriver.h" + +#include "CGUISkin.h" +#include "CGUIButton.h" +#include "CGUIScrollBar.h" +#include "CGUIFont.h" +#include "CGUISpriteBank.h" +#include "CGUIImage.h" +#include "CGUICheckBox.h" +#include "CGUIListBox.h" +#include "CGUIImageList.h" +#include "CGUIFileOpenDialog.h" +#include "CGUIStaticText.h" +#include "CGUIEditBox.h" +#include "CGUITabControl.h" +#include "CGUIComboBox.h" + +#include "IWriteFile.h" +#ifdef IRR_ENABLE_BUILTIN_FONT +#include "BuiltInFont.h" +#endif +#include "os.h" + +namespace irr +{ +namespace gui +{ + +const io::path CGUIEnvironment::DefaultFontName = "#DefaultFont"; + +//! constructor +CGUIEnvironment::CGUIEnvironment(io::IFileSystem *fs, video::IVideoDriver *driver, IOSOperator *op) : + IGUIElement(EGUIET_ROOT, 0, 0, 0, core::rect(driver ? core::dimension2d(driver->getScreenSize()) : core::dimension2d(0, 0))), + Driver(driver), Hovered(0), HoveredNoSubelement(0), Focus(0), LastHoveredMousePos(0, 0), CurrentSkin(0), + FileSystem(fs), UserReceiver(0), Operator(op), FocusFlags(EFF_SET_ON_LMOUSE_DOWN | EFF_SET_ON_TAB) +{ + if (Driver) + Driver->grab(); + + if (FileSystem) + FileSystem->grab(); + + if (Operator) + Operator->grab(); + +#ifdef _DEBUG + IGUIEnvironment::setDebugName("CGUIEnvironment"); +#endif + + loadBuiltInFont(); + + IGUISkin *skin = createSkin(gui::EGST_WINDOWS_METALLIC); + setSkin(skin); + skin->drop(); + + // set tooltip default + ToolTip.LastTime = 0; + ToolTip.EnterTime = 0; + ToolTip.LaunchTime = 1000; + ToolTip.RelaunchTime = 500; + ToolTip.Element = 0; + + // environment is root tab group + Environment = this; + setTabGroup(true); +} + +//! destructor +CGUIEnvironment::~CGUIEnvironment() +{ + clearDeletionQueue(); + + if (HoveredNoSubelement && HoveredNoSubelement != this) { + HoveredNoSubelement->drop(); + HoveredNoSubelement = 0; + } + + if (Hovered && Hovered != this) { + Hovered->drop(); + Hovered = 0; + } + + if (Focus) { + Focus->drop(); + Focus = 0; + } + + if (ToolTip.Element) { + ToolTip.Element->drop(); + ToolTip.Element = 0; + } + + // drop skin + if (CurrentSkin) { + CurrentSkin->drop(); + CurrentSkin = 0; + } + + u32 i; + + // delete all sprite banks + for (i = 0; i < Banks.size(); ++i) + if (Banks[i].Bank) + Banks[i].Bank->drop(); + + // delete all fonts + for (i = 0; i < Fonts.size(); ++i) + Fonts[i].Font->drop(); + + if (Operator) { + Operator->drop(); + Operator = 0; + } + + if (FileSystem) { + FileSystem->drop(); + FileSystem = 0; + } + + if (Driver) { + Driver->drop(); + Driver = 0; + } +} + +void CGUIEnvironment::loadBuiltInFont() +{ +#ifdef IRR_ENABLE_BUILTIN_FONT + io::IReadFile *file = FileSystem->createMemoryReadFile(BuiltInFontData, + BuiltInFontDataSize, DefaultFontName, false); + + CGUIFont *font = new CGUIFont(this, DefaultFontName); + if (!font->load(file)) { + os::Printer::log("Error: Could not load built-in Font.", ELL_ERROR); + font->drop(); + file->drop(); + return; + } + + SFont f; + f.NamedPath.setPath(DefaultFontName); + f.Font = font; + Fonts.push_back(f); + + file->drop(); +#endif +} + +//! draws all gui elements +void CGUIEnvironment::drawAll(bool useScreenSize) +{ + if (useScreenSize && Driver) { + core::dimension2d dim(Driver->getScreenSize()); + if (AbsoluteRect.LowerRightCorner.X != dim.Width || + AbsoluteRect.UpperLeftCorner.X != 0 || + AbsoluteRect.LowerRightCorner.Y != dim.Height || + AbsoluteRect.UpperLeftCorner.Y != 0) { + setRelativePosition(core::recti(0, 0, dim.Width, dim.Height)); + } + } + + // make sure tooltip is always on top + if (ToolTip.Element) + bringToFront(ToolTip.Element); + + draw(); + OnPostRender(os::Timer::getTime()); + + clearDeletionQueue(); +} + +//! sets the focus to an element +bool CGUIEnvironment::setFocus(IGUIElement *element) +{ + if (Focus == element) { + return false; + } + + // GUI Environment should just reset the focus to 0 + if (element == this) + element = 0; + + // stop element from being deleted + if (element) + element->grab(); + + // focus may change or be removed in this call + IGUIElement *currentFocus = 0; + if (Focus) { + currentFocus = Focus; + currentFocus->grab(); + SEvent e; + e.EventType = EET_GUI_EVENT; + e.GUIEvent.Caller = Focus; + e.GUIEvent.Element = element; + e.GUIEvent.EventType = EGET_ELEMENT_FOCUS_LOST; + if (Focus->OnEvent(e)) { + if (element) + element->drop(); + currentFocus->drop(); + return false; + } + currentFocus->drop(); + currentFocus = 0; + } + + if (element) { + currentFocus = Focus; + if (currentFocus) + currentFocus->grab(); + + // send focused event + SEvent e; + e.EventType = EET_GUI_EVENT; + e.GUIEvent.Caller = element; + e.GUIEvent.Element = Focus; + e.GUIEvent.EventType = EGET_ELEMENT_FOCUSED; + if (element->OnEvent(e)) { + if (element) + element->drop(); + if (currentFocus) + currentFocus->drop(); + return false; + } + } + + if (currentFocus) + currentFocus->drop(); + + if (Focus) + Focus->drop(); + + // element is the new focus so it doesn't have to be dropped + Focus = element; + + return true; +} + +//! returns the element with the focus +IGUIElement *CGUIEnvironment::getFocus() const +{ + return Focus; +} + +//! returns the element last known to be under the mouse cursor +IGUIElement *CGUIEnvironment::getHovered() const +{ + return Hovered; +} + +//! removes the focus from an element +bool CGUIEnvironment::removeFocus(IGUIElement *element) +{ + if (Focus && Focus == element) { + SEvent e; + e.EventType = EET_GUI_EVENT; + e.GUIEvent.Caller = Focus; + e.GUIEvent.Element = 0; + e.GUIEvent.EventType = EGET_ELEMENT_FOCUS_LOST; + if (Focus->OnEvent(e)) { + return false; + } + } + if (Focus) { + Focus->drop(); + Focus = 0; + } + + return true; +} + +//! Returns whether the element has focus +bool CGUIEnvironment::hasFocus(const IGUIElement *element, bool checkSubElements) const +{ + if (element == Focus) + return true; + + if (!checkSubElements || !element) + return false; + + IGUIElement *f = Focus; + while (f && f->isSubElement()) { + f = f->getParent(); + if (f == element) + return true; + } + return false; +} + +//! returns the current video driver +video::IVideoDriver *CGUIEnvironment::getVideoDriver() const +{ + return Driver; +} + +//! returns the current file system +io::IFileSystem *CGUIEnvironment::getFileSystem() const +{ + return FileSystem; +} + +//! returns a pointer to the OS operator +IOSOperator *CGUIEnvironment::getOSOperator() const +{ + return Operator; +} + +//! clear all GUI elements +void CGUIEnvironment::clear() +{ + // Remove the focus + if (Focus) { + Focus->drop(); + Focus = 0; + } + + if (Hovered && Hovered != this) { + Hovered->drop(); + Hovered = 0; + } + if (HoveredNoSubelement && HoveredNoSubelement != this) { + HoveredNoSubelement->drop(); + HoveredNoSubelement = 0; + } + + getRootGUIElement()->removeAllChildren(); +} + +//! called by ui if an event happened. +bool CGUIEnvironment::OnEvent(const SEvent &event) +{ + + bool ret = false; + if (UserReceiver && (event.EventType != EET_MOUSE_INPUT_EVENT) && (event.EventType != EET_KEY_INPUT_EVENT) && (event.EventType != EET_GUI_EVENT || event.GUIEvent.Caller != this)) { + ret = UserReceiver->OnEvent(event); + } + + return ret; +} + +// +void CGUIEnvironment::OnPostRender(u32 time) +{ + // launch tooltip + if (ToolTip.Element == 0 && + HoveredNoSubelement && HoveredNoSubelement != this && + (time - ToolTip.EnterTime >= ToolTip.LaunchTime || (time - ToolTip.LastTime >= ToolTip.RelaunchTime && time - ToolTip.LastTime < ToolTip.LaunchTime)) && + HoveredNoSubelement->getToolTipText().size() && + getSkin() && + getSkin()->getFont(EGDF_TOOLTIP)) { + core::rect pos; + + pos.UpperLeftCorner = LastHoveredMousePos; + core::dimension2du dim = getSkin()->getFont(EGDF_TOOLTIP)->getDimension(HoveredNoSubelement->getToolTipText().c_str()); + dim.Width += getSkin()->getSize(EGDS_TEXT_DISTANCE_X) * 2; + dim.Height += getSkin()->getSize(EGDS_TEXT_DISTANCE_Y) * 2; + + pos.UpperLeftCorner.Y -= dim.Height + 1; + pos.LowerRightCorner.Y = pos.UpperLeftCorner.Y + dim.Height - 1; + pos.LowerRightCorner.X = pos.UpperLeftCorner.X + dim.Width; + + pos.constrainTo(getAbsolutePosition()); + + ToolTip.Element = addStaticText(HoveredNoSubelement->getToolTipText().c_str(), pos, true, true, this, -1, true); + ToolTip.Element->setOverrideColor(getSkin()->getColor(EGDC_TOOLTIP)); + ToolTip.Element->setBackgroundColor(getSkin()->getColor(EGDC_TOOLTIP_BACKGROUND)); + ToolTip.Element->setOverrideFont(getSkin()->getFont(EGDF_TOOLTIP)); + ToolTip.Element->setSubElement(true); + ToolTip.Element->grab(); + + s32 textHeight = ToolTip.Element->getTextHeight(); + pos = ToolTip.Element->getRelativePosition(); + pos.LowerRightCorner.Y = pos.UpperLeftCorner.Y + textHeight; + ToolTip.Element->setRelativePosition(pos); + } + + if (ToolTip.Element && ToolTip.Element->isVisible()) { // (isVisible() check only because we might use visibility for ToolTip one day) + ToolTip.LastTime = time; + + // got invisible or removed in the meantime? + if (!HoveredNoSubelement || + !HoveredNoSubelement->isVisible() || + !HoveredNoSubelement->getParent()) // got invisible or removed in the meantime? + { + ToolTip.Element->remove(); + ToolTip.Element->drop(); + ToolTip.Element = 0; + } + } + + IGUIElement::OnPostRender(time); +} + +void CGUIEnvironment::addToDeletionQueue(IGUIElement *element) +{ + if (!element) + return; + + element->grab(); + DeletionQueue.push_back(element); +} + +void CGUIEnvironment::clearDeletionQueue() +{ + if (DeletionQueue.empty()) + return; + + for (u32 i = 0; i < DeletionQueue.size(); ++i) { + DeletionQueue[i]->remove(); + DeletionQueue[i]->drop(); + } + + DeletionQueue.clear(); +} + +// +void CGUIEnvironment::updateHoveredElement(core::position2d mousePos) +{ + IGUIElement *lastHovered = Hovered; + IGUIElement *lastHoveredNoSubelement = HoveredNoSubelement; + LastHoveredMousePos = mousePos; + + Hovered = getElementFromPoint(mousePos); + + if (ToolTip.Element && Hovered == ToolTip.Element) { + // When the mouse is over the ToolTip we remove that so it will be re-created at a new position. + // Note that ToolTip.EnterTime does not get changed here, so it will be re-created at once. + ToolTip.Element->remove(); + ToolTip.Element->drop(); + ToolTip.Element = 0; + + // Get the real Hovered + Hovered = getElementFromPoint(mousePos); + } + + // for tooltips we want the element itself and not some of it's subelements + HoveredNoSubelement = Hovered; + while (HoveredNoSubelement && HoveredNoSubelement->isSubElement()) { + HoveredNoSubelement = HoveredNoSubelement->getParent(); + } + + if (Hovered && Hovered != this) + Hovered->grab(); + if (HoveredNoSubelement && HoveredNoSubelement != this) + HoveredNoSubelement->grab(); + + if (Hovered != lastHovered) { + SEvent event; + event.EventType = EET_GUI_EVENT; + + if (lastHovered) { + event.GUIEvent.Caller = lastHovered; + event.GUIEvent.Element = 0; + event.GUIEvent.EventType = EGET_ELEMENT_LEFT; + lastHovered->OnEvent(event); + } + + if (Hovered) { + event.GUIEvent.Caller = Hovered; + event.GUIEvent.Element = Hovered; + event.GUIEvent.EventType = EGET_ELEMENT_HOVERED; + Hovered->OnEvent(event); + } + } + + if (lastHoveredNoSubelement != HoveredNoSubelement) { + if (ToolTip.Element) { + ToolTip.Element->remove(); + ToolTip.Element->drop(); + ToolTip.Element = 0; + } + + if (HoveredNoSubelement) { + u32 now = os::Timer::getTime(); + ToolTip.EnterTime = now; + } + } + + if (lastHovered && lastHovered != this) + lastHovered->drop(); + if (lastHoveredNoSubelement && lastHoveredNoSubelement != this) + lastHoveredNoSubelement->drop(); +} + +//! This sets a new event receiver for gui events. Usually you do not have to +//! use this method, it is used by the internal engine. +void CGUIEnvironment::setUserEventReceiver(IEventReceiver *evr) +{ + UserReceiver = evr; +} + +//! posts an input event to the environment +bool CGUIEnvironment::postEventFromUser(const SEvent &event) +{ + switch (event.EventType) { + case EET_GUI_EVENT: { + // hey, why is the user sending gui events..? + } + + break; + case EET_MOUSE_INPUT_EVENT: + + updateHoveredElement(core::position2d(event.MouseInput.X, event.MouseInput.Y)); + + if (Hovered != Focus) { + IGUIElement *focusCandidate = Hovered; + + // Only allow enabled elements to be focused (unless EFF_CAN_FOCUS_DISABLED is set) + if (Hovered && !Hovered->isEnabled() && !(FocusFlags & EFF_CAN_FOCUS_DISABLED)) + focusCandidate = NULL; // we still remove focus from the active element + + // Please don't merge this into a single if clause, it's easier to debug the way it is + if (FocusFlags & EFF_SET_ON_LMOUSE_DOWN && + event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) { + setFocus(focusCandidate); + } else if (FocusFlags & EFF_SET_ON_RMOUSE_DOWN && + event.MouseInput.Event == EMIE_RMOUSE_PRESSED_DOWN) { + setFocus(focusCandidate); + } else if (FocusFlags & EFF_SET_ON_MOUSE_OVER && + event.MouseInput.Event == EMIE_MOUSE_MOVED) { + setFocus(focusCandidate); + } + } + + // sending input to focus + if (Focus && Focus->OnEvent(event)) + return true; + + // focus could have died in last call + if (!Focus && Hovered) { + return Hovered->OnEvent(event); + } + + break; + case EET_KEY_INPUT_EVENT: { + if (Focus && Focus->OnEvent(event)) + return true; + + // For keys we handle the event before changing focus to give elements the chance for catching the TAB + // Send focus changing event + // CAREFUL when changing - there's an identical check in CGUIModalScreen::OnEvent + if (FocusFlags & EFF_SET_ON_TAB && + event.KeyInput.PressedDown && + event.KeyInput.Key == KEY_TAB) { + IGUIElement *next = getNextElement(event.KeyInput.Shift, event.KeyInput.Control); + if (next && next != Focus) { + if (setFocus(next)) + return true; + } + } + } break; + case EET_STRING_INPUT_EVENT: + if (Focus && Focus->OnEvent(event)) + return true; + break; + default: + break; + } // end switch + + return false; +} + +//! returns the current gui skin +IGUISkin *CGUIEnvironment::getSkin() const +{ + return CurrentSkin; +} + +//! Sets a new GUI Skin +void CGUIEnvironment::setSkin(IGUISkin *skin) +{ + if (CurrentSkin == skin) + return; + + if (CurrentSkin) + CurrentSkin->drop(); + + CurrentSkin = skin; + + if (CurrentSkin) + CurrentSkin->grab(); +} + +//! Creates a new GUI Skin based on a template. +/** \return Returns a pointer to the created skin. +If you no longer need the skin, you should call IGUISkin::drop(). +See IReferenceCounted::drop() for more information. */ +IGUISkin *CGUIEnvironment::createSkin(EGUI_SKIN_TYPE type) +{ + IGUISkin *skin = new CGUISkin(type, Driver); + + IGUIFont *builtinfont = getBuiltInFont(); + IGUIFontBitmap *bitfont = 0; + if (builtinfont && builtinfont->getType() == EGFT_BITMAP) + bitfont = (IGUIFontBitmap *)builtinfont; + + IGUISpriteBank *bank = 0; + skin->setFont(builtinfont); + + if (bitfont) + bank = bitfont->getSpriteBank(); + + skin->setSpriteBank(bank); + + return skin; +} + +//! adds a button. The returned pointer must not be dropped. +IGUIButton *CGUIEnvironment::addButton(const core::rect &rectangle, IGUIElement *parent, s32 id, const wchar_t *text, const wchar_t *tooltiptext) +{ + IGUIButton *button = new CGUIButton(this, parent ? parent : this, id, rectangle); + if (text) + button->setText(text); + + if (tooltiptext) + button->setToolTipText(tooltiptext); + + button->drop(); + return button; +} + +//! adds a scrollbar. The returned pointer must not be dropped. +IGUIScrollBar *CGUIEnvironment::addScrollBar(bool horizontal, const core::rect &rectangle, IGUIElement *parent, s32 id) +{ + IGUIScrollBar *bar = new CGUIScrollBar(horizontal, this, parent ? parent : this, id, rectangle); + bar->drop(); + return bar; +} + +//! Adds an image element. +IGUIImage *CGUIEnvironment::addImage(video::ITexture *image, core::position2d pos, + bool useAlphaChannel, IGUIElement *parent, s32 id, const wchar_t *text) +{ + core::dimension2d sz(0, 0); + if (image) + sz = core::dimension2d(image->getOriginalSize()); + + IGUIImage *img = new CGUIImage(this, parent ? parent : this, + id, core::rect(pos, sz)); + + if (text) + img->setText(text); + + if (useAlphaChannel) + img->setUseAlphaChannel(true); + + if (image) + img->setImage(image); + + img->drop(); + return img; +} + +//! adds an image. The returned pointer must not be dropped. +IGUIImage *CGUIEnvironment::addImage(const core::rect &rectangle, IGUIElement *parent, s32 id, const wchar_t *text, bool useAlphaChannel) +{ + IGUIImage *img = new CGUIImage(this, parent ? parent : this, + id, rectangle); + + if (text) + img->setText(text); + + if (useAlphaChannel) + img->setUseAlphaChannel(true); + + img->drop(); + return img; +} + +//! adds a checkbox +IGUICheckBox *CGUIEnvironment::addCheckBox(bool checked, const core::rect &rectangle, IGUIElement *parent, s32 id, const wchar_t *text) +{ + IGUICheckBox *b = new CGUICheckBox(checked, this, + parent ? parent : this, id, rectangle); + + if (text) + b->setText(text); + + b->drop(); + return b; +} + +//! adds a list box +IGUIListBox *CGUIEnvironment::addListBox(const core::rect &rectangle, + IGUIElement *parent, s32 id, bool drawBackground) +{ + IGUIListBox *b = new CGUIListBox(this, parent ? parent : this, id, rectangle, + true, drawBackground, false); + + if (CurrentSkin && CurrentSkin->getSpriteBank()) { + b->setSpriteBank(CurrentSkin->getSpriteBank()); + } else if (getBuiltInFont() && getBuiltInFont()->getType() == EGFT_BITMAP) { + b->setSpriteBank(((IGUIFontBitmap *)getBuiltInFont())->getSpriteBank()); + } + + b->drop(); + return b; +} + +//! adds a file open dialog. The returned pointer must not be dropped. +IGUIFileOpenDialog *CGUIEnvironment::addFileOpenDialog(const wchar_t *title, + bool modal, IGUIElement *parent, s32 id, + bool restoreCWD, io::path::char_type *startDir) +{ + parent = parent ? parent : this; + + if (modal) + return nullptr; + + IGUIFileOpenDialog *d = new CGUIFileOpenDialog(title, this, parent, id, + restoreCWD, startDir); + d->drop(); + + return d; +} + +//! adds a static text. The returned pointer must not be dropped. +IGUIStaticText *CGUIEnvironment::addStaticText(const wchar_t *text, + const core::rect &rectangle, + bool border, bool wordWrap, + IGUIElement *parent, s32 id, bool background) +{ + IGUIStaticText *d = new CGUIStaticText(text, border, this, + parent ? parent : this, id, rectangle, background); + + d->setWordWrap(wordWrap); + d->drop(); + + return d; +} + +//! Adds an edit box. The returned pointer must not be dropped. +IGUIEditBox *CGUIEnvironment::addEditBox(const wchar_t *text, + const core::rect &rectangle, bool border, + IGUIElement *parent, s32 id) +{ + IGUIEditBox *d = new CGUIEditBox(text, border, this, + parent ? parent : this, id, rectangle); + + d->drop(); + return d; +} + +//! Adds a tab control to the environment. +IGUITabControl *CGUIEnvironment::addTabControl(const core::rect &rectangle, + IGUIElement *parent, bool fillbackground, bool border, s32 id) +{ + IGUITabControl *t = new CGUITabControl(this, parent ? parent : this, + rectangle, fillbackground, border, id); + t->drop(); + return t; +} + +//! Adds tab to the environment. +IGUITab *CGUIEnvironment::addTab(const core::rect &rectangle, + IGUIElement *parent, s32 id) +{ + IGUITab *t = new CGUITab(this, parent ? parent : this, + rectangle, id); + t->drop(); + return t; +} + +//! Adds a combo box to the environment. +IGUIComboBox *CGUIEnvironment::addComboBox(const core::rect &rectangle, + IGUIElement *parent, s32 id) +{ + IGUIComboBox *t = new CGUIComboBox(this, parent ? parent : this, + id, rectangle); + t->drop(); + return t; +} + +//! returns the font +IGUIFont *CGUIEnvironment::getFont(const io::path &filename) +{ + // search existing font + + SFont f; + f.NamedPath.setPath(filename); + + s32 index = Fonts.binary_search(f); + if (index != -1) + return Fonts[index].Font; + + // font doesn't exist, attempt to load it + + // does the file exist? + + if (!FileSystem->existFile(filename)) { + os::Printer::log("Could not load font because the file does not exist", f.NamedPath.getPath(), ELL_ERROR); + return 0; + } + + IGUIFont *ifont = 0; +#if 0 + { + CGUIFont* font = new CGUIFont(this, filename); + ifont = (IGUIFont*)font; + + // load the font + io::path directory; + core::splitFilename(filename, &directory); + if (!font->load(xml, directory)) + { + font->drop(); + font = 0; + ifont = 0; + } + } +#endif + + if (!ifont) { + + CGUIFont *font = new CGUIFont(this, f.NamedPath.getPath()); + ifont = (IGUIFont *)font; + if (!font->load(f.NamedPath.getPath())) { + font->drop(); + return 0; + } + } + + // add to fonts. + + f.Font = ifont; + Fonts.push_back(f); + + return ifont; +} + +//! add an externally loaded font +IGUIFont *CGUIEnvironment::addFont(const io::path &name, IGUIFont *font) +{ + if (font) { + SFont f; + f.NamedPath.setPath(name); + s32 index = Fonts.binary_search(f); + if (index != -1) + return Fonts[index].Font; + f.Font = font; + Fonts.push_back(f); + font->grab(); + } + return font; +} + +//! remove loaded font +void CGUIEnvironment::removeFont(IGUIFont *font) +{ + if (!font) + return; + for (u32 i = 0; i < Fonts.size(); ++i) { + if (Fonts[i].Font == font) { + Fonts[i].Font->drop(); + Fonts.erase(i); + return; + } + } +} + +//! returns default font +IGUIFont *CGUIEnvironment::getBuiltInFont() const +{ + if (Fonts.empty()) + return 0; + + return Fonts[0].Font; +} + +IGUISpriteBank *CGUIEnvironment::getSpriteBank(const io::path &filename) +{ + // search for the file name + + SSpriteBank b; + b.NamedPath.setPath(filename); + + s32 index = Banks.binary_search(b); + if (index != -1) + return Banks[index].Bank; + + // we don't have this sprite bank, we should load it + if (!FileSystem->existFile(b.NamedPath.getPath())) { + if (filename != DefaultFontName) { + os::Printer::log("Could not load sprite bank because the file does not exist", b.NamedPath.getPath(), ELL_DEBUG); + } + return 0; + } + + // todo: load it! + + return 0; +} + +IGUISpriteBank *CGUIEnvironment::addEmptySpriteBank(const io::path &name) +{ + // no duplicate names allowed + + SSpriteBank b; + b.NamedPath.setPath(name); + + const s32 index = Banks.binary_search(b); + if (index != -1) + return 0; + + // create a new sprite bank + + b.Bank = new CGUISpriteBank(this); + Banks.push_back(b); + + return b.Bank; +} + +//! Creates the image list from the given texture. +IGUIImageList *CGUIEnvironment::createImageList(video::ITexture *texture, + core::dimension2d imageSize, bool useAlphaChannel) +{ + CGUIImageList *imageList = new CGUIImageList(Driver); + if (!imageList->createImageList(texture, imageSize, useAlphaChannel)) { + imageList->drop(); + return 0; + } + + return imageList; +} + +//! Returns the root gui element. +IGUIElement *CGUIEnvironment::getRootGUIElement() +{ + return this; +} + +//! Returns the next element in the tab group starting at the focused element +IGUIElement *CGUIEnvironment::getNextElement(bool reverse, bool group) +{ + // start the search at the root of the current tab group + IGUIElement *startPos = Focus ? Focus->getTabGroup() : 0; + s32 startOrder = -1; + + // if we're searching for a group + if (group && startPos) { + startOrder = startPos->getTabOrder(); + } else if (!group && Focus && !Focus->isTabGroup()) { + startOrder = Focus->getTabOrder(); + if (startOrder == -1) { + // this element is not part of the tab cycle, + // but its parent might be... + IGUIElement *el = Focus; + while (el && el->getParent() && startOrder == -1) { + el = el->getParent(); + startOrder = el->getTabOrder(); + } + } + } + + if (group || !startPos) + startPos = this; // start at the root + + // find the element + IGUIElement *closest = 0; + IGUIElement *first = 0; + startPos->getNextElement(startOrder, reverse, group, first, closest, false, (FocusFlags & EFF_CAN_FOCUS_DISABLED) != 0); + + if (closest) + return closest; // we found an element + else if (first) + return first; // go to the end or the start + else if (group) + return this; // no group found? root group + else + return 0; +} + +void CGUIEnvironment::setFocusBehavior(u32 flags) +{ + FocusFlags = flags; +} + +u32 CGUIEnvironment::getFocusBehavior() const +{ + return FocusFlags; +} + +//! creates an GUI Environment +IGUIEnvironment *createGUIEnvironment(io::IFileSystem *fs, + video::IVideoDriver *Driver, + IOSOperator *op) +{ + return new CGUIEnvironment(fs, Driver, op); +} + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIEnvironment.h b/irr/src/CGUIEnvironment.h new file mode 100644 index 000000000..b03c6f0d3 --- /dev/null +++ b/irr/src/CGUIEnvironment.h @@ -0,0 +1,226 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIEnvironment.h" +#include "IGUIElement.h" +#include "irrArray.h" +#include "IFileSystem.h" +#include "IOSOperator.h" + +namespace irr +{ + +namespace gui +{ + +class CGUIEnvironment : public IGUIEnvironment, public IGUIElement +{ +public: + //! constructor + CGUIEnvironment(io::IFileSystem *fs, video::IVideoDriver *driver, IOSOperator *op); + + //! destructor + virtual ~CGUIEnvironment(); + + //! draws all gui elements + void drawAll(bool useScreenSize) override; + + //! returns the current video driver + video::IVideoDriver *getVideoDriver() const override; + + //! returns pointer to the filesystem + io::IFileSystem *getFileSystem() const override; + + //! returns a pointer to the OS operator + IOSOperator *getOSOperator() const override; + + //! posts an input event to the environment + bool postEventFromUser(const SEvent &event) override; + + //! This sets a new event receiver for gui events. Usually you do not have to + //! use this method, it is used by the internal engine. + void setUserEventReceiver(IEventReceiver *evr) override; + + //! removes all elements from the environment + void clear() override; + + //! called if an event happened. + bool OnEvent(const SEvent &event) override; + + //! returns the current gui skin + IGUISkin *getSkin() const override; + + //! Sets a new GUI Skin + void setSkin(IGUISkin *skin) override; + + //! Creates a new GUI Skin based on a template. + /** \return Returns a pointer to the created skin. + If you no longer need the skin, you should call IGUISkin::drop(). + See IReferenceCounted::drop() for more information. */ + IGUISkin *createSkin(EGUI_SKIN_TYPE type) override; + + //! Creates the image list from the given texture. + virtual IGUIImageList *createImageList(video::ITexture *texture, + core::dimension2d imageSize, bool useAlphaChannel) override; + + //! returns the font + IGUIFont *getFont(const io::path &filename) override; + + //! add an externally loaded font + IGUIFont *addFont(const io::path &name, IGUIFont *font) override; + + //! remove loaded font + void removeFont(IGUIFont *font) override; + + //! returns default font + IGUIFont *getBuiltInFont() const override; + + //! returns the sprite bank + IGUISpriteBank *getSpriteBank(const io::path &filename) override; + + //! returns the sprite bank + IGUISpriteBank *addEmptySpriteBank(const io::path &name) override; + + //! adds an button. The returned pointer must not be dropped. + IGUIButton *addButton(const core::rect &rectangle, IGUIElement *parent = 0, s32 id = -1, const wchar_t *text = 0, const wchar_t *tooltiptext = 0) override; + + //! adds a scrollbar. The returned pointer must not be dropped. + virtual IGUIScrollBar *addScrollBar(bool horizontal, const core::rect &rectangle, + IGUIElement *parent = 0, s32 id = -1) override; + + //! Adds an image element. + virtual IGUIImage *addImage(video::ITexture *image, core::position2d pos, + bool useAlphaChannel = true, IGUIElement *parent = 0, s32 id = -1, const wchar_t *text = 0) override; + + //! adds an image. The returned pointer must not be dropped. + virtual IGUIImage *addImage(const core::rect &rectangle, + IGUIElement *parent = 0, s32 id = -1, const wchar_t *text = 0, bool useAlphaChannel = true) override; + + //! adds a checkbox + virtual IGUICheckBox *addCheckBox(bool checked, const core::rect &rectangle, + IGUIElement *parent = 0, s32 id = -1, const wchar_t *text = 0) override; + + //! adds a list box + virtual IGUIListBox *addListBox(const core::rect &rectangle, + IGUIElement *parent = 0, s32 id = -1, bool drawBackground = false) override; + + //! Adds a file open dialog. + virtual IGUIFileOpenDialog *addFileOpenDialog(const wchar_t *title = 0, + bool modal = true, IGUIElement *parent = 0, s32 id = -1, + bool restoreCWD = false, io::path::char_type *startDir = 0) override; + + //! adds a static text. The returned pointer must not be dropped. + virtual IGUIStaticText *addStaticText(const wchar_t *text, const core::rect &rectangle, + bool border = false, bool wordWrap = true, IGUIElement *parent = 0, s32 id = -1, bool drawBackground = false) override; + + //! Adds an edit box. The returned pointer must not be dropped. + virtual IGUIEditBox *addEditBox(const wchar_t *text, const core::rect &rectangle, + bool border = false, IGUIElement *parent = 0, s32 id = -1) override; + + //! Adds a tab control to the environment. + virtual IGUITabControl *addTabControl(const core::rect &rectangle, + IGUIElement *parent = 0, bool fillbackground = false, bool border = true, s32 id = -1) override; + + //! Adds tab to the environment. + virtual IGUITab *addTab(const core::rect &rectangle, + IGUIElement *parent = 0, s32 id = -1) override; + + //! Adds a combo box to the environment. + virtual IGUIComboBox *addComboBox(const core::rect &rectangle, + IGUIElement *parent = 0, s32 id = -1) override; + + //! sets the focus to an element + bool setFocus(IGUIElement *element) override; + + //! removes the focus from an element + bool removeFocus(IGUIElement *element) override; + + //! Returns if the element has focus + bool hasFocus(const IGUIElement *element, bool checkSubElements = false) const override; + + //! Returns the element with the focus + IGUIElement *getFocus() const override; + + //! Returns the element last known to be under the mouse + IGUIElement *getHovered() const override; + + //! Returns the root gui element. + IGUIElement *getRootGUIElement() override; + + void OnPostRender(u32 time) override; + + //! Find the next element which would be selected when pressing the tab-key + IGUIElement *getNextElement(bool reverse = false, bool group = false) override; + + //! Set the way the gui will handle focus changes + void setFocusBehavior(u32 flags) override; + + //! Get the way the gui does handle focus changes + u32 getFocusBehavior() const override; + + //! Adds a IGUIElement to deletion queue. + void addToDeletionQueue(IGUIElement *element) override; + +private: + //! clears the deletion queue + void clearDeletionQueue(); + + void updateHoveredElement(core::position2d mousePos); + + void loadBuiltInFont(); + + struct SFont + { + io::SNamedPath NamedPath; + IGUIFont *Font; + + bool operator<(const SFont &other) const + { + return (NamedPath < other.NamedPath); + } + }; + + struct SSpriteBank + { + io::SNamedPath NamedPath; + IGUISpriteBank *Bank; + + bool operator<(const SSpriteBank &other) const + { + return (NamedPath < other.NamedPath); + } + }; + + struct SToolTip + { + IGUIStaticText *Element; + u32 LastTime; + u32 EnterTime; + u32 LaunchTime; + u32 RelaunchTime; + }; + + SToolTip ToolTip; + + core::array Fonts; + core::array Banks; + video::IVideoDriver *Driver; + IGUIElement *Hovered; + IGUIElement *HoveredNoSubelement; // subelements replaced by their parent, so you only have 'real' elements here + IGUIElement *Focus; + core::position2d LastHoveredMousePos; + IGUISkin *CurrentSkin; + io::IFileSystem *FileSystem; + IEventReceiver *UserReceiver; + IOSOperator *Operator; + u32 FocusFlags; + core::array DeletionQueue; + + static const io::path DefaultFontName; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIFileOpenDialog.cpp b/irr/src/CGUIFileOpenDialog.cpp new file mode 100644 index 000000000..1e669b255 --- /dev/null +++ b/irr/src/CGUIFileOpenDialog.cpp @@ -0,0 +1,372 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIFileOpenDialog.h" + +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "IGUIButton.h" +#include "IGUIStaticText.h" +#include "IGUIFont.h" +#include "IGUIFontBitmap.h" +#include "IFileList.h" +#include "os.h" + +namespace irr +{ +namespace gui +{ + +const s32 FOD_WIDTH = 350; +const s32 FOD_HEIGHT = 250; + +//! constructor +CGUIFileOpenDialog::CGUIFileOpenDialog(const wchar_t *title, + IGUIEnvironment *environment, IGUIElement *parent, s32 id, + bool restoreCWD, io::path::char_type *startDir) : + IGUIFileOpenDialog(environment, parent, id, + core::rect((parent->getAbsolutePosition().getWidth() - FOD_WIDTH) / 2, + (parent->getAbsolutePosition().getHeight() - FOD_HEIGHT) / 2, + (parent->getAbsolutePosition().getWidth() - FOD_WIDTH) / 2 + FOD_WIDTH, + (parent->getAbsolutePosition().getHeight() - FOD_HEIGHT) / 2 + FOD_HEIGHT)), + FileNameText(0), FileList(0), Dragging(false) +{ +#ifdef _DEBUG + IGUIElement::setDebugName("CGUIFileOpenDialog"); +#endif + + Text = title; + + FileSystem = Environment ? Environment->getFileSystem() : 0; + + if (FileSystem) { + FileSystem->grab(); + + if (restoreCWD) + RestoreDirectory = FileSystem->getWorkingDirectory(); + if (startDir) { + StartDirectory = startDir; + FileSystem->changeWorkingDirectoryTo(startDir); + } + } else + return; + + IGUISpriteBank *sprites = 0; + video::SColor color(255, 255, 255, 255); + IGUISkin *skin = Environment->getSkin(); + if (skin) { + sprites = skin->getSpriteBank(); + color = skin->getColor(EGDC_WINDOW_SYMBOL); + } + + const s32 buttonw = skin ? skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) : 2; + const s32 posx = RelativeRect.getWidth() - buttonw - 4; + + CloseButton = Environment->addButton(core::rect(posx, 3, posx + buttonw, 3 + buttonw), this, -1, + L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close"); + CloseButton->setSubElement(true); + CloseButton->setTabStop(false); + if (sprites && skin) { + CloseButton->setSpriteBank(sprites); + CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), color); + CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), color); + } + CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + CloseButton->grab(); + + OKButton = Environment->addButton( + core::rect(RelativeRect.getWidth() - 80, 30, RelativeRect.getWidth() - 10, 50), + this, -1, skin ? skin->getDefaultText(EGDT_MSG_BOX_OK) : L"OK"); + OKButton->setSubElement(true); + OKButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + OKButton->grab(); + + CancelButton = Environment->addButton( + core::rect(RelativeRect.getWidth() - 80, 55, RelativeRect.getWidth() - 10, 75), + this, -1, skin ? skin->getDefaultText(EGDT_MSG_BOX_CANCEL) : L"Cancel"); + CancelButton->setSubElement(true); + CancelButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + CancelButton->grab(); + + FileBox = Environment->addListBox(core::rect(10, 55, RelativeRect.getWidth() - 90, 230), this, -1, true); + FileBox->setSubElement(true); + FileBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + FileBox->grab(); + + FileNameText = Environment->addEditBox(0, core::rect(10, 30, RelativeRect.getWidth() - 90, 50), true, this); + FileNameText->setSubElement(true); + FileNameText->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + FileNameText->grab(); + + setTabGroup(true); + + fillListBox(); +} + +//! destructor +CGUIFileOpenDialog::~CGUIFileOpenDialog() +{ + if (CloseButton) + CloseButton->drop(); + + if (OKButton) + OKButton->drop(); + + if (CancelButton) + CancelButton->drop(); + + if (FileBox) + FileBox->drop(); + + if (FileNameText) + FileNameText->drop(); + + if (FileSystem) { + // revert to original CWD if path was set in constructor + if (RestoreDirectory.size()) + FileSystem->changeWorkingDirectoryTo(RestoreDirectory); + FileSystem->drop(); + } + + if (FileList) + FileList->drop(); +} + +//! returns the filename of the selected file. Returns NULL, if no file was selected. +const wchar_t *CGUIFileOpenDialog::getFileName() const +{ + return FileNameW.c_str(); +} + +const io::path &CGUIFileOpenDialog::getFileNameP() const +{ + return FileName; +} + +//! Returns the directory of the selected file. Returns NULL, if no directory was selected. +const io::path &CGUIFileOpenDialog::getDirectoryName() const +{ + return FileDirectoryFlat; +} + +const wchar_t *CGUIFileOpenDialog::getDirectoryNameW() const +{ + return FileDirectoryFlatW.c_str(); +} + +void CGUIFileOpenDialog::setFileName(const irr::io::path &name) +{ + FileName = name; + pathToStringW(FileNameW, FileName); +} + +void CGUIFileOpenDialog::setDirectoryName(const irr::io::path &name) +{ + FileDirectory = name; + FileDirectoryFlat = name; + FileSystem->flattenFilename(FileDirectoryFlat); + pathToStringW(FileDirectoryFlatW, FileDirectoryFlat); +} + +//! called if an event happened. +bool CGUIFileOpenDialog::OnEvent(const SEvent &event) +{ + if (isEnabled()) { + switch (event.EventType) { + case EET_GUI_EVENT: + switch (event.GUIEvent.EventType) { + case EGET_ELEMENT_FOCUS_LOST: + Dragging = false; + break; + case EGET_BUTTON_CLICKED: + if (event.GUIEvent.Caller == CloseButton || + event.GUIEvent.Caller == CancelButton) { + sendCancelEvent(); + remove(); + return true; + } else if (event.GUIEvent.Caller == OKButton) { + if (FileDirectory != L"") { + sendSelectedEvent(EGET_DIRECTORY_SELECTED); + } + if (FileName != L"") { + sendSelectedEvent(EGET_FILE_SELECTED); + remove(); + return true; + } + } + break; + + case EGET_LISTBOX_CHANGED: { + s32 selected = FileBox->getSelected(); + if (FileList && FileSystem) { + if (FileList->isDirectory(selected)) { + setFileName(""); + setDirectoryName(FileList->getFullFileName(selected)); + } else { + setDirectoryName(""); + setFileName(FileList->getFullFileName(selected)); + } + return true; + } + } break; + + case EGET_LISTBOX_SELECTED_AGAIN: { + const s32 selected = FileBox->getSelected(); + if (FileList && FileSystem) { + if (FileList->isDirectory(selected)) { + setDirectoryName(FileList->getFullFileName(selected)); + FileSystem->changeWorkingDirectoryTo(FileDirectory); + fillListBox(); + setFileName(""); + } else { + setFileName(FileList->getFullFileName(selected)); + } + return true; + } + } break; + case EGET_EDITBOX_ENTER: + if (event.GUIEvent.Caller == FileNameText) { + io::path dir(FileNameText->getText()); + if (FileSystem->changeWorkingDirectoryTo(dir)) { + fillListBox(); + setFileName(""); + } + return true; + } + break; + default: + break; + } + break; + case EET_MOUSE_INPUT_EVENT: + switch (event.MouseInput.Event) { + case EMIE_MOUSE_WHEEL: + return FileBox->OnEvent(event); + case EMIE_LMOUSE_PRESSED_DOWN: + DragStart.X = event.MouseInput.X; + DragStart.Y = event.MouseInput.Y; + Dragging = true; + return true; + case EMIE_LMOUSE_LEFT_UP: + Dragging = false; + return true; + case EMIE_MOUSE_MOVED: + + if (!event.MouseInput.isLeftPressed()) + Dragging = false; + + if (Dragging) { + // gui window should not be dragged outside its parent + if (Parent) + if (event.MouseInput.X < Parent->getAbsolutePosition().UpperLeftCorner.X + 1 || + event.MouseInput.Y < Parent->getAbsolutePosition().UpperLeftCorner.Y + 1 || + event.MouseInput.X > Parent->getAbsolutePosition().LowerRightCorner.X - 1 || + event.MouseInput.Y > Parent->getAbsolutePosition().LowerRightCorner.Y - 1) + + return true; + + move(core::position2d(event.MouseInput.X - DragStart.X, event.MouseInput.Y - DragStart.Y)); + DragStart.X = event.MouseInput.X; + DragStart.Y = event.MouseInput.Y; + return true; + } + break; + default: + break; + } + default: + break; + } + } + + return IGUIElement::OnEvent(event); +} + +//! draws the element and its children +void CGUIFileOpenDialog::draw() +{ + if (!IsVisible) + return; + + IGUISkin *skin = Environment->getSkin(); + + core::rect rect = AbsoluteRect; + + rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER), + rect, &AbsoluteClippingRect); + + if (Text.size()) { + rect.UpperLeftCorner.X += 2; + rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5; + + IGUIFont *font = skin->getFont(EGDF_WINDOW); + if (font) + font->draw(Text.c_str(), rect, + skin->getColor(EGDC_ACTIVE_CAPTION), + false, true, &AbsoluteClippingRect); + } + + IGUIElement::draw(); +} + +void CGUIFileOpenDialog::pathToStringW(irr::core::stringw &result, const irr::io::path &p) +{ + core::multibyteToWString(result, p); +} + +//! fills the listbox with files. +void CGUIFileOpenDialog::fillListBox() +{ + IGUISkin *skin = Environment->getSkin(); + + if (!FileSystem || !FileBox || !skin) + return; + + if (FileList) + FileList->drop(); + + FileBox->clear(); + + FileList = FileSystem->createFileList(); + core::stringw s; + + if (FileList) { + for (u32 i = 0; i < FileList->getFileCount(); ++i) { + pathToStringW(s, FileList->getFileName(i)); + FileBox->addItem(s.c_str(), skin->getIcon(FileList->isDirectory(i) ? EGDI_DIRECTORY : EGDI_FILE)); + } + } + + if (FileNameText) { + setDirectoryName(FileSystem->getWorkingDirectory()); + pathToStringW(s, FileDirectory); + FileNameText->setText(s.c_str()); + } +} + +//! sends the event that the file has been selected. +void CGUIFileOpenDialog::sendSelectedEvent(EGUI_EVENT_TYPE type) +{ + SEvent event; + event.EventType = EET_GUI_EVENT; + event.GUIEvent.Caller = this; + event.GUIEvent.Element = 0; + event.GUIEvent.EventType = type; + Parent->OnEvent(event); +} + +//! sends the event that the file choose process has been cancelled +void CGUIFileOpenDialog::sendCancelEvent() +{ + SEvent event; + event.EventType = EET_GUI_EVENT; + event.GUIEvent.Caller = this; + event.GUIEvent.Element = 0; + event.GUIEvent.EventType = EGET_FILE_CHOOSE_DIALOG_CANCELLED; + Parent->OnEvent(event); +} + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIFileOpenDialog.h b/irr/src/CGUIFileOpenDialog.h new file mode 100644 index 000000000..133509233 --- /dev/null +++ b/irr/src/CGUIFileOpenDialog.h @@ -0,0 +1,84 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIFileOpenDialog.h" +#include "IGUIButton.h" +#include "IGUIListBox.h" +#include "IGUIEditBox.h" +#include "IFileSystem.h" + +namespace irr +{ +namespace gui +{ + +class CGUIFileOpenDialog : public IGUIFileOpenDialog +{ +public: + //! constructor + CGUIFileOpenDialog(const wchar_t *title, IGUIEnvironment *environment, + IGUIElement *parent, s32 id, bool restoreCWD = false, + io::path::char_type *startDir = 0); + + //! destructor + virtual ~CGUIFileOpenDialog(); + + //! returns the filename of the selected file. Returns NULL, if no file was selected. + const wchar_t *getFileName() const override; + + //! Returns the filename of the selected file. Is empty if no file was selected. + const io::path &getFileNameP() const override; + + //! Returns the directory of the selected file. Returns NULL, if no directory was selected. + const io::path &getDirectoryName() const override; + + //! Returns the directory of the selected file converted to wide characters. Returns NULL if no directory was selected. + const wchar_t *getDirectoryNameW() const override; + + //! called if an event happened. + bool OnEvent(const SEvent &event) override; + + //! draws the element and its children + void draw() override; + +protected: + void setFileName(const irr::io::path &name); + void setDirectoryName(const irr::io::path &name); + + //! Ensure filenames are converted correct depending on wide-char settings + void pathToStringW(irr::core::stringw &result, const irr::io::path &p); + + //! fills the listbox with files. + void fillListBox(); + + //! sends the event that the file has been selected. + void sendSelectedEvent(EGUI_EVENT_TYPE type); + + //! sends the event that the file choose process has been canceld + void sendCancelEvent(); + + core::position2d DragStart; + io::path FileName; + core::stringw FileNameW; + io::path FileDirectory; + io::path FileDirectoryFlat; + core::stringw FileDirectoryFlatW; + io::path RestoreDirectory; + io::path StartDirectory; + + IGUIButton *CloseButton; + IGUIButton *OKButton; + IGUIButton *CancelButton; + IGUIListBox *FileBox; + IGUIEditBox *FileNameText; + IGUIElement *EventParent; + io::IFileSystem *FileSystem; + io::IFileList *FileList; + bool Dragging; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIFont.cpp b/irr/src/CGUIFont.cpp new file mode 100644 index 000000000..4d85702f5 --- /dev/null +++ b/irr/src/CGUIFont.cpp @@ -0,0 +1,548 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIFont.h" + +#include "os.h" +#include "coreutil.h" +#include "IGUIEnvironment.h" +#include "IReadFile.h" +#include "IVideoDriver.h" +#include "IGUISpriteBank.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIFont::CGUIFont(IGUIEnvironment *env, const io::path &filename) : + Driver(0), SpriteBank(0), Environment(env), WrongCharacter(0), + MaxHeight(0), GlobalKerningWidth(0), GlobalKerningHeight(0) +{ +#ifdef _DEBUG + setDebugName("CGUIFont"); +#endif + + if (Environment) { + // don't grab environment, to avoid circular references + Driver = Environment->getVideoDriver(); + + SpriteBank = Environment->getSpriteBank(filename); + if (!SpriteBank) // could be default-font which has no file + SpriteBank = Environment->addEmptySpriteBank(filename); + if (SpriteBank) + SpriteBank->grab(); + } + + if (Driver) + Driver->grab(); + + setInvisibleCharacters(L" "); +} + +//! destructor +CGUIFont::~CGUIFont() +{ + if (Driver) + Driver->drop(); + + if (SpriteBank) { + SpriteBank->drop(); + // TODO: spritebank still exists in gui-environment and should be removed here when it's + // reference-count is 1. Just can't do that from here at the moment. + // But spritebank would not be able to drop textures anyway because those are in texture-cache + // where they can't be removed unless materials start reference-couting 'em. + } +} + +#if 0 +//! loads a font file from xml +bool CGUIFont::load(io::IXMLReader* xml, const io::path& directory) +{ + if (!SpriteBank) + return false; + + SpriteBank->clear(); + + while (xml->read()) + { + if (io::EXN_ELEMENT == xml->getNodeType()) + { + if (core::stringw(L"Texture") == xml->getNodeName()) + { + // add a texture + core::stringc fn = xml->getAttributeValue(L"filename"); + u32 i = (u32)xml->getAttributeValueAsInt(L"index"); + core::stringw alpha = xml->getAttributeValue(L"hasAlpha"); + + while (i+1 > SpriteBank->getTextureCount()) + SpriteBank->addTexture(0); + + bool flags[3]; + pushTextureCreationFlags(flags); + + // load texture + io::path textureFullName = core::mergeFilename(directory, fn); + SpriteBank->setTexture(i, Driver->getTexture(textureFullName)); + + popTextureCreationFlags(flags); + + // couldn't load texture, abort. + if (!SpriteBank->getTexture(i)) + { + os::Printer::log("Unable to load all textures in the font, aborting", ELL_ERROR); + return false; + } + else + { + // colorkey texture rather than alpha channel? + if (alpha == core::stringw("false")) + Driver->makeColorKeyTexture(SpriteBank->getTexture(i), core::position2di(0,0)); + } + } + else if (core::stringw(L"c") == xml->getNodeName()) + { + // adding a character to this font + SFontArea a; + SGUISpriteFrame f; + SGUISprite s; + core::rect rectangle; + + a.underhang = xml->getAttributeValueAsInt(L"u"); + a.overhang = xml->getAttributeValueAsInt(L"o"); + a.spriteno = SpriteBank->getSprites().size(); + s32 texno = xml->getAttributeValueAsInt(L"i"); + + // parse rectangle + core::stringc rectstr = xml->getAttributeValue(L"r"); + wchar_t ch = xml->getAttributeValue(L"c")[0]; + + const c8 *c = rectstr.c_str(); + s32 val; + val = 0; + while (*c >= '0' && *c <= '9') + { + val *= 10; + val += *c - '0'; + c++; + } + rectangle.UpperLeftCorner.X = val; + while (*c == L' ' || *c == L',') c++; + + val = 0; + while (*c >= '0' && *c <= '9') + { + val *= 10; + val += *c - '0'; + c++; + } + rectangle.UpperLeftCorner.Y = val; + while (*c == L' ' || *c == L',') c++; + + val = 0; + while (*c >= '0' && *c <= '9') + { + val *= 10; + val += *c - '0'; + c++; + } + rectangle.LowerRightCorner.X = val; + while (*c == L' ' || *c == L',') c++; + + val = 0; + while (*c >= '0' && *c <= '9') + { + val *= 10; + val += *c - '0'; + c++; + } + rectangle.LowerRightCorner.Y = val; + + CharacterMap.emplace(ch, Areas.size()); + + // make frame + f.rectNumber = SpriteBank->getPositions().size(); + f.textureNumber = texno; + + // add frame to sprite + s.Frames.push_back(f); + s.frameTime = 0; + + // add rectangle to sprite bank + SpriteBank->getPositions().push_back(rectangle); + a.width = rectangle.getWidth(); + + // add sprite to sprite bank + SpriteBank->getSprites().push_back(s); + + // add character to font + Areas.push_back(a); + } + } + } + + // set bad character + WrongCharacter = getAreaFromCharacter(L' '); + + setMaxHeight(); + + return true; +} +#endif + +void CGUIFont::setMaxHeight() +{ + if (!SpriteBank) + return; + + MaxHeight = 0; + + core::array> &p = SpriteBank->getPositions(); + + for (u32 i = 0; i < p.size(); ++i) { + const s32 t = p[i].getHeight(); + if (t > MaxHeight) + MaxHeight = t; + } +} + +void CGUIFont::pushTextureCreationFlags(bool (&flags)[3]) +{ + flags[0] = Driver->getTextureCreationFlag(video::ETCF_ALLOW_NON_POWER_2); + flags[1] = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); + flags[2] = Driver->getTextureCreationFlag(video::ETCF_ALLOW_MEMORY_COPY); + + Driver->setTextureCreationFlag(video::ETCF_ALLOW_NON_POWER_2, true); + Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); + Driver->setTextureCreationFlag(video::ETCF_ALLOW_MEMORY_COPY, true); +} + +void CGUIFont::popTextureCreationFlags(const bool (&flags)[3]) +{ + Driver->setTextureCreationFlag(video::ETCF_ALLOW_NON_POWER_2, flags[0]); + Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, flags[1]); + Driver->setTextureCreationFlag(video::ETCF_ALLOW_MEMORY_COPY, flags[2]); +} + +//! loads a font file, native file needed, for texture parsing +bool CGUIFont::load(io::IReadFile *file) +{ + if (!Driver) + return false; + + return loadTexture(Driver->createImageFromFile(file), + file->getFileName()); +} + +//! loads a font file, native file needed, for texture parsing +bool CGUIFont::load(const io::path &filename) +{ + if (!Driver) + return false; + + return loadTexture(Driver->createImageFromFile(filename), + filename); +} + +//! load & prepare font from ITexture +bool CGUIFont::loadTexture(video::IImage *image, const io::path &name) +{ + if (!image || !SpriteBank) + return false; + + s32 lowerRightPositions = 0; + + video::IImage *tmpImage = image; + bool deleteTmpImage = false; + switch (image->getColorFormat()) { + case video::ECF_R5G6B5: + tmpImage = Driver->createImage(video::ECF_A1R5G5B5, image->getDimension()); + image->copyTo(tmpImage); + deleteTmpImage = true; + break; + case video::ECF_A1R5G5B5: + case video::ECF_A8R8G8B8: + break; + case video::ECF_R8G8B8: + tmpImage = Driver->createImage(video::ECF_A8R8G8B8, image->getDimension()); + image->copyTo(tmpImage); + deleteTmpImage = true; + break; + default: + os::Printer::log("Unknown texture format provided for CGUIFont::loadTexture", ELL_ERROR); + return false; + } + readPositions(tmpImage, lowerRightPositions); + + WrongCharacter = getAreaFromCharacter(L' '); + + // output warnings + if (!lowerRightPositions || !SpriteBank->getSprites().size()) + os::Printer::log("Either no upper or lower corner pixels in the font file. If this font was made using the new font tool, please load the XML file instead. If not, the font may be corrupted.", ELL_ERROR); + else if (lowerRightPositions != (s32)SpriteBank->getPositions().size()) + os::Printer::log("The amount of upper corner pixels and the lower corner pixels is not equal, font file may be corrupted.", ELL_ERROR); + + bool ret = (!SpriteBank->getSprites().empty() && lowerRightPositions); + + if (ret) { + bool flags[3]; + pushTextureCreationFlags(flags); + + SpriteBank->addTexture(Driver->addTexture(name, tmpImage)); + + popTextureCreationFlags(flags); + } + if (deleteTmpImage) + tmpImage->drop(); + image->drop(); + + setMaxHeight(); + + return ret; +} + +void CGUIFont::readPositions(video::IImage *image, s32 &lowerRightPositions) +{ + if (!SpriteBank) + return; + + const core::dimension2d size = image->getDimension(); + + video::SColor colorTopLeft = image->getPixel(0, 0); + colorTopLeft.setAlpha(255); + image->setPixel(0, 0, colorTopLeft); + video::SColor colorLowerRight = image->getPixel(1, 0); + video::SColor colorBackGround = image->getPixel(2, 0); + video::SColor colorBackGroundTransparent = 0; + + image->setPixel(1, 0, colorBackGround); + + // start parsing + + core::position2d pos(0, 0); + for (pos.Y = 0; pos.Y < (s32)size.Height; ++pos.Y) { + for (pos.X = 0; pos.X < (s32)size.Width; ++pos.X) { + const video::SColor c = image->getPixel(pos.X, pos.Y); + if (c == colorTopLeft) { + image->setPixel(pos.X, pos.Y, colorBackGroundTransparent); + SpriteBank->getPositions().push_back(core::rect(pos, pos)); + } else if (c == colorLowerRight) { + // too many lower right points + if (SpriteBank->getPositions().size() <= (u32)lowerRightPositions) { + lowerRightPositions = 0; + return; + } + + image->setPixel(pos.X, pos.Y, colorBackGroundTransparent); + SpriteBank->getPositions()[lowerRightPositions].LowerRightCorner = pos; + // add frame to sprite bank + SGUISpriteFrame f; + f.rectNumber = lowerRightPositions; + f.textureNumber = 0; + SGUISprite s; + s.Frames.push_back(f); + s.frameTime = 0; + SpriteBank->getSprites().push_back(s); + // add character to font + SFontArea a; + a.overhang = 0; + a.underhang = 0; + a.spriteno = lowerRightPositions; + a.width = SpriteBank->getPositions()[lowerRightPositions].getWidth(); + Areas.push_back(a); + // map letter to character + wchar_t ch = (wchar_t)(lowerRightPositions + 32); + CharacterMap[ch] = lowerRightPositions; + + ++lowerRightPositions; + } else if (c == colorBackGround) + image->setPixel(pos.X, pos.Y, colorBackGroundTransparent); + } + } +} + +//! set an Pixel Offset on Drawing ( scale position on width ) +void CGUIFont::setKerningWidth(s32 kerning) +{ + GlobalKerningWidth = kerning; +} + +//! set an Pixel Offset on Drawing ( scale position on width ) +s32 CGUIFont::getKerningWidth(const wchar_t *thisLetter, const wchar_t *previousLetter) const +{ + s32 ret = GlobalKerningWidth; + + if (thisLetter) { + ret += Areas[getAreaFromCharacter(*thisLetter)].overhang; + + if (previousLetter) { + ret += Areas[getAreaFromCharacter(*previousLetter)].underhang; + } + } + + return ret; +} + +//! set an Pixel Offset on Drawing ( scale position on height ) +void CGUIFont::setKerningHeight(s32 kerning) +{ + GlobalKerningHeight = kerning; +} + +//! set an Pixel Offset on Drawing ( scale position on height ) +s32 CGUIFont::getKerningHeight() const +{ + return GlobalKerningHeight; +} + +//! returns the sprite number from a given character +u32 CGUIFont::getSpriteNoFromChar(const wchar_t *c) const +{ + return Areas[getAreaFromCharacter(*c)].spriteno; +} + +s32 CGUIFont::getAreaFromCharacter(const wchar_t c) const +{ + auto n = CharacterMap.find(c); + if (n != CharacterMap.end()) + return n->second; + else + return WrongCharacter; +} + +void CGUIFont::setInvisibleCharacters(const wchar_t *s) +{ + Invisible = s; +} + +//! returns the dimension of text +core::dimension2d CGUIFont::getDimension(const wchar_t *text) const +{ + core::dimension2d dim(0, 0); + core::dimension2d thisLine(0, MaxHeight); + + for (const wchar_t *p = text; *p; ++p) { + bool lineBreak = false; + if (*p == L'\r') { // Mac or Windows breaks + lineBreak = true; + if (p[1] == L'\n') // Windows breaks + ++p; + } else if (*p == L'\n') { // Unix breaks + lineBreak = true; + } + if (lineBreak) { + dim.Height += thisLine.Height; + if (dim.Width < thisLine.Width) + dim.Width = thisLine.Width; + thisLine.Width = 0; + continue; + } + + const SFontArea &area = Areas[getAreaFromCharacter(*p)]; + + thisLine.Width += area.underhang; + thisLine.Width += area.width + area.overhang + GlobalKerningWidth; + } + + dim.Height += thisLine.Height; + if (dim.Width < thisLine.Width) + dim.Width = thisLine.Width; + + return dim; +} + +//! draws some text and clips it to the specified rectangle if wanted +void CGUIFont::draw(const core::stringw &text, const core::rect &position, + video::SColor color, + bool hcenter, bool vcenter, const core::rect *clip) +{ + if (!Driver || !SpriteBank) + return; + + core::dimension2d textDimension; // NOTE: don't make this u32 or the >> later on can fail when the dimension width is < position width + core::position2d offset = position.UpperLeftCorner; + + if (hcenter || vcenter || clip) + textDimension = getDimension(text.c_str()); + + if (hcenter) + offset.X += (position.getWidth() - textDimension.Width) >> 1; + + if (vcenter) + offset.Y += (position.getHeight() - textDimension.Height) >> 1; + + if (clip) { + core::rect clippedRect(offset, textDimension); + clippedRect.clipAgainst(*clip); + if (!clippedRect.isValid()) + return; + } + + core::array indices(text.size()); + core::array offsets(text.size()); + + for (u32 i = 0; i < text.size(); i++) { + wchar_t c = text[i]; + + bool lineBreak = false; + if (c == L'\r') { // Mac or Windows breaks + lineBreak = true; + if (text[i + 1] == L'\n') // Windows breaks + c = text[++i]; + } else if (c == L'\n') { // Unix breaks + lineBreak = true; + } + + if (lineBreak) { + offset.Y += MaxHeight; + offset.X = position.UpperLeftCorner.X; + + if (hcenter) { + offset.X += (position.getWidth() - textDimension.Width) >> 1; + } + continue; + } + + SFontArea &area = Areas[getAreaFromCharacter(c)]; + + offset.X += area.underhang; + if (Invisible.findFirst(c) < 0) { + indices.push_back(area.spriteno); + offsets.push_back(offset); + } + + offset.X += area.width + area.overhang + GlobalKerningWidth; + } + + SpriteBank->draw2DSpriteBatch(indices, offsets, clip, color); +} + +//! Calculates the index of the character in the text which is on a specific position. +s32 CGUIFont::getCharacterFromPos(const wchar_t *text, s32 pixel_x) const +{ + s32 x = 0; + s32 idx = 0; + + while (text[idx]) { + const SFontArea &a = Areas[getAreaFromCharacter(text[idx])]; + + x += a.width + a.overhang + a.underhang + GlobalKerningWidth; + + if (x >= pixel_x) + return idx; + + ++idx; + } + + return -1; +} + +IGUISpriteBank *CGUIFont::getSpriteBank() const +{ + return SpriteBank; +} + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIFont.h b/irr/src/CGUIFont.h new file mode 100644 index 000000000..2f383a5f7 --- /dev/null +++ b/irr/src/CGUIFont.h @@ -0,0 +1,107 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIFontBitmap.h" +#include "irrString.h" +#include "IReadFile.h" +#include "irrArray.h" +#include + +namespace irr +{ + +namespace video +{ +class IVideoDriver; +class IImage; +} + +namespace gui +{ + +class IGUIEnvironment; + +class CGUIFont : public IGUIFontBitmap +{ +public: + //! constructor + CGUIFont(IGUIEnvironment *env, const io::path &filename); + + //! destructor + virtual ~CGUIFont(); + + //! loads a font from a texture file + bool load(const io::path &filename); + + //! loads a font from a texture file + bool load(io::IReadFile *file); + + //! draws an text and clips it to the specified rectangle if wanted + virtual void draw(const core::stringw &text, const core::rect &position, + video::SColor color, bool hcenter = false, + bool vcenter = false, const core::rect *clip = 0) override; + + //! returns the dimension of a text + core::dimension2d getDimension(const wchar_t *text) const override; + + //! Calculates the index of the character in the text which is on a specific position. + s32 getCharacterFromPos(const wchar_t *text, s32 pixel_x) const override; + + //! Returns the type of this font + EGUI_FONT_TYPE getType() const override { return EGFT_BITMAP; } + + //! set an Pixel Offset on Drawing ( scale position on width ) + void setKerningWidth(s32 kerning) override; + void setKerningHeight(s32 kerning) override; + + //! set an Pixel Offset on Drawing ( scale position on width ) + s32 getKerningWidth(const wchar_t *thisLetter = 0, const wchar_t *previousLetter = 0) const override; + s32 getKerningHeight() const override; + + //! gets the sprite bank + IGUISpriteBank *getSpriteBank() const override; + + //! returns the sprite number from a given character + u32 getSpriteNoFromChar(const wchar_t *c) const override; + + void setInvisibleCharacters(const wchar_t *s) override; + +private: + struct SFontArea + { + SFontArea() : + underhang(0), overhang(0), width(0), spriteno(0) {} + s32 underhang; + s32 overhang; + s32 width; + u32 spriteno; + }; + + //! load & prepare font from ITexture + bool loadTexture(video::IImage *image, const io::path &name); + + void readPositions(video::IImage *texture, s32 &lowerRightPositions); + + s32 getAreaFromCharacter(const wchar_t c) const; + void setMaxHeight(); + + void pushTextureCreationFlags(bool (&flags)[3]); + void popTextureCreationFlags(const bool (&flags)[3]); + + core::array Areas; + std::map CharacterMap; + video::IVideoDriver *Driver; + IGUISpriteBank *SpriteBank; + IGUIEnvironment *Environment; + u32 WrongCharacter; + s32 MaxHeight; + s32 GlobalKerningWidth, GlobalKerningHeight; + + core::stringw Invisible; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIImage.cpp b/irr/src/CGUIImage.cpp new file mode 100644 index 000000000..5f7bb8e26 --- /dev/null +++ b/irr/src/CGUIImage.cpp @@ -0,0 +1,164 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIImage.h" + +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIImage::CGUIImage(IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect rectangle) : + IGUIImage(environment, parent, id, rectangle), Texture(0), Color(255, 255, 255, 255), + UseAlphaChannel(false), ScaleImage(false), DrawBounds(0.f, 0.f, 1.f, 1.f), DrawBackground(true) +{ +#ifdef _DEBUG + setDebugName("CGUIImage"); +#endif +} + +//! destructor +CGUIImage::~CGUIImage() +{ + if (Texture) + Texture->drop(); +} + +//! sets an image +void CGUIImage::setImage(video::ITexture *image) +{ + if (image == Texture) + return; + + if (Texture) + Texture->drop(); + + Texture = image; + + if (Texture) + Texture->grab(); +} + +//! Gets the image texture +video::ITexture *CGUIImage::getImage() const +{ + return Texture; +} + +//! sets the color of the image +void CGUIImage::setColor(video::SColor color) +{ + Color = color; +} + +//! Gets the color of the image +video::SColor CGUIImage::getColor() const +{ + return Color; +} + +//! draws the element and its children +void CGUIImage::draw() +{ + if (!IsVisible) + return; + + IGUISkin *skin = Environment->getSkin(); + video::IVideoDriver *driver = Environment->getVideoDriver(); + + if (Texture) { + core::rect sourceRect(SourceRect); + if (sourceRect.getWidth() == 0 || sourceRect.getHeight() == 0) { + sourceRect = core::rect(core::dimension2di(Texture->getOriginalSize())); + } + + if (ScaleImage) { + const video::SColor Colors[] = {Color, Color, Color, Color}; + + core::rect clippingRect(AbsoluteClippingRect); + checkBounds(clippingRect); + + driver->draw2DImage(Texture, AbsoluteRect, sourceRect, + &clippingRect, Colors, UseAlphaChannel); + } else { + core::rect clippingRect(AbsoluteRect.UpperLeftCorner, sourceRect.getSize()); + checkBounds(clippingRect); + clippingRect.clipAgainst(AbsoluteClippingRect); + + driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, sourceRect, + &clippingRect, Color, UseAlphaChannel); + } + } else if (DrawBackground) { + core::rect clippingRect(AbsoluteClippingRect); + checkBounds(clippingRect); + + skin->draw2DRectangle(this, skin->getColor(EGDC_3D_DARK_SHADOW), AbsoluteRect, &clippingRect); + } + + IGUIElement::draw(); +} + +//! sets if the image should use its alpha channel to draw itself +void CGUIImage::setUseAlphaChannel(bool use) +{ + UseAlphaChannel = use; +} + +//! sets if the image should use its alpha channel to draw itself +void CGUIImage::setScaleImage(bool scale) +{ + ScaleImage = scale; +} + +//! Returns true if the image is scaled to fit, false if not +bool CGUIImage::isImageScaled() const +{ + return ScaleImage; +} + +//! Returns true if the image is using the alpha channel, false if not +bool CGUIImage::isAlphaChannelUsed() const +{ + return UseAlphaChannel; +} + +//! Sets the source rectangle of the image. By default the full image is used. +void CGUIImage::setSourceRect(const core::rect &sourceRect) +{ + SourceRect = sourceRect; +} + +//! Returns the customized source rectangle of the image to be used. +core::rect CGUIImage::getSourceRect() const +{ + return SourceRect; +} + +//! Restrict target drawing-area. +void CGUIImage::setDrawBounds(const core::rect &drawBoundUVs) +{ + DrawBounds = drawBoundUVs; + DrawBounds.UpperLeftCorner.X = core::clamp(DrawBounds.UpperLeftCorner.X, 0.f, 1.f); + DrawBounds.UpperLeftCorner.Y = core::clamp(DrawBounds.UpperLeftCorner.Y, 0.f, 1.f); + DrawBounds.LowerRightCorner.X = core::clamp(DrawBounds.LowerRightCorner.X, 0.f, 1.f); + DrawBounds.LowerRightCorner.X = core::clamp(DrawBounds.LowerRightCorner.X, 0.f, 1.f); + if (DrawBounds.UpperLeftCorner.X > DrawBounds.LowerRightCorner.X) + DrawBounds.UpperLeftCorner.X = DrawBounds.LowerRightCorner.X; + if (DrawBounds.UpperLeftCorner.Y > DrawBounds.LowerRightCorner.Y) + DrawBounds.UpperLeftCorner.Y = DrawBounds.LowerRightCorner.Y; +} + +//! Get target drawing-area restrictions. +core::rect CGUIImage::getDrawBounds() const +{ + return DrawBounds; +} + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIImage.h b/irr/src/CGUIImage.h new file mode 100644 index 000000000..967ac40ea --- /dev/null +++ b/irr/src/CGUIImage.h @@ -0,0 +1,97 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIImage.h" + +namespace irr +{ +namespace gui +{ + +class CGUIImage : public IGUIImage +{ +public: + //! constructor + CGUIImage(IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect rectangle); + + //! destructor + virtual ~CGUIImage(); + + //! sets an image + void setImage(video::ITexture *image) override; + + //! Gets the image texture + video::ITexture *getImage() const override; + + //! sets the color of the image + void setColor(video::SColor color) override; + + //! sets if the image should scale to fit the element + void setScaleImage(bool scale) override; + + //! draws the element and its children + void draw() override; + + //! sets if the image should use its alpha channel to draw itself + void setUseAlphaChannel(bool use) override; + + //! Gets the color of the image + video::SColor getColor() const override; + + //! Returns true if the image is scaled to fit, false if not + bool isImageScaled() const override; + + //! Returns true if the image is using the alpha channel, false if not + bool isAlphaChannelUsed() const override; + + //! Sets the source rectangle of the image. By default the full image is used. + void setSourceRect(const core::rect &sourceRect) override; + + //! Returns the customized source rectangle of the image to be used. + core::rect getSourceRect() const override; + + //! Restrict drawing-area. + void setDrawBounds(const core::rect &drawBoundUVs) override; + + //! Get drawing-area restrictions. + core::rect getDrawBounds() const override; + + //! Sets whether to draw a background color (EGDC_3D_DARK_SHADOW) when no texture is set + void setDrawBackground(bool draw) override + { + DrawBackground = draw; + } + + //! Checks if a background is drawn when no texture is set + bool isDrawBackgroundEnabled() const override + { + return DrawBackground; + } + +protected: + void checkBounds(core::rect &rect) + { + f32 clipWidth = (f32)rect.getWidth(); + f32 clipHeight = (f32)rect.getHeight(); + + rect.UpperLeftCorner.X += core::round32(DrawBounds.UpperLeftCorner.X * clipWidth); + rect.UpperLeftCorner.Y += core::round32(DrawBounds.UpperLeftCorner.Y * clipHeight); + rect.LowerRightCorner.X -= core::round32((1.f - DrawBounds.LowerRightCorner.X) * clipWidth); + rect.LowerRightCorner.Y -= core::round32((1.f - DrawBounds.LowerRightCorner.Y) * clipHeight); + } + +private: + video::ITexture *Texture; + video::SColor Color; + bool UseAlphaChannel; + bool ScaleImage; + core::rect SourceRect; + core::rect DrawBounds; + bool DrawBackground; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIImageList.cpp b/irr/src/CGUIImageList.cpp new file mode 100644 index 000000000..3bd30d913 --- /dev/null +++ b/irr/src/CGUIImageList.cpp @@ -0,0 +1,84 @@ +// This file is part of the "Irrlicht Engine". +// written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de +// modified by Thomas Alten + +#include "CGUIImageList.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIImageList::CGUIImageList(video::IVideoDriver *driver) : + Driver(driver), + Texture(0), + ImageCount(0), + ImageSize(0, 0), + ImagesPerRow(0), + UseAlphaChannel(false) +{ +#ifdef _DEBUG + setDebugName("CGUIImageList"); +#endif + + if (Driver) { + Driver->grab(); + } +} + +//! destructor +CGUIImageList::~CGUIImageList() +{ + if (Driver) { + Driver->drop(); + } + + if (Texture) { + Texture->drop(); + } +} + +//! Creates the image list from texture. +bool CGUIImageList::createImageList(video::ITexture *texture, + core::dimension2d imageSize, + bool useAlphaChannel) +{ + if (!texture) { + return false; + } + + Texture = texture; + Texture->grab(); + + ImageSize = imageSize; + + ImagesPerRow = Texture->getSize().Width / ImageSize.Width; + ImageCount = ImagesPerRow * Texture->getSize().Height / ImageSize.Height; + + UseAlphaChannel = useAlphaChannel; + + return true; +} + +//! Draws an image and clips it to the specified rectangle if wanted +void CGUIImageList::draw(s32 index, const core::position2d &destPos, + const core::rect *clip /*= 0*/) +{ + core::rect sourceRect; + + if (!Driver || index < 0 || index >= ImageCount) { + return; + } + + sourceRect.UpperLeftCorner.X = (index % ImagesPerRow) * ImageSize.Width; + sourceRect.UpperLeftCorner.Y = (index / ImagesPerRow) * ImageSize.Height; + sourceRect.LowerRightCorner.X = sourceRect.UpperLeftCorner.X + ImageSize.Width; + sourceRect.LowerRightCorner.Y = sourceRect.UpperLeftCorner.Y + ImageSize.Height; + + Driver->draw2DImage(Texture, destPos, sourceRect, clip, + video::SColor(255, 255, 255, 255), UseAlphaChannel); +} + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIImageList.h b/irr/src/CGUIImageList.h new file mode 100644 index 000000000..afde14e0a --- /dev/null +++ b/irr/src/CGUIImageList.h @@ -0,0 +1,65 @@ +// This file is part of the "Irrlicht Engine". +// written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de + +#pragma once + +#include "IGUIImageList.h" +#include "IVideoDriver.h" + +namespace irr +{ +namespace gui +{ + +class CGUIImageList : public IGUIImageList +{ +public: + //! constructor + CGUIImageList(video::IVideoDriver *Driver); + + //! destructor + virtual ~CGUIImageList(); + + //! Creates the image list from texture. + //! \param texture: The texture to use + //! \param imageSize: Size of a single image + //! \param useAlphaChannel: true if the alpha channel from the texture should be used + //! \return + //! true if the image list was created + bool createImageList(video::ITexture *texture, + core::dimension2d imageSize, + bool useAlphaChannel); + + //! Draws an image and clips it to the specified rectangle if wanted + //! \param index: Index of the image + //! \param destPos: Position of the image to draw + //! \param clip: Optional pointer to a rectangle against which the text will be clipped. + //! If the pointer is null, no clipping will be done. + virtual void draw(s32 index, const core::position2d &destPos, + const core::rect *clip = 0) override; + + //! Returns the count of Images in the list. + //! \return Returns the count of Images in the list. + s32 getImageCount() const override + { + return ImageCount; + } + + //! Returns the size of the images in the list. + //! \return Returns the size of the images in the list. + core::dimension2d getImageSize() const override + { + return ImageSize; + } + +private: + video::IVideoDriver *Driver; + video::ITexture *Texture; + s32 ImageCount; + core::dimension2d ImageSize; + s32 ImagesPerRow; + bool UseAlphaChannel; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIListBox.cpp b/irr/src/CGUIListBox.cpp new file mode 100644 index 000000000..78cb96ecf --- /dev/null +++ b/irr/src/CGUIListBox.cpp @@ -0,0 +1,745 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIListBox.h" + +#include "CGUIListBox.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "IGUIFont.h" +#include "IGUISpriteBank.h" +#include "CGUIScrollBar.h" +#include "os.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIListBox::CGUIListBox(IGUIEnvironment *environment, IGUIElement *parent, + s32 id, core::rect rectangle, bool clip, + bool drawBack, bool moveOverSelect) : + IGUIListBox(environment, parent, id, rectangle), + Selected(-1), + ItemHeight(0), ItemHeightOverride(0), + TotalItemHeight(0), ItemsIconWidth(0), Font(0), IconBank(0), + ScrollBar(0), selectTime(0), LastKeyTime(0), Selecting(false), DrawBack(drawBack), + MoveOverSelect(moveOverSelect), AutoScroll(true), HighlightWhenNotFocused(true) +{ +#ifdef _DEBUG + setDebugName("CGUIListBox"); +#endif + + IGUISkin *skin = Environment->getSkin(); + + ScrollBar = new CGUIScrollBar(false, Environment, this, -1, + core::recti(0, 0, 1, 1), + !clip); + ScrollBar->setSubElement(true); + ScrollBar->setTabStop(false); + ScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + ScrollBar->setVisible(false); + ScrollBar->setPos(0); + + updateScrollBarSize(skin->getSize(EGDS_SCROLLBAR_SIZE)); + + setNotClipped(!clip); + + // this element can be tabbed to + setTabStop(true); + setTabOrder(-1); + + updateAbsolutePosition(); +} + +//! destructor +CGUIListBox::~CGUIListBox() +{ + if (ScrollBar) + ScrollBar->drop(); + + if (Font) + Font->drop(); + + if (IconBank) + IconBank->drop(); +} + +//! returns amount of list items +u32 CGUIListBox::getItemCount() const +{ + return Items.size(); +} + +//! returns string of a list item. the may be a value from 0 to itemCount-1 +const wchar_t *CGUIListBox::getListItem(u32 id) const +{ + if (id >= Items.size()) + return 0; + + return Items[id].Text.c_str(); +} + +//! Returns the icon of an item +s32 CGUIListBox::getIcon(u32 id) const +{ + if (id >= Items.size()) + return -1; + + return Items[id].Icon; +} + +//! adds a list item, returns id of item +u32 CGUIListBox::addItem(const wchar_t *text) +{ + return addItem(text, -1); +} + +//! adds a list item, returns id of item +void CGUIListBox::removeItem(u32 id) +{ + if (id >= Items.size()) + return; + + if ((u32)Selected == id) { + Selected = -1; + } else if ((u32)Selected > id) { + Selected -= 1; + selectTime = os::Timer::getTime(); + } + + Items.erase(id); + + recalculateItemHeight(); +} + +s32 CGUIListBox::getItemAt(s32 xpos, s32 ypos) const +{ + if (xpos < AbsoluteRect.UpperLeftCorner.X || xpos >= AbsoluteRect.LowerRightCorner.X || ypos < AbsoluteRect.UpperLeftCorner.Y || ypos >= AbsoluteRect.LowerRightCorner.Y) + return -1; + + if (ItemHeight == 0) + return -1; + + s32 item = ((ypos - AbsoluteRect.UpperLeftCorner.Y - 1) + ScrollBar->getPos()) / ItemHeight; + if (item < 0 || item >= (s32)Items.size()) + return -1; + + return item; +} + +//! clears the list +void CGUIListBox::clear() +{ + Items.clear(); + ItemsIconWidth = 0; + Selected = -1; + + ScrollBar->setPos(0); + + recalculateItemHeight(); +} + +void CGUIListBox::recalculateItemHeight() +{ + IGUISkin *skin = Environment->getSkin(); + + if (Font != skin->getFont()) { + if (Font) + Font->drop(); + + Font = skin->getFont(); + if (0 == ItemHeightOverride) + ItemHeight = 0; + + if (Font) { + if (0 == ItemHeightOverride) + ItemHeight = Font->getDimension(L"A").Height + 4; + + Font->grab(); + } + } + + TotalItemHeight = ItemHeight * Items.size(); + ScrollBar->setMax(core::max_(0, TotalItemHeight - AbsoluteRect.getHeight())); + s32 minItemHeight = ItemHeight > 0 ? ItemHeight : 1; + ScrollBar->setSmallStep(minItemHeight); + ScrollBar->setLargeStep(2 * minItemHeight); + + if (TotalItemHeight <= AbsoluteRect.getHeight()) + ScrollBar->setVisible(false); + else + ScrollBar->setVisible(true); +} + +//! returns id of selected item. returns -1 if no item is selected. +s32 CGUIListBox::getSelected() const +{ + return Selected; +} + +//! sets the selected item. Set this to -1 if no item should be selected +void CGUIListBox::setSelected(s32 id) +{ + if ((u32)id >= Items.size()) + Selected = -1; + else + Selected = id; + + selectTime = os::Timer::getTime(); + + recalculateScrollPos(); +} + +//! sets the selected item. Set this to -1 if no item should be selected +void CGUIListBox::setSelected(const wchar_t *item) +{ + s32 index = -1; + + if (item) { + for (index = 0; index < (s32)Items.size(); ++index) { + if (Items[index].Text == item) + break; + } + } + setSelected(index); +} + +//! called if an event happened. +bool CGUIListBox::OnEvent(const SEvent &event) +{ + if (isEnabled()) { + switch (event.EventType) { + case EET_KEY_INPUT_EVENT: + if (event.KeyInput.PressedDown && + (event.KeyInput.Key == KEY_DOWN || + event.KeyInput.Key == KEY_UP || + event.KeyInput.Key == KEY_HOME || + event.KeyInput.Key == KEY_END || + event.KeyInput.Key == KEY_NEXT || + event.KeyInput.Key == KEY_PRIOR)) { + s32 oldSelected = Selected; + switch (event.KeyInput.Key) { + case KEY_DOWN: + Selected += 1; + break; + case KEY_UP: + Selected -= 1; + break; + case KEY_HOME: + Selected = 0; + break; + case KEY_END: + Selected = (s32)Items.size() - 1; + break; + case KEY_NEXT: + Selected += AbsoluteRect.getHeight() / ItemHeight; + break; + case KEY_PRIOR: + Selected -= AbsoluteRect.getHeight() / ItemHeight; + break; + default: + break; + } + if (Selected < 0) + Selected = 0; + if (Selected >= (s32)Items.size()) + Selected = Items.size() - 1; // will set Selected to -1 for empty listboxes which is correct + + recalculateScrollPos(); + + // post the news + + if (oldSelected != Selected && Parent && !Selecting && !MoveOverSelect) { + SEvent e; + e.EventType = EET_GUI_EVENT; + e.GUIEvent.Caller = this; + e.GUIEvent.Element = 0; + e.GUIEvent.EventType = EGET_LISTBOX_CHANGED; + Parent->OnEvent(e); + } + + return true; + } else if (!event.KeyInput.PressedDown && (event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE)) { + if (Parent) { + SEvent e; + e.EventType = EET_GUI_EVENT; + e.GUIEvent.Caller = this; + e.GUIEvent.Element = 0; + e.GUIEvent.EventType = EGET_LISTBOX_SELECTED_AGAIN; + Parent->OnEvent(e); + } + return true; + } else if (event.KeyInput.Key == KEY_TAB) { + return false; + } else if (event.KeyInput.PressedDown && event.KeyInput.Char) { + // change selection based on text as it is typed. + u32 now = os::Timer::getTime(); + + if (now - LastKeyTime < 500) { + // add to key buffer if it isn't a key repeat + if (!(KeyBuffer.size() == 1 && KeyBuffer[0] == event.KeyInput.Char)) { + KeyBuffer += L" "; + KeyBuffer[KeyBuffer.size() - 1] = event.KeyInput.Char; + } + } else { + KeyBuffer = L" "; + KeyBuffer[0] = event.KeyInput.Char; + } + LastKeyTime = now; + + // find the selected item, starting at the current selection + s32 start = Selected; + // dont change selection if the key buffer matches the current item + if (Selected > -1 && KeyBuffer.size() > 1) { + if (Items[Selected].Text.size() >= KeyBuffer.size() && + KeyBuffer.equals_ignore_case(Items[Selected].Text.subString(0, KeyBuffer.size()))) + return true; + } + + s32 current; + for (current = start + 1; current < (s32)Items.size(); ++current) { + if (Items[current].Text.size() >= KeyBuffer.size()) { + if (KeyBuffer.equals_ignore_case(Items[current].Text.subString(0, KeyBuffer.size()))) { + if (Parent && Selected != current && !Selecting && !MoveOverSelect) { + SEvent e; + e.EventType = EET_GUI_EVENT; + e.GUIEvent.Caller = this; + e.GUIEvent.Element = 0; + e.GUIEvent.EventType = EGET_LISTBOX_CHANGED; + Parent->OnEvent(e); + } + setSelected(current); + return true; + } + } + } + for (current = 0; current <= start; ++current) { + if (Items[current].Text.size() >= KeyBuffer.size()) { + if (KeyBuffer.equals_ignore_case(Items[current].Text.subString(0, KeyBuffer.size()))) { + if (Parent && Selected != current && !Selecting && !MoveOverSelect) { + Selected = current; + SEvent e; + e.EventType = EET_GUI_EVENT; + e.GUIEvent.Caller = this; + e.GUIEvent.Element = 0; + e.GUIEvent.EventType = EGET_LISTBOX_CHANGED; + Parent->OnEvent(e); + } + setSelected(current); + return true; + } + } + } + + return true; + } + break; + + case EET_GUI_EVENT: + switch (event.GUIEvent.EventType) { + case gui::EGET_SCROLL_BAR_CHANGED: + if (event.GUIEvent.Caller == ScrollBar) + return true; + break; + case gui::EGET_ELEMENT_FOCUS_LOST: { + if (event.GUIEvent.Caller == this) + Selecting = false; + } + default: + break; + } + break; + + case EET_MOUSE_INPUT_EVENT: { + core::position2d p(event.MouseInput.X, event.MouseInput.Y); + + switch (event.MouseInput.Event) { + case EMIE_MOUSE_WHEEL: + ScrollBar->setPos(ScrollBar->getPos() + (event.MouseInput.Wheel < 0 ? -1 : 1) * -ItemHeight / 2); + return true; + + case EMIE_LMOUSE_PRESSED_DOWN: { + Selecting = true; + return true; + } + + case EMIE_LMOUSE_LEFT_UP: { + Selecting = false; + + if (isPointInside(p)) + selectNew(event.MouseInput.Y); + + return true; + } + + case EMIE_MOUSE_MOVED: + if (Selecting || MoveOverSelect) { + if (isPointInside(p)) { + selectNew(event.MouseInput.Y, true); + return true; + } + } + default: + break; + } + } break; + default: + break; + } + } + + return IGUIElement::OnEvent(event); +} + +void CGUIListBox::selectNew(s32 ypos, bool onlyHover) +{ + u32 now = os::Timer::getTime(); + s32 oldSelected = Selected; + + Selected = getItemAt(AbsoluteRect.UpperLeftCorner.X, ypos); + if (Selected < 0 && !Items.empty()) + Selected = 0; + + recalculateScrollPos(); + + gui::EGUI_EVENT_TYPE eventType = (Selected == oldSelected && now < selectTime + 500) ? EGET_LISTBOX_SELECTED_AGAIN : EGET_LISTBOX_CHANGED; + selectTime = now; + // post the news + if (Parent && !onlyHover) { + SEvent event; + event.EventType = EET_GUI_EVENT; + event.GUIEvent.Caller = this; + event.GUIEvent.Element = 0; + event.GUIEvent.EventType = eventType; + Parent->OnEvent(event); + } +} + +//! Update the position and size of the listbox, and update the scrollbar +void CGUIListBox::updateAbsolutePosition() +{ + IGUIElement::updateAbsolutePosition(); + + recalculateItemHeight(); +} + +//! draws the element and its children +void CGUIListBox::draw() +{ + if (!IsVisible) + return; + + recalculateItemHeight(); // if the font changed + + IGUISkin *skin = Environment->getSkin(); + updateScrollBarSize(skin->getSize(EGDS_SCROLLBAR_SIZE)); + + core::rect *clipRect = 0; + + // draw background + core::rect frameRect(AbsoluteRect); + + // draw items + + core::rect clientClip(AbsoluteRect); + clientClip.UpperLeftCorner.Y += 1; + clientClip.UpperLeftCorner.X += 1; + if (ScrollBar->isVisible()) + clientClip.LowerRightCorner.X -= ScrollBar->getRelativePosition().getWidth(); + clientClip.LowerRightCorner.Y -= 1; + clientClip.clipAgainst(AbsoluteClippingRect); + + skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_HIGH_LIGHT), true, + DrawBack, frameRect, &AbsoluteClippingRect); + + if (clipRect) + clientClip.clipAgainst(*clipRect); + + frameRect = AbsoluteRect; + frameRect.UpperLeftCorner.X += 1; + if (ScrollBar->isVisible()) + frameRect.LowerRightCorner.X -= ScrollBar->getRelativePosition().getWidth(); + + frameRect.LowerRightCorner.Y = AbsoluteRect.UpperLeftCorner.Y + ItemHeight; + + frameRect.UpperLeftCorner.Y -= ScrollBar->getPos(); + frameRect.LowerRightCorner.Y -= ScrollBar->getPos(); + + bool hl = (HighlightWhenNotFocused || Environment->hasFocus(this) || Environment->hasFocus(ScrollBar)); + + for (s32 i = 0; i < (s32)Items.size(); ++i) { + if (frameRect.LowerRightCorner.Y >= AbsoluteRect.UpperLeftCorner.Y && + frameRect.UpperLeftCorner.Y <= AbsoluteRect.LowerRightCorner.Y) { + if (i == Selected && hl) + skin->draw2DRectangle(this, skin->getColor(EGDC_HIGH_LIGHT), frameRect, &clientClip); + + core::rect textRect = frameRect; + textRect.UpperLeftCorner.X += 3; + + if (Font) { + if (IconBank && (Items[i].Icon > -1)) { + core::position2di iconPos = textRect.UpperLeftCorner; + iconPos.Y += textRect.getHeight() / 2; + iconPos.X += ItemsIconWidth / 2; + + if (i == Selected && hl) { + IconBank->draw2DSprite((u32)Items[i].Icon, iconPos, &clientClip, + hasItemOverrideColor(i, EGUI_LBC_ICON_HIGHLIGHT) ? getItemOverrideColor(i, EGUI_LBC_ICON_HIGHLIGHT) : getItemDefaultColor(EGUI_LBC_ICON_HIGHLIGHT), + selectTime, os::Timer::getTime(), false, true); + } else { + IconBank->draw2DSprite((u32)Items[i].Icon, iconPos, &clientClip, + hasItemOverrideColor(i, EGUI_LBC_ICON) ? getItemOverrideColor(i, EGUI_LBC_ICON) : getItemDefaultColor(EGUI_LBC_ICON), + 0, (i == Selected) ? os::Timer::getTime() : 0, false, true); + } + } + + textRect.UpperLeftCorner.X += ItemsIconWidth + 3; + + if (i == Selected && hl) { + Font->draw(Items[i].Text.c_str(), textRect, + hasItemOverrideColor(i, EGUI_LBC_TEXT_HIGHLIGHT) ? getItemOverrideColor(i, EGUI_LBC_TEXT_HIGHLIGHT) : getItemDefaultColor(EGUI_LBC_TEXT_HIGHLIGHT), + false, true, &clientClip); + } else { + Font->draw(Items[i].Text.c_str(), textRect, + hasItemOverrideColor(i, EGUI_LBC_TEXT) ? getItemOverrideColor(i, EGUI_LBC_TEXT) : getItemDefaultColor(EGUI_LBC_TEXT), + false, true, &clientClip); + } + + textRect.UpperLeftCorner.X -= ItemsIconWidth + 3; + } + } + + frameRect.UpperLeftCorner.Y += ItemHeight; + frameRect.LowerRightCorner.Y += ItemHeight; + } + + IGUIElement::draw(); +} + +//! adds an list item with an icon +u32 CGUIListBox::addItem(const wchar_t *text, s32 icon) +{ + ListItem i; + i.Text = text; + i.Icon = icon; + + Items.push_back(i); + recalculateItemHeight(); + recalculateItemWidth(icon); + + return Items.size() - 1; +} + +void CGUIListBox::setSpriteBank(IGUISpriteBank *bank) +{ + if (bank == IconBank) + return; + if (IconBank) + IconBank->drop(); + + IconBank = bank; + if (IconBank) + IconBank->grab(); +} + +void CGUIListBox::recalculateScrollPos() +{ + if (!AutoScroll) + return; + + const s32 selPos = (getSelected() == -1 ? TotalItemHeight : getSelected() * ItemHeight) - ScrollBar->getPos(); + + if (selPos < 0) { + ScrollBar->setPos(ScrollBar->getPos() + selPos); + } else if (selPos > AbsoluteRect.getHeight() - ItemHeight) { + ScrollBar->setPos(ScrollBar->getPos() + selPos - AbsoluteRect.getHeight() + ItemHeight); + } +} + +void CGUIListBox::updateScrollBarSize(s32 size) +{ + if (size != ScrollBar->getRelativePosition().getWidth()) { + core::recti r(RelativeRect.getWidth() - size, 0, RelativeRect.getWidth(), RelativeRect.getHeight()); + ScrollBar->setRelativePosition(r); + } +} + +void CGUIListBox::setAutoScrollEnabled(bool scroll) +{ + AutoScroll = scroll; +} + +bool CGUIListBox::isAutoScrollEnabled() const +{ + return AutoScroll; +} + +bool CGUIListBox::getSerializationLabels(EGUI_LISTBOX_COLOR colorType, core::stringc &useColorLabel, core::stringc &colorLabel) const +{ + switch (colorType) { + case EGUI_LBC_TEXT: + useColorLabel = "UseColText"; + colorLabel = "ColText"; + break; + case EGUI_LBC_TEXT_HIGHLIGHT: + useColorLabel = "UseColTextHl"; + colorLabel = "ColTextHl"; + break; + case EGUI_LBC_ICON: + useColorLabel = "UseColIcon"; + colorLabel = "ColIcon"; + break; + case EGUI_LBC_ICON_HIGHLIGHT: + useColorLabel = "UseColIconHl"; + colorLabel = "ColIconHl"; + break; + default: + return false; + } + return true; +} + +void CGUIListBox::recalculateItemWidth(s32 icon) +{ + if (IconBank && icon > -1 && + IconBank->getSprites().size() > (u32)icon && + IconBank->getSprites()[(u32)icon].Frames.size()) { + u32 rno = IconBank->getSprites()[(u32)icon].Frames[0].rectNumber; + if (IconBank->getPositions().size() > rno) { + const s32 w = IconBank->getPositions()[rno].getWidth(); + if (w > ItemsIconWidth) + ItemsIconWidth = w; + } + } +} + +void CGUIListBox::setItem(u32 index, const wchar_t *text, s32 icon) +{ + if (index >= Items.size()) + return; + + Items[index].Text = text; + Items[index].Icon = icon; + + recalculateItemHeight(); + recalculateItemWidth(icon); +} + +//! Insert the item at the given index +//! Return the index on success or -1 on failure. +s32 CGUIListBox::insertItem(u32 index, const wchar_t *text, s32 icon) +{ + ListItem i; + i.Text = text; + i.Icon = icon; + + Items.insert(i, index); + recalculateItemHeight(); + recalculateItemWidth(icon); + + return index; +} + +void CGUIListBox::swapItems(u32 index1, u32 index2) +{ + if (index1 >= Items.size() || index2 >= Items.size()) + return; + + ListItem dummmy = Items[index1]; + Items[index1] = Items[index2]; + Items[index2] = dummmy; +} + +void CGUIListBox::setItemOverrideColor(u32 index, video::SColor color) +{ + for (u32 c = 0; c < EGUI_LBC_COUNT; ++c) { + Items[index].OverrideColors[c].Use = true; + Items[index].OverrideColors[c].Color = color; + } +} + +void CGUIListBox::setItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType, video::SColor color) +{ + if (index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT) + return; + + Items[index].OverrideColors[colorType].Use = true; + Items[index].OverrideColors[colorType].Color = color; +} + +void CGUIListBox::clearItemOverrideColor(u32 index) +{ + for (u32 c = 0; c < (u32)EGUI_LBC_COUNT; ++c) { + Items[index].OverrideColors[c].Use = false; + } +} + +void CGUIListBox::clearItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) +{ + if (index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT) + return; + + Items[index].OverrideColors[colorType].Use = false; +} + +bool CGUIListBox::hasItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const +{ + if (index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT) + return false; + + return Items[index].OverrideColors[colorType].Use; +} + +video::SColor CGUIListBox::getItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const +{ + if ((u32)index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT) + return video::SColor(); + + return Items[index].OverrideColors[colorType].Color; +} + +video::SColor CGUIListBox::getItemDefaultColor(EGUI_LISTBOX_COLOR colorType) const +{ + IGUISkin *skin = Environment->getSkin(); + if (!skin) + return video::SColor(); + + switch (colorType) { + case EGUI_LBC_TEXT: + return skin->getColor(EGDC_BUTTON_TEXT); + case EGUI_LBC_TEXT_HIGHLIGHT: + return skin->getColor(EGDC_HIGH_LIGHT_TEXT); + case EGUI_LBC_ICON: + return skin->getColor(EGDC_ICON); + case EGUI_LBC_ICON_HIGHLIGHT: + return skin->getColor(EGDC_ICON_HIGH_LIGHT); + default: + return video::SColor(); + } +} + +//! set global itemHeight +void CGUIListBox::setItemHeight(s32 height) +{ + ItemHeight = height; + ItemHeightOverride = 1; +} + +//! Sets whether to draw the background +void CGUIListBox::setDrawBackground(bool draw) +{ + DrawBack = draw; +} + +//! Access the vertical scrollbar +IGUIScrollBar *CGUIListBox::getVerticalScrollBar() const +{ + return ScrollBar; +} + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIListBox.h b/irr/src/CGUIListBox.h new file mode 100644 index 000000000..ea1eaebd0 --- /dev/null +++ b/irr/src/CGUIListBox.h @@ -0,0 +1,173 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIListBox.h" +#include "irrArray.h" + +namespace irr +{ +namespace gui +{ + +class IGUIFont; +class IGUIScrollBar; + +class CGUIListBox : public IGUIListBox +{ +public: + //! constructor + CGUIListBox(IGUIEnvironment *environment, IGUIElement *parent, + s32 id, core::rect rectangle, bool clip = true, + bool drawBack = false, bool moveOverSelect = false); + + //! destructor + virtual ~CGUIListBox(); + + //! returns amount of list items + u32 getItemCount() const override; + + //! returns string of a list item. the id may be a value from 0 to itemCount-1 + const wchar_t *getListItem(u32 id) const override; + + //! adds an list item, returns id of item + u32 addItem(const wchar_t *text) override; + + //! clears the list + void clear() override; + + //! returns id of selected item. returns -1 if no item is selected. + s32 getSelected() const override; + + //! sets the selected item. Set this to -1 if no item should be selected + void setSelected(s32 id) override; + + //! sets the selected item. Set this to -1 if no item should be selected + void setSelected(const wchar_t *item) override; + + //! called if an event happened. + bool OnEvent(const SEvent &event) override; + + //! draws the element and its children + void draw() override; + + //! adds an list item with an icon + //! \param text Text of list entry + //! \param icon Sprite index of the Icon within the current sprite bank. Set it to -1 if you want no icon + //! \return + //! returns the id of the new created item + u32 addItem(const wchar_t *text, s32 icon) override; + + //! Returns the icon of an item + s32 getIcon(u32 id) const override; + + //! removes an item from the list + void removeItem(u32 id) override; + + //! get the the id of the item at the given absolute coordinates + s32 getItemAt(s32 xpos, s32 ypos) const override; + + //! Sets the sprite bank which should be used to draw list icons. This font is set to the sprite bank of + //! the built-in-font by default. A sprite can be displayed in front of every list item. + //! An icon is an index within the icon sprite bank. Several default icons are available in the + //! skin through getIcon + void setSpriteBank(IGUISpriteBank *bank) override; + + //! set whether the listbox should scroll to newly selected items + void setAutoScrollEnabled(bool scroll) override; + + //! returns true if automatic scrolling is enabled, false if not. + bool isAutoScrollEnabled() const override; + + //! Update the position and size of the listbox, and update the scrollbar + void updateAbsolutePosition() override; + + //! set all item colors at given index to color + void setItemOverrideColor(u32 index, video::SColor color) override; + + //! set all item colors of specified type at given index to color + void setItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType, video::SColor color) override; + + //! clear all item colors at index + void clearItemOverrideColor(u32 index) override; + + //! clear item color at index for given colortype + void clearItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) override; + + //! has the item at index its color overwritten? + bool hasItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const override; + + //! return the overwrite color at given item index. + video::SColor getItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const override; + + //! return the default color which is used for the given colorType + video::SColor getItemDefaultColor(EGUI_LISTBOX_COLOR colorType) const override; + + //! set the item at the given index + void setItem(u32 index, const wchar_t *text, s32 icon) override; + + //! Insert the item at the given index + //! Return the index on success or -1 on failure. + s32 insertItem(u32 index, const wchar_t *text, s32 icon) override; + + //! Swap the items at the given indices + void swapItems(u32 index1, u32 index2) override; + + //! set global itemHeight + void setItemHeight(s32 height) override; + + //! Sets whether to draw the background + void setDrawBackground(bool draw) override; + + //! Access the vertical scrollbar + IGUIScrollBar *getVerticalScrollBar() const override; + +private: + struct ListItem + { + core::stringw Text; + s32 Icon = -1; + + // A multicolor extension + struct ListItemOverrideColor + { + bool Use = false; + video::SColor Color; + }; + ListItemOverrideColor OverrideColors[EGUI_LBC_COUNT]{}; + }; + + void recalculateItemHeight(); + void selectNew(s32 ypos, bool onlyHover = false); + void recalculateScrollPos(); + void updateScrollBarSize(s32 size); + + // extracted that function to avoid copy&paste code + void recalculateItemWidth(s32 icon); + + // get labels used for serialization + bool getSerializationLabels(EGUI_LISTBOX_COLOR colorType, core::stringc &useColorLabel, core::stringc &colorLabel) const; + + core::array Items; + s32 Selected; + s32 ItemHeight; + s32 ItemHeightOverride; + s32 TotalItemHeight; + s32 ItemsIconWidth; + gui::IGUIFont *Font; + gui::IGUISpriteBank *IconBank; + gui::IGUIScrollBar *ScrollBar; + u32 selectTime; + u32 LastKeyTime; + core::stringw KeyBuffer; + bool Selecting; + bool DrawBack; + bool MoveOverSelect; + bool AutoScroll; + bool HighlightWhenNotFocused; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIScrollBar.cpp b/irr/src/CGUIScrollBar.cpp new file mode 100644 index 000000000..f9ebad09e --- /dev/null +++ b/irr/src/CGUIScrollBar.cpp @@ -0,0 +1,463 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIScrollBar.h" + +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "CGUIButton.h" +#include "IGUIFont.h" +#include "IGUIFontBitmap.h" +#include "os.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIScrollBar::CGUIScrollBar(bool horizontal, IGUIEnvironment *environment, + IGUIElement *parent, s32 id, + core::rect rectangle, bool noclip) : + IGUIScrollBar(environment, parent, id, rectangle), + UpButton(0), + DownButton(0), Dragging(false), Horizontal(horizontal), + DraggedBySlider(false), TrayClick(false), Pos(0), DrawPos(0), + DrawHeight(0), Min(0), Max(100), SmallStep(10), LargeStep(50), DesiredPos(0), + LastChange(0) +{ +#ifdef _DEBUG + setDebugName("CGUIScrollBar"); +#endif + + refreshControls(); + + setNotClipped(noclip); + + // this element can be tabbed to + setTabStop(true); + setTabOrder(-1); + + setPos(0); +} + +//! destructor +CGUIScrollBar::~CGUIScrollBar() +{ + if (UpButton) + UpButton->drop(); + + if (DownButton) + DownButton->drop(); +} + +//! called if an event happened. +bool CGUIScrollBar::OnEvent(const SEvent &event) +{ + if (isEnabled()) { + + switch (event.EventType) { + case EET_KEY_INPUT_EVENT: + if (event.KeyInput.PressedDown) { + const s32 oldPos = Pos; + bool absorb = true; + switch (event.KeyInput.Key) { + case KEY_LEFT: + case KEY_UP: + setPos(Pos - SmallStep); + break; + case KEY_RIGHT: + case KEY_DOWN: + setPos(Pos + SmallStep); + break; + case KEY_HOME: + setPos(Min); + break; + case KEY_PRIOR: + setPos(Pos - LargeStep); + break; + case KEY_END: + setPos(Max); + break; + case KEY_NEXT: + setPos(Pos + LargeStep); + break; + default: + absorb = false; + } + + if (Pos != oldPos) { + SEvent newEvent; + newEvent.EventType = EET_GUI_EVENT; + newEvent.GUIEvent.Caller = this; + newEvent.GUIEvent.Element = 0; + newEvent.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; + Parent->OnEvent(newEvent); + } + if (absorb) + return true; + } + break; + case EET_GUI_EVENT: + if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED) { + if (event.GUIEvent.Caller == UpButton) + setPos(Pos - SmallStep); + else if (event.GUIEvent.Caller == DownButton) + setPos(Pos + SmallStep); + + SEvent newEvent; + newEvent.EventType = EET_GUI_EVENT; + newEvent.GUIEvent.Caller = this; + newEvent.GUIEvent.Element = 0; + newEvent.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; + Parent->OnEvent(newEvent); + + return true; + } else if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) { + if (event.GUIEvent.Caller == this) + Dragging = false; + } + break; + case EET_MOUSE_INPUT_EVENT: { + const core::position2di p(event.MouseInput.X, event.MouseInput.Y); + bool isInside = isPointInside(p); + switch (event.MouseInput.Event) { + case EMIE_MOUSE_WHEEL: + if (Environment->hasFocus(this)) { + // thanks to a bug report by REAPER + // thanks to tommi by tommi for another bugfix + // everybody needs a little thanking. hallo niko!;-) + setPos(getPos() + + ((event.MouseInput.Wheel < 0 ? -1 : 1) * SmallStep * (Horizontal ? 1 : -1))); + + SEvent newEvent; + newEvent.EventType = EET_GUI_EVENT; + newEvent.GUIEvent.Caller = this; + newEvent.GUIEvent.Element = 0; + newEvent.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; + Parent->OnEvent(newEvent); + return true; + } + break; + case EMIE_LMOUSE_PRESSED_DOWN: { + if (isInside) { + Dragging = true; + DraggedBySlider = SliderRect.isPointInside(p); + TrayClick = !DraggedBySlider; + DesiredPos = getPosFromMousePos(p); + return true; + } + break; + } + case EMIE_LMOUSE_LEFT_UP: + case EMIE_MOUSE_MOVED: { + if (!event.MouseInput.isLeftPressed()) + Dragging = false; + + if (!Dragging) { + if (event.MouseInput.Event == EMIE_MOUSE_MOVED) + break; + return isInside; + } + + if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) + Dragging = false; + + const s32 newPos = getPosFromMousePos(p); + const s32 oldPos = Pos; + + if (!DraggedBySlider) { + if (isInside) { + DraggedBySlider = SliderRect.isPointInside(p); + TrayClick = !DraggedBySlider; + } + + if (DraggedBySlider) { + setPos(newPos); + } else { + TrayClick = false; + if (event.MouseInput.Event == EMIE_MOUSE_MOVED) + return isInside; + } + } + + if (DraggedBySlider) { + setPos(newPos); + } else { + DesiredPos = newPos; + } + + if (Pos != oldPos && Parent) { + SEvent newEvent; + newEvent.EventType = EET_GUI_EVENT; + newEvent.GUIEvent.Caller = this; + newEvent.GUIEvent.Element = 0; + newEvent.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; + Parent->OnEvent(newEvent); + } + return isInside; + } break; + + default: + break; + } + } break; + default: + break; + } + } + + return IGUIElement::OnEvent(event); +} + +void CGUIScrollBar::OnPostRender(u32 timeMs) +{ + if (Dragging && !DraggedBySlider && TrayClick && timeMs > LastChange + 200) { + LastChange = timeMs; + + const s32 oldPos = Pos; + + if (DesiredPos >= Pos + LargeStep) + setPos(Pos + LargeStep); + else if (DesiredPos <= Pos - LargeStep) + setPos(Pos - LargeStep); + else if (DesiredPos >= Pos - LargeStep && DesiredPos <= Pos + LargeStep) + setPos(DesiredPos); + + if (Pos != oldPos && Parent) { + SEvent newEvent; + newEvent.EventType = EET_GUI_EVENT; + newEvent.GUIEvent.Caller = this; + newEvent.GUIEvent.Element = 0; + newEvent.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; + Parent->OnEvent(newEvent); + } + } +} + +//! draws the element and its children +void CGUIScrollBar::draw() +{ + if (!IsVisible) + return; + + IGUISkin *skin = Environment->getSkin(); + if (!skin) + return; + + video::SColor iconColor = skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL); + if (iconColor != CurrentIconColor) { + refreshControls(); + } + + SliderRect = AbsoluteRect; + + // draws the background + skin->draw2DRectangle(this, skin->getColor(EGDC_SCROLLBAR), SliderRect, &AbsoluteClippingRect); + + if (core::isnotzero(range())) { + // recalculate slider rectangle + if (Horizontal) { + SliderRect.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X + DrawPos + RelativeRect.getHeight() - DrawHeight / 2; + SliderRect.LowerRightCorner.X = SliderRect.UpperLeftCorner.X + DrawHeight; + } else { + SliderRect.UpperLeftCorner.Y = AbsoluteRect.UpperLeftCorner.Y + DrawPos + RelativeRect.getWidth() - DrawHeight / 2; + SliderRect.LowerRightCorner.Y = SliderRect.UpperLeftCorner.Y + DrawHeight; + } + + skin->draw3DButtonPaneStandard(this, SliderRect, &AbsoluteClippingRect); + } + + // draw buttons + IGUIElement::draw(); +} + +void CGUIScrollBar::updateAbsolutePosition() +{ + IGUIElement::updateAbsolutePosition(); + // todo: properly resize + refreshControls(); + setPos(Pos); +} + +//! +s32 CGUIScrollBar::getPosFromMousePos(const core::position2di &pos) const +{ + f32 w, p; + if (Horizontal) { + w = RelativeRect.getWidth() - f32(RelativeRect.getHeight()) * 3.0f; + p = pos.X - AbsoluteRect.UpperLeftCorner.X - RelativeRect.getHeight() * 1.5f; + } else { + w = RelativeRect.getHeight() - f32(RelativeRect.getWidth()) * 3.0f; + p = pos.Y - AbsoluteRect.UpperLeftCorner.Y - RelativeRect.getWidth() * 1.5f; + } + return (s32)(p / w * range()) + Min; +} + +//! sets the position of the scrollbar +void CGUIScrollBar::setPos(s32 pos) +{ + Pos = core::s32_clamp(pos, Min, Max); + + if (core::isnotzero(range())) { + if (Horizontal) { + f32 f = (RelativeRect.getWidth() - ((f32)RelativeRect.getHeight() * 3.0f)) / range(); + DrawPos = (s32)(((Pos - Min) * f) + ((f32)RelativeRect.getHeight() * 0.5f)); + DrawHeight = RelativeRect.getHeight(); + } else { + f32 f = (RelativeRect.getHeight() - ((f32)RelativeRect.getWidth() * 3.0f)) / range(); + + DrawPos = (s32)(((Pos - Min) * f) + ((f32)RelativeRect.getWidth() * 0.5f)); + DrawHeight = RelativeRect.getWidth(); + } + } +} + +//! gets the small step value +s32 CGUIScrollBar::getSmallStep() const +{ + return SmallStep; +} + +//! sets the small step value +void CGUIScrollBar::setSmallStep(s32 step) +{ + if (step > 0) + SmallStep = step; + else + SmallStep = 10; +} + +//! gets the small step value +s32 CGUIScrollBar::getLargeStep() const +{ + return LargeStep; +} + +//! sets the small step value +void CGUIScrollBar::setLargeStep(s32 step) +{ + if (step > 0) + LargeStep = step; + else + LargeStep = 50; +} + +//! gets the maximum value of the scrollbar. +s32 CGUIScrollBar::getMax() const +{ + return Max; +} + +//! sets the maximum value of the scrollbar. +void CGUIScrollBar::setMax(s32 max) +{ + Max = max; + if (Min > Max) + Min = Max; + + bool enable = core::isnotzero(range()); + UpButton->setEnabled(enable); + DownButton->setEnabled(enable); + setPos(Pos); +} + +//! gets the minimum value of the scrollbar. +s32 CGUIScrollBar::getMin() const +{ + return Min; +} + +//! sets the minimum value of the scrollbar. +void CGUIScrollBar::setMin(s32 min) +{ + Min = min; + if (Max < Min) + Max = Min; + + bool enable = core::isnotzero(range()); + UpButton->setEnabled(enable); + DownButton->setEnabled(enable); + setPos(Pos); +} + +//! gets the current position of the scrollbar +s32 CGUIScrollBar::getPos() const +{ + return Pos; +} + +//! refreshes the position and text on child buttons +void CGUIScrollBar::refreshControls() +{ + CurrentIconColor = video::SColor(255, 255, 255, 255); + + IGUISkin *skin = Environment->getSkin(); + IGUISpriteBank *sprites = 0; + + if (skin) { + sprites = skin->getSpriteBank(); + CurrentIconColor = skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL); + } + + if (Horizontal) { + const s32 h = RelativeRect.getHeight(); + const s32 w = (h < RelativeRect.getWidth() / 2) ? h : RelativeRect.getWidth() / 2; + if (!UpButton) { + UpButton = new CGUIButton(Environment, this, -1, core::rect(0, 0, w, h), NoClip); + UpButton->setSubElement(true); + UpButton->setTabStop(false); + } + if (sprites) { + UpButton->setSpriteBank(sprites); + UpButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_LEFT), CurrentIconColor); + UpButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_LEFT), CurrentIconColor); + } + UpButton->setRelativePosition(core::rect(0, 0, w, h)); + UpButton->setAlignment(EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + if (!DownButton) { + DownButton = new CGUIButton(Environment, this, -1, core::rect(RelativeRect.getWidth() - w, 0, RelativeRect.getWidth(), h), NoClip); + DownButton->setSubElement(true); + DownButton->setTabStop(false); + } + if (sprites) { + DownButton->setSpriteBank(sprites); + DownButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_RIGHT), CurrentIconColor); + DownButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_RIGHT), CurrentIconColor); + } + DownButton->setRelativePosition(core::rect(RelativeRect.getWidth() - w, 0, RelativeRect.getWidth(), h)); + DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + } else { + const s32 w = RelativeRect.getWidth(); + const s32 h = (w < RelativeRect.getHeight() / 2) ? w : RelativeRect.getHeight() / 2; + if (!UpButton) { + UpButton = new CGUIButton(Environment, this, -1, core::rect(0, 0, w, h), NoClip); + UpButton->setSubElement(true); + UpButton->setTabStop(false); + } + if (sprites) { + UpButton->setSpriteBank(sprites); + UpButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_UP), CurrentIconColor); + UpButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_UP), CurrentIconColor); + } + UpButton->setRelativePosition(core::rect(0, 0, w, h)); + UpButton->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + if (!DownButton) { + DownButton = new CGUIButton(Environment, this, -1, core::rect(0, RelativeRect.getHeight() - h, w, RelativeRect.getHeight()), NoClip); + DownButton->setSubElement(true); + DownButton->setTabStop(false); + } + if (sprites) { + DownButton->setSpriteBank(sprites); + DownButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_DOWN), CurrentIconColor); + DownButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_DOWN), CurrentIconColor); + } + DownButton->setRelativePosition(core::rect(0, RelativeRect.getHeight() - h, w, RelativeRect.getHeight())); + DownButton->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT); + } +} + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIScrollBar.h b/irr/src/CGUIScrollBar.h new file mode 100644 index 000000000..82c5c5c26 --- /dev/null +++ b/irr/src/CGUIScrollBar.h @@ -0,0 +1,95 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIScrollBar.h" +#include "IGUIButton.h" + +namespace irr +{ +namespace gui +{ + +class CGUIScrollBar : public IGUIScrollBar +{ +public: + //! constructor + CGUIScrollBar(bool horizontal, IGUIEnvironment *environment, + IGUIElement *parent, s32 id, core::rect rectangle, + bool noclip = false); + + //! destructor + virtual ~CGUIScrollBar(); + + //! called if an event happened. + bool OnEvent(const SEvent &event) override; + + //! draws the element and its children + void draw() override; + + void OnPostRender(u32 timeMs) override; + + //! gets the maximum value of the scrollbar. + s32 getMax() const override; + + //! sets the maximum value of the scrollbar. + void setMax(s32 max) override; + + //! gets the minimum value of the scrollbar. + s32 getMin() const override; + + //! sets the minimum value of the scrollbar. + void setMin(s32 min) override; + + //! gets the small step value + s32 getSmallStep() const override; + + //! sets the small step value + void setSmallStep(s32 step) override; + + //! gets the large step value + s32 getLargeStep() const override; + + //! sets the large step value + void setLargeStep(s32 step) override; + + //! gets the current position of the scrollbar + s32 getPos() const override; + + //! sets the position of the scrollbar + void setPos(s32 pos) override; + + //! updates the rectangle + void updateAbsolutePosition() override; + +private: + void refreshControls(); + s32 getPosFromMousePos(const core::position2di &p) const; + + IGUIButton *UpButton; + IGUIButton *DownButton; + + core::rect SliderRect; + + bool Dragging; + bool Horizontal; + bool DraggedBySlider; + bool TrayClick; + s32 Pos; + s32 DrawPos; + s32 DrawHeight; + s32 Min; + s32 Max; + s32 SmallStep; + s32 LargeStep; + s32 DesiredPos; + u32 LastChange; + video::SColor CurrentIconColor; + + f32 range() const { return (f32)(Max - Min); } +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUISkin.cpp b/irr/src/CGUISkin.cpp new file mode 100644 index 000000000..84ceaeabf --- /dev/null +++ b/irr/src/CGUISkin.cpp @@ -0,0 +1,891 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUISkin.h" + +#include "IGUIFont.h" +#include "IGUISpriteBank.h" +#include "IGUIElement.h" +#include "IVideoDriver.h" +#include "IAttributes.h" + +namespace irr +{ +namespace gui +{ + +CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver *driver) : + SpriteBank(0), Driver(driver), Type(type) +{ +#ifdef _DEBUG + setDebugName("CGUISkin"); +#endif + + if ((Type == EGST_WINDOWS_CLASSIC) || (Type == EGST_WINDOWS_METALLIC)) { + Colors[EGDC_3D_DARK_SHADOW] = video::SColor(101, 50, 50, 50); + Colors[EGDC_3D_SHADOW] = video::SColor(101, 130, 130, 130); + Colors[EGDC_3D_FACE] = video::SColor(101, 210, 210, 210); + Colors[EGDC_3D_HIGH_LIGHT] = video::SColor(101, 255, 255, 255); + Colors[EGDC_3D_LIGHT] = video::SColor(101, 210, 210, 210); + Colors[EGDC_ACTIVE_BORDER] = video::SColor(101, 16, 14, 115); + Colors[EGDC_ACTIVE_CAPTION] = video::SColor(255, 255, 255, 255); + Colors[EGDC_APP_WORKSPACE] = video::SColor(101, 100, 100, 100); + Colors[EGDC_BUTTON_TEXT] = video::SColor(240, 10, 10, 10); + Colors[EGDC_GRAY_TEXT] = video::SColor(240, 130, 130, 130); + Colors[EGDC_HIGH_LIGHT] = video::SColor(101, 8, 36, 107); + Colors[EGDC_HIGH_LIGHT_TEXT] = video::SColor(240, 255, 255, 255); + Colors[EGDC_INACTIVE_BORDER] = video::SColor(101, 165, 165, 165); + Colors[EGDC_INACTIVE_CAPTION] = video::SColor(255, 30, 30, 30); + Colors[EGDC_TOOLTIP] = video::SColor(200, 0, 0, 0); + Colors[EGDC_TOOLTIP_BACKGROUND] = video::SColor(200, 255, 255, 225); + Colors[EGDC_SCROLLBAR] = video::SColor(101, 230, 230, 230); + Colors[EGDC_WINDOW] = video::SColor(101, 255, 255, 255); + Colors[EGDC_WINDOW_SYMBOL] = video::SColor(200, 10, 10, 10); + Colors[EGDC_ICON] = video::SColor(200, 255, 255, 255); + Colors[EGDC_ICON_HIGH_LIGHT] = video::SColor(200, 8, 36, 107); + Colors[EGDC_GRAY_WINDOW_SYMBOL] = video::SColor(240, 100, 100, 100); + Colors[EGDC_EDITABLE] = video::SColor(255, 255, 255, 255); + Colors[EGDC_GRAY_EDITABLE] = video::SColor(255, 120, 120, 120); + Colors[EGDC_FOCUSED_EDITABLE] = video::SColor(255, 240, 240, 255); + + Sizes[EGDS_SCROLLBAR_SIZE] = 14; + Sizes[EGDS_MENU_HEIGHT] = 30; + Sizes[EGDS_WINDOW_BUTTON_WIDTH] = 15; + Sizes[EGDS_CHECK_BOX_WIDTH] = 18; + Sizes[EGDS_MESSAGE_BOX_WIDTH] = 500; + Sizes[EGDS_MESSAGE_BOX_HEIGHT] = 200; + Sizes[EGDS_BUTTON_WIDTH] = 80; + Sizes[EGDS_BUTTON_HEIGHT] = 30; + + Sizes[EGDS_TEXT_DISTANCE_X] = 2; + Sizes[EGDS_TEXT_DISTANCE_Y] = 0; + + Sizes[EGDS_TITLEBARTEXT_DISTANCE_X] = 2; + Sizes[EGDS_TITLEBARTEXT_DISTANCE_Y] = 0; + } else { + // 0x80a6a8af + Colors[EGDC_3D_DARK_SHADOW] = 0x60767982; + // Colors[EGDC_3D_FACE] = 0xc0c9ccd4; // tab background + Colors[EGDC_3D_FACE] = 0xc0cbd2d9; // tab background + Colors[EGDC_3D_SHADOW] = 0x50e4e8f1; // tab background, and left-top highlight + Colors[EGDC_3D_HIGH_LIGHT] = 0x40c7ccdc; + Colors[EGDC_3D_LIGHT] = 0x802e313a; + Colors[EGDC_ACTIVE_BORDER] = 0x80404040; // window title + Colors[EGDC_ACTIVE_CAPTION] = 0xffd0d0d0; + Colors[EGDC_APP_WORKSPACE] = 0xc0646464; // unused + Colors[EGDC_BUTTON_TEXT] = 0xd0161616; + Colors[EGDC_GRAY_TEXT] = 0x3c141414; + Colors[EGDC_HIGH_LIGHT] = 0x6c606060; + Colors[EGDC_HIGH_LIGHT_TEXT] = 0xd0e0e0e0; + Colors[EGDC_INACTIVE_BORDER] = 0xf0a5a5a5; + Colors[EGDC_INACTIVE_CAPTION] = 0xffd2d2d2; + Colors[EGDC_TOOLTIP] = 0xf00f2033; + Colors[EGDC_TOOLTIP_BACKGROUND] = 0xc0cbd2d9; + Colors[EGDC_SCROLLBAR] = 0xf0e0e0e0; + Colors[EGDC_WINDOW] = 0xf0f0f0f0; + Colors[EGDC_WINDOW_SYMBOL] = 0xd0161616; + Colors[EGDC_ICON] = 0xd0161616; + Colors[EGDC_ICON_HIGH_LIGHT] = 0xd0606060; + Colors[EGDC_GRAY_WINDOW_SYMBOL] = 0x3c101010; + Colors[EGDC_EDITABLE] = 0xf0ffffff; + Colors[EGDC_GRAY_EDITABLE] = 0xf0cccccc; + Colors[EGDC_FOCUSED_EDITABLE] = 0xf0fffff0; + + Sizes[EGDS_SCROLLBAR_SIZE] = 14; + Sizes[EGDS_MENU_HEIGHT] = 48; + Sizes[EGDS_WINDOW_BUTTON_WIDTH] = 15; + Sizes[EGDS_CHECK_BOX_WIDTH] = 18; + Sizes[EGDS_MESSAGE_BOX_WIDTH] = 500; + Sizes[EGDS_MESSAGE_BOX_HEIGHT] = 200; + Sizes[EGDS_BUTTON_WIDTH] = 80; + Sizes[EGDS_BUTTON_HEIGHT] = 30; + + Sizes[EGDS_TEXT_DISTANCE_X] = 3; + Sizes[EGDS_TEXT_DISTANCE_Y] = 2; + + Sizes[EGDS_TITLEBARTEXT_DISTANCE_X] = 3; + Sizes[EGDS_TITLEBARTEXT_DISTANCE_Y] = 2; + } + + Sizes[EGDS_MESSAGE_BOX_GAP_SPACE] = 15; + Sizes[EGDS_MESSAGE_BOX_MIN_TEXT_WIDTH] = 0; + Sizes[EGDS_MESSAGE_BOX_MAX_TEXT_WIDTH] = 500; + Sizes[EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT] = 0; + Sizes[EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT] = 99999; + + Sizes[EGDS_BUTTON_PRESSED_IMAGE_OFFSET_X] = 1; + Sizes[EGDS_BUTTON_PRESSED_IMAGE_OFFSET_Y] = 1; + Sizes[EGDS_BUTTON_PRESSED_TEXT_OFFSET_X] = 0; + Sizes[EGDS_BUTTON_PRESSED_TEXT_OFFSET_Y] = 2; + Sizes[EGDS_BUTTON_PRESSED_SPRITE_OFFSET_X] = 0; + Sizes[EGDS_BUTTON_PRESSED_SPRITE_OFFSET_Y] = 0; + + Texts[EGDT_MSG_BOX_OK] = L"OK"; + Texts[EGDT_MSG_BOX_CANCEL] = L"Cancel"; + Texts[EGDT_MSG_BOX_YES] = L"Yes"; + Texts[EGDT_MSG_BOX_NO] = L"No"; + Texts[EGDT_WINDOW_CLOSE] = L"Close"; + Texts[EGDT_WINDOW_RESTORE] = L"Restore"; + Texts[EGDT_WINDOW_MINIMIZE] = L"Minimize"; + Texts[EGDT_WINDOW_MAXIMIZE] = L"Maximize"; + + Icons[EGDI_WINDOW_MAXIMIZE] = 225; + Icons[EGDI_WINDOW_RESTORE] = 226; + Icons[EGDI_WINDOW_CLOSE] = 227; + Icons[EGDI_WINDOW_MINIMIZE] = 228; + Icons[EGDI_CURSOR_UP] = 229; + Icons[EGDI_CURSOR_DOWN] = 230; + Icons[EGDI_CURSOR_LEFT] = 231; + Icons[EGDI_CURSOR_RIGHT] = 232; + Icons[EGDI_MENU_MORE] = 232; + Icons[EGDI_CHECK_BOX_CHECKED] = 233; + Icons[EGDI_DROP_DOWN] = 234; + Icons[EGDI_SMALL_CURSOR_UP] = 235; + Icons[EGDI_SMALL_CURSOR_DOWN] = 236; + Icons[EGDI_RADIO_BUTTON_CHECKED] = 237; + Icons[EGDI_MORE_LEFT] = 238; + Icons[EGDI_MORE_RIGHT] = 239; + Icons[EGDI_MORE_UP] = 240; + Icons[EGDI_MORE_DOWN] = 241; + Icons[EGDI_WINDOW_RESIZE] = 242; + Icons[EGDI_EXPAND] = 243; + Icons[EGDI_COLLAPSE] = 244; + + Icons[EGDI_FILE] = 245; + Icons[EGDI_DIRECTORY] = 246; + + for (u32 i = 0; i < EGDF_COUNT; ++i) + Fonts[i] = 0; + + UseGradient = (Type == EGST_WINDOWS_METALLIC) || (Type == EGST_BURNING_SKIN); +} + +//! destructor +CGUISkin::~CGUISkin() +{ + for (u32 i = 0; i < EGDF_COUNT; ++i) { + if (Fonts[i]) + Fonts[i]->drop(); + } + + if (SpriteBank) + SpriteBank->drop(); +} + +//! returns default color +video::SColor CGUISkin::getColor(EGUI_DEFAULT_COLOR color) const +{ + if ((u32)color < EGDC_COUNT) + return Colors[color]; + else + return video::SColor(); +} + +//! sets a default color +void CGUISkin::setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor) +{ + if ((u32)which < EGDC_COUNT) + Colors[which] = newColor; +} + +//! returns size for the given size type +s32 CGUISkin::getSize(EGUI_DEFAULT_SIZE size) const +{ + if ((u32)size < EGDS_COUNT) + return Sizes[size]; + else + return 0; +} + +//! sets a default size +void CGUISkin::setSize(EGUI_DEFAULT_SIZE which, s32 size) +{ + if ((u32)which < EGDS_COUNT) + Sizes[which] = size; +} + +//! returns the default font +IGUIFont *CGUISkin::getFont(EGUI_DEFAULT_FONT which) const +{ + if (((u32)which < EGDF_COUNT) && Fonts[which]) + return Fonts[which]; + else + return Fonts[EGDF_DEFAULT]; +} + +//! sets a default font +void CGUISkin::setFont(IGUIFont *font, EGUI_DEFAULT_FONT which) +{ + if ((u32)which >= EGDF_COUNT) + return; + + if (font) { + font->grab(); + if (Fonts[which]) + Fonts[which]->drop(); + + Fonts[which] = font; + } +} + +//! gets the sprite bank stored +IGUISpriteBank *CGUISkin::getSpriteBank() const +{ + return SpriteBank; +} + +//! set a new sprite bank or remove one by passing 0 +void CGUISkin::setSpriteBank(IGUISpriteBank *bank) +{ + if (bank) + bank->grab(); + + if (SpriteBank) + SpriteBank->drop(); + + SpriteBank = bank; +} + +//! Returns a default icon +u32 CGUISkin::getIcon(EGUI_DEFAULT_ICON icon) const +{ + if ((u32)icon < EGDI_COUNT) + return Icons[icon]; + else + return 0; +} + +//! Sets a default icon +void CGUISkin::setIcon(EGUI_DEFAULT_ICON icon, u32 index) +{ + if ((u32)icon < EGDI_COUNT) + Icons[icon] = index; +} + +//! Returns a default text. For example for Message box button captions: +//! "OK", "Cancel", "Yes", "No" and so on. +const wchar_t *CGUISkin::getDefaultText(EGUI_DEFAULT_TEXT text) const +{ + if ((u32)text < EGDT_COUNT) + return Texts[text].c_str(); + else + return Texts[0].c_str(); +} + +//! Sets a default text. For example for Message box button captions: +//! "OK", "Cancel", "Yes", "No" and so on. +void CGUISkin::setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t *newText) +{ + if ((u32)which < EGDT_COUNT) + Texts[which] = newText; +} + +//! draws a standard 3d button pane +/** Used for drawing for example buttons in normal state. +It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and +EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. +\param rect: Defining area where to draw. +\param clip: Clip area. +\param element: Pointer to the element which wishes to draw this. This parameter +is usually not used by ISkin, but can be used for example by more complex +implementations to find out how to draw the part exactly. */ +void CGUISkin::draw3DButtonPaneStandard(IGUIElement *element, + const core::rect &r, + const core::rect *clip) +{ + if (!Driver) + return; + + core::rect rect = r; + + if (Type == EGST_BURNING_SKIN) { + rect.UpperLeftCorner.X -= 1; + rect.UpperLeftCorner.Y -= 1; + rect.LowerRightCorner.X += 1; + rect.LowerRightCorner.Y += 1; + draw3DSunkenPane(element, + getColor(EGDC_WINDOW).getInterpolated(0xFFFFFFFF, 0.9f), false, true, rect, clip); + return; + } + + Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); + + rect.LowerRightCorner.X -= 1; + rect.LowerRightCorner.Y -= 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); + + rect.UpperLeftCorner.X += 1; + rect.UpperLeftCorner.Y += 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); + + rect.LowerRightCorner.X -= 1; + rect.LowerRightCorner.Y -= 1; + + if (!UseGradient) { + Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip); + } else { + const video::SColor c1 = getColor(EGDC_3D_FACE); + const video::SColor c2 = c1.getInterpolated(getColor(EGDC_3D_DARK_SHADOW), 0.4f); + Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); + } +} + +//! draws a pressed 3d button pane +/** Used for drawing for example buttons in pressed state. +It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and +EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. +\param rect: Defining area where to draw. +\param clip: Clip area. +\param element: Pointer to the element which wishes to draw this. This parameter +is usually not used by ISkin, but can be used for example by more complex +implementations to find out how to draw the part exactly. */ +void CGUISkin::draw3DButtonPanePressed(IGUIElement *element, + const core::rect &r, + const core::rect *clip) +{ + if (!Driver) + return; + + core::rect rect = r; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); + + rect.LowerRightCorner.X -= 1; + rect.LowerRightCorner.Y -= 1; + Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); + + rect.UpperLeftCorner.X += 1; + rect.UpperLeftCorner.Y += 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); + + rect.UpperLeftCorner.X += 1; + rect.UpperLeftCorner.Y += 1; + + if (!UseGradient) { + Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip); + } else { + const video::SColor c1 = getColor(EGDC_3D_FACE); + const video::SColor c2 = c1.getInterpolated(getColor(EGDC_3D_DARK_SHADOW), 0.4f); + Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); + } +} + +//! draws a sunken 3d pane +/** Used for drawing the background of edit, combo or check boxes. +\param element: Pointer to the element which wishes to draw this. This parameter +is usually not used by ISkin, but can be used for example by more complex +implementations to find out how to draw the part exactly. +\param bgcolor: Background color. +\param flat: Specifies if the sunken pane should be flat or displayed as sunken +deep into the ground. +\param rect: Defining area where to draw. +\param clip: Clip area. */ +void CGUISkin::draw3DSunkenPane(IGUIElement *element, video::SColor bgcolor, + bool flat, bool fillBackGround, + const core::rect &r, + const core::rect *clip) +{ + if (!Driver) + return; + + core::rect rect = r; + + if (fillBackGround) + Driver->draw2DRectangle(bgcolor, rect, clip); + + if (flat) { + // draw flat sunken pane + + rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); // top + + ++rect.UpperLeftCorner.Y; + rect.LowerRightCorner.Y = r.LowerRightCorner.Y; + rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); // left + + rect = r; + ++rect.UpperLeftCorner.Y; + rect.UpperLeftCorner.X = rect.LowerRightCorner.X - 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); // right + + rect = r; + ++rect.UpperLeftCorner.X; + rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1; + --rect.LowerRightCorner.X; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); // bottom + } else { + // draw deep sunken pane + rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); // top + ++rect.UpperLeftCorner.X; + ++rect.UpperLeftCorner.Y; + --rect.LowerRightCorner.X; + ++rect.LowerRightCorner.Y; + Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); + + rect.UpperLeftCorner.X = r.UpperLeftCorner.X; + rect.UpperLeftCorner.Y = r.UpperLeftCorner.Y + 1; + rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1; + rect.LowerRightCorner.Y = r.LowerRightCorner.Y; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); // left + ++rect.UpperLeftCorner.X; + ++rect.UpperLeftCorner.Y; + ++rect.LowerRightCorner.X; + --rect.LowerRightCorner.Y; + Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); + + rect = r; + rect.UpperLeftCorner.X = rect.LowerRightCorner.X - 1; + ++rect.UpperLeftCorner.Y; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); // right + --rect.UpperLeftCorner.X; + ++rect.UpperLeftCorner.Y; + --rect.LowerRightCorner.X; + --rect.LowerRightCorner.Y; + Driver->draw2DRectangle(getColor(EGDC_3D_LIGHT), rect, clip); + + rect = r; + ++rect.UpperLeftCorner.X; + rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1; + --rect.LowerRightCorner.X; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); // bottom + ++rect.UpperLeftCorner.X; + --rect.UpperLeftCorner.Y; + --rect.LowerRightCorner.X; + --rect.LowerRightCorner.Y; + Driver->draw2DRectangle(getColor(EGDC_3D_LIGHT), rect, clip); + } +} + +//! draws a window background +// return where to draw title bar text. +core::rect CGUISkin::draw3DWindowBackground(IGUIElement *element, + bool drawTitleBar, video::SColor titleBarColor, + const core::rect &r, + const core::rect *clip, + core::rect *checkClientArea) +{ + if (!Driver) { + if (checkClientArea) { + *checkClientArea = r; + } + return r; + } + + core::rect rect = r; + + // top border + rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1; + if (!checkClientArea) { + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); + } + + // left border + rect.LowerRightCorner.Y = r.LowerRightCorner.Y; + rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1; + if (!checkClientArea) { + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); + } + + // right border dark outer line + rect.UpperLeftCorner.X = r.LowerRightCorner.X - 1; + rect.LowerRightCorner.X = r.LowerRightCorner.X; + rect.UpperLeftCorner.Y = r.UpperLeftCorner.Y; + rect.LowerRightCorner.Y = r.LowerRightCorner.Y; + if (!checkClientArea) { + Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); + } + + // right border bright innner line + rect.UpperLeftCorner.X -= 1; + rect.LowerRightCorner.X -= 1; + rect.UpperLeftCorner.Y += 1; + rect.LowerRightCorner.Y -= 1; + if (!checkClientArea) { + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); + } + + // bottom border dark outer line + rect.UpperLeftCorner.X = r.UpperLeftCorner.X; + rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1; + rect.LowerRightCorner.Y = r.LowerRightCorner.Y; + rect.LowerRightCorner.X = r.LowerRightCorner.X; + if (!checkClientArea) { + Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); + } + + // bottom border bright inner line + rect.UpperLeftCorner.X += 1; + rect.LowerRightCorner.X -= 1; + rect.UpperLeftCorner.Y -= 1; + rect.LowerRightCorner.Y -= 1; + if (!checkClientArea) { + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); + } + + // client area for background + rect = r; + rect.UpperLeftCorner.X += 1; + rect.UpperLeftCorner.Y += 1; + rect.LowerRightCorner.X -= 2; + rect.LowerRightCorner.Y -= 2; + if (checkClientArea) { + *checkClientArea = rect; + } + + if (!checkClientArea) { + if (!UseGradient) { + Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip); + } else if (Type == EGST_BURNING_SKIN) { + const video::SColor c1 = getColor(EGDC_WINDOW).getInterpolated(0xFFFFFFFF, 0.9f); + const video::SColor c2 = getColor(EGDC_WINDOW).getInterpolated(0xFFFFFFFF, 0.8f); + + Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); + } else { + const video::SColor c2 = getColor(EGDC_3D_SHADOW); + const video::SColor c1 = getColor(EGDC_3D_FACE); + Driver->draw2DRectangle(rect, c1, c1, c1, c2, clip); + } + } + + // title bar + rect = r; + rect.UpperLeftCorner.X += 2; + rect.UpperLeftCorner.Y += 2; + rect.LowerRightCorner.X -= 2; + rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + getSize(EGDS_WINDOW_BUTTON_WIDTH) + 2; + + if (drawTitleBar) { + if (checkClientArea) { + (*checkClientArea).UpperLeftCorner.Y = rect.LowerRightCorner.Y; + } else { + // draw title bar + // if (!UseGradient) + // Driver->draw2DRectangle(titleBarColor, rect, clip); + // else + if (Type == EGST_BURNING_SKIN) { + const video::SColor c = titleBarColor.getInterpolated(video::SColor(titleBarColor.getAlpha(), 255, 255, 255), 0.8f); + Driver->draw2DRectangle(rect, titleBarColor, titleBarColor, c, c, clip); + } else { + const video::SColor c = titleBarColor.getInterpolated(video::SColor(titleBarColor.getAlpha(), 0, 0, 0), 0.2f); + Driver->draw2DRectangle(rect, titleBarColor, c, titleBarColor, c, clip); + } + } + } + + return rect; +} + +//! draws a standard 3d menu pane +/** Used for drawing for menus and context menus. +It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and +EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. +\param element: Pointer to the element which wishes to draw this. This parameter +is usually not used by ISkin, but can be used for example by more complex +implementations to find out how to draw the part exactly. +\param rect: Defining area where to draw. +\param clip: Clip area. */ +void CGUISkin::draw3DMenuPane(IGUIElement *element, + const core::rect &r, const core::rect *clip) +{ + if (!Driver) + return; + + core::rect rect = r; + + if (Type == EGST_BURNING_SKIN) { + rect.UpperLeftCorner.Y -= 3; + draw3DButtonPaneStandard(element, rect, clip); + return; + } + + // in this skin, this is exactly what non pressed buttons look like, + // so we could simply call + // draw3DButtonPaneStandard(element, rect, clip); + // here. + // but if the skin is transparent, this doesn't look that nice. So + // We draw it a little bit better, with some more draw2DRectangle calls, + // but there aren't that much menus visible anyway. + + rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); + + rect.LowerRightCorner.Y = r.LowerRightCorner.Y; + rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); + + rect.UpperLeftCorner.X = r.LowerRightCorner.X - 1; + rect.LowerRightCorner.X = r.LowerRightCorner.X; + rect.UpperLeftCorner.Y = r.UpperLeftCorner.Y; + rect.LowerRightCorner.Y = r.LowerRightCorner.Y; + Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); + + rect.UpperLeftCorner.X -= 1; + rect.LowerRightCorner.X -= 1; + rect.UpperLeftCorner.Y += 1; + rect.LowerRightCorner.Y -= 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); + + rect.UpperLeftCorner.X = r.UpperLeftCorner.X; + rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1; + rect.LowerRightCorner.Y = r.LowerRightCorner.Y; + rect.LowerRightCorner.X = r.LowerRightCorner.X; + Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip); + + rect.UpperLeftCorner.X += 1; + rect.LowerRightCorner.X -= 1; + rect.UpperLeftCorner.Y -= 1; + rect.LowerRightCorner.Y -= 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); + + rect = r; + rect.UpperLeftCorner.X += 1; + rect.UpperLeftCorner.Y += 1; + rect.LowerRightCorner.X -= 2; + rect.LowerRightCorner.Y -= 2; + + if (!UseGradient) + Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip); + else { + const video::SColor c1 = getColor(EGDC_3D_FACE); + const video::SColor c2 = getColor(EGDC_3D_SHADOW); + Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); + } +} + +//! draws a standard 3d tool bar +/** Used for drawing for toolbars and menus. +\param element: Pointer to the element which wishes to draw this. This parameter +is usually not used by ISkin, but can be used for example by more complex +implementations to find out how to draw the part exactly. +\param rect: Defining area where to draw. +\param clip: Clip area. */ +void CGUISkin::draw3DToolBar(IGUIElement *element, + const core::rect &r, + const core::rect *clip) +{ + if (!Driver) + return; + + core::rect rect = r; + + rect.UpperLeftCorner.X = r.UpperLeftCorner.X; + rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1; + rect.LowerRightCorner.Y = r.LowerRightCorner.Y; + rect.LowerRightCorner.X = r.LowerRightCorner.X; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); + + rect = r; + rect.LowerRightCorner.Y -= 1; + + if (!UseGradient) { + Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip); + } else if (Type == EGST_BURNING_SKIN) { + const video::SColor c1 = 0xF0000000 | getColor(EGDC_3D_FACE).color; + const video::SColor c2 = 0xF0000000 | getColor(EGDC_3D_SHADOW).color; + + rect.LowerRightCorner.Y += 1; + Driver->draw2DRectangle(rect, c1, c2, c1, c2, clip); + } else { + const video::SColor c1 = getColor(EGDC_3D_FACE); + const video::SColor c2 = getColor(EGDC_3D_SHADOW); + Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); + } +} + +//! draws a tab button +/** Used for drawing for tab buttons on top of tabs. +\param element: Pointer to the element which wishes to draw this. This parameter +is usually not used by ISkin, but can be used for example by more complex +implementations to find out how to draw the part exactly. +\param active: Specifies if the tab is currently active. +\param rect: Defining area where to draw. +\param clip: Clip area. */ +void CGUISkin::draw3DTabButton(IGUIElement *element, bool active, + const core::rect &frameRect, const core::rect *clip, EGUI_ALIGNMENT alignment) +{ + if (!Driver) + return; + + core::rect tr = frameRect; + + if (alignment == EGUIA_UPPERLEFT) { + tr.LowerRightCorner.X -= 2; + tr.LowerRightCorner.Y = tr.UpperLeftCorner.Y + 1; + tr.UpperLeftCorner.X += 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); + + // draw left highlight + tr = frameRect; + tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; + tr.UpperLeftCorner.Y += 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); + + // draw grey background + tr = frameRect; + tr.UpperLeftCorner.X += 1; + tr.UpperLeftCorner.Y += 1; + tr.LowerRightCorner.X -= 2; + Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip); + + // draw right middle gray shadow + tr.LowerRightCorner.X += 1; + tr.UpperLeftCorner.X = tr.LowerRightCorner.X - 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); + + tr.LowerRightCorner.X += 1; + tr.UpperLeftCorner.X += 1; + tr.UpperLeftCorner.Y += 1; + Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), tr, clip); + } else { + tr.LowerRightCorner.X -= 2; + tr.UpperLeftCorner.Y = tr.LowerRightCorner.Y - 1; + tr.UpperLeftCorner.X += 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); + + // draw left highlight + tr = frameRect; + tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; + tr.LowerRightCorner.Y -= 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); + + // draw grey background + tr = frameRect; + tr.UpperLeftCorner.X += 1; + tr.UpperLeftCorner.Y -= 1; + tr.LowerRightCorner.X -= 2; + tr.LowerRightCorner.Y -= 1; + Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip); + + // draw right middle gray shadow + tr.LowerRightCorner.X += 1; + tr.UpperLeftCorner.X = tr.LowerRightCorner.X - 1; + // tr.LowerRightCorner.Y -= 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); + + tr.LowerRightCorner.X += 1; + tr.UpperLeftCorner.X += 1; + tr.LowerRightCorner.Y -= 1; + Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), tr, clip); + } +} + +//! draws a tab control body +/** \param element: Pointer to the element which wishes to draw this. This parameter +is usually not used by ISkin, but can be used for example by more complex +implementations to find out how to draw the part exactly. +\param border: Specifies if the border should be drawn. +\param background: Specifies if the background should be drawn. +\param rect: Defining area where to draw. +\param clip: Clip area. */ +void CGUISkin::draw3DTabBody(IGUIElement *element, bool border, bool background, + const core::rect &rect, const core::rect *clip, s32 tabHeight, EGUI_ALIGNMENT alignment) +{ + if (!Driver) + return; + + core::rect tr = rect; + + if (tabHeight == -1) + tabHeight = getSize(gui::EGDS_BUTTON_HEIGHT); + + // draw border. + if (border) { + if (alignment == EGUIA_UPPERLEFT) { + // draw left hightlight + tr.UpperLeftCorner.Y += tabHeight + 2; + tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); + + // draw right shadow + tr.UpperLeftCorner.X = rect.LowerRightCorner.X - 1; + tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); + + // draw lower shadow + tr = rect; + tr.UpperLeftCorner.Y = tr.LowerRightCorner.Y - 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); + } else { + // draw left hightlight + tr.LowerRightCorner.Y -= tabHeight + 2; + tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); + + // draw right shadow + tr.UpperLeftCorner.X = rect.LowerRightCorner.X - 1; + tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); + + // draw lower shadow + tr = rect; + tr.LowerRightCorner.Y = tr.UpperLeftCorner.Y + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); + } + } + + if (background) { + if (alignment == EGUIA_UPPERLEFT) { + tr = rect; + tr.UpperLeftCorner.Y += tabHeight + 2; + tr.LowerRightCorner.X -= 1; + tr.UpperLeftCorner.X += 1; + tr.LowerRightCorner.Y -= 1; + } else { + tr = rect; + tr.UpperLeftCorner.X += 1; + tr.UpperLeftCorner.Y -= 1; + tr.LowerRightCorner.X -= 1; + tr.LowerRightCorner.Y -= tabHeight + 2; + // tr.UpperLeftCorner.X += 1; + } + + if (!UseGradient) + Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip); + else { + video::SColor c1 = getColor(EGDC_3D_FACE); + video::SColor c2 = getColor(EGDC_3D_SHADOW); + Driver->draw2DRectangle(tr, c1, c1, c2, c2, clip); + } + } +} + +//! draws an icon, usually from the skin's sprite bank +/** \param parent: Pointer to the element which wishes to draw this icon. +This parameter is usually not used by IGUISkin, but can be used for example +by more complex implementations to find out how to draw the part exactly. +\param icon: Specifies the icon to be drawn. +\param position: The position to draw the icon +\param starttime: The time at the start of the animation +\param currenttime: The present time, used to calculate the frame number +\param loop: Whether the animation should loop or not +\param clip: Clip area. */ +void CGUISkin::drawIcon(IGUIElement *element, EGUI_DEFAULT_ICON icon, + const core::position2di position, + u32 starttime, u32 currenttime, + bool loop, const core::rect *clip) +{ + if (!SpriteBank) + return; + + bool gray = element && !element->isEnabled(); + SpriteBank->draw2DSprite(Icons[icon], position, clip, + Colors[gray ? EGDC_GRAY_WINDOW_SYMBOL : EGDC_WINDOW_SYMBOL], starttime, currenttime, loop, true); +} + +EGUI_SKIN_TYPE CGUISkin::getType() const +{ + return Type; +} + +//! draws a 2d rectangle. +void CGUISkin::draw2DRectangle(IGUIElement *element, + const video::SColor &color, const core::rect &pos, + const core::rect *clip) +{ + Driver->draw2DRectangle(color, pos, clip); +} + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUISkin.h b/irr/src/CGUISkin.h new file mode 100644 index 000000000..130e5fada --- /dev/null +++ b/irr/src/CGUISkin.h @@ -0,0 +1,226 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUISkin.h" +#include "irrString.h" + +namespace irr +{ +namespace video +{ +class IVideoDriver; +} +namespace gui +{ + +class CGUISkin : public IGUISkin +{ +public: + CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver *driver); + + //! destructor + virtual ~CGUISkin(); + + //! returns default color + video::SColor getColor(EGUI_DEFAULT_COLOR color) const override; + + //! sets a default color + void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor) override; + + //! returns size for the given size type + s32 getSize(EGUI_DEFAULT_SIZE size) const override; + + //! sets a default size + void setSize(EGUI_DEFAULT_SIZE which, s32 size) override; + + //! returns the default font + IGUIFont *getFont(EGUI_DEFAULT_FONT which = EGDF_DEFAULT) const override; + + //! sets a default font + void setFont(IGUIFont *font, EGUI_DEFAULT_FONT which = EGDF_DEFAULT) override; + + //! sets the sprite bank used for drawing icons + void setSpriteBank(IGUISpriteBank *bank) override; + + //! gets the sprite bank used for drawing icons + IGUISpriteBank *getSpriteBank() const override; + + //! Returns a default icon + /** Returns the sprite index within the sprite bank */ + u32 getIcon(EGUI_DEFAULT_ICON icon) const override; + + //! Sets a default icon + /** Sets the sprite index used for drawing icons like arrows, + close buttons and ticks in checkboxes + \param icon: Enum specifying which icon to change + \param index: The sprite index used to draw this icon */ + void setIcon(EGUI_DEFAULT_ICON icon, u32 index) override; + + //! Returns a default text. + /** For example for Message box button captions: + "OK", "Cancel", "Yes", "No" and so on. */ + const wchar_t *getDefaultText(EGUI_DEFAULT_TEXT text) const override; + + //! Sets a default text. + /** For example for Message box button captions: + "OK", "Cancel", "Yes", "No" and so on. */ + void setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t *newText) override; + + //! draws a standard 3d button pane + /** Used for drawing for example buttons in normal state. + It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and + EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. + \param rect: Defining area where to draw. + \param clip: Clip area. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by ISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. */ + virtual void draw3DButtonPaneStandard(IGUIElement *element, + const core::rect &rect, + const core::rect *clip = 0) override; + + //! draws a pressed 3d button pane + /** Used for drawing for example buttons in pressed state. + It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and + EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. + \param rect: Defining area where to draw. + \param clip: Clip area. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by ISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. */ + virtual void draw3DButtonPanePressed(IGUIElement *element, + const core::rect &rect, + const core::rect *clip = 0) override; + + //! draws a sunken 3d pane + /** Used for drawing the background of edit, combo or check boxes. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by ISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param bgcolor: Background color. + \param flat: Specifies if the sunken pane should be flat or displayed as sunken + deep into the ground. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DSunkenPane(IGUIElement *element, + video::SColor bgcolor, bool flat, + bool fillBackGround, + const core::rect &rect, + const core::rect *clip = 0) override; + + //! draws a window background + /** Used for drawing the background of dialogs and windows. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by ISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param titleBarColor: Title color. + \param drawTitleBar: True to enable title drawing. + \param rect: Defining area where to draw. + \param clip: Clip area. + \param checkClientArea: When set to non-null the function will not draw anything, + but will instead return the clientArea which can be used for drawing by the calling window. + That is the area without borders and without titlebar. + \return Returns rect where it would be good to draw title bar text. This will + work even when checkClientArea is set to a non-null value.*/ + virtual core::rect draw3DWindowBackground(IGUIElement *element, + bool drawTitleBar, video::SColor titleBarColor, + const core::rect &rect, + const core::rect *clip, + core::rect *checkClientArea) override; + + //! draws a standard 3d menu pane + /** Used for drawing for menus and context menus. + It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and + EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by ISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DMenuPane(IGUIElement *element, + const core::rect &rect, + const core::rect *clip = 0) override; + + //! draws a standard 3d tool bar + /** Used for drawing for toolbars and menus. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by ISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DToolBar(IGUIElement *element, + const core::rect &rect, + const core::rect *clip = 0) override; + + //! draws a tab button + /** Used for drawing for tab buttons on top of tabs. + \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by ISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param active: Specifies if the tab is currently active. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DTabButton(IGUIElement *element, bool active, + const core::rect &rect, const core::rect *clip = 0, + EGUI_ALIGNMENT alignment = EGUIA_UPPERLEFT) override; + + //! draws a tab control body + /** \param element: Pointer to the element which wishes to draw this. This parameter + is usually not used by ISkin, but can be used for example by more complex + implementations to find out how to draw the part exactly. + \param border: Specifies if the border should be drawn. + \param background: Specifies if the background should be drawn. + \param rect: Defining area where to draw. + \param clip: Clip area. */ + virtual void draw3DTabBody(IGUIElement *element, bool border, bool background, + const core::rect &rect, const core::rect *clip = 0, s32 tabHeight = -1, + EGUI_ALIGNMENT alignment = EGUIA_UPPERLEFT) override; + + //! draws an icon, usually from the skin's sprite bank + /** \param element: Pointer to the element which wishes to draw this icon. + This parameter is usually not used by IGUISkin, but can be used for example + by more complex implementations to find out how to draw the part exactly. + \param icon: Specifies the icon to be drawn. + \param position: The position to draw the icon + \param starttime: The time at the start of the animation + \param currenttime: The present time, used to calculate the frame number + \param loop: Whether the animation should loop or not + \param clip: Clip area. */ + virtual void drawIcon(IGUIElement *element, EGUI_DEFAULT_ICON icon, + const core::position2di position, + u32 starttime = 0, u32 currenttime = 0, + bool loop = false, const core::rect *clip = 0) override; + + //! draws a 2d rectangle. + /** \param element: Pointer to the element which wishes to draw this icon. + This parameter is usually not used by IGUISkin, but can be used for example + by more complex implementations to find out how to draw the part exactly. + \param color: Color of the rectangle to draw. The alpha component specifies how + transparent the rectangle will be. + \param pos: Position of the rectangle. + \param clip: Pointer to rectangle against which the rectangle will be clipped. + If the pointer is null, no clipping will be performed. */ + virtual void draw2DRectangle(IGUIElement *element, const video::SColor &color, + const core::rect &pos, const core::rect *clip = 0) override; + + //! get the type of this skin + EGUI_SKIN_TYPE getType() const override; + +private: + video::SColor Colors[EGDC_COUNT]; + s32 Sizes[EGDS_COUNT]; + u32 Icons[EGDI_COUNT]; + IGUIFont *Fonts[EGDF_COUNT]; + IGUISpriteBank *SpriteBank; + core::stringw Texts[EGDT_COUNT]; + video::IVideoDriver *Driver; + bool UseGradient; + + EGUI_SKIN_TYPE Type; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUISpriteBank.cpp b/irr/src/CGUISpriteBank.cpp new file mode 100644 index 000000000..fe0c087b8 --- /dev/null +++ b/irr/src/CGUISpriteBank.cpp @@ -0,0 +1,246 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUISpriteBank.h" + +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "ITexture.h" + +namespace irr +{ +namespace gui +{ + +CGUISpriteBank::CGUISpriteBank(IGUIEnvironment *env) : + Environment(env), Driver(0) +{ +#ifdef _DEBUG + setDebugName("CGUISpriteBank"); +#endif + + if (Environment) { + Driver = Environment->getVideoDriver(); + if (Driver) + Driver->grab(); + } +} + +CGUISpriteBank::~CGUISpriteBank() +{ + clear(); + + // drop video driver + if (Driver) + Driver->drop(); +} + +core::array> &CGUISpriteBank::getPositions() +{ + return Rectangles; +} + +core::array &CGUISpriteBank::getSprites() +{ + return Sprites; +} + +u32 CGUISpriteBank::getTextureCount() const +{ + return Textures.size(); +} + +video::ITexture *CGUISpriteBank::getTexture(u32 index) const +{ + if (index < Textures.size()) + return Textures[index]; + else + return 0; +} + +void CGUISpriteBank::addTexture(video::ITexture *texture) +{ + if (texture) + texture->grab(); + + Textures.push_back(texture); +} + +void CGUISpriteBank::setTexture(u32 index, video::ITexture *texture) +{ + while (index >= Textures.size()) + Textures.push_back(0); + + if (texture) + texture->grab(); + + if (Textures[index]) + Textures[index]->drop(); + + Textures[index] = texture; +} + +//! clear everything +void CGUISpriteBank::clear() +{ + // drop textures + for (u32 i = 0; i < Textures.size(); ++i) { + if (Textures[i]) + Textures[i]->drop(); + } + Textures.clear(); + Sprites.clear(); + Rectangles.clear(); +} + +//! Add the texture and use it for a single non-animated sprite. +s32 CGUISpriteBank::addTextureAsSprite(video::ITexture *texture) +{ + if (!texture) + return -1; + + addTexture(texture); + u32 textureIndex = getTextureCount() - 1; + + u32 rectangleIndex = Rectangles.size(); + Rectangles.push_back(core::rect(0, 0, texture->getOriginalSize().Width, texture->getOriginalSize().Height)); + + SGUISprite sprite; + sprite.frameTime = 0; + + SGUISpriteFrame frame; + frame.textureNumber = textureIndex; + frame.rectNumber = rectangleIndex; + sprite.Frames.push_back(frame); + + Sprites.push_back(sprite); + + return Sprites.size() - 1; +} + +// get FrameNr for time. return true on exisiting frame +inline bool CGUISpriteBank::getFrameNr(u32 &frame, u32 index, u32 time, bool loop) const +{ + frame = 0; + if (index >= Sprites.size()) + return false; + + const SGUISprite &sprite = Sprites[index]; + const u32 frameSize = sprite.Frames.size(); + if (frameSize < 1) + return false; + + if (sprite.frameTime) { + u32 f = (time / sprite.frameTime); + if (loop) + frame = f % frameSize; + else + frame = (f >= frameSize) ? frameSize - 1 : f; + } + return true; +} + +//! draws a sprite in 2d with scale and color +void CGUISpriteBank::draw2DSprite(u32 index, const core::position2di &pos, + const core::rect *clip, const video::SColor &color, + u32 starttime, u32 currenttime, bool loop, bool center) +{ + u32 frame = 0; + if (!getFrameNr(frame, index, currenttime - starttime, loop)) + return; + + const video::ITexture *tex = getTexture(Sprites[index].Frames[frame].textureNumber); + if (!tex) + return; + + const u32 rn = Sprites[index].Frames[frame].rectNumber; + if (rn >= Rectangles.size()) + return; + + const core::rect &r = Rectangles[rn]; + core::position2di p(pos); + if (center) { + p -= r.getSize() / 2; + } + Driver->draw2DImage(tex, p, r, clip, color, true); +} + +void CGUISpriteBank::draw2DSprite(u32 index, const core::rect &destRect, + const core::rect *clip, const video::SColor *const colors, + u32 timeTicks, bool loop) +{ + u32 frame = 0; + if (!getFrameNr(frame, index, timeTicks, loop)) + return; + + const video::ITexture *tex = getTexture(Sprites[index].Frames[frame].textureNumber); + if (!tex) + return; + + const u32 rn = Sprites[index].Frames[frame].rectNumber; + if (rn >= Rectangles.size()) + return; + + Driver->draw2DImage(tex, destRect, Rectangles[rn], clip, colors, true); +} + +void CGUISpriteBank::draw2DSpriteBatch(const core::array &indices, + const core::array &pos, + const core::rect *clip, + const video::SColor &color, + u32 starttime, u32 currenttime, + bool loop, bool center) +{ + const irr::u32 drawCount = core::min_(indices.size(), pos.size()); + + if (!getTextureCount()) + return; + core::array drawBatches(getTextureCount()); + for (u32 i = 0; i < Textures.size(); ++i) { + drawBatches.push_back(SDrawBatch()); + drawBatches[i].positions.reallocate(drawCount); + drawBatches[i].sourceRects.reallocate(drawCount); + } + + for (u32 i = 0; i < drawCount; ++i) { + const u32 index = indices[i]; + + // work out frame number + u32 frame = 0; + if (!getFrameNr(frame, index, currenttime - starttime, loop)) + return; + + const u32 texNum = Sprites[index].Frames[frame].textureNumber; + if (texNum >= drawBatches.size()) { + continue; + } + SDrawBatch ¤tBatch = drawBatches[texNum]; + + const u32 rn = Sprites[index].Frames[frame].rectNumber; + if (rn >= Rectangles.size()) + return; + + const core::rect &r = Rectangles[rn]; + + if (center) { + core::position2di p = pos[i]; + p -= r.getSize() / 2; + + currentBatch.positions.push_back(p); + currentBatch.sourceRects.push_back(r); + } else { + currentBatch.positions.push_back(pos[i]); + currentBatch.sourceRects.push_back(r); + } + } + + for (u32 i = 0; i < drawBatches.size(); i++) { + if (!drawBatches[i].positions.empty() && !drawBatches[i].sourceRects.empty()) + Driver->draw2DImageBatch(getTexture(i), drawBatches[i].positions, + drawBatches[i].sourceRects, clip, color, true); + } +} + +} // namespace gui +} // namespace irr diff --git a/irr/src/CGUISpriteBank.h b/irr/src/CGUISpriteBank.h new file mode 100644 index 000000000..f46ca8b15 --- /dev/null +++ b/irr/src/CGUISpriteBank.h @@ -0,0 +1,81 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUISpriteBank.h" + +namespace irr +{ + +namespace video +{ +class IVideoDriver; +class ITexture; +} + +namespace gui +{ + +class IGUIEnvironment; + +//! Sprite bank interface. +class CGUISpriteBank : public IGUISpriteBank +{ +public: + CGUISpriteBank(IGUIEnvironment *env); + virtual ~CGUISpriteBank(); + + core::array> &getPositions() override; + core::array &getSprites() override; + + u32 getTextureCount() const override; + video::ITexture *getTexture(u32 index) const override; + void addTexture(video::ITexture *texture) override; + void setTexture(u32 index, video::ITexture *texture) override; + + //! Add the texture and use it for a single non-animated sprite. + s32 addTextureAsSprite(video::ITexture *texture) override; + + //! clears sprites, rectangles and textures + void clear() override; + + //! Draws a sprite in 2d with position and color + virtual void draw2DSprite(u32 index, const core::position2di &pos, const core::rect *clip = 0, + const video::SColor &color = video::SColor(255, 255, 255, 255), + u32 starttime = 0, u32 currenttime = 0, bool loop = true, bool center = false) override; + + //! Draws a sprite in 2d with destination rectangle and colors + virtual void draw2DSprite(u32 index, const core::rect &destRect, + const core::rect *clip = 0, + const video::SColor *const colors = 0, + u32 timeTicks = 0, + bool loop = true) override; + + //! Draws a sprite batch in 2d using an array of positions and a color + virtual void draw2DSpriteBatch(const core::array &indices, const core::array &pos, + const core::rect *clip = 0, + const video::SColor &color = video::SColor(255, 255, 255, 255), + u32 starttime = 0, u32 currenttime = 0, + bool loop = true, bool center = false) override; + +protected: + bool getFrameNr(u32 &frameNr, u32 index, u32 time, bool loop) const; + + struct SDrawBatch + { + core::array positions; + core::array sourceRects; + u32 textureNumber; + }; + + core::array Sprites; + core::array> Rectangles; + core::array Textures; + IGUIEnvironment *Environment; + video::IVideoDriver *Driver; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIStaticText.cpp b/irr/src/CGUIStaticText.cpp new file mode 100644 index 000000000..035847583 --- /dev/null +++ b/irr/src/CGUIStaticText.cpp @@ -0,0 +1,511 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUIStaticText.h" + +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IGUIFont.h" +#include "IVideoDriver.h" +#include "rect.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIStaticText::CGUIStaticText(const wchar_t *text, bool border, + IGUIEnvironment *environment, IGUIElement *parent, + s32 id, const core::rect &rectangle, + bool background) : + IGUIStaticText(environment, parent, id, rectangle), + HAlign(EGUIA_UPPERLEFT), VAlign(EGUIA_UPPERLEFT), + Border(border), OverrideColorEnabled(false), OverrideBGColorEnabled(false), WordWrap(false), Background(background), + RestrainTextInside(true), RightToLeft(false), + OverrideColor(video::SColor(101, 255, 255, 255)), BGColor(video::SColor(101, 210, 210, 210)), + OverrideFont(0), LastBreakFont(0) +{ +#ifdef _DEBUG + setDebugName("CGUIStaticText"); +#endif + + Text = text; + if (environment && environment->getSkin()) { + BGColor = environment->getSkin()->getColor(gui::EGDC_3D_FACE); + } +} + +//! destructor +CGUIStaticText::~CGUIStaticText() +{ + if (OverrideFont) + OverrideFont->drop(); +} + +//! draws the element and its children +void CGUIStaticText::draw() +{ + if (!IsVisible) + return; + + IGUISkin *skin = Environment->getSkin(); + if (!skin) + return; + video::IVideoDriver *driver = Environment->getVideoDriver(); + + core::rect frameRect(AbsoluteRect); + + // draw background + + if (Background) { + if (!OverrideBGColorEnabled) // skin-colors can change + BGColor = skin->getColor(gui::EGDC_3D_FACE); + + driver->draw2DRectangle(BGColor, frameRect, &AbsoluteClippingRect); + } + + // draw the border + + if (Border) { + skin->draw3DSunkenPane(this, 0, true, false, frameRect, &AbsoluteClippingRect); + frameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X); + } + + // draw the text + if (Text.size()) { + IGUIFont *font = getActiveFont(); + + if (font) { + if (!WordWrap) { + if (VAlign == EGUIA_LOWERRIGHT) { + frameRect.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - + font->getDimension(L"A").Height - font->getKerningHeight(); + } + if (HAlign == EGUIA_LOWERRIGHT) { + frameRect.UpperLeftCorner.X = frameRect.LowerRightCorner.X - + font->getDimension(Text.c_str()).Width; + } + + font->draw(Text.c_str(), frameRect, + getActiveColor(), + HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER, (RestrainTextInside ? &AbsoluteClippingRect : NULL)); + } else { + if (font != LastBreakFont) + breakText(); + + core::rect r = frameRect; + s32 height = font->getDimension(L"A").Height + font->getKerningHeight(); + s32 totalHeight = height * BrokenText.size(); + if (VAlign == EGUIA_CENTER) { + r.UpperLeftCorner.Y = r.getCenter().Y - (totalHeight / 2); + } else if (VAlign == EGUIA_LOWERRIGHT) { + r.UpperLeftCorner.Y = r.LowerRightCorner.Y - totalHeight; + } + + for (u32 i = 0; i < BrokenText.size(); ++i) { + if (HAlign == EGUIA_LOWERRIGHT) { + r.UpperLeftCorner.X = frameRect.LowerRightCorner.X - + font->getDimension(BrokenText[i].c_str()).Width; + } + + font->draw(BrokenText[i].c_str(), r, + getActiveColor(), + HAlign == EGUIA_CENTER, false, (RestrainTextInside ? &AbsoluteClippingRect : NULL)); + + r.LowerRightCorner.Y += height; + r.UpperLeftCorner.Y += height; + } + } + } + } + + IGUIElement::draw(); +} + +//! Sets another skin independent font. +void CGUIStaticText::setOverrideFont(IGUIFont *font) +{ + if (OverrideFont == font) + return; + + if (OverrideFont) + OverrideFont->drop(); + + OverrideFont = font; + + if (OverrideFont) + OverrideFont->grab(); + + breakText(); +} + +//! Gets the override font (if any) +IGUIFont *CGUIStaticText::getOverrideFont() const +{ + return OverrideFont; +} + +//! Get the font which is used right now for drawing +IGUIFont *CGUIStaticText::getActiveFont() const +{ + if (OverrideFont) + return OverrideFont; + IGUISkin *skin = Environment->getSkin(); + if (skin) + return skin->getFont(); + return 0; +} + +//! Sets another color for the text. +void CGUIStaticText::setOverrideColor(video::SColor color) +{ + OverrideColor = color; + OverrideColorEnabled = true; +} + +//! Sets another color for the text. +void CGUIStaticText::setBackgroundColor(video::SColor color) +{ + BGColor = color; + OverrideBGColorEnabled = true; + Background = true; +} + +//! Sets whether to draw the background +void CGUIStaticText::setDrawBackground(bool draw) +{ + Background = draw; +} + +//! Gets the background color +video::SColor CGUIStaticText::getBackgroundColor() const +{ + return BGColor; +} + +//! Checks if background drawing is enabled +bool CGUIStaticText::isDrawBackgroundEnabled() const +{ + return Background; +} + +//! Sets whether to draw the border +void CGUIStaticText::setDrawBorder(bool draw) +{ + Border = draw; +} + +//! Checks if border drawing is enabled +bool CGUIStaticText::isDrawBorderEnabled() const +{ + return Border; +} + +void CGUIStaticText::setTextRestrainedInside(bool restrainTextInside) +{ + RestrainTextInside = restrainTextInside; +} + +bool CGUIStaticText::isTextRestrainedInside() const +{ + return RestrainTextInside; +} + +void CGUIStaticText::setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) +{ + HAlign = horizontal; + VAlign = vertical; +} + +video::SColor CGUIStaticText::getOverrideColor() const +{ + return OverrideColor; +} + +irr::video::SColor CGUIStaticText::getActiveColor() const +{ + if (OverrideColorEnabled) + return OverrideColor; + IGUISkin *skin = Environment->getSkin(); + if (skin) + return OverrideColorEnabled ? OverrideColor : skin->getColor(isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT); + return OverrideColor; +} + +//! Sets if the static text should use the override color or the +//! color in the gui skin. +void CGUIStaticText::enableOverrideColor(bool enable) +{ + OverrideColorEnabled = enable; +} + +bool CGUIStaticText::isOverrideColorEnabled() const +{ + return OverrideColorEnabled; +} + +//! Enables or disables word wrap for using the static text as +//! multiline text control. +void CGUIStaticText::setWordWrap(bool enable) +{ + WordWrap = enable; + breakText(); +} + +bool CGUIStaticText::isWordWrapEnabled() const +{ + return WordWrap; +} + +void CGUIStaticText::setRightToLeft(bool rtl) +{ + if (RightToLeft != rtl) { + RightToLeft = rtl; + breakText(); + } +} + +bool CGUIStaticText::isRightToLeft() const +{ + return RightToLeft; +} + +//! Breaks the single text line. +void CGUIStaticText::breakText() +{ + if (!WordWrap) + return; + + BrokenText.clear(); + + IGUISkin *skin = Environment->getSkin(); + IGUIFont *font = getActiveFont(); + if (!font) + return; + + LastBreakFont = font; + + core::stringw line; + core::stringw word; + core::stringw whitespace; + s32 size = Text.size(); + s32 length = 0; + s32 elWidth = RelativeRect.getWidth(); + if (Border) + elWidth -= 2 * skin->getSize(EGDS_TEXT_DISTANCE_X); + wchar_t c; + + // We have to deal with right-to-left and left-to-right differently + // However, most parts of the following code is the same, it's just + // some order and boundaries which change. + if (!RightToLeft) { + // regular (left-to-right) + for (s32 i = 0; i < size; ++i) { + c = Text[i]; + bool lineBreak = false; + + if (c == L'\r') { // Mac or Windows breaks + lineBreak = true; + if (Text[i + 1] == L'\n') { // Windows breaks + Text.erase(i + 1); + --size; + } + c = '\0'; + } else if (c == L'\n') { // Unix breaks + lineBreak = true; + c = '\0'; + } + + bool isWhitespace = (c == L' ' || c == 0); + if (!isWhitespace) { + // part of a word + word += c; + } + + if (isWhitespace || i == (size - 1)) { + if (word.size()) { + // here comes the next whitespace, look if + // we must break the last word to the next line. + const s32 whitelgth = font->getDimension(whitespace.c_str()).Width; + const s32 wordlgth = font->getDimension(word.c_str()).Width; + + if (wordlgth > elWidth) { + // This word is too long to fit in the available space, look for + // the Unicode Soft HYphen (SHY / 00AD) character for a place to + // break the word at + int where = word.findFirst(wchar_t(0x00AD)); + if (where != -1) { + core::stringw first = word.subString(0, where); + core::stringw second = word.subString(where, word.size() - where); + BrokenText.push_back(line + first + L"-"); + const s32 secondLength = font->getDimension(second.c_str()).Width; + + length = secondLength; + line = second; + } else { + // No soft hyphen found, so there's nothing more we can do + // break to next line + if (length) + BrokenText.push_back(line); + length = wordlgth; + line = word; + } + } else if (length && (length + wordlgth + whitelgth > elWidth)) { + // break to next line + BrokenText.push_back(line); + length = wordlgth; + line = word; + } else { + // add word to line + line += whitespace; + line += word; + length += whitelgth + wordlgth; + } + + word = L""; + whitespace = L""; + } + + if (isWhitespace) { + whitespace += c; + } + + // compute line break + if (lineBreak) { + line += whitespace; + line += word; + BrokenText.push_back(line); + line = L""; + word = L""; + whitespace = L""; + length = 0; + } + } + } + + line += whitespace; + line += word; + BrokenText.push_back(line); + } else { + // right-to-left + for (s32 i = size; i >= 0; --i) { + c = Text[i]; + bool lineBreak = false; + + if (c == L'\r') { // Mac or Windows breaks + lineBreak = true; + if ((i > 0) && Text[i - 1] == L'\n') { // Windows breaks + Text.erase(i - 1); + --size; + } + c = '\0'; + } else if (c == L'\n') { // Unix breaks + lineBreak = true; + c = '\0'; + } + + if (c == L' ' || c == 0 || i == 0) { + if (word.size()) { + // here comes the next whitespace, look if + // we must break the last word to the next line. + const s32 whitelgth = font->getDimension(whitespace.c_str()).Width; + const s32 wordlgth = font->getDimension(word.c_str()).Width; + + if (length && (length + wordlgth + whitelgth > elWidth)) { + // break to next line + BrokenText.push_back(line); + length = wordlgth; + line = word; + } else { + // add word to line + line = whitespace + line; + line = word + line; + length += whitelgth + wordlgth; + } + + word = L""; + whitespace = L""; + } + + if (c != 0) + whitespace = core::stringw(&c, 1) + whitespace; + + // compute line break + if (lineBreak) { + line = whitespace + line; + line = word + line; + BrokenText.push_back(line); + line = L""; + word = L""; + whitespace = L""; + length = 0; + } + } else { + // yippee this is a word.. + word = core::stringw(&c, 1) + word; + } + } + + line = whitespace + line; + line = word + line; + BrokenText.push_back(line); + } +} + +//! Sets the new caption of this element. +void CGUIStaticText::setText(const wchar_t *text) +{ + IGUIElement::setText(text); + breakText(); +} + +void CGUIStaticText::updateAbsolutePosition() +{ + IGUIElement::updateAbsolutePosition(); + breakText(); +} + +//! Returns the height of the text in pixels when it is drawn. +s32 CGUIStaticText::getTextHeight() const +{ + IGUIFont *font = getActiveFont(); + if (!font) + return 0; + + if (WordWrap) { + s32 height = font->getDimension(L"A").Height + font->getKerningHeight(); + return height * BrokenText.size(); + } else { + // TODO: Text can have multiple lines which are not in BrokenText + // This is likely not correct. But as I have no time for further + // investigation I just fix it for now by return the true height here. + return font->getDimension(Text.c_str()).Height; + } +} + +s32 CGUIStaticText::getTextWidth() const +{ + IGUIFont *font = getActiveFont(); + if (!font) + return 0; + + if (WordWrap) { + s32 widest = 0; + + for (u32 line = 0; line < BrokenText.size(); ++line) { + s32 width = font->getDimension(BrokenText[line].c_str()).Width; + + if (width > widest) + widest = width; + } + + return widest; + } else { + return font->getDimension(Text.c_str()).Width; + } +} + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUIStaticText.h b/irr/src/CGUIStaticText.h new file mode 100644 index 000000000..c127769f8 --- /dev/null +++ b/irr/src/CGUIStaticText.h @@ -0,0 +1,131 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUIStaticText.h" +#include "irrArray.h" + +namespace irr +{ +namespace gui +{ +class CGUIStaticText : public IGUIStaticText +{ +public: + //! constructor + CGUIStaticText(const wchar_t *text, bool border, IGUIEnvironment *environment, + IGUIElement *parent, s32 id, const core::rect &rectangle, + bool background = false); + + //! destructor + virtual ~CGUIStaticText(); + + //! draws the element and its children + void draw() override; + + //! Sets another skin independent font. + void setOverrideFont(IGUIFont *font = 0) override; + + //! Gets the override font (if any) + IGUIFont *getOverrideFont() const override; + + //! Get the font which is used right now for drawing + IGUIFont *getActiveFont() const override; + + //! Sets another color for the text. + void setOverrideColor(video::SColor color) override; + + //! Sets another color for the background. + void setBackgroundColor(video::SColor color) override; + + //! Sets whether to draw the background + void setDrawBackground(bool draw) override; + + //! Gets the background color + video::SColor getBackgroundColor() const override; + + //! Checks if background drawing is enabled + bool isDrawBackgroundEnabled() const override; + + //! Sets whether to draw the border + void setDrawBorder(bool draw) override; + + //! Checks if border drawing is enabled + bool isDrawBorderEnabled() const override; + + //! Sets alignment mode for text + void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) override; + + //! Gets the override color + video::SColor getOverrideColor() const override; + + //! Gets the currently used text color + video::SColor getActiveColor() const override; + + //! Sets if the static text should use the override color or the + //! color in the gui skin. + void enableOverrideColor(bool enable) override; + + //! Checks if an override color is enabled + bool isOverrideColorEnabled() const override; + + //! Set whether the text in this label should be clipped if it goes outside bounds + void setTextRestrainedInside(bool restrainedInside) override; + + //! Checks if the text in this label should be clipped if it goes outside bounds + bool isTextRestrainedInside() const override; + + //! Enables or disables word wrap for using the static text as + //! multiline text control. + void setWordWrap(bool enable) override; + + //! Checks if word wrap is enabled + bool isWordWrapEnabled() const override; + + //! Sets the new caption of this element. + void setText(const wchar_t *text) override; + + //! Returns the height of the text in pixels when it is drawn. + s32 getTextHeight() const override; + + //! Returns the width of the current text, in the current font + s32 getTextWidth() const override; + + //! Updates the absolute position, splits text if word wrap is enabled + void updateAbsolutePosition() override; + + //! Set whether the string should be interpreted as right-to-left (RTL) text + /** \note This component does not implement the Unicode bidi standard, the + text of the component should be already RTL if you call this. The + main difference when RTL is enabled is that the linebreaks for multiline + elements are performed starting from the end. + */ + void setRightToLeft(bool rtl) override; + + //! Checks if the text should be interpreted as right-to-left text + bool isRightToLeft() const override; + +private: + //! Breaks the single text line. + void breakText(); + + EGUI_ALIGNMENT HAlign, VAlign; + bool Border; + bool OverrideColorEnabled; + bool OverrideBGColorEnabled; + bool WordWrap; + bool Background; + bool RestrainTextInside; + bool RightToLeft; + + video::SColor OverrideColor, BGColor; + gui::IGUIFont *OverrideFont; + gui::IGUIFont *LastBreakFont; // stored because: if skin changes, line break must be recalculated. + + core::array BrokenText; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CGUITabControl.cpp b/irr/src/CGUITabControl.cpp new file mode 100644 index 000000000..3e02773db --- /dev/null +++ b/irr/src/CGUITabControl.cpp @@ -0,0 +1,934 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUITabControl.h" + +#include "CGUIButton.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IGUIFont.h" +#include "IVideoDriver.h" +#include "rect.h" +#include "os.h" + +namespace irr +{ +namespace gui +{ + +// ------------------------------------------------------------------ +// Tab +// ------------------------------------------------------------------ + +//! constructor +CGUITab::CGUITab(IGUIEnvironment *environment, + IGUIElement *parent, const core::rect &rectangle, + s32 id) : + IGUITab(environment, parent, id, rectangle), + BackColor(0, 0, 0, 0), OverrideTextColorEnabled(false), TextColor(255, 0, 0, 0), + DrawBackground(false) +{ +#ifdef _DEBUG + setDebugName("CGUITab"); +#endif + + const IGUISkin *const skin = environment->getSkin(); + if (skin) + TextColor = skin->getColor(EGDC_BUTTON_TEXT); +} + +//! draws the element and its children +void CGUITab::draw() +{ + if (!IsVisible) + return; + + IGUISkin *skin = Environment->getSkin(); + + if (skin && DrawBackground) + skin->draw2DRectangle(this, BackColor, AbsoluteRect, &AbsoluteClippingRect); + + IGUIElement::draw(); +} + +//! sets if the tab should draw its background +void CGUITab::setDrawBackground(bool draw) +{ + DrawBackground = draw; +} + +//! sets the color of the background, if it should be drawn. +void CGUITab::setBackgroundColor(video::SColor c) +{ + BackColor = c; +} + +//! sets the color of the text +void CGUITab::setTextColor(video::SColor c) +{ + OverrideTextColorEnabled = true; + TextColor = c; +} + +video::SColor CGUITab::getTextColor() const +{ + if (OverrideTextColorEnabled) + return TextColor; + else + return Environment->getSkin()->getColor(EGDC_BUTTON_TEXT); +} + +//! returns true if the tab is drawing its background, false if not +bool CGUITab::isDrawingBackground() const +{ + return DrawBackground; +} + +//! returns the color of the background +video::SColor CGUITab::getBackgroundColor() const +{ + return BackColor; +} + +// ------------------------------------------------------------------ +// Tabcontrol +// ------------------------------------------------------------------ + +//! constructor +CGUITabControl::CGUITabControl(IGUIEnvironment *environment, + IGUIElement *parent, const core::rect &rectangle, + bool fillbackground, bool border, s32 id) : + IGUITabControl(environment, parent, id, rectangle), + ActiveTabIndex(-1), + Border(border), FillBackground(fillbackground), ScrollControl(false), TabHeight(0), VerticalAlignment(EGUIA_UPPERLEFT), + UpButton(0), DownButton(0), TabMaxWidth(0), CurrentScrollTabIndex(0), TabExtraWidth(20) +{ +#ifdef _DEBUG + setDebugName("CGUITabControl"); +#endif + + IGUISkin *skin = Environment->getSkin(); + IGUISpriteBank *sprites = 0; + + TabHeight = 32; + + if (skin) { + sprites = skin->getSpriteBank(); + TabHeight = skin->getSize(gui::EGDS_BUTTON_HEIGHT) + 2; + } + + UpButton = Environment->addButton(core::rect(0, 0, 10, 10), this); + + if (UpButton) { + UpButton->setSpriteBank(sprites); + UpButton->setVisible(false); + UpButton->setSubElement(true); + UpButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + UpButton->setOverrideFont(Environment->getBuiltInFont()); + UpButton->grab(); + } + + DownButton = Environment->addButton(core::rect(0, 0, 10, 10), this); + + if (DownButton) { + DownButton->setSpriteBank(sprites); + DownButton->setVisible(false); + DownButton->setSubElement(true); + DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + DownButton->setOverrideFont(Environment->getBuiltInFont()); + DownButton->grab(); + } + + setTabVerticalAlignment(EGUIA_UPPERLEFT); + refreshSprites(); +} + +//! destructor +CGUITabControl::~CGUITabControl() +{ + for (u32 i = 0; i < Tabs.size(); ++i) { + if (Tabs[i]) + Tabs[i]->drop(); + } + + if (UpButton) + UpButton->drop(); + + if (DownButton) + DownButton->drop(); +} + +void CGUITabControl::refreshSprites() +{ + video::SColor color(255, 255, 255, 255); + IGUISkin *skin = Environment->getSkin(); + if (skin) { + color = skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL); + + if (UpButton) { + UpButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_LEFT), color); + UpButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_LEFT), color); + } + + if (DownButton) { + DownButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_RIGHT), color); + DownButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_RIGHT), color); + } + } +} + +//! Adds a tab +IGUITab *CGUITabControl::addTab(const wchar_t *caption, s32 id) +{ + CGUITab *tab = new CGUITab(Environment, this, calcTabPos(), id); + + tab->setText(caption); + tab->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + tab->setVisible(false); + Tabs.push_back(tab); // no grab as new already creates a reference + + if (ActiveTabIndex == -1) { + ActiveTabIndex = Tabs.size() - 1; + tab->setVisible(true); + } + + recalculateScrollBar(); + + return tab; +} + +//! adds a tab which has been created elsewhere +s32 CGUITabControl::addTab(IGUITab *tab) +{ + return insertTab(Tabs.size(), tab, false); +} + +//! Insert the tab at the given index +IGUITab *CGUITabControl::insertTab(s32 idx, const wchar_t *caption, s32 id) +{ + if (idx < 0 || idx > (s32)Tabs.size()) // idx == Tabs.size() is indeed OK here as core::array can handle that + return NULL; + + CGUITab *tab = new CGUITab(Environment, this, calcTabPos(), id); + + tab->setText(caption); + tab->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + tab->setVisible(false); + Tabs.insert(tab, (u32)idx); + + if (ActiveTabIndex == -1) { + ActiveTabIndex = (u32)idx; + tab->setVisible(true); + } else if (idx <= ActiveTabIndex) { + ++ActiveTabIndex; + setVisibleTab(ActiveTabIndex); + } + + recalculateScrollBar(); + + return tab; +} + +s32 CGUITabControl::insertTab(s32 idx, IGUITab *tab, bool serializationMode) +{ + if (!tab) + return -1; + if (idx > (s32)Tabs.size() && !serializationMode) // idx == Tabs.size() is indeed OK here as core::array can handle that + return -1; + // Not allowing to add same tab twice as it would make things complicated (serialization or setting active visible) + if (getTabIndex(tab) >= 0) + return -1; + + if (idx < 0) + idx = (s32)Tabs.size(); + + if (tab->getParent() != this) + this->addChildToEnd(tab); + + tab->setVisible(false); + + tab->grab(); + + if (serializationMode) { + while (idx >= (s32)Tabs.size()) { + Tabs.push_back(0); + } + Tabs[idx] = tab; + + if (idx == ActiveTabIndex) { // in serialization that can happen for any index + setVisibleTab(ActiveTabIndex); + tab->setVisible(true); + } + } else { + Tabs.insert(tab, (u32)idx); + + if (ActiveTabIndex == -1) { + ActiveTabIndex = idx; + setVisibleTab(ActiveTabIndex); + } else if (idx <= ActiveTabIndex) { + ++ActiveTabIndex; + setVisibleTab(ActiveTabIndex); + } + } + + recalculateScrollBar(); + + return idx; +} + +//! Removes a child. +void CGUITabControl::removeChild(IGUIElement *child) +{ + s32 idx = getTabIndex(child); + if (idx >= 0) + removeTabButNotChild(idx); + + // remove real element + IGUIElement::removeChild(child); + + recalculateScrollBar(); +} + +//! Removes a tab from the tabcontrol +void CGUITabControl::removeTab(s32 idx) +{ + if (idx < 0 || idx >= (s32)Tabs.size()) + return; + + removeChild(Tabs[(u32)idx]); +} + +void CGUITabControl::removeTabButNotChild(s32 idx) +{ + if (idx < 0 || idx >= (s32)Tabs.size()) + return; + + Tabs[(u32)idx]->drop(); + Tabs.erase((u32)idx); + + if (idx < ActiveTabIndex) { + --ActiveTabIndex; + setVisibleTab(ActiveTabIndex); + } else if (idx == ActiveTabIndex) { + if ((u32)idx == Tabs.size()) + --ActiveTabIndex; + setVisibleTab(ActiveTabIndex); + } +} + +//! Clears the tabcontrol removing all tabs +void CGUITabControl::clear() +{ + for (u32 i = 0; i < Tabs.size(); ++i) { + if (Tabs[i]) { + IGUIElement::removeChild(Tabs[i]); + Tabs[i]->drop(); + } + } + Tabs.clear(); + + recalculateScrollBar(); +} + +//! Returns amount of tabs in the tabcontrol +s32 CGUITabControl::getTabCount() const +{ + return Tabs.size(); +} + +//! Returns a tab based on zero based index +IGUITab *CGUITabControl::getTab(s32 idx) const +{ + if (idx < 0 || (u32)idx >= Tabs.size()) + return 0; + + return Tabs[idx]; +} + +//! called if an event happened. +bool CGUITabControl::OnEvent(const SEvent &event) +{ + if (isEnabled()) { + switch (event.EventType) { + case EET_GUI_EVENT: + switch (event.GUIEvent.EventType) { + case EGET_BUTTON_CLICKED: + if (event.GUIEvent.Caller == UpButton) { + scrollLeft(); + return true; + } else if (event.GUIEvent.Caller == DownButton) { + scrollRight(); + return true; + } + + break; + default: + break; + } + break; + case EET_MOUSE_INPUT_EVENT: + switch (event.MouseInput.Event) { + // case EMIE_LMOUSE_PRESSED_DOWN: + // // todo: dragging tabs around + // return true; + case EMIE_LMOUSE_LEFT_UP: { + s32 idx = getTabAt(event.MouseInput.X, event.MouseInput.Y); + if (idx >= 0) { + setActiveTab(idx); + return true; + } + break; + } + default: + break; + } + break; + default: + break; + } + } + + return IGUIElement::OnEvent(event); +} + +void CGUITabControl::scrollLeft() +{ + if (CurrentScrollTabIndex > 0) + --CurrentScrollTabIndex; + recalculateScrollBar(); +} + +void CGUITabControl::scrollRight() +{ + if (CurrentScrollTabIndex < (s32)(Tabs.size()) - 1) { + if (needScrollControl(CurrentScrollTabIndex, true)) + ++CurrentScrollTabIndex; + } + recalculateScrollBar(); +} + +s32 CGUITabControl::calcTabWidth(IGUIFont *font, const wchar_t *text) const +{ + if (!font) + return 0; + + s32 len = font->getDimension(text).Width + TabExtraWidth; + if (TabMaxWidth > 0 && len > TabMaxWidth) + len = TabMaxWidth; + + return len; +} + +bool CGUITabControl::needScrollControl(s32 startIndex, bool withScrollControl, s32 *pos_rightmost) +{ + if (startIndex < 0) + startIndex = 0; + + IGUISkin *skin = Environment->getSkin(); + if (!skin) + return false; + + IGUIFont *font = skin->getFont(); + + if (Tabs.empty()) + return false; + + if (!font) + return false; + + s32 pos = AbsoluteRect.UpperLeftCorner.X + 2; + const s32 pos_right = withScrollControl ? UpButton->getAbsolutePosition().UpperLeftCorner.X - 2 : AbsoluteRect.LowerRightCorner.X; + + for (s32 i = startIndex; i < (s32)Tabs.size(); ++i) { + // get Text + const wchar_t *text = 0; + if (Tabs[i]) { + text = Tabs[i]->getText(); + + // get text length + s32 len = calcTabWidth(font, text); // always without withScrollControl here or len would be shortened + pos += len; + } + + if (pos > pos_right) + return true; + } + + if (pos_rightmost) + *pos_rightmost = pos; + return false; +} + +s32 CGUITabControl::calculateScrollIndexFromActive() +{ + if (!ScrollControl || Tabs.empty()) + return 0; + + IGUISkin *skin = Environment->getSkin(); + if (!skin) + return false; + + IGUIFont *font = skin->getFont(); + if (!font) + return false; + + const s32 pos_left = AbsoluteRect.UpperLeftCorner.X + 2; + const s32 pos_right = UpButton->getAbsolutePosition().UpperLeftCorner.X - 2; + + // Move from center to the left border left until it is reached + s32 pos_cl = (pos_left + pos_right) / 2; + s32 i = ActiveTabIndex; + for (; i > 0; --i) { + if (!Tabs[i]) + continue; + + s32 len = calcTabWidth(font, Tabs[i]->getText()); + if (i == ActiveTabIndex) + len /= 2; + if (pos_cl - len < pos_left) + break; + + pos_cl -= len; + } + if (i == 0) + return i; + + // Is scrolling to right still possible? + s32 pos_rr = 0; + if (needScrollControl(i, true, &pos_rr)) + return i; // Yes? -> OK + + // No? -> Decrease "i" more. Append tabs until scrolling becomes necessary + for (--i; i > 0; --i) { + if (!Tabs[i]) + continue; + + pos_rr += calcTabWidth(font, Tabs[i]->getText()); + if (pos_rr > pos_right) + break; + } + return i + 1; +} + +core::rect CGUITabControl::calcTabPos() +{ + core::rect r; + r.UpperLeftCorner.X = 0; + r.LowerRightCorner.X = AbsoluteRect.getWidth(); + if (Border) { + ++r.UpperLeftCorner.X; + --r.LowerRightCorner.X; + } + + if (VerticalAlignment == EGUIA_UPPERLEFT) { + r.UpperLeftCorner.Y = TabHeight + 2; + r.LowerRightCorner.Y = AbsoluteRect.getHeight() - 1; + if (Border) { + --r.LowerRightCorner.Y; + } + } else { + r.UpperLeftCorner.Y = 0; + r.LowerRightCorner.Y = AbsoluteRect.getHeight() - (TabHeight + 2); + if (Border) { + ++r.UpperLeftCorner.Y; + } + } + + return r; +} + +//! draws the element and its children +void CGUITabControl::draw() +{ + if (!IsVisible) + return; + + IGUISkin *skin = Environment->getSkin(); + if (!skin) + return; + + IGUIFont *font = skin->getFont(); + video::IVideoDriver *driver = Environment->getVideoDriver(); + + core::rect frameRect(AbsoluteRect); + + // some empty background as placeholder when there are no tabs + if (Tabs.empty()) + driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), frameRect, &AbsoluteClippingRect); + + if (!font) + return; + + // tab button bar can be above or below the tabs + if (VerticalAlignment == EGUIA_UPPERLEFT) { + frameRect.UpperLeftCorner.Y += 2; + frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + TabHeight; + } else { + frameRect.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - TabHeight - 1; + frameRect.LowerRightCorner.Y -= 2; + } + + core::rect tr; + s32 pos = frameRect.UpperLeftCorner.X + 2; + + bool needLeftScroll = CurrentScrollTabIndex > 0; + bool needRightScroll = false; + + // left and right pos of the active tab + s32 left = 0; + s32 right = 0; + + // const wchar_t* activetext = 0; + IGUITab *activeTab = 0; + + // Draw all tab-buttons except the active one + for (u32 i = CurrentScrollTabIndex; i < Tabs.size() && !needRightScroll; ++i) { + // get Text + const wchar_t *text = 0; + if (Tabs[i]) + text = Tabs[i]->getText(); + + // get text length + s32 len = calcTabWidth(font, text); + if (ScrollControl) { + s32 space = UpButton->getAbsolutePosition().UpperLeftCorner.X - 2 - pos; + if (space < len) { + needRightScroll = true; + len = space; + } + } + + frameRect.LowerRightCorner.X += len; + frameRect.UpperLeftCorner.X = pos; + frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + len; + + pos += len; + + if ((s32)i == ActiveTabIndex) { + // for active button just remember values + left = frameRect.UpperLeftCorner.X; + right = frameRect.LowerRightCorner.X; + // activetext = text; + activeTab = Tabs[i]; + } else { + skin->draw3DTabButton(this, false, frameRect, &AbsoluteClippingRect, VerticalAlignment); + + // draw text + core::rect textClipRect(frameRect); // TODO: exact size depends on borders in draw3DTabButton which we don't get with current interface + textClipRect.clipAgainst(AbsoluteClippingRect); + font->draw(text, frameRect, Tabs[i]->getTextColor(), + true, true, &textClipRect); + } + } + + // Draw active tab button + // Drawn later than other buttons because it draw over the buttons before/after it. + if (left != 0 && right != 0 && activeTab != 0) { + // draw upper highlight frame + if (VerticalAlignment == EGUIA_UPPERLEFT) { + frameRect.UpperLeftCorner.X = left - 2; + frameRect.LowerRightCorner.X = right + 2; + frameRect.UpperLeftCorner.Y -= 2; + + skin->draw3DTabButton(this, true, frameRect, &AbsoluteClippingRect, VerticalAlignment); + + // draw text + core::rect textClipRect(frameRect); // TODO: exact size depends on borders in draw3DTabButton which we don't get with current interface + textClipRect.clipAgainst(AbsoluteClippingRect); + font->draw(activeTab->getText(), frameRect, activeTab->getTextColor(), + true, true, &textClipRect); + + tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X; + tr.LowerRightCorner.X = left - 1; + tr.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - 1; + tr.LowerRightCorner.Y = frameRect.LowerRightCorner.Y; + driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect); + + tr.UpperLeftCorner.X = right; + tr.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X; + driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect); + } else { + frameRect.UpperLeftCorner.X = left - 2; + frameRect.LowerRightCorner.X = right + 2; + frameRect.LowerRightCorner.Y += 2; + + skin->draw3DTabButton(this, true, frameRect, &AbsoluteClippingRect, VerticalAlignment); + + // draw text + font->draw(activeTab->getText(), frameRect, activeTab->getTextColor(), + true, true, &frameRect); + + tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X; + tr.LowerRightCorner.X = left - 1; + tr.UpperLeftCorner.Y = frameRect.UpperLeftCorner.Y - 1; + tr.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y; + driver->draw2DRectangle(skin->getColor(EGDC_3D_DARK_SHADOW), tr, &AbsoluteClippingRect); + + tr.UpperLeftCorner.X = right; + tr.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X; + driver->draw2DRectangle(skin->getColor(EGDC_3D_DARK_SHADOW), tr, &AbsoluteClippingRect); + } + } else { + // No active tab + // Draw a line separating button bar from tab area + tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X; + tr.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X; + tr.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - 1; + tr.LowerRightCorner.Y = frameRect.LowerRightCorner.Y; + + if (VerticalAlignment == EGUIA_UPPERLEFT) { + driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect); + } else { + tr.UpperLeftCorner.Y = frameRect.UpperLeftCorner.Y - 1; + tr.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y; + driver->draw2DRectangle(skin->getColor(EGDC_3D_DARK_SHADOW), tr, &AbsoluteClippingRect); + } + } + + // drawing some border and background for the tab-area. + skin->draw3DTabBody(this, Border, FillBackground, AbsoluteRect, &AbsoluteClippingRect, TabHeight, VerticalAlignment); + + // enable scrollcontrols on need + if (UpButton) + UpButton->setEnabled(needLeftScroll); + if (DownButton) + DownButton->setEnabled(needRightScroll); + refreshSprites(); + + IGUIElement::draw(); +} + +//! Set the height of the tabs +void CGUITabControl::setTabHeight(s32 height) +{ + if (height < 0) + height = 0; + + TabHeight = height; + + recalculateScrollButtonPlacement(); + recalculateScrollBar(); +} + +//! Get the height of the tabs +s32 CGUITabControl::getTabHeight() const +{ + return TabHeight; +} + +//! set the maximal width of a tab. Per default width is 0 which means "no width restriction". +void CGUITabControl::setTabMaxWidth(s32 width) +{ + TabMaxWidth = width; +} + +//! get the maximal width of a tab +s32 CGUITabControl::getTabMaxWidth() const +{ + return TabMaxWidth; +} + +//! Set the extra width added to tabs on each side of the text +void CGUITabControl::setTabExtraWidth(s32 extraWidth) +{ + if (extraWidth < 0) + extraWidth = 0; + + TabExtraWidth = extraWidth; + + recalculateScrollBar(); +} + +//! Get the extra width added to tabs on each side of the text +s32 CGUITabControl::getTabExtraWidth() const +{ + return TabExtraWidth; +} + +void CGUITabControl::recalculateScrollBar() +{ + // Down: to right, Up: to left + if (!UpButton || !DownButton) + return; + + ScrollControl = needScrollControl() || CurrentScrollTabIndex > 0; + + if (ScrollControl) { + UpButton->setVisible(true); + DownButton->setVisible(true); + } else { + UpButton->setVisible(false); + DownButton->setVisible(false); + } + + bringToFront(UpButton); + bringToFront(DownButton); +} + +//! Set the alignment of the tabs +void CGUITabControl::setTabVerticalAlignment(EGUI_ALIGNMENT alignment) +{ + VerticalAlignment = alignment; + + recalculateScrollButtonPlacement(); + recalculateScrollBar(); + + core::rect r(calcTabPos()); + for (u32 i = 0; i < Tabs.size(); ++i) { + Tabs[i]->setRelativePosition(r); + } +} + +void CGUITabControl::recalculateScrollButtonPlacement() +{ + IGUISkin *skin = Environment->getSkin(); + s32 ButtonSize = 16; + s32 ButtonHeight = TabHeight - 2; + if (ButtonHeight < 0) + ButtonHeight = TabHeight; + if (skin) { + ButtonSize = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); + if (ButtonSize > TabHeight) + ButtonSize = TabHeight; + } + + s32 ButtonX = RelativeRect.getWidth() - (s32)(2.5f * (f32)ButtonSize) - 1; + s32 ButtonY = 0; + + if (VerticalAlignment == EGUIA_UPPERLEFT) { + ButtonY = 2 + (TabHeight / 2) - (ButtonHeight / 2); + UpButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + } else { + ButtonY = RelativeRect.getHeight() - (TabHeight / 2) - (ButtonHeight / 2) - 2; + UpButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT); + DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT); + } + + UpButton->setRelativePosition(core::rect(ButtonX, ButtonY, ButtonX + ButtonSize, ButtonY + ButtonHeight)); + ButtonX += ButtonSize + 1; + DownButton->setRelativePosition(core::rect(ButtonX, ButtonY, ButtonX + ButtonSize, ButtonY + ButtonHeight)); +} + +//! Get the alignment of the tabs +EGUI_ALIGNMENT CGUITabControl::getTabVerticalAlignment() const +{ + return VerticalAlignment; +} + +s32 CGUITabControl::getTabAt(s32 xpos, s32 ypos) const +{ + core::position2di p(xpos, ypos); + IGUISkin *skin = Environment->getSkin(); + IGUIFont *font = skin->getFont(); + + core::rect frameRect(AbsoluteRect); + + if (VerticalAlignment == EGUIA_UPPERLEFT) { + frameRect.UpperLeftCorner.Y += 2; + frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + TabHeight; + } else { + frameRect.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - TabHeight; + } + + s32 pos = frameRect.UpperLeftCorner.X + 2; + + if (!frameRect.isPointInside(p)) + return -1; + + bool abort = false; + for (s32 i = CurrentScrollTabIndex; i < (s32)Tabs.size() && !abort; ++i) { + // get Text + const wchar_t *text = 0; + if (Tabs[i]) + text = Tabs[i]->getText(); + + // get text length + s32 len = calcTabWidth(font, text); + if (ScrollControl) { + // TODO: merge this with draw() ? + s32 space = UpButton->getAbsolutePosition().UpperLeftCorner.X - 2 - pos; + if (space < len) { + abort = true; + len = space; + } + } + + frameRect.UpperLeftCorner.X = pos; + frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + len; + + pos += len; + + if (frameRect.isPointInside(p)) { + return i; + } + } + return -1; +} + +//! Returns which tab is currently active +s32 CGUITabControl::getActiveTab() const +{ + return ActiveTabIndex; +} + +//! Brings a tab to front. +bool CGUITabControl::setActiveTab(s32 idx) +{ + if ((u32)idx >= Tabs.size()) + return false; + + bool changed = (ActiveTabIndex != idx); + + ActiveTabIndex = idx; + + setVisibleTab(ActiveTabIndex); + + if (changed && Parent) { + SEvent event; + event.EventType = EET_GUI_EVENT; + event.GUIEvent.Caller = this; + event.GUIEvent.Element = 0; + event.GUIEvent.EventType = EGET_TAB_CHANGED; + Parent->OnEvent(event); + } + + if (ScrollControl) { + CurrentScrollTabIndex = calculateScrollIndexFromActive(); + recalculateScrollBar(); + } + + return true; +} + +void CGUITabControl::setVisibleTab(s32 idx) +{ + for (u32 i = 0; i < Tabs.size(); ++i) + if (Tabs[i]) + Tabs[i]->setVisible((s32)i == idx); +} + +bool CGUITabControl::setActiveTab(IGUITab *tab) +{ + return setActiveTab(getTabIndex(tab)); +} + +s32 CGUITabControl::getTabIndex(const IGUIElement *tab) const +{ + for (u32 i = 0; i < Tabs.size(); ++i) + if (Tabs[i] == tab) + return (s32)i; + + return -1; +} + +//! Update the position of the element, decides scroll button status +void CGUITabControl::updateAbsolutePosition() +{ + IGUIElement::updateAbsolutePosition(); + recalculateScrollBar(); +} + +} // end namespace irr +} // end namespace gui diff --git a/irr/src/CGUITabControl.h b/irr/src/CGUITabControl.h new file mode 100644 index 000000000..5c167c2a3 --- /dev/null +++ b/irr/src/CGUITabControl.h @@ -0,0 +1,175 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IGUITabControl.h" +#include "irrArray.h" +#include "IGUISkin.h" + +namespace irr +{ +namespace gui +{ +class CGUITabControl; +class IGUIButton; + +// A tab, onto which other gui elements could be added. +class CGUITab : public IGUITab +{ +public: + //! constructor + CGUITab(IGUIEnvironment *environment, + IGUIElement *parent, const core::rect &rectangle, + s32 id); + + //! draws the element and its children + void draw() override; + + //! sets if the tab should draw its background + void setDrawBackground(bool draw = true) override; + + //! sets the color of the background, if it should be drawn. + void setBackgroundColor(video::SColor c) override; + + //! sets the color of the text + void setTextColor(video::SColor c) override; + + //! returns true if the tab is drawing its background, false if not + bool isDrawingBackground() const override; + + //! returns the color of the background + video::SColor getBackgroundColor() const override; + + video::SColor getTextColor() const override; + +private: + video::SColor BackColor; + bool OverrideTextColorEnabled; + video::SColor TextColor; + bool DrawBackground; +}; + +//! A standard tab control +class CGUITabControl : public IGUITabControl +{ +public: + //! destructor + CGUITabControl(IGUIEnvironment *environment, + IGUIElement *parent, const core::rect &rectangle, + bool fillbackground = true, bool border = true, s32 id = -1); + + //! destructor + virtual ~CGUITabControl(); + + //! Adds a tab + IGUITab *addTab(const wchar_t *caption, s32 id = -1) override; + + //! Adds an existing tab + s32 addTab(IGUITab *tab) override; + + //! Insert the tab at the given index + IGUITab *insertTab(s32 idx, const wchar_t *caption, s32 id = -1) override; + + //! Insert an existing tab + /** Note that it will also add the tab as a child of this TabControl. + \return Index of added tab (should be same as the one passed) or -1 for failure*/ + s32 insertTab(s32 idx, IGUITab *tab, bool serializationMode) override; + + //! Removes a tab from the tabcontrol + void removeTab(s32 idx) override; + + //! Clears the tabcontrol removing all tabs + void clear() override; + + //! Returns amount of tabs in the tabcontrol + s32 getTabCount() const override; + + //! Returns a tab based on zero based index + IGUITab *getTab(s32 idx) const override; + + //! Brings a tab to front. + bool setActiveTab(s32 idx) override; + + //! Brings a tab to front. + bool setActiveTab(IGUITab *tab) override; + + //! For given given tab find it's zero-based index (or -1 for not found) + s32 getTabIndex(const IGUIElement *tab) const override; + + //! Returns which tab is currently active + s32 getActiveTab() const override; + + //! get the the id of the tab at the given absolute coordinates + s32 getTabAt(s32 xpos, s32 ypos) const override; + + //! called if an event happened. + bool OnEvent(const SEvent &event) override; + + //! draws the element and its children + void draw() override; + + //! Removes a child. + void removeChild(IGUIElement *child) override; + + //! Set the height of the tabs + void setTabHeight(s32 height) override; + + //! Get the height of the tabs + s32 getTabHeight() const override; + + //! set the maximal width of a tab. Per default width is 0 which means "no width restriction". + void setTabMaxWidth(s32 width) override; + + //! get the maximal width of a tab + s32 getTabMaxWidth() const override; + + //! Set the alignment of the tabs + //! note: EGUIA_CENTER is not an option + void setTabVerticalAlignment(gui::EGUI_ALIGNMENT alignment) override; + + //! Get the alignment of the tabs + gui::EGUI_ALIGNMENT getTabVerticalAlignment() const override; + + //! Set the extra width added to tabs on each side of the text + void setTabExtraWidth(s32 extraWidth) override; + + //! Get the extra width added to tabs on each side of the text + s32 getTabExtraWidth() const override; + + //! Update the position of the element, decides scroll button status + void updateAbsolutePosition() override; + +private: + void scrollLeft(); + void scrollRight(); + //! Indicates whether the tabs overflow in X direction + bool needScrollControl(s32 startIndex = 0, bool withScrollControl = false, s32 *pos_rightmost = nullptr); + //! Left index calculation based on the selected tab + s32 calculateScrollIndexFromActive(); + s32 calcTabWidth(IGUIFont *font, const wchar_t *text) const; + core::rect calcTabPos(); + void setVisibleTab(s32 idx); + void removeTabButNotChild(s32 idx); + + void recalculateScrollButtonPlacement(); + void recalculateScrollBar(); + void refreshSprites(); + + core::array Tabs; + s32 ActiveTabIndex; + bool Border; + bool FillBackground; + bool ScrollControl; + s32 TabHeight; + gui::EGUI_ALIGNMENT VerticalAlignment; + IGUIButton *UpButton; + IGUIButton *DownButton; + s32 TabMaxWidth; + s32 CurrentScrollTabIndex; + s32 TabExtraWidth; +}; + +} // end namespace gui +} // end namespace irr diff --git a/irr/src/CImage.cpp b/irr/src/CImage.cpp new file mode 100644 index 000000000..209590174 --- /dev/null +++ b/irr/src/CImage.cpp @@ -0,0 +1,373 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CImage.h" +#include "irrString.h" +#include "CColorConverter.h" +#include "CBlit.h" +#include "os.h" +#include "SoftwareDriver2_helper.h" + +namespace irr +{ +namespace video +{ + +//! Constructor from raw data +CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d &size, void *data, + bool ownForeignMemory, bool deleteMemory) : + IImage(format, size, deleteMemory) +{ + if (ownForeignMemory) { + Data = (u8 *)data; + } else { + const u32 dataSize = getDataSizeFromFormat(Format, Size.Width, Size.Height); + const u32 allocSize = align_next(dataSize, 16); + + // allocate as u32 to ensure enough alignment when casted + Data = reinterpret_cast(new u32[allocSize / 4]); + memcpy(Data, data, dataSize); + DeleteMemory = true; + } +} + +//! Constructor of empty image +CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d &size) : + IImage(format, size, true) +{ + const u32 dataSize = getDataSizeFromFormat(Format, Size.Width, Size.Height); + const u32 allocSize = align_next(dataSize, 16); + + Data = reinterpret_cast(new u32[allocSize / 4]); + DeleteMemory = true; +} + +//! sets a pixel +void CImage::setPixel(u32 x, u32 y, const SColor &color, bool blend) +{ + if (x >= Size.Width || y >= Size.Height) + return; + + switch (Format) { + case ECF_A1R5G5B5: { + u16 *dest = (u16 *)(Data + (y * Pitch) + (x << 1)); + *dest = video::A8R8G8B8toA1R5G5B5(color.color); + } break; + + case ECF_R5G6B5: { + u16 *dest = (u16 *)(Data + (y * Pitch) + (x << 1)); + *dest = video::A8R8G8B8toR5G6B5(color.color); + } break; + + case ECF_R8G8B8: { + u8 *dest = Data + (y * Pitch) + (x * 3); + dest[0] = (u8)color.getRed(); + dest[1] = (u8)color.getGreen(); + dest[2] = (u8)color.getBlue(); + } break; + + case ECF_A8R8G8B8: { + u32 *dest = (u32 *)(Data + (y * Pitch) + (x << 2)); + *dest = blend ? PixelBlend32(*dest, color.color) : color.color; + } break; + + case ECF_UNKNOWN: + os::Printer::log("IImage::setPixel unknown format.", ELL_WARNING); + return; + + default: + break; + } +} + +//! returns a pixel +SColor CImage::getPixel(u32 x, u32 y) const +{ + if (x >= Size.Width || y >= Size.Height) + return SColor(0); + + switch (Format) { + case ECF_A1R5G5B5: + return A1R5G5B5toA8R8G8B8(((u16 *)Data)[y * Size.Width + x]); + case ECF_R5G6B5: + return R5G6B5toA8R8G8B8(((u16 *)Data)[y * Size.Width + x]); + case ECF_A8R8G8B8: + return ((u32 *)Data)[y * Size.Width + x]; + case ECF_R8G8B8: { + u8 *p = Data + (y * 3) * Size.Width + (x * 3); + return SColor(255, p[0], p[1], p[2]); + } + + case ECF_UNKNOWN: + os::Printer::log("IImage::getPixel unknown format.", ELL_WARNING); + break; + + default: + break; + } + + return SColor(0); +} + +//! copies this surface into another at given position +void CImage::copyTo(IImage *target, const core::position2d &pos) +{ + if (IImage::isCompressedFormat(Format)) { + os::Printer::log("IImage::copyTo method doesn't work with compressed images.", ELL_WARNING); + return; + } + + if (!Blit(BLITTER_TEXTURE, target, 0, &pos, this, 0, 0) && target && pos.X == 0 && pos.Y == 0 && + CColorConverter::canConvertFormat(Format, target->getColorFormat())) { + // No fast blitting, but copyToScaling uses other color conversions and might work + irr::core::dimension2du dim(target->getDimension()); + copyToScaling(target->getData(), dim.Width, dim.Height, target->getColorFormat(), target->getPitch()); + } +} + +//! copies this surface partially into another at given position +void CImage::copyTo(IImage *target, const core::position2d &pos, const core::rect &sourceRect, const core::rect *clipRect) +{ + if (IImage::isCompressedFormat(Format)) { + os::Printer::log("IImage::copyTo method doesn't work with compressed images.", ELL_WARNING); + return; + } + + Blit(BLITTER_TEXTURE, target, clipRect, &pos, this, &sourceRect, 0); +} + +//! copies this surface into another, using the alpha mask, a cliprect and a color to add with +void CImage::copyToWithAlpha(IImage *target, const core::position2d &pos, const core::rect &sourceRect, const SColor &color, const core::rect *clipRect, bool combineAlpha) +{ + if (IImage::isCompressedFormat(Format)) { + os::Printer::log("IImage::copyToWithAlpha method doesn't work with compressed images.", ELL_WARNING); + return; + } + + eBlitter op = combineAlpha ? BLITTER_TEXTURE_COMBINE_ALPHA : color.color == 0xFFFFFFFF ? BLITTER_TEXTURE_ALPHA_BLEND + : BLITTER_TEXTURE_ALPHA_COLOR_BLEND; + Blit(op, target, clipRect, &pos, this, &sourceRect, color.color); +} + +//! copies this surface into another, if it has the exact same size and format. +bool CImage::copyToNoScaling(void *target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch) const +{ + if (IImage::isCompressedFormat(Format)) { + os::Printer::log("IImage::copyToNoScaling method doesn't work with compressed images.", ELL_WARNING); + return false; + } + + if (!target || !width || !height || !Size.Width || !Size.Height) + return false; + + const u32 bpp = getBitsPerPixelFromFormat(format) / 8; + if (0 == pitch) + pitch = width * bpp; + + if (!(Format == format && Size.Width == width && Size.Height == height)) + return false; + + if (pitch == Pitch) { + memcpy(target, Data, (size_t)height * pitch); + } else { + u8 *tgtpos = (u8 *)target; + u8 *srcpos = Data; + const u32 bwidth = width * bpp; + const u32 rest = pitch - bwidth; + for (u32 y = 0; y < height; ++y) { + // copy scanline + memcpy(tgtpos, srcpos, bwidth); + // clear pitch + memset(tgtpos + bwidth, 0, rest); + tgtpos += pitch; + srcpos += Pitch; + } + } + + return true; +} + +//! copies this surface into another, scaling it to the target image size +// note: this is very very slow. +void CImage::copyToScaling(void *target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch) +{ + if (IImage::isCompressedFormat(Format)) { + os::Printer::log("IImage::copyToScaling method doesn't work with compressed images.", ELL_WARNING); + return; + } + + if (!target || !width || !height || !Size.Width || !Size.Height) + return; + + const u32 bpp = getBitsPerPixelFromFormat(format) / 8; + if (0 == pitch) + pitch = width * bpp; + + if (copyToNoScaling(target, width, height, format, pitch)) + return; + + // NOTE: Scaling is coded to keep the border pixels intact. + // Alternatively we could for example work with first pixel being taken at half step-size. + // Then we have one more step here and it would be: + // sourceXStep = (f32)(Size.Width-1) / (f32)(width); + // And sx would start at 0.5f + sourceXStep / 2.f; + // Similar for y. + // As scaling is done without any antialiasing it doesn't matter too much which outermost pixels we use and keeping + // border pixels intact is probably mostly better (with AA the other solution would be more correct). + // This is however unnecessary (and unexpected) for scaling to integer multiples, so don't do it there. + f32 sourceXStep, sourceYStep; + f32 sourceXStart = 0.f, sourceYStart = 0.f; + if (width % Size.Width == 0) + sourceXStep = (f32)(Size.Width) / (f32)(width); + else { + sourceXStep = width > 1 ? (f32)(Size.Width - 1) / (f32)(width - 1) : 0.f; + sourceXStart = 0.5f; // for rounding to nearest pixel + } + if (height % Size.Height == 0) + sourceYStep = (f32)(Size.Height) / (f32)(height); + else { + sourceYStep = height > 1 ? (f32)(Size.Height - 1) / (f32)(height - 1) : 0.f; + sourceYStart = 0.5f; // for rounding to nearest pixel + } + + s32 yval = 0, syval = 0; + f32 sy = sourceYStart; + for (u32 y = 0; y < height; ++y) { + f32 sx = sourceXStart; + for (u32 x = 0; x < width; ++x) { + CColorConverter::convert_viaFormat(Data + syval + ((s32)sx) * BytesPerPixel, Format, 1, ((u8 *)target) + yval + (x * bpp), format); + sx += sourceXStep; + } + sy += sourceYStep; + syval = (s32)(sy)*Pitch; + yval += pitch; + } +} + +//! copies this surface into another, scaling it to the target image size +// note: this is very very slow. +void CImage::copyToScaling(IImage *target) +{ + if (IImage::isCompressedFormat(Format)) { + os::Printer::log("IImage::copyToScaling method doesn't work with compressed images.", ELL_WARNING); + return; + } + + if (!target) + return; + + const core::dimension2d &targetSize = target->getDimension(); + + if (targetSize == Size) { + copyTo(target); + return; + } + + copyToScaling(target->getData(), targetSize.Width, targetSize.Height, target->getColorFormat()); +} + +//! copies this surface into another, scaling it to fit it. +void CImage::copyToScalingBoxFilter(IImage *target, s32 bias, bool blend) +{ + if (IImage::isCompressedFormat(Format)) { + os::Printer::log("IImage::copyToScalingBoxFilter method doesn't work with compressed images.", ELL_WARNING); + return; + } + + const core::dimension2d destSize = target->getDimension(); + + const f32 sourceXStep = (f32)Size.Width / (f32)destSize.Width; + const f32 sourceYStep = (f32)Size.Height / (f32)destSize.Height; + + s32 fx = core::ceil32(sourceXStep); + s32 fy = core::ceil32(sourceYStep); + f32 sx; + f32 sy; + + sy = 0.f; + for (u32 y = 0; y != destSize.Height; ++y) { + sx = 0.f; + for (u32 x = 0; x != destSize.Width; ++x) { + target->setPixel(x, y, + getPixelBox(core::floor32(sx), core::floor32(sy), fx, fy, bias), blend); + sx += sourceXStep; + } + sy += sourceYStep; + } +} + +//! fills the surface with given color +void CImage::fill(const SColor &color) +{ + if (IImage::isCompressedFormat(Format)) { + os::Printer::log("IImage::fill method doesn't work with compressed images.", ELL_WARNING); + return; + } + + u32 c; + + switch (Format) { + case ECF_A1R5G5B5: + c = color.toA1R5G5B5(); + c |= c << 16; + break; + case ECF_R5G6B5: + c = video::A8R8G8B8toR5G6B5(color.color); + c |= c << 16; + break; + case ECF_A8R8G8B8: + c = color.color; + break; + case ECF_R8G8B8: { + u8 rgb[3]; + CColorConverter::convert_A8R8G8B8toR8G8B8(&color, 1, rgb); + const u32 size = getImageDataSizeInBytes(); + for (u32 i = 0; i < size; i += 3) { + memcpy(Data + i, rgb, 3); + } + return; + } break; + default: + // TODO: Handle other formats + return; + } + memset32(Data, c, getImageDataSizeInBytes()); +} + +//! get a filtered pixel +inline SColor CImage::getPixelBox(s32 x, s32 y, s32 fx, s32 fy, s32 bias) const +{ + if (IImage::isCompressedFormat(Format)) { + os::Printer::log("IImage::getPixelBox method doesn't work with compressed images.", ELL_WARNING); + return SColor(0); + } + + SColor c; + s32 a = 0, r = 0, g = 0, b = 0; + + for (s32 dx = 0; dx != fx; ++dx) { + for (s32 dy = 0; dy != fy; ++dy) { + c = getPixel(core::s32_min(x + dx, Size.Width - 1), + core::s32_min(y + dy, Size.Height - 1)); + + a += c.getAlpha(); + r += c.getRed(); + g += c.getGreen(); + b += c.getBlue(); + } + } + + s32 sdiv = s32_log2_s32(fx * fy); + + a = core::s32_clamp((a >> sdiv) + bias, 0, 255); + r = core::s32_clamp((r >> sdiv) + bias, 0, 255); + g = core::s32_clamp((g >> sdiv) + bias, 0, 255); + b = core::s32_clamp((b >> sdiv) + bias, 0, 255); + + c.set(a, r, g, b); + return c; +} + +} // end namespace video +} // end namespace irr diff --git a/irr/src/CImage.h b/irr/src/CImage.h new file mode 100644 index 000000000..955f85705 --- /dev/null +++ b/irr/src/CImage.h @@ -0,0 +1,74 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IImage.h" +#include "rect.h" + +namespace irr +{ +namespace video +{ + +//! check sanity of image dimensions to prevent issues later, for use by CImageLoaders +inline bool checkImageDimensions(u32 width, u32 height) +{ + // 4 * 23000 * 23000 is just under S32_MAX + return width <= 23000 && height <= 23000; +} + +//! IImage implementation with a lot of special image operations for +//! 16 bit A1R5G5B5/32 Bit A8R8G8B8 images, which are used by the SoftwareDevice. +class CImage : public IImage +{ +public: + //! constructor from raw image data + /** \param useForeignMemory: If true, the image will use the data pointer + directly and own it from now on, which means it will also try to delete [] the + data when the image will be destructed. If false, the memory will by copied. */ + CImage(ECOLOR_FORMAT format, const core::dimension2d &size, void *data, + bool ownForeignMemory = true, bool deleteMemory = true); + + //! constructor for empty image + CImage(ECOLOR_FORMAT format, const core::dimension2d &size); + + //! returns a pixel + SColor getPixel(u32 x, u32 y) const override; + + //! sets a pixel + void setPixel(u32 x, u32 y, const SColor &color, bool blend = false) override; + + //! copies this surface into another, if it has the exact same size and format. + bool copyToNoScaling(void *target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch = 0) const override; + + //! copies this surface into another, scaling it to fit. + void copyToScaling(void *target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch = 0) override; + + //! copies this surface into another, scaling it to fit. + void copyToScaling(IImage *target) override; + + //! copies this surface into another + void copyTo(IImage *target, const core::position2d &pos = core::position2d(0, 0)) override; + + //! copies this surface into another + void copyTo(IImage *target, const core::position2d &pos, const core::rect &sourceRect, const core::rect *clipRect = 0) override; + + //! copies this surface into another, using the alpha mask, an cliprect and a color to add with + virtual void copyToWithAlpha(IImage *target, const core::position2d &pos, + const core::rect &sourceRect, const SColor &color, + const core::rect *clipRect = 0, bool combineAlpha = false) override; + + //! copies this surface into another, scaling it to fit, applying a box filter + void copyToScalingBoxFilter(IImage *target, s32 bias = 0, bool blend = false) override; + + //! fills the surface with given color + void fill(const SColor &color) override; + +private: + inline SColor getPixelBox(s32 x, s32 y, s32 fx, s32 fy, s32 bias) const; +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/src/CImageLoaderBMP.cpp b/irr/src/CImageLoaderBMP.cpp new file mode 100644 index 000000000..301edb2fe --- /dev/null +++ b/irr/src/CImageLoaderBMP.cpp @@ -0,0 +1,402 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CImageLoaderBMP.h" + +#include "IReadFile.h" +#include "SColor.h" +#include "CColorConverter.h" +#include "CImage.h" +#include "os.h" +#include "irrString.h" + +namespace irr +{ +namespace video +{ + +//! constructor +CImageLoaderBMP::CImageLoaderBMP() +{ +#ifdef _DEBUG + setDebugName("CImageLoaderBMP"); +#endif +} + +//! returns true if the file maybe is able to be loaded by this class +//! based on the file extension (e.g. ".tga") +bool CImageLoaderBMP::isALoadableFileExtension(const io::path &filename) const +{ + return core::hasFileExtension(filename, "bmp"); +} + +//! returns true if the file maybe is able to be loaded by this class +bool CImageLoaderBMP::isALoadableFileFormat(io::IReadFile *file) const +{ + u16 headerID; + file->read(&headerID, sizeof(u16)); +#ifdef __BIG_ENDIAN__ + headerID = os::Byteswap::byteswap(headerID); +#endif + return headerID == 0x4d42; +} + +// UB-safe overflow check +static inline bool overflowCheck(const void *base, size_t offset, const void *end) +{ + auto baseI = reinterpret_cast(base), + endI = reinterpret_cast(end); + return baseI > endI || offset >= (endI - baseI); +} +// check whether &p[0] to &p[_off - 1] can be accessed +#define CHECKP(_off) \ + if ((_off) < 0 || overflowCheck(p, _off, pEnd)) \ + goto exit +// same for d +#define CHECKD(_off) \ + if ((_off) < 0 || overflowCheck(d, _off, destEnd)) \ + goto exit + +void CImageLoaderBMP::decompress8BitRLE(u8 *&bmpData, s32 size, s32 width, s32 height, s32 pitch) const +{ + u8 *p = bmpData; + const u8 *pEnd = bmpData + size; + u8 *newBmp = new u8[(width + pitch) * height]; + u8 *d = newBmp; + const u8 *destEnd = newBmp + (width + pitch) * height; + s32 line = 0; + + while (p < pEnd && d < destEnd) { + if (*p == 0) { + ++p; + CHECKP(1); + + switch (*p) { + case 0: // end of line + ++p; + ++line; + d = newBmp + (line * (width + pitch)); + break; + case 1: // end of bmp + goto exit; + case 2: + ++p; + CHECKP(2); + d += (u8)*p; + ++p; // delta + d += ((u8)*p) * (width + pitch); + ++p; + break; + default: { + // absolute mode + s32 count = (u8)*p; + ++p; + s32 readAdditional = ((2 - (count % 2)) % 2); + + CHECKP(count); + CHECKD(count); + for (s32 i = 0; i < count; ++i) { + *d = *p; + ++p; + ++d; + } + + CHECKP(readAdditional); + for (s32 i = 0; i < readAdditional; ++i) + ++p; + } + } + } else { + s32 count = (u8)*p; + ++p; + CHECKP(1); + u8 color = *p; + ++p; + CHECKD(count); + for (s32 i = 0; i < count; ++i) { + *d = color; + ++d; + } + } + } + +exit: + delete[] bmpData; + bmpData = newBmp; +} + +// how many bytes will be touched given the current state of decompress4BitRLE +static inline u32 shiftedCount(s32 count, s32 shift) +{ + _IRR_DEBUG_BREAK_IF(count < 0) + u32 ret = count / 2; + if (shift == 0 || count % 2 == 1) + ++ret; + return ret; +} + +void CImageLoaderBMP::decompress4BitRLE(u8 *&bmpData, s32 size, s32 width, s32 height, s32 pitch) const +{ + const s32 lineWidth = (width + 1) / 2 + pitch; + u8 *p = bmpData; + const u8 *pEnd = bmpData + size; + u8 *newBmp = new u8[lineWidth * height]; + u8 *d = newBmp; + const u8 *destEnd = newBmp + lineWidth * height; + s32 line = 0; + s32 shift = 4; + + while (p < pEnd && d < destEnd) { + if (*p == 0) { + ++p; + CHECKP(1); + + switch (*p) { + case 0: // end of line + ++p; + ++line; + d = newBmp + (line * lineWidth); + shift = 4; + break; + case 1: // end of bmp + goto exit; + case 2: { + ++p; + CHECKP(2); + s32 x = (u8)*p; + ++p; + s32 y = (u8)*p; + ++p; + d += x / 2 + y * lineWidth; + shift = x % 2 == 0 ? 4 : 0; + } break; + default: { + // absolute mode + s32 count = (u8)*p; + ++p; + s32 readAdditional = ((2 - ((count) % 2)) % 2); + s32 readShift = 4; + + CHECKP(shiftedCount(count, readShift)); + CHECKD(shiftedCount(count, shift)); + for (s32 i = 0; i < count; ++i) { + s32 color = (((u8)*p) >> readShift) & 0x0f; + readShift -= 4; + if (readShift < 0) { + ++*p; // <- bug? + readShift = 4; + } + + u8 mask = 0x0f << shift; + *d = (*d & (~mask)) | ((color << shift) & mask); + + shift -= 4; + if (shift < 0) { + shift = 4; + ++d; + } + } + + CHECKP(readAdditional); + for (s32 i = 0; i < readAdditional; ++i) + ++p; + } + } + } else { + s32 count = (u8)*p; + ++p; + CHECKP(1); + s32 color1 = (u8)*p; + color1 = color1 & 0x0f; + s32 color2 = (u8)*p; + color2 = (color2 >> 4) & 0x0f; + ++p; + + CHECKD(shiftedCount(count, shift)); + for (s32 i = 0; i < count; ++i) { + u8 mask = 0x0f << shift; + u8 toSet = (shift == 0 ? color1 : color2) << shift; + *d = (*d & (~mask)) | (toSet & mask); + + shift -= 4; + if (shift < 0) { + shift = 4; + ++d; + } + } + } + } + +exit: + delete[] bmpData; + bmpData = newBmp; +} + +#undef CHECKOFF +#undef CHECKP +#undef CHECKD + +//! creates a surface from the file +IImage *CImageLoaderBMP::loadImage(io::IReadFile *file) const +{ + SBMPHeader header; + + file->read(&header, sizeof(header)); + +#ifdef __BIG_ENDIAN__ + header.Id = os::Byteswap::byteswap(header.Id); + header.FileSize = os::Byteswap::byteswap(header.FileSize); + header.BitmapDataOffset = os::Byteswap::byteswap(header.BitmapDataOffset); + header.BitmapHeaderSize = os::Byteswap::byteswap(header.BitmapHeaderSize); + header.Width = os::Byteswap::byteswap(header.Width); + header.Height = os::Byteswap::byteswap(header.Height); + header.Planes = os::Byteswap::byteswap(header.Planes); + header.BPP = os::Byteswap::byteswap(header.BPP); + header.Compression = os::Byteswap::byteswap(header.Compression); + header.BitmapDataSize = os::Byteswap::byteswap(header.BitmapDataSize); + header.PixelPerMeterX = os::Byteswap::byteswap(header.PixelPerMeterX); + header.PixelPerMeterY = os::Byteswap::byteswap(header.PixelPerMeterY); + header.Colors = os::Byteswap::byteswap(header.Colors); + header.ImportantColors = os::Byteswap::byteswap(header.ImportantColors); +#endif + + s32 pitch = 0; + + //! return if the header is false + + if (header.Id != 0x4d42) + return 0; + + if (header.Compression > 2) { // we'll only handle RLE-Compression + os::Printer::log("Compression mode not supported.", ELL_ERROR); + return 0; + } + + if (header.BPP > 32 || !checkImageDimensions(header.Width, header.Height)) { + os::Printer::log("Rejecting BMP with unreasonable size or BPP.", ELL_ERROR); + return 0; + } + + // adjust bitmap data size to dword boundary + header.BitmapDataSize += (4 - (header.BitmapDataSize % 4)) % 4; + + // read palette + + long pos = file->getPos(); + constexpr s32 paletteAllocSize = 256; + s32 paletteSize = (header.BitmapDataOffset - pos) / 4; + paletteSize = core::clamp(paletteSize, 0, paletteAllocSize); + + s32 *paletteData = 0; + if (paletteSize) { + // always allocate an 8-bit palette to ensure enough space + paletteData = new s32[paletteAllocSize]; + memset(paletteData, 0, paletteAllocSize * sizeof(s32)); + file->read(paletteData, paletteSize * sizeof(s32)); +#ifdef __BIG_ENDIAN__ + for (s32 i = 0; i < paletteSize; ++i) + paletteData[i] = os::Byteswap::byteswap(paletteData[i]); +#endif + } + + // read image data + + if (!header.BitmapDataSize) { + // okay, lets guess the size + // some tools simply don't set it + header.BitmapDataSize = static_cast(file->getSize()) - header.BitmapDataOffset; + } + + file->seek(header.BitmapDataOffset); + + s32 widthInBytes; + { + f32 t = (header.Width) * (header.BPP / 8.0f); + widthInBytes = (s32)t; + t -= widthInBytes; + if (t != 0.0f) + ++widthInBytes; + } + + const s32 lineSize = widthInBytes + ((4 - (widthInBytes % 4))) % 4; + pitch = lineSize - widthInBytes; + + u8 *bmpData = new u8[header.BitmapDataSize]; + file->read(bmpData, header.BitmapDataSize); + + // decompress data if needed + switch (header.Compression) { + case 1: // 8 bit rle + decompress8BitRLE(bmpData, header.BitmapDataSize, header.Width, header.Height, pitch); + header.BitmapDataSize = (header.Width + pitch) * header.Height; + break; + case 2: // 4 bit rle + decompress4BitRLE(bmpData, header.BitmapDataSize, header.Width, header.Height, pitch); + header.BitmapDataSize = ((header.Width + 1) / 2 + pitch) * header.Height; + break; + } + + if (header.BitmapDataSize < lineSize * header.Height) { + os::Printer::log("Bitmap data is cut off.", ELL_ERROR); + + delete[] paletteData; + delete[] bmpData; + return 0; + } + + // create surface + core::dimension2d dim; + dim.Width = header.Width; + dim.Height = header.Height; + + IImage *image = 0; + switch (header.BPP) { + case 1: + image = new CImage(ECF_A1R5G5B5, dim); + if (image) + CColorConverter::convert1BitTo16Bit(bmpData, (s16 *)image->getData(), header.Width, header.Height, pitch, true); + break; + case 4: + image = new CImage(ECF_A1R5G5B5, dim); + if (image) + CColorConverter::convert4BitTo16Bit(bmpData, (s16 *)image->getData(), header.Width, header.Height, paletteData, pitch, true); + break; + case 8: + image = new CImage(ECF_A1R5G5B5, dim); + if (image) + CColorConverter::convert8BitTo16Bit(bmpData, (s16 *)image->getData(), header.Width, header.Height, paletteData, pitch, true); + break; + case 16: + image = new CImage(ECF_A1R5G5B5, dim); + if (image) + CColorConverter::convert16BitTo16Bit((s16 *)bmpData, (s16 *)image->getData(), header.Width, header.Height, pitch, true); + break; + case 24: + image = new CImage(ECF_R8G8B8, dim); + if (image) + CColorConverter::convert24BitTo24Bit(bmpData, (u8 *)image->getData(), header.Width, header.Height, pitch, true, true); + break; + case 32: // thx to Reinhard Ostermeier + image = new CImage(ECF_A8R8G8B8, dim); + if (image) + CColorConverter::convert32BitTo32Bit((s32 *)bmpData, (s32 *)image->getData(), header.Width, header.Height, pitch, true); + break; + }; + + // clean up + + delete[] paletteData; + delete[] bmpData; + + return image; +} + +//! creates a loader which is able to load windows bitmaps +IImageLoader *createImageLoaderBMP() +{ + return new CImageLoaderBMP; +} + +} // end namespace video +} // end namespace irr diff --git a/irr/src/CImageLoaderBMP.h b/irr/src/CImageLoaderBMP.h new file mode 100644 index 000000000..e7ef8ed2b --- /dev/null +++ b/irr/src/CImageLoaderBMP.h @@ -0,0 +1,81 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IImageLoader.h" + +namespace irr +{ +namespace video +{ + +// byte-align structures +#include "irrpack.h" + +struct SBMPHeader +{ + u16 Id; // BM - Windows 3.1x, 95, NT, 98, 2000, ME, XP + // BA - OS/2 Bitmap Array + // CI - OS/2 Color Icon + // CP - OS/2 Color Pointer + // IC - OS/2 Icon + // PT - OS/2 Pointer + u32 FileSize; + u32 Reserved; + u32 BitmapDataOffset; + u32 BitmapHeaderSize; // should be 28h for windows bitmaps or + // 0Ch for OS/2 1.x or F0h for OS/2 2.x + u32 Width; + u32 Height; + u16 Planes; + u16 BPP; // 1: Monochrome bitmap + // 4: 16 color bitmap + // 8: 256 color bitmap + // 16: 16bit (high color) bitmap + // 24: 24bit (true color) bitmap + // 32: 32bit (true color) bitmap + + u32 Compression; // 0: none (Also identified by BI_RGB) + // 1: RLE 8-bit / pixel (Also identified by BI_RLE4) + // 2: RLE 4-bit / pixel (Also identified by BI_RLE8) + // 3: Bitfields (Also identified by BI_BITFIELDS) + + u32 BitmapDataSize; // Size of the bitmap data in bytes. This number must be rounded to the next 4 byte boundary. + u32 PixelPerMeterX; + u32 PixelPerMeterY; + u32 Colors; + u32 ImportantColors; +} PACK_STRUCT; + +// Default alignment +#include "irrunpack.h" + +/*! + Surface Loader for Windows bitmaps +*/ +class CImageLoaderBMP : public IImageLoader +{ +public: + //! constructor + CImageLoaderBMP(); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".tga") + bool isALoadableFileExtension(const io::path &filename) const override; + + //! returns true if the file maybe is able to be loaded by this class + bool isALoadableFileFormat(io::IReadFile *file) const override; + + //! creates a surface from the file + IImage *loadImage(io::IReadFile *file) const override; + +private: + void decompress8BitRLE(u8 *&BmpData, s32 size, s32 width, s32 height, s32 pitch) const; + + void decompress4BitRLE(u8 *&BmpData, s32 size, s32 width, s32 height, s32 pitch) const; +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/src/CImageLoaderJPG.cpp b/irr/src/CImageLoaderJPG.cpp new file mode 100644 index 000000000..e64c458e7 --- /dev/null +++ b/irr/src/CImageLoaderJPG.cpp @@ -0,0 +1,263 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CImageLoaderJPG.h" + +#include "IReadFile.h" +#include "CImage.h" +#include "os.h" +#include "irrString.h" + +namespace irr +{ +namespace video +{ + +//! constructor +CImageLoaderJPG::CImageLoaderJPG() +{ +#ifdef _DEBUG + setDebugName("CImageLoaderJPG"); +#endif +} + +//! destructor +CImageLoaderJPG::~CImageLoaderJPG() +{ +} + +//! returns true if the file maybe is able to be loaded by this class +//! based on the file extension (e.g. ".tga") +bool CImageLoaderJPG::isALoadableFileExtension(const io::path &filename) const +{ + return core::hasFileExtension(filename, "jpg", "jpeg"); +} + +// struct for handling jpeg errors +struct irr_jpeg_error_mgr +{ + // public jpeg error fields + struct jpeg_error_mgr pub; + + // for longjmp, to return to caller on a fatal error + jmp_buf setjmp_buffer; + + // for having access to the filename when printing the error messages + core::stringc *filename; +}; + +void CImageLoaderJPG::init_source(j_decompress_ptr cinfo) +{ + // DO NOTHING +} + +boolean CImageLoaderJPG::fill_input_buffer(j_decompress_ptr cinfo) +{ + // DO NOTHING + return TRUE; +} + +void CImageLoaderJPG::skip_input_data(j_decompress_ptr cinfo, long count) +{ + jpeg_source_mgr *src = cinfo->src; + if (count > 0) { + src->bytes_in_buffer -= count; + src->next_input_byte += count; + } +} + +void CImageLoaderJPG::term_source(j_decompress_ptr cinfo) +{ + // DO NOTHING +} + +void CImageLoaderJPG::error_exit(j_common_ptr cinfo) +{ + // unfortunately we need to use a goto rather than throwing an exception + // as gcc crashes under linux crashes when using throw from within + // extern c code + + // Always display the message + (*cinfo->err->output_message)(cinfo); + + // cinfo->err really points to a irr_error_mgr struct + irr_jpeg_error_mgr *myerr = (irr_jpeg_error_mgr *)cinfo->err; + + longjmp(myerr->setjmp_buffer, 1); +} + +void CImageLoaderJPG::output_message(j_common_ptr cinfo) +{ + // display the error message. + c8 temp1[JMSG_LENGTH_MAX]; + (*cinfo->err->format_message)(cinfo, temp1); + core::stringc errMsg("JPEG FATAL ERROR in "); + + irr_jpeg_error_mgr *myerr = (irr_jpeg_error_mgr *)cinfo->err; + errMsg += *myerr->filename; + os::Printer::log(errMsg.c_str(), temp1, ELL_ERROR); +} + +//! returns true if the file maybe is able to be loaded by this class +bool CImageLoaderJPG::isALoadableFileFormat(io::IReadFile *file) const +{ + if (!(file && file->seek(0))) + return false; + unsigned char header[3]; + size_t headerLen = file->read(header, sizeof(header)); + return headerLen >= 3 && !memcmp(header, "\xFF\xD8\xFF", 3); +} + +//! creates a surface from the file +IImage *CImageLoaderJPG::loadImage(io::IReadFile *file) const +{ + if (!file) + return 0; + + core::stringc filename = file->getFileName(); + + u8 **rowPtr = 0; + u8 *input = new u8[file->getSize()]; + file->read(input, file->getSize()); + + // allocate and initialize JPEG decompression object + struct jpeg_decompress_struct cinfo; + struct irr_jpeg_error_mgr jerr; + + // We have to set up the error handler first, in case the initialization + // step fails. (Unlikely, but it could happen if you are out of memory.) + // This routine fills in the contents of struct jerr, and returns jerr's + // address which we place into the link field in cinfo. + + cinfo.err = jpeg_std_error(&jerr.pub); + cinfo.err->error_exit = error_exit; + cinfo.err->output_message = output_message; + jerr.filename = &filename; + + // compatibility fudge: + // we need to use setjmp/longjmp for error handling as gcc-linux + // crashes when throwing within external c code + if (setjmp(jerr.setjmp_buffer)) { + // If we get here, the JPEG code has signaled an error. + // We need to clean up the JPEG object and return. + + jpeg_destroy_decompress(&cinfo); + + delete[] input; + delete[] rowPtr; + + // return null pointer + return 0; + } + + // Now we can initialize the JPEG decompression object. + jpeg_create_decompress(&cinfo); + + // specify data source + jpeg_source_mgr jsrc; + + // Set up data pointer + jsrc.bytes_in_buffer = file->getSize(); + jsrc.next_input_byte = (JOCTET *)input; + cinfo.src = &jsrc; + + jsrc.init_source = init_source; + jsrc.fill_input_buffer = fill_input_buffer; + jsrc.skip_input_data = skip_input_data; + jsrc.resync_to_restart = jpeg_resync_to_restart; + jsrc.term_source = term_source; + + // Decodes JPG input from whatever source + // Does everything AFTER jpeg_create_decompress + // and BEFORE jpeg_destroy_decompress + // Caller is responsible for arranging these + setting up cinfo + + // read file parameters with jpeg_read_header() + jpeg_read_header(&cinfo, TRUE); + + bool useCMYK = false; + if (cinfo.jpeg_color_space == JCS_CMYK) { + cinfo.out_color_space = JCS_CMYK; + cinfo.out_color_components = 4; + useCMYK = true; + } else { + cinfo.out_color_space = JCS_RGB; + cinfo.out_color_components = 3; + } + cinfo.output_gamma = 2.2; + cinfo.do_fancy_upsampling = FALSE; + + // reject unreasonable sizes + if (!checkImageDimensions(cinfo.image_width, cinfo.image_height)) + longjmp(jerr.setjmp_buffer, 1); + + // Start decompressor + jpeg_start_decompress(&cinfo); + + // Get image data + u32 rowspan = cinfo.image_width * cinfo.out_color_components; + u32 width = cinfo.image_width; + u32 height = cinfo.image_height; + + // Allocate memory for buffer + u8 *output = new u8[rowspan * height]; + + // Here we use the library's state variable cinfo.output_scanline as the + // loop counter, so that we don't have to keep track ourselves. + // Create array of row pointers for lib + rowPtr = new u8 *[height]; + + for (u32 i = 0; i < height; i++) + rowPtr[i] = &output[i * rowspan]; + + u32 rowsRead = 0; + + while (cinfo.output_scanline < cinfo.output_height) + rowsRead += jpeg_read_scanlines(&cinfo, &rowPtr[rowsRead], cinfo.output_height - rowsRead); + + delete[] rowPtr; + // Finish decompression + + jpeg_finish_decompress(&cinfo); + + // Release JPEG decompression object + // This is an important step since it will release a good deal of memory. + jpeg_destroy_decompress(&cinfo); + + // convert image + IImage *image = 0; + if (useCMYK) { + image = new CImage(ECF_R8G8B8, + core::dimension2d(width, height)); + const u32 size = 3 * width * height; + u8 *data = (u8 *)image->getData(); + if (data) { + for (u32 i = 0, j = 0; i < size; i += 3, j += 4) { + // Also works without K, but has more contrast with K multiplied in + // data[i+0] = output[j+2]; + // data[i+1] = output[j+1]; + // data[i+2] = output[j+0]; + data[i + 0] = (char)(output[j + 2] * (output[j + 3] / 255.f)); + data[i + 1] = (char)(output[j + 1] * (output[j + 3] / 255.f)); + data[i + 2] = (char)(output[j + 0] * (output[j + 3] / 255.f)); + } + } + delete[] output; + } else + image = new CImage(ECF_R8G8B8, + core::dimension2d(width, height), output); + + delete[] input; + + return image; +} + +//! creates a loader which is able to load jpeg images +IImageLoader *createImageLoaderJPG() +{ + return new CImageLoaderJPG(); +} + +} // end namespace video +} // end namespace irr diff --git a/irr/src/CImageLoaderJPG.h b/irr/src/CImageLoaderJPG.h new file mode 100644 index 000000000..921a46a25 --- /dev/null +++ b/irr/src/CImageLoaderJPG.h @@ -0,0 +1,87 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IImageLoader.h" + +#include // required for jpeglib.h +#include // use system lib +#include + +namespace irr +{ +namespace video +{ + +//! Surface Loader for JPG images +class CImageLoaderJPG : public IImageLoader +{ +public: + //! constructor + CImageLoaderJPG(); + + //! destructor + virtual ~CImageLoaderJPG(); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".tga") + bool isALoadableFileExtension(const io::path &filename) const override; + + //! returns true if the file maybe is able to be loaded by this class + bool isALoadableFileFormat(io::IReadFile *file) const override; + + //! creates a surface from the file + IImage *loadImage(io::IReadFile *file) const override; + +private: + // several methods used via function pointers by jpeglib + + /* Receives control for a fatal error. Information sufficient to + generate the error message has been stored in cinfo->err; call + output_message to display it. Control must NOT return to the caller; + generally this routine will exit() or longjmp() somewhere. + Typically you would override this routine to get rid of the exit() + default behavior. Note that if you continue processing, you should + clean up the JPEG object with jpeg_abort() or jpeg_destroy(). + */ + static void error_exit(j_common_ptr cinfo); + + /* output error messages via Irrlicht logger. */ + static void output_message(j_common_ptr cinfo); + + /* Initialize source. This is called by jpeg_read_header() before any + data is actually read. Unlike init_destination(), it may leave + bytes_in_buffer set to 0 (in which case a fill_input_buffer() call + will occur immediately). */ + static void init_source(j_decompress_ptr cinfo); + + /* This is called whenever bytes_in_buffer has reached zero and more + data is wanted. In typical applications, it should read fresh data + into the buffer (ignoring the current state of next_input_byte and + bytes_in_buffer), reset the pointer & count to the start of the + buffer, and return TRUE indicating that the buffer has been reloaded. + It is not necessary to fill the buffer entirely, only to obtain at + least one more byte. bytes_in_buffer MUST be set to a positive value + if TRUE is returned. A FALSE return should only be used when I/O + suspension is desired (this mode is discussed in the next section). */ + static boolean fill_input_buffer(j_decompress_ptr cinfo); + + /* Skip num_bytes worth of data. The buffer pointer and count should + be advanced over num_bytes input bytes, refilling the buffer as + needed. This is used to skip over a potentially large amount of + uninteresting data (such as an APPn marker). In some applications + it may be possible to optimize away the reading of the skipped data, + but it's not clear that being smart is worth much trouble; large + skips are uncommon. bytes_in_buffer may be zero on return. + A zero or negative skip count should be treated as a no-op. */ + static void skip_input_data(j_decompress_ptr cinfo, long num_bytes); + + /* Terminate source --- called by jpeg_finish_decompress() after all + data has been read. Often a no-op. */ + static void term_source(j_decompress_ptr cinfo); +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/src/CImageLoaderPNG.cpp b/irr/src/CImageLoaderPNG.cpp new file mode 100644 index 000000000..42cfc51d2 --- /dev/null +++ b/irr/src/CImageLoaderPNG.cpp @@ -0,0 +1,248 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CImageLoaderPNG.h" + +#include // use system lib png + +#include "CImage.h" +#include "CReadFile.h" +#include "os.h" + +namespace irr +{ +namespace video +{ + +// PNG function for error handling +static void png_cpexcept_error(png_structp png_ptr, png_const_charp msg) +{ + os::Printer::log("PNG fatal error", msg, ELL_ERROR); + longjmp(png_jmpbuf(png_ptr), 1); +} + +// PNG function for warning handling +static void png_cpexcept_warn(png_structp png_ptr, png_const_charp msg) +{ + os::Printer::log("PNG warning", msg, ELL_WARNING); +} + +// PNG function for file reading +void PNGAPI user_read_data_fcn(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_size_t check; + + // changed by zola { + io::IReadFile *file = (io::IReadFile *)png_get_io_ptr(png_ptr); + check = (png_size_t)file->read((void *)data, length); + // } + + if (check != length) + png_error(png_ptr, "Read Error"); +} + +//! returns true if the file maybe is able to be loaded by this class +//! based on the file extension (e.g. ".tga") +bool CImageLoaderPng::isALoadableFileExtension(const io::path &filename) const +{ + return core::hasFileExtension(filename, "png"); +} + +//! returns true if the file maybe is able to be loaded by this class +bool CImageLoaderPng::isALoadableFileFormat(io::IReadFile *file) const +{ + if (!file) + return false; + + png_byte buffer[8]; + // Read the first few bytes of the PNG file + if (file->read(buffer, 8) != 8) + return false; + + // Check if it really is a PNG file + return !png_sig_cmp(buffer, 0, 8); +} + +// load in the image data +IImage *CImageLoaderPng::loadImage(io::IReadFile *file) const +{ + if (!file) + return 0; + + // Used to point to image rows + u8 **RowPointers = 0; + + png_byte buffer[8]; + // Read the first few bytes of the PNG file + if (file->read(buffer, 8) != 8) { + os::Printer::log("LOAD PNG: can't read file (filesize < 8)", file->getFileName(), ELL_ERROR); + return 0; + } + + // Check if it really is a PNG file + if (png_sig_cmp(buffer, 0, 8)) { + os::Printer::log("LOAD PNG: not really a png (wrong signature)", file->getFileName(), ELL_ERROR); + return 0; + } + + // Allocate the png read struct + png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, + NULL, (png_error_ptr)png_cpexcept_error, (png_error_ptr)png_cpexcept_warn); + if (!png_ptr) { + os::Printer::log("LOAD PNG: Internal PNG create read struct failure", file->getFileName(), ELL_ERROR); + return 0; + } + + // Allocate the png info struct + png_infop info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) { + os::Printer::log("LOAD PNG: Internal PNG create info struct failure", file->getFileName(), ELL_ERROR); + png_destroy_read_struct(&png_ptr, NULL, NULL); + return 0; + } + + // for proper error handling + if (setjmp(png_jmpbuf(png_ptr))) { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + delete[] RowPointers; + return 0; + } + + // changed by zola so we don't need to have public FILE pointers + png_set_read_fn(png_ptr, file, user_read_data_fcn); + + png_set_sig_bytes(png_ptr, 8); // Tell png that we read the signature + + png_read_info(png_ptr, info_ptr); // Read the info section of the png file + + u32 Width; + u32 Height; + s32 BitDepth; + s32 ColorType; + { + // Use temporary variables to avoid passing cast pointers + png_uint_32 w, h; + // Extract info + png_get_IHDR(png_ptr, info_ptr, + &w, &h, + &BitDepth, &ColorType, NULL, NULL, NULL); + Width = w; + Height = h; + } + + if (!checkImageDimensions(Width, Height)) + png_cpexcept_error(png_ptr, "Unreasonable size"); + + // Convert palette color to true color + if (ColorType == PNG_COLOR_TYPE_PALETTE) + png_set_palette_to_rgb(png_ptr); + + // Convert low bit colors to 8 bit colors + if (BitDepth < 8) { + if (ColorType == PNG_COLOR_TYPE_GRAY || ColorType == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_expand_gray_1_2_4_to_8(png_ptr); + else + png_set_packing(png_ptr); + } + + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) + png_set_tRNS_to_alpha(png_ptr); + + // Convert high bit colors to 8 bit colors + if (BitDepth == 16) + png_set_strip_16(png_ptr); + + // Convert gray color to true color + if (ColorType == PNG_COLOR_TYPE_GRAY || ColorType == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_gray_to_rgb(png_ptr); + + int intent; + const double screen_gamma = 2.2; + + if (png_get_sRGB(png_ptr, info_ptr, &intent)) + png_set_gamma(png_ptr, screen_gamma, 0.45455); + else { + double image_gamma; + if (png_get_gAMA(png_ptr, info_ptr, &image_gamma)) + png_set_gamma(png_ptr, screen_gamma, image_gamma); + else + png_set_gamma(png_ptr, screen_gamma, 0.45455); + } + + // Update the changes in between, as we need to get the new color type + // for proper processing of the RGBA type + png_read_update_info(png_ptr, info_ptr); + { + // Use temporary variables to avoid passing cast pointers + png_uint_32 w, h; + // Extract info + png_get_IHDR(png_ptr, info_ptr, + &w, &h, + &BitDepth, &ColorType, NULL, NULL, NULL); + Width = w; + Height = h; + } + + // Convert RGBA to BGRA + if (ColorType == PNG_COLOR_TYPE_RGB_ALPHA) { +#ifdef __BIG_ENDIAN__ + png_set_swap_alpha(png_ptr); +#else + png_set_bgr(png_ptr); +#endif + } + + // Create the image structure to be filled by png data + video::IImage *image = 0; + if (ColorType == PNG_COLOR_TYPE_RGB_ALPHA) + image = new CImage(ECF_A8R8G8B8, core::dimension2d(Width, Height)); + else + image = new CImage(ECF_R8G8B8, core::dimension2d(Width, Height)); + if (!image) { + os::Printer::log("LOAD PNG: Internal PNG create image struct failure", file->getFileName(), ELL_ERROR); + png_destroy_read_struct(&png_ptr, NULL, NULL); + return 0; + } + + // Create array of pointers to rows in image data + RowPointers = new png_bytep[Height]; + if (!RowPointers) { + os::Printer::log("LOAD PNG: Internal PNG create row pointers failure", file->getFileName(), ELL_ERROR); + png_destroy_read_struct(&png_ptr, NULL, NULL); + delete image; + return 0; + } + + // Fill array of pointers to rows in image data + unsigned char *data = (unsigned char *)image->getData(); + for (u32 i = 0; i < Height; ++i) { + RowPointers[i] = data; + data += image->getPitch(); + } + + // for proper error handling + if (setjmp(png_jmpbuf(png_ptr))) { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + delete[] RowPointers; + delete image; + return 0; + } + + // Read data using the library function that handles all transformations including interlacing + png_read_image(png_ptr, RowPointers); + + png_read_end(png_ptr, NULL); + delete[] RowPointers; + png_destroy_read_struct(&png_ptr, &info_ptr, 0); // Clean up memory + + return image; +} + +IImageLoader *createImageLoaderPNG() +{ + return new CImageLoaderPng(); +} + +} // end namespace irr +} // end namespace video diff --git a/irr/src/CImageLoaderPNG.h b/irr/src/CImageLoaderPNG.h new file mode 100644 index 000000000..f878320ba --- /dev/null +++ b/irr/src/CImageLoaderPNG.h @@ -0,0 +1,34 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +// this file was created by rt (www.tomkorp.com), based on ttk's png-reader +// i wanted to be able to read in PNG images with irrlicht :) +// why? lossless compression with 8-bit alpha channel! + +#pragma once + +#include "IImageLoader.h" + +namespace irr +{ +namespace video +{ + +//! Surface Loader for PNG files +class CImageLoaderPng : public IImageLoader +{ +public: + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".png") + bool isALoadableFileExtension(const io::path &filename) const override; + + //! returns true if the file maybe is able to be loaded by this class + bool isALoadableFileFormat(io::IReadFile *file) const override; + + //! creates a surface from the file + IImage *loadImage(io::IReadFile *file) const override; +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/src/CImageLoaderTGA.cpp b/irr/src/CImageLoaderTGA.cpp new file mode 100644 index 000000000..5b7cc6143 --- /dev/null +++ b/irr/src/CImageLoaderTGA.cpp @@ -0,0 +1,246 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CImageLoaderTGA.h" + +#include "IReadFile.h" +#include "os.h" +#include "CColorConverter.h" +#include "CImage.h" +#include "irrString.h" + +#define MAX(x, y) (((x) > (y)) ? (x) : (y)) + +namespace irr +{ +namespace video +{ + +//! returns true if the file maybe is able to be loaded by this class +//! based on the file extension (e.g. ".tga") +bool CImageLoaderTGA::isALoadableFileExtension(const io::path &filename) const +{ + return core::hasFileExtension(filename, "tga"); +} + +//! loads a compressed tga. +u8 *CImageLoaderTGA::loadCompressedImage(io::IReadFile *file, const STGAHeader &header) const +{ + // This was written and sent in by Jon Pry, thank you very much! + // I only changed the formatting a little bit. + + const u32 bytesPerPixel = header.PixelDepth / 8; + const u32 imageSize = header.ImageHeight * header.ImageWidth * bytesPerPixel; + u8 *data = new u8[imageSize]; + u32 currentByte = 0; + + while (currentByte < imageSize) { + u8 chunkheader = 0; + file->read(&chunkheader, sizeof(u8)); // Read The Chunk's Header + + if (chunkheader < 128) { // If The Chunk Is A 'RAW' Chunk + chunkheader++; // Add 1 To The Value To Get Total Number Of Raw Pixels + + const u32 bytesToRead = bytesPerPixel * chunkheader; + if (currentByte + bytesToRead <= imageSize) { + file->read(&data[currentByte], bytesToRead); + currentByte += bytesToRead; + } else { + os::Printer::log("Compressed TGA file RAW chunk tries writing beyond buffer", file->getFileName(), ELL_WARNING); + break; + } + } else { + // thnx to neojzs for some fixes with this code + + // If It's An RLE Header + chunkheader -= 127; // Subtract 127 To Get Rid Of The ID Bit + + u32 dataOffset = currentByte; + if (dataOffset + bytesPerPixel < imageSize) { + file->read(&data[dataOffset], bytesPerPixel); + currentByte += bytesPerPixel; + } else { + os::Printer::log("Compressed TGA file RLE headertries writing beyond buffer", file->getFileName(), ELL_WARNING); + break; + } + + for (u32 counter = 1; counter < chunkheader; counter++) { + if (currentByte + bytesPerPixel <= imageSize) { + for (u32 elementCounter = 0; elementCounter < bytesPerPixel; elementCounter++) { + data[currentByte + elementCounter] = data[dataOffset + elementCounter]; + } + } + + currentByte += bytesPerPixel; + } + } + } + + return data; +} + +//! returns true if the file maybe is able to be loaded by this class +bool CImageLoaderTGA::isALoadableFileFormat(io::IReadFile *file) const +{ + if (!file) + return false; + + STGAFooter footer; + memset(&footer, 0, sizeof(STGAFooter)); + file->seek(file->getSize() - sizeof(STGAFooter)); + file->read(&footer, sizeof(STGAFooter)); + return (!strcmp(footer.Signature, "TRUEVISION-XFILE.")); // very old tgas are refused. +} + +//! creates a surface from the file +IImage *CImageLoaderTGA::loadImage(io::IReadFile *file) const +{ + STGAHeader header; + u32 *palette = 0; + + file->read(&header, sizeof(STGAHeader)); + +#ifdef __BIG_ENDIAN__ + header.ColorMapLength = os::Byteswap::byteswap(header.ColorMapLength); + header.ImageWidth = os::Byteswap::byteswap(header.ImageWidth); + header.ImageHeight = os::Byteswap::byteswap(header.ImageHeight); +#endif + + if (!checkImageDimensions(header.ImageWidth, header.ImageHeight)) { + os::Printer::log("Image dimensions too large in file", file->getFileName(), ELL_ERROR); + return 0; + } + + // skip image identification field + if (header.IdLength) + file->seek(header.IdLength, true); + + if (header.ColorMapType) { + // Create 32 bit palette + // `core::max_()` is not used here because it takes its inputs as references. Since `header` is packed, use the macro `MAX()` instead: + const irr::u16 paletteSize = MAX((u16)256u, header.ColorMapLength); // ColorMapLength can lie, but so far we only use palette for 8-bit, so ensure it has 256 entries + palette = new u32[paletteSize]; + + if (paletteSize > header.ColorMapLength) { + // To catch images using palette colors with invalid indices + const irr::u32 errorCol = irr::video::SColor(255, 255, 0, 205).color; // bright magenta + for (irr::u16 i = header.ColorMapLength; i < paletteSize; ++i) + palette[i] = errorCol; + } + + // read color map + u8 *colorMap = new u8[header.ColorMapEntrySize / 8 * header.ColorMapLength]; + file->read(colorMap, header.ColorMapEntrySize / 8 * header.ColorMapLength); + + // convert to 32-bit palette + switch (header.ColorMapEntrySize) { + case 16: + CColorConverter::convert_A1R5G5B5toA8R8G8B8(colorMap, header.ColorMapLength, palette); + break; + case 24: + CColorConverter::convert_B8G8R8toA8R8G8B8(colorMap, header.ColorMapLength, palette); + break; + case 32: + CColorConverter::convert_B8G8R8A8toA8R8G8B8(colorMap, header.ColorMapLength, palette); + break; + } + delete[] colorMap; + } + + // read image + + u8 *data = 0; + + if (header.ImageType == 1 || // Uncompressed, color-mapped images. + header.ImageType == 2 || // Uncompressed, RGB images + header.ImageType == 3 // Uncompressed, black and white images + ) { + const s32 imageSize = header.ImageHeight * header.ImageWidth * (header.PixelDepth / 8); + data = new u8[imageSize]; + file->read(data, imageSize); + } else if (header.ImageType == 10) { + // Runlength encoded RGB images + data = loadCompressedImage(file, header); + } else { + os::Printer::log("Unsupported TGA file type", file->getFileName(), ELL_ERROR); + delete[] palette; + return 0; + } + + IImage *image = 0; + + switch (header.PixelDepth) { + case 8: { + if (header.ImageType == 3) { // grey image + image = new CImage(ECF_R8G8B8, + core::dimension2d(header.ImageWidth, header.ImageHeight)); + if (image) + CColorConverter::convert8BitTo24Bit((u8 *)data, + (u8 *)image->getData(), + header.ImageWidth, header.ImageHeight, + 0, 0, (header.ImageDescriptor & 0x20) == 0); + } else { + switch (header.ColorMapEntrySize) { + case 16: + image = new CImage(ECF_A1R5G5B5, core::dimension2d(header.ImageWidth, header.ImageHeight)); + if (image) + CColorConverter::convert8BitTo16Bit((u8 *)data, + (s16 *)image->getData(), + header.ImageWidth, header.ImageHeight, + (s32 *)palette, 0, + (header.ImageDescriptor & 0x20) == 0); + break; + // Note: 24 bit with palette would need a 24 bit palette, too lazy doing that now (textures will prefer 32-bit later anyway) + default: + image = new CImage(ECF_A8R8G8B8, core::dimension2d(header.ImageWidth, header.ImageHeight)); + if (image) + CColorConverter::convert8BitTo32Bit((u8 *)data, + (u8 *)image->getData(), + header.ImageWidth, header.ImageHeight, + (u8 *)palette, 0, + (header.ImageDescriptor & 0x20) == 0); + break; + } + } + } break; + case 16: + image = new CImage(ECF_A1R5G5B5, + core::dimension2d(header.ImageWidth, header.ImageHeight)); + if (image) + CColorConverter::convert16BitTo16Bit((s16 *)data, + (s16 *)image->getData(), header.ImageWidth, header.ImageHeight, 0, (header.ImageDescriptor & 0x20) == 0); + break; + case 24: + image = new CImage(ECF_R8G8B8, + core::dimension2d(header.ImageWidth, header.ImageHeight)); + if (image) + CColorConverter::convert24BitTo24Bit( + (u8 *)data, (u8 *)image->getData(), header.ImageWidth, header.ImageHeight, 0, (header.ImageDescriptor & 0x20) == 0, true); + break; + case 32: + image = new CImage(ECF_A8R8G8B8, + core::dimension2d(header.ImageWidth, header.ImageHeight)); + if (image) + CColorConverter::convert32BitTo32Bit((s32 *)data, + (s32 *)image->getData(), header.ImageWidth, header.ImageHeight, 0, (header.ImageDescriptor & 0x20) == 0); + break; + default: + os::Printer::log("Unsupported TGA format", file->getFileName(), ELL_ERROR); + break; + } + + delete[] data; + delete[] palette; + + return image; +} + +//! creates a loader which is able to load tgas +IImageLoader *createImageLoaderTGA() +{ + return new CImageLoaderTGA(); +} + +} // end namespace video +} // end namespace irr diff --git a/irr/src/CImageLoaderTGA.h b/irr/src/CImageLoaderTGA.h new file mode 100644 index 000000000..18930da3d --- /dev/null +++ b/irr/src/CImageLoaderTGA.h @@ -0,0 +1,66 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IImageLoader.h" + +namespace irr +{ +namespace video +{ + +// byte-align structures +#include "irrpack.h" + +// these structs are also used in the TGA writer +struct STGAHeader +{ + u8 IdLength; + u8 ColorMapType; + u8 ImageType; + u8 FirstEntryIndex[2]; + u16 ColorMapLength; + u8 ColorMapEntrySize; + u8 XOrigin[2]; + u8 YOrigin[2]; + u16 ImageWidth; + u16 ImageHeight; + u8 PixelDepth; + u8 ImageDescriptor; +} PACK_STRUCT; + +struct STGAFooter +{ + u32 ExtensionOffset; + u32 DeveloperOffset; + c8 Signature[18]; +} PACK_STRUCT; + +// Default alignment +#include "irrunpack.h" + +/*! + Surface Loader for targa images +*/ +class CImageLoaderTGA : public IImageLoader +{ +public: + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".tga") + bool isALoadableFileExtension(const io::path &filename) const override; + + //! returns true if the file maybe is able to be loaded by this class + bool isALoadableFileFormat(io::IReadFile *file) const override; + + //! creates a surface from the file + IImage *loadImage(io::IReadFile *file) const override; + +private: + //! loads a compressed tga. Was written and sent in by Jon Pry, thank you very much! + u8 *loadCompressedImage(io::IReadFile *file, const STGAHeader &header) const; +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/src/CImageWriterJPG.cpp b/irr/src/CImageWriterJPG.cpp new file mode 100644 index 000000000..574e46041 --- /dev/null +++ b/irr/src/CImageWriterJPG.cpp @@ -0,0 +1,195 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CImageWriterJPG.h" + +#include "CColorConverter.h" +#include "IWriteFile.h" +#include "CImage.h" +#include "irrString.h" +#include "os.h" + +#include // required for jpeglib.h +extern "C" { +#include +#include +} + +namespace irr +{ +namespace video +{ + +// The writer uses a 4k buffer and flushes to disk each time it's filled +#define OUTPUT_BUF_SIZE 4096 +typedef struct +{ + struct jpeg_destination_mgr pub; /* public fields */ + + io::IWriteFile *file; /* target file */ + JOCTET buffer[OUTPUT_BUF_SIZE]; /* image buffer */ +} mem_destination_mgr; + +typedef mem_destination_mgr *mem_dest_ptr; + +// init +static void jpeg_init_destination(j_compress_ptr cinfo) +{ + mem_dest_ptr dest = (mem_dest_ptr)cinfo->dest; + dest->pub.next_output_byte = dest->buffer; + dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; +} + +// flush to disk and reset buffer +static boolean jpeg_empty_output_buffer(j_compress_ptr cinfo) +{ + mem_dest_ptr dest = (mem_dest_ptr)cinfo->dest; + + // for now just exit upon file error + if (dest->file->write(dest->buffer, OUTPUT_BUF_SIZE) != OUTPUT_BUF_SIZE) + ERREXIT(cinfo, JERR_FILE_WRITE); + + dest->pub.next_output_byte = dest->buffer; + dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; + + return TRUE; +} + +static void jpeg_term_destination(j_compress_ptr cinfo) +{ + mem_dest_ptr dest = (mem_dest_ptr)cinfo->dest; + const size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer; + // for now just exit upon file error + if (dest->file->write(dest->buffer, datacount) != datacount) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + +// set up buffer data +static void jpeg_file_dest(j_compress_ptr cinfo, io::IWriteFile *file) +{ + if (cinfo->dest == NULL) { /* first time for this JPEG object? */ + cinfo->dest = (struct jpeg_destination_mgr *)(*cinfo->mem->alloc_small)((j_common_ptr)cinfo, + JPOOL_PERMANENT, + sizeof(mem_destination_mgr)); + } + + mem_dest_ptr dest = (mem_dest_ptr)cinfo->dest; /* for casting */ + + /* Initialize method pointers */ + dest->pub.init_destination = jpeg_init_destination; + dest->pub.empty_output_buffer = jpeg_empty_output_buffer; + dest->pub.term_destination = jpeg_term_destination; + + /* Initialize private member */ + dest->file = file; +} + +/* write_JPEG_memory: store JPEG compressed image into memory. + */ +static bool writeJPEGFile(io::IWriteFile *file, IImage *image, u32 quality) +{ + void (*format)(const void *, s32, void *) = 0; + switch (image->getColorFormat()) { + case ECF_R8G8B8: + format = CColorConverter::convert_R8G8B8toR8G8B8; + break; + case ECF_A8R8G8B8: + format = CColorConverter::convert_A8R8G8B8toR8G8B8; + break; + case ECF_A1R5G5B5: + format = CColorConverter::convert_A1R5G5B5toB8G8R8; + break; + case ECF_R5G6B5: + format = CColorConverter::convert_R5G6B5toR8G8B8; + break; + default: + os::Printer::log("writeJPEGFile does not support image format", ColorFormatNames[image->getColorFormat()], ELL_WARNING); + break; + } + + // couldn't find a color converter + if (0 == format) + return false; + + const core::dimension2du dim = image->getDimension(); + + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; + cinfo.err = jpeg_std_error(&jerr); + + jpeg_create_compress(&cinfo); + jpeg_file_dest(&cinfo, file); + cinfo.image_width = dim.Width; + cinfo.image_height = dim.Height; + cinfo.input_components = 3; + cinfo.in_color_space = JCS_RGB; + + jpeg_set_defaults(&cinfo); + + if (0 == quality) + quality = 75; + + jpeg_set_quality(&cinfo, quality, TRUE); + jpeg_start_compress(&cinfo, TRUE); + + u8 *dest = new u8[dim.Width * 3]; + + if (dest) { + const u32 pitch = image->getPitch(); + JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ + row_pointer[0] = dest; + + u8 *src = (u8 *)image->getData(); + + while (cinfo.next_scanline < cinfo.image_height) { + // convert next line + format(src, dim.Width, dest); + src += pitch; + jpeg_write_scanlines(&cinfo, row_pointer, 1); + } + + delete[] dest; + + /* Step 6: Finish compression */ + jpeg_finish_compress(&cinfo); + } + + /* Step 7: Destroy */ + jpeg_destroy_compress(&cinfo); + + return (dest != 0); +} + +} // namespace video +} // namespace irr + +namespace irr +{ +namespace video +{ + +IImageWriter *createImageWriterJPG() +{ + return new CImageWriterJPG; +} + +CImageWriterJPG::CImageWriterJPG() +{ +#ifdef _DEBUG + setDebugName("CImageWriterJPG"); +#endif +} + +bool CImageWriterJPG::isAWriteableFileExtension(const io::path &filename) const +{ + return core::hasFileExtension(filename, "jpg", "jpeg"); +} + +bool CImageWriterJPG::writeImage(io::IWriteFile *file, IImage *image, u32 quality) const +{ + return writeJPEGFile(file, image, quality); +} + +} // namespace video +} // namespace irr diff --git a/irr/src/CImageWriterJPG.h b/irr/src/CImageWriterJPG.h new file mode 100644 index 000000000..1d8dde53f --- /dev/null +++ b/irr/src/CImageWriterJPG.h @@ -0,0 +1,28 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IImageWriter.h" + +namespace irr +{ +namespace video +{ + +class CImageWriterJPG : public IImageWriter +{ +public: + //! constructor + CImageWriterJPG(); + + //! return true if this writer can write a file with the given extension + bool isAWriteableFileExtension(const io::path &filename) const override; + + //! write image to file + bool writeImage(io::IWriteFile *file, IImage *image, u32 param) const override; +}; + +} +} diff --git a/irr/src/CImageWriterPNG.cpp b/irr/src/CImageWriterPNG.cpp new file mode 100644 index 000000000..1c8a840ca --- /dev/null +++ b/irr/src/CImageWriterPNG.cpp @@ -0,0 +1,190 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CImageWriterPNG.h" + +#include "CImageLoaderPNG.h" +#include "CColorConverter.h" +#include "IWriteFile.h" +#include "irrString.h" +#include "os.h" // for logging + +#include // use system lib png + +namespace irr +{ +namespace video +{ + +IImageWriter *createImageWriterPNG() +{ + return new CImageWriterPNG; +} + +// PNG function for error handling +static void png_cpexcept_error(png_structp png_ptr, png_const_charp msg) +{ + os::Printer::log("PNG fatal error", msg, ELL_ERROR); + longjmp(png_jmpbuf(png_ptr), 1); +} + +// PNG function for warning handling +static void png_cpexcept_warning(png_structp png_ptr, png_const_charp msg) +{ + os::Printer::log("PNG warning", msg, ELL_WARNING); +} + +// PNG function for file writing +void PNGAPI user_write_data_fcn(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_size_t check; + + io::IWriteFile *file = (io::IWriteFile *)png_get_io_ptr(png_ptr); + check = (png_size_t)file->write((const void *)data, length); + + if (check != length) + png_error(png_ptr, "Write Error"); +} + +CImageWriterPNG::CImageWriterPNG() +{ +#ifdef _DEBUG + setDebugName("CImageWriterPNG"); +#endif +} + +bool CImageWriterPNG::isAWriteableFileExtension(const io::path &filename) const +{ + return core::hasFileExtension(filename, "png"); +} + +bool CImageWriterPNG::writeImage(io::IWriteFile *file, IImage *image, u32 param) const +{ + if (!file || !image) + return false; + + // Allocate the png write struct + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, + NULL, (png_error_ptr)png_cpexcept_error, (png_error_ptr)png_cpexcept_warning); + if (!png_ptr) { + os::Printer::log("PNGWriter: Internal PNG create write struct failure", file->getFileName(), ELL_ERROR); + return false; + } + + // Allocate the png info struct + png_infop info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) { + os::Printer::log("PNGWriter: Internal PNG create info struct failure", file->getFileName(), ELL_ERROR); + png_destroy_write_struct(&png_ptr, NULL); + return false; + } + + // for proper error handling + if (setjmp(png_jmpbuf(png_ptr))) { + png_destroy_write_struct(&png_ptr, &info_ptr); + return false; + } + + png_set_write_fn(png_ptr, file, user_write_data_fcn, NULL); + + // Set info + switch (image->getColorFormat()) { + case ECF_A8R8G8B8: + case ECF_A1R5G5B5: + png_set_IHDR(png_ptr, info_ptr, + image->getDimension().Width, image->getDimension().Height, + 8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + break; + default: + png_set_IHDR(png_ptr, info_ptr, + image->getDimension().Width, image->getDimension().Height, + 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + } + + s32 lineWidth = image->getDimension().Width; + switch (image->getColorFormat()) { + case ECF_R8G8B8: + case ECF_R5G6B5: + lineWidth *= 3; + break; + case ECF_A8R8G8B8: + case ECF_A1R5G5B5: + lineWidth *= 4; + break; + // TODO: Error handling in case of unsupported color format + default: + break; + } + u8 *tmpImage = new u8[image->getDimension().Height * lineWidth]; + if (!tmpImage) { + os::Printer::log("PNGWriter: Internal PNG create image failure", file->getFileName(), ELL_ERROR); + png_destroy_write_struct(&png_ptr, &info_ptr); + return false; + } + + u8 *data = (u8 *)image->getData(); + switch (image->getColorFormat()) { + case ECF_R8G8B8: + CColorConverter::convert_R8G8B8toR8G8B8(data, image->getDimension().Height * image->getDimension().Width, tmpImage); + break; + case ECF_A8R8G8B8: + CColorConverter::convert_A8R8G8B8toA8R8G8B8(data, image->getDimension().Height * image->getDimension().Width, tmpImage); + break; + case ECF_R5G6B5: + CColorConverter::convert_R5G6B5toR8G8B8(data, image->getDimension().Height * image->getDimension().Width, tmpImage); + break; + case ECF_A1R5G5B5: + CColorConverter::convert_A1R5G5B5toA8R8G8B8(data, image->getDimension().Height * image->getDimension().Width, tmpImage); + break; + // TODO: Error handling in case of unsupported color format + default: + os::Printer::log("CImageWriterPNG does not support image format", ColorFormatNames[image->getColorFormat()], ELL_WARNING); + png_destroy_write_struct(&png_ptr, &info_ptr); + delete[] tmpImage; + return false; + } + + // Create array of pointers to rows in image data + + // Used to point to image rows + u8 **RowPointers = new png_bytep[image->getDimension().Height]; + if (!RowPointers) { + os::Printer::log("PNGWriter: Internal PNG create row pointers failure", file->getFileName(), ELL_ERROR); + png_destroy_write_struct(&png_ptr, &info_ptr); + delete[] tmpImage; + return false; + } + + data = tmpImage; + // Fill array of pointers to rows in image data + for (u32 i = 0; i < image->getDimension().Height; ++i) { + RowPointers[i] = data; + data += lineWidth; + } + // for proper error handling + if (setjmp(png_jmpbuf(png_ptr))) { + png_destroy_write_struct(&png_ptr, &info_ptr); + delete[] RowPointers; + delete[] tmpImage; + return false; + } + + png_set_rows(png_ptr, info_ptr, RowPointers); + + if (image->getColorFormat() == ECF_A8R8G8B8 || image->getColorFormat() == ECF_A1R5G5B5) + png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_BGR, NULL); + else { + png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); + } + + delete[] RowPointers; + delete[] tmpImage; + png_destroy_write_struct(&png_ptr, &info_ptr); + return true; +} + +} // namespace video +} // namespace irr diff --git a/irr/src/CImageWriterPNG.h b/irr/src/CImageWriterPNG.h new file mode 100644 index 000000000..b0f7348ee --- /dev/null +++ b/irr/src/CImageWriterPNG.h @@ -0,0 +1,28 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IImageWriter.h" + +namespace irr +{ +namespace video +{ + +class CImageWriterPNG : public IImageWriter +{ +public: + //! constructor + CImageWriterPNG(); + + //! return true if this writer can write a file with the given extension + bool isAWriteableFileExtension(const io::path &filename) const override; + + //! write image to file + bool writeImage(io::IWriteFile *file, IImage *image, u32 param) const override; +}; + +} // namespace video +} // namespace irr diff --git a/irr/src/CIrrDeviceLinux.cpp b/irr/src/CIrrDeviceLinux.cpp new file mode 100644 index 000000000..71eb0f260 --- /dev/null +++ b/irr/src/CIrrDeviceLinux.cpp @@ -0,0 +1,2244 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CIrrDeviceLinux.h" + +#ifdef _IRR_COMPILE_WITH_X11_DEVICE_ + +#include +#include +#include +#include +#include +#include "IEventReceiver.h" +#include "ISceneManager.h" +#include "IGUIElement.h" +#include "IGUIEnvironment.h" +#include "os.h" +#include "CTimer.h" +#include "irrString.h" +#include "Keycodes.h" +#include "COSOperator.h" +#include "CColorConverter.h" +#include "SIrrCreationParameters.h" +#include "SExposedVideoData.h" +#include "IGUISpriteBank.h" +#include "IImageLoader.h" +#include "IFileSystem.h" +#include +#include + +#if defined(_IRR_LINUX_X11_XINPUT2_) +#include +#endif + +#if defined(_IRR_COMPILE_WITH_OGLES1_) || defined(_IRR_COMPILE_WITH_OGLES2_) +#include "CEGLManager.h" +#endif + +#if defined(_IRR_COMPILE_WITH_OPENGL_) +#include "CGLXManager.h" +#endif + +#ifdef _IRR_LINUX_XCURSOR_ +#include +#endif + +#if defined _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ +#include +#include + +#ifdef __FreeBSD__ +#include +#else + +// linux/joystick.h includes linux/input.h, which #defines values for various KEY_FOO keys. +// These override the irr::KEY_FOO equivalents, which stops key handling from working. +// As a workaround, defining _INPUT_H stops linux/input.h from being included; it +// doesn't actually seem to be necessary except to pull in sys/ioctl.h. +#define _INPUT_H +#include // Would normally be included in linux/input.h +#include +#undef _INPUT_H +#endif + +#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ + +namespace irr +{ +namespace video +{ +#ifdef _IRR_COMPILE_WITH_OPENGL_ +IVideoDriver *createOpenGLDriver(const irr::SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager); +#endif + +#ifdef _IRR_COMPILE_WITH_OGLES1_ +IVideoDriver *createOGLES1Driver(const irr::SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager); +#endif + +#ifdef _IRR_COMPILE_WITH_OGLES2_ +IVideoDriver *createOGLES2Driver(const irr::SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager); +#endif + +#ifdef _IRR_COMPILE_WITH_WEBGL1_ +IVideoDriver *createWebGL1Driver(const irr::SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager); +#endif +} +} // end namespace irr + +namespace +{ +Atom X_ATOM_CLIPBOARD; +Atom X_ATOM_TARGETS; +Atom X_ATOM_UTF8_STRING; +Atom X_ATOM_UTF8_MIME_TYPE; +Atom X_ATOM_TEXT; +Atom X_ATOM_NETWM_MAXIMIZE_VERT; +Atom X_ATOM_NETWM_MAXIMIZE_HORZ; +Atom X_ATOM_NETWM_STATE; +Atom X_ATOM_NETWM_STATE_FULLSCREEN; + +Atom X_ATOM_WM_DELETE_WINDOW; + +#if defined(_IRR_LINUX_X11_XINPUT2_) +int XI_EXTENSIONS_OPCODE; +#endif +} + +namespace irr +{ +//! constructor +CIrrDeviceLinux::CIrrDeviceLinux(const SIrrlichtCreationParameters ¶m) : + CIrrDeviceStub(param), +#ifdef _IRR_COMPILE_WITH_X11_ + XDisplay(0), VisualInfo(0), Screennr(0), XWindow(0), StdHints(0), + XInputMethod(0), XInputContext(0), + HasNetWM(false), +#endif +#if defined(_IRR_LINUX_X11_XINPUT2_) + currentTouchedCount(0), +#endif + Width(param.WindowSize.Width), Height(param.WindowSize.Height), + WindowHasFocus(false), WindowMinimized(false), WindowMaximized(param.WindowMaximized), + ExternalWindow(false), AutorepeatSupport(0) +{ +#ifdef _DEBUG + setDebugName("CIrrDeviceLinux"); +#endif + + // print version, distribution etc. + // thx to LynxLuna for pointing me to the uname function + core::stringc linuxversion; + struct utsname LinuxInfo; + uname(&LinuxInfo); + + linuxversion += LinuxInfo.sysname; + linuxversion += " "; + linuxversion += LinuxInfo.release; + linuxversion += " "; + linuxversion += LinuxInfo.version; + linuxversion += " "; + linuxversion += LinuxInfo.machine; + + Operator = new COSOperator(linuxversion, this); + os::Printer::log(linuxversion.c_str(), ELL_INFORMATION); + + // create keymap + createKeyMap(); + + // initialize X11 thread safety + // libX11 1.8+ has this on by default + // without it, multi-threaded GL drivers may crash + XInitThreads(); + + // create window + if (CreationParams.DriverType != video::EDT_NULL) { + // create the window, only if we do not use the null device + if (!createWindow()) + return; + if (param.WindowResizable < 2) + setResizable(param.WindowResizable == 1 ? true : false); +#ifdef _IRR_COMPILE_WITH_X11_ + createInputContext(); +#endif + } + + // create cursor control + CursorControl = new CCursorControl(this, CreationParams.DriverType == video::EDT_NULL); + + // create driver + createDriver(); + + if (!VideoDriver) + return; + + createGUIAndScene(); + + if (param.WindowMaximized) + maximizeWindow(); + + setupTopLevelXorgWindow(); +} + +//! destructor +CIrrDeviceLinux::~CIrrDeviceLinux() +{ +#ifdef _IRR_COMPILE_WITH_X11_ + if (StdHints) + XFree(StdHints); + // Disable cursor (it is drop'ed in stub) + if (CursorControl) { + CursorControl->setVisible(false); + static_cast(CursorControl)->clearCursors(); + } + + // Must free OpenGL textures etc before destroying context, so can't wait for stub destructor + if (GUIEnvironment) { + GUIEnvironment->drop(); + GUIEnvironment = NULL; + } + if (SceneManager) { + SceneManager->drop(); + SceneManager = NULL; + } + if (VideoDriver) { + VideoDriver->drop(); + VideoDriver = NULL; + } + + destroyInputContext(); + + if (XDisplay) { + if (ContextManager) { + ContextManager->destroyContext(); + ContextManager->destroySurface(); + } + + if (!ExternalWindow) { + XDestroyWindow(XDisplay, XWindow); + XCloseDisplay(XDisplay); + } + } + if (VisualInfo) + XFree(VisualInfo); + +#endif // #ifdef _IRR_COMPILE_WITH_X11_ + +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) + for (u32 joystick = 0; joystick < ActiveJoysticks.size(); ++joystick) { + if (ActiveJoysticks[joystick].fd >= 0) { + close(ActiveJoysticks[joystick].fd); + } + } +#endif +} + +#if defined(_IRR_COMPILE_WITH_X11_) && defined(_DEBUG) +int IrrPrintXError(Display *display, XErrorEvent *event) +{ + char msg[256]; + char msg2[256]; + + snprintf_irr(msg, 256, "%d", event->request_code); + XGetErrorDatabaseText(display, "XRequest", msg, "unknown", msg2, 256); + XGetErrorText(display, event->error_code, msg, 256); + os::Printer::log("X Error", msg, ELL_WARNING); + os::Printer::log("From call ", msg2, ELL_WARNING); + return 0; +} +#endif + +bool CIrrDeviceLinux::switchToFullscreen() +{ + if (!CreationParams.Fullscreen) + return true; + + if (!HasNetWM) { + os::Printer::log("NetWM support is required to allow Irrlicht to switch " + "to fullscreen mode. Running in windowed mode instead.", + ELL_WARNING); + CreationParams.Fullscreen = false; + return false; + } + + XEvent ev = {0}; + + ev.type = ClientMessage; + ev.xclient.window = XWindow; + ev.xclient.message_type = X_ATOM_NETWM_STATE; + ev.xclient.format = 32; + ev.xclient.data.l[0] = 1; // _NET_WM_STATE_ADD + ev.xclient.data.l[1] = X_ATOM_NETWM_STATE_FULLSCREEN; + + XSendEvent(XDisplay, DefaultRootWindow(XDisplay), false, + SubstructureNotifyMask | SubstructureRedirectMask, &ev); + + return true; +} + +void CIrrDeviceLinux::setupTopLevelXorgWindow() +{ +#ifdef _IRR_COMPILE_WITH_X11_ + if (CreationParams.DriverType == video::EDT_NULL) + return; // no display and window + + os::Printer::log("Configuring X11-specific top level window properties", ELL_DEBUG); + + // Set application name and class hints. For now name and class are the same. + // Note: SDL uses the executable name here (i.e. "minetest"). + XClassHint *classhint = XAllocClassHint(); + classhint->res_name = const_cast("Minetest"); + classhint->res_class = const_cast("Minetest"); + + XSetClassHint(XDisplay, XWindow, classhint); + XFree(classhint); + + // FIXME: In the future WMNormalHints should be set ... e.g see the + // gtk/gdk code (gdk/x11/gdksurface-x11.c) for the setup_top_level + // method. But for now (as it would require some significant changes) + // leave the code as is. + + // The following is borrowed from the above gdk source for setting top + // level windows. The source indicates and the Xlib docs suggest that + // this will set the WM_CLIENT_MACHINE and WM_LOCAL_NAME. This will not + // set the WM_CLIENT_MACHINE to a Fully Qualified Domain Name (FQDN) which is + // required by the Extended Window Manager Hints (EWMH) spec when setting + // the _NET_WM_PID (see further down) but running Minetest in an env + // where the window manager is on another machine from Minetest (therefore + // making the PID useless) is not expected to be a problem. Further + // more, using gtk/gdk as the model it would seem that not using a FQDN is + // not an issue for modern Xorg window managers. + + os::Printer::log("Setting Xorg window manager Properties", ELL_DEBUG); + + XSetWMProperties(XDisplay, XWindow, NULL, NULL, NULL, 0, NULL, NULL, NULL); + + // Set the _NET_WM_PID window property according to the EWMH spec. _NET_WM_PID + // (in conjunction with WM_CLIENT_MACHINE) can be used by window managers to + // force a shutdown of an application if it doesn't respond to the destroy + // window message. + + os::Printer::log("Setting Xorg _NET_WM_PID extended window manager property", ELL_DEBUG); + + Atom NET_WM_PID = XInternAtom(XDisplay, "_NET_WM_PID", false); + + long pid = static_cast(getpid()); + + XChangeProperty(XDisplay, XWindow, NET_WM_PID, + XA_CARDINAL, 32, PropModeReplace, + reinterpret_cast(&pid), 1); + + // Set the WM_CLIENT_LEADER window property here. Minetest has only one + // window and that window will always be the leader. + + os::Printer::log("Setting Xorg WM_CLIENT_LEADER property", ELL_DEBUG); + + Atom WM_CLIENT_LEADER = XInternAtom(XDisplay, "WM_CLIENT_LEADER", false); + + XChangeProperty(XDisplay, XWindow, WM_CLIENT_LEADER, + XA_WINDOW, 32, PropModeReplace, + reinterpret_cast(&XWindow), 1); +#endif +} + +#if defined(_IRR_COMPILE_WITH_X11_) +void IrrPrintXGrabError(int grabResult, const c8 *grabCommand) +{ + if (grabResult == GrabSuccess) { + // os::Printer::log(grabCommand, "GrabSuccess", ELL_INFORMATION); + return; + } + + switch (grabResult) { + case AlreadyGrabbed: + os::Printer::log(grabCommand, "AlreadyGrabbed", ELL_WARNING); + break; + case GrabNotViewable: + os::Printer::log(grabCommand, "GrabNotViewable", ELL_WARNING); + break; + case GrabFrozen: + os::Printer::log(grabCommand, "GrabFrozen", ELL_WARNING); + break; + case GrabInvalidTime: + os::Printer::log(grabCommand, "GrabInvalidTime", ELL_WARNING); + break; + default: + os::Printer::log(grabCommand, "grab failed with unknown problem", ELL_WARNING); + break; + } +} +#endif + +bool CIrrDeviceLinux::createWindow() +{ +#ifdef _IRR_COMPILE_WITH_X11_ +#ifdef _DEBUG + os::Printer::log("Creating X window...", ELL_INFORMATION); + XSetErrorHandler(IrrPrintXError); +#endif + + XDisplay = XOpenDisplay(0); + if (!XDisplay) { + os::Printer::log("Error: Need running XServer to start Irrlicht Engine.", ELL_ERROR); + if (XDisplayName(0)[0]) + os::Printer::log("Could not open display", XDisplayName(0), ELL_ERROR); + else + os::Printer::log("Could not open display, set DISPLAY variable", ELL_ERROR); + return false; + } + + Screennr = DefaultScreen(XDisplay); + + initXAtoms(); + + // check netwm support + Atom WMCheck = XInternAtom(XDisplay, "_NET_SUPPORTING_WM_CHECK", True); + if (WMCheck != None) + HasNetWM = true; + +#if defined(_IRR_COMPILE_WITH_OPENGL_) + // don't use the XVisual with OpenGL, because it ignores all requested + // properties of the CreationParams + if (CreationParams.DriverType == video::EDT_OPENGL) { + video::SExposedVideoData data; + data.OpenGLLinux.X11Display = XDisplay; + ContextManager = new video::CGLXManager(CreationParams, data, Screennr); + VisualInfo = ((video::CGLXManager *)ContextManager)->getVisual(); + } +#endif + + if (!VisualInfo) { + // create visual with standard X methods + os::Printer::log("Using plain X visual"); + XVisualInfo visTempl; // Template to hold requested values + int visNumber; // Return value of available visuals + + visTempl.screen = Screennr; + // ARGB visuals should be avoided for usual applications + visTempl.depth = CreationParams.WithAlphaChannel ? 32 : 24; + while ((!VisualInfo) && (visTempl.depth >= 16)) { + VisualInfo = XGetVisualInfo(XDisplay, VisualScreenMask | VisualDepthMask, + &visTempl, &visNumber); + visTempl.depth -= 8; + } + } + + if (!VisualInfo) { + os::Printer::log("Fatal error, could not get visual.", ELL_ERROR); + XCloseDisplay(XDisplay); + XDisplay = 0; + return false; + } +#ifdef _DEBUG + else + os::Printer::log("Visual chosen", core::stringc(static_cast(VisualInfo->visualid)).c_str(), ELL_DEBUG); +#endif + + // create color map + Colormap colormap; + colormap = XCreateColormap(XDisplay, + RootWindow(XDisplay, VisualInfo->screen), + VisualInfo->visual, AllocNone); + + WndAttributes.colormap = colormap; + WndAttributes.border_pixel = 0; + WndAttributes.event_mask = StructureNotifyMask | FocusChangeMask | ExposureMask; + WndAttributes.event_mask |= PointerMotionMask | + ButtonPressMask | KeyPressMask | + ButtonReleaseMask | KeyReleaseMask; + + if (!CreationParams.WindowId) { + int x = 0; + int y = 0; + + if (!CreationParams.Fullscreen) { + if (CreationParams.WindowPosition.X > 0) + x = CreationParams.WindowPosition.X; + if (CreationParams.WindowPosition.Y > 0) + y = CreationParams.WindowPosition.Y; + } + + // create new Window + // Remove window manager decoration in fullscreen + XWindow = XCreateWindow(XDisplay, + RootWindow(XDisplay, VisualInfo->screen), + x, y, Width, Height, 0, VisualInfo->depth, + InputOutput, VisualInfo->visual, + CWBorderPixel | CWColormap | CWEventMask, + &WndAttributes); + + XMapRaised(XDisplay, XWindow); + CreationParams.WindowId = (void *)XWindow; + X_ATOM_WM_DELETE_WINDOW = XInternAtom(XDisplay, "WM_DELETE_WINDOW", True); + XSetWMProtocols(XDisplay, XWindow, &X_ATOM_WM_DELETE_WINDOW, 1); + + if (CreationParams.Fullscreen) { + // Don't try to set window position + } else if (CreationParams.WindowPosition.X >= 0 || CreationParams.WindowPosition.Y >= 0) { // default is -1, -1 + // Window managers are free to ignore positions above, so give it another shot + XMoveWindow(XDisplay, XWindow, x, y); + } + } else { + // attach external window + XWindow = (Window)CreationParams.WindowId; + { + // Note: This might be further improved by using a InputOnly window instead of InputOutput. + // I think then it should be possible to render into the given parent window instead of + // creating a child-window. + // Also... this does possibly leak. + Window child_window = XCreateWindow(XDisplay, + XWindow, + 0, 0, Width, Height, 0, VisualInfo->depth, + InputOutput, VisualInfo->visual, + CWBorderPixel | CWColormap | CWEventMask, + &WndAttributes); + + // do not forget to map new window + XMapWindow(XDisplay, child_window); + + // overwrite device window id + XWindow = child_window; + } + XWindowAttributes wa; + XGetWindowAttributes(XDisplay, XWindow, &wa); + CreationParams.WindowSize.Width = wa.width; + CreationParams.WindowSize.Height = wa.height; + CreationParams.Fullscreen = false; + ExternalWindow = true; + } + + switchToFullscreen(); + + WindowMinimized = false; + XkbSetDetectableAutoRepeat(XDisplay, True, &AutorepeatSupport); + + Window tmp; + u32 borderWidth; + int x, y; + unsigned int bits; + + XGetGeometry(XDisplay, XWindow, &tmp, &x, &y, &Width, &Height, &borderWidth, &bits); + CreationParams.Bits = bits; + CreationParams.WindowSize.Width = Width; + CreationParams.WindowSize.Height = Height; + + StdHints = XAllocSizeHints(); + long num; + XGetWMNormalHints(XDisplay, XWindow, StdHints, &num); + + initXInput2(); + +#endif // #ifdef _IRR_COMPILE_WITH_X11_ + return true; +} + +//! create the driver +void CIrrDeviceLinux::createDriver() +{ + switch (CreationParams.DriverType) { +#ifdef _IRR_COMPILE_WITH_X11_ + case video::EDT_OPENGL: +#ifdef _IRR_COMPILE_WITH_OPENGL_ + { + video::SExposedVideoData data; + data.OpenGLLinux.X11Window = XWindow; + data.OpenGLLinux.X11Display = XDisplay; + + ContextManager->initialize(CreationParams, data); + + VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, ContextManager); + } +#else + os::Printer::log("No OpenGL support compiled in.", ELL_ERROR); +#endif + break; + case video::EDT_OGLES1: +#ifdef _IRR_COMPILE_WITH_OGLES1_ + { + video::SExposedVideoData data; + data.OpenGLLinux.X11Window = XWindow; + data.OpenGLLinux.X11Display = XDisplay; + + ContextManager = new video::CEGLManager(); + ContextManager->initialize(CreationParams, data); + + VideoDriver = video::createOGLES1Driver(CreationParams, FileSystem, ContextManager); + } +#else + os::Printer::log("No OpenGL-ES1 support compiled in.", ELL_ERROR); +#endif + break; + case video::EDT_OGLES2: +#ifdef _IRR_COMPILE_WITH_OGLES2_ + { + video::SExposedVideoData data; + data.OpenGLLinux.X11Window = XWindow; + data.OpenGLLinux.X11Display = XDisplay; + + ContextManager = new video::CEGLManager(); + ContextManager->initialize(CreationParams, data); + + VideoDriver = video::createOGLES2Driver(CreationParams, FileSystem, ContextManager); + } +#else + os::Printer::log("No OpenGL-ES2 support compiled in.", ELL_ERROR); +#endif + break; + case video::EDT_WEBGL1: +#ifdef _IRR_COMPILE_WITH_WEBGL1_ + { + video::SExposedVideoData data; + data.OpenGLLinux.X11Window = XWindow; + data.OpenGLLinux.X11Display = XDisplay; + + ContextManager = new video::CEGLManager(); + ContextManager->initialize(CreationParams, data); + + VideoDriver = video::createWebGL1Driver(CreationParams, FileSystem, ContextManager); + } +#else + os::Printer::log("No WebGL1 support compiled in.", ELL_ERROR); +#endif + break; + case video::EDT_NULL: + VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); + break; + default: + os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR); + break; +#else + case video::EDT_NULL: + VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); + break; + default: + os::Printer::log("No X11 support compiled in. Only Null driver available.", ELL_ERROR); + break; +#endif + } +} + +#ifdef _IRR_COMPILE_WITH_X11_ +bool CIrrDeviceLinux::createInputContext() +{ + // One one side it would be nicer to let users do that - on the other hand + // not setting the environment locale will not work when using i18n X11 functions. + // So users would have to call it always or their input is broken badly. + // We can restore immediately - so won't mess with anything in users apps. + core::stringc oldLocale(setlocale(LC_CTYPE, NULL)); + setlocale(LC_CTYPE, ""); // use environment locale + + if (!XSupportsLocale()) { + os::Printer::log("Locale not supported. Falling back to non-i18n input.", ELL_WARNING); + setlocale(LC_CTYPE, oldLocale.c_str()); + return false; + } + + // Load XMODIFIERS (e.g. for IMEs) + if (!XSetLocaleModifiers("")) { + setlocale(LC_CTYPE, oldLocale.c_str()); + os::Printer::log("XSetLocaleModifiers failed. Falling back to non-i18n input.", ELL_WARNING); + return false; + } + + XInputMethod = XOpenIM(XDisplay, NULL, NULL, NULL); + if (!XInputMethod) { + setlocale(LC_CTYPE, oldLocale.c_str()); + os::Printer::log("XOpenIM failed to create an input method. Falling back to non-i18n input.", ELL_WARNING); + return false; + } + + XIMStyles *im_supported_styles; + XGetIMValues(XInputMethod, XNQueryInputStyle, &im_supported_styles, (char *)NULL); + XIMStyle bestStyle = 0; + XIMStyle supportedStyle = XIMPreeditNothing | XIMStatusNothing; + for (int i = 0; i < im_supported_styles->count_styles; ++i) { + XIMStyle style = im_supported_styles->supported_styles[i]; + if ((style & supportedStyle) == style) /* if we can handle it */ + { + bestStyle = style; + break; + } + } + XFree(im_supported_styles); + + if (!bestStyle) { + XDestroyIC(XInputContext); + XInputContext = 0; + + os::Printer::log("XInputMethod has no input style we can use. Falling back to non-i18n input.", ELL_WARNING); + setlocale(LC_CTYPE, oldLocale.c_str()); + return false; + } + + XInputContext = XCreateIC(XInputMethod, + XNInputStyle, bestStyle, + XNClientWindow, XWindow, + (char *)NULL); + if (!XInputContext) { + os::Printer::log("XInputContext failed to create an input context. Falling back to non-i18n input.", ELL_WARNING); + setlocale(LC_CTYPE, oldLocale.c_str()); + return false; + } + XSetICFocus(XInputContext); + setlocale(LC_CTYPE, oldLocale.c_str()); + return true; +} + +void CIrrDeviceLinux::destroyInputContext() +{ + if (XInputContext) { + XUnsetICFocus(XInputContext); + XDestroyIC(XInputContext); + XInputContext = 0; + } + if (XInputMethod) { + XCloseIM(XInputMethod); + XInputMethod = 0; + } +} + +EKEY_CODE CIrrDeviceLinux::getKeyCode(XEvent &event) +{ + EKEY_CODE keyCode = (EKEY_CODE)0; + + SKeyMap mp; + mp.X11Key = XkbKeycodeToKeysym(XDisplay, event.xkey.keycode, 0, 0); + const s32 idx = KeyMap.binary_search(mp); + if (idx != -1) { + keyCode = (EKEY_CODE)KeyMap[idx].Win32Key; + } + if (keyCode == 0) { + keyCode = KEY_UNKNOWN; + if (!mp.X11Key) { + os::Printer::log("No such X11Key, event keycode", core::stringc(event.xkey.keycode).c_str(), ELL_INFORMATION); + } else if (idx == -1) { + os::Printer::log("EKEY_CODE not found, X11 keycode", core::stringc(mp.X11Key).c_str(), ELL_INFORMATION); + } else { + os::Printer::log("EKEY_CODE is 0, X11 keycode", core::stringc(mp.X11Key).c_str(), ELL_INFORMATION); + } + } + return keyCode; +} +#endif + +//! runs the device. Returns false if device wants to be deleted +bool CIrrDeviceLinux::run() +{ + os::Timer::tick(); + +#ifdef _IRR_COMPILE_WITH_X11_ + + if (CursorControl) + static_cast(CursorControl)->update(); + + if ((CreationParams.DriverType != video::EDT_NULL) && XDisplay) { + SEvent irrevent; + irrevent.MouseInput.ButtonStates = 0xffffffff; + + while (XPending(XDisplay) > 0 && !Close) { + XEvent event; + XNextEvent(XDisplay, &event); + if (XFilterEvent(&event, None)) + continue; + + switch (event.type) { + case ConfigureNotify: + // check for changed window size + if ((event.xconfigure.width != (int)Width) || + (event.xconfigure.height != (int)Height)) { + Width = event.xconfigure.width; + Height = event.xconfigure.height; + + if (VideoDriver) + VideoDriver->OnResize(core::dimension2d(Width, Height)); + } + break; + + case MapNotify: + WindowMinimized = false; + break; + + case UnmapNotify: + WindowMinimized = true; + break; + + case FocusIn: + WindowHasFocus = true; + break; + + case FocusOut: + WindowHasFocus = false; + break; + + case MotionNotify: + irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT; + irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED; + irrevent.MouseInput.X = event.xbutton.x; + irrevent.MouseInput.Y = event.xbutton.y; + irrevent.MouseInput.Control = (event.xkey.state & ControlMask) != 0; + irrevent.MouseInput.Shift = (event.xkey.state & ShiftMask) != 0; + + // mouse button states + irrevent.MouseInput.ButtonStates = (event.xbutton.state & Button1Mask) ? irr::EMBSM_LEFT : 0; + irrevent.MouseInput.ButtonStates |= (event.xbutton.state & Button3Mask) ? irr::EMBSM_RIGHT : 0; + irrevent.MouseInput.ButtonStates |= (event.xbutton.state & Button2Mask) ? irr::EMBSM_MIDDLE : 0; + + postEventFromUser(irrevent); + break; + + case ButtonPress: + case ButtonRelease: + + irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT; + irrevent.MouseInput.X = event.xbutton.x; + irrevent.MouseInput.Y = event.xbutton.y; + irrevent.MouseInput.Control = (event.xkey.state & ControlMask) != 0; + irrevent.MouseInput.Shift = (event.xkey.state & ShiftMask) != 0; + + // mouse button states + // This sets the state which the buttons had _prior_ to the event. + // So unlike on Windows the button which just got changed has still the old state here. + // We handle that below by flipping the corresponding bit later. + irrevent.MouseInput.ButtonStates = (event.xbutton.state & Button1Mask) ? irr::EMBSM_LEFT : 0; + irrevent.MouseInput.ButtonStates |= (event.xbutton.state & Button3Mask) ? irr::EMBSM_RIGHT : 0; + irrevent.MouseInput.ButtonStates |= (event.xbutton.state & Button2Mask) ? irr::EMBSM_MIDDLE : 0; + + irrevent.MouseInput.Event = irr::EMIE_COUNT; + + switch (event.xbutton.button) { + case Button1: + irrevent.MouseInput.Event = + (event.type == ButtonPress) ? irr::EMIE_LMOUSE_PRESSED_DOWN : irr::EMIE_LMOUSE_LEFT_UP; + irrevent.MouseInput.ButtonStates ^= irr::EMBSM_LEFT; + break; + + case Button3: + irrevent.MouseInput.Event = + (event.type == ButtonPress) ? irr::EMIE_RMOUSE_PRESSED_DOWN : irr::EMIE_RMOUSE_LEFT_UP; + irrevent.MouseInput.ButtonStates ^= irr::EMBSM_RIGHT; + break; + + case Button2: + irrevent.MouseInput.Event = + (event.type == ButtonPress) ? irr::EMIE_MMOUSE_PRESSED_DOWN : irr::EMIE_MMOUSE_LEFT_UP; + irrevent.MouseInput.ButtonStates ^= irr::EMBSM_MIDDLE; + break; + + case Button4: + if (event.type == ButtonPress) { + irrevent.MouseInput.Event = EMIE_MOUSE_WHEEL; + irrevent.MouseInput.Wheel = 1.0f; + } + break; + + case Button5: + if (event.type == ButtonPress) { + irrevent.MouseInput.Event = EMIE_MOUSE_WHEEL; + irrevent.MouseInput.Wheel = -1.0f; + } + break; + } + + if (irrevent.MouseInput.Event != irr::EMIE_COUNT) { + postEventFromUser(irrevent); + + if (irrevent.MouseInput.Event >= EMIE_LMOUSE_PRESSED_DOWN && irrevent.MouseInput.Event <= EMIE_MMOUSE_PRESSED_DOWN) { + u32 clicks = checkSuccessiveClicks(irrevent.MouseInput.X, irrevent.MouseInput.Y, irrevent.MouseInput.Event); + if (clicks == 2) { + irrevent.MouseInput.Event = (EMOUSE_INPUT_EVENT)(EMIE_LMOUSE_DOUBLE_CLICK + irrevent.MouseInput.Event - EMIE_LMOUSE_PRESSED_DOWN); + postEventFromUser(irrevent); + } else if (clicks == 3) { + irrevent.MouseInput.Event = (EMOUSE_INPUT_EVENT)(EMIE_LMOUSE_TRIPLE_CLICK + irrevent.MouseInput.Event - EMIE_LMOUSE_PRESSED_DOWN); + postEventFromUser(irrevent); + } + } + } + break; + + case MappingNotify: + XRefreshKeyboardMapping(&event.xmapping); + break; + + case KeyRelease: + if (0 == AutorepeatSupport && (XPending(XDisplay) > 0)) { + // check for Autorepeat manually + // We'll do the same as Windows does: Only send KeyPressed + // So every KeyRelease is a real release + XEvent next_event; + XPeekEvent(event.xkey.display, &next_event); + if ((next_event.type == KeyPress) && + (next_event.xkey.keycode == event.xkey.keycode) && + (next_event.xkey.time - event.xkey.time) < 2) // usually same time, but on some systems a difference of 1 is possible + { + // Ignore the key release event + break; + } + } + + irrevent.EventType = irr::EET_KEY_INPUT_EVENT; + irrevent.KeyInput.PressedDown = false; + irrevent.KeyInput.Char = 0; // on release that's undefined + irrevent.KeyInput.Control = (event.xkey.state & ControlMask) != 0; + irrevent.KeyInput.Shift = (event.xkey.state & ShiftMask) != 0; + irrevent.KeyInput.Key = getKeyCode(event); + + postEventFromUser(irrevent); + break; + + case KeyPress: { + SKeyMap mp; + if (XInputContext) { + wchar_t buf[64] = {0}; + Status status; + int strLen = XwcLookupString(XInputContext, &event.xkey, buf, sizeof(buf) / sizeof(wchar_t) - 1, &mp.X11Key, &status); + if (status == XBufferOverflow) { + os::Printer::log("XwcLookupString needs a larger buffer", ELL_INFORMATION); + } + if (strLen > 0 && (status == XLookupChars || status == XLookupBoth)) { + if (strLen > 1) { + // Multiple characters: send string event + irrevent.EventType = irr::EET_STRING_INPUT_EVENT; + irrevent.StringInput.Str = new core::stringw(buf); + postEventFromUser(irrevent); + delete irrevent.StringInput.Str; + irrevent.StringInput.Str = NULL; + break; + } else { + irrevent.KeyInput.Char = buf[0]; + } + } else { +#if 0 // Most of those are fine - but useful to have the info when debugging Irrlicht itself. + if ( status == XLookupNone ) + os::Printer::log("XLookupNone", ELL_INFORMATION); + else if ( status == XLookupKeySym ) + // Getting this also when user did not set setlocale(LC_ALL, ""); and using an unknown locale + // XSupportsLocale doesn't seem to catch that unfortunately - any other ideas to catch it are welcome. + os::Printer::log("XLookupKeySym", ELL_INFORMATION); + else if ( status == XBufferOverflow ) + os::Printer::log("XBufferOverflow", ELL_INFORMATION); + else if ( strLen == 0 ) + os::Printer::log("no string", ELL_INFORMATION); +#endif + irrevent.KeyInput.Char = 0; + } + } else // Old version without InputContext. Does not support i18n, but good to have as fallback. + { + union + { + char buf[8]; + wchar_t wbuf[2]; + } tmp = {{0}}; + XLookupString(&event.xkey, tmp.buf, sizeof(tmp.buf), &mp.X11Key, NULL); + irrevent.KeyInput.Char = tmp.wbuf[0]; + } + + irrevent.EventType = irr::EET_KEY_INPUT_EVENT; + irrevent.KeyInput.PressedDown = true; + irrevent.KeyInput.Control = (event.xkey.state & ControlMask) != 0; + irrevent.KeyInput.Shift = (event.xkey.state & ShiftMask) != 0; + irrevent.KeyInput.Key = getKeyCode(event); + postEventFromUser(irrevent); + } break; + + case ClientMessage: { + if (static_cast(event.xclient.data.l[0]) == X_ATOM_WM_DELETE_WINDOW && X_ATOM_WM_DELETE_WINDOW != None) { + os::Printer::log("Quit message received.", ELL_INFORMATION); + Close = true; + } else { + // we assume it's a user message + irrevent.EventType = irr::EET_USER_EVENT; + irrevent.UserEvent.UserData1 = static_cast(event.xclient.data.l[0]); + irrevent.UserEvent.UserData2 = static_cast(event.xclient.data.l[1]); + postEventFromUser(irrevent); + } + } break; + + case SelectionRequest: { + XSelectionRequestEvent *req = &(event.xselectionrequest); + + auto send_response = [this, req](Atom property) { + XEvent response; + response.xselection.type = SelectionNotify; + response.xselection.display = req->display; + response.xselection.requestor = req->requestor; + response.xselection.selection = req->selection; + response.xselection.target = req->target; + response.xselection.property = property; + response.xselection.time = req->time; + XSendEvent(XDisplay, req->requestor, 0, 0, &response); + XFlush(XDisplay); + }; + auto send_response_refuse = [&send_response] { + send_response(None); + }; + + // sets the required property to data of type type and + // sends the according response + auto set_property_and_notify = [this, req, &send_response](Atom type, int format, const void *data, u32 data_size) { + XChangeProperty(XDisplay, + req->requestor, + req->property, + type, + format, + PropModeReplace, + (const unsigned char *)data, + data_size); + send_response(req->property); + }; + + if ((req->selection != X_ATOM_CLIPBOARD && + req->selection != XA_PRIMARY) || + req->owner != XWindow) { + // we are not the owner, refuse request + send_response_refuse(); + break; + } + const core::stringc &text_buffer = req->selection == X_ATOM_CLIPBOARD ? Clipboard : PrimarySelection; + + // for debugging: + //~ { + //~ char *target_name = XGetAtomName(XDisplay, req->target); + //~ fprintf(stderr, "CIrrDeviceLinux::run: target: %s (=%ld)\n", + //~ target_name, req->target); + //~ XFree(target_name); + //~ } + + if (req->property == None) { + // req is from obsolete client, use target as property name + // and X_ATOM_UTF8_STRING as type + // Note: this was not tested and might be incorrect + os::Printer::log("CIrrDeviceLinux::run: SelectionRequest from obsolete client", + ELL_WARNING); + XChangeProperty(XDisplay, + req->requestor, + req->target, X_ATOM_UTF8_STRING, + 8, // format = 8-bit + PropModeReplace, + (unsigned char *)text_buffer.c_str(), + text_buffer.size()); + send_response(req->target); + break; + } + + if (req->target == X_ATOM_TARGETS) { + Atom data[] = { + X_ATOM_TARGETS, + X_ATOM_TEXT, + X_ATOM_UTF8_STRING, + X_ATOM_UTF8_MIME_TYPE}; + set_property_and_notify( + XA_ATOM, + 32, // Atom is long, we need to set 32 for longs + &data, + sizeof(data) / sizeof(*data)); + + } else if (req->target == X_ATOM_TEXT || + req->target == X_ATOM_UTF8_STRING || + req->target == X_ATOM_UTF8_MIME_TYPE) { + set_property_and_notify( + X_ATOM_UTF8_STRING, + 8, + text_buffer.c_str(), + text_buffer.size()); + + } else { + // refuse the request + send_response_refuse(); + } + } break; + +#if defined(_IRR_LINUX_X11_XINPUT2_) + case GenericEvent: { + XGenericEventCookie *cookie = &event.xcookie; + if (XGetEventData(XDisplay, cookie) && cookie->extension == XI_EXTENSIONS_OPCODE && XI_EXTENSIONS_OPCODE && (cookie->evtype == XI_TouchUpdate || cookie->evtype == XI_TouchBegin || cookie->evtype == XI_TouchEnd)) { + XIDeviceEvent *de = (XIDeviceEvent *)cookie->data; + + irrevent.EventType = EET_TOUCH_INPUT_EVENT; + + irrevent.TouchInput.Event = cookie->evtype == XI_TouchUpdate ? ETIE_MOVED : (cookie->evtype == XI_TouchBegin ? ETIE_PRESSED_DOWN : ETIE_LEFT_UP); + + irrevent.TouchInput.ID = de->detail; + irrevent.TouchInput.X = de->event_x; + irrevent.TouchInput.Y = de->event_y; + + if (irrevent.TouchInput.Event == ETIE_PRESSED_DOWN) { + currentTouchedCount++; + } + irrevent.TouchInput.touchedCount = currentTouchedCount; + if (currentTouchedCount > 0 && irrevent.TouchInput.Event == ETIE_LEFT_UP) { + currentTouchedCount--; + } + + postEventFromUser(irrevent); + } + } break; +#endif + + default: + break; + } // end switch + + // Update IME information + if (XInputContext && GUIEnvironment) { + gui::IGUIElement *elem = GUIEnvironment->getFocus(); + if (elem && elem->acceptsIME()) { + core::rect r = elem->getAbsolutePosition(); + XPoint p; + p.x = (short)r.UpperLeftCorner.X; + p.y = (short)r.LowerRightCorner.Y; + XSetICFocus(XInputContext); + XVaNestedList l = XVaCreateNestedList(0, XNSpotLocation, &p, NULL); + XSetICValues(XInputContext, XNPreeditAttributes, l, NULL); + XFree(l); + } else { + XUnsetICFocus(XInputContext); + } + } + + } // end while + } +#endif //_IRR_COMPILE_WITH_X11_ + + if (!Close) + pollJoysticks(); + + return !Close; +} + +//! Pause the current process for the minimum time allowed only to allow other processes to execute +void CIrrDeviceLinux::yield() +{ + struct timespec ts = {0, 1}; + nanosleep(&ts, NULL); +} + +//! Pause execution and let other processes to run for a specified amount of time. +void CIrrDeviceLinux::sleep(u32 timeMs, bool pauseTimer = false) +{ + const bool wasStopped = Timer ? Timer->isStopped() : true; + + struct timespec ts; + ts.tv_sec = (time_t)(timeMs / 1000); + ts.tv_nsec = (long)(timeMs % 1000) * 1000000; + + if (pauseTimer && !wasStopped) + Timer->stop(); + + nanosleep(&ts, NULL); + + if (pauseTimer && !wasStopped) + Timer->start(); +} + +//! sets the caption of the window +void CIrrDeviceLinux::setWindowCaption(const wchar_t *text) +{ +#ifdef _IRR_COMPILE_WITH_X11_ + if (CreationParams.DriverType == video::EDT_NULL) + return; + + XTextProperty txt; + if (Success == XwcTextListToTextProperty(XDisplay, const_cast(&text), + 1, XStdICCTextStyle, &txt)) { + XSetWMName(XDisplay, XWindow, &txt); + XSetWMIconName(XDisplay, XWindow, &txt); + XFree(txt.value); + } +#endif +} + +//! Sets the window icon. +bool CIrrDeviceLinux::setWindowIcon(const video::IImage *img) +{ + if (CreationParams.DriverType == video::EDT_NULL) + return false; // no display and window + + u32 height = img->getDimension().Height; + u32 width = img->getDimension().Width; + + size_t icon_buffer_len = 2 + height * width; + long *icon_buffer = new long[icon_buffer_len]; + + icon_buffer[0] = width; + icon_buffer[1] = height; + + for (u32 x = 0; x < width; x++) { + for (u32 y = 0; y < height; y++) { + video::SColor col = img->getPixel(x, y); + long pixel_val = 0; + pixel_val |= (u8)col.getAlpha() << 24; + pixel_val |= (u8)col.getRed() << 16; + pixel_val |= (u8)col.getGreen() << 8; + pixel_val |= (u8)col.getBlue(); + icon_buffer[2 + x + y * width] = pixel_val; + } + } + + if (XDisplay == NULL) { + os::Printer::log("Could not find x11 display for setting its icon.", ELL_ERROR); + delete[] icon_buffer; + return false; + } + + Atom net_wm_icon = XInternAtom(XDisplay, "_NET_WM_ICON", False); + Atom cardinal = XInternAtom(XDisplay, "CARDINAL", False); + XChangeProperty(XDisplay, XWindow, net_wm_icon, cardinal, 32, PropModeReplace, + (const unsigned char *)icon_buffer, icon_buffer_len); + + delete[] icon_buffer; + + return true; +} + +//! notifies the device that it should close itself +void CIrrDeviceLinux::closeDevice() +{ + Close = true; +} + +//! returns if window is active. if not, nothing need to be drawn +bool CIrrDeviceLinux::isWindowActive() const +{ + return (WindowHasFocus && !WindowMinimized); +} + +//! returns if window has focus. +bool CIrrDeviceLinux::isWindowFocused() const +{ + return WindowHasFocus; +} + +//! returns if window is minimized. +bool CIrrDeviceLinux::isWindowMinimized() const +{ + return WindowMinimized; +} + +//! returns last state from maximizeWindow() and restoreWindow() +bool CIrrDeviceLinux::isWindowMaximized() const +{ + return WindowMaximized; +} + +//! returns color format of the window. +video::ECOLOR_FORMAT CIrrDeviceLinux::getColorFormat() const +{ +#ifdef _IRR_COMPILE_WITH_X11_ + if (VisualInfo && (VisualInfo->depth != 16)) + return video::ECF_R8G8B8; + else +#endif + return video::ECF_R5G6B5; +} + +//! Sets if the window should be resizable in windowed mode. +void CIrrDeviceLinux::setResizable(bool resize) +{ +#ifdef _IRR_COMPILE_WITH_X11_ + if (CreationParams.DriverType == video::EDT_NULL || CreationParams.Fullscreen) + return; + + if (!resize) { + // Must be heap memory because data size depends on X Server + XSizeHints *hints = XAllocSizeHints(); + hints->flags = PSize | PMinSize | PMaxSize; + hints->min_width = hints->max_width = hints->base_width = Width; + hints->min_height = hints->max_height = hints->base_height = Height; + XSetWMNormalHints(XDisplay, XWindow, hints); + XFree(hints); + } else { + XSetWMNormalHints(XDisplay, XWindow, StdHints); + } + XFlush(XDisplay); +#endif // #ifdef _IRR_COMPILE_WITH_X11_ +} + +//! Resize the render window. +void CIrrDeviceLinux::setWindowSize(const irr::core::dimension2d &size) +{ +#ifdef _IRR_COMPILE_WITH_X11_ + if (CreationParams.DriverType == video::EDT_NULL || CreationParams.Fullscreen) + return; + + XWindowChanges values; + values.width = size.Width; + values.height = size.Height; + XConfigureWindow(XDisplay, XWindow, CWWidth | CWHeight, &values); + XFlush(XDisplay); +#endif // #ifdef _IRR_COMPILE_WITH_X11_ +} + +//! Minimize window +void CIrrDeviceLinux::minimizeWindow() +{ +#ifdef _IRR_COMPILE_WITH_X11_ + XIconifyWindow(XDisplay, XWindow, Screennr); +#endif +} + +//! Maximize window +void CIrrDeviceLinux::maximizeWindow() +{ +#ifdef _IRR_COMPILE_WITH_X11_ + // Maximize is not implemented in bare X, it's a WM construct. + if (HasNetWM) { + XEvent ev = {0}; + + ev.type = ClientMessage; + ev.xclient.window = XWindow; + ev.xclient.message_type = X_ATOM_NETWM_STATE; + ev.xclient.format = 32; + ev.xclient.data.l[0] = 1; // _NET_WM_STATE_ADD + ev.xclient.data.l[1] = X_ATOM_NETWM_MAXIMIZE_VERT; + ev.xclient.data.l[2] = X_ATOM_NETWM_MAXIMIZE_HORZ; + + XSendEvent(XDisplay, DefaultRootWindow(XDisplay), false, + SubstructureNotifyMask | SubstructureRedirectMask, &ev); + } + + XMapWindow(XDisplay, XWindow); + + WindowMaximized = true; +#endif +} + +//! Restore original window size +void CIrrDeviceLinux::restoreWindow() +{ +#ifdef _IRR_COMPILE_WITH_X11_ + // Maximize is not implemented in bare X, it's a WM construct. + if (HasNetWM) { + XEvent ev = {0}; + + ev.type = ClientMessage; + ev.xclient.window = XWindow; + ev.xclient.message_type = X_ATOM_NETWM_STATE; + ev.xclient.format = 32; + ev.xclient.data.l[0] = 0; // _NET_WM_STATE_REMOVE + ev.xclient.data.l[1] = X_ATOM_NETWM_MAXIMIZE_VERT; + ev.xclient.data.l[2] = X_ATOM_NETWM_MAXIMIZE_HORZ; + + XSendEvent(XDisplay, DefaultRootWindow(XDisplay), false, + SubstructureNotifyMask | SubstructureRedirectMask, &ev); + } + + XMapWindow(XDisplay, XWindow); + + WindowMaximized = false; +#endif +} + +core::position2di CIrrDeviceLinux::getWindowPosition() +{ + int wx = 0, wy = 0; +#ifdef _IRR_COMPILE_WITH_X11_ + Window child; + XTranslateCoordinates(XDisplay, XWindow, DefaultRootWindow(XDisplay), 0, 0, &wx, &wy, &child); +#endif + return core::position2di(wx, wy); +} + +void CIrrDeviceLinux::createKeyMap() +{ + // I don't know if this is the best method to create + // the lookuptable, but I'll leave it like that until + // I find a better version. + // Search for missing numbers in keysymdef.h + +#ifdef _IRR_COMPILE_WITH_X11_ + KeyMap.reallocate(190); + KeyMap.push_back(SKeyMap(XK_BackSpace, KEY_BACK)); + KeyMap.push_back(SKeyMap(XK_Tab, KEY_TAB)); + KeyMap.push_back(SKeyMap(XK_ISO_Left_Tab, KEY_TAB)); + KeyMap.push_back(SKeyMap(XK_Linefeed, 0)); // ??? + KeyMap.push_back(SKeyMap(XK_Clear, KEY_CLEAR)); + KeyMap.push_back(SKeyMap(XK_Return, KEY_RETURN)); + KeyMap.push_back(SKeyMap(XK_Pause, KEY_PAUSE)); + KeyMap.push_back(SKeyMap(XK_Scroll_Lock, KEY_SCROLL)); + KeyMap.push_back(SKeyMap(XK_Sys_Req, 0)); // ??? + KeyMap.push_back(SKeyMap(XK_Escape, KEY_ESCAPE)); + KeyMap.push_back(SKeyMap(XK_Insert, KEY_INSERT)); + KeyMap.push_back(SKeyMap(XK_Delete, KEY_DELETE)); + KeyMap.push_back(SKeyMap(XK_Home, KEY_HOME)); + KeyMap.push_back(SKeyMap(XK_Left, KEY_LEFT)); + KeyMap.push_back(SKeyMap(XK_Up, KEY_UP)); + KeyMap.push_back(SKeyMap(XK_Right, KEY_RIGHT)); + KeyMap.push_back(SKeyMap(XK_Down, KEY_DOWN)); + KeyMap.push_back(SKeyMap(XK_Prior, KEY_PRIOR)); + KeyMap.push_back(SKeyMap(XK_Page_Up, KEY_PRIOR)); + KeyMap.push_back(SKeyMap(XK_Next, KEY_NEXT)); + KeyMap.push_back(SKeyMap(XK_Page_Down, KEY_NEXT)); + KeyMap.push_back(SKeyMap(XK_End, KEY_END)); + KeyMap.push_back(SKeyMap(XK_Begin, KEY_NUMPAD5)); + KeyMap.push_back(SKeyMap(XK_Num_Lock, KEY_NUMLOCK)); + KeyMap.push_back(SKeyMap(XK_KP_Space, KEY_SPACE)); + KeyMap.push_back(SKeyMap(XK_KP_Tab, KEY_TAB)); + KeyMap.push_back(SKeyMap(XK_KP_Enter, KEY_RETURN)); + KeyMap.push_back(SKeyMap(XK_KP_F1, KEY_F1)); + KeyMap.push_back(SKeyMap(XK_KP_F2, KEY_F2)); + KeyMap.push_back(SKeyMap(XK_KP_F3, KEY_F3)); + KeyMap.push_back(SKeyMap(XK_KP_F4, KEY_F4)); + KeyMap.push_back(SKeyMap(XK_KP_Home, KEY_HOME)); + KeyMap.push_back(SKeyMap(XK_KP_Left, KEY_LEFT)); + KeyMap.push_back(SKeyMap(XK_KP_Up, KEY_UP)); + KeyMap.push_back(SKeyMap(XK_KP_Right, KEY_RIGHT)); + KeyMap.push_back(SKeyMap(XK_KP_Down, KEY_DOWN)); + KeyMap.push_back(SKeyMap(XK_Print, KEY_PRINT)); + KeyMap.push_back(SKeyMap(XK_KP_Prior, KEY_PRIOR)); + KeyMap.push_back(SKeyMap(XK_KP_Page_Up, KEY_PRIOR)); + KeyMap.push_back(SKeyMap(XK_KP_Next, KEY_NEXT)); + KeyMap.push_back(SKeyMap(XK_KP_Page_Down, KEY_NEXT)); + KeyMap.push_back(SKeyMap(XK_KP_End, KEY_END)); + KeyMap.push_back(SKeyMap(XK_KP_Begin, KEY_NUMPAD5)); + KeyMap.push_back(SKeyMap(XK_KP_Insert, KEY_INSERT)); + KeyMap.push_back(SKeyMap(XK_KP_Delete, KEY_DELETE)); + KeyMap.push_back(SKeyMap(XK_KP_Equal, 0)); // ??? + KeyMap.push_back(SKeyMap(XK_KP_Multiply, KEY_MULTIPLY)); + KeyMap.push_back(SKeyMap(XK_KP_Add, KEY_ADD)); + KeyMap.push_back(SKeyMap(XK_KP_Separator, KEY_SEPARATOR)); + KeyMap.push_back(SKeyMap(XK_KP_Subtract, KEY_SUBTRACT)); + KeyMap.push_back(SKeyMap(XK_KP_Decimal, KEY_DECIMAL)); + KeyMap.push_back(SKeyMap(XK_KP_Divide, KEY_DIVIDE)); + KeyMap.push_back(SKeyMap(XK_KP_0, KEY_NUMPAD0)); + KeyMap.push_back(SKeyMap(XK_KP_1, KEY_NUMPAD1)); + KeyMap.push_back(SKeyMap(XK_KP_2, KEY_NUMPAD2)); + KeyMap.push_back(SKeyMap(XK_KP_3, KEY_NUMPAD3)); + KeyMap.push_back(SKeyMap(XK_KP_4, KEY_NUMPAD4)); + KeyMap.push_back(SKeyMap(XK_KP_5, KEY_NUMPAD5)); + KeyMap.push_back(SKeyMap(XK_KP_6, KEY_NUMPAD6)); + KeyMap.push_back(SKeyMap(XK_KP_7, KEY_NUMPAD7)); + KeyMap.push_back(SKeyMap(XK_KP_8, KEY_NUMPAD8)); + KeyMap.push_back(SKeyMap(XK_KP_9, KEY_NUMPAD9)); + KeyMap.push_back(SKeyMap(XK_F1, KEY_F1)); + KeyMap.push_back(SKeyMap(XK_F2, KEY_F2)); + KeyMap.push_back(SKeyMap(XK_F3, KEY_F3)); + KeyMap.push_back(SKeyMap(XK_F4, KEY_F4)); + KeyMap.push_back(SKeyMap(XK_F5, KEY_F5)); + KeyMap.push_back(SKeyMap(XK_F6, KEY_F6)); + KeyMap.push_back(SKeyMap(XK_F7, KEY_F7)); + KeyMap.push_back(SKeyMap(XK_F8, KEY_F8)); + KeyMap.push_back(SKeyMap(XK_F9, KEY_F9)); + KeyMap.push_back(SKeyMap(XK_F10, KEY_F10)); + KeyMap.push_back(SKeyMap(XK_F11, KEY_F11)); + KeyMap.push_back(SKeyMap(XK_F12, KEY_F12)); + KeyMap.push_back(SKeyMap(XK_Shift_L, KEY_LSHIFT)); + KeyMap.push_back(SKeyMap(XK_Shift_R, KEY_RSHIFT)); + KeyMap.push_back(SKeyMap(XK_Control_L, KEY_LCONTROL)); + KeyMap.push_back(SKeyMap(XK_Control_R, KEY_RCONTROL)); + KeyMap.push_back(SKeyMap(XK_Caps_Lock, KEY_CAPITAL)); + KeyMap.push_back(SKeyMap(XK_Shift_Lock, KEY_CAPITAL)); + KeyMap.push_back(SKeyMap(XK_Meta_L, KEY_LWIN)); + KeyMap.push_back(SKeyMap(XK_Meta_R, KEY_RWIN)); + KeyMap.push_back(SKeyMap(XK_Alt_L, KEY_LMENU)); + KeyMap.push_back(SKeyMap(XK_Alt_R, KEY_RMENU)); + KeyMap.push_back(SKeyMap(XK_ISO_Level3_Shift, KEY_RMENU)); + KeyMap.push_back(SKeyMap(XK_Menu, KEY_MENU)); + KeyMap.push_back(SKeyMap(XK_space, KEY_SPACE)); + KeyMap.push_back(SKeyMap(XK_exclam, 0)); //? + KeyMap.push_back(SKeyMap(XK_quotedbl, 0)); //? + KeyMap.push_back(SKeyMap(XK_section, 0)); //? + KeyMap.push_back(SKeyMap(XK_numbersign, KEY_OEM_2)); + KeyMap.push_back(SKeyMap(XK_dollar, 0)); //? + KeyMap.push_back(SKeyMap(XK_percent, 0)); //? + KeyMap.push_back(SKeyMap(XK_ampersand, 0)); //? + KeyMap.push_back(SKeyMap(XK_apostrophe, KEY_OEM_7)); + KeyMap.push_back(SKeyMap(XK_parenleft, 0)); //? + KeyMap.push_back(SKeyMap(XK_parenright, 0)); //? + KeyMap.push_back(SKeyMap(XK_asterisk, 0)); //? + KeyMap.push_back(SKeyMap(XK_plus, KEY_PLUS)); //? + KeyMap.push_back(SKeyMap(XK_comma, KEY_COMMA)); //? + KeyMap.push_back(SKeyMap(XK_minus, KEY_MINUS)); //? + KeyMap.push_back(SKeyMap(XK_period, KEY_PERIOD)); //? + KeyMap.push_back(SKeyMap(XK_slash, KEY_OEM_2)); //? + KeyMap.push_back(SKeyMap(XK_0, KEY_KEY_0)); + KeyMap.push_back(SKeyMap(XK_1, KEY_KEY_1)); + KeyMap.push_back(SKeyMap(XK_2, KEY_KEY_2)); + KeyMap.push_back(SKeyMap(XK_3, KEY_KEY_3)); + KeyMap.push_back(SKeyMap(XK_4, KEY_KEY_4)); + KeyMap.push_back(SKeyMap(XK_5, KEY_KEY_5)); + KeyMap.push_back(SKeyMap(XK_6, KEY_KEY_6)); + KeyMap.push_back(SKeyMap(XK_7, KEY_KEY_7)); + KeyMap.push_back(SKeyMap(XK_8, KEY_KEY_8)); + KeyMap.push_back(SKeyMap(XK_9, KEY_KEY_9)); + KeyMap.push_back(SKeyMap(XK_colon, 0)); //? + KeyMap.push_back(SKeyMap(XK_semicolon, KEY_OEM_1)); + KeyMap.push_back(SKeyMap(XK_less, KEY_OEM_102)); + KeyMap.push_back(SKeyMap(XK_equal, KEY_PLUS)); + KeyMap.push_back(SKeyMap(XK_greater, 0)); //? + KeyMap.push_back(SKeyMap(XK_question, 0)); //? + KeyMap.push_back(SKeyMap(XK_at, KEY_KEY_2)); //? + KeyMap.push_back(SKeyMap(XK_mu, 0)); //? + KeyMap.push_back(SKeyMap(XK_EuroSign, 0)); //? + KeyMap.push_back(SKeyMap(XK_A, KEY_KEY_A)); + KeyMap.push_back(SKeyMap(XK_B, KEY_KEY_B)); + KeyMap.push_back(SKeyMap(XK_C, KEY_KEY_C)); + KeyMap.push_back(SKeyMap(XK_D, KEY_KEY_D)); + KeyMap.push_back(SKeyMap(XK_E, KEY_KEY_E)); + KeyMap.push_back(SKeyMap(XK_F, KEY_KEY_F)); + KeyMap.push_back(SKeyMap(XK_G, KEY_KEY_G)); + KeyMap.push_back(SKeyMap(XK_H, KEY_KEY_H)); + KeyMap.push_back(SKeyMap(XK_I, KEY_KEY_I)); + KeyMap.push_back(SKeyMap(XK_J, KEY_KEY_J)); + KeyMap.push_back(SKeyMap(XK_K, KEY_KEY_K)); + KeyMap.push_back(SKeyMap(XK_L, KEY_KEY_L)); + KeyMap.push_back(SKeyMap(XK_M, KEY_KEY_M)); + KeyMap.push_back(SKeyMap(XK_N, KEY_KEY_N)); + KeyMap.push_back(SKeyMap(XK_O, KEY_KEY_O)); + KeyMap.push_back(SKeyMap(XK_P, KEY_KEY_P)); + KeyMap.push_back(SKeyMap(XK_Q, KEY_KEY_Q)); + KeyMap.push_back(SKeyMap(XK_R, KEY_KEY_R)); + KeyMap.push_back(SKeyMap(XK_S, KEY_KEY_S)); + KeyMap.push_back(SKeyMap(XK_T, KEY_KEY_T)); + KeyMap.push_back(SKeyMap(XK_U, KEY_KEY_U)); + KeyMap.push_back(SKeyMap(XK_V, KEY_KEY_V)); + KeyMap.push_back(SKeyMap(XK_W, KEY_KEY_W)); + KeyMap.push_back(SKeyMap(XK_X, KEY_KEY_X)); + KeyMap.push_back(SKeyMap(XK_Y, KEY_KEY_Y)); + KeyMap.push_back(SKeyMap(XK_Z, KEY_KEY_Z)); + KeyMap.push_back(SKeyMap(XK_bracketleft, KEY_OEM_4)); + KeyMap.push_back(SKeyMap(XK_backslash, KEY_OEM_5)); + KeyMap.push_back(SKeyMap(XK_bracketright, KEY_OEM_6)); + KeyMap.push_back(SKeyMap(XK_asciicircum, KEY_OEM_5)); + KeyMap.push_back(SKeyMap(XK_dead_circumflex, KEY_OEM_5)); + KeyMap.push_back(SKeyMap(XK_degree, 0)); //? + KeyMap.push_back(SKeyMap(XK_underscore, KEY_MINUS)); //? + KeyMap.push_back(SKeyMap(XK_grave, KEY_OEM_3)); + KeyMap.push_back(SKeyMap(XK_dead_grave, KEY_OEM_3)); + KeyMap.push_back(SKeyMap(XK_acute, KEY_OEM_6)); + KeyMap.push_back(SKeyMap(XK_dead_acute, KEY_OEM_6)); + KeyMap.push_back(SKeyMap(XK_a, KEY_KEY_A)); + KeyMap.push_back(SKeyMap(XK_b, KEY_KEY_B)); + KeyMap.push_back(SKeyMap(XK_c, KEY_KEY_C)); + KeyMap.push_back(SKeyMap(XK_d, KEY_KEY_D)); + KeyMap.push_back(SKeyMap(XK_e, KEY_KEY_E)); + KeyMap.push_back(SKeyMap(XK_f, KEY_KEY_F)); + KeyMap.push_back(SKeyMap(XK_g, KEY_KEY_G)); + KeyMap.push_back(SKeyMap(XK_h, KEY_KEY_H)); + KeyMap.push_back(SKeyMap(XK_i, KEY_KEY_I)); + KeyMap.push_back(SKeyMap(XK_j, KEY_KEY_J)); + KeyMap.push_back(SKeyMap(XK_k, KEY_KEY_K)); + KeyMap.push_back(SKeyMap(XK_l, KEY_KEY_L)); + KeyMap.push_back(SKeyMap(XK_m, KEY_KEY_M)); + KeyMap.push_back(SKeyMap(XK_n, KEY_KEY_N)); + KeyMap.push_back(SKeyMap(XK_o, KEY_KEY_O)); + KeyMap.push_back(SKeyMap(XK_p, KEY_KEY_P)); + KeyMap.push_back(SKeyMap(XK_q, KEY_KEY_Q)); + KeyMap.push_back(SKeyMap(XK_r, KEY_KEY_R)); + KeyMap.push_back(SKeyMap(XK_s, KEY_KEY_S)); + KeyMap.push_back(SKeyMap(XK_t, KEY_KEY_T)); + KeyMap.push_back(SKeyMap(XK_u, KEY_KEY_U)); + KeyMap.push_back(SKeyMap(XK_v, KEY_KEY_V)); + KeyMap.push_back(SKeyMap(XK_w, KEY_KEY_W)); + KeyMap.push_back(SKeyMap(XK_x, KEY_KEY_X)); + KeyMap.push_back(SKeyMap(XK_y, KEY_KEY_Y)); + KeyMap.push_back(SKeyMap(XK_z, KEY_KEY_Z)); + KeyMap.push_back(SKeyMap(XK_ssharp, KEY_OEM_4)); + KeyMap.push_back(SKeyMap(XK_adiaeresis, KEY_OEM_7)); + KeyMap.push_back(SKeyMap(XK_odiaeresis, KEY_OEM_3)); + KeyMap.push_back(SKeyMap(XK_udiaeresis, KEY_OEM_1)); + KeyMap.push_back(SKeyMap(XK_Super_L, KEY_LWIN)); + KeyMap.push_back(SKeyMap(XK_Super_R, KEY_RWIN)); + + KeyMap.sort(); +#endif +} + +bool CIrrDeviceLinux::activateJoysticks(core::array &joystickInfo) +{ +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) + + joystickInfo.clear(); + + u32 joystick; + for (joystick = 0; joystick < 32; ++joystick) { + // The joystick device could be here... + core::stringc devName = "/dev/js"; + devName += joystick; + + SJoystickInfo returnInfo; + JoystickInfo info; + + info.fd = open(devName.c_str(), O_RDONLY); + if (-1 == info.fd) { + // ...but Ubuntu and possibly other distros + // create the devices in /dev/input + devName = "/dev/input/js"; + devName += joystick; + info.fd = open(devName.c_str(), O_RDONLY); + if (-1 == info.fd) { + // and BSD here + devName = "/dev/joy"; + devName += joystick; + info.fd = open(devName.c_str(), O_RDONLY); + } + } + + if (-1 == info.fd) + continue; + +#ifdef __FreeBSD__ + info.axes = 2; + info.buttons = 2; +#else + ioctl(info.fd, JSIOCGAXES, &(info.axes)); + ioctl(info.fd, JSIOCGBUTTONS, &(info.buttons)); + fcntl(info.fd, F_SETFL, O_NONBLOCK); +#endif + + (void)memset(&info.persistentData, 0, sizeof(info.persistentData)); + info.persistentData.EventType = irr::EET_JOYSTICK_INPUT_EVENT; + info.persistentData.JoystickEvent.Joystick = ActiveJoysticks.size(); + + // There's no obvious way to determine which (if any) axes represent a POV + // hat, so we'll just set it to "not used" and forget about it. + info.persistentData.JoystickEvent.POV = 65535; + + ActiveJoysticks.push_back(info); + + returnInfo.Joystick = joystick; + returnInfo.PovHat = SJoystickInfo::POV_HAT_UNKNOWN; + returnInfo.Axes = info.axes; + returnInfo.Buttons = info.buttons; + +#ifndef __FreeBSD__ + char name[80]; + ioctl(info.fd, JSIOCGNAME(80), name); + returnInfo.Name = name; +#endif + + joystickInfo.push_back(returnInfo); + } + + for (joystick = 0; joystick < joystickInfo.size(); ++joystick) { + char logString[256]; + snprintf_irr(logString, sizeof(logString), "Found joystick %d, %d axes, %d buttons '%s'", + joystick, joystickInfo[joystick].Axes, + joystickInfo[joystick].Buttons, joystickInfo[joystick].Name.c_str()); + os::Printer::log(logString, ELL_INFORMATION); + } + + return true; +#else + return false; +#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ +} + +void CIrrDeviceLinux::pollJoysticks() +{ +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) + if (0 == ActiveJoysticks.size()) + return; + + for (u32 j = 0; j < ActiveJoysticks.size(); ++j) { + JoystickInfo &info = ActiveJoysticks[j]; + +#ifdef __FreeBSD__ + struct joystick js; + if (read(info.fd, &js, sizeof(js)) == sizeof(js)) { + info.persistentData.JoystickEvent.ButtonStates = js.b1 | (js.b2 << 1); /* should be a two-bit field */ + info.persistentData.JoystickEvent.Axis[0] = js.x; /* X axis */ + info.persistentData.JoystickEvent.Axis[1] = js.y; /* Y axis */ + } +#else + struct js_event event; + while (sizeof(event) == read(info.fd, &event, sizeof(event))) { + switch (event.type & ~JS_EVENT_INIT) { + case JS_EVENT_BUTTON: + if (event.value) + info.persistentData.JoystickEvent.ButtonStates |= (1 << event.number); + else + info.persistentData.JoystickEvent.ButtonStates &= ~(1 << event.number); + break; + + case JS_EVENT_AXIS: + if (event.number < SEvent::SJoystickEvent::NUMBER_OF_AXES) + info.persistentData.JoystickEvent.Axis[event.number] = event.value; + break; + + default: + break; + } + } +#endif + + // Send an irrlicht joystick event once per ::run() even if no new data were received. + (void)postEventFromUser(info.persistentData); + } +#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ +} + +#if defined(_IRR_COMPILE_WITH_X11_) +//! gets text from the clipboard +//! \return Returns 0 if no string is in there, otherwise utf-8 text. +const c8 *CIrrDeviceLinux::getTextFromSelection(Atom selection, core::stringc &text_buffer) const +{ + Window ownerWindow = XGetSelectionOwner(XDisplay, selection); + if (ownerWindow == XWindow) { + return text_buffer.c_str(); + } + + text_buffer = ""; + + if (ownerWindow == None) { + return text_buffer.c_str(); + } + + // delete the property to be set beforehand + XDeleteProperty(XDisplay, XWindow, XA_PRIMARY); + + XConvertSelection(XDisplay, selection, X_ATOM_UTF8_STRING, XA_PRIMARY, + XWindow, CurrentTime); + XFlush(XDisplay); + + // wait for event via a blocking call + XEvent event_ret; + std::pair args(XWindow, selection); + XIfEvent( + XDisplay, &event_ret, [](Display *_display, XEvent *event, XPointer arg) { + auto p = reinterpret_cast *>(arg); + return (Bool)(event->type == SelectionNotify && + event->xselection.requestor == p->first && + event->xselection.selection == p->second && + event->xselection.target == X_ATOM_UTF8_STRING); + }, + (XPointer)&args); + + _IRR_DEBUG_BREAK_IF(!(event_ret.type == SelectionNotify && + event_ret.xselection.requestor == XWindow && + event_ret.xselection.selection == selection && + event_ret.xselection.target == X_ATOM_UTF8_STRING)); + + Atom property_set = event_ret.xselection.property; + if (event_ret.xselection.property == None) { + // request failed => empty string + return text_buffer.c_str(); + } + + // check for data + Atom type; + int format; + unsigned long numItems, bytesLeft, dummy; + unsigned char *data = nullptr; + XGetWindowProperty(XDisplay, XWindow, + property_set, // property name + 0, // offset + 0, // length (we only check for data, so 0) + 0, // Delete 0==false + AnyPropertyType, // AnyPropertyType or property identifier + &type, // return type + &format, // return format + &numItems, // number items + &bytesLeft, // remaining bytes for partial reads + &data); // data + if (data) { + XFree(data); + data = nullptr; + } + + // for debugging: + //~ { + //~ char *type_name = XGetAtomName(XDisplay, type); + //~ fprintf(stderr, "CIrrDeviceLinux::getTextFromSelection: actual type: %s (=%ld)\n", + //~ type_name, type); + //~ XFree(type_name); + //~ } + + if (type != X_ATOM_UTF8_STRING && type != X_ATOM_UTF8_MIME_TYPE) { + os::Printer::log("CIrrDeviceLinux::getTextFromSelection: did not get utf-8 string", + ELL_WARNING); + return text_buffer.c_str(); + } + + if (bytesLeft > 0) { + // there is some data to get + int result = XGetWindowProperty(XDisplay, XWindow, property_set, 0, + bytesLeft, 0, AnyPropertyType, &type, &format, + &numItems, &dummy, &data); + if (result == Success) + text_buffer = (irr::c8 *)data; + XFree(data); + } + + // delete the property again, to inform the owner about the successful transfer + XDeleteProperty(XDisplay, XWindow, property_set); + + return text_buffer.c_str(); +} +#endif + +//! gets text from the clipboard +//! \return Returns 0 if no string is in there, otherwise utf-8 text. +const c8 *CIrrDeviceLinux::getTextFromClipboard() const +{ +#if defined(_IRR_COMPILE_WITH_X11_) + return getTextFromSelection(X_ATOM_CLIPBOARD, Clipboard); +#else + return nullptr; +#endif +} + +//! gets text from the primary selection +//! \return Returns 0 if no string is in there, otherwise utf-8 text. +const c8 *CIrrDeviceLinux::getTextFromPrimarySelection() const +{ +#if defined(_IRR_COMPILE_WITH_X11_) + return getTextFromSelection(XA_PRIMARY, PrimarySelection); +#else + return nullptr; +#endif +} + +#if defined(_IRR_COMPILE_WITH_X11_) +bool CIrrDeviceLinux::becomeSelectionOwner(Atom selection) const +{ + XSetSelectionOwner(XDisplay, selection, XWindow, CurrentTime); + XFlush(XDisplay); + Window owner = XGetSelectionOwner(XDisplay, selection); + return owner == XWindow; +} +#endif + +//! copies text to the clipboard +void CIrrDeviceLinux::copyToClipboard(const c8 *text) const +{ +#if defined(_IRR_COMPILE_WITH_X11_) + // Actually there is no clipboard on X but applications just say they own the clipboard and return text when asked. + // Which btw. also means that on X you lose clipboard content when closing applications. + Clipboard = text; + if (!becomeSelectionOwner(X_ATOM_CLIPBOARD)) { + os::Printer::log("CIrrDeviceLinux::copyToClipboard: failed to set owner", ELL_WARNING); + } +#endif +} + +//! copies text to the primary selection +void CIrrDeviceLinux::copyToPrimarySelection(const c8 *text) const +{ +#if defined(_IRR_COMPILE_WITH_X11_) + PrimarySelection = text; + if (!becomeSelectionOwner(XA_PRIMARY)) { + os::Printer::log("CIrrDeviceLinux::copyToPrimarySelection: failed to set owner", ELL_WARNING); + } +#endif +} + +#ifdef _IRR_COMPILE_WITH_X11_ +// return true if the passed event has the type passed in parameter arg +Bool PredicateIsEventType(Display *display, XEvent *event, XPointer arg) +{ + if (event && event->type == *(int *)arg) { + // os::Printer::log("remove event", core::stringc((int)arg).c_str(), ELL_INFORMATION); + return True; + } + return False; +} +#endif //_IRR_COMPILE_WITH_X11_ + +//! Remove all messages pending in the system message loop +void CIrrDeviceLinux::clearSystemMessages() +{ +#ifdef _IRR_COMPILE_WITH_X11_ + if (CreationParams.DriverType != video::EDT_NULL) { + XEvent event; + int usrArg = ButtonPress; + while (XCheckIfEvent(XDisplay, &event, PredicateIsEventType, XPointer(&usrArg)) == True) { + } + usrArg = ButtonRelease; + while (XCheckIfEvent(XDisplay, &event, PredicateIsEventType, XPointer(&usrArg)) == True) { + } + usrArg = MotionNotify; + while (XCheckIfEvent(XDisplay, &event, PredicateIsEventType, XPointer(&usrArg)) == True) { + } + usrArg = KeyRelease; + while (XCheckIfEvent(XDisplay, &event, PredicateIsEventType, XPointer(&usrArg)) == True) { + } + usrArg = KeyPress; + while (XCheckIfEvent(XDisplay, &event, PredicateIsEventType, XPointer(&usrArg)) == True) { + } + } +#endif //_IRR_COMPILE_WITH_X11_ +} + +//! Get the display density in dots per inch. +float CIrrDeviceLinux::getDisplayDensity() const +{ +#ifdef _IRR_COMPILE_WITH_X11_ + if (XDisplay != NULL) { + /* try x direct */ + int dh = DisplayHeight(XDisplay, 0); + int dw = DisplayWidth(XDisplay, 0); + int dh_mm = DisplayHeightMM(XDisplay, 0); + int dw_mm = DisplayWidthMM(XDisplay, 0); + + if (dh_mm != 0 && dw_mm != 0) { + float dpi_height = floor(dh / (dh_mm * 0.039370) + 0.5); + float dpi_width = floor(dw / (dw_mm * 0.039370) + 0.5); + return std::max(dpi_height, dpi_width); + } + } +#endif //_IRR_COMPILE_WITH_X11_ + + return 0.0f; +} + +void CIrrDeviceLinux::initXAtoms() +{ +#ifdef _IRR_COMPILE_WITH_X11_ + X_ATOM_CLIPBOARD = XInternAtom(XDisplay, "CLIPBOARD", False); + X_ATOM_TARGETS = XInternAtom(XDisplay, "TARGETS", False); + X_ATOM_UTF8_STRING = XInternAtom(XDisplay, "UTF8_STRING", False); + X_ATOM_UTF8_MIME_TYPE = XInternAtom(XDisplay, "text/plain;charset=utf-8", False); + X_ATOM_TEXT = XInternAtom(XDisplay, "TEXT", False); + X_ATOM_NETWM_MAXIMIZE_VERT = XInternAtom(XDisplay, "_NET_WM_STATE_MAXIMIZED_VERT", true); + X_ATOM_NETWM_MAXIMIZE_HORZ = XInternAtom(XDisplay, "_NET_WM_STATE_MAXIMIZED_HORZ", true); + X_ATOM_NETWM_STATE = XInternAtom(XDisplay, "_NET_WM_STATE", true); + X_ATOM_NETWM_STATE_FULLSCREEN = XInternAtom(XDisplay, "_NET_WM_STATE_FULLSCREEN", True); +#endif +} + +void CIrrDeviceLinux::initXInput2() +{ +#if defined(_IRR_LINUX_X11_XINPUT2_) + int ev = 0; + int err = 0; + if (!XQueryExtension(XDisplay, "XInputExtension", &XI_EXTENSIONS_OPCODE, &ev, &err)) { + os::Printer::log("X Input extension not available.", ELL_WARNING); + return; + } + + int major = 2; + int minor = 3; + int rc = XIQueryVersion(XDisplay, &major, &minor); + if (rc != Success) { + os::Printer::log("No XI2 support.", ELL_WARNING); + return; + } + + // So far we only use XInput2 for touch events. + // So we enable those and disable all other events for now. + XIEventMask eventMask; + unsigned char mask[XIMaskLen(XI_TouchEnd)]; + memset(mask, 0, sizeof(mask)); + eventMask.deviceid = XIAllMasterDevices; + eventMask.mask_len = sizeof(mask); + eventMask.mask = mask; + XISetMask(eventMask.mask, XI_TouchBegin); + XISetMask(eventMask.mask, XI_TouchUpdate); + XISetMask(eventMask.mask, XI_TouchEnd); + + XISelectEvents(XDisplay, XWindow, &eventMask, 1); +#endif +} + +#ifdef _IRR_COMPILE_WITH_X11_ + +Cursor CIrrDeviceLinux::TextureToMonochromeCursor(irr::video::ITexture *tex, const core::rect &sourceRect, const core::position2d &hotspot) +{ + XImage *sourceImage = XCreateImage(XDisplay, VisualInfo->visual, + 1, // depth, + ZPixmap, // XYBitmap (depth=1), ZPixmap(depth=x) + 0, 0, sourceRect.getWidth(), sourceRect.getHeight(), + 32, // bitmap_pad, + 0 // bytes_per_line (0 means continuous in memory) + ); + sourceImage->data = new char[sourceImage->height * sourceImage->bytes_per_line]; + XImage *maskImage = XCreateImage(XDisplay, VisualInfo->visual, + 1, // depth, + ZPixmap, + 0, 0, sourceRect.getWidth(), sourceRect.getHeight(), + 32, // bitmap_pad, + 0 // bytes_per_line + ); + maskImage->data = new char[maskImage->height * maskImage->bytes_per_line]; + + // write texture into XImage + video::ECOLOR_FORMAT format = tex->getColorFormat(); + u32 bytesPerPixel = video::IImage::getBitsPerPixelFromFormat(format) / 8; + u32 bytesLeftGap = sourceRect.UpperLeftCorner.X * bytesPerPixel; + u32 bytesRightGap = tex->getPitch() - sourceRect.LowerRightCorner.X * bytesPerPixel; + const u8 *data = (const u8 *)tex->lock(video::ETLM_READ_ONLY, 0); + data += sourceRect.UpperLeftCorner.Y * tex->getPitch(); + for (s32 y = 0; y < sourceRect.getHeight(); ++y) { + data += bytesLeftGap; + for (s32 x = 0; x < sourceRect.getWidth(); ++x) { + video::SColor pixelCol; + pixelCol.setData((const void *)data, format); + data += bytesPerPixel; + + if (pixelCol.getAlpha() == 0) { // transparent + XPutPixel(maskImage, x, y, 0); + XPutPixel(sourceImage, x, y, 0); + } else // color + { + if (pixelCol.getAverage() >= 127) + XPutPixel(sourceImage, x, y, 1); + else + XPutPixel(sourceImage, x, y, 0); + XPutPixel(maskImage, x, y, 1); + } + } + data += bytesRightGap; + } + tex->unlock(); + + Pixmap sourcePixmap = XCreatePixmap(XDisplay, XWindow, sourceImage->width, sourceImage->height, sourceImage->depth); + Pixmap maskPixmap = XCreatePixmap(XDisplay, XWindow, maskImage->width, maskImage->height, maskImage->depth); + + XGCValues values; + values.foreground = 1; + values.background = 1; + GC gc = XCreateGC(XDisplay, sourcePixmap, GCForeground | GCBackground, &values); + + XPutImage(XDisplay, sourcePixmap, gc, sourceImage, 0, 0, 0, 0, sourceImage->width, sourceImage->height); + XPutImage(XDisplay, maskPixmap, gc, maskImage, 0, 0, 0, 0, maskImage->width, maskImage->height); + + XFreeGC(XDisplay, gc); + XDestroyImage(sourceImage); + XDestroyImage(maskImage); + + Cursor cursorResult = 0; + XColor foreground, background; + foreground.red = 65535; + foreground.green = 65535; + foreground.blue = 65535; + foreground.flags = DoRed | DoGreen | DoBlue; + background.red = 0; + background.green = 0; + background.blue = 0; + background.flags = DoRed | DoGreen | DoBlue; + + cursorResult = XCreatePixmapCursor(XDisplay, sourcePixmap, maskPixmap, &foreground, &background, hotspot.X, hotspot.Y); + + XFreePixmap(XDisplay, sourcePixmap); + XFreePixmap(XDisplay, maskPixmap); + + return cursorResult; +} + +#ifdef _IRR_LINUX_XCURSOR_ +Cursor CIrrDeviceLinux::TextureToARGBCursor(irr::video::ITexture *tex, const core::rect &sourceRect, const core::position2d &hotspot) +{ + XcursorImage *image = XcursorImageCreate(sourceRect.getWidth(), sourceRect.getHeight()); + image->xhot = hotspot.X; + image->yhot = hotspot.Y; + + // write texture into XcursorImage + video::ECOLOR_FORMAT format = tex->getColorFormat(); + u32 bytesPerPixel = video::IImage::getBitsPerPixelFromFormat(format) / 8; + u32 bytesLeftGap = sourceRect.UpperLeftCorner.X * bytesPerPixel; + u32 bytesRightGap = tex->getPitch() - sourceRect.LowerRightCorner.X * bytesPerPixel; + XcursorPixel *target = image->pixels; + const u8 *data = (const u8 *)tex->lock(video::ETLM_READ_ONLY, 0); + data += sourceRect.UpperLeftCorner.Y * tex->getPitch(); + for (s32 y = 0; y < sourceRect.getHeight(); ++y) { + data += bytesLeftGap; + for (s32 x = 0; x < sourceRect.getWidth(); ++x) { + video::SColor pixelCol; + pixelCol.setData((const void *)data, format); + data += bytesPerPixel; + + *target = (XcursorPixel)pixelCol.color; + ++target; + } + data += bytesRightGap; + } + tex->unlock(); + + Cursor cursorResult = XcursorImageLoadCursor(XDisplay, image); + + XcursorImageDestroy(image); + + return cursorResult; +} +#endif // #ifdef _IRR_LINUX_XCURSOR_ + +Cursor CIrrDeviceLinux::TextureToCursor(irr::video::ITexture *tex, const core::rect &sourceRect, const core::position2d &hotspot) +{ +#ifdef _IRR_LINUX_XCURSOR_ + return TextureToARGBCursor(tex, sourceRect, hotspot); +#else + return TextureToMonochromeCursor(tex, sourceRect, hotspot); +#endif +} +#endif // _IRR_COMPILE_WITH_X11_ + +CIrrDeviceLinux::CCursorControl::CCursorControl(CIrrDeviceLinux *dev, bool null) : + Device(dev) +#ifdef _IRR_COMPILE_WITH_X11_ + , + PlatformBehavior(gui::ECPB_NONE), LastQuery(0) +#ifdef _IRR_LINUX_X11_XINPUT2_ + , + DeviceId(0) +#endif +#endif + , + IsVisible(true), Null(null), UseReferenceRect(false), ActiveIcon(gui::ECI_NORMAL), ActiveIconStartTime(0) +{ +#ifdef _IRR_COMPILE_WITH_X11_ + if (!Null) { +#ifdef _IRR_LINUX_X11_XINPUT2_ + // XIWarpPointer is entirely broken on multi-head setups (see also [1]), + // but behaves better in other cases so we can't just disable it outright. + // [1] https://developer.blender.org/rB165caafb99c6846e53d11c4e966990aaffc06cea + if (XScreenCount(Device->XDisplay) > 1) { + os::Printer::log("Detected classic multi-head setup, not using XIWarpPointer"); + } else { + XIGetClientPointer(Device->XDisplay, Device->XWindow, &DeviceId); + } +#endif + + XGCValues values; + unsigned long valuemask = 0; + + XColor fg, bg; + + // this code, for making the cursor invisible was sent in by + // Sirshane, thank your very much! + + Pixmap invisBitmap = XCreatePixmap(Device->XDisplay, Device->XWindow, 32, 32, 1); + Pixmap maskBitmap = XCreatePixmap(Device->XDisplay, Device->XWindow, 32, 32, 1); + Colormap screen_colormap = DefaultColormap(Device->XDisplay, DefaultScreen(Device->XDisplay)); + XAllocNamedColor(Device->XDisplay, screen_colormap, "black", &fg, &fg); + XAllocNamedColor(Device->XDisplay, screen_colormap, "white", &bg, &bg); + + GC gc = XCreateGC(Device->XDisplay, invisBitmap, valuemask, &values); + + XSetForeground(Device->XDisplay, gc, BlackPixel(Device->XDisplay, DefaultScreen(Device->XDisplay))); + XFillRectangle(Device->XDisplay, invisBitmap, gc, 0, 0, 32, 32); + XFillRectangle(Device->XDisplay, maskBitmap, gc, 0, 0, 32, 32); + + InvisCursor = XCreatePixmapCursor(Device->XDisplay, invisBitmap, maskBitmap, &fg, &bg, 1, 1); + XFreeGC(Device->XDisplay, gc); + XFreePixmap(Device->XDisplay, invisBitmap); + XFreePixmap(Device->XDisplay, maskBitmap); + + initCursors(); + } +#endif +} + +CIrrDeviceLinux::CCursorControl::~CCursorControl() +{ + // Do not clearCursors here as the display is already closed + // TODO (cutealien): dropping cursorcontrol earlier might work, not sure about reason why that's done in stub currently. +} + +#ifdef _IRR_COMPILE_WITH_X11_ +void CIrrDeviceLinux::CCursorControl::clearCursors() +{ + if (!Null) + XFreeCursor(Device->XDisplay, InvisCursor); + for (u32 i = 0; i < Cursors.size(); ++i) { + for (u32 f = 0; f < Cursors[i].Frames.size(); ++f) { + XFreeCursor(Device->XDisplay, Cursors[i].Frames[f].IconHW); + } + } +} + +void CIrrDeviceLinux::CCursorControl::initCursors() +{ + Cursors.push_back(CursorX11(XCreateFontCursor(Device->XDisplay, XC_top_left_arrow))); // (or XC_arrow?) + Cursors.push_back(CursorX11(XCreateFontCursor(Device->XDisplay, XC_crosshair))); + Cursors.push_back(CursorX11(XCreateFontCursor(Device->XDisplay, XC_hand2))); // (or XC_hand1? ) + Cursors.push_back(CursorX11(XCreateFontCursor(Device->XDisplay, XC_question_arrow))); + Cursors.push_back(CursorX11(XCreateFontCursor(Device->XDisplay, XC_xterm))); + Cursors.push_back(CursorX11(XCreateFontCursor(Device->XDisplay, XC_X_cursor))); // (or XC_pirate?) + Cursors.push_back(CursorX11(XCreateFontCursor(Device->XDisplay, XC_watch))); // (or XC_clock?) + Cursors.push_back(CursorX11(XCreateFontCursor(Device->XDisplay, XC_fleur))); + Cursors.push_back(CursorX11(XCreateFontCursor(Device->XDisplay, XC_top_right_corner))); // NESW not available in X11 + Cursors.push_back(CursorX11(XCreateFontCursor(Device->XDisplay, XC_top_left_corner))); // NWSE not available in X11 + Cursors.push_back(CursorX11(XCreateFontCursor(Device->XDisplay, XC_sb_v_double_arrow))); + Cursors.push_back(CursorX11(XCreateFontCursor(Device->XDisplay, XC_sb_h_double_arrow))); + Cursors.push_back(CursorX11(XCreateFontCursor(Device->XDisplay, XC_sb_up_arrow))); // (or XC_center_ptr?) +} + +void CIrrDeviceLinux::CCursorControl::update() +{ + if ((u32)ActiveIcon < Cursors.size() && !Cursors[ActiveIcon].Frames.empty() && Cursors[ActiveIcon].FrameTime) { + // update animated cursors. This could also be done by X11 in case someone wants to figure that out (this way was just easier to implement) + u32 now = Device->getTimer()->getRealTime(); + u32 frame = ((now - ActiveIconStartTime) / Cursors[ActiveIcon].FrameTime) % Cursors[ActiveIcon].Frames.size(); + XDefineCursor(Device->XDisplay, Device->XWindow, Cursors[ActiveIcon].Frames[frame].IconHW); + } +} +#endif + +//! Sets the active cursor icon +void CIrrDeviceLinux::CCursorControl::setActiveIcon(gui::ECURSOR_ICON iconId) +{ +#ifdef _IRR_COMPILE_WITH_X11_ + if (iconId >= (s32)Cursors.size()) + return; + + if (Cursors[iconId].Frames.size()) + XDefineCursor(Device->XDisplay, Device->XWindow, Cursors[iconId].Frames[0].IconHW); + + ActiveIconStartTime = Device->getTimer()->getRealTime(); + ActiveIcon = iconId; +#endif +} + +//! Add a custom sprite as cursor icon. +gui::ECURSOR_ICON CIrrDeviceLinux::CCursorControl::addIcon(const gui::SCursorSprite &icon) +{ +#ifdef _IRR_COMPILE_WITH_X11_ + if (icon.SpriteId >= 0) { + CursorX11 cX11; + cX11.FrameTime = icon.SpriteBank->getSprites()[icon.SpriteId].frameTime; + for (u32 i = 0; i < icon.SpriteBank->getSprites()[icon.SpriteId].Frames.size(); ++i) { + irr::u32 texId = icon.SpriteBank->getSprites()[icon.SpriteId].Frames[i].textureNumber; + irr::u32 rectId = icon.SpriteBank->getSprites()[icon.SpriteId].Frames[i].rectNumber; + irr::core::rect rectIcon = icon.SpriteBank->getPositions()[rectId]; + Cursor cursor = Device->TextureToCursor(icon.SpriteBank->getTexture(texId), rectIcon, icon.HotSpot); + cX11.Frames.push_back(CursorFrameX11(cursor)); + } + + Cursors.push_back(cX11); + + return (gui::ECURSOR_ICON)(Cursors.size() - 1); + } +#endif + return gui::ECI_NORMAL; +} + +//! replace the given cursor icon. +void CIrrDeviceLinux::CCursorControl::changeIcon(gui::ECURSOR_ICON iconId, const gui::SCursorSprite &icon) +{ +#ifdef _IRR_COMPILE_WITH_X11_ + if (iconId >= (s32)Cursors.size()) + return; + + for (u32 i = 0; i < Cursors[iconId].Frames.size(); ++i) + XFreeCursor(Device->XDisplay, Cursors[iconId].Frames[i].IconHW); + + if (icon.SpriteId >= 0) { + CursorX11 cX11; + cX11.FrameTime = icon.SpriteBank->getSprites()[icon.SpriteId].frameTime; + for (u32 i = 0; i < icon.SpriteBank->getSprites()[icon.SpriteId].Frames.size(); ++i) { + irr::u32 texId = icon.SpriteBank->getSprites()[icon.SpriteId].Frames[i].textureNumber; + irr::u32 rectId = icon.SpriteBank->getSprites()[icon.SpriteId].Frames[i].rectNumber; + irr::core::rect rectIcon = icon.SpriteBank->getPositions()[rectId]; + Cursor cursor = Device->TextureToCursor(icon.SpriteBank->getTexture(texId), rectIcon, icon.HotSpot); + cX11.Frames.push_back(CursorFrameX11(cursor)); + } + + Cursors[iconId] = cX11; + } +#endif +} + +irr::core::dimension2di CIrrDeviceLinux::CCursorControl::getSupportedIconSize() const +{ + // this returns the closest match that is smaller or same size, so we just pass a value which should be large enough for cursors + unsigned int width = 0, height = 0; +#ifdef _IRR_COMPILE_WITH_X11_ + XQueryBestCursor(Device->XDisplay, Device->XWindow, 64, 64, &width, &height); +#endif + return core::dimension2di(width, height); +} + +} // end namespace + +#endif // _IRR_COMPILE_WITH_X11_DEVICE_ diff --git a/irr/src/CIrrDeviceLinux.h b/irr/src/CIrrDeviceLinux.h new file mode 100644 index 000000000..4aac1cf6c --- /dev/null +++ b/irr/src/CIrrDeviceLinux.h @@ -0,0 +1,469 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#ifdef _IRR_COMPILE_WITH_X11_DEVICE_ + +#include "CIrrDeviceStub.h" +#include "IrrlichtDevice.h" +#include "ICursorControl.h" +#include "os.h" + +#ifdef _IRR_COMPILE_WITH_X11_ + +#include +#include +#include +#include + +#ifdef _IRR_LINUX_X11_XINPUT2_ +#include +#endif + +#else +#define KeySym s32 +#endif + +namespace irr +{ + +class CIrrDeviceLinux : public CIrrDeviceStub +{ +public: + //! constructor + CIrrDeviceLinux(const SIrrlichtCreationParameters ¶m); + + //! destructor + virtual ~CIrrDeviceLinux(); + + //! runs the device. Returns false if device wants to be deleted + bool run() override; + + //! Cause the device to temporarily pause execution and let other processes to run + // This should bring down processor usage without major performance loss for Irrlicht + void yield() override; + + //! Pause execution and let other processes to run for a specified amount of time. + void sleep(u32 timeMs, bool pauseTimer) override; + + //! sets the caption of the window + void setWindowCaption(const wchar_t *text) override; + + //! Sets the window icon. + bool setWindowIcon(const video::IImage *img) override; + + //! returns if window is active. if not, nothing need to be drawn + bool isWindowActive() const override; + + //! returns if window has focus. + bool isWindowFocused() const override; + + //! returns if window is minimized. + bool isWindowMinimized() const override; + + //! returns last state from maximizeWindow() and restoreWindow() + bool isWindowMaximized() const override; + + //! returns color format of the window. + video::ECOLOR_FORMAT getColorFormat() const override; + + //! notifies the device that it should close itself + void closeDevice() override; + + //! Sets if the window should be resizable in windowed mode. + void setResizable(bool resize = false) override; + + //! Resize the render window. + void setWindowSize(const irr::core::dimension2d &size) override; + + //! Minimizes the window. + void minimizeWindow() override; + + //! Maximizes the window. + void maximizeWindow() override; + + //! Restores the window size. + void restoreWindow() override; + + //! Get the position of this window on screen + core::position2di getWindowPosition() override; + + //! Activate any joysticks, and generate events for them. + bool activateJoysticks(core::array &joystickInfo) override; + + //! gets text from the clipboard + //! \return Returns 0 if no string is in there, otherwise utf-8 text. + virtual const c8 *getTextFromClipboard() const; + + //! gets text from the primary selection + //! \return Returns 0 if no string is in there, otherwise utf-8 text. + virtual const c8 *getTextFromPrimarySelection() const; + + //! copies text to the clipboard + //! This sets the clipboard selection and _not_ the primary selection. + //! @param text The text in utf-8 + virtual void copyToClipboard(const c8 *text) const; + + //! copies text to the primary selection + //! This sets the primary selection which you have on X on the middle mouse button. + //! @param text The text in utf-8 + virtual void copyToPrimarySelection(const c8 *text) const; + + //! Remove all messages pending in the system message loop + void clearSystemMessages() override; + + //! Get the device type + E_DEVICE_TYPE getType() const override + { + return EIDT_X11; + } + + //! Get the display density in dots per inch. + float getDisplayDensity() const override; + +#ifdef _IRR_COMPILE_WITH_X11_ + // convert an Irrlicht texture to a X11 cursor + Cursor TextureToCursor(irr::video::ITexture *tex, const core::rect &sourceRect, const core::position2d &hotspot); + Cursor TextureToMonochromeCursor(irr::video::ITexture *tex, const core::rect &sourceRect, const core::position2d &hotspot); +#ifdef _IRR_LINUX_XCURSOR_ + Cursor TextureToARGBCursor(irr::video::ITexture *tex, const core::rect &sourceRect, const core::position2d &hotspot); +#endif +#endif + +private: + //! create the driver + void createDriver(); + + bool createWindow(); + + void createKeyMap(); + + void pollJoysticks(); + + void initXAtoms(); + + void initXInput2(); + + bool switchToFullscreen(); + + void setupTopLevelXorgWindow(); + +#ifdef _IRR_COMPILE_WITH_X11_ + bool createInputContext(); + void destroyInputContext(); + EKEY_CODE getKeyCode(XEvent &event); + + const c8 *getTextFromSelection(Atom selection, core::stringc &text_buffer) const; + bool becomeSelectionOwner(Atom selection) const; +#endif + + //! Implementation of the linux cursor control + class CCursorControl : public gui::ICursorControl + { + public: + CCursorControl(CIrrDeviceLinux *dev, bool null); + + ~CCursorControl(); + + //! Changes the visible state of the mouse cursor. + void setVisible(bool visible) override + { + if (visible == IsVisible) + return; + IsVisible = visible; +#ifdef _IRR_COMPILE_WITH_X11_ + if (!Null) { + if (!IsVisible) + XDefineCursor(Device->XDisplay, Device->XWindow, InvisCursor); + else + XUndefineCursor(Device->XDisplay, Device->XWindow); + } +#endif + } + + //! Returns if the cursor is currently visible. + bool isVisible() const override + { + return IsVisible; + } + + //! Sets the new position of the cursor. + void setPosition(const core::position2d &pos) override + { + setPosition(pos.X, pos.Y); + } + + //! Sets the new position of the cursor. + void setPosition(f32 x, f32 y) override + { + setPosition((s32)(x * Device->Width), (s32)(y * Device->Height)); + } + + //! Sets the new position of the cursor. + void setPosition(const core::position2d &pos) override + { + setPosition(pos.X, pos.Y); + } + + //! Sets the new position of the cursor. + void setPosition(s32 x, s32 y) override + { +#ifdef _IRR_COMPILE_WITH_X11_ + + if (!Null) { + if (UseReferenceRect) { +// NOTE: XIWarpPointer works when X11 has set a coordinate transformation matrix for the mouse unlike XWarpPointer +// which runs into a bug mentioned here: https://gitlab.freedesktop.org/xorg/xserver/-/issues/600 +// So also workaround for Irrlicht bug #450 +#ifdef _IRR_LINUX_X11_XINPUT2_ + if (DeviceId != 0) { + XIWarpPointer(Device->XDisplay, + DeviceId, + None, + Device->XWindow, 0, 0, + Device->Width, + Device->Height, + ReferenceRect.UpperLeftCorner.X + x, + ReferenceRect.UpperLeftCorner.Y + y); + } else +#endif + { + XWarpPointer(Device->XDisplay, + None, + Device->XWindow, 0, 0, + Device->Width, + Device->Height, + ReferenceRect.UpperLeftCorner.X + x, + ReferenceRect.UpperLeftCorner.Y + y); + } + } else { +#ifdef _IRR_LINUX_X11_XINPUT2_ + if (DeviceId != 0) { + XIWarpPointer(Device->XDisplay, + DeviceId, + None, + Device->XWindow, 0, 0, + Device->Width, + Device->Height, x, y); + } else +#endif + { + XWarpPointer(Device->XDisplay, + None, + Device->XWindow, 0, 0, + Device->Width, + Device->Height, x, y); + } + } + XFlush(Device->XDisplay); + } +#endif + CursorPos.X = x; + CursorPos.Y = y; + } + + //! Returns the current position of the mouse cursor. + const core::position2d &getPosition(bool updateCursor) override + { + if (updateCursor) + updateCursorPos(); + return CursorPos; + } + + //! Returns the current position of the mouse cursor. + core::position2d getRelativePosition(bool updateCursor) override + { + if (updateCursor) + updateCursorPos(); + + if (!UseReferenceRect) { + return core::position2d(CursorPos.X / (f32)Device->Width, + CursorPos.Y / (f32)Device->Height); + } + + return core::position2d(CursorPos.X / (f32)ReferenceRect.getWidth(), + CursorPos.Y / (f32)ReferenceRect.getHeight()); + } + + void setReferenceRect(core::rect *rect = 0) override + { + if (rect) { + ReferenceRect = *rect; + UseReferenceRect = true; + + // prevent division through zero and uneven sizes + + if (!ReferenceRect.getHeight() || ReferenceRect.getHeight() % 2) + ReferenceRect.LowerRightCorner.Y += 1; + + if (!ReferenceRect.getWidth() || ReferenceRect.getWidth() % 2) + ReferenceRect.LowerRightCorner.X += 1; + } else + UseReferenceRect = false; + } + + //! Sets the active cursor icon + void setActiveIcon(gui::ECURSOR_ICON iconId) override; + + //! Gets the currently active icon + gui::ECURSOR_ICON getActiveIcon() const override + { + return ActiveIcon; + } + + //! Add a custom sprite as cursor icon. + gui::ECURSOR_ICON addIcon(const gui::SCursorSprite &icon) override; + + //! replace the given cursor icon. + void changeIcon(gui::ECURSOR_ICON iconId, const gui::SCursorSprite &icon) override; + + //! Return a system-specific size which is supported for cursors. Larger icons will fail, smaller icons might work. + core::dimension2di getSupportedIconSize() const override; + +#ifdef _IRR_COMPILE_WITH_X11_ + //! Set platform specific behavior flags. + void setPlatformBehavior(gui::ECURSOR_PLATFORM_BEHAVIOR behavior) override { PlatformBehavior = behavior; } + + //! Return platform specific behavior. + gui::ECURSOR_PLATFORM_BEHAVIOR getPlatformBehavior() const override { return PlatformBehavior; } + + void update(); + void clearCursors(); +#endif + private: + void updateCursorPos() + { +#ifdef _IRR_COMPILE_WITH_X11_ + if (Null) + return; + + if (PlatformBehavior & gui::ECPB_X11_CACHE_UPDATES && !os::Timer::isStopped()) { + u32 now = os::Timer::getTime(); + if (now <= LastQuery) + return; + LastQuery = now; + } + + Window tmp; + int itmp1, itmp2; + unsigned int maskreturn; + XQueryPointer(Device->XDisplay, Device->XWindow, + &tmp, &tmp, + &itmp1, &itmp2, + &CursorPos.X, &CursorPos.Y, &maskreturn); +#endif + } + + CIrrDeviceLinux *Device; + core::position2d CursorPos; + core::rect ReferenceRect; +#ifdef _IRR_COMPILE_WITH_X11_ + gui::ECURSOR_PLATFORM_BEHAVIOR PlatformBehavior; + u32 LastQuery; + Cursor InvisCursor; + +#ifdef _IRR_LINUX_X11_XINPUT2_ + int DeviceId; +#endif + + struct CursorFrameX11 + { + CursorFrameX11() : + IconHW(0) {} + CursorFrameX11(Cursor icon) : + IconHW(icon) {} + + Cursor IconHW; // hardware cursor + }; + + struct CursorX11 + { + CursorX11() {} + explicit CursorX11(Cursor iconHw, u32 frameTime = 0) : + FrameTime(frameTime) + { + Frames.push_back(CursorFrameX11(iconHw)); + } + core::array Frames; + u32 FrameTime; + }; + + core::array Cursors; + + void initCursors(); +#endif + bool IsVisible; + bool Null; + bool UseReferenceRect; + gui::ECURSOR_ICON ActiveIcon; + u32 ActiveIconStartTime; + }; + + friend class CCursorControl; + +#ifdef _IRR_COMPILE_WITH_X11_ + friend class COpenGLDriver; + + Display *XDisplay; + XVisualInfo *VisualInfo; + int Screennr; + Window XWindow; + XSetWindowAttributes WndAttributes; + XSizeHints *StdHints; + XIM XInputMethod; + XIC XInputContext; + bool HasNetWM; + // text is utf-8 + mutable core::stringc Clipboard; + mutable core::stringc PrimarySelection; +#endif +#if defined(_IRR_LINUX_X11_XINPUT2_) + int currentTouchedCount; +#endif + u32 Width, Height; + bool WindowHasFocus; + bool WindowMinimized; + bool WindowMaximized; + bool ExternalWindow; + int AutorepeatSupport; + + struct SKeyMap + { + SKeyMap() {} + SKeyMap(s32 x11, s32 win32) : + X11Key(x11), Win32Key(win32) + { + } + + KeySym X11Key; + s32 Win32Key; + + bool operator<(const SKeyMap &o) const + { + return X11Key < o.X11Key; + } + }; + + core::array KeyMap; + +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) + struct JoystickInfo + { + int fd; + int axes; + int buttons; + + SEvent persistentData; + + JoystickInfo() : + fd(-1), axes(0), buttons(0) {} + }; + core::array ActiveJoysticks; +#endif +}; + +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_X11_DEVICE_ diff --git a/irr/src/CIrrDeviceOSX.h b/irr/src/CIrrDeviceOSX.h new file mode 100644 index 000000000..f4f159aa2 --- /dev/null +++ b/irr/src/CIrrDeviceOSX.h @@ -0,0 +1,238 @@ +// Copyright (C) 2005-2006 Etienne Petitjean +// Copyright (C) 2007-2012 Christian Stehno +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#pragma once + +#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ + +#include "CIrrDeviceStub.h" +#include "IrrlichtDevice.h" +#include "IGUIEnvironment.h" +#include "ICursorControl.h" + +#import +#import + +#include + +namespace irr +{ +class CIrrDeviceMacOSX; +} + +@interface CIrrDelegateOSX : NSObject + +- (id)initWithDevice:(irr::CIrrDeviceMacOSX *)device; +- (void)terminate:(id)sender; +- (BOOL)isQuit; + +@end + +namespace irr +{ +class CIrrDeviceMacOSX : public CIrrDeviceStub +{ +public: + //! constructor + CIrrDeviceMacOSX(const SIrrlichtCreationParameters ¶ms); + + //! destructor + virtual ~CIrrDeviceMacOSX(); + + //! runs the device. Returns false if device wants to be deleted + bool run() override; + + //! Cause the device to temporarily pause execution and let other processes to run + // This should bring down processor usage without major performance loss for Irrlicht + void yield() override; + + //! Pause execution and let other processes to run for a specified amount of time. + void sleep(u32 timeMs, bool pauseTimer) override; + + //! sets the caption of the window + void setWindowCaption(const wchar_t *text) override; + + //! returns if window is active. if not, nothing need to be drawn + bool isWindowActive() const override; + + //! Checks if the Irrlicht window has focus + bool isWindowFocused() const override; + + //! Checks if the Irrlicht window is minimized + bool isWindowMinimized() const override; + + //! notifies the device that it should close itself + void closeDevice() override; + + //! Sets if the window should be resizable in windowed mode. + void setResizable(bool resize) override; + + //! Returns true if the window is resizable, false if not + virtual bool isResizable() const; + + //! Minimizes the window if possible + void minimizeWindow() override; + + //! Maximizes the window if possible. + void maximizeWindow() override; + + //! Restore the window to normal size if possible. + void restoreWindow() override; + + //! Get the position of this window on screen + core::position2di getWindowPosition() override; + + //! Activate any joysticks, and generate events for them. + bool activateJoysticks(core::array &joystickInfo) override; + + //! Get the device type + E_DEVICE_TYPE getType() const override + { + return EIDT_OSX; + } + + void setMouseLocation(int x, int y); + void setResize(int width, int height); + void setCursorVisible(bool visible); + void setWindow(NSWindow *window); + +private: + //! create the driver + void createDriver(); + + //! Implementation of the macos x cursor control + class CCursorControl : public gui::ICursorControl + { + public: + CCursorControl(const core::dimension2d &wsize, CIrrDeviceMacOSX *device) : + WindowSize(wsize), InvWindowSize(0.0f, 0.0f), Device(device), IsVisible(true), UseReferenceRect(false) + { + CursorPos.X = CursorPos.Y = 0; + if (WindowSize.Width != 0) + InvWindowSize.Width = 1.0f / WindowSize.Width; + if (WindowSize.Height != 0) + InvWindowSize.Height = 1.0f / WindowSize.Height; + } + + //! Changes the visible state of the mouse cursor. + void setVisible(bool visible) override + { + IsVisible = visible; + Device->setCursorVisible(visible); + } + + //! Returns if the cursor is currently visible. + bool isVisible() const override + { + return IsVisible; + } + + //! Sets the new position of the cursor. + void setPosition(const core::position2d &pos) override + { + setPosition(pos.X, pos.Y); + } + + //! Sets the new position of the cursor. + void setPosition(f32 x, f32 y) override + { + setPosition((s32)(x * WindowSize.Width), (s32)(y * WindowSize.Height)); + } + + //! Sets the new position of the cursor. + void setPosition(const core::position2d &pos) override + { + if (CursorPos.X != pos.X || CursorPos.Y != pos.Y) + setPosition(pos.X, pos.Y); + } + + //! Sets the new position of the cursor. + void setPosition(s32 x, s32 y) override + { + if (UseReferenceRect) { + Device->setMouseLocation(ReferenceRect.UpperLeftCorner.X + x, ReferenceRect.UpperLeftCorner.Y + y); + } else { + Device->setMouseLocation(x, y); + } + } + + //! Returns the current position of the mouse cursor. + const core::position2d &getPosition(bool updateCursor) override + { + return CursorPos; + } + + //! Returns the current position of the mouse cursor. + core::position2d getRelativePosition(bool updateCursor) override + { + if (!UseReferenceRect) { + return core::position2d(CursorPos.X * InvWindowSize.Width, + CursorPos.Y * InvWindowSize.Height); + } + + return core::position2d(CursorPos.X / (f32)ReferenceRect.getWidth(), + CursorPos.Y / (f32)ReferenceRect.getHeight()); + } + + //! Sets an absolute reference rect for calculating the cursor position. + void setReferenceRect(core::rect *rect = 0) override + { + if (rect) { + ReferenceRect = *rect; + UseReferenceRect = true; + + // prevent division through zero and uneven sizes + + if (!ReferenceRect.getHeight() || ReferenceRect.getHeight() % 2) + ReferenceRect.LowerRightCorner.Y += 1; + + if (!ReferenceRect.getWidth() || ReferenceRect.getWidth() % 2) + ReferenceRect.LowerRightCorner.X += 1; + } else + UseReferenceRect = false; + } + + //! Updates the internal cursor position + void updateInternalCursorPosition(int x, int y) + { + CursorPos.X = x; + CursorPos.Y = y; + } + + private: + core::position2d CursorPos; + core::dimension2d WindowSize; + core::dimension2d InvWindowSize; + core::rect ReferenceRect; + CIrrDeviceMacOSX *Device; + bool IsVisible; + bool UseReferenceRect; + }; + + bool createWindow(); + void initKeycodes(); + void storeMouseLocation(); + void postMouseEvent(void *event, irr::SEvent &ievent); + void postKeyEvent(void *event, irr::SEvent &ievent, bool pressed); + void pollJoysticks(); + + NSWindow *Window; + CGDirectDisplayID Display; + std::map KeyCodes; + int DeviceWidth; + int DeviceHeight; + int ScreenWidth; + int ScreenHeight; + u32 MouseButtonStates; + bool IsFullscreen; + bool IsActive; + bool IsShiftDown; + bool IsControlDown; + bool IsResizable; +}; + +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_OSX_DEVICE_ diff --git a/irr/src/CIrrDeviceOSX.mm b/irr/src/CIrrDeviceOSX.mm new file mode 100644 index 000000000..8e4843441 --- /dev/null +++ b/irr/src/CIrrDeviceOSX.mm @@ -0,0 +1,1470 @@ +// Copyright (C) 2005-2006 Etienne Petitjean +// Copyright (C) 2007-2012 Christian Stehno +// Copyright (C) 2013-2015 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ + +#import +#import + +#include "CIrrDeviceOSX.h" + +#include "IEventReceiver.h" +#include "os.h" +#include "CTimer.h" +#include "irrString.h" +#include "Keycodes.h" +#include +#include +#include "COSOperator.h" +#include "CColorConverter.h" +#include "irrlicht.h" +#include + +#include +#include + +#include "CNSOGLManager.h" + +#if defined _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ + +#include +#include +#include +#include +#include + +struct JoystickComponent +{ + IOHIDElementCookie cookie; // unique value which identifies element, will NOT change + long min; // reported min value possible + long max; // reported max value possible + + long minRead; // min read value + long maxRead; // max read value + + JoystickComponent() : + min(0), minRead(0), max(0), maxRead(0) + { + } +}; + +struct JoystickInfo +{ + irr::core::array axisComp; + irr::core::array buttonComp; + irr::core::array hatComp; + + int hats; + int axes; + int buttons; + int numActiveJoysticks; + + irr::SEvent persistentData; + + IOHIDDeviceInterface **interface; + bool removed; + char joystickName[256]; + long usage; // usage page from IOUSBHID Parser.h which defines general usage + long usagePage; // usage within above page from IOUSBHID Parser.h which defines specific usage + + JoystickInfo() : + hats(0), axes(0), buttons(0), interface(0), removed(false), usage(0), usagePage(0), numActiveJoysticks(0) + { + interface = NULL; + memset(joystickName, '\0', 256); + axisComp.clear(); + buttonComp.clear(); + hatComp.clear(); + + persistentData.EventType = irr::EET_JOYSTICK_INPUT_EVENT; + persistentData.JoystickEvent.POV = 65535; + persistentData.JoystickEvent.ButtonStates = 0; + } +}; +irr::core::array ActiveJoysticks; + +// helper functions for init joystick +static IOReturn closeJoystickDevice(JoystickInfo *joyInfo) +{ + IOReturn result = kIOReturnSuccess; + if (joyInfo && joyInfo->interface) { + /* close the interface */ + result = (*(joyInfo->interface))->close(joyInfo->interface); + if (kIOReturnNotOpen == result) { + /* do nothing as device was not opened, thus can't be closed */ + } else if (kIOReturnSuccess != result) + irr::os::Printer::log("IOHIDDeviceInterface failed to close", irr::ELL_ERROR); + /* release the interface */ + result = (*(joyInfo->interface))->Release(joyInfo->interface); + if (kIOReturnSuccess != result) + irr::os::Printer::log("IOHIDDeviceInterface failed to release", irr::ELL_ERROR); + joyInfo->interface = NULL; + } + return result; +} + +static void addComponentInfo(CFTypeRef refElement, JoystickComponent *pComponent, int numActiveJoysticks) +{ + long number; + CFTypeRef refType; + + refType = CFDictionaryGetValue((CFDictionaryRef)refElement, CFSTR(kIOHIDElementCookieKey)); + if (refType && CFNumberGetValue((CFNumberRef)refType, kCFNumberLongType, &number)) + pComponent->cookie = (IOHIDElementCookie)number; + refType = CFDictionaryGetValue((CFDictionaryRef)refElement, CFSTR(kIOHIDElementMinKey)); + if (refType && CFNumberGetValue((CFNumberRef)refType, kCFNumberLongType, &number)) + pComponent->minRead = pComponent->min = number; + refType = CFDictionaryGetValue((CFDictionaryRef)refElement, CFSTR(kIOHIDElementMaxKey)); + if (refType && CFNumberGetValue((CFNumberRef)refType, kCFNumberLongType, &number)) + pComponent->maxRead = pComponent->max = number; +} + +static void getJoystickComponentArrayHandler(const void *value, void *parameter); + +static void addJoystickComponent(CFTypeRef refElement, JoystickInfo *joyInfo) +{ + long elementType, usagePage, usage; + CFTypeRef refElementType = CFDictionaryGetValue((CFDictionaryRef)refElement, CFSTR(kIOHIDElementTypeKey)); + CFTypeRef refUsagePage = CFDictionaryGetValue((CFDictionaryRef)refElement, CFSTR(kIOHIDElementUsagePageKey)); + CFTypeRef refUsage = CFDictionaryGetValue((CFDictionaryRef)refElement, CFSTR(kIOHIDElementUsageKey)); + + if ((refElementType) && (CFNumberGetValue((CFNumberRef)refElementType, kCFNumberLongType, &elementType))) { + /* look at types of interest */ + if ((elementType == kIOHIDElementTypeInput_Misc) || (elementType == kIOHIDElementTypeInput_Button) || + (elementType == kIOHIDElementTypeInput_Axis)) { + if (refUsagePage && CFNumberGetValue((CFNumberRef)refUsagePage, kCFNumberLongType, &usagePage) && + refUsage && CFNumberGetValue((CFNumberRef)refUsage, kCFNumberLongType, &usage)) { + switch (usagePage) /* only interested in kHIDPage_GenericDesktop and kHIDPage_Button */ + { + case kHIDPage_GenericDesktop: { + switch (usage) /* look at usage to determine function */ + { + case kHIDUsage_GD_X: + case kHIDUsage_GD_Y: + case kHIDUsage_GD_Z: + case kHIDUsage_GD_Rx: + case kHIDUsage_GD_Ry: + case kHIDUsage_GD_Rz: + case kHIDUsage_GD_Slider: + case kHIDUsage_GD_Dial: + case kHIDUsage_GD_Wheel: { + joyInfo->axes++; + JoystickComponent newComponent; + addComponentInfo(refElement, &newComponent, joyInfo->numActiveJoysticks); + joyInfo->axisComp.push_back(newComponent); + } break; + case kHIDUsage_GD_Hatswitch: { + joyInfo->hats++; + JoystickComponent newComponent; + addComponentInfo(refElement, &newComponent, joyInfo->numActiveJoysticks); + joyInfo->hatComp.push_back(newComponent); + } break; + } + } break; + case kHIDPage_Button: { + joyInfo->buttons++; + JoystickComponent newComponent; + addComponentInfo(refElement, &newComponent, joyInfo->numActiveJoysticks); + joyInfo->buttonComp.push_back(newComponent); + } break; + default: + break; + } + } + } else if (kIOHIDElementTypeCollection == elementType) { + // get elements + CFTypeRef refElementTop = CFDictionaryGetValue((CFMutableDictionaryRef)refElement, CFSTR(kIOHIDElementKey)); + if (refElementTop) { + CFTypeID type = CFGetTypeID(refElementTop); + if (type == CFArrayGetTypeID()) { + CFRange range = {0, CFArrayGetCount((CFArrayRef)refElementTop)}; + CFArrayApplyFunction((CFArrayRef)refElementTop, range, getJoystickComponentArrayHandler, joyInfo); + } + } + } + } +} + +static void getJoystickComponentArrayHandler(const void *value, void *parameter) +{ + if (CFGetTypeID(value) == CFDictionaryGetTypeID()) + addJoystickComponent((CFTypeRef)value, (JoystickInfo *)parameter); +} + +static void joystickTopLevelElementHandler(const void *value, void *parameter) +{ + CFTypeRef refCF = 0; + if (CFGetTypeID(value) != CFDictionaryGetTypeID()) + return; + refCF = CFDictionaryGetValue((CFDictionaryRef)value, CFSTR(kIOHIDElementUsagePageKey)); + if (!CFNumberGetValue((CFNumberRef)refCF, kCFNumberLongType, &((JoystickInfo *)parameter)->usagePage)) + irr::os::Printer::log("CFNumberGetValue error retrieving JoystickInfo->usagePage", irr::ELL_ERROR); + refCF = CFDictionaryGetValue((CFDictionaryRef)value, CFSTR(kIOHIDElementUsageKey)); + if (!CFNumberGetValue((CFNumberRef)refCF, kCFNumberLongType, &((JoystickInfo *)parameter)->usage)) + irr::os::Printer::log("CFNumberGetValue error retrieving JoystickInfo->usage", irr::ELL_ERROR); +} + +static void getJoystickDeviceInfo(io_object_t hidDevice, CFMutableDictionaryRef hidProperties, JoystickInfo *joyInfo) +{ + CFMutableDictionaryRef usbProperties = 0; + io_registry_entry_t parent1, parent2; + + /* Mac OS X currently is not mirroring all USB properties to HID page so need to look at USB device page also + * get dictionary for usb properties: step up two levels and get CF dictionary for USB properties + */ + if ((KERN_SUCCESS == IORegistryEntryGetParentEntry(hidDevice, kIOServicePlane, &parent1)) && + (KERN_SUCCESS == IORegistryEntryGetParentEntry(parent1, kIOServicePlane, &parent2)) && + (KERN_SUCCESS == IORegistryEntryCreateCFProperties(parent2, &usbProperties, kCFAllocatorDefault, kNilOptions))) { + if (usbProperties) { + CFTypeRef refCF = 0; + /* get device info + * try hid dictionary first, if fail then go to usb dictionary + */ + + /* get joystickName name */ + refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey)); + if (!refCF) + refCF = CFDictionaryGetValue(usbProperties, CFSTR("USB Product Name")); + if (refCF) { + if (!CFStringGetCString((CFStringRef)refCF, joyInfo->joystickName, 256, CFStringGetSystemEncoding())) + irr::os::Printer::log("CFStringGetCString error getting joyInfo->joystickName", irr::ELL_ERROR); + } + + /* get usage page and usage */ + refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDPrimaryUsagePageKey)); + if (refCF) { + if (!CFNumberGetValue((CFNumberRef)refCF, kCFNumberLongType, &joyInfo->usagePage)) + irr::os::Printer::log("CFNumberGetValue error getting joyInfo->usagePage", irr::ELL_ERROR); + refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDPrimaryUsageKey)); + if (refCF) + if (!CFNumberGetValue((CFNumberRef)refCF, kCFNumberLongType, &joyInfo->usage)) + irr::os::Printer::log("CFNumberGetValue error getting joyInfo->usage", irr::ELL_ERROR); + } + + if (NULL == refCF) /* get top level element HID usage page or usage */ + { + /* use top level element instead */ + CFTypeRef refCFTopElement = 0; + refCFTopElement = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDElementKey)); + { + /* refCFTopElement points to an array of element dictionaries */ + CFRange range = {0, CFArrayGetCount((CFArrayRef)refCFTopElement)}; + CFArrayApplyFunction((CFArrayRef)refCFTopElement, range, joystickTopLevelElementHandler, joyInfo); + } + } + + CFRelease(usbProperties); + } else + irr::os::Printer::log("IORegistryEntryCreateCFProperties failed to create usbProperties", irr::ELL_ERROR); + + if (kIOReturnSuccess != IOObjectRelease(parent2)) + irr::os::Printer::log("IOObjectRelease failed to release parent2", irr::ELL_ERROR); + if (kIOReturnSuccess != IOObjectRelease(parent1)) + irr::os::Printer::log("IOObjectRelease failed to release parent1", irr::ELL_ERROR); + } +} + +#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ + +// Contents from Events.h from Carbon/HIToolbox but we need it with Cocoa too +// and for some reason no Cocoa equivalent of these constants seems provided. +// So I'm doing like everyone else and using copy-and-paste. + +/* + * Summary: + * Virtual keycodes + * + * Discussion: + * These constants are the virtual keycodes defined originally in + * Inside Mac Volume V, pg. V-191. They identify physical keys on a + * keyboard. Those constants with "ANSI" in the name are labeled + * according to the key position on an ANSI-standard US keyboard. + * For example, kVK_ANSI_A indicates the virtual keycode for the key + * with the letter 'A' in the US keyboard layout. Other keyboard + * layouts may have the 'A' key label on a different physical key; + * in this case, pressing 'A' will generate a different virtual + * keycode. + */ +enum +{ + kVK_ANSI_A = 0x00, + kVK_ANSI_S = 0x01, + kVK_ANSI_D = 0x02, + kVK_ANSI_F = 0x03, + kVK_ANSI_H = 0x04, + kVK_ANSI_G = 0x05, + kVK_ANSI_Z = 0x06, + kVK_ANSI_X = 0x07, + kVK_ANSI_C = 0x08, + kVK_ANSI_V = 0x09, + kVK_ANSI_B = 0x0B, + kVK_ANSI_Q = 0x0C, + kVK_ANSI_W = 0x0D, + kVK_ANSI_E = 0x0E, + kVK_ANSI_R = 0x0F, + kVK_ANSI_Y = 0x10, + kVK_ANSI_T = 0x11, + kVK_ANSI_1 = 0x12, + kVK_ANSI_2 = 0x13, + kVK_ANSI_3 = 0x14, + kVK_ANSI_4 = 0x15, + kVK_ANSI_6 = 0x16, + kVK_ANSI_5 = 0x17, + kVK_ANSI_Equal = 0x18, + kVK_ANSI_9 = 0x19, + kVK_ANSI_7 = 0x1A, + kVK_ANSI_Minus = 0x1B, + kVK_ANSI_8 = 0x1C, + kVK_ANSI_0 = 0x1D, + kVK_ANSI_RightBracket = 0x1E, + kVK_ANSI_O = 0x1F, + kVK_ANSI_U = 0x20, + kVK_ANSI_LeftBracket = 0x21, + kVK_ANSI_I = 0x22, + kVK_ANSI_P = 0x23, + kVK_ANSI_L = 0x25, + kVK_ANSI_J = 0x26, + kVK_ANSI_Quote = 0x27, + kVK_ANSI_K = 0x28, + kVK_ANSI_Semicolon = 0x29, + kVK_ANSI_Backslash = 0x2A, + kVK_ANSI_Comma = 0x2B, + kVK_ANSI_Slash = 0x2C, + kVK_ANSI_N = 0x2D, + kVK_ANSI_M = 0x2E, + kVK_ANSI_Period = 0x2F, + kVK_ANSI_Grave = 0x32, + kVK_ANSI_KeypadDecimal = 0x41, + kVK_ANSI_KeypadMultiply = 0x43, + kVK_ANSI_KeypadPlus = 0x45, + kVK_ANSI_KeypadClear = 0x47, + kVK_ANSI_KeypadDivide = 0x4B, + kVK_ANSI_KeypadEnter = 0x4C, + kVK_ANSI_KeypadMinus = 0x4E, + kVK_ANSI_KeypadEquals = 0x51, + kVK_ANSI_Keypad0 = 0x52, + kVK_ANSI_Keypad1 = 0x53, + kVK_ANSI_Keypad2 = 0x54, + kVK_ANSI_Keypad3 = 0x55, + kVK_ANSI_Keypad4 = 0x56, + kVK_ANSI_Keypad5 = 0x57, + kVK_ANSI_Keypad6 = 0x58, + kVK_ANSI_Keypad7 = 0x59, + kVK_ANSI_Keypad8 = 0x5B, + kVK_ANSI_Keypad9 = 0x5C +}; + +/* keycodes for keys that are independent of keyboard layout*/ +enum +{ + kVK_Return = 0x24, + kVK_Tab = 0x30, + kVK_Space = 0x31, + kVK_Delete = 0x33, + kVK_Escape = 0x35, + kVK_Command = 0x37, + kVK_Shift = 0x38, + kVK_CapsLock = 0x39, + kVK_Option = 0x3A, + kVK_Control = 0x3B, + kVK_RightShift = 0x3C, + kVK_RightOption = 0x3D, + kVK_RightControl = 0x3E, + kVK_Function = 0x3F, + kVK_F17 = 0x40, + kVK_VolumeUp = 0x48, + kVK_VolumeDown = 0x49, + kVK_Mute = 0x4A, + kVK_F18 = 0x4F, + kVK_F19 = 0x50, + kVK_F20 = 0x5A, + kVK_F5 = 0x60, + kVK_F6 = 0x61, + kVK_F7 = 0x62, + kVK_F3 = 0x63, + kVK_F8 = 0x64, + kVK_F9 = 0x65, + kVK_F11 = 0x67, + kVK_F13 = 0x69, + kVK_F16 = 0x6A, + kVK_F14 = 0x6B, + kVK_F10 = 0x6D, + kVK_F12 = 0x6F, + kVK_F15 = 0x71, + kVK_Help = 0x72, + kVK_Home = 0x73, + kVK_PageUp = 0x74, + kVK_ForwardDelete = 0x75, + kVK_F4 = 0x76, + kVK_End = 0x77, + kVK_F2 = 0x78, + kVK_PageDown = 0x79, + kVK_F1 = 0x7A, + kVK_LeftArrow = 0x7B, + kVK_RightArrow = 0x7C, + kVK_DownArrow = 0x7D, + kVK_UpArrow = 0x7E +}; + +//------------------------------------------------------------------------------------------ +Boolean GetDictionaryBoolean(CFDictionaryRef theDict, const void *key) +{ + // get a boolean from the dictionary + Boolean value = false; + CFBooleanRef boolRef; + boolRef = (CFBooleanRef)CFDictionaryGetValue(theDict, key); + if (boolRef != NULL) + value = CFBooleanGetValue(boolRef); + return value; +} +//------------------------------------------------------------------------------------------ +long GetDictionaryLong(CFDictionaryRef theDict, const void *key) +{ + // get a long from the dictionary + long value = 0; + CFNumberRef numRef; + numRef = (CFNumberRef)CFDictionaryGetValue(theDict, key); + if (numRef != NULL) + CFNumberGetValue(numRef, kCFNumberLongType, &value); + return value; +} + +namespace irr +{ +namespace video +{ +IVideoDriver *createOpenGLDriver(const SIrrlichtCreationParameters ¶m, io::IFileSystem *io, IContextManager *contextManager); +} +} // end namespace irr + +static bool firstLaunch = true; + +@implementation CIrrDelegateOSX { + irr::CIrrDeviceMacOSX *Device; + bool Quit; +} + +- (id)initWithDevice:(irr::CIrrDeviceMacOSX *)device +{ + self = [super init]; + + if (self) + Device = device; + + Quit = false; + + return (self); +} + +- (void)applicationDidFinishLaunching:(NSNotification *)notification +{ + Quit = false; +} + +- (void)orderFrontStandardAboutPanel:(id)sender +{ + [NSApp orderFrontStandardAboutPanel:sender]; +} + +- (void)unhideAllApplications:(id)sender +{ + [NSApp unhideAllApplications:sender]; +} + +- (void)hide:(id)sender +{ + [NSApp hide:sender]; +} + +- (void)hideOtherApplications:(id)sender +{ + [NSApp hideOtherApplications:sender]; +} + +- (void)terminate:(id)sender +{ + Quit = true; +} + +- (void)windowWillClose:(id)sender +{ + Device->setWindow(nil); + Quit = true; +} + +- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize +{ + if (Device->isResizable()) + return proposedFrameSize; + else + return [window frame].size; +} + +- (void)windowDidResize:(NSNotification *)aNotification +{ + NSWindow *window; + NSRect frame; + + window = [aNotification object]; + frame = [window frame]; + Device->setResize((int)frame.size.width, (int)frame.size.height); +} + +- (BOOL)isQuit +{ + return (Quit); +} + +@end + +namespace irr +{ +//! constructor +CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters ¶m) : + CIrrDeviceStub(param), Window(NULL), Display(NULL), + DeviceWidth(0), DeviceHeight(0), + ScreenWidth(0), ScreenHeight(0), MouseButtonStates(0), + IsActive(true), IsFullscreen(false), IsShiftDown(false), IsControlDown(false), IsResizable(false) +{ + struct utsname name; + +#ifdef _DEBUG + setDebugName("CIrrDeviceMacOSX"); +#endif + + if (firstLaunch) { + firstLaunch = false; + + if (!CreationParams.WindowId) { + [[NSAutoreleasePool alloc] init]; + [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; + [[NSApplication sharedApplication] setDelegate:[[[CIrrDelegateOSX alloc] initWithDevice:this] autorelease]]; + + // Create menu + + NSString *bundleName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]; + if (bundleName == nil) + bundleName = @"Irrlicht"; + + NSMenu *mainMenu = [[[NSMenu alloc] initWithTitle:@"MainMenu"] autorelease]; + NSMenu *menu = [[[NSMenu alloc] initWithTitle:bundleName] autorelease]; + NSMenuItem *menuItem = [mainMenu addItemWithTitle:bundleName action:nil keyEquivalent:@""]; + [mainMenu setSubmenu:menu forItem:menuItem]; + menuItem = [menu addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"]; + [menuItem setKeyEquivalentModifierMask:NSCommandKeyMask]; + + [NSApp setMainMenu:mainMenu]; + + [NSApp finishLaunching]; + } + + NSString *path = [[NSBundle mainBundle] bundlePath]; + if (path != nil) { + path = [path stringByAppendingString:@"/Contents/Resources"]; + chdir([path fileSystemRepresentation]); + [path release]; + } + } + + uname(&name); + Operator = new COSOperator(name.version); + os::Printer::log(name.version, ELL_INFORMATION); + + initKeycodes(); + + bool success = true; + + if (CreationParams.DriverType != video::EDT_NULL) + success = createWindow(); + + // in case of failure, one can check VideoDriver for initialization + if (!success) + return; + + setResizable(false); + CursorControl = new CCursorControl(CreationParams.WindowSize, this); + + createDriver(); + createGUIAndScene(); +} + +CIrrDeviceMacOSX::~CIrrDeviceMacOSX() +{ + [NSApp setPresentationOptions:(NSApplicationPresentationDefault)]; + closeDevice(); +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) + for (u32 joystick = 0; joystick < ActiveJoysticks.size(); ++joystick) { + if (ActiveJoysticks[joystick].interface) + closeJoystickDevice(&ActiveJoysticks[joystick]); + } +#endif +} + +void CIrrDeviceMacOSX::closeDevice() +{ + if (Window != nil) { + [Window setIsVisible:FALSE]; + [Window setReleasedWhenClosed:TRUE]; + [Window release]; + Window = nil; + } + + IsFullscreen = false; + IsActive = false; +} + +bool CIrrDeviceMacOSX::createWindow() +{ + CGDisplayErr error; + bool result = false; + Display = CGMainDisplayID(); + + CGRect displayRect; + CGDisplayModeRef displaymode, olddisplaymode; + + ScreenWidth = (int)CGDisplayPixelsWide(Display); + ScreenHeight = (int)CGDisplayPixelsHigh(Display); + + const NSBackingStoreType type = (CreationParams.DriverType == video::EDT_OPENGL) ? NSBackingStoreBuffered : NSBackingStoreNonretained; + + // TODO: fullscreen + // if (!CreationParams.Fullscreen) + { + if (!CreationParams.WindowId) { // create another window when WindowId is null + int x = (CreationParams.WindowPosition.X > 0) ? CreationParams.WindowPosition.X : 0; + int y = (CreationParams.WindowPosition.Y > 0) ? CreationParams.WindowPosition.Y : 0; + + if (CreationParams.WindowPosition.Y > -1) { + int screenHeight = [[[NSScreen screens] objectAtIndex:0] frame].size.height; + y = screenHeight - y - CreationParams.WindowSize.Height; + } + + Window = [[NSWindow alloc] initWithContentRect:NSMakeRect(x, y, CreationParams.WindowSize.Width, CreationParams.WindowSize.Height) styleMask:NSTitledWindowMask + NSClosableWindowMask + NSResizableWindowMask backing:type defer:FALSE]; + + if (CreationParams.WindowPosition.X == -1 && CreationParams.WindowPosition.Y == -1) + [Window center]; + } + + DeviceWidth = CreationParams.WindowSize.Width; + DeviceHeight = CreationParams.WindowSize.Height; + + result = true; + } + + if (result) { + if (Window) { + [Window setDelegate:(CIrrDelegateOSX *)[NSApp delegate]]; + [Window setAcceptsMouseMovedEvents:TRUE]; + [Window setIsVisible:TRUE]; + [Window makeKeyAndOrderFront:nil]; + } + } + + return result; +} + +void CIrrDeviceMacOSX::setResize(int width, int height) +{ + // set new window size + DeviceWidth = width; + DeviceHeight = height; + +#if defined(_IRR_COMPILE_WITH_OPENGL_) + // update the size of the opengl rendering context + if (CreationParams.DriverType == video::EDT_OPENGL) { + NSOpenGLContext *Context = (NSOpenGLContext *)ContextManager->getContext().OpenGLOSX.Context; + + if (Context) + [Context update]; + } +#endif + + // resize the driver to the inner pane size + if (Window) { + NSRect driverFrame = [Window contentRectForFrameRect:[Window frame]]; + getVideoDriver()->OnResize(core::dimension2d((s32)driverFrame.size.width, (s32)driverFrame.size.height)); + DeviceWidth = (s32)driverFrame.size.width; + DeviceHeight = (s32)driverFrame.size.height; + } else + getVideoDriver()->OnResize(core::dimension2d((s32)width, (s32)height)); +} + +void CIrrDeviceMacOSX::createDriver() +{ + switch (CreationParams.DriverType) { + case video::EDT_OPENGL: +#ifdef _IRR_COMPILE_WITH_OPENGL_ + { + video::SExposedVideoData data; + data.OpenGLOSX.Window = Window; + ContextManager = new video::CNSOGLManager(); + ContextManager->initialize(CreationParams, data); + VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, ContextManager); + if (!VideoDriver) { + os::Printer::log("Could not create OpenGL driver.", ELL_ERROR); + } + + if (Window) { + [[Window contentView] setWantsBestResolutionOpenGLSurface:NO]; + [(NSOpenGLContext *)ContextManager->getContext().OpenGLOSX.Context setView:[Window contentView]]; + } else { + [(NSView *)CreationParams.WindowId setWantsBestResolutionOpenGLSurface:NO]; + [(NSOpenGLContext *)ContextManager->getContext().OpenGLOSX.Context setView:(NSView *)CreationParams.WindowId]; + } + } +#else + os::Printer::log("No OpenGL support compiled in.", ELL_ERROR); +#endif + break; + + case video::EDT_OGLES1: + case video::EDT_OGLES2: + os::Printer::log("This driver is not available in OSX. Try OpenGL or Software renderer.", ELL_ERROR); + break; + + case video::EDT_NULL: + VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); + break; + + default: + os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR); + break; + } +} + +bool CIrrDeviceMacOSX::run() +{ + NSAutoreleasePool *Pool = [[NSAutoreleasePool alloc] init]; + + NSEvent *event; + irr::SEvent ievent; + + os::Timer::tick(); + storeMouseLocation(); + + event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES]; + if (event != nil) { + bzero(&ievent, sizeof(ievent)); + + switch ([(NSEvent *)event type]) { + case NSKeyDown: + postKeyEvent(event, ievent, true); + break; + + case NSKeyUp: + postKeyEvent(event, ievent, false); + break; + + case NSFlagsChanged: + ievent.EventType = irr::EET_KEY_INPUT_EVENT; + ievent.KeyInput.Shift = ([(NSEvent *)event modifierFlags] & NSShiftKeyMask) != 0; + ievent.KeyInput.Control = ([(NSEvent *)event modifierFlags] & NSControlKeyMask) != 0; + + if (IsShiftDown != ievent.KeyInput.Shift) { + ievent.KeyInput.Char = irr::KEY_SHIFT; + ievent.KeyInput.Key = irr::KEY_SHIFT; + ievent.KeyInput.PressedDown = ievent.KeyInput.Shift; + + IsShiftDown = ievent.KeyInput.Shift; + + postEventFromUser(ievent); + } + + if (IsControlDown != ievent.KeyInput.Control) { + ievent.KeyInput.Char = irr::KEY_CONTROL; + ievent.KeyInput.Key = irr::KEY_CONTROL; + ievent.KeyInput.PressedDown = ievent.KeyInput.Control; + + IsControlDown = ievent.KeyInput.Control; + + postEventFromUser(ievent); + } + + [NSApp sendEvent:event]; + break; + + case NSLeftMouseDown: + ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; + ievent.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN; + MouseButtonStates |= irr::EMBSM_LEFT; + ievent.MouseInput.ButtonStates = MouseButtonStates; + postMouseEvent(event, ievent); + break; + + case NSLeftMouseUp: + ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; + MouseButtonStates &= !irr::EMBSM_LEFT; + ievent.MouseInput.ButtonStates = MouseButtonStates; + ievent.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP; + postMouseEvent(event, ievent); + break; + + case NSOtherMouseDown: + ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; + ievent.MouseInput.Event = irr::EMIE_MMOUSE_PRESSED_DOWN; + MouseButtonStates |= irr::EMBSM_MIDDLE; + ievent.MouseInput.ButtonStates = MouseButtonStates; + postMouseEvent(event, ievent); + break; + + case NSOtherMouseUp: + ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; + MouseButtonStates &= !irr::EMBSM_MIDDLE; + ievent.MouseInput.ButtonStates = MouseButtonStates; + ievent.MouseInput.Event = irr::EMIE_MMOUSE_LEFT_UP; + postMouseEvent(event, ievent); + break; + + case NSMouseMoved: + case NSLeftMouseDragged: + case NSRightMouseDragged: + case NSOtherMouseDragged: + ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; + ievent.MouseInput.Event = irr::EMIE_MOUSE_MOVED; + ievent.MouseInput.ButtonStates = MouseButtonStates; + postMouseEvent(event, ievent); + break; + + case NSRightMouseDown: + ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; + ievent.MouseInput.Event = irr::EMIE_RMOUSE_PRESSED_DOWN; + MouseButtonStates |= irr::EMBSM_RIGHT; + ievent.MouseInput.ButtonStates = MouseButtonStates; + postMouseEvent(event, ievent); + break; + + case NSRightMouseUp: + ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; + ievent.MouseInput.Event = irr::EMIE_RMOUSE_LEFT_UP; + MouseButtonStates &= !irr::EMBSM_RIGHT; + ievent.MouseInput.ButtonStates = MouseButtonStates; + postMouseEvent(event, ievent); + break; + + case NSScrollWheel: + ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; + ievent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL; + ievent.MouseInput.Wheel = [(NSEvent *)event deltaY]; + if (ievent.MouseInput.Wheel < 1.0f) + ievent.MouseInput.Wheel *= 10.0f; + else + ievent.MouseInput.Wheel *= 5.0f; + postMouseEvent(event, ievent); + break; + + default: + [NSApp sendEvent:event]; + break; + } + } + + pollJoysticks(); + + [Pool release]; + + return (![[NSApp delegate] isQuit] && IsActive); +} + +//! Pause the current process for the minimum time allowed only to allow other processes to execute +void CIrrDeviceMacOSX::yield() +{ + struct timespec ts = {0, 0}; + nanosleep(&ts, NULL); +} + +//! Pause execution and let other processes to run for a specified amount of time. +void CIrrDeviceMacOSX::sleep(u32 timeMs, bool pauseTimer = false) +{ + bool wasStopped = Timer ? Timer->isStopped() : true; + + struct timespec ts; + ts.tv_sec = (time_t)(timeMs / 1000); + ts.tv_nsec = (long)(timeMs % 1000) * 1000000; + + if (pauseTimer && !wasStopped) + Timer->stop(); + + nanosleep(&ts, NULL); + + if (pauseTimer && !wasStopped) + Timer->start(); +} + +void CIrrDeviceMacOSX::setWindowCaption(const wchar_t *text) +{ + if (Window != NULL) { + if (text) { + size_t numBytes = wcslen(text) * sizeof(wchar_t); + +#ifdef __BIG_ENDIAN__ + NSStringEncoding encode = sizeof(wchar_t) == 4 ? NSUTF32BigEndianStringEncoding : NSUTF16BigEndianStringEncoding; +#else + NSStringEncoding encode = sizeof(wchar_t) == 4 ? NSUTF32LittleEndianStringEncoding : NSUTF16LittleEndianStringEncoding; +#endif + NSString *name = [[NSString alloc] initWithBytes:text length:numBytes encoding:encode]; + if (name) { + [Window setTitle:name]; + [name release]; + } + } else { + [Window setTitle:@""]; + } + } +} + +bool CIrrDeviceMacOSX::isWindowActive() const +{ + return (IsActive); +} + +bool CIrrDeviceMacOSX::isWindowFocused() const +{ + if (Window != NULL) + return [Window isKeyWindow]; + return false; +} + +bool CIrrDeviceMacOSX::isWindowMinimized() const +{ + if (Window != NULL) + return [Window isMiniaturized]; + return false; +} + +void CIrrDeviceMacOSX::postKeyEvent(void *event, irr::SEvent &ievent, bool pressed) +{ + NSString *str; + std::map::const_iterator iter; + unsigned int c, mkey, mchar; + const unsigned char *cStr; + BOOL skipCommand; + + str = [(NSEvent *)event characters]; + if ((str != nil) && ([str length] > 0)) { + mkey = mchar = 0; + skipCommand = false; + c = [str characterAtIndex:0]; + mchar = c; + + iter = KeyCodes.find([(NSEvent *)event keyCode]); + if (iter != KeyCodes.end()) + mkey = (*iter).second; + else if ((iter = KeyCodes.find(c)) != KeyCodes.end()) + mkey = (*iter).second; + else { + // workaround for period character + if (c == 0x2E) { + mkey = irr::KEY_PERIOD; + mchar = '.'; + } else { + cStr = (unsigned char *)[str cStringUsingEncoding:NSWindowsCP1252StringEncoding]; + if (cStr != NULL && strlen((char *)cStr) > 0) { + mchar = cStr[0]; + mkey = toupper(mchar); + if ([(NSEvent *)event modifierFlags] & NSCommandKeyMask) { + if (mkey == 'C' || mkey == 'V' || mkey == 'X') { + mchar = 0; + skipCommand = true; + } + } + } + } + } + + ievent.EventType = irr::EET_KEY_INPUT_EVENT; + ievent.KeyInput.Key = (irr::EKEY_CODE)mkey; + ievent.KeyInput.PressedDown = pressed; + ievent.KeyInput.Shift = ([(NSEvent *)event modifierFlags] & NSShiftKeyMask) != 0; + ievent.KeyInput.Control = ([(NSEvent *)event modifierFlags] & NSControlKeyMask) != 0; + ievent.KeyInput.Char = mchar; + + if (skipCommand) + ievent.KeyInput.Control = true; + else if ([(NSEvent *)event modifierFlags] & NSCommandKeyMask) + [NSApp sendEvent:(NSEvent *)event]; + + postEventFromUser(ievent); + } +} + +void CIrrDeviceMacOSX::postMouseEvent(void *event, irr::SEvent &ievent) +{ + bool post = true; + + if (Window != NULL) { + ievent.MouseInput.X = (int)[(NSEvent *)event locationInWindow].x; + ievent.MouseInput.Y = DeviceHeight - (int)[(NSEvent *)event locationInWindow].y; + + if (ievent.MouseInput.Y < 0) + post = false; + } else { + CGEventRef ourEvent = CGEventCreate(NULL); + CGPoint point = CGEventGetLocation(ourEvent); + CFRelease(ourEvent); + + ievent.MouseInput.X = (int)point.x; + ievent.MouseInput.Y = (int)point.y; + + if (ievent.MouseInput.Y < 0) + post = false; + } + + if (post) { + ievent.MouseInput.Shift = ([(NSEvent *)event modifierFlags] & NSShiftKeyMask) != 0; + ievent.MouseInput.Control = ([(NSEvent *)event modifierFlags] & NSControlKeyMask) != 0; + + postEventFromUser(ievent); + } + + [NSApp sendEvent:(NSEvent *)event]; +} + +void CIrrDeviceMacOSX::storeMouseLocation() +{ + int x, y; + + if (Window != NULL) { + NSPoint p; + p = [NSEvent mouseLocation]; + p = [Window convertScreenToBase:p]; + x = (int)p.x; + y = DeviceHeight - (int)p.y; + } else { + // Do we still need this? + CGEventRef ourEvent = CGEventCreate(NULL); + CGPoint point = CGEventGetLocation(ourEvent); + CFRelease(ourEvent); + + x = (int)point.x; + y = (int)point.y; + + const core::position2di &curr = ((CCursorControl *)CursorControl)->getPosition(true); + if (curr.X != x || curr.Y != y) { + irr::SEvent ievent; + ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; + ievent.MouseInput.Event = irr::EMIE_MOUSE_MOVED; + ievent.MouseInput.X = x; + ievent.MouseInput.Y = y; + postEventFromUser(ievent); + } + } + + ((CCursorControl *)CursorControl)->updateInternalCursorPosition(x, y); +} + +void CIrrDeviceMacOSX::setMouseLocation(int x, int y) +{ + NSPoint p; + CGPoint c; + + if (Window != NULL) { + // Irrlicht window exists + p.x = (float)x; + p.y = (float)(DeviceHeight - y); + p = [Window convertBaseToScreen:p]; + p.y = ScreenHeight - p.y; + } else { + p.x = (float)x; + p.y = (float)y + (ScreenHeight - DeviceHeight); + } + + c.x = p.x; + c.y = p.y; + + CGWarpMouseCursorPosition(c); + CGAssociateMouseAndMouseCursorPosition(YES); +} + +void CIrrDeviceMacOSX::setCursorVisible(bool visible) +{ + if (visible) + CGDisplayShowCursor(CGMainDisplayID()); + else + CGDisplayHideCursor(CGMainDisplayID()); +} + +void CIrrDeviceMacOSX::setWindow(NSWindow *window) +{ + Window = window; +} + +void CIrrDeviceMacOSX::initKeycodes() +{ + KeyCodes[kVK_UpArrow] = irr::KEY_UP; + KeyCodes[kVK_DownArrow] = irr::KEY_DOWN; + KeyCodes[kVK_LeftArrow] = irr::KEY_LEFT; + KeyCodes[kVK_RightArrow] = irr::KEY_RIGHT; + KeyCodes[kVK_F1] = irr::KEY_F1; + KeyCodes[kVK_F2] = irr::KEY_F2; + KeyCodes[kVK_F3] = irr::KEY_F3; + KeyCodes[kVK_F4] = irr::KEY_F4; + KeyCodes[kVK_F5] = irr::KEY_F5; + KeyCodes[kVK_F6] = irr::KEY_F6; + KeyCodes[kVK_F7] = irr::KEY_F7; + KeyCodes[kVK_F8] = irr::KEY_F8; + KeyCodes[kVK_F9] = irr::KEY_F9; + KeyCodes[kVK_F10] = irr::KEY_F10; + KeyCodes[kVK_F11] = irr::KEY_F11; + KeyCodes[kVK_F12] = irr::KEY_F12; + KeyCodes[kVK_F13] = irr::KEY_F13; + KeyCodes[kVK_F14] = irr::KEY_F14; + KeyCodes[kVK_F15] = irr::KEY_F15; + KeyCodes[kVK_F16] = irr::KEY_F16; + KeyCodes[kVK_F17] = irr::KEY_F17; + KeyCodes[kVK_F18] = irr::KEY_F18; + KeyCodes[kVK_F19] = irr::KEY_F19; + KeyCodes[kVK_F20] = irr::KEY_F20; + KeyCodes[kVK_Home] = irr::KEY_HOME; + KeyCodes[kVK_End] = irr::KEY_END; + KeyCodes[NSInsertFunctionKey] = irr::KEY_INSERT; + KeyCodes[kVK_ForwardDelete] = irr::KEY_DELETE; + KeyCodes[kVK_Help] = irr::KEY_HELP; + KeyCodes[NSSelectFunctionKey] = irr::KEY_SELECT; + KeyCodes[NSPrintFunctionKey] = irr::KEY_PRINT; + KeyCodes[NSExecuteFunctionKey] = irr::KEY_EXECUT; + KeyCodes[NSPrintScreenFunctionKey] = irr::KEY_SNAPSHOT; + KeyCodes[NSPauseFunctionKey] = irr::KEY_PAUSE; + KeyCodes[NSScrollLockFunctionKey] = irr::KEY_SCROLL; + KeyCodes[kVK_Delete] = irr::KEY_BACK; + KeyCodes[kVK_Tab] = irr::KEY_TAB; + KeyCodes[kVK_Return] = irr::KEY_RETURN; + KeyCodes[kVK_Escape] = irr::KEY_ESCAPE; + KeyCodes[kVK_Control] = irr::KEY_CONTROL; + KeyCodes[kVK_RightControl] = irr::KEY_RCONTROL; + KeyCodes[kVK_Command] = irr::KEY_MENU; + KeyCodes[kVK_Shift] = irr::KEY_SHIFT; + KeyCodes[kVK_RightShift] = irr::KEY_RSHIFT; + KeyCodes[kVK_Space] = irr::KEY_SPACE; + + KeyCodes[kVK_ANSI_A] = irr::KEY_KEY_A; + KeyCodes[kVK_ANSI_B] = irr::KEY_KEY_B; + KeyCodes[kVK_ANSI_C] = irr::KEY_KEY_C; + KeyCodes[kVK_ANSI_D] = irr::KEY_KEY_D; + KeyCodes[kVK_ANSI_E] = irr::KEY_KEY_E; + KeyCodes[kVK_ANSI_F] = irr::KEY_KEY_F; + KeyCodes[kVK_ANSI_G] = irr::KEY_KEY_G; + KeyCodes[kVK_ANSI_H] = irr::KEY_KEY_H; + KeyCodes[kVK_ANSI_I] = irr::KEY_KEY_I; + KeyCodes[kVK_ANSI_J] = irr::KEY_KEY_J; + KeyCodes[kVK_ANSI_K] = irr::KEY_KEY_K; + KeyCodes[kVK_ANSI_L] = irr::KEY_KEY_L; + KeyCodes[kVK_ANSI_M] = irr::KEY_KEY_M; + KeyCodes[kVK_ANSI_N] = irr::KEY_KEY_N; + KeyCodes[kVK_ANSI_O] = irr::KEY_KEY_O; + KeyCodes[kVK_ANSI_P] = irr::KEY_KEY_P; + KeyCodes[kVK_ANSI_Q] = irr::KEY_KEY_Q; + KeyCodes[kVK_ANSI_R] = irr::KEY_KEY_R; + KeyCodes[kVK_ANSI_S] = irr::KEY_KEY_S; + KeyCodes[kVK_ANSI_T] = irr::KEY_KEY_T; + KeyCodes[kVK_ANSI_U] = irr::KEY_KEY_U; + KeyCodes[kVK_ANSI_V] = irr::KEY_KEY_V; + KeyCodes[kVK_ANSI_W] = irr::KEY_KEY_W; + KeyCodes[kVK_ANSI_X] = irr::KEY_KEY_X; + KeyCodes[kVK_ANSI_X] = irr::KEY_KEY_X; + KeyCodes[kVK_ANSI_Y] = irr::KEY_KEY_Y; + KeyCodes[kVK_ANSI_Z] = irr::KEY_KEY_Z; + + KeyCodes[kVK_ANSI_0] = irr::KEY_KEY_0; + KeyCodes[kVK_ANSI_1] = irr::KEY_KEY_1; + KeyCodes[kVK_ANSI_2] = irr::KEY_KEY_2; + KeyCodes[kVK_ANSI_3] = irr::KEY_KEY_3; + KeyCodes[kVK_ANSI_4] = irr::KEY_KEY_4; + KeyCodes[kVK_ANSI_5] = irr::KEY_KEY_5; + KeyCodes[kVK_ANSI_6] = irr::KEY_KEY_6; + KeyCodes[kVK_ANSI_7] = irr::KEY_KEY_7; + KeyCodes[kVK_ANSI_8] = irr::KEY_KEY_8; + KeyCodes[kVK_ANSI_9] = irr::KEY_KEY_9; + + KeyCodes[kVK_ANSI_Slash] = irr::KEY_DIVIDE; + KeyCodes[kVK_ANSI_Comma] = irr::KEY_COMMA; + KeyCodes[kVK_ANSI_Period] = irr::KEY_PERIOD; + KeyCodes[kVK_PageUp] = irr::KEY_PRIOR; + KeyCodes[kVK_PageDown] = irr::KEY_NEXT; + + KeyCodes[kVK_ANSI_Keypad0] = irr::KEY_NUMPAD0; + KeyCodes[kVK_ANSI_Keypad1] = irr::KEY_NUMPAD1; + KeyCodes[kVK_ANSI_Keypad2] = irr::KEY_NUMPAD2; + KeyCodes[kVK_ANSI_Keypad3] = irr::KEY_NUMPAD3; + KeyCodes[kVK_ANSI_Keypad4] = irr::KEY_NUMPAD4; + KeyCodes[kVK_ANSI_Keypad5] = irr::KEY_NUMPAD5; + KeyCodes[kVK_ANSI_Keypad6] = irr::KEY_NUMPAD6; + KeyCodes[kVK_ANSI_Keypad7] = irr::KEY_NUMPAD7; + KeyCodes[kVK_ANSI_Keypad8] = irr::KEY_NUMPAD8; + KeyCodes[kVK_ANSI_Keypad9] = irr::KEY_NUMPAD9; + + KeyCodes[kVK_ANSI_KeypadDecimal] = irr::KEY_DECIMAL; + KeyCodes[kVK_ANSI_KeypadMultiply] = irr::KEY_MULTIPLY; + KeyCodes[kVK_ANSI_KeypadPlus] = irr::KEY_PLUS; + KeyCodes[kVK_ANSI_KeypadClear] = irr::KEY_OEM_CLEAR; + KeyCodes[kVK_ANSI_KeypadDivide] = irr::KEY_DIVIDE; + KeyCodes[kVK_ANSI_KeypadEnter] = irr::KEY_RETURN; + KeyCodes[kVK_ANSI_KeypadMinus] = irr::KEY_SUBTRACT; + + KeyCodes[kVK_ANSI_LeftBracket] = irr::KEY_OEM_4; + KeyCodes[kVK_ANSI_Backslash] = irr::KEY_OEM_5; + KeyCodes[kVK_ANSI_RightBracket] = irr::KEY_OEM_6; +} + +//! Sets if the window should be resizable in windowed mode. +void CIrrDeviceMacOSX::setResizable(bool resize) +{ + IsResizable = resize; +#if 0 + if (resize) + [Window setStyleMask:NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask]; + else + [Window setStyleMask:NSTitledWindowMask|NSClosableWindowMask]; +#endif +} + +bool CIrrDeviceMacOSX::isResizable() const +{ + return IsResizable; +} + +void CIrrDeviceMacOSX::minimizeWindow() +{ + if (Window != NULL) + [Window miniaturize:[NSApp self]]; +} + +//! Maximizes the window if possible. +void CIrrDeviceMacOSX::maximizeWindow() +{ + // todo: implement +} + +//! get the window to normal size if possible. +void CIrrDeviceMacOSX::restoreWindow() +{ + [Window deminiaturize:[NSApp self]]; +} + +//! Get the position of this window on screen +core::position2di CIrrDeviceMacOSX::getWindowPosition() +{ + NSRect rect = [Window frame]; + int screenHeight = [[[NSScreen screens] objectAtIndex:0] frame].size.height; + return core::position2di(rect.origin.x, screenHeight - rect.origin.y - rect.size.height); +} + +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) +static void joystickRemovalCallback(void *target, + IOReturn result, void *refcon, void *sender) +{ + JoystickInfo *joy = (JoystickInfo *)refcon; + joy->removed = 1; +} +#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ + +bool CIrrDeviceMacOSX::activateJoysticks(core::array &joystickInfo) +{ +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) + ActiveJoysticks.clear(); + joystickInfo.clear(); + + io_object_t hidObject = 0; + io_iterator_t hidIterator = 0; + IOReturn result = kIOReturnSuccess; + mach_port_t masterPort = 0; + CFMutableDictionaryRef hidDictionaryRef = NULL; + + result = IOMasterPort(bootstrap_port, &masterPort); + if (kIOReturnSuccess != result) { + os::Printer::log("initialiseJoysticks IOMasterPort failed", ELL_ERROR); + return false; + } + + hidDictionaryRef = IOServiceMatching(kIOHIDDeviceKey); + if (!hidDictionaryRef) { + os::Printer::log("initialiseJoysticks IOServiceMatching failed", ELL_ERROR); + return false; + } + result = IOServiceGetMatchingServices(masterPort, hidDictionaryRef, &hidIterator); + + if (kIOReturnSuccess != result) { + os::Printer::log("initialiseJoysticks IOServiceGetMatchingServices failed", ELL_ERROR); + return false; + } + + // no joysticks just return + if (!hidIterator) + return false; + + u32 jindex = 0u; + while ((hidObject = IOIteratorNext(hidIterator))) { + JoystickInfo info; + + // get dictionary for HID properties + CFMutableDictionaryRef hidProperties = 0; + + kern_return_t kern_result = IORegistryEntryCreateCFProperties(hidObject, &hidProperties, kCFAllocatorDefault, kNilOptions); + if ((kern_result == KERN_SUCCESS) && hidProperties) { + HRESULT plugInResult = S_OK; + SInt32 score = 0; + IOCFPlugInInterface **ppPlugInInterface = NULL; + result = IOCreatePlugInInterfaceForService(hidObject, kIOHIDDeviceUserClientTypeID, + kIOCFPlugInInterfaceID, &ppPlugInInterface, &score); + if (kIOReturnSuccess == result) { + plugInResult = (*ppPlugInInterface)->QueryInterface(ppPlugInInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (void **)&(info.interface)); + if (plugInResult != S_OK) + os::Printer::log("initialiseJoysticks query HID class device interface failed", ELL_ERROR); + (*ppPlugInInterface)->Release(ppPlugInInterface); + } else + continue; + + if (info.interface != NULL) { + result = (*(info.interface))->open(info.interface, 0); + if (result == kIOReturnSuccess) { + (*(info.interface))->setRemovalCallback(info.interface, joystickRemovalCallback, &info, &info); + getJoystickDeviceInfo(hidObject, hidProperties, &info); + + // get elements + CFTypeRef refElementTop = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDElementKey)); + if (refElementTop) { + CFTypeID type = CFGetTypeID(refElementTop); + if (type == CFArrayGetTypeID()) { + CFRange range = {0, CFArrayGetCount((CFArrayRef)refElementTop)}; + info.numActiveJoysticks = ActiveJoysticks.size(); + CFArrayApplyFunction((CFArrayRef)refElementTop, range, getJoystickComponentArrayHandler, &info); + } + } + } else { + CFRelease(hidProperties); + os::Printer::log("initialiseJoysticks Open interface failed", ELL_ERROR); + continue; + } + + CFRelease(hidProperties); + + result = IOObjectRelease(hidObject); + + if ((info.usagePage != kHIDPage_GenericDesktop) || + ((info.usage != kHIDUsage_GD_Joystick && + info.usage != kHIDUsage_GD_GamePad && + info.usage != kHIDUsage_GD_MultiAxisController))) { + closeJoystickDevice(&info); + continue; + } + + for (u32 i = 0; i < 6; ++i) + info.persistentData.JoystickEvent.Axis[i] = 0; + + ActiveJoysticks.push_back(info); + + SJoystickInfo returnInfo; + returnInfo.Joystick = jindex; + returnInfo.Axes = info.axes; + // returnInfo.Hats = info.hats; + returnInfo.Buttons = info.buttons; + returnInfo.Name = info.joystickName; + returnInfo.PovHat = SJoystickInfo::POV_HAT_UNKNOWN; + ++jindex; + + // if (info.hatComp.size()) + // returnInfo.PovHat = SJoystickInfo::POV_HAT_PRESENT; + // else + // returnInfo.PovHat = SJoystickInfo::POV_HAT_ABSENT; + + joystickInfo.push_back(returnInfo); + } + + } else { + continue; + } + } + result = IOObjectRelease(hidIterator); + + return true; +#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ + + return false; +} + +void CIrrDeviceMacOSX::pollJoysticks() +{ +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) + if (0 == ActiveJoysticks.size()) + return; + + u32 joystick; + for (joystick = 0; joystick < ActiveJoysticks.size(); ++joystick) { + if (ActiveJoysticks[joystick].removed) + continue; + + bool found = false; + ActiveJoysticks[joystick].persistentData.JoystickEvent.Joystick = joystick; + + if (ActiveJoysticks[joystick].interface) { + for (u32 n = 0; n < ActiveJoysticks[joystick].axisComp.size(); n++) { + IOReturn result = kIOReturnSuccess; + IOHIDEventStruct hidEvent; + hidEvent.value = 0; + result = (*(ActiveJoysticks[joystick].interface))->getElementValue(ActiveJoysticks[joystick].interface, ActiveJoysticks[joystick].axisComp[n].cookie, &hidEvent); + if (kIOReturnSuccess == result) { + const f32 min = -32768.0f; + const f32 max = 32767.0f; + const f32 deviceScale = max - min; + const f32 readScale = (f32)ActiveJoysticks[joystick].axisComp[n].maxRead - (f32)ActiveJoysticks[joystick].axisComp[n].minRead; + + if (hidEvent.value < ActiveJoysticks[joystick].axisComp[n].minRead) + ActiveJoysticks[joystick].axisComp[n].minRead = hidEvent.value; + if (hidEvent.value > ActiveJoysticks[joystick].axisComp[n].maxRead) + ActiveJoysticks[joystick].axisComp[n].maxRead = hidEvent.value; + + if (readScale != 0.0f) + hidEvent.value = (int)(((f32)((f32)hidEvent.value - (f32)ActiveJoysticks[joystick].axisComp[n].minRead) * deviceScale / readScale) + min); + + if (ActiveJoysticks[joystick].persistentData.JoystickEvent.Axis[n] != (s16)hidEvent.value) + found = true; + ActiveJoysticks[joystick].persistentData.JoystickEvent.Axis[n] = (s16)hidEvent.value; + } + } // axis check + + for (u32 n = 0; n < ActiveJoysticks[joystick].buttonComp.size(); n++) { + IOReturn result = kIOReturnSuccess; + IOHIDEventStruct hidEvent; + hidEvent.value = 0; + result = (*(ActiveJoysticks[joystick].interface))->getElementValue(ActiveJoysticks[joystick].interface, ActiveJoysticks[joystick].buttonComp[n].cookie, &hidEvent); + if (kIOReturnSuccess == result) { + if (hidEvent.value && !((ActiveJoysticks[joystick].persistentData.JoystickEvent.ButtonStates & (1 << n)) ? true : false)) + found = true; + else if (!hidEvent.value && ((ActiveJoysticks[joystick].persistentData.JoystickEvent.ButtonStates & (1 << n)) ? true : false)) + found = true; + + if (hidEvent.value) + ActiveJoysticks[joystick].persistentData.JoystickEvent.ButtonStates |= (1 << n); + else + ActiveJoysticks[joystick].persistentData.JoystickEvent.ButtonStates &= ~(1 << n); + } + } // button check + // still ToDo..will be done soon :) + /* + for (u32 n = 0; n < ActiveJoysticks[joystick].hatComp.size(); n++) + { + IOReturn result = kIOReturnSuccess; + IOHIDEventStruct hidEvent; + hidEvent.value = 0; + result = (*(ActiveJoysticks[joystick].interface))->getElementValue(ActiveJoysticks[joystick].interface, ActiveJoysticks[joystick].hatComp[n].cookie, &hidEvent); + if (kIOReturnSuccess == result) + { + if (ActiveJoysticks[joystick].persistentData.JoystickEvent.POV != hidEvent.value) + found = true; + ActiveJoysticks[joystick].persistentData.JoystickEvent.POV = hidEvent.value; + } + }//hat check + */ + } + + if (found) + postEventFromUser(ActiveJoysticks[joystick].persistentData); + } +#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ +} + +} // end namespace + +#endif // _IRR_COMPILE_WITH_OSX_DEVICE_ diff --git a/irr/src/CIrrDeviceSDL.cpp b/irr/src/CIrrDeviceSDL.cpp new file mode 100644 index 000000000..17dc033d4 --- /dev/null +++ b/irr/src/CIrrDeviceSDL.cpp @@ -0,0 +1,1264 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ + +#include "CIrrDeviceSDL.h" +#include "IEventReceiver.h" +#include "IGUIElement.h" +#include "IGUIEnvironment.h" +#include "IImageLoader.h" +#include "IFileSystem.h" +#include "os.h" +#include "CTimer.h" +#include "irrString.h" +#include "Keycodes.h" +#include "COSOperator.h" +#include +#include +#include "SIrrCreationParameters.h" +#include + +#ifdef _IRR_EMSCRIPTEN_PLATFORM_ +#include +#endif + +#include "CSDLManager.h" + +static int SDLDeviceInstances = 0; + +namespace irr +{ +namespace video +{ +#ifdef _IRR_COMPILE_WITH_OPENGL_ +IVideoDriver *createOpenGLDriver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager); +#else +static IVideoDriver *createOpenGLDriver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager) +{ + os::Printer::log("No OpenGL support compiled in.", ELL_ERROR); + return nullptr; +} +#endif + +#ifdef ENABLE_OPENGL3 +IVideoDriver *createOpenGL3Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager); +#else +static IVideoDriver *createOpenGL3Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager) +{ + os::Printer::log("No OpenGL 3 support compiled in.", ELL_ERROR); + return nullptr; +} +#endif + +#ifdef _IRR_COMPILE_WITH_OGLES2_ +IVideoDriver *createOGLES2Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager); +#else +static IVideoDriver *createOGLES2Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager) +{ + os::Printer::log("No OpenGL ES 2 support compiled in.", ELL_ERROR); + return nullptr; +} +#endif + +#ifdef _IRR_COMPILE_WITH_WEBGL1_ +IVideoDriver *createWebGL1Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager); +#else +static IVideoDriver *createWebGL1Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager) +{ + os::Printer::log("No WebGL 1 support compiled in.", ELL_ERROR); + return nullptr; +} +#endif +} // end namespace video + +} // end namespace irr + +namespace irr +{ +#ifdef _IRR_EMSCRIPTEN_PLATFORM_ +EM_BOOL CIrrDeviceSDL::MouseUpDownCallback(int eventType, const EmscriptenMouseEvent *event, void *userData) +{ + // We need this callback so far only because otherwise "emscripten_request_pointerlock" calls will + // fail as their request are infinitely deferred. + // Not exactly certain why, maybe SDL does catch those mouse-events otherwise and not pass them on. + return EM_FALSE; +} + +EM_BOOL CIrrDeviceSDL::MouseEnterCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) +{ + CIrrDeviceSDL *This = static_cast(userData); + + SEvent irrevent; + + irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT; + irrevent.MouseInput.Event = irr::EMIE_MOUSE_ENTER_CANVAS; + This->MouseX = irrevent.MouseInput.X = mouseEvent->canvasX; + This->MouseY = irrevent.MouseInput.Y = mouseEvent->canvasY; + This->MouseXRel = mouseEvent->movementX; // should be 0 I guess? Or can it enter while pointer is locked()? + This->MouseYRel = mouseEvent->movementY; + irrevent.MouseInput.ButtonStates = This->MouseButtonStates; // TODO: not correct, but couldn't figure out the bitset of mouseEvent->buttons yet. + irrevent.MouseInput.Shift = mouseEvent->shiftKey; + irrevent.MouseInput.Control = mouseEvent->ctrlKey; + + This->postEventFromUser(irrevent); + + return EM_FALSE; +} + +EM_BOOL CIrrDeviceSDL::MouseLeaveCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) +{ + CIrrDeviceSDL *This = static_cast(userData); + + SEvent irrevent; + + irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT; + irrevent.MouseInput.Event = irr::EMIE_MOUSE_LEAVE_CANVAS; + This->MouseX = irrevent.MouseInput.X = mouseEvent->canvasX; + This->MouseY = irrevent.MouseInput.Y = mouseEvent->canvasY; + This->MouseXRel = mouseEvent->movementX; // should be 0 I guess? Or can it enter while pointer is locked()? + This->MouseYRel = mouseEvent->movementY; + irrevent.MouseInput.ButtonStates = This->MouseButtonStates; // TODO: not correct, but couldn't figure out the bitset of mouseEvent->buttons yet. + irrevent.MouseInput.Shift = mouseEvent->shiftKey; + irrevent.MouseInput.Control = mouseEvent->ctrlKey; + + This->postEventFromUser(irrevent); + + return EM_FALSE; +} +#endif + +bool CIrrDeviceSDL::keyIsKnownSpecial(EKEY_CODE key) +{ + switch (key) { + // keys which are known to have safe special character interpretation + // could need changes over time (removals and additions!) + case KEY_RETURN: + case KEY_PAUSE: + case KEY_ESCAPE: + case KEY_PRIOR: + case KEY_NEXT: + case KEY_HOME: + case KEY_END: + case KEY_LEFT: + case KEY_UP: + case KEY_RIGHT: + case KEY_DOWN: + case KEY_TAB: + case KEY_PRINT: + case KEY_SNAPSHOT: + case KEY_INSERT: + case KEY_BACK: + case KEY_DELETE: + case KEY_HELP: + case KEY_APPS: + case KEY_SLEEP: + case KEY_F1: + case KEY_F2: + case KEY_F3: + case KEY_F4: + case KEY_F5: + case KEY_F6: + case KEY_F7: + case KEY_F8: + case KEY_F9: + case KEY_F10: + case KEY_F11: + case KEY_F12: + case KEY_F13: + case KEY_F14: + case KEY_F15: + case KEY_F16: + case KEY_F17: + case KEY_F18: + case KEY_F19: + case KEY_F20: + case KEY_F21: + case KEY_F22: + case KEY_F23: + case KEY_F24: + case KEY_NUMLOCK: + case KEY_SCROLL: + case KEY_LCONTROL: + case KEY_RCONTROL: + return true; + + default: + return false; + } +} + +int CIrrDeviceSDL::findCharToPassToIrrlicht(int assumedChar, EKEY_CODE key) +{ + // special cases that always return a char regardless of how the SDL keycode + // looks + switch (key) { + case KEY_RETURN: + case KEY_ESCAPE: + return (int)key; + default: + break; + } + + // SDL in-place ORs values with no character representation with 1<<30 + // https://wiki.libsdl.org/SDL2/SDLKeycodeLookup + if (assumedChar & (1 << 30)) + return 0; + + switch (key) { + case KEY_PRIOR: + case KEY_NEXT: + case KEY_HOME: + case KEY_END: + case KEY_LEFT: + case KEY_UP: + case KEY_RIGHT: + case KEY_DOWN: + case KEY_NUMLOCK: + return 0; + default: + return assumedChar; + } +} + +void CIrrDeviceSDL::resetReceiveTextInputEvents() +{ + gui::IGUIElement *elem = GUIEnvironment->getFocus(); + if (elem && elem->acceptsIME()) { + // IBus seems to have an issue where dead keys and compose keys do not + // work (specifically, the individual characters in the sequence are + // sent as text input events instead of the result) when + // SDL_StartTextInput() is called on the same input box. + core::rect pos = elem->getAbsolutePosition(); + if (!SDL_IsTextInputActive() || lastElemPos != pos) { + lastElemPos = pos; + SDL_Rect rect; + rect.x = pos.UpperLeftCorner.X; + rect.y = pos.UpperLeftCorner.Y; + rect.w = pos.getWidth(); + rect.h = pos.getHeight(); + SDL_SetTextInputRect(&rect); + SDL_StartTextInput(); + } + } else { + SDL_StopTextInput(); + } +} + +//! constructor +CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters ¶m) : + CIrrDeviceStub(param), + Window((SDL_Window *)param.WindowId), SDL_Flags(0), + MouseX(0), MouseY(0), MouseXRel(0), MouseYRel(0), MouseButtonStates(0), + Width(param.WindowSize.Width), Height(param.WindowSize.Height), + Resizable(param.WindowResizable == 1 ? true : false), CurrentTouchCount(0) +{ +#ifdef _DEBUG + setDebugName("CIrrDeviceSDL"); +#endif + + if (++SDLDeviceInstances == 1) { + u32 flags = SDL_INIT_TIMER | SDL_INIT_EVENTS; + if (CreationParams.DriverType != video::EDT_NULL) + flags |= SDL_INIT_VIDEO; +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) + flags |= SDL_INIT_JOYSTICK; +#endif + if (SDL_Init(flags) < 0) { + os::Printer::log("Unable to initialize SDL", SDL_GetError(), ELL_ERROR); + Close = true; + } else { + os::Printer::log("SDL initialized", ELL_INFORMATION); + } + } + + // Minetest has its own code to synthesize mouse events from touch events, + // so we prevent SDL from doing it. + SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0"); + SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0"); + + // create keymap + createKeyMap(); + + // create window + if (CreationParams.DriverType != video::EDT_NULL) { + if (!createWindow()) { + Close = true; + return; + } + } + + SDL_VERSION(&Info.version); + +#ifndef _IRR_EMSCRIPTEN_PLATFORM_ + SDL_GetWindowWMInfo(Window, &Info); +#endif //_IRR_EMSCRIPTEN_PLATFORM_ + core::stringc sdlversion = "SDL Version "; + sdlversion += Info.version.major; + sdlversion += "."; + sdlversion += Info.version.minor; + sdlversion += "."; + sdlversion += Info.version.patch; + + Operator = new COSOperator(sdlversion); + if (SDLDeviceInstances == 1) { + os::Printer::log(sdlversion.c_str(), ELL_INFORMATION); + } + + // create cursor control + CursorControl = new CCursorControl(this); + + // create driver + createDriver(); + + if (VideoDriver) { + createGUIAndScene(); + VideoDriver->OnResize(core::dimension2d(Width, Height)); + } +} + +//! destructor +CIrrDeviceSDL::~CIrrDeviceSDL() +{ + if (--SDLDeviceInstances == 0) { +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) + const u32 numJoysticks = Joysticks.size(); + for (u32 i = 0; i < numJoysticks; ++i) + SDL_JoystickClose(Joysticks[i]); +#endif + if (Window) { + SDL_GL_MakeCurrent(Window, NULL); + SDL_GL_DeleteContext(Context); + SDL_DestroyWindow(Window); + } + SDL_Quit(); + + os::Printer::log("Quit SDL", ELL_INFORMATION); + } +} + +void CIrrDeviceSDL::logAttributes() +{ + core::stringc sdl_attr("SDL attribs:"); + int value = 0; + if (SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value) == 0) + sdl_attr += core::stringc(" r:") + core::stringc(value); + if (SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value) == 0) + sdl_attr += core::stringc(" g:") + core::stringc(value); + if (SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value) == 0) + sdl_attr += core::stringc(" b:") + core::stringc(value); + if (SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &value) == 0) + sdl_attr += core::stringc(" a:") + core::stringc(value); + + if (SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value) == 0) + sdl_attr += core::stringc(" depth:") + core::stringc(value); + if (SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &value) == 0) + sdl_attr += core::stringc(" stencil:") + core::stringc(value); + if (SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &value) == 0) + sdl_attr += core::stringc(" doublebuf:") + core::stringc(value); + if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value) == 0) + sdl_attr += core::stringc(" aa:") + core::stringc(value); + if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value) == 0) + sdl_attr += core::stringc(" aa-samples:") + core::stringc(value); + + os::Printer::log(sdl_attr.c_str()); +} + +bool CIrrDeviceSDL::createWindow() +{ + if (CreationParams.Fullscreen) { +#ifdef _IRR_EMSCRIPTEN_PLATFORM_ + SDL_Flags |= SDL_WINDOW_FULLSCREEN; +#else + SDL_Flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; +#endif + } + if (Resizable) + SDL_Flags |= SDL_WINDOW_RESIZABLE; + if (CreationParams.WindowMaximized) + SDL_Flags |= SDL_WINDOW_MAXIMIZED; + SDL_Flags |= SDL_WINDOW_OPENGL; + +#ifdef _IRR_EMSCRIPTEN_PLATFORM_ + if (Width != 0 || Height != 0) + emscripten_set_canvas_size(Width, Height); + else { + int w, h, fs; + emscripten_get_canvas_size(&w, &h, &fs); + Width = w; + Height = h; + } + + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel ? 8 : 0); + + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, CreationParams.ZBufferBits); + SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, CreationParams.Stencilbuffer ? 8 : 0); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, CreationParams.Doublebuffer ? 1 : 0); + + if (CreationParams.AntiAlias > 1) { + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias); + } else { + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0); + } + + SDL_CreateWindowAndRenderer(0, 0, SDL_Flags, &Window, &Renderer); // 0,0 will use the canvas size + + logAttributes(); + + // "#canvas" is for the opengl context + emscripten_set_mousedown_callback("#canvas", (void *)this, true, MouseUpDownCallback); + emscripten_set_mouseup_callback("#canvas", (void *)this, true, MouseUpDownCallback); + emscripten_set_mouseenter_callback("#canvas", (void *)this, false, MouseEnterCallback); + emscripten_set_mouseleave_callback("#canvas", (void *)this, false, MouseLeaveCallback); + + return true; +#else // !_IRR_EMSCRIPTEN_PLATFORM_ + if (Close) + return false; + + switch (CreationParams.DriverType) { + case video::EDT_OPENGL: + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); + break; + case video::EDT_OPENGL3: + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); + break; + case video::EDT_OGLES1: + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); + break; + case video::EDT_OGLES2: + case video::EDT_WEBGL1: + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); + break; + default:; + } + +#ifdef _DEBUG + SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG | SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG); +#endif + + if (CreationParams.Bits == 16) { + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel ? 1 : 0); + } else { + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, CreationParams.WithAlphaChannel ? 8 : 0); + } + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, CreationParams.ZBufferBits); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, CreationParams.Doublebuffer); + SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, CreationParams.Stencilbuffer ? 8 : 0); + SDL_GL_SetAttribute(SDL_GL_STEREO, CreationParams.Stereobuffer); + if (CreationParams.AntiAlias > 1) { + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias); + } + if (!Window) + Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags); + if (!Window) { + os::Printer::log("Could not create window...", SDL_GetError(), ELL_WARNING); + } + if (!Window && CreationParams.AntiAlias > 1) { + while (--CreationParams.AntiAlias > 1) { + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, CreationParams.AntiAlias); + Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags); + if (Window) + break; + } + if (!Window) { + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0); + Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags); + if (Window) + os::Printer::log("AntiAliasing disabled due to lack of support!", ELL_WARNING); + } + } + + if (!Window && CreationParams.Doublebuffer) { + // Try single buffer + if (CreationParams.DriverType == video::EDT_OPENGL) + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + Window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, SDL_Flags); + } + if (!Window) { + os::Printer::log("Could not initialize display", SDL_GetError(), ELL_ERROR); + return false; + } + + Context = SDL_GL_CreateContext(Window); + if (!Context) { + os::Printer::log("Could not initialize context", SDL_GetError(), ELL_ERROR); + SDL_DestroyWindow(Window); + return false; + } + + return true; +#endif // !_IRR_EMSCRIPTEN_PLATFORM_ +} + +//! create the driver +void CIrrDeviceSDL::createDriver() +{ + if (CreationParams.DriverType == video::EDT_NULL) { + VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); + return; + } + + ContextManager = new video::CSDLManager(this); + switch (CreationParams.DriverType) { + case video::EDT_OPENGL: + VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, ContextManager); + break; + case video::EDT_OPENGL3: + VideoDriver = video::createOpenGL3Driver(CreationParams, FileSystem, ContextManager); + break; + case video::EDT_OGLES2: + VideoDriver = video::createOGLES2Driver(CreationParams, FileSystem, ContextManager); + break; + case video::EDT_WEBGL1: + VideoDriver = video::createWebGL1Driver(CreationParams, FileSystem, ContextManager); + break; + default:; + } + if (!VideoDriver) + os::Printer::log("Could not create video driver", ELL_ERROR); +} + +//! runs the device. Returns false if device wants to be deleted +bool CIrrDeviceSDL::run() +{ + os::Timer::tick(); + + SEvent irrevent; + SDL_Event SDL_event; + + while (!Close && SDL_PollEvent(&SDL_event)) { + // os::Printer::log("event: ", core::stringc((int)SDL_event.type).c_str(), ELL_INFORMATION); // just for debugging + + switch (SDL_event.type) { + case SDL_MOUSEMOTION: { + SDL_Keymod keymod = SDL_GetModState(); + + irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT; + irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED; + MouseX = irrevent.MouseInput.X = SDL_event.motion.x; + MouseY = irrevent.MouseInput.Y = SDL_event.motion.y; + MouseXRel = SDL_event.motion.xrel; + MouseYRel = SDL_event.motion.yrel; + irrevent.MouseInput.ButtonStates = MouseButtonStates; + irrevent.MouseInput.Shift = (keymod & KMOD_SHIFT) != 0; + irrevent.MouseInput.Control = (keymod & KMOD_CTRL) != 0; + + postEventFromUser(irrevent); + break; + } + case SDL_MOUSEWHEEL: { + SDL_Keymod keymod = SDL_GetModState(); + + irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT; + irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL; +#if SDL_VERSION_ATLEAST(2, 0, 18) + 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.Control = (keymod & KMOD_CTRL) != 0; + irrevent.MouseInput.X = MouseX; + irrevent.MouseInput.Y = MouseY; + + postEventFromUser(irrevent); + break; + } + case SDL_MOUSEBUTTONDOWN: + case SDL_MOUSEBUTTONUP: { + SDL_Keymod keymod = SDL_GetModState(); + + irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT; + irrevent.MouseInput.X = SDL_event.button.x; + irrevent.MouseInput.Y = SDL_event.button.y; + irrevent.MouseInput.Shift = (keymod & KMOD_SHIFT) != 0; + irrevent.MouseInput.Control = (keymod & KMOD_CTRL) != 0; + + irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED; + +#ifdef _IRR_EMSCRIPTEN_PLATFORM_ + // Handle mouselocking in emscripten in Windowed mode. + // In fullscreen SDL will handle it. + // The behavior we want windowed is - when the canvas was clicked then + // we will lock the mouse-pointer if it should be invisible. + // For security reasons this will be delayed until the next mouse-up event. + // We do not pass on this event as we don't want the activation click to do anything. + if (SDL_event.type == SDL_MOUSEBUTTONDOWN && !isFullscreen()) { + EmscriptenPointerlockChangeEvent pointerlockStatus; // let's hope that test is not expensive ... + if (emscripten_get_pointerlock_status(&pointerlockStatus) == EMSCRIPTEN_RESULT_SUCCESS) { + if (CursorControl->isVisible() && pointerlockStatus.isActive) { + emscripten_exit_pointerlock(); + return !Close; + } else if (!CursorControl->isVisible() && !pointerlockStatus.isActive) { + emscripten_request_pointerlock(0, true); + return !Close; + } + } + } +#endif + + switch (SDL_event.button.button) { + case SDL_BUTTON_LEFT: + if (SDL_event.type == SDL_MOUSEBUTTONDOWN) { + irrevent.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN; + MouseButtonStates |= irr::EMBSM_LEFT; + } else { + irrevent.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP; + MouseButtonStates &= ~irr::EMBSM_LEFT; + } + break; + + case SDL_BUTTON_RIGHT: + if (SDL_event.type == SDL_MOUSEBUTTONDOWN) { + irrevent.MouseInput.Event = irr::EMIE_RMOUSE_PRESSED_DOWN; + MouseButtonStates |= irr::EMBSM_RIGHT; + } else { + irrevent.MouseInput.Event = irr::EMIE_RMOUSE_LEFT_UP; + MouseButtonStates &= ~irr::EMBSM_RIGHT; + } + break; + + case SDL_BUTTON_MIDDLE: + if (SDL_event.type == SDL_MOUSEBUTTONDOWN) { + irrevent.MouseInput.Event = irr::EMIE_MMOUSE_PRESSED_DOWN; + MouseButtonStates |= irr::EMBSM_MIDDLE; + } else { + irrevent.MouseInput.Event = irr::EMIE_MMOUSE_LEFT_UP; + MouseButtonStates &= ~irr::EMBSM_MIDDLE; + } + break; + } + + irrevent.MouseInput.ButtonStates = MouseButtonStates; + + if (irrevent.MouseInput.Event != irr::EMIE_MOUSE_MOVED) { + postEventFromUser(irrevent); + + if (irrevent.MouseInput.Event >= EMIE_LMOUSE_PRESSED_DOWN && irrevent.MouseInput.Event <= EMIE_MMOUSE_PRESSED_DOWN) { + u32 clicks = checkSuccessiveClicks(irrevent.MouseInput.X, irrevent.MouseInput.Y, irrevent.MouseInput.Event); + if (clicks == 2) { + irrevent.MouseInput.Event = (EMOUSE_INPUT_EVENT)(EMIE_LMOUSE_DOUBLE_CLICK + irrevent.MouseInput.Event - EMIE_LMOUSE_PRESSED_DOWN); + postEventFromUser(irrevent); + } else if (clicks == 3) { + irrevent.MouseInput.Event = (EMOUSE_INPUT_EVENT)(EMIE_LMOUSE_TRIPLE_CLICK + irrevent.MouseInput.Event - EMIE_LMOUSE_PRESSED_DOWN); + postEventFromUser(irrevent); + } + } + } + break; + } + + case SDL_TEXTINPUT: { + irrevent.EventType = irr::EET_STRING_INPUT_EVENT; + irrevent.StringInput.Str = new core::stringw(); + irr::core::utf8ToWString(*irrevent.StringInput.Str, SDL_event.text.text); + postEventFromUser(irrevent); + delete irrevent.StringInput.Str; + irrevent.StringInput.Str = NULL; + } break; + + case SDL_KEYDOWN: + case SDL_KEYUP: { + SKeyMap mp; + mp.SDLKey = SDL_event.key.keysym.sym; + s32 idx = KeyMap.binary_search(mp); + + EKEY_CODE key; + if (idx == -1) + key = (EKEY_CODE)0; + else + key = (EKEY_CODE)KeyMap[idx].Win32Key; + + if (key == (EKEY_CODE)0) + os::Printer::log("keycode not mapped", core::stringc(mp.SDLKey), ELL_DEBUG); + + // Make sure to only input special characters if something is in focus, as SDL_TEXTINPUT handles normal unicode already + if (SDL_IsTextInputActive() && !keyIsKnownSpecial(key) && (SDL_event.key.keysym.mod & KMOD_CTRL) == 0) + break; + + irrevent.EventType = irr::EET_KEY_INPUT_EVENT; + irrevent.KeyInput.Key = key; + irrevent.KeyInput.PressedDown = (SDL_event.type == SDL_KEYDOWN); + irrevent.KeyInput.Shift = (SDL_event.key.keysym.mod & KMOD_SHIFT) != 0; + irrevent.KeyInput.Control = (SDL_event.key.keysym.mod & KMOD_CTRL) != 0; + irrevent.KeyInput.Char = findCharToPassToIrrlicht(mp.SDLKey, key); + postEventFromUser(irrevent); + } break; + + case SDL_QUIT: + Close = true; + break; + + case SDL_WINDOWEVENT: + switch (SDL_event.window.event) { + case SDL_WINDOWEVENT_RESIZED: + if ((SDL_event.window.data1 != (int)Width) || (SDL_event.window.data2 != (int)Height)) { + Width = SDL_event.window.data1; + Height = SDL_event.window.data2; + if (VideoDriver) + VideoDriver->OnResize(core::dimension2d(Width, Height)); + } + break; + } + + case SDL_USEREVENT: + irrevent.EventType = irr::EET_USER_EVENT; + irrevent.UserEvent.UserData1 = reinterpret_cast(SDL_event.user.data1); + irrevent.UserEvent.UserData2 = reinterpret_cast(SDL_event.user.data2); + + postEventFromUser(irrevent); + break; + + case SDL_FINGERDOWN: + irrevent.EventType = EET_TOUCH_INPUT_EVENT; + irrevent.TouchInput.Event = ETIE_PRESSED_DOWN; + irrevent.TouchInput.ID = SDL_event.tfinger.fingerId; + irrevent.TouchInput.X = SDL_event.tfinger.x * Width; + irrevent.TouchInput.Y = SDL_event.tfinger.y * Height; + CurrentTouchCount++; + irrevent.TouchInput.touchedCount = CurrentTouchCount; + + postEventFromUser(irrevent); + break; + + case SDL_FINGERMOTION: + irrevent.EventType = EET_TOUCH_INPUT_EVENT; + irrevent.TouchInput.Event = ETIE_MOVED; + irrevent.TouchInput.ID = SDL_event.tfinger.fingerId; + irrevent.TouchInput.X = SDL_event.tfinger.x * Width; + irrevent.TouchInput.Y = SDL_event.tfinger.y * Height; + irrevent.TouchInput.touchedCount = CurrentTouchCount; + + postEventFromUser(irrevent); + break; + + case SDL_FINGERUP: + irrevent.EventType = EET_TOUCH_INPUT_EVENT; + irrevent.TouchInput.Event = ETIE_LEFT_UP; + irrevent.TouchInput.ID = SDL_event.tfinger.fingerId; + irrevent.TouchInput.X = SDL_event.tfinger.x * Width; + irrevent.TouchInput.Y = SDL_event.tfinger.y * Height; + // To match Android behavior, still count the pointer that was + // just released. + irrevent.TouchInput.touchedCount = CurrentTouchCount; + if (CurrentTouchCount > 0) { + CurrentTouchCount--; + } + + postEventFromUser(irrevent); + break; + + default: + break; + } // end switch + resetReceiveTextInputEvents(); + } // end while + +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) + // TODO: Check if the multiple open/close calls are too expensive, then + // open/close in the constructor/destructor instead + + // update joystick states manually + SDL_JoystickUpdate(); + // we'll always send joystick input events... + SEvent joyevent; + joyevent.EventType = EET_JOYSTICK_INPUT_EVENT; + for (u32 i = 0; i < Joysticks.size(); ++i) { + SDL_Joystick *joystick = Joysticks[i]; + if (joystick) { + int j; + // query all buttons + const int numButtons = core::min_(SDL_JoystickNumButtons(joystick), 32); + joyevent.JoystickEvent.ButtonStates = 0; + for (j = 0; j < numButtons; ++j) + joyevent.JoystickEvent.ButtonStates |= (SDL_JoystickGetButton(joystick, j) << j); + + // query all axes, already in correct range + const int numAxes = core::min_(SDL_JoystickNumAxes(joystick), (int)SEvent::SJoystickEvent::NUMBER_OF_AXES); + joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_X] = 0; + joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Y] = 0; + joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Z] = 0; + joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_R] = 0; + joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_U] = 0; + joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_V] = 0; + for (j = 0; j < numAxes; ++j) + joyevent.JoystickEvent.Axis[j] = SDL_JoystickGetAxis(joystick, j); + + // we can only query one hat, SDL only supports 8 directions + if (SDL_JoystickNumHats(joystick) > 0) { + switch (SDL_JoystickGetHat(joystick, 0)) { + case SDL_HAT_UP: + joyevent.JoystickEvent.POV = 0; + break; + case SDL_HAT_RIGHTUP: + joyevent.JoystickEvent.POV = 4500; + break; + case SDL_HAT_RIGHT: + joyevent.JoystickEvent.POV = 9000; + break; + case SDL_HAT_RIGHTDOWN: + joyevent.JoystickEvent.POV = 13500; + break; + case SDL_HAT_DOWN: + joyevent.JoystickEvent.POV = 18000; + break; + case SDL_HAT_LEFTDOWN: + joyevent.JoystickEvent.POV = 22500; + break; + case SDL_HAT_LEFT: + joyevent.JoystickEvent.POV = 27000; + break; + case SDL_HAT_LEFTUP: + joyevent.JoystickEvent.POV = 31500; + break; + case SDL_HAT_CENTERED: + default: + joyevent.JoystickEvent.POV = 65535; + break; + } + } else { + joyevent.JoystickEvent.POV = 65535; + } + + // we map the number directly + joyevent.JoystickEvent.Joystick = static_cast(i); + // now post the event + postEventFromUser(joyevent); + // and close the joystick + } + } +#endif + return !Close; +} + +//! Activate any joysticks, and generate events for them. +bool CIrrDeviceSDL::activateJoysticks(core::array &joystickInfo) +{ +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) + joystickInfo.clear(); + + // we can name up to 256 different joysticks + const int numJoysticks = core::min_(SDL_NumJoysticks(), 256); + Joysticks.reallocate(numJoysticks); + joystickInfo.reallocate(numJoysticks); + + int joystick = 0; + for (; joystick < numJoysticks; ++joystick) { + Joysticks.push_back(SDL_JoystickOpen(joystick)); + SJoystickInfo info; + + info.Joystick = joystick; + info.Axes = SDL_JoystickNumAxes(Joysticks[joystick]); + info.Buttons = SDL_JoystickNumButtons(Joysticks[joystick]); + info.Name = SDL_JoystickName(Joysticks[joystick]); + info.PovHat = (SDL_JoystickNumHats(Joysticks[joystick]) > 0) + ? SJoystickInfo::POV_HAT_PRESENT + : SJoystickInfo::POV_HAT_ABSENT; + + joystickInfo.push_back(info); + } + + for (joystick = 0; joystick < (int)joystickInfo.size(); ++joystick) { + char logString[256]; + snprintf_irr(logString, sizeof(logString), "Found joystick %d, %d axes, %d buttons '%s'", + joystick, joystickInfo[joystick].Axes, + joystickInfo[joystick].Buttons, joystickInfo[joystick].Name.c_str()); + os::Printer::log(logString, ELL_INFORMATION); + } + + return true; + +#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ + + return false; +} + +//! Get the display density in dots per inch. +float CIrrDeviceSDL::getDisplayDensity() const +{ + if (!Window) + return 0.0f; + + int window_w; + int window_h; + SDL_GetWindowSize(Window, &window_w, &window_h); + + int drawable_w; + int drawable_h; + SDL_GL_GetDrawableSize(Window, &drawable_w, &drawable_h); + + // assume 96 dpi + float dpi_w = (float)drawable_w / (float)window_w * 96.0f; + float dpi_h = (float)drawable_h / (float)window_h * 96.0f; + + return std::max(dpi_w, dpi_h); +} + +void CIrrDeviceSDL::SwapWindow() +{ + SDL_GL_SwapWindow(Window); +} + +//! pause execution temporarily +void CIrrDeviceSDL::yield() +{ + SDL_Delay(0); +} + +//! pause execution for a specified time +void CIrrDeviceSDL::sleep(u32 timeMs, bool pauseTimer) +{ + const bool wasStopped = Timer ? Timer->isStopped() : true; + if (pauseTimer && !wasStopped) + Timer->stop(); + + SDL_Delay(timeMs); + + if (pauseTimer && !wasStopped) + Timer->start(); +} + +//! sets the caption of the window +void CIrrDeviceSDL::setWindowCaption(const wchar_t *text) +{ + core::stringc textc; + core::wStringToUTF8(textc, text); + SDL_SetWindowTitle(Window, textc.c_str()); +} + +//! Sets the window icon. +bool CIrrDeviceSDL::setWindowIcon(const video::IImage *img) +{ + if (!Window) + return false; + + u32 height = img->getDimension().Height; + u32 width = img->getDimension().Width; + + SDL_Surface *surface = SDL_CreateRGBSurface(0, width, height, 32, + 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); + + if (!surface) { + os::Printer::log("Failed to create SDL suface", ELL_ERROR); + return false; + } + + SDL_LockSurface(surface); + bool succ = img->copyToNoScaling(surface->pixels, width, height, video::ECF_A8R8G8B8, surface->pitch); + SDL_UnlockSurface(surface); + + if (!succ) { + os::Printer::log("Could not copy icon image. Is the format not ECF_A8R8G8B8?", ELL_ERROR); + SDL_FreeSurface(surface); + return false; + } + + SDL_SetWindowIcon(Window, surface); + + SDL_FreeSurface(surface); + + return true; +} + +//! notifies the device that it should close itself +void CIrrDeviceSDL::closeDevice() +{ + Close = true; +} + +//! Sets if the window should be resizable in windowed mode. +void CIrrDeviceSDL::setResizable(bool resize) +{ +#ifdef _IRR_EMSCRIPTEN_PLATFORM_ + os::Printer::log("Resizable not available on the web.", ELL_WARNING); + return; +#else // !_IRR_EMSCRIPTEN_PLATFORM_ + if (resize != Resizable) { + if (resize) + SDL_Flags |= SDL_WINDOW_RESIZABLE; + else + SDL_Flags &= ~SDL_WINDOW_RESIZABLE; + + if (Window) { + SDL_SetWindowResizable(Window, (SDL_bool)resize); + } + Resizable = resize; + } +#endif // !_IRR_EMSCRIPTEN_PLATFORM_ +} + +//! Minimizes window if possible +void CIrrDeviceSDL::minimizeWindow() +{ + if (Window) + SDL_MinimizeWindow(Window); +} + +//! Maximize window +void CIrrDeviceSDL::maximizeWindow() +{ + if (Window) + SDL_MaximizeWindow(Window); +} + +//! Get the position of this window on screen +core::position2di CIrrDeviceSDL::getWindowPosition() +{ + return core::position2di(-1, -1); +} + +//! Restore original window size +void CIrrDeviceSDL::restoreWindow() +{ + if (Window) + SDL_RestoreWindow(Window); +} + +bool CIrrDeviceSDL::isWindowMaximized() const +{ + return Window && (SDL_GetWindowFlags(Window) & SDL_WINDOW_MAXIMIZED) != 0; +} + +bool CIrrDeviceSDL::isFullscreen() const +{ +#ifdef _IRR_EMSCRIPTEN_PLATFORM_ + return SDL_GetWindowFlags(0) == SDL_WINDOW_FULLSCREEN; +#else + + return CIrrDeviceStub::isFullscreen(); +#endif +} + +//! returns if window is active. if not, nothing need to be drawn +bool CIrrDeviceSDL::isWindowActive() const +{ +#ifdef _IRR_EMSCRIPTEN_PLATFORM_ + // Hidden test only does something in some browsers (when tab in background or window is minimized) + // In other browsers code automatically doesn't seem to be called anymore. + EmscriptenVisibilityChangeEvent emVisibility; + if (emscripten_get_visibility_status(&emVisibility) == EMSCRIPTEN_RESULT_SUCCESS) { + if (emVisibility.hidden) + return false; + } +#endif + const u32 windowFlags = SDL_GetWindowFlags(Window); + return windowFlags & SDL_WINDOW_SHOWN && windowFlags & SDL_WINDOW_INPUT_FOCUS; +} + +//! returns if window has focus. +bool CIrrDeviceSDL::isWindowFocused() const +{ + return Window && (SDL_GetWindowFlags(Window) & SDL_WINDOW_INPUT_FOCUS) != 0; +} + +//! returns if window is minimized. +bool CIrrDeviceSDL::isWindowMinimized() const +{ + return Window && (SDL_GetWindowFlags(Window) & SDL_WINDOW_MINIMIZED) != 0; +} + +//! returns color format of the window. +video::ECOLOR_FORMAT CIrrDeviceSDL::getColorFormat() const +{ + if (Window) { + SDL_Surface *surface = SDL_GetWindowSurface(Window); + if (surface->format->BitsPerPixel == 16) { + if (surface->format->Amask != 0) + return video::ECF_A1R5G5B5; + else + return video::ECF_R5G6B5; + } else { + if (surface->format->Amask != 0) + return video::ECF_A8R8G8B8; + else + return video::ECF_R8G8B8; + } + } else + return CIrrDeviceStub::getColorFormat(); +} + +void CIrrDeviceSDL::createKeyMap() +{ + // I don't know if this is the best method to create + // the lookuptable, but I'll leave it like that until + // I find a better version. + + KeyMap.reallocate(105); + + // buttons missing + + KeyMap.push_back(SKeyMap(SDLK_BACKSPACE, KEY_BACK)); + KeyMap.push_back(SKeyMap(SDLK_TAB, KEY_TAB)); + KeyMap.push_back(SKeyMap(SDLK_CLEAR, KEY_CLEAR)); + KeyMap.push_back(SKeyMap(SDLK_RETURN, KEY_RETURN)); + + // combined modifiers missing + + KeyMap.push_back(SKeyMap(SDLK_PAUSE, KEY_PAUSE)); + KeyMap.push_back(SKeyMap(SDLK_CAPSLOCK, KEY_CAPITAL)); + + // asian letter keys missing + + KeyMap.push_back(SKeyMap(SDLK_ESCAPE, KEY_ESCAPE)); + + // asian letter keys missing + + KeyMap.push_back(SKeyMap(SDLK_SPACE, KEY_SPACE)); + KeyMap.push_back(SKeyMap(SDLK_PAGEUP, KEY_PRIOR)); + KeyMap.push_back(SKeyMap(SDLK_PAGEDOWN, KEY_NEXT)); + KeyMap.push_back(SKeyMap(SDLK_END, KEY_END)); + KeyMap.push_back(SKeyMap(SDLK_HOME, KEY_HOME)); + KeyMap.push_back(SKeyMap(SDLK_LEFT, KEY_LEFT)); + KeyMap.push_back(SKeyMap(SDLK_UP, KEY_UP)); + KeyMap.push_back(SKeyMap(SDLK_RIGHT, KEY_RIGHT)); + KeyMap.push_back(SKeyMap(SDLK_DOWN, KEY_DOWN)); + + // select missing + KeyMap.push_back(SKeyMap(SDLK_PRINTSCREEN, KEY_PRINT)); + // execute missing + KeyMap.push_back(SKeyMap(SDLK_PRINTSCREEN, KEY_SNAPSHOT)); + + KeyMap.push_back(SKeyMap(SDLK_INSERT, KEY_INSERT)); + KeyMap.push_back(SKeyMap(SDLK_DELETE, KEY_DELETE)); + KeyMap.push_back(SKeyMap(SDLK_HELP, KEY_HELP)); + + KeyMap.push_back(SKeyMap(SDLK_0, KEY_KEY_0)); + KeyMap.push_back(SKeyMap(SDLK_1, KEY_KEY_1)); + KeyMap.push_back(SKeyMap(SDLK_2, KEY_KEY_2)); + KeyMap.push_back(SKeyMap(SDLK_3, KEY_KEY_3)); + KeyMap.push_back(SKeyMap(SDLK_4, KEY_KEY_4)); + KeyMap.push_back(SKeyMap(SDLK_5, KEY_KEY_5)); + KeyMap.push_back(SKeyMap(SDLK_6, KEY_KEY_6)); + KeyMap.push_back(SKeyMap(SDLK_7, KEY_KEY_7)); + KeyMap.push_back(SKeyMap(SDLK_8, KEY_KEY_8)); + KeyMap.push_back(SKeyMap(SDLK_9, KEY_KEY_9)); + + KeyMap.push_back(SKeyMap(SDLK_a, KEY_KEY_A)); + KeyMap.push_back(SKeyMap(SDLK_b, KEY_KEY_B)); + KeyMap.push_back(SKeyMap(SDLK_c, KEY_KEY_C)); + KeyMap.push_back(SKeyMap(SDLK_d, KEY_KEY_D)); + KeyMap.push_back(SKeyMap(SDLK_e, KEY_KEY_E)); + KeyMap.push_back(SKeyMap(SDLK_f, KEY_KEY_F)); + KeyMap.push_back(SKeyMap(SDLK_g, KEY_KEY_G)); + KeyMap.push_back(SKeyMap(SDLK_h, KEY_KEY_H)); + KeyMap.push_back(SKeyMap(SDLK_i, KEY_KEY_I)); + KeyMap.push_back(SKeyMap(SDLK_j, KEY_KEY_J)); + KeyMap.push_back(SKeyMap(SDLK_k, KEY_KEY_K)); + KeyMap.push_back(SKeyMap(SDLK_l, KEY_KEY_L)); + KeyMap.push_back(SKeyMap(SDLK_m, KEY_KEY_M)); + KeyMap.push_back(SKeyMap(SDLK_n, KEY_KEY_N)); + KeyMap.push_back(SKeyMap(SDLK_o, KEY_KEY_O)); + KeyMap.push_back(SKeyMap(SDLK_p, KEY_KEY_P)); + KeyMap.push_back(SKeyMap(SDLK_q, KEY_KEY_Q)); + KeyMap.push_back(SKeyMap(SDLK_r, KEY_KEY_R)); + KeyMap.push_back(SKeyMap(SDLK_s, KEY_KEY_S)); + KeyMap.push_back(SKeyMap(SDLK_t, KEY_KEY_T)); + KeyMap.push_back(SKeyMap(SDLK_u, KEY_KEY_U)); + KeyMap.push_back(SKeyMap(SDLK_v, KEY_KEY_V)); + KeyMap.push_back(SKeyMap(SDLK_w, KEY_KEY_W)); + KeyMap.push_back(SKeyMap(SDLK_x, KEY_KEY_X)); + KeyMap.push_back(SKeyMap(SDLK_y, KEY_KEY_Y)); + KeyMap.push_back(SKeyMap(SDLK_z, KEY_KEY_Z)); + + KeyMap.push_back(SKeyMap(SDLK_LGUI, KEY_LWIN)); + KeyMap.push_back(SKeyMap(SDLK_RGUI, KEY_RWIN)); + // apps missing + KeyMap.push_back(SKeyMap(SDLK_POWER, KEY_SLEEP)); //?? + + KeyMap.push_back(SKeyMap(SDLK_KP_0, KEY_NUMPAD0)); + KeyMap.push_back(SKeyMap(SDLK_KP_1, KEY_NUMPAD1)); + KeyMap.push_back(SKeyMap(SDLK_KP_2, KEY_NUMPAD2)); + KeyMap.push_back(SKeyMap(SDLK_KP_3, KEY_NUMPAD3)); + KeyMap.push_back(SKeyMap(SDLK_KP_4, KEY_NUMPAD4)); + KeyMap.push_back(SKeyMap(SDLK_KP_5, KEY_NUMPAD5)); + KeyMap.push_back(SKeyMap(SDLK_KP_6, KEY_NUMPAD6)); + KeyMap.push_back(SKeyMap(SDLK_KP_7, KEY_NUMPAD7)); + KeyMap.push_back(SKeyMap(SDLK_KP_8, KEY_NUMPAD8)); + KeyMap.push_back(SKeyMap(SDLK_KP_9, KEY_NUMPAD9)); + KeyMap.push_back(SKeyMap(SDLK_KP_MULTIPLY, KEY_MULTIPLY)); + KeyMap.push_back(SKeyMap(SDLK_KP_PLUS, KEY_ADD)); + KeyMap.push_back(SKeyMap(SDLK_KP_ENTER, KEY_RETURN)); + KeyMap.push_back(SKeyMap(SDLK_KP_MINUS, KEY_SUBTRACT)); + KeyMap.push_back(SKeyMap(SDLK_KP_PERIOD, KEY_DECIMAL)); + KeyMap.push_back(SKeyMap(SDLK_KP_DIVIDE, KEY_DIVIDE)); + + KeyMap.push_back(SKeyMap(SDLK_F1, KEY_F1)); + KeyMap.push_back(SKeyMap(SDLK_F2, KEY_F2)); + KeyMap.push_back(SKeyMap(SDLK_F3, KEY_F3)); + KeyMap.push_back(SKeyMap(SDLK_F4, KEY_F4)); + KeyMap.push_back(SKeyMap(SDLK_F5, KEY_F5)); + KeyMap.push_back(SKeyMap(SDLK_F6, KEY_F6)); + KeyMap.push_back(SKeyMap(SDLK_F7, KEY_F7)); + KeyMap.push_back(SKeyMap(SDLK_F8, KEY_F8)); + KeyMap.push_back(SKeyMap(SDLK_F9, KEY_F9)); + KeyMap.push_back(SKeyMap(SDLK_F10, KEY_F10)); + KeyMap.push_back(SKeyMap(SDLK_F11, KEY_F11)); + KeyMap.push_back(SKeyMap(SDLK_F12, KEY_F12)); + KeyMap.push_back(SKeyMap(SDLK_F13, KEY_F13)); + KeyMap.push_back(SKeyMap(SDLK_F14, KEY_F14)); + KeyMap.push_back(SKeyMap(SDLK_F15, KEY_F15)); + // no higher F-keys + + KeyMap.push_back(SKeyMap(SDLK_NUMLOCKCLEAR, KEY_NUMLOCK)); + KeyMap.push_back(SKeyMap(SDLK_SCROLLLOCK, KEY_SCROLL)); + KeyMap.push_back(SKeyMap(SDLK_LSHIFT, KEY_LSHIFT)); + KeyMap.push_back(SKeyMap(SDLK_RSHIFT, KEY_RSHIFT)); + KeyMap.push_back(SKeyMap(SDLK_LCTRL, KEY_LCONTROL)); + KeyMap.push_back(SKeyMap(SDLK_RCTRL, KEY_RCONTROL)); + KeyMap.push_back(SKeyMap(SDLK_LALT, KEY_LMENU)); + KeyMap.push_back(SKeyMap(SDLK_RALT, KEY_RMENU)); + + KeyMap.push_back(SKeyMap(SDLK_PLUS, KEY_PLUS)); + KeyMap.push_back(SKeyMap(SDLK_COMMA, KEY_COMMA)); + KeyMap.push_back(SKeyMap(SDLK_MINUS, KEY_MINUS)); + KeyMap.push_back(SKeyMap(SDLK_PERIOD, KEY_PERIOD)); + + // some special keys missing + + KeyMap.sort(); +} + +void CIrrDeviceSDL::CCursorControl::initCursors() +{ + Cursors.reserve(gui::ECI_COUNT); + + Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW)); // ECI_NORMAL + Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_CROSSHAIR)); // ECI_CROSS + Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND)); // ECI_HAND + Cursors.emplace_back(nullptr); // ECI_HELP + Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM)); // ECI_IBEAM + Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO)); // ECI_NO + Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT)); // ECI_WAIT + Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL)); // ECI_SIZEALL + Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW)); // ECI_SIZENESW + Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE)); // ECI_SIZENWSE + Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS)); // ECI_SIZENS + Cursors.emplace_back(SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE)); // ECI_SIZEWE + Cursors.emplace_back(nullptr); // ECI_UP +} + +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_SDL_DEVICE_ diff --git a/irr/src/CIrrDeviceSDL.h b/irr/src/CIrrDeviceSDL.h new file mode 100644 index 000000000..b1e2a7858 --- /dev/null +++ b/irr/src/CIrrDeviceSDL.h @@ -0,0 +1,326 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h +// This device code is based on the original SDL device implementation +// contributed by Shane Parker (sirshane). + +#pragma once + +#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ + +#include "IrrlichtDevice.h" +#include "CIrrDeviceStub.h" +#include "ICursorControl.h" + +#ifdef _IRR_EMSCRIPTEN_PLATFORM_ +#include +#endif + +#include +// DirectFB is removed in SDL3, thou distribution as Alpine currently ships SDL2 +// with enabled DirectFB, but requiring another fix at a top of SDL2. +// We don't need DirectFB in Irrlicht/Minetest, so simply disable it here to prevent issues. +#undef SDL_VIDEO_DRIVER_DIRECTFB +#include + +#include + +namespace irr +{ + +class CIrrDeviceSDL : public CIrrDeviceStub +{ +public: + //! constructor + CIrrDeviceSDL(const SIrrlichtCreationParameters ¶m); + + //! destructor + virtual ~CIrrDeviceSDL(); + + //! runs the device. Returns false if device wants to be deleted + bool run() override; + + //! pause execution temporarily + void yield() override; + + //! pause execution for a specified time + void sleep(u32 timeMs, bool pauseTimer) override; + + //! sets the caption of the window + void setWindowCaption(const wchar_t *text) override; + + //! Sets the window icon. + bool setWindowIcon(const video::IImage *img) override; + + //! returns if window is active. if not, nothing need to be drawn + bool isWindowActive() const override; + + //! returns if window has focus. + bool isWindowFocused() const override; + + //! returns if window is minimized. + bool isWindowMinimized() const override; + + //! returns color format of the window. + video::ECOLOR_FORMAT getColorFormat() const override; + + //! notifies the device that it should close itself + void closeDevice() override; + + //! Sets if the window should be resizable in windowed mode. + void setResizable(bool resize = false) override; + + //! Minimizes the window. + void minimizeWindow() override; + + //! Maximizes the window. + void maximizeWindow() override; + + //! Restores the window size. + void restoreWindow() override; + + //! Checks if the window is maximized. + bool isWindowMaximized() const override; + + //! Checks if the Irrlicht window is running in fullscreen mode + /** \return True if window is fullscreen. */ + bool isFullscreen() const override; + + //! Get the position of this window on screen + core::position2di getWindowPosition() override; + + //! Activate any joysticks, and generate events for them. + bool activateJoysticks(core::array &joystickInfo) override; + + //! Get the device type + E_DEVICE_TYPE getType() const override + { + return EIDT_SDL; + } + + //! Get the display density in dots per inch. + float getDisplayDensity() const override; + + void SwapWindow(); + + //! Implementation of the linux cursor control + class CCursorControl : public gui::ICursorControl + { + public: + CCursorControl(CIrrDeviceSDL *dev) : + Device(dev), IsVisible(true) + { + initCursors(); + } + + //! Changes the visible state of the mouse cursor. + void setVisible(bool visible) override + { + IsVisible = visible; + if (visible) + SDL_ShowCursor(SDL_ENABLE); + else { + SDL_ShowCursor(SDL_DISABLE); + } + } + + //! Returns if the cursor is currently visible. + bool isVisible() const override + { + return IsVisible; + } + + //! Sets the new position of the cursor. + void setPosition(const core::position2d &pos) override + { + setPosition(pos.X, pos.Y); + } + + //! Sets the new position of the cursor. + void setPosition(f32 x, f32 y) override + { + setPosition((s32)(x * Device->Width), (s32)(y * Device->Height)); + } + + //! Sets the new position of the cursor. + void setPosition(const core::position2d &pos) override + { + setPosition(pos.X, pos.Y); + } + + //! Sets the new position of the cursor. + void setPosition(s32 x, s32 y) override + { + SDL_WarpMouseInWindow(Device->Window, x, y); + + if (SDL_GetRelativeMouseMode()) { + // There won't be an event for this warp (details on libsdl-org/SDL/issues/6034) + Device->MouseX = x; + Device->MouseY = y; + } + } + + //! Returns the current position of the mouse cursor. + const core::position2d &getPosition(bool updateCursor) override + { + if (updateCursor) + updateCursorPos(); + return CursorPos; + } + + //! Returns the current position of the mouse cursor. + core::position2d getRelativePosition(bool updateCursor) override + { + if (updateCursor) + updateCursorPos(); + return core::position2d(CursorPos.X / (f32)Device->Width, + CursorPos.Y / (f32)Device->Height); + } + + void setReferenceRect(core::rect *rect = 0) override + { + } + + virtual void setRelativeMode(bool relative) _IRR_OVERRIDE_ + { + // Only change it when necessary, as it flushes mouse motion when enabled + if (relative != SDL_GetRelativeMouseMode()) { + if (relative) + SDL_SetRelativeMouseMode(SDL_TRUE); + else + SDL_SetRelativeMouseMode(SDL_FALSE); + } + } + + void setActiveIcon(gui::ECURSOR_ICON iconId) override + { + ActiveIcon = iconId; + if (iconId > Cursors.size() || !Cursors[iconId]) { + iconId = gui::ECI_NORMAL; + if (iconId > Cursors.size() || !Cursors[iconId]) + return; + } + SDL_SetCursor(Cursors[iconId].get()); + } + + gui::ECURSOR_ICON getActiveIcon() const override + { + return ActiveIcon; + } + + private: + void updateCursorPos() + { +#ifdef _IRR_EMSCRIPTEN_PLATFORM_ + EmscriptenPointerlockChangeEvent pointerlockStatus; // let's hope that test is not expensive ... + if (emscripten_get_pointerlock_status(&pointerlockStatus) == EMSCRIPTEN_RESULT_SUCCESS) { + if (pointerlockStatus.isActive) { + CursorPos.X += Device->MouseXRel; + CursorPos.Y += Device->MouseYRel; + Device->MouseXRel = 0; + Device->MouseYRel = 0; + } else { + CursorPos.X = Device->MouseX; + CursorPos.Y = Device->MouseY; + } + } +#else + CursorPos.X = Device->MouseX; + CursorPos.Y = Device->MouseY; + + if (CursorPos.X < 0) + CursorPos.X = 0; + if (CursorPos.X > (s32)Device->Width) + CursorPos.X = Device->Width; + if (CursorPos.Y < 0) + CursorPos.Y = 0; + if (CursorPos.Y > (s32)Device->Height) + CursorPos.Y = Device->Height; +#endif + } + + void initCursors(); + + CIrrDeviceSDL *Device; + core::position2d CursorPos; + bool IsVisible; + + struct CursorDeleter + { + void operator()(SDL_Cursor *ptr) + { + if (ptr) + SDL_FreeCursor(ptr); + } + }; + std::vector> Cursors; + gui::ECURSOR_ICON ActiveIcon = gui::ECURSOR_ICON::ECI_NORMAL; + }; + +private: +#ifdef _IRR_EMSCRIPTEN_PLATFORM_ + static EM_BOOL MouseUpDownCallback(int eventType, const EmscriptenMouseEvent *event, void *userData); + static EM_BOOL MouseEnterCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData); + static EM_BOOL MouseLeaveCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData); + +#endif + // Check if a key is a known special character with no side effects on text boxes. + static bool keyIsKnownSpecial(EKEY_CODE key); + + // Return the Char that should be sent to Irrlicht for the given key (either the one passed in or 0). + static int findCharToPassToIrrlicht(int assumedChar, EKEY_CODE key); + + // Check if a text box is in focus. Enable or disable SDL_TEXTINPUT events only if in focus. + void resetReceiveTextInputEvents(); + + //! create the driver + void createDriver(); + + bool createWindow(); + + void createKeyMap(); + + void logAttributes(); + SDL_GLContext Context; + SDL_Window *Window; + int SDL_Flags; +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) + core::array Joysticks; +#endif + + s32 MouseX, MouseY; + s32 MouseXRel, MouseYRel; + u32 MouseButtonStates; + + u32 Width, Height; + + bool Resizable; + + core::rect lastElemPos; + + struct SKeyMap + { + SKeyMap() {} + SKeyMap(s32 x11, s32 win32) : + SDLKey(x11), Win32Key(win32) + { + } + + s32 SDLKey; + s32 Win32Key; + + bool operator<(const SKeyMap &o) const + { + return SDLKey < o.SDLKey; + } + }; + + core::array KeyMap; + SDL_SysWMinfo Info; + + s32 CurrentTouchCount; +}; + +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_SDL_DEVICE_ diff --git a/irr/src/CIrrDeviceStub.cpp b/irr/src/CIrrDeviceStub.cpp new file mode 100644 index 000000000..2292db191 --- /dev/null +++ b/irr/src/CIrrDeviceStub.cpp @@ -0,0 +1,376 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CIrrDeviceStub.h" +#include "ISceneManager.h" +#include "IEventReceiver.h" +#include "IFileSystem.h" +#include "IGUIElement.h" +#include "IGUIEnvironment.h" +#include "os.h" +#include "CTimer.h" +#include "CLogger.h" +#include "irrString.h" +#include "IrrCompileConfig.h" // for IRRLICHT_SDK_VERSION + +namespace irr +{ +//! constructor +CIrrDeviceStub::CIrrDeviceStub(const SIrrlichtCreationParameters ¶ms) : + IrrlichtDevice(), VideoDriver(0), GUIEnvironment(0), SceneManager(0), + Timer(0), CursorControl(0), UserReceiver(params.EventReceiver), + Logger(0), Operator(0), FileSystem(0), + InputReceivingSceneManager(0), ContextManager(0), + CreationParams(params), Close(false) +{ + Timer = new CTimer(); + if (os::Printer::Logger) { + os::Printer::Logger->grab(); + Logger = (CLogger *)os::Printer::Logger; + Logger->setReceiver(UserReceiver); + } else { + Logger = new CLogger(UserReceiver); + os::Printer::Logger = Logger; + } + Logger->setLogLevel(CreationParams.LoggingLevel); + + os::Printer::Logger = Logger; + + FileSystem = io::createFileSystem(); + + core::stringc s = "Irrlicht Engine version "; + s.append(getVersion()); + os::Printer::log(s.c_str(), ELL_INFORMATION); + + checkVersion(params.SDK_version_do_not_use); +} + +CIrrDeviceStub::~CIrrDeviceStub() +{ + if (GUIEnvironment) + GUIEnvironment->drop(); + + if (SceneManager) + SceneManager->drop(); + + if (VideoDriver) + VideoDriver->drop(); + + if (ContextManager) + ContextManager->drop(); + + if (FileSystem) + FileSystem->drop(); + + if (InputReceivingSceneManager) + InputReceivingSceneManager->drop(); + + if (CursorControl) + CursorControl->drop(); + + if (Operator) + Operator->drop(); + + CursorControl = 0; + + if (Timer) + Timer->drop(); + + if (Logger->drop()) + os::Printer::Logger = 0; +} + +void CIrrDeviceStub::createGUIAndScene() +{ + // create gui environment + GUIEnvironment = gui::createGUIEnvironment(FileSystem, VideoDriver, Operator); + + // create Scene manager + SceneManager = scene::createSceneManager(VideoDriver, CursorControl); + + setEventReceiver(UserReceiver); +} + +//! returns the video driver +video::IVideoDriver *CIrrDeviceStub::getVideoDriver() +{ + return VideoDriver; +} + +//! return file system +io::IFileSystem *CIrrDeviceStub::getFileSystem() +{ + return FileSystem; +} + +//! returns the gui environment +gui::IGUIEnvironment *CIrrDeviceStub::getGUIEnvironment() +{ + return GUIEnvironment; +} + +//! returns the scene manager +scene::ISceneManager *CIrrDeviceStub::getSceneManager() +{ + return SceneManager; +} + +//! \return Returns a pointer to the ITimer object. With it the +//! current Time can be received. +ITimer *CIrrDeviceStub::getTimer() +{ + return Timer; +} + +//! Sets the window icon. +bool CIrrDeviceStub::setWindowIcon(const video::IImage *img) +{ + return false; +} + +//! Returns the version of the engine. +const char *CIrrDeviceStub::getVersion() const +{ + return IRRLICHT_SDK_VERSION; +} + +//! \return Returns a pointer to the mouse cursor control interface. +gui::ICursorControl *CIrrDeviceStub::getCursorControl() +{ + return CursorControl; +} + +//! return the context manager +video::IContextManager *CIrrDeviceStub::getContextManager() +{ + return ContextManager; +} + +//! checks version of sdk and prints warning if there might be a problem +bool CIrrDeviceStub::checkVersion(const char *version) +{ + if (strcmp(getVersion(), version)) { + core::stringc w; + w = "Warning: The library version of the Irrlicht Engine ("; + w += getVersion(); + w += ") does not match the version the application was compiled with ("; + w += version; + w += "). This may cause problems."; + os::Printer::log(w.c_str(), ELL_WARNING); + + return false; + } + + return true; +} + +//! Compares to the last call of this function to return double and triple clicks. +u32 CIrrDeviceStub::checkSuccessiveClicks(s32 mouseX, s32 mouseY, EMOUSE_INPUT_EVENT inputEvent) +{ + const s32 MAX_MOUSEMOVE = 3; + + irr::u32 clickTime = getTimer()->getRealTime(); + + if ((clickTime - MouseMultiClicks.LastClickTime) < MouseMultiClicks.DoubleClickTime && core::abs_(MouseMultiClicks.LastClick.X - mouseX) <= MAX_MOUSEMOVE && core::abs_(MouseMultiClicks.LastClick.Y - mouseY) <= MAX_MOUSEMOVE && MouseMultiClicks.CountSuccessiveClicks < 3 && MouseMultiClicks.LastMouseInputEvent == inputEvent) { + ++MouseMultiClicks.CountSuccessiveClicks; + } else { + MouseMultiClicks.CountSuccessiveClicks = 1; + } + + MouseMultiClicks.LastMouseInputEvent = inputEvent; + MouseMultiClicks.LastClickTime = clickTime; + MouseMultiClicks.LastClick.X = mouseX; + MouseMultiClicks.LastClick.Y = mouseY; + + return MouseMultiClicks.CountSuccessiveClicks; +} + +//! send the event to the right receiver +bool CIrrDeviceStub::postEventFromUser(const SEvent &event) +{ + bool absorbed = false; + + if (UserReceiver) + absorbed = UserReceiver->OnEvent(event); + + if (!absorbed && GUIEnvironment) + absorbed = GUIEnvironment->postEventFromUser(event); + + scene::ISceneManager *inputReceiver = InputReceivingSceneManager; + if (!inputReceiver) + inputReceiver = SceneManager; + + if (!absorbed && inputReceiver) + absorbed = inputReceiver->postEventFromUser(event); + + return absorbed; +} + +//! Sets a new event receiver to receive events +void CIrrDeviceStub::setEventReceiver(IEventReceiver *receiver) +{ + UserReceiver = receiver; + Logger->setReceiver(receiver); + if (GUIEnvironment) + GUIEnvironment->setUserEventReceiver(receiver); +} + +//! Returns poinhter to the current event receiver. Returns 0 if there is none. +IEventReceiver *CIrrDeviceStub::getEventReceiver() +{ + return UserReceiver; +} + +//! \return Returns a pointer to the logger. +ILogger *CIrrDeviceStub::getLogger() +{ + return Logger; +} + +//! Returns the operation system opertator object. +IOSOperator *CIrrDeviceStub::getOSOperator() +{ + return Operator; +} + +//! Sets the input receiving scene manager. +void CIrrDeviceStub::setInputReceivingSceneManager(scene::ISceneManager *sceneManager) +{ + if (sceneManager) + sceneManager->grab(); + if (InputReceivingSceneManager) + InputReceivingSceneManager->drop(); + + InputReceivingSceneManager = sceneManager; +} + +//! Checks if the window is maximized. +bool CIrrDeviceStub::isWindowMaximized() const +{ + return false; +} + +//! Checks if the window is running in fullscreen mode +bool CIrrDeviceStub::isFullscreen() const +{ + return CreationParams.Fullscreen; +} + +//! returns color format +video::ECOLOR_FORMAT CIrrDeviceStub::getColorFormat() const +{ + return video::ECF_R5G6B5; +} + +//! No-op in this implementation +bool CIrrDeviceStub::activateJoysticks(core::array &joystickInfo) +{ + return false; +} + +//! No-op in this implementation +bool CIrrDeviceStub::activateAccelerometer(float updateInterval) +{ + return false; +} + +//! No-op in this implementation +bool CIrrDeviceStub::deactivateAccelerometer() +{ + return false; +} + +//! No-op in this implementation +bool CIrrDeviceStub::isAccelerometerActive() +{ + return false; +} + +//! No-op in this implementation +bool CIrrDeviceStub::isAccelerometerAvailable() +{ + return false; +} + +//! No-op in this implementation +bool CIrrDeviceStub::activateGyroscope(float updateInterval) +{ + return false; +} + +//! No-op in this implementation +bool CIrrDeviceStub::deactivateGyroscope() +{ + return false; +} + +//! No-op in this implementation +bool CIrrDeviceStub::isGyroscopeActive() +{ + return false; +} + +//! No-op in this implementation +bool CIrrDeviceStub::isGyroscopeAvailable() +{ + return false; +} + +//! No-op in this implementation +bool CIrrDeviceStub::activateDeviceMotion(float updateInterval) +{ + return false; +} + +//! No-op in this implementation +bool CIrrDeviceStub::deactivateDeviceMotion() +{ + return false; +} + +//! No-op in this implementation +bool CIrrDeviceStub::isDeviceMotionActive() +{ + return false; +} + +//! No-op in this implementation +bool CIrrDeviceStub::isDeviceMotionAvailable() +{ + return false; +} + +//! Set the maximal elapsed time between 2 clicks to generate doubleclicks for the mouse. It also affects tripleclick behavior. +void CIrrDeviceStub::setDoubleClickTime(u32 timeMs) +{ + MouseMultiClicks.DoubleClickTime = timeMs; +} + +//! Get the maximal elapsed time between 2 clicks to generate double- and tripleclicks for the mouse. +u32 CIrrDeviceStub::getDoubleClickTime() const +{ + return MouseMultiClicks.DoubleClickTime; +} + +//! Remove all messages pending in the system message loop +void CIrrDeviceStub::clearSystemMessages() +{ +} + +//! Get the display density in dots per inch. +float CIrrDeviceStub::getDisplayDensity() const +{ + return 0.0f; +} + +//! Checks whether the input device should take input from the IME +bool CIrrDeviceStub::acceptsIME() +{ + if (!GUIEnvironment) + return false; + gui::IGUIElement *elem = GUIEnvironment->getFocus(); + return elem && elem->acceptsIME(); +} + +} // end namespace irr diff --git a/irr/src/CIrrDeviceStub.h b/irr/src/CIrrDeviceStub.h new file mode 100644 index 000000000..163e44f39 --- /dev/null +++ b/irr/src/CIrrDeviceStub.h @@ -0,0 +1,204 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IrrlichtDevice.h" +#include "SIrrCreationParameters.h" +#include "IContextManager.h" + +namespace irr +{ +// lots of prototypes: +class ILogger; +class CLogger; + +namespace gui +{ +class IGUIEnvironment; +IGUIEnvironment *createGUIEnvironment(io::IFileSystem *fs, + video::IVideoDriver *Driver, IOSOperator *op); +} + +namespace scene +{ +ISceneManager *createSceneManager(video::IVideoDriver *driver, gui::ICursorControl *cc); +} + +namespace io +{ +IFileSystem *createFileSystem(); +} + +namespace video +{ +IVideoDriver *createNullDriver(io::IFileSystem *io, const core::dimension2d &screenSize); +} + +//! Stub for an Irrlicht Device implementation +class CIrrDeviceStub : public IrrlichtDevice +{ +public: + //! constructor + CIrrDeviceStub(const SIrrlichtCreationParameters ¶m); + + //! destructor + virtual ~CIrrDeviceStub(); + + //! returns the video driver + video::IVideoDriver *getVideoDriver() override; + + //! return file system + io::IFileSystem *getFileSystem() override; + + //! returns the gui environment + gui::IGUIEnvironment *getGUIEnvironment() override; + + //! returns the scene manager + scene::ISceneManager *getSceneManager() override; + + //! \return Returns a pointer to the mouse cursor control interface. + gui::ICursorControl *getCursorControl() override; + + //! return the context manager + video::IContextManager *getContextManager() override; + + //! Returns a pointer to the ITimer object. With it the current Time can be received. + ITimer *getTimer() override; + + //! Sets the window icon. + bool setWindowIcon(const video::IImage *img) override; + + //! Returns the version of the engine. + const char *getVersion() const override; + + //! send the event to the right receiver + bool postEventFromUser(const SEvent &event) override; + + //! Sets a new event receiver to receive events + void setEventReceiver(IEventReceiver *receiver) override; + + //! Returns pointer to the current event receiver. Returns 0 if there is none. + IEventReceiver *getEventReceiver() override; + + //! Sets the input receiving scene manager. + /** If set to null, the main scene manager (returned by GetSceneManager()) will receive the input */ + void setInputReceivingSceneManager(scene::ISceneManager *sceneManager) override; + + //! Returns a pointer to the logger. + ILogger *getLogger() override; + + //! Returns the operation system opertator object. + IOSOperator *getOSOperator() override; + + //! Checks if the window is maximized. + bool isWindowMaximized() const override; + + //! Checks if the window is running in fullscreen mode. + bool isFullscreen() const override; + + //! get color format of the current window + video::ECOLOR_FORMAT getColorFormat() const override; + + //! Activate any joysticks, and generate events for them. + bool activateJoysticks(core::array &joystickInfo) override; + + //! Activate accelerometer. + bool activateAccelerometer(float updateInterval = 0.016666f) override; + + //! Deactivate accelerometer. + bool deactivateAccelerometer() override; + + //! Is accelerometer active. + bool isAccelerometerActive() override; + + //! Is accelerometer available. + bool isAccelerometerAvailable() override; + + //! Activate gyroscope. + bool activateGyroscope(float updateInterval = 0.016666f) override; + + //! Deactivate gyroscope. + bool deactivateGyroscope() override; + + //! Is gyroscope active. + bool isGyroscopeActive() override; + + //! Is gyroscope available. + bool isGyroscopeAvailable() override; + + //! Activate device motion. + bool activateDeviceMotion(float updateInterval = 0.016666f) override; + + //! Deactivate device motion. + bool deactivateDeviceMotion() override; + + //! Is device motion active. + bool isDeviceMotionActive() override; + + //! Is device motion available. + bool isDeviceMotionAvailable() override; + + //! Set the maximal elapsed time between 2 clicks to generate doubleclicks for the mouse. It also affects tripleclick behavior. + //! When set to 0 no double- and tripleclicks will be generated. + void setDoubleClickTime(u32 timeMs) override; + + //! Get the maximal elapsed time between 2 clicks to generate double- and tripleclicks for the mouse. + u32 getDoubleClickTime() const override; + + //! Remove all messages pending in the system message loop + void clearSystemMessages() override; + + //! Get the display density in dots per inch. + float getDisplayDensity() const override; + + //! Resize the render window. + void setWindowSize(const irr::core::dimension2d &size) override {} + +protected: + void createGUIAndScene(); + + //! checks version of SDK and prints warning if there might be a problem + bool checkVersion(const char *version); + + //! Compares to the last call of this function to return double and triple clicks. + /** Needed for win32 device event handling + \return Returns only 1,2 or 3. A 4th click will start with 1 again. + */ + virtual u32 checkSuccessiveClicks(s32 mouseX, s32 mouseY, EMOUSE_INPUT_EVENT inputEvent); + + //! Checks whether the input device should take input from the IME + bool acceptsIME(); + + video::IVideoDriver *VideoDriver; + gui::IGUIEnvironment *GUIEnvironment; + scene::ISceneManager *SceneManager; + ITimer *Timer; + gui::ICursorControl *CursorControl; + IEventReceiver *UserReceiver; + CLogger *Logger; + IOSOperator *Operator; + io::IFileSystem *FileSystem; + scene::ISceneManager *InputReceivingSceneManager; + + struct SMouseMultiClicks + { + SMouseMultiClicks() : + DoubleClickTime(500), CountSuccessiveClicks(0), LastClickTime(0), LastMouseInputEvent(EMIE_COUNT) + { + } + + u32 DoubleClickTime; + u32 CountSuccessiveClicks; + u32 LastClickTime; + core::position2di LastClick; + EMOUSE_INPUT_EVENT LastMouseInputEvent; + }; + SMouseMultiClicks MouseMultiClicks; + video::IContextManager *ContextManager; + SIrrlichtCreationParameters CreationParams; + bool Close; +}; + +} // end namespace irr diff --git a/irr/src/CIrrDeviceWin32.cpp b/irr/src/CIrrDeviceWin32.cpp new file mode 100644 index 000000000..c2876fcce --- /dev/null +++ b/irr/src/CIrrDeviceWin32.cpp @@ -0,0 +1,1474 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ + +#if defined(__STRICT_ANSI__) +#error Compiling with __STRICT_ANSI__ not supported. g++ does set this when compiling with -std=c++11 or -std=c++0x. Use instead -std=gnu++11 or -std=gnu++0x. Or use -U__STRICT_ANSI__ to disable strict ansi. +#endif + +#include "CIrrDeviceWin32.h" +#include "IEventReceiver.h" +#include "os.h" + +#include "CTimer.h" +#include "irrString.h" +#include "COSOperator.h" +#include "dimension2d.h" +#include "IGUISpriteBank.h" +#include +#include "SExposedVideoData.h" + +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) +#include +#include +#ifdef _IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_ +#define DIRECTINPUT_VERSION 0x0800 +#include +#endif +#endif + +#if defined(_IRR_COMPILE_WITH_OGLES1_) || defined(_IRR_COMPILE_WITH_OGLES2_) +#include "CEGLManager.h" +#endif + +#if defined(_IRR_COMPILE_WITH_OPENGL_) +#include "CWGLManager.h" +#endif + +namespace irr +{ +namespace video +{ +#ifdef _IRR_COMPILE_WITH_OPENGL_ +IVideoDriver *createOpenGLDriver(const irr::SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager); +#endif + +#ifdef _IRR_COMPILE_WITH_OGLES1_ +IVideoDriver *createOGLES1Driver(const irr::SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager); +#endif + +#ifdef _IRR_COMPILE_WITH_OGLES2_ +IVideoDriver *createOGLES2Driver(const irr::SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager); +#endif +} +} // end namespace irr + +namespace irr +{ +struct SJoystickWin32Control +{ + CIrrDeviceWin32 *Device; + +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) && defined(_IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_) + IDirectInput8 *DirectInputDevice; +#endif +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) + struct JoystickInfo + { + u32 Index; +#ifdef _IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_ + core::stringc Name; + GUID guid; + LPDIRECTINPUTDEVICE8 lpdijoy; + DIDEVCAPS devcaps; + u8 axisValid[8]; +#else + JOYCAPS Caps; +#endif + }; + core::array ActiveJoysticks; +#endif + + SJoystickWin32Control(CIrrDeviceWin32 *dev); + ~SJoystickWin32Control(); + +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) && defined(_IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_) + static BOOL CALLBACK EnumJoysticks(LPCDIDEVICEINSTANCE lpddi, LPVOID cp); + void directInputAddJoystick(LPCDIDEVICEINSTANCE lpddi); +#endif + + void pollJoysticks(); + bool activateJoysticks(core::array &joystickInfo); + irr::core::stringc findJoystickName(int index, const JOYCAPS &caps) const; +}; + +SJoystickWin32Control::SJoystickWin32Control(CIrrDeviceWin32 *dev) : + Device(dev) +{ +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) && defined(_IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_) + DirectInputDevice = 0; + if (DI_OK != (DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&DirectInputDevice, NULL))) { + os::Printer::log("Could not create DirectInput8 Object", ELL_WARNING); + return; + } +#endif +} + +SJoystickWin32Control::~SJoystickWin32Control() +{ +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) && defined(_IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_) + for (u32 joystick = 0; joystick < ActiveJoysticks.size(); ++joystick) { + LPDIRECTINPUTDEVICE8 dev = ActiveJoysticks[joystick].lpdijoy; + if (dev) { + dev->Unacquire(); + dev->Release(); + } + } + + if (DirectInputDevice) + DirectInputDevice->Release(); +#endif +} + +#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) && defined(_IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_) +BOOL CALLBACK SJoystickWin32Control::EnumJoysticks(LPCDIDEVICEINSTANCE lpddi, LPVOID cp) +{ + SJoystickWin32Control *p = (SJoystickWin32Control *)cp; + p->directInputAddJoystick(lpddi); + return DIENUM_CONTINUE; +} +void SJoystickWin32Control::directInputAddJoystick(LPCDIDEVICEINSTANCE lpddi) +{ + // Get the GUID of the joystuck + const GUID guid = lpddi->guidInstance; + + JoystickInfo activeJoystick; + activeJoystick.Index = ActiveJoysticks.size(); + activeJoystick.guid = guid; + activeJoystick.Name = lpddi->tszProductName; + if (FAILED(DirectInputDevice->CreateDevice(guid, &activeJoystick.lpdijoy, NULL))) { + os::Printer::log("Could not create DirectInput device", ELL_WARNING); + return; + } + + activeJoystick.devcaps.dwSize = sizeof(activeJoystick.devcaps); + if (FAILED(activeJoystick.lpdijoy->GetCapabilities(&activeJoystick.devcaps))) { + os::Printer::log("Could not create DirectInput device", ELL_WARNING); + return; + } + + if (FAILED(activeJoystick.lpdijoy->SetCooperativeLevel(Device->HWnd, DISCL_BACKGROUND | DISCL_EXCLUSIVE))) { + os::Printer::log("Could not set DirectInput device cooperative level", ELL_WARNING); + return; + } + + if (FAILED(activeJoystick.lpdijoy->SetDataFormat(&c_dfDIJoystick2))) { + os::Printer::log("Could not set DirectInput device data format", ELL_WARNING); + return; + } + + if (FAILED(activeJoystick.lpdijoy->Acquire())) { + os::Printer::log("Could not set DirectInput cooperative level", ELL_WARNING); + return; + } + + DIJOYSTATE2 info; + if (FAILED(activeJoystick.lpdijoy->GetDeviceState(sizeof(info), &info))) { + os::Printer::log("Could not read DirectInput device state", ELL_WARNING); + return; + } + + ZeroMemory(activeJoystick.axisValid, sizeof(activeJoystick.axisValid)); + activeJoystick.axisValid[0] = (info.lX != 0) ? 1 : 0; + activeJoystick.axisValid[1] = (info.lY != 0) ? 1 : 0; + activeJoystick.axisValid[2] = (info.lZ != 0) ? 1 : 0; + activeJoystick.axisValid[3] = (info.lRx != 0) ? 1 : 0; + activeJoystick.axisValid[4] = (info.lRy != 0) ? 1 : 0; + activeJoystick.axisValid[5] = (info.lRz != 0) ? 1 : 0; + + int caxis = 0; + for (u8 i = 0; i < 6; i++) { + if (activeJoystick.axisValid[i]) + caxis++; + } + + for (u8 i = 0; i < (activeJoystick.devcaps.dwAxes) - caxis; i++) { + if (i + caxis < 8) + activeJoystick.axisValid[i + caxis] = 1; + } + + ActiveJoysticks.push_back(activeJoystick); +} +#endif + +void SJoystickWin32Control::pollJoysticks() +{ +#if defined _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ +#ifdef _IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_ + if (0 == ActiveJoysticks.size()) + return; + + u32 joystick; + DIJOYSTATE2 info; + + for (joystick = 0; joystick < ActiveJoysticks.size(); ++joystick) { + // needs to be reset for each joystick + // request ALL values and POV as continuous if possible + + const DIDEVCAPS &caps = ActiveJoysticks[joystick].devcaps; + // if no POV is available don't ask for POV values + + if (!FAILED(ActiveJoysticks[joystick].lpdijoy->GetDeviceState(sizeof(info), &info))) { + SEvent event; + + event.EventType = irr::EET_JOYSTICK_INPUT_EVENT; + event.JoystickEvent.Joystick = (u8)joystick; + + event.JoystickEvent.POV = (u16)info.rgdwPOV[0]; + // set to undefined if no POV value was returned or the value + // is out of range + if ((caps.dwPOVs == 0) || (event.JoystickEvent.POV > 35900)) + event.JoystickEvent.POV = 65535; + + for (int axis = 0; axis < SEvent::SJoystickEvent::NUMBER_OF_AXES; ++axis) + event.JoystickEvent.Axis[axis] = 0; + + u16 dxAxis = 0; + u16 irrAxis = 0; + + while (dxAxis < 6 && irrAxis < caps.dwAxes) { + bool axisFound = 0; + s32 axisValue = 0; + + switch (dxAxis) { + case 0: + axisValue = info.lX; + break; + case 1: + axisValue = info.lY; + break; + case 2: + axisValue = info.lZ; + break; + case 3: + axisValue = info.lRx; + break; + case 4: + axisValue = info.lRy; + break; + case 5: + axisValue = info.lRz; + break; + case 6: + axisValue = info.rglSlider[0]; + break; + case 7: + axisValue = info.rglSlider[1]; + break; + default: + break; + } + + if (ActiveJoysticks[joystick].axisValid[dxAxis] > 0) + axisFound = 1; + + if (axisFound) { + s32 val = axisValue - 32768; + + if (val < -32767) + val = -32767; + if (val > 32767) + val = 32767; + event.JoystickEvent.Axis[irrAxis] = (s16)(val); + irrAxis++; + } + + dxAxis++; + } + + u32 buttons = 0; + BYTE *bytebuttons = info.rgbButtons; + for (u16 i = 0; i < 32; i++) { + if (bytebuttons[i] > 0) { + buttons |= (1 << i); + } + } + event.JoystickEvent.ButtonStates = buttons; + + (void)Device->postEventFromUser(event); + } + } +#else + if (0 == ActiveJoysticks.size()) + return; + + u32 joystick; + JOYINFOEX info; + + for (joystick = 0; joystick < ActiveJoysticks.size(); ++joystick) { + // needs to be reset for each joystick + // request ALL values and POV as continuous if possible + info.dwSize = sizeof(info); + info.dwFlags = JOY_RETURNALL | JOY_RETURNPOVCTS; + const JOYCAPS &caps = ActiveJoysticks[joystick].Caps; + // if no POV is available don't ask for POV values + if (!(caps.wCaps & JOYCAPS_HASPOV)) + info.dwFlags &= ~(JOY_RETURNPOV | JOY_RETURNPOVCTS); + if (JOYERR_NOERROR == joyGetPosEx(ActiveJoysticks[joystick].Index, &info)) { + SEvent event; + + event.EventType = irr::EET_JOYSTICK_INPUT_EVENT; + event.JoystickEvent.Joystick = (u8)joystick; + + event.JoystickEvent.POV = (u16)info.dwPOV; + // set to undefined if no POV value was returned or the value + // is out of range + if (!(info.dwFlags & JOY_RETURNPOV) || (event.JoystickEvent.POV > 35900)) + event.JoystickEvent.POV = 65535; + + for (int axis = 0; axis < SEvent::SJoystickEvent::NUMBER_OF_AXES; ++axis) + event.JoystickEvent.Axis[axis] = 0; + + event.JoystickEvent.ButtonStates = info.dwButtons; + + switch (caps.wNumAxes) { + default: + case 6: + event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_V] = + (s16)((65535 * (info.dwVpos - caps.wVmin)) / (caps.wVmax - caps.wVmin) - 32768); + + case 5: + event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_U] = + (s16)((65535 * (info.dwUpos - caps.wUmin)) / (caps.wUmax - caps.wUmin) - 32768); + + case 4: + event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_R] = + (s16)((65535 * (info.dwRpos - caps.wRmin)) / (caps.wRmax - caps.wRmin) - 32768); + + case 3: + event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Z] = + (s16)((65535 * (info.dwZpos - caps.wZmin)) / (caps.wZmax - caps.wZmin) - 32768); + + case 2: + event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Y] = + (s16)((65535 * (info.dwYpos - caps.wYmin)) / (caps.wYmax - caps.wYmin) - 32768); + + case 1: + event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_X] = + (s16)((65535 * (info.dwXpos - caps.wXmin)) / (caps.wXmax - caps.wXmin) - 32768); + } + + (void)Device->postEventFromUser(event); + } + } +#endif +#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ +} + +/** This function is ported from SDL and released under zlib-license: + * Copyright (C) 1997-2014 Sam Lantinga */ +irr::core::stringc SJoystickWin32Control::findJoystickName(int index, const JOYCAPS &caps) const +{ +#if defined _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ + + // As a default use the name given in the joystick structure. + // It is always the same name, independent of joystick. + irr::core::stringc result(caps.szPname); + + core::stringc key = core::stringc(REGSTR_PATH_JOYCONFIG) + "\\" + caps.szRegKey + "\\" + REGSTR_KEY_JOYCURR; + HKEY hTopKey = HKEY_LOCAL_MACHINE; + HKEY hKey; + long regresult = RegOpenKeyExA(hTopKey, key.c_str(), 0, KEY_READ, &hKey); + if (regresult != ERROR_SUCCESS) { + hTopKey = HKEY_CURRENT_USER; + regresult = RegOpenKeyExA(hTopKey, key.c_str(), 0, KEY_READ, &hKey); + } + if (regresult != ERROR_SUCCESS) + return result; + + /* find the registry key name for the joystick's properties */ + char regname[256]; + DWORD regsize = sizeof(regname); + core::stringc regvalue = core::stringc("Joystick") + core::stringc(index + 1) + REGSTR_VAL_JOYOEMNAME; + regresult = RegQueryValueExA(hKey, regvalue.c_str(), 0, 0, (LPBYTE)regname, ®size); + RegCloseKey(hKey); + if (regresult != ERROR_SUCCESS) + return result; + + /* open that registry key */ + core::stringc regkey = core::stringc(REGSTR_PATH_JOYOEM) + "\\" + regname; + regresult = RegOpenKeyExA(hTopKey, regkey.c_str(), 0, KEY_READ, &hKey); + if (regresult != ERROR_SUCCESS) + return result; + + /* find the size for the OEM name text */ + regsize = sizeof(regvalue); + regresult = RegQueryValueEx(hKey, REGSTR_VAL_JOYOEMNAME, 0, 0, + NULL, ®size); + if (regresult == ERROR_SUCCESS) { + char *name; + /* allocate enough memory for the OEM name text ... */ + name = new char[regsize]; + if (name) { + /* ... and read it from the registry */ + regresult = RegQueryValueEx(hKey, REGSTR_VAL_JOYOEMNAME, 0, 0, + (LPBYTE)name, ®size); + result = name; + } + delete[] name; + } + RegCloseKey(hKey); + + return result; +#endif + return ""; +} + +bool SJoystickWin32Control::activateJoysticks(core::array &joystickInfo) +{ +#if defined _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ + joystickInfo.clear(); + ActiveJoysticks.clear(); +#ifdef _IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_ + if (!DirectInputDevice || (DirectInputDevice->EnumDevices(DI8DEVCLASS_GAMECTRL, SJoystickWin32Control::EnumJoysticks, this, DIEDFL_ATTACHEDONLY))) { + os::Printer::log("Could not enum DirectInput8 controllers", ELL_WARNING); + return false; + } + + for (u32 joystick = 0; joystick < ActiveJoysticks.size(); ++joystick) { + JoystickInfo &activeJoystick = ActiveJoysticks[joystick]; + SJoystickInfo info; + info.Axes = activeJoystick.devcaps.dwAxes; + info.Buttons = activeJoystick.devcaps.dwButtons; + info.Name = activeJoystick.Name; + info.PovHat = (activeJoystick.devcaps.dwPOVs != 0) + ? SJoystickInfo::POV_HAT_PRESENT + : SJoystickInfo::POV_HAT_ABSENT; + joystickInfo.push_back(info); + } + return true; +#else + const u32 numberOfJoysticks = ::joyGetNumDevs(); + JOYINFOEX info; + info.dwSize = sizeof(info); + info.dwFlags = JOY_RETURNALL; + + JoystickInfo activeJoystick; + SJoystickInfo returnInfo; + + joystickInfo.reallocate(numberOfJoysticks); + ActiveJoysticks.reallocate(numberOfJoysticks); + + u32 joystick = 0; + for (; joystick < numberOfJoysticks; ++joystick) { + if (JOYERR_NOERROR == joyGetPosEx(joystick, &info) && + JOYERR_NOERROR == joyGetDevCaps(joystick, + &activeJoystick.Caps, + sizeof(activeJoystick.Caps))) { + activeJoystick.Index = joystick; + ActiveJoysticks.push_back(activeJoystick); + + returnInfo.Joystick = (u8)joystick; + returnInfo.Axes = activeJoystick.Caps.wNumAxes; + returnInfo.Buttons = activeJoystick.Caps.wNumButtons; + returnInfo.Name = findJoystickName(joystick, activeJoystick.Caps); + returnInfo.PovHat = ((activeJoystick.Caps.wCaps & JOYCAPS_HASPOV) == JOYCAPS_HASPOV) + ? SJoystickInfo::POV_HAT_PRESENT + : SJoystickInfo::POV_HAT_ABSENT; + + joystickInfo.push_back(returnInfo); + } + } + + for (joystick = 0; joystick < joystickInfo.size(); ++joystick) { + char logString[256]; + snprintf_irr(logString, sizeof(logString), "Found joystick %d, %d axes, %d buttons '%s'", + joystick, joystickInfo[joystick].Axes, + joystickInfo[joystick].Buttons, joystickInfo[joystick].Name.c_str()); + os::Printer::log(logString, ELL_INFORMATION); + } + + return true; +#endif +#else + return false; +#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_ +} +} // end namespace irr + +namespace +{ +struct SEnvMapper +{ + HWND hWnd; + irr::CIrrDeviceWin32 *irrDev; +}; +// NOTE: This is global. We can have more than one Irrlicht Device at same time. +irr::core::array EnvMap; + +HKL KEYBOARD_INPUT_HKL = 0; +} + +irr::CIrrDeviceWin32 *getDeviceFromHWnd(HWND hWnd) +{ + const irr::u32 end = EnvMap.size(); + for (irr::u32 i = 0; i < end; ++i) { + const SEnvMapper &env = EnvMap[i]; + if (env.hWnd == hWnd) + return env.irrDev; + } + + return 0; +} + +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ +#ifndef WHEEL_DELTA +#define WHEEL_DELTA 120 +#endif + + irr::CIrrDeviceWin32 *dev = 0; + irr::SEvent event; + + static irr::s32 ClickCount = 0; + if (GetCapture() != hWnd && ClickCount > 0) + ClickCount = 0; + + struct messageMap + { + irr::s32 group; + UINT winMessage; + irr::s32 irrMessage; + }; + + static messageMap mouseMap[] = { + {0, WM_LBUTTONDOWN, irr::EMIE_LMOUSE_PRESSED_DOWN}, + {1, WM_LBUTTONUP, irr::EMIE_LMOUSE_LEFT_UP}, + {0, WM_RBUTTONDOWN, irr::EMIE_RMOUSE_PRESSED_DOWN}, + {1, WM_RBUTTONUP, irr::EMIE_RMOUSE_LEFT_UP}, + {0, WM_MBUTTONDOWN, irr::EMIE_MMOUSE_PRESSED_DOWN}, + {1, WM_MBUTTONUP, irr::EMIE_MMOUSE_LEFT_UP}, + {2, WM_MOUSEMOVE, irr::EMIE_MOUSE_MOVED}, + {3, WM_MOUSEWHEEL, irr::EMIE_MOUSE_WHEEL}, + {-1, 0, 0}, + }; + + // handle grouped events + messageMap *m = mouseMap; + while (m->group >= 0 && m->winMessage != message) + m += 1; + + if (m->group >= 0) { + if (m->group == 0) { // down + ClickCount++; + SetCapture(hWnd); + } else if (m->group == 1) { // up + ClickCount--; + if (ClickCount < 1) { + ClickCount = 0; + ReleaseCapture(); + } + } + + event.EventType = irr::EET_MOUSE_INPUT_EVENT; + event.MouseInput.Event = (irr::EMOUSE_INPUT_EVENT)m->irrMessage; + event.MouseInput.X = (short)LOWORD(lParam); + event.MouseInput.Y = (short)HIWORD(lParam); + event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0); + event.MouseInput.Control = ((LOWORD(wParam) & MK_CONTROL) != 0); + // left and right mouse buttons + event.MouseInput.ButtonStates = wParam & (MK_LBUTTON | MK_RBUTTON); + // middle and extra buttons + if (wParam & MK_MBUTTON) + event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE; + if (wParam & MK_XBUTTON1) + event.MouseInput.ButtonStates |= irr::EMBSM_EXTRA1; + if (wParam & MK_XBUTTON2) + event.MouseInput.ButtonStates |= irr::EMBSM_EXTRA2; + event.MouseInput.Wheel = 0.f; + + // wheel + if (m->group == 3) { + POINT p; // fixed by jox + p.x = 0; + p.y = 0; + ClientToScreen(hWnd, &p); + event.MouseInput.X -= p.x; + event.MouseInput.Y -= p.y; + event.MouseInput.Wheel = ((irr::f32)((short)HIWORD(wParam))) / (irr::f32)WHEEL_DELTA; + } + + dev = getDeviceFromHWnd(hWnd); + if (dev) { + dev->postEventFromUser(event); + + if (event.MouseInput.Event >= irr::EMIE_LMOUSE_PRESSED_DOWN && event.MouseInput.Event <= irr::EMIE_MMOUSE_PRESSED_DOWN) { + irr::u32 clicks = dev->checkSuccessiveClicks(event.MouseInput.X, event.MouseInput.Y, event.MouseInput.Event); + if (clicks == 2) { + event.MouseInput.Event = (irr::EMOUSE_INPUT_EVENT)(irr::EMIE_LMOUSE_DOUBLE_CLICK + event.MouseInput.Event - irr::EMIE_LMOUSE_PRESSED_DOWN); + dev->postEventFromUser(event); + } else if (clicks == 3) { + event.MouseInput.Event = (irr::EMOUSE_INPUT_EVENT)(irr::EMIE_LMOUSE_TRIPLE_CLICK + event.MouseInput.Event - irr::EMIE_LMOUSE_PRESSED_DOWN); + dev->postEventFromUser(event); + } + } + } + return 0; + } + + switch (message) { + case WM_PAINT: { + PAINTSTRUCT ps; + BeginPaint(hWnd, &ps); + EndPaint(hWnd, &ps); + } + return 0; + + case WM_ERASEBKGND: + return 0; + + case WM_SYSKEYDOWN: + case WM_SYSKEYUP: + case WM_KEYDOWN: + case WM_KEYUP: { + BYTE allKeys[256]; + + event.EventType = irr::EET_KEY_INPUT_EVENT; + event.KeyInput.Key = (irr::EKEY_CODE)wParam; + event.KeyInput.PressedDown = (message == WM_KEYDOWN || message == WM_SYSKEYDOWN); + + if (event.KeyInput.Key == irr::KEY_SHIFT) { + event.KeyInput.Key = (irr::EKEY_CODE)MapVirtualKey(((lParam >> 16) & 255), MAPVK_VSC_TO_VK_EX); + } + if (event.KeyInput.Key == irr::KEY_CONTROL) { + event.KeyInput.Key = (irr::EKEY_CODE)MapVirtualKey(((lParam >> 16) & 255), MAPVK_VSC_TO_VK_EX); + // some keyboards will just return LEFT for both - left and right keys. So also check extend bit. + if (lParam & 0x1000000) + event.KeyInput.Key = irr::KEY_RCONTROL; + } + if (event.KeyInput.Key == irr::KEY_MENU) { + event.KeyInput.Key = (irr::EKEY_CODE)MapVirtualKey(((lParam >> 16) & 255), MAPVK_VSC_TO_VK_EX); + if (lParam & 0x1000000) + event.KeyInput.Key = irr::KEY_RMENU; + } + + GetKeyboardState(allKeys); + + event.KeyInput.Shift = ((allKeys[VK_SHIFT] & 0x80) != 0); + event.KeyInput.Control = ((allKeys[VK_CONTROL] & 0x80) != 0); + + // Handle unicode and deadkeys + WCHAR keyChars[2]; + UINT scanCode = HIWORD(lParam); + int conversionResult = ToUnicodeEx(static_cast(wParam), scanCode, allKeys, keyChars, 2, 0, KEYBOARD_INPUT_HKL); + if (conversionResult == 1) + event.KeyInput.Char = keyChars[0]; + else + event.KeyInput.Char = 0; + + // allow composing characters like '@' with Alt Gr on non-US keyboards + if ((allKeys[VK_MENU] & 0x80) != 0) + event.KeyInput.Control = 0; + + dev = getDeviceFromHWnd(hWnd); + if (dev) + dev->postEventFromUser(event); + + if (message == WM_SYSKEYDOWN || message == WM_SYSKEYUP) + return DefWindowProcW(hWnd, message, wParam, lParam); + else + return 0; + } + + case WM_SIZE: { + // resize + dev = getDeviceFromHWnd(hWnd); + if (dev) + dev->OnResized(); + } + return 0; + + case WM_DESTROY: + PostQuitMessage(0); + return 0; + + case WM_SYSCOMMAND: + // prevent screensaver or monitor powersave mode from starting + if ((wParam & 0xFFF0) == SC_SCREENSAVE || + (wParam & 0xFFF0) == SC_MONITORPOWER || + (wParam & 0xFFF0) == SC_KEYMENU) + return 0; + + break; + + case WM_USER: + event.EventType = irr::EET_USER_EVENT; + event.UserEvent.UserData1 = static_cast(wParam); + event.UserEvent.UserData2 = static_cast(lParam); + dev = getDeviceFromHWnd(hWnd); + + if (dev) + dev->postEventFromUser(event); + + return 0; + + case WM_SETCURSOR: + // because Windows forgot about that in the meantime + dev = getDeviceFromHWnd(hWnd); + if (dev) { + dev->getCursorControl()->setActiveIcon(dev->getCursorControl()->getActiveIcon()); + dev->getCursorControl()->setVisible(dev->getCursorControl()->isVisible()); + } + break; + + case WM_INPUTLANGCHANGE: + // get the new codepage used for keyboard input + KEYBOARD_INPUT_HKL = GetKeyboardLayout(0); + return 0; + } + return DefWindowProcW(hWnd, message, wParam, lParam); +} + +namespace irr +{ + +//! constructor +CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters ¶ms) : + CIrrDeviceStub(params), HWnd(0), Resized(false), + ExternalWindow(false), Win32CursorControl(0), JoyControl(0), + WindowMaximized(params.WindowMaximized) +{ +#ifdef _DEBUG + setDebugName("CIrrDeviceWin32"); +#endif + + // get windows version and create OS operator + core::stringc winversion; + getWindowsVersion(winversion); + Operator = new COSOperator(winversion); + os::Printer::log(winversion.c_str(), ELL_INFORMATION); + + // get handle to exe file + HINSTANCE hInstance = GetModuleHandle(0); + + // create the window if we need to and we do not use the null device + if (!CreationParams.WindowId && CreationParams.DriverType != video::EDT_NULL) { + const wchar_t *ClassName = L"CIrrDeviceWin32"; + + // Register Class + WNDCLASSEXW wcex; + wcex.cbSize = sizeof(WNDCLASSEXW); + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = NULL; + wcex.hCursor = 0; // LoadCursor(NULL, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + wcex.lpszMenuName = 0; + wcex.lpszClassName = ClassName; + wcex.hIconSm = 0; + + RegisterClassExW(&wcex); + + // calculate client size + + RECT clientSize; + clientSize.top = 0; + clientSize.left = 0; + clientSize.right = CreationParams.WindowSize.Width; + clientSize.bottom = CreationParams.WindowSize.Height; + + DWORD style = getWindowStyle(CreationParams.Fullscreen, CreationParams.WindowResizable > 0 ? true : false); + AdjustWindowRect(&clientSize, style, FALSE); + + const s32 realWidth = clientSize.right - clientSize.left; + const s32 realHeight = clientSize.bottom - clientSize.top; + + s32 windowLeft = (CreationParams.WindowPosition.X == -1 ? (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2 : CreationParams.WindowPosition.X); + s32 windowTop = (CreationParams.WindowPosition.Y == -1 ? (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2 : CreationParams.WindowPosition.Y); + + if (windowLeft < 0) + windowLeft = 0; + if (windowTop < 0) + windowTop = 0; // make sure window menus are in screen on creation + + if (CreationParams.Fullscreen) { + windowLeft = 0; + windowTop = 0; + } + + // create window + HWnd = CreateWindowW(ClassName, L"", style, windowLeft, windowTop, + realWidth, realHeight, NULL, NULL, hInstance, NULL); + if (!HWnd) { + os::Printer::log("Window could not be created.", ELL_ERROR); + } + + CreationParams.WindowId = HWnd; + // CreationParams.WindowSize.Width = realWidth; + // CreationParams.WindowSize.Height = realHeight; + + ShowWindow(HWnd, SW_SHOWNORMAL); + UpdateWindow(HWnd); + + // fix ugly ATI driver bugs. Thanks to ariaci + MoveWindow(HWnd, windowLeft, windowTop, realWidth, realHeight, TRUE); + + // make sure everything gets updated to the real sizes + Resized = true; + } else if (CreationParams.WindowId) { + // attach external window + HWnd = static_cast(CreationParams.WindowId); + RECT r; + GetWindowRect(HWnd, &r); + CreationParams.WindowSize.Width = r.right - r.left; + CreationParams.WindowSize.Height = r.bottom - r.top; + CreationParams.Fullscreen = false; + ExternalWindow = true; + } + + // create cursor control + + Win32CursorControl = new CCursorControl(this, CreationParams.WindowSize, HWnd, CreationParams.Fullscreen); + CursorControl = Win32CursorControl; + JoyControl = new SJoystickWin32Control(this); + + // initialize doubleclicks with system values + MouseMultiClicks.DoubleClickTime = GetDoubleClickTime(); + + // create driver + + createDriver(); + + if (VideoDriver) + createGUIAndScene(); + + // register environment + + SEnvMapper em; + em.irrDev = this; + em.hWnd = HWnd; + EnvMap.push_back(em); + + // set this as active window + if (!ExternalWindow) { + SetActiveWindow(HWnd); + SetForegroundWindow(HWnd); + } + + KEYBOARD_INPUT_HKL = GetKeyboardLayout(0); + + // inform driver about the window size etc. + resizeIfNecessary(); + + if (params.WindowMaximized) + maximizeWindow(); +} + +//! destructor +CIrrDeviceWin32::~CIrrDeviceWin32() +{ + delete JoyControl; + + // unregister environment + for (u32 i = 0; i < EnvMap.size(); ++i) { + if (EnvMap[i].hWnd == HWnd) { + EnvMap.erase(i); + break; + } + } +} + +//! create the driver +void CIrrDeviceWin32::createDriver() +{ + switch (CreationParams.DriverType) { + case video::EDT_OPENGL: +#ifdef _IRR_COMPILE_WITH_OPENGL_ + switchToFullScreen(); + + ContextManager = new video::CWGLManager(); + ContextManager->initialize(CreationParams, video::SExposedVideoData(HWnd)); + + VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, ContextManager); + + if (!VideoDriver) + os::Printer::log("Could not create OpenGL driver.", ELL_ERROR); +#else + os::Printer::log("OpenGL driver was not compiled in.", ELL_ERROR); +#endif + break; + case video::EDT_OGLES1: +#ifdef _IRR_COMPILE_WITH_OGLES1_ + switchToFullScreen(); + + ContextManager = new video::CEGLManager(); + ContextManager->initialize(CreationParams, video::SExposedVideoData(HWnd)); + + VideoDriver = video::createOGLES1Driver(CreationParams, FileSystem, ContextManager); + + if (!VideoDriver) + os::Printer::log("Could not create OpenGL-ES1 driver.", ELL_ERROR); +#else + os::Printer::log("OpenGL-ES1 driver was not compiled in.", ELL_ERROR); +#endif + break; + case video::EDT_OGLES2: +#ifdef _IRR_COMPILE_WITH_OGLES2_ + switchToFullScreen(); + + ContextManager = new video::CEGLManager(); + ContextManager->initialize(CreationParams, video::SExposedVideoData(HWnd)); + + VideoDriver = video::createOGLES2Driver(CreationParams, FileSystem, ContextManager); + + if (!VideoDriver) + os::Printer::log("Could not create OpenGL-ES2 driver.", ELL_ERROR); +#else + os::Printer::log("OpenGL-ES2 driver was not compiled in.", ELL_ERROR); +#endif + break; + case video::EDT_WEBGL1: + os::Printer::log("WebGL1 driver not supported on Win32 device.", ELL_ERROR); + break; + case video::EDT_NULL: + VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); + break; + default: + os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR); + break; + } +} + +//! runs the device. Returns false if device wants to be deleted +bool CIrrDeviceWin32::run() +{ + os::Timer::tick(); + + static_cast(CursorControl)->update(); + + handleSystemMessages(); + + if (!Close) + resizeIfNecessary(); + + if (!Close && JoyControl) + JoyControl->pollJoysticks(); + + return !Close; +} + +//! Pause the current process for the minimum time allowed only to allow other processes to execute +void CIrrDeviceWin32::yield() +{ + Sleep(0); +} + +//! Pause execution and let other processes to run for a specified amount of time. +void CIrrDeviceWin32::sleep(u32 timeMs, bool pauseTimer) +{ + const bool wasStopped = Timer ? Timer->isStopped() : true; + if (pauseTimer && !wasStopped) + Timer->stop(); + + Sleep(timeMs); + + if (pauseTimer && !wasStopped) + Timer->start(); +} + +void CIrrDeviceWin32::resizeIfNecessary() +{ + if (!Resized || !getVideoDriver()) + return; + + RECT r; + GetClientRect(HWnd, &r); + + char tmp[255]; + + if (r.right < 2 || r.bottom < 2) { + snprintf_irr(tmp, sizeof(tmp), "Ignoring resize operation to (%ld %ld)", r.right, r.bottom); + os::Printer::log(tmp); + } else { + snprintf_irr(tmp, sizeof(tmp), "Resizing window (%ld %ld)", r.right, r.bottom); + os::Printer::log(tmp); + + getVideoDriver()->OnResize(irr::core::dimension2du((u32)r.right, (u32)r.bottom)); + getWin32CursorControl()->OnResize(getVideoDriver()->getScreenSize()); + } + + Resized = false; +} + +DWORD CIrrDeviceWin32::getWindowStyle(bool fullscreen, bool resizable) const +{ + if (fullscreen) + return WS_POPUP; + + if (resizable) + return WS_THICKFRAME | WS_SYSMENU | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX; + + return WS_BORDER | WS_SYSMENU | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; +} + +//! sets the caption of the window +void CIrrDeviceWin32::setWindowCaption(const wchar_t *text) +{ + // We use SendMessage instead of SetText to ensure proper + // function even in cases where the HWND was created in a different thread + DWORD_PTR dwResult; + SendMessageTimeoutW(HWnd, WM_SETTEXT, 0, + reinterpret_cast(text), + SMTO_ABORTIFHUNG, 2000, &dwResult); +} + +//! Sets the window icon. +bool CIrrDeviceWin32::setWindowIcon(const video::IImage *img) +{ + // Ignore the img, instead load the ICON from resource file + // (This is minetest-specific!) + const HICON hicon = LoadIcon(GetModuleHandle(NULL), + MAKEINTRESOURCE(130) // The ID of the ICON defined in + // winresource.rc + ); + + if (hicon) { + SendMessage(HWnd, WM_SETICON, ICON_BIG, reinterpret_cast(hicon)); + SendMessage(HWnd, WM_SETICON, ICON_SMALL, + reinterpret_cast(hicon)); + return true; + } + return false; +} + +//! notifies the device that it should close itself +void CIrrDeviceWin32::closeDevice() +{ + if (!ExternalWindow) { + MSG msg; + PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE); + PostQuitMessage(0); + PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE); + DestroyWindow(HWnd); + const wchar_t *ClassName = L"CIrrDeviceWin32"; + HINSTANCE hInstance = GetModuleHandle(0); + UnregisterClassW(ClassName, hInstance); + } + Close = true; +} + +//! returns if window is active. if not, nothing needs to be drawn +bool CIrrDeviceWin32::isWindowActive() const +{ + return (GetActiveWindow() == HWnd); +} + +//! returns if window has focus +bool CIrrDeviceWin32::isWindowFocused() const +{ + bool ret = (GetFocus() == HWnd); + return ret; +} + +//! returns if window is minimized +bool CIrrDeviceWin32::isWindowMinimized() const +{ + WINDOWPLACEMENT plc; + plc.length = sizeof(WINDOWPLACEMENT); + bool ret = false; + if (GetWindowPlacement(HWnd, &plc)) + ret = plc.showCmd == SW_SHOWMINIMIZED; + return ret; +} + +//! returns last state from maximizeWindow() and restoreWindow() +bool CIrrDeviceWin32::isWindowMaximized() const +{ + return WindowMaximized; +} + +//! switches to fullscreen +bool CIrrDeviceWin32::switchToFullScreen() +{ + if (!CreationParams.Fullscreen) + return true; + + // No border, title bar, etc. is already set up through getWindowStyle() + // We only set the window size to match the monitor. + + MONITORINFO mi; + mi.cbSize = sizeof(mi); + if (GetMonitorInfo(MonitorFromWindow(HWnd, MONITOR_DEFAULTTOPRIMARY), &mi)) { + UINT flags = SWP_NOCOPYBITS | SWP_NOOWNERZORDER | SWP_FRAMECHANGED; + SetWindowPos(HWnd, HWND_TOP, mi.rcMonitor.left, mi.rcMonitor.top, + mi.rcMonitor.right - mi.rcMonitor.left, + mi.rcMonitor.bottom - mi.rcMonitor.top, flags); + } else { + CreationParams.Fullscreen = false; + } + + return CreationParams.Fullscreen; +} + +//! returns the win32 cursor control +CIrrDeviceWin32::CCursorControl *CIrrDeviceWin32::getWin32CursorControl() +{ + return Win32CursorControl; +} + +void CIrrDeviceWin32::getWindowsVersion(core::stringc &out) +{ + OSVERSIONINFO osvi; + + ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&osvi); + + char tmp[255]; + snprintf(tmp, sizeof(tmp), "Microsoft Windows %lu.%lu %s", osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.szCSDVersion); + out.append(tmp); +} + +//! Notifies the device, that it has been resized +void CIrrDeviceWin32::OnResized() +{ + Resized = true; +} + +//! Resize the render window. +void CIrrDeviceWin32::setWindowSize(const irr::core::dimension2d &size) +{ + if (ExternalWindow || !getVideoDriver() || CreationParams.Fullscreen) + return; + + // get size of the window for the give size of the client area + DWORD style = static_cast(GetWindowLongPtr(HWnd, GWL_STYLE)); + DWORD exStyle = static_cast(GetWindowLongPtr(HWnd, GWL_EXSTYLE)); + RECT clientSize; + clientSize.top = 0; + clientSize.left = 0; + clientSize.right = size.Width; + clientSize.bottom = size.Height; + AdjustWindowRectEx(&clientSize, style, false, exStyle); + const s32 realWidth = clientSize.right - clientSize.left; + const s32 realHeight = clientSize.bottom - clientSize.top; + + UINT flags = SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER; + SetWindowPos(HWnd, HWND_TOP, 0, 0, realWidth, realHeight, flags); +} + +//! Sets if the window should be resizable in windowed mode. +void CIrrDeviceWin32::setResizable(bool resize) +{ + if (ExternalWindow || !getVideoDriver() || CreationParams.Fullscreen) + return; + + LONG_PTR style = (LONG_PTR)getWindowStyle(false, resize); + if (!SetWindowLongPtr(HWnd, GWL_STYLE, style)) + os::Printer::log("Could not change window style."); + + RECT clientSize; + clientSize.top = 0; + clientSize.left = 0; + clientSize.right = getVideoDriver()->getScreenSize().Width; + clientSize.bottom = getVideoDriver()->getScreenSize().Height; + + AdjustWindowRect(&clientSize, static_cast(style), FALSE); + + const s32 realWidth = clientSize.right - clientSize.left; + const s32 realHeight = clientSize.bottom - clientSize.top; + + const s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2; + const s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2; + + SetWindowPos(HWnd, HWND_TOP, windowLeft, windowTop, realWidth, realHeight, + SWP_FRAMECHANGED | SWP_NOMOVE | SWP_SHOWWINDOW); + + static_cast(CursorControl)->updateBorderSize(CreationParams.Fullscreen, resize); +} + +//! Minimizes the window. +void CIrrDeviceWin32::minimizeWindow() +{ + WINDOWPLACEMENT wndpl; + wndpl.length = sizeof(WINDOWPLACEMENT); + GetWindowPlacement(HWnd, &wndpl); + wndpl.showCmd = SW_SHOWMINNOACTIVE; + SetWindowPlacement(HWnd, &wndpl); +} + +//! Maximizes the window. +void CIrrDeviceWin32::maximizeWindow() +{ + WINDOWPLACEMENT wndpl; + wndpl.length = sizeof(WINDOWPLACEMENT); + GetWindowPlacement(HWnd, &wndpl); + wndpl.showCmd = SW_SHOWMAXIMIZED; + SetWindowPlacement(HWnd, &wndpl); + + WindowMaximized = true; +} + +//! Restores the window to its original size. +void CIrrDeviceWin32::restoreWindow() +{ + WINDOWPLACEMENT wndpl; + wndpl.length = sizeof(WINDOWPLACEMENT); + GetWindowPlacement(HWnd, &wndpl); + wndpl.showCmd = SW_SHOWNORMAL; + SetWindowPlacement(HWnd, &wndpl); + + WindowMaximized = false; +} + +core::position2di CIrrDeviceWin32::getWindowPosition() +{ + WINDOWPLACEMENT wndpl; + wndpl.length = sizeof(WINDOWPLACEMENT); + if (GetWindowPlacement(HWnd, &wndpl)) { + return core::position2di((int)wndpl.rcNormalPosition.left, + (int)wndpl.rcNormalPosition.top); + } else { + // No reason for this to happen + os::Printer::log("Failed to retrieve window location", ELL_ERROR); + return core::position2di(-1, -1); + } +} + +bool CIrrDeviceWin32::activateJoysticks(core::array &joystickInfo) +{ + if (JoyControl) + return JoyControl->activateJoysticks(joystickInfo); + else + return false; +} + +//! Process system events +void CIrrDeviceWin32::handleSystemMessages() +{ + MSG msg; + + while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { + if (ExternalWindow && msg.hwnd == HWnd) { + if (msg.hwnd == HWnd) { + WndProc(HWnd, msg.message, msg.wParam, msg.lParam); + } else { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } else { + // No message translation because we don't use WM_CHAR and it would conflict with our + // deadkey handling. + DispatchMessage(&msg); + } + + if (msg.message == WM_QUIT) + Close = true; + } +} + +//! Remove all messages pending in the system message loop +void CIrrDeviceWin32::clearSystemMessages() +{ + MSG msg; + while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE)) { + } + while (PeekMessage(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE)) { + } +} + +//! Get the display density in dots per inch. +float CIrrDeviceWin32::getDisplayDensity() const +{ + HDC hdc = GetDC(HWnd); + float dpi = GetDeviceCaps(hdc, LOGPIXELSX); + ReleaseDC(HWnd, hdc); + return dpi; +} + +// Convert an Irrlicht texture to a Windows cursor +// Based on http://www.codeguru.com/cpp/w-p/win32/cursors/article.php/c4529/ +HCURSOR CIrrDeviceWin32::TextureToCursor(HWND hwnd, irr::video::ITexture *tex, const core::rect &sourceRect, const core::position2d &hotspot) +{ + // + // create the bitmaps needed for cursors from the texture + + HDC dc = GetDC(hwnd); + HDC andDc = CreateCompatibleDC(dc); + HDC xorDc = CreateCompatibleDC(dc); + HBITMAP andBitmap = CreateCompatibleBitmap(dc, sourceRect.getWidth(), sourceRect.getHeight()); + HBITMAP xorBitmap = CreateCompatibleBitmap(dc, sourceRect.getWidth(), sourceRect.getHeight()); + + HBITMAP oldAndBitmap = (HBITMAP)SelectObject(andDc, andBitmap); + HBITMAP oldXorBitmap = (HBITMAP)SelectObject(xorDc, xorBitmap); + + video::ECOLOR_FORMAT format = tex->getColorFormat(); + u32 bytesPerPixel = video::IImage::getBitsPerPixelFromFormat(format) / 8; + u32 bytesLeftGap = sourceRect.UpperLeftCorner.X * bytesPerPixel; + u32 bytesRightGap = tex->getPitch() - sourceRect.LowerRightCorner.X * bytesPerPixel; + const u8 *data = (const u8 *)tex->lock(video::ETLM_READ_ONLY, 0); + data += sourceRect.UpperLeftCorner.Y * tex->getPitch(); + for (s32 y = 0; y < sourceRect.getHeight(); ++y) { + data += bytesLeftGap; + for (s32 x = 0; x < sourceRect.getWidth(); ++x) { + video::SColor pixelCol; + pixelCol.setData((const void *)data, format); + data += bytesPerPixel; + + if (pixelCol.getAlpha() == 0) { // transparent + SetPixel(andDc, x, y, RGB(255, 255, 255)); + SetPixel(xorDc, x, y, RGB(0, 0, 0)); + } else // color + { + SetPixel(andDc, x, y, RGB(0, 0, 0)); + SetPixel(xorDc, x, y, RGB(pixelCol.getRed(), pixelCol.getGreen(), pixelCol.getBlue())); + } + } + data += bytesRightGap; + } + tex->unlock(); + + SelectObject(andDc, oldAndBitmap); + SelectObject(xorDc, oldXorBitmap); + + DeleteDC(xorDc); + DeleteDC(andDc); + + ReleaseDC(hwnd, dc); + + // create the cursor + + ICONINFO iconinfo; + iconinfo.fIcon = false; // type is cursor not icon + iconinfo.xHotspot = hotspot.X; + iconinfo.yHotspot = hotspot.Y; + iconinfo.hbmMask = andBitmap; + iconinfo.hbmColor = xorBitmap; + + HCURSOR cursor = CreateIconIndirect(&iconinfo); + + DeleteObject(andBitmap); + DeleteObject(xorBitmap); + + return cursor; +} + +CIrrDeviceWin32::CCursorControl::CCursorControl(CIrrDeviceWin32 *device, const core::dimension2d &wsize, HWND hwnd, bool fullscreen) : + Device(device), WindowSize(wsize), InvWindowSize(0.0f, 0.0f), + HWnd(hwnd), BorderX(0), BorderY(0), + UseReferenceRect(false), IsVisible(true), ActiveIcon(gui::ECI_NORMAL), ActiveIconStartTime(0) +{ + if (WindowSize.Width != 0) + InvWindowSize.Width = 1.0f / WindowSize.Width; + + if (WindowSize.Height != 0) + InvWindowSize.Height = 1.0f / WindowSize.Height; + + updateBorderSize(fullscreen, false); + initCursors(); +} + +CIrrDeviceWin32::CCursorControl::~CCursorControl() +{ + for (u32 i = 0; i < Cursors.size(); ++i) { + for (u32 f = 0; f < Cursors[i].Frames.size(); ++f) { + DestroyCursor(Cursors[i].Frames[f].IconHW); + } + } +} + +void CIrrDeviceWin32::CCursorControl::initCursors() +{ + Cursors.push_back(CursorW32(LoadCursor(NULL, IDC_ARROW))); + Cursors.push_back(CursorW32(LoadCursor(NULL, IDC_CROSS))); + Cursors.push_back(CursorW32(LoadCursor(NULL, IDC_HAND))); + Cursors.push_back(CursorW32(LoadCursor(NULL, IDC_HELP))); + Cursors.push_back(CursorW32(LoadCursor(NULL, IDC_IBEAM))); + Cursors.push_back(CursorW32(LoadCursor(NULL, IDC_NO))); + Cursors.push_back(CursorW32(LoadCursor(NULL, IDC_WAIT))); + Cursors.push_back(CursorW32(LoadCursor(NULL, IDC_SIZEALL))); + Cursors.push_back(CursorW32(LoadCursor(NULL, IDC_SIZENESW))); + Cursors.push_back(CursorW32(LoadCursor(NULL, IDC_SIZENWSE))); + Cursors.push_back(CursorW32(LoadCursor(NULL, IDC_SIZENS))); + Cursors.push_back(CursorW32(LoadCursor(NULL, IDC_SIZEWE))); + Cursors.push_back(CursorW32(LoadCursor(NULL, IDC_UPARROW))); +} + +void CIrrDeviceWin32::CCursorControl::update() +{ + if (!Cursors[ActiveIcon].Frames.empty() && Cursors[ActiveIcon].FrameTime) { + // update animated cursors. This could also be done by X11 in case someone wants to figure that out (this way was just easier to implement) + u32 now = Device->getTimer()->getRealTime(); + u32 frame = ((now - ActiveIconStartTime) / Cursors[ActiveIcon].FrameTime) % Cursors[ActiveIcon].Frames.size(); + SetCursor(Cursors[ActiveIcon].Frames[frame].IconHW); + } +} + +//! Sets the active cursor icon +void CIrrDeviceWin32::CCursorControl::setActiveIcon(gui::ECURSOR_ICON iconId) +{ + if (iconId >= (s32)Cursors.size()) + return; + + ActiveIcon = iconId; + ActiveIconStartTime = Device->getTimer()->getRealTime(); + if (Cursors[ActiveIcon].Frames.size()) + SetCursor(Cursors[ActiveIcon].Frames[0].IconHW); +} + +//! Add a custom sprite as cursor icon. +gui::ECURSOR_ICON CIrrDeviceWin32::CCursorControl::addIcon(const gui::SCursorSprite &icon) +{ + if (icon.SpriteId >= 0) { + CursorW32 cW32; + cW32.FrameTime = icon.SpriteBank->getSprites()[icon.SpriteId].frameTime; + + for (u32 i = 0; i < icon.SpriteBank->getSprites()[icon.SpriteId].Frames.size(); ++i) { + irr::u32 texId = icon.SpriteBank->getSprites()[icon.SpriteId].Frames[i].textureNumber; + irr::u32 rectId = icon.SpriteBank->getSprites()[icon.SpriteId].Frames[i].rectNumber; + irr::core::rect rectIcon = icon.SpriteBank->getPositions()[rectId]; + + HCURSOR hc = Device->TextureToCursor(HWnd, icon.SpriteBank->getTexture(texId), rectIcon, icon.HotSpot); + cW32.Frames.push_back(CursorFrameW32(hc)); + } + + Cursors.push_back(cW32); + return (gui::ECURSOR_ICON)(Cursors.size() - 1); + } + return gui::ECI_NORMAL; +} + +//! replace the given cursor icon. +void CIrrDeviceWin32::CCursorControl::changeIcon(gui::ECURSOR_ICON iconId, const gui::SCursorSprite &icon) +{ + if (iconId >= (s32)Cursors.size()) + return; + + for (u32 i = 0; i < Cursors[iconId].Frames.size(); ++i) + DestroyCursor(Cursors[iconId].Frames[i].IconHW); + + if (icon.SpriteId >= 0) { + CursorW32 cW32; + cW32.FrameTime = icon.SpriteBank->getSprites()[icon.SpriteId].frameTime; + for (u32 i = 0; i < icon.SpriteBank->getSprites()[icon.SpriteId].Frames.size(); ++i) { + irr::u32 texId = icon.SpriteBank->getSprites()[icon.SpriteId].Frames[i].textureNumber; + irr::u32 rectId = icon.SpriteBank->getSprites()[icon.SpriteId].Frames[i].rectNumber; + irr::core::rect rectIcon = icon.SpriteBank->getPositions()[rectId]; + + HCURSOR hc = Device->TextureToCursor(HWnd, icon.SpriteBank->getTexture(texId), rectIcon, icon.HotSpot); + cW32.Frames.push_back(CursorFrameW32(hc)); + } + + Cursors[iconId] = cW32; + } +} + +//! Return a system-specific size which is supported for cursors. Larger icons will fail, smaller icons might work. +core::dimension2di CIrrDeviceWin32::CCursorControl::getSupportedIconSize() const +{ + core::dimension2di result; + + result.Width = GetSystemMetrics(SM_CXCURSOR); + result.Height = GetSystemMetrics(SM_CYCURSOR); + + return result; +} + +} // end namespace + +#endif // _IRR_COMPILE_WITH_WINDOWS_DEVICE_ diff --git a/irr/src/CIrrDeviceWin32.h b/irr/src/CIrrDeviceWin32.h new file mode 100644 index 000000000..8a4c14276 --- /dev/null +++ b/irr/src/CIrrDeviceWin32.h @@ -0,0 +1,405 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ + +#include "CIrrDeviceStub.h" +#include "IrrlichtDevice.h" + +#define WIN32_LEAN_AND_MEAN +#include +#include // For JOYCAPS +#include +#if !defined(GET_X_LPARAM) +#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp)) +#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp)) +#endif + +namespace irr +{ +struct SJoystickWin32Control; + +class CIrrDeviceWin32 : public CIrrDeviceStub +{ + friend struct SJoystickWin32Control; + +public: + //! constructor + CIrrDeviceWin32(const SIrrlichtCreationParameters ¶ms); + + //! destructor + virtual ~CIrrDeviceWin32(); + + //! runs the device. Returns false if device wants to be deleted + bool run() override; + + //! Cause the device to temporarily pause execution and let other processes to run + // This should bring down processor usage without major performance loss for Irrlicht + void yield() override; + + //! Pause execution and let other processes to run for a specified amount of time. + void sleep(u32 timeMs, bool pauseTimer) override; + + //! sets the caption of the window + void setWindowCaption(const wchar_t *text) override; + + //! Sets the window icon. + bool setWindowIcon(const video::IImage *img) override; + + //! returns if window is active. if not, nothing need to be drawn + bool isWindowActive() const override; + + //! returns if window has focus + bool isWindowFocused() const override; + + //! returns if window is minimized + bool isWindowMinimized() const override; + + //! returns last state from maximizeWindow() and restoreWindow() + bool isWindowMaximized() const override; + + //! notifies the device that it should close itself + void closeDevice() override; + + //! Notifies the device, that it has been resized + /** Must be publis as it is called from free function (event handler) */ + void OnResized(); + + //! Sets if the window should be resizable in windowed mode. + void setResizable(bool resize = false) override; + + //! Resize the render window. + void setWindowSize(const irr::core::dimension2d &size) override; + + //! Minimizes the window. + void minimizeWindow() override; + + //! Maximizes the window. + void maximizeWindow() override; + + //! Restores the window size. + void restoreWindow() override; + + //! Get the position of the window on screen + core::position2di getWindowPosition() override; + + //! Activate any joysticks, and generate events for them. + bool activateJoysticks(core::array &joystickInfo) override; + + //! Remove all messages pending in the system message loop + void clearSystemMessages() override; + + //! Get the device type + E_DEVICE_TYPE getType() const override + { + return EIDT_WIN32; + } + + //! Get the display density in dots per inch. + float getDisplayDensity() const override; + + //! Compares to the last call of this function to return double and triple clicks. + //! \return Returns only 1,2 or 3. A 4th click will start with 1 again. + u32 checkSuccessiveClicks(s32 mouseX, s32 mouseY, EMOUSE_INPUT_EVENT inputEvent) override + { + // we just have to make it public + return CIrrDeviceStub::checkSuccessiveClicks(mouseX, mouseY, inputEvent); + } + + //! Switch to fullscreen + bool switchToFullScreen(); + + // convert an Irrlicht texture to a windows cursor + HCURSOR TextureToCursor(HWND hwnd, irr::video::ITexture *tex, const core::rect &sourceRect, const core::position2d &hotspot); + + //! Implementation of the win32 cursor control + class CCursorControl : public gui::ICursorControl + { + public: + CCursorControl(CIrrDeviceWin32 *device, const core::dimension2d &wsize, HWND hwnd, bool fullscreen); + ~CCursorControl(); + + //! Changes the visible state of the mouse cursor. + void setVisible(bool visible) override + { + CURSORINFO info; + info.cbSize = sizeof(CURSORINFO); + BOOL gotCursorInfo = GetCursorInfo(&info); + while (gotCursorInfo) { +#ifdef CURSOR_SUPPRESSED + // Since Windows 8 the cursor can be suppressed by a touch interface + if (visible && info.flags == CURSOR_SUPPRESSED) { + break; + } +#endif + if ((visible && info.flags == CURSOR_SHOWING) || // visible + (!visible && info.flags == 0)) // hidden + { + break; + } + // this only increases an internal + // display counter in windows, so it + // might have to be called some more + const int showResult = ShowCursor(visible); + // if result has correct sign we can + // stop here as well + if ((!visible && showResult < 0) || + (visible && showResult >= 0)) + break; + // yes, it really must be set each time + info.cbSize = sizeof(CURSORINFO); + gotCursorInfo = GetCursorInfo(&info); + +#ifdef CURSOR_SUPPRESSED + // Not sure if a cursor which we tried to hide still can be suppressed. + // I have no touch-display for testing this and MSDN doesn't describe it. + // But adding this check shouldn't hurt and might prevent an endless loop. + if (!visible && info.flags == CURSOR_SUPPRESSED) { + break; + } +#endif + } + IsVisible = visible; + } + + //! Returns if the cursor is currently visible. + bool isVisible() const override + { + return IsVisible; + } + + //! Sets the new position of the cursor. + void setPosition(const core::position2d &pos) override + { + setPosition(pos.X, pos.Y); + } + + //! Sets the new position of the cursor. + void setPosition(f32 x, f32 y) override + { + if (!UseReferenceRect) + setPosition(core::round32(x * WindowSize.Width), core::round32(y * WindowSize.Height)); + else + setPosition(core::round32(x * ReferenceRect.getWidth()), core::round32(y * ReferenceRect.getHeight())); + } + + //! Sets the new position of the cursor. + void setPosition(const core::position2d &pos) override + { + setPosition(pos.X, pos.Y); + } + + //! Sets the new position of the cursor. + void setPosition(s32 x, s32 y) override + { + if (UseReferenceRect) { + SetCursorPos(ReferenceRect.UpperLeftCorner.X + x, + ReferenceRect.UpperLeftCorner.Y + y); + } else { + RECT rect; + if (GetWindowRect(HWnd, &rect)) + SetCursorPos(x + rect.left + BorderX, y + rect.top + BorderY); + } + + CursorPos.X = x; + CursorPos.Y = y; + } + + //! Returns the current position of the mouse cursor. + const core::position2d &getPosition(bool updateCursor) override + { + if (updateCursor) + updateInternalCursorPosition(); + return CursorPos; + } + + //! Returns the current position of the mouse cursor. + core::position2d getRelativePosition(bool updateCursor) override + { + if (updateCursor) + updateInternalCursorPosition(); + + if (!UseReferenceRect) { + return core::position2d(CursorPos.X * InvWindowSize.Width, + CursorPos.Y * InvWindowSize.Height); + } + + return core::position2d(CursorPos.X / (f32)ReferenceRect.getWidth(), + CursorPos.Y / (f32)ReferenceRect.getHeight()); + } + + //! Sets an absolute reference rect for calculating the cursor position. + void setReferenceRect(core::rect *rect = 0) override + { + if (rect) { + ReferenceRect = *rect; + UseReferenceRect = true; + + // prevent division through zero and uneven sizes + + if (!ReferenceRect.getHeight() || ReferenceRect.getHeight() % 2) + ReferenceRect.LowerRightCorner.Y += 1; + + if (!ReferenceRect.getWidth() || ReferenceRect.getWidth() % 2) + ReferenceRect.LowerRightCorner.X += 1; + } else + UseReferenceRect = false; + } + + /** Used to notify the cursor that the window was resized. */ + void OnResize(const core::dimension2d &size) + { + WindowSize = size; + if (size.Width != 0) + InvWindowSize.Width = 1.0f / size.Width; + else + InvWindowSize.Width = 0.f; + + if (size.Height != 0) + InvWindowSize.Height = 1.0f / size.Height; + else + InvWindowSize.Height = 0.f; + } + + /** Used to notify the cursor that the window resizable settings changed. */ + void updateBorderSize(bool fullscreen, bool resizable) + { + if (!fullscreen) { + s32 paddingBorder = 0; +#ifdef SM_CXPADDEDBORDER + paddingBorder = GetSystemMetrics(SM_CXPADDEDBORDER); +#endif + + if (resizable) { + BorderX = GetSystemMetrics(SM_CXSIZEFRAME) + paddingBorder; + BorderY = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYSIZEFRAME) + paddingBorder; + } else { + BorderX = GetSystemMetrics(SM_CXDLGFRAME) + paddingBorder; + BorderY = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYDLGFRAME) + paddingBorder; + } + } else { + BorderX = BorderY = 0; + } + } + + //! Sets the active cursor icon + void setActiveIcon(gui::ECURSOR_ICON iconId) override; + + //! Gets the currently active icon + gui::ECURSOR_ICON getActiveIcon() const override + { + return ActiveIcon; + } + + //! Add a custom sprite as cursor icon. + gui::ECURSOR_ICON addIcon(const gui::SCursorSprite &icon) override; + + //! replace the given cursor icon. + void changeIcon(gui::ECURSOR_ICON iconId, const gui::SCursorSprite &icon) override; + + //! Return a system-specific size which is supported for cursors. Larger icons will fail, smaller icons might work. + core::dimension2di getSupportedIconSize() const override; + + void update(); + + private: + //! Updates the internal cursor position + void updateInternalCursorPosition() + { + POINT p; + if (!GetCursorPos(&p)) { + DWORD xy = GetMessagePos(); + p.x = GET_X_LPARAM(xy); + p.y = GET_Y_LPARAM(xy); + } + + if (UseReferenceRect) { + CursorPos.X = p.x - ReferenceRect.UpperLeftCorner.X; + CursorPos.Y = p.y - ReferenceRect.UpperLeftCorner.Y; + } else { + RECT rect; + if (GetWindowRect(HWnd, &rect)) { + CursorPos.X = p.x - rect.left - BorderX; + CursorPos.Y = p.y - rect.top - BorderY; + } else { + // window seems not to be existent, so set cursor to + // a negative value + CursorPos.X = -1; + CursorPos.Y = -1; + } + } + } + + CIrrDeviceWin32 *Device; + core::position2d CursorPos; + core::dimension2d WindowSize; + core::dimension2d InvWindowSize; + HWND HWnd; + + s32 BorderX, BorderY; + core::rect ReferenceRect; + bool UseReferenceRect; + bool IsVisible; + + struct CursorFrameW32 + { + CursorFrameW32() : + IconHW(0) {} + CursorFrameW32(HCURSOR icon) : + IconHW(icon) {} + + HCURSOR IconHW; // hardware cursor + }; + + struct CursorW32 + { + CursorW32() {} + explicit CursorW32(HCURSOR iconHw, u32 frameTime = 0) : + FrameTime(frameTime) + { + Frames.push_back(CursorFrameW32(iconHw)); + } + core::array Frames; + u32 FrameTime; + }; + + core::array Cursors; + gui::ECURSOR_ICON ActiveIcon; + u32 ActiveIconStartTime; + + void initCursors(); + }; + + //! returns the win32 cursor control + CCursorControl *getWin32CursorControl(); + +private: + //! create the driver + void createDriver(); + + //! Process system events + void handleSystemMessages(); + + void getWindowsVersion(core::stringc &version); + + void resizeIfNecessary(); + + DWORD getWindowStyle(bool fullscreen, bool resizable) const; + + HWND HWnd; + + bool Resized; + bool ExternalWindow; + CCursorControl *Win32CursorControl; + + SJoystickWin32Control *JoyControl; + + bool WindowMaximized; +}; + +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_WINDOWS_DEVICE_ diff --git a/irr/src/CLimitReadFile.cpp b/irr/src/CLimitReadFile.cpp new file mode 100644 index 000000000..de9bf9ec3 --- /dev/null +++ b/irr/src/CLimitReadFile.cpp @@ -0,0 +1,115 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CLimitReadFile.h" +#include "irrMath.h" +#include "irrString.h" + +namespace irr +{ +namespace io +{ + +CLimitReadFile::CLimitReadFile(IReadFile *alreadyOpenedFile, long pos, + long areaSize, const io::path &name) : + Filename(name), + AreaStart(0), AreaEnd(0), Pos(0), + File(alreadyOpenedFile) +{ +#ifdef _DEBUG + setDebugName("CLimitReadFile"); +#endif + + if (File) { + File->grab(); + AreaStart = pos; + AreaEnd = AreaStart + areaSize; + } +} + +CLimitReadFile::~CLimitReadFile() +{ + if (File) + File->drop(); +} + +//! returns how much was read +size_t CLimitReadFile::read(void *buffer, size_t sizeToRead) +{ + if (0 == File) + return 0; + +#if 1 + long r = AreaStart + Pos; + long toRead = core::min_(AreaEnd, r + (long)sizeToRead) - core::max_(AreaStart, r); + if (toRead < 0) + return 0; + File->seek(r); + r = (long)File->read(buffer, toRead); + Pos += r; + return r; +#else + const long pos = File->getPos(); + + if (pos >= AreaEnd) + return 0; + + if (pos + (long)sizeToRead >= AreaEnd) + sizeToRead = AreaEnd - pos; + + return File->read(buffer, sizeToRead); +#endif +} + +//! changes position in file, returns true if successful +bool CLimitReadFile::seek(long finalPos, bool relativeMovement) +{ +#if 1 + Pos = core::s32_clamp(finalPos + (relativeMovement ? Pos : 0), 0, AreaEnd - AreaStart); + return true; +#else + const long pos = File->getPos(); + + if (relativeMovement) { + if (pos + finalPos > AreaEnd) + finalPos = AreaEnd - pos; + } else { + finalPos += AreaStart; + if (finalPos > AreaEnd) + return false; + } + + return File->seek(finalPos, relativeMovement); +#endif +} + +//! returns size of file +long CLimitReadFile::getSize() const +{ + return AreaEnd - AreaStart; +} + +//! returns where in the file we are. +long CLimitReadFile::getPos() const +{ +#if 1 + return Pos; +#else + return File->getPos() - AreaStart; +#endif +} + +//! returns name of file +const io::path &CLimitReadFile::getFileName() const +{ + return Filename; +} + +IReadFile *createLimitReadFile(const io::path &fileName, IReadFile *alreadyOpenedFile, long pos, long areaSize) +{ + return new CLimitReadFile(alreadyOpenedFile, pos, areaSize, fileName); +} + +} // end namespace io +} // end namespace irr diff --git a/irr/src/CLimitReadFile.h b/irr/src/CLimitReadFile.h new file mode 100644 index 000000000..1594135e6 --- /dev/null +++ b/irr/src/CLimitReadFile.h @@ -0,0 +1,62 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReadFile.h" +#include "irrString.h" + +namespace irr +{ +class CUnicodeConverter; + +namespace io +{ + +/*! this is a read file, which is limited to some boundaries, + so that it may only start from a certain file position + and may only read until a certain file position. + This can be useful, for example for reading uncompressed files + in an archive (zip, tar). +!*/ +class CLimitReadFile : public IReadFile +{ +public: + CLimitReadFile(IReadFile *alreadyOpenedFile, long pos, long areaSize, const io::path &name); + + virtual ~CLimitReadFile(); + + //! returns how much was read + size_t read(void *buffer, size_t sizeToRead) override; + + //! changes position in file, returns true if successful + //! if relativeMovement==true, the pos is changed relative to current pos, + //! otherwise from begin of file + bool seek(long finalPos, bool relativeMovement = false) override; + + //! returns size of file + long getSize() const override; + + //! returns where in the file we are. + long getPos() const override; + + //! returns name of file + const io::path &getFileName() const override; + + //! Get the type of the class implementing this interface + EREAD_FILE_TYPE getType() const override + { + return ERFT_LIMIT_READ_FILE; + } + +private: + io::path Filename; + long AreaStart; + long AreaEnd; + long Pos; + IReadFile *File; +}; + +} // end namespace io +} // end namespace irr diff --git a/irr/src/CLogger.cpp b/irr/src/CLogger.cpp new file mode 100644 index 000000000..70d06b36a --- /dev/null +++ b/irr/src/CLogger.cpp @@ -0,0 +1,66 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CLogger.h" + +namespace irr +{ + +CLogger::CLogger(IEventReceiver *r) : + LogLevel(ELL_INFORMATION), Receiver(r) +{ +#ifdef _DEBUG + setDebugName("CLogger"); +#endif +} + +//! Returns the current set log level. +ELOG_LEVEL CLogger::getLogLevel() const +{ + return LogLevel; +} + +//! Sets a new log level. +void CLogger::setLogLevel(ELOG_LEVEL ll) +{ + LogLevel = ll; +} + +//! Prints out a text into the log +void CLogger::log(const c8 *text, ELOG_LEVEL ll) +{ + if (ll < LogLevel) + return; + + if (Receiver) { + SEvent event; + event.EventType = EET_LOG_TEXT_EVENT; + event.LogEvent.Text = text; + event.LogEvent.Level = ll; + if (Receiver->OnEvent(event)) + return; + } + + os::Printer::print(text); +} + +//! Prints out a text into the log +void CLogger::log(const c8 *text, const c8 *hint, ELOG_LEVEL ll) +{ + if (ll < LogLevel) + return; + + core::stringc s = text; + s += ": "; + s += hint; + log(s.c_str(), ll); +} + +//! Sets a new event receiver +void CLogger::setReceiver(IEventReceiver *r) +{ + Receiver = r; +} + +} // end namespace irr diff --git a/irr/src/CLogger.h b/irr/src/CLogger.h new file mode 100644 index 000000000..e9cfae8fc --- /dev/null +++ b/irr/src/CLogger.h @@ -0,0 +1,41 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "ILogger.h" +#include "os.h" +#include "irrString.h" +#include "IEventReceiver.h" + +namespace irr +{ + +//! Class for logging messages, warnings and errors to stdout +class CLogger : public ILogger +{ +public: + CLogger(IEventReceiver *r); + + //! Returns the current set log level. + ELOG_LEVEL getLogLevel() const override; + + //! Sets a new log level. void setLogLevel(ELOG_LEVEL ll) override; + void setLogLevel(ELOG_LEVEL ll) override; + + //! Prints out a text into the log + void log(const c8 *text, ELOG_LEVEL ll = ELL_INFORMATION) override; + + //! Prints out a text into the log + void log(const c8 *text, const c8 *hint, ELOG_LEVEL ll = ELL_INFORMATION) override; + + //! Sets a new event receiver + void setReceiver(IEventReceiver *r); + +private: + ELOG_LEVEL LogLevel; + IEventReceiver *Receiver; +}; + +} // end namespace diff --git a/irr/src/CMakeLists.txt b/irr/src/CMakeLists.txt new file mode 100644 index 000000000..46eaf9cca --- /dev/null +++ b/irr/src/CMakeLists.txt @@ -0,0 +1,580 @@ +if(NOT ANDROID AND NOT APPLE) + set(DEFAULT_SDL2 ON) +endif() + +option(BUILD_SHARED_LIBS "Build shared library" TRUE) +option(USE_SDL2 "Use the SDL2 backend" ${DEFAULT_SDL2}) + +# Compiler flags + +add_definitions(-DIRRLICHT_EXPORTS) +if(BUILD_SHARED_LIBS) + if(WIN32) + set(API_IMPORT "__declspec(dllimport)") + set(API_EXPORT "__declspec(dllexport)") + elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$") + set(API_EXPORT "__attribute__ ((visibility(\"default\")))") # only necessary if default visibility is set to hidden + endif() +else() + add_definitions(-D_IRR_STATIC_LIB_) +endif() +add_definitions("-DIRRLICHT_API=${API_EXPORT}") + +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + add_definitions(-D_DEBUG) +endif() +set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) + +if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$") + set(CMAKE_CXX_FLAGS_RELEASE "-O3") + set(CMAKE_CXX_FLAGS_DEBUG "-g") + + add_compile_options(-Wall -pipe -fno-exceptions) + + # Enable SSE for floating point math on 32-bit x86 by default + # reasoning see minetest issue #11810 and https://gcc.gnu.org/wiki/FloatingPointMath + if(CMAKE_SIZEOF_VOID_P EQUAL 4) + include(CheckCXXSourceCompiles) + check_cxx_source_compiles("#ifndef __i686__\n#error\n#endif\nint main(){}" IS_I686) + if(IS_I686) + message(STATUS "Detected Intel x86: using SSE instead of x87 FPU") + add_compile_options(-mfpmath=sse -msse) + endif() + endif() + +elseif(MSVC) + string(APPEND CMAKE_CXX_STANDARD_LIBRARIES " msvcrt.lib") # ???? fuck off + + add_compile_options(/GR- /Zl) + + # Enable SSE for floating point math on 32-bit x86 by default + # reasoning see minetest issue #11810 and https://gcc.gnu.org/wiki/FloatingPointMath + if(CMAKE_SIZEOF_VOID_P EQUAL 4) + add_compile_options(/arch:SSE) + endif() + + add_compile_options(/D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING) +endif() + +# Sanity-check version + +include(CheckCXXSourceCompiles) +set(CMAKE_REQUIRED_INCLUDES ${PROJECT_SOURCE_DIR}/include) +unset(REVISION_SANITY_CHECK CACHE) +check_cxx_source_compiles("#include \n\ +#if IRRLICHT_VERSION_MT_REVISION != ${IRRLICHTMT_REVISION}\n\ +#error\n\ +#endif\n\ +int main() {}" REVISION_SANITY_CHECK) +if(NOT REVISION_SANITY_CHECK) + message(FATAL_ERROR "IrrlichtMt revision number mismatches between CMake and headers.") +endif() + +# Platform-independent configuration (hard-coded currently) +add_definitions( + -DIRR_ENABLE_BUILTIN_FONT +) + +# Platform-specific configuration + +if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") + set(SOLARIS TRUE) +endif() + +# Device + +if(WIN32) + add_definitions(-D_IRR_WINDOWS_ -D_IRR_WINDOWS_API_) + set(DEVICE "WINDOWS") +elseif(APPLE) + add_definitions(-D_IRR_OSX_PLATFORM_) + set(DEVICE "OSX") +elseif(ANDROID) + add_definitions(-D_IRR_ANDROID_PLATFORM_) + if(USE_SDL2) + message(FATAL_ERROR "SDL2 device is not (yet) supported on Android") + endif() + set(DEVICE "ANDROID") +elseif(EMSCRIPTEN) + add_definitions(-D_IRR_EMSCRIPTEN_PLATFORM_ -D_IRR_COMPILE_WITH_EGL_MANAGER_) + set(LINUX_PLATFORM TRUE) + set(DEVICE "SDL") +elseif(SOLARIS) + add_definitions(-D_IRR_SOLARIS_PLATFORM_ -D_IRR_POSIX_API_) + set(DEVICE "X11") +else() + add_definitions(-D_IRR_POSIX_API_) + set(LINUX_PLATFORM TRUE) + set(DEVICE "X11") +endif() + +if(LINUX_PLATFORM) + add_definitions(-D_IRR_LINUX_PLATFORM_) +endif() + +if(USE_SDL2) + set(DEVICE "SDL") +elseif(DEVICE STREQUAL "SDL") + message(FATAL_ERROR "SDL was used but not enabled?!") +endif() + +add_definitions("-D_IRR_COMPILE_WITH_${DEVICE}_DEVICE_") + +# X11 + +if(DEVICE STREQUAL "X11") + option(USE_X11 "Use X11" TRUE) +else() + set(USE_X11 FALSE) +endif() + +if(LINUX_PLATFORM AND USE_X11) + option(USE_XINPUT2 "Use XInput2" TRUE) + option(USE_XCURSOR "Use XCursor" FALSE) +else() + set(USE_XINPUT2 FALSE) + set(USE_XCURSOR FALSE) +endif() + +# Joystick + +if(NOT (BSD OR SOLARIS OR EMSCRIPTEN)) + add_definitions(-D_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) +endif() + +# OpenGL + +if(USE_SDL2) + option(ENABLE_OPENGL3 "Enable OpenGL 3+" TRUE) +else() + set(ENABLE_OPENGL3 FALSE) +endif() + +if(ANDROID OR EMSCRIPTEN) + set(ENABLE_OPENGL FALSE) +else() + option(ENABLE_OPENGL "Enable OpenGL" TRUE) +endif() + +if(EMSCRIPTEN OR APPLE) + set(ENABLE_GLES1 FALSE) +else() + if(ANDROID) + set(DEFAULT_GLES1 TRUE) + endif() + option(ENABLE_GLES1 "Enable OpenGL ES" ${DEFAULT_GLES1}) +endif() + +if(APPLE) + set(ENABLE_GLES2 FALSE) + set(ENABLE_WEBGL1 FALSE) +else() + if(ANDROID OR EMSCRIPTEN) + set(DEFAULT_GLES2 TRUE) + endif() + if(EMSCRIPTEN) + set(DEFAULT_WEBGL1 TRUE) + endif() + option(ENABLE_GLES2 "Enable OpenGL ES 2+" ${DEFAULT_GLES2}) + #option(ENABLE_WEBGL1 "Enable WebGL (requires GLES2)" ${DEFAULT_WEBGL1}) + set(ENABLE_WEBGL1 FALSE) # not working currently + if(ENABLE_WEBGL1) + set(ENABLE_GLES2 TRUE) + endif() +endif() + +if(ENABLE_OPENGL) + add_definitions(-D_IRR_COMPILE_WITH_OPENGL_) + set(OPENGL_DIRECT_LINK TRUE) # driver relies on this + if(DEVICE STREQUAL "WINDOWS") + add_definitions(-D_IRR_COMPILE_WITH_WGL_MANAGER_) + elseif(DEVICE STREQUAL "X11") + add_definitions(-D_IRR_COMPILE_WITH_GLX_MANAGER_) + elseif(DEVICE STREQUAL "OSX") + add_definitions(-D_IRR_COMPILE_WITH_NSOGL_MANAGER_) + endif() +endif() + +if(ENABLE_OPENGL3) + if (NOT USE_SDL2) + message(FATAL_ERROR "OpenGL 3 driver requires SDL2") + endif() +endif() + +if(ENABLE_GLES1) + if (USE_SDL2) + message(FATAL_ERROR "OpenGL ES 1 is not supported with SDL2") + endif() + add_definitions(-D_IRR_COMPILE_WITH_OGLES1_) + set(OPENGLES_DIRECT_LINK TRUE) + if(DEVICE MATCHES "^(WINDOWS|X11|ANDROID)$") + add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_) + endif() +endif() + +if(ENABLE_GLES2) + add_definitions(-D_IRR_COMPILE_WITH_OGLES2_) + if(DEVICE MATCHES "^(WINDOWS|X11|ANDROID)$" OR EMSCRIPTEN) + add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_) + endif() +endif() + +if(ENABLE_WEBGL1) + add_definitions(-D_IRR_COMPILE_WITH_WEBGL1_) +endif() + +# Misc + +include(TestBigEndian) +TEST_BIG_ENDIAN(BIG_ENDIAN) +if(BIG_ENDIAN) + add_definitions(-D__BIG_ENDIAN__) +endif() + +# Configuration report + +message(STATUS "Device: ${DEVICE}") +message(STATUS "OpenGL: ${ENABLE_OPENGL}") +message(STATUS "OpenGL 3: ${ENABLE_OPENGL3}") +message(STATUS "OpenGL ES: ${ENABLE_GLES1}") +if (ENABLE_GLES2) + message(STATUS "OpenGL ES 2: ON (unified)") +else() + message(STATUS "OpenGL ES 2: OFF") +endif() +#message(STATUS "WebGL: ${ENABLE_WEBGL1}") + +# Required libs + +find_package(ZLIB REQUIRED) +find_package(JPEG REQUIRED) +find_package(PNG REQUIRED) + + +if(ENABLE_GLES1) + # only tested on Android, probably works on Linux (is this needed anywhere else?) + find_library(OPENGLES_LIBRARY NAMES GLESv1_CM REQUIRED) + find_library(EGL_LIBRARY NAMES EGL REQUIRED) + + message(STATUS "Found OpenGLES: ${OPENGLES_LIBRARY}") +endif() +if(ENABLE_GLES2) + find_package(OpenGLES2 REQUIRED) +endif() +if(ENABLE_OPENGL OR ENABLE_OPENGL3) + find_package(OpenGL REQUIRED) +endif() +if(USE_SDL2) + find_package(SDL2 REQUIRED) + message(STATUS "Found SDL2: ${SDL2_LIBRARIES}") + + # unfortunately older SDL does not provide its version to cmake, so check header. + set(CMAKE_REQUIRED_INCLUDES ${SDL2_INCLUDE_DIRS}) + unset(CHECK_SDL_VERSION CACHE) + check_cxx_source_compiles("#include \n\ +#if !SDL_VERSION_ATLEAST(2, 0, 10)\n\ +#error\n\ +#endif\n\ +int main() {}" CHECK_SDL_VERSION) + if(NOT CHECK_SDL_VERSION) + message(FATAL_ERROR "SDL2 is too old, required is at least 2.0.10!") + endif() + + # ...no target either. + if(NOT TARGET SDL2::SDL2) + add_library(SDL2::SDL2 SHARED IMPORTED) + set_target_properties(SDL2::SDL2 PROPERTIES + IMPORTED_LOCATION "${SDL2_LIBRARIES}") + endif() +endif() + +# More special config + +if(ENABLE_OPENGL AND DEVICE STREQUAL "SDL") + # The legacy GL driver requires some symbols from GL 4.5 to compile, + # which SDL only provides since 2.26.0 (Nov 2022). + # We have a fallback in case this isn't satisfied so test for it. + set(CMAKE_REQUIRED_INCLUDES ${SDL2_INCLUDE_DIRS}) + unset(CHECK_GL_VERSION_4_5 CACHE) + check_cxx_source_compiles("#include \n\ +#ifndef GL_VERSION_4_5\n\ +#error\n\ +#endif\n\ +int main() {}" CHECK_GL_VERSION_4_5) + if(CHECK_GL_VERSION_4_5) + add_definitions(-DIRR_PREFER_SDL_GL_HEADER) + endif() +endif() + +# Platform-specific libs + +if(ANDROID) + enable_language(C) +elseif(APPLE) + find_library(COCOA_LIB Cocoa REQUIRED) + find_library(IOKIT_LIB IOKit REQUIRED) + + add_definitions(-DGL_SILENCE_DEPRECATION) +elseif(NOT USE_SDL2) + # Unix probably + find_package(X11 REQUIRED) + if(USE_XINPUT2 AND NOT X11_Xi_FOUND) + message(FATAL_ERROR "XInput not found") + endif() +endif() + +set(link_includes + "${PROJECT_SOURCE_DIR}/include" + "${CMAKE_CURRENT_SOURCE_DIR}" + + "${ZLIB_INCLUDE_DIR}" + "${JPEG_INCLUDE_DIR}" + "${PNG_INCLUDE_DIR}" + "$<$:${SDL2_INCLUDE_DIRS}>" + + ${OPENGL_INCLUDE_DIR} + ${OPENGLES2_INCLUDE_DIR} + ${EGL_INCLUDE_DIR} + + "$<$:${ANDROID_NDK}/sources/android/native_app_glue>" + "$<$:${X11_INCLUDE_DIR}>" +) + +# Source files + +set(IRRMESHLOADER + CB3DMeshFileLoader.cpp + COBJMeshFileLoader.cpp + CXMeshFileLoader.cpp +) + +add_library(IRRMESHOBJ OBJECT + CSkinnedMesh.cpp + CBoneSceneNode.cpp + CMeshSceneNode.cpp + CAnimatedMeshSceneNode.cpp + ${IRRMESHLOADER} +) + +add_library(IRROBJ OBJECT + CBillboardSceneNode.cpp + CCameraSceneNode.cpp + CDummyTransformationSceneNode.cpp + CEmptySceneNode.cpp + CMeshManipulator.cpp + CSceneCollisionManager.cpp + CSceneManager.cpp + CMeshCache.cpp +) + +set(IRRDRVROBJ + CNullDriver.cpp + CGLXManager.cpp + CWGLManager.cpp + CEGLManager.cpp + CSDLManager.cpp + mt_opengl_loader.cpp +) + +# the two legacy drivers + +if(ENABLE_OPENGL) + set(IRRDRVROBJ + ${IRRDRVROBJ} + COpenGLCacheHandler.cpp + COpenGLDriver.cpp + COpenGLSLMaterialRenderer.cpp + COpenGLExtensionHandler.cpp + ) +endif() + +if(ENABLE_GLES1) + set(IRRDRVROBJ + ${IRRDRVROBJ} + COGLESDriver.cpp + COGLESExtensionHandler.cpp + ) +endif() + +# the unified drivers + +if(ENABLE_OPENGL3 OR ENABLE_GLES2) + set(IRRDRVROBJ + ${IRRDRVROBJ} + OpenGL/Driver.cpp + OpenGL/ExtensionHandler.cpp + OpenGL/FixedPipelineRenderer.cpp + OpenGL/MaterialRenderer.cpp + OpenGL/Renderer2D.cpp + ) +endif() + +if(ENABLE_OPENGL3) + set(IRRDRVROBJ + ${IRRDRVROBJ} + OpenGL3/Driver.cpp + ) +endif() + +if(ENABLE_GLES2) + set(IRRDRVROBJ + ${IRRDRVROBJ} + OpenGLES2/Driver.cpp + ) +endif() + +set(IRRIMAGEOBJ + CColorConverter.cpp + CImage.cpp + CImageLoaderBMP.cpp + CImageLoaderJPG.cpp + CImageLoaderPNG.cpp + CImageLoaderTGA.cpp + CImageWriterJPG.cpp + CImageWriterPNG.cpp +) + +add_library(IRRVIDEOOBJ OBJECT + CFPSCounter.cpp + ${IRRDRVROBJ} + ${IRRIMAGEOBJ} +) + +add_library(IRRIOOBJ OBJECT + CFileList.cpp + CFileSystem.cpp + CLimitReadFile.cpp + CMemoryFile.cpp + CReadFile.cpp + CWriteFile.cpp + CZipReader.cpp + CAttributes.cpp +) + +add_library(IRROTHEROBJ OBJECT + CIrrDeviceSDL.cpp + CIrrDeviceLinux.cpp + CIrrDeviceStub.cpp + CIrrDeviceWin32.cpp + CLogger.cpp + COSOperator.cpp + Irrlicht.cpp + os.cpp +) + +if(ENABLE_OPENGL3) + target_compile_definitions(IRROTHEROBJ PRIVATE ENABLE_OPENGL3) +endif() + +if(ANDROID) + target_sources(IRROTHEROBJ PRIVATE + Android/CIrrDeviceAndroid.cpp + Android/CAndroidAssetReader.cpp + Android/CAndroidAssetFileArchive.cpp + Android/CKeyEventWrapper.cpp + ) +elseif(APPLE) + # Build all IRROTHEROBJ sources as objc++, including the .cpp's + set_target_properties(IRROTHEROBJ PROPERTIES COMPILE_OPTIONS "-xobjective-c++") + target_sources(IRROTHEROBJ PRIVATE + CIrrDeviceOSX.mm + CNSOGLManager.mm + ) +endif() + +if(USE_X11) + target_compile_definitions(IRROTHEROBJ PRIVATE _IRR_COMPILE_WITH_X11_) +endif() + +if(USE_XINPUT2) + target_compile_definitions(IRROTHEROBJ PRIVATE _IRR_LINUX_X11_XINPUT2_) +endif() + +if(USE_XCURSOR) + target_compile_definitions(IRROTHEROBJ PRIVATE _IRR_LINUX_XCURSOR_) +endif() + +add_library(IRRGUIOBJ OBJECT + CGUIButton.cpp + CGUICheckBox.cpp + CGUIComboBox.cpp + CGUIEditBox.cpp + CGUIEnvironment.cpp + CGUIFileOpenDialog.cpp + CGUIFont.cpp + CGUIImage.cpp + CGUIListBox.cpp + CGUIScrollBar.cpp + CGUISkin.cpp + CGUIStaticText.cpp + CGUITabControl.cpp + CGUISpriteBank.cpp + CGUIImageList.cpp +) + +# Library + +add_library(IrrlichtMt) +foreach(object_lib + IRRMESHOBJ IRROBJ IRRVIDEOOBJ + IRRIOOBJ IRROTHEROBJ IRRGUIOBJ) + # Set include directories for object library compilation + target_include_directories(${object_lib} PRIVATE ${link_includes}) + # Add objects from object library to main library + target_sources(IrrlichtMt PRIVATE $) +endforeach() + +# Alias target provides add_submodule compatibility +add_library(IrrlichtMt::IrrlichtMt ALIAS IrrlichtMt) + +target_include_directories(IrrlichtMt + PUBLIC + "$" + "$" + "$" + PRIVATE + ${link_includes} +) + +# this needs to be here and not in a variable (like link_includes) due to issues +# with the generator expressions on at least CMake 3.22, but not 3.28 or later +target_link_libraries(IrrlichtMt PRIVATE + ${ZLIB_LIBRARY} + ${JPEG_LIBRARY} + ${PNG_LIBRARY} + "$<$:SDL2::SDL2>" + + "$<$:${OPENGL_LIBRARIES}>" + "$<$:${OPENGLES_LIBRARY}>" + ${EGL_LIBRARY} + + "$<$:-landroid -llog>" + ${COCOA_LIB} + ${IOKIT_LIB} + "$<$:gdi32>" + "$<$:winmm>" + "$<$:${X11_X11_LIB}>" + "$<$:${X11_Xi_LIB}>" +) + +if(WIN32) + target_compile_definitions(IrrlichtMt INTERFACE _IRR_WINDOWS_API_) # used in _IRR_DEBUG_BREAK_IF definition in a public header +endif() +target_compile_definitions(IrrlichtMt INTERFACE "IRRLICHT_API=${API_IMPORT}") +if(APPLE OR ANDROID OR EMSCRIPTEN) + target_compile_definitions(IrrlichtMt PUBLIC IRR_MOBILE_PATHS) +endif() + +set_target_properties(IrrlichtMt PROPERTIES + VERSION ${PROJECT_VERSION} +) + +if(WIN32) + set_target_properties(IrrlichtMt PROPERTIES PREFIX "") # for DLL name +endif() + +# Installation of library +install(TARGETS IrrlichtMt + EXPORT IrrlichtMt-export + DESTINATION "${CMAKE_INSTALL_LIBDIR}" +) diff --git a/irr/src/CMemoryFile.cpp b/irr/src/CMemoryFile.cpp new file mode 100644 index 000000000..6d7906b91 --- /dev/null +++ b/irr/src/CMemoryFile.cpp @@ -0,0 +1,165 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CMemoryFile.h" +#include "irrString.h" + +namespace irr +{ +namespace io +{ + +CMemoryReadFile::CMemoryReadFile(const void *memory, long len, const io::path &fileName, bool d) : + Buffer(memory), Len(len), Pos(0), Filename(fileName), deleteMemoryWhenDropped(d) +{ +#ifdef _DEBUG + setDebugName("CMemoryReadFile"); +#endif +} + +CMemoryReadFile::~CMemoryReadFile() +{ + if (deleteMemoryWhenDropped) + delete[] (c8 *)Buffer; +} + +//! returns how much was read +size_t CMemoryReadFile::read(void *buffer, size_t sizeToRead) +{ + long amount = static_cast(sizeToRead); + if (Pos + amount > Len) + amount -= Pos + amount - Len; + + if (amount <= 0) + return 0; + + c8 *p = (c8 *)Buffer; + memcpy(buffer, p + Pos, amount); + + Pos += amount; + + return static_cast(amount); +} + +//! changes position in file, returns true if successful +//! if relativeMovement==true, the pos is changed relative to current pos, +//! otherwise from begin of file +bool CMemoryReadFile::seek(long finalPos, bool relativeMovement) +{ + if (relativeMovement) { + if (Pos + finalPos < 0 || Pos + finalPos > Len) + return false; + + Pos += finalPos; + } else { + if (finalPos < 0 || finalPos > Len) + return false; + + Pos = finalPos; + } + + return true; +} + +//! returns size of file +long CMemoryReadFile::getSize() const +{ + return Len; +} + +//! returns where in the file we are. +long CMemoryReadFile::getPos() const +{ + return Pos; +} + +//! returns name of file +const io::path &CMemoryReadFile::getFileName() const +{ + return Filename; +} + +CMemoryWriteFile::CMemoryWriteFile(void *memory, long len, const io::path &fileName, bool d) : + Buffer(memory), Len(len), Pos(0), Filename(fileName), deleteMemoryWhenDropped(d) +{ +#ifdef _DEBUG + setDebugName("CMemoryWriteFile"); +#endif +} + +CMemoryWriteFile::~CMemoryWriteFile() +{ + if (deleteMemoryWhenDropped) + delete[] (c8 *)Buffer; +} + +//! returns how much was written +size_t CMemoryWriteFile::write(const void *buffer, size_t sizeToWrite) +{ + long amount = (long)sizeToWrite; + if (Pos + amount > Len) + amount -= Pos + amount - Len; + + if (amount <= 0) + return 0; + + c8 *p = (c8 *)Buffer; + memcpy(p + Pos, buffer, amount); + + Pos += amount; + + return (size_t)amount; +} + +//! changes position in file, returns true if successful +//! if relativeMovement==true, the pos is changed relative to current pos, +//! otherwise from begin of file +bool CMemoryWriteFile::seek(long finalPos, bool relativeMovement) +{ + if (relativeMovement) { + if (Pos + finalPos < 0 || Pos + finalPos > Len) + return false; + + Pos += finalPos; + } else { + if (finalPos < 0 || finalPos > Len) + return false; + + Pos = finalPos; + } + + return true; +} + +//! returns where in the file we are. +long CMemoryWriteFile::getPos() const +{ + return Pos; +} + +//! returns name of file +const io::path &CMemoryWriteFile::getFileName() const +{ + return Filename; +} + +bool CMemoryWriteFile::flush() +{ + return true; // no buffering, so nothing to do +} + +IReadFile *createMemoryReadFile(const void *memory, long size, const io::path &fileName, bool deleteMemoryWhenDropped) +{ + CMemoryReadFile *file = new CMemoryReadFile(memory, size, fileName, deleteMemoryWhenDropped); + return file; +} + +IWriteFile *createMemoryWriteFile(void *memory, long size, const io::path &fileName, bool deleteMemoryWhenDropped) +{ + CMemoryWriteFile *file = new CMemoryWriteFile(memory, size, fileName, deleteMemoryWhenDropped); + return file; +} + +} // end namespace io +} // end namespace irr diff --git a/irr/src/CMemoryFile.h b/irr/src/CMemoryFile.h new file mode 100644 index 000000000..3ce0e8460 --- /dev/null +++ b/irr/src/CMemoryFile.h @@ -0,0 +1,99 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IMemoryReadFile.h" +#include "IWriteFile.h" +#include "irrString.h" + +namespace irr +{ + +namespace io +{ + +/*! + Class for reading from memory. +*/ +class CMemoryReadFile : public IMemoryReadFile +{ +public: + //! Constructor + CMemoryReadFile(const void *memory, long len, const io::path &fileName, bool deleteMemoryWhenDropped); + + //! Destructor + virtual ~CMemoryReadFile(); + + //! returns how much was read + size_t read(void *buffer, size_t sizeToRead) override; + + //! changes position in file, returns true if successful + bool seek(long finalPos, bool relativeMovement = false) override; + + //! returns size of file + long getSize() const override; + + //! returns where in the file we are. + long getPos() const override; + + //! returns name of file + const io::path &getFileName() const override; + + //! Get the type of the class implementing this interface + EREAD_FILE_TYPE getType() const override + { + return ERFT_MEMORY_READ_FILE; + } + + //! Get direct access to internal buffer + const void *getBuffer() const override + { + return Buffer; + } + +private: + const void *Buffer; + long Len; + long Pos; + io::path Filename; + bool deleteMemoryWhenDropped; +}; + +/*! + Class for writing to memory. +*/ +class CMemoryWriteFile : public IWriteFile +{ +public: + //! Constructor + CMemoryWriteFile(void *memory, long len, const io::path &fileName, bool deleteMemoryWhenDropped); + + //! Destructor + virtual ~CMemoryWriteFile(); + + //! returns how much was written + size_t write(const void *buffer, size_t sizeToWrite) override; + + //! changes position in file, returns true if successful + bool seek(long finalPos, bool relativeMovement = false) override; + + //! returns where in the file we are. + long getPos() const override; + + //! returns name of file + const io::path &getFileName() const override; + + bool flush() override; + +private: + void *Buffer; + long Len; + long Pos; + io::path Filename; + bool deleteMemoryWhenDropped; +}; + +} // end namespace io +} // end namespace irr diff --git a/irr/src/CMeshCache.cpp b/irr/src/CMeshCache.cpp new file mode 100644 index 000000000..4f7e1203c --- /dev/null +++ b/irr/src/CMeshCache.cpp @@ -0,0 +1,156 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CMeshCache.h" +#include "IAnimatedMesh.h" +#include "IMesh.h" + +namespace irr +{ +namespace scene +{ + +static const io::SNamedPath emptyNamedPath; + +CMeshCache::~CMeshCache() +{ + clear(); +} + +//! adds a mesh to the list +void CMeshCache::addMesh(const io::path &filename, IAnimatedMesh *mesh) +{ + mesh->grab(); + + MeshEntry e(filename); + e.Mesh = mesh; + + Meshes.push_back(e); +} + +//! Removes a mesh from the cache. +void CMeshCache::removeMesh(const IMesh *const mesh) +{ + if (!mesh) + return; + for (u32 i = 0; i < Meshes.size(); ++i) { + if (Meshes[i].Mesh == mesh || (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh)) { + Meshes[i].Mesh->drop(); + Meshes.erase(i); + return; + } + } +} + +//! Returns amount of loaded meshes +u32 CMeshCache::getMeshCount() const +{ + return Meshes.size(); +} + +//! Returns current number of the mesh +s32 CMeshCache::getMeshIndex(const IMesh *const mesh) const +{ + for (u32 i = 0; i < Meshes.size(); ++i) { + if (Meshes[i].Mesh == mesh || (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh)) + return (s32)i; + } + + return -1; +} + +//! Returns a mesh based on its index number +IAnimatedMesh *CMeshCache::getMeshByIndex(u32 number) +{ + if (number >= Meshes.size()) + return 0; + + return Meshes[number].Mesh; +} + +//! Returns a mesh based on its name. +IAnimatedMesh *CMeshCache::getMeshByName(const io::path &name) +{ + MeshEntry e(name); + s32 id = Meshes.binary_search(e); + return (id != -1) ? Meshes[id].Mesh : 0; +} + +//! Get the name of a loaded mesh, based on its index. +const io::SNamedPath &CMeshCache::getMeshName(u32 index) const +{ + if (index >= Meshes.size()) + return emptyNamedPath; + + return Meshes[index].NamedPath; +} + +//! Get the name of a loaded mesh, if there is any. +const io::SNamedPath &CMeshCache::getMeshName(const IMesh *const mesh) const +{ + if (!mesh) + return emptyNamedPath; + + for (u32 i = 0; i < Meshes.size(); ++i) { + if (Meshes[i].Mesh == mesh || (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh)) + return Meshes[i].NamedPath; + } + + return emptyNamedPath; +} + +//! Renames a loaded mesh. +bool CMeshCache::renameMesh(u32 index, const io::path &name) +{ + if (index >= Meshes.size()) + return false; + + Meshes[index].NamedPath.setPath(name); + Meshes.sort(); + return true; +} + +//! Renames a loaded mesh. +bool CMeshCache::renameMesh(const IMesh *const mesh, const io::path &name) +{ + for (u32 i = 0; i < Meshes.size(); ++i) { + if (Meshes[i].Mesh == mesh || (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh)) { + Meshes[i].NamedPath.setPath(name); + Meshes.sort(); + return true; + } + } + + return false; +} + +//! returns if a mesh already was loaded +bool CMeshCache::isMeshLoaded(const io::path &name) +{ + return getMeshByName(name) != 0; +} + +//! Clears the whole mesh cache, removing all meshes. +void CMeshCache::clear() +{ + for (u32 i = 0; i < Meshes.size(); ++i) + Meshes[i].Mesh->drop(); + + Meshes.clear(); +} + +//! Clears all meshes that are held in the mesh cache but not used anywhere else. +void CMeshCache::clearUnusedMeshes() +{ + for (u32 i = 0; i < Meshes.size(); ++i) { + if (Meshes[i].Mesh->getReferenceCount() == 1) { + Meshes[i].Mesh->drop(); + Meshes.erase(i); + --i; + } + } +} + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CMeshCache.h b/irr/src/CMeshCache.h new file mode 100644 index 000000000..1c2b52686 --- /dev/null +++ b/irr/src/CMeshCache.h @@ -0,0 +1,116 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IMeshCache.h" +#include "irrArray.h" + +namespace irr +{ + +namespace scene +{ +class CMeshCache : public IMeshCache +{ +public: + virtual ~CMeshCache(); + + //! Adds a mesh to the internal list of loaded meshes. + /** Usually, ISceneManager::getMesh() is called to load a mesh from file. + That method searches the list of loaded meshes if a mesh has already been loaded and + returns a pointer to if it is in that list and already in memory. Otherwise it loads + the mesh. With IMeshCache::addMesh(), it is possible to pretend that a mesh already + has been loaded. This method can be used for example by mesh loaders who need to + load more than one mesh with one call. They can add additional meshes with this + method to the scene manager. The COLLADA loader for example uses this method. + \param filename: Filename of the mesh. When called ISceneManager::getMesh() with this + parameter, the method will return the mesh parameter given with this method. + \param mesh: Pointer to a mesh which will now be referenced by this name. */ + void addMesh(const io::path &filename, IAnimatedMesh *mesh) override; + + //! Removes a mesh from the cache. + /** After loading a mesh with getMesh(), the mesh can be removed from the cache + using this method, freeing a lot of memory. */ + void removeMesh(const IMesh *const mesh) override; + + //! Returns amount of loaded meshes in the cache. + /** You can load new meshes into the cache using getMesh() and addMesh(). + If you ever need to access the internal mesh cache, you can do this using + removeMesh(), getMeshNumber(), getMeshByIndex() and getMeshFilename() */ + u32 getMeshCount() const override; + + //! Returns current index number of the mesh, and -1 if it is not in the cache. + s32 getMeshIndex(const IMesh *const mesh) const override; + + //! Returns a mesh based on its index number. + /** \param index: Index of the mesh, number between 0 and getMeshCount()-1. + Note that this number is only valid until a new mesh is loaded or removed * + \return Returns pointer to the mesh or 0 if there is none with this number. */ + IAnimatedMesh *getMeshByIndex(u32 index) override; + + //! Returns a mesh based on its name. + /** \param name Name of the mesh. Usually a filename. + \return Pointer to the mesh or 0 if there is none with this number. */ + IAnimatedMesh *getMeshByName(const io::path &name) override; + + //! Get the name of a loaded mesh, based on its index. + /** \param index: Index of the mesh, number between 0 and getMeshCount()-1. + \return The name if mesh was found and has a name, else the path is empty. */ + const io::SNamedPath &getMeshName(u32 index) const override; + + //! Get the name of a loaded mesh, if there is any. + /** \param mesh Pointer to mesh to query. + \return The name if mesh was found and has a name, else the path is empty. */ + const io::SNamedPath &getMeshName(const IMesh *const mesh) const override; + + //! Renames a loaded mesh. + /** Note that renaming meshes might change the ordering of the + meshes, and so the index of the meshes as returned by + getMeshIndex() or taken by some methods will change. + \param index The index of the mesh in the cache. + \param name New name for the mesh. + \return True if mesh was renamed. */ + bool renameMesh(u32 index, const io::path &name) override; + + //! Renames a loaded mesh. + /** Note that renaming meshes might change the ordering of the + meshes, and so the index of the meshes as returned by + getMeshIndex() or taken by some methods will change. + \param mesh Mesh to be renamed. + \param name New name for the mesh. + \return True if mesh was renamed. */ + bool renameMesh(const IMesh *const mesh, const io::path &name) override; + + //! returns if a mesh already was loaded + bool isMeshLoaded(const io::path &name) override; + + //! Clears the whole mesh cache, removing all meshes. + void clear() override; + + //! Clears all meshes that are held in the mesh cache but not used anywhere else. + void clearUnusedMeshes() override; + +protected: + struct MeshEntry + { + MeshEntry(const io::path &name) : + NamedPath(name) + { + } + io::SNamedPath NamedPath; + IAnimatedMesh *Mesh; + + bool operator<(const MeshEntry &other) const + { + return (NamedPath < other.NamedPath); + } + }; + + //! loaded meshes + core::array Meshes; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CMeshManipulator.cpp b/irr/src/CMeshManipulator.cpp new file mode 100644 index 000000000..3309fea3f --- /dev/null +++ b/irr/src/CMeshManipulator.cpp @@ -0,0 +1,218 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CMeshManipulator.h" +#include "ISkinnedMesh.h" +#include "SMesh.h" +#include "CMeshBuffer.h" +#include "SAnimatedMesh.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + +static inline core::vector3df getAngleWeight(const core::vector3df &v1, + const core::vector3df &v2, + const core::vector3df &v3) +{ + // Calculate this triangle's weight for each of its three vertices + // start by calculating the lengths of its sides + const f32 a = v2.getDistanceFromSQ(v3); + const f32 asqrt = sqrtf(a); + const f32 b = v1.getDistanceFromSQ(v3); + const f32 bsqrt = sqrtf(b); + const f32 c = v1.getDistanceFromSQ(v2); + const f32 csqrt = sqrtf(c); + + // use them to find the angle at each vertex + return core::vector3df( + acosf((b + c - a) / (2.f * bsqrt * csqrt)), + acosf((-b + c + a) / (2.f * asqrt * csqrt)), + acosf((b - c + a) / (2.f * bsqrt * asqrt))); +} + +namespace +{ +template +void recalculateNormalsT(IMeshBuffer *buffer, bool smooth, bool angleWeighted) +{ + const u32 vtxcnt = buffer->getVertexCount(); + const u32 idxcnt = buffer->getIndexCount(); + const T *idx = reinterpret_cast(buffer->getIndices()); + + if (!smooth) { + for (u32 i = 0; i < idxcnt; i += 3) { + const core::vector3df &v1 = buffer->getPosition(idx[i + 0]); + const core::vector3df &v2 = buffer->getPosition(idx[i + 1]); + const core::vector3df &v3 = buffer->getPosition(idx[i + 2]); + const core::vector3df normal = core::plane3d(v1, v2, v3).Normal; + buffer->getNormal(idx[i + 0]) = normal; + buffer->getNormal(idx[i + 1]) = normal; + buffer->getNormal(idx[i + 2]) = normal; + } + } else { + u32 i; + + for (i = 0; i != vtxcnt; ++i) + buffer->getNormal(i).set(0.f, 0.f, 0.f); + + for (i = 0; i < idxcnt; i += 3) { + const core::vector3df &v1 = buffer->getPosition(idx[i + 0]); + const core::vector3df &v2 = buffer->getPosition(idx[i + 1]); + const core::vector3df &v3 = buffer->getPosition(idx[i + 2]); + const core::vector3df normal = core::plane3d(v1, v2, v3).Normal; + + core::vector3df weight(1.f, 1.f, 1.f); + if (angleWeighted) + weight = irr::scene::getAngleWeight(v1, v2, v3); // writing irr::scene:: necessary for borland + + buffer->getNormal(idx[i + 0]) += weight.X * normal; + buffer->getNormal(idx[i + 1]) += weight.Y * normal; + buffer->getNormal(idx[i + 2]) += weight.Z * normal; + } + + for (i = 0; i != vtxcnt; ++i) + buffer->getNormal(i).normalize(); + } +} +} + +//! Recalculates all normals of the mesh buffer. +/** \param buffer: Mesh buffer on which the operation is performed. */ +void CMeshManipulator::recalculateNormals(IMeshBuffer *buffer, bool smooth, bool angleWeighted) const +{ + if (!buffer) + return; + + if (buffer->getIndexType() == video::EIT_16BIT) + recalculateNormalsT(buffer, smooth, angleWeighted); + else + recalculateNormalsT(buffer, smooth, angleWeighted); +} + +//! Recalculates all normals of the mesh. +//! \param mesh: Mesh on which the operation is performed. +void CMeshManipulator::recalculateNormals(scene::IMesh *mesh, bool smooth, bool angleWeighted) const +{ + if (!mesh) + return; + + if (mesh->getMeshType() == EAMT_SKINNED) { + ISkinnedMesh *smesh = (ISkinnedMesh *)mesh; + smesh->resetAnimation(); + } + + const u32 bcount = mesh->getMeshBufferCount(); + for (u32 b = 0; b < bcount; ++b) + recalculateNormals(mesh->getMeshBuffer(b), smooth, angleWeighted); + + if (mesh->getMeshType() == EAMT_SKINNED) { + ISkinnedMesh *smesh = (ISkinnedMesh *)mesh; + smesh->refreshJointCache(); + } +} + +//! Clones a static IMesh into a modifyable SMesh. +// not yet 32bit +SMesh *CMeshManipulator::createMeshCopy(scene::IMesh *mesh) const +{ + if (!mesh) + return 0; + + SMesh *clone = new SMesh(); + + const u32 meshBufferCount = mesh->getMeshBufferCount(); + + for (u32 b = 0; b < meshBufferCount; ++b) { + const IMeshBuffer *const mb = mesh->getMeshBuffer(b); + switch (mb->getVertexType()) { + case video::EVT_STANDARD: { + SMeshBuffer *buffer = new SMeshBuffer(); + buffer->Material = mb->getMaterial(); + const u32 vcount = mb->getVertexCount(); + buffer->Vertices.reallocate(vcount); + video::S3DVertex *vertices = (video::S3DVertex *)mb->getVertices(); + for (u32 i = 0; i < vcount; ++i) + buffer->Vertices.push_back(vertices[i]); + const u32 icount = mb->getIndexCount(); + buffer->Indices.reallocate(icount); + const u16 *indices = mb->getIndices(); + for (u32 i = 0; i < icount; ++i) + buffer->Indices.push_back(indices[i]); + clone->addMeshBuffer(buffer); + buffer->drop(); + } break; + case video::EVT_2TCOORDS: { + SMeshBufferLightMap *buffer = new SMeshBufferLightMap(); + buffer->Material = mb->getMaterial(); + const u32 vcount = mb->getVertexCount(); + buffer->Vertices.reallocate(vcount); + video::S3DVertex2TCoords *vertices = (video::S3DVertex2TCoords *)mb->getVertices(); + for (u32 i = 0; i < vcount; ++i) + buffer->Vertices.push_back(vertices[i]); + const u32 icount = mb->getIndexCount(); + buffer->Indices.reallocate(icount); + const u16 *indices = mb->getIndices(); + for (u32 i = 0; i < icount; ++i) + buffer->Indices.push_back(indices[i]); + clone->addMeshBuffer(buffer); + buffer->drop(); + } break; + case video::EVT_TANGENTS: { + SMeshBufferTangents *buffer = new SMeshBufferTangents(); + buffer->Material = mb->getMaterial(); + const u32 vcount = mb->getVertexCount(); + buffer->Vertices.reallocate(vcount); + video::S3DVertexTangents *vertices = (video::S3DVertexTangents *)mb->getVertices(); + for (u32 i = 0; i < vcount; ++i) + buffer->Vertices.push_back(vertices[i]); + const u32 icount = mb->getIndexCount(); + buffer->Indices.reallocate(icount); + const u16 *indices = mb->getIndices(); + for (u32 i = 0; i < icount; ++i) + buffer->Indices.push_back(indices[i]); + clone->addMeshBuffer(buffer); + buffer->drop(); + } break; + } // end switch + + } // end for all mesh buffers + + clone->BoundingBox = mesh->getBoundingBox(); + return clone; +} + +//! Returns amount of polygons in mesh. +s32 CMeshManipulator::getPolyCount(scene::IMesh *mesh) const +{ + if (!mesh) + return 0; + + s32 trianglecount = 0; + + for (u32 g = 0; g < mesh->getMeshBufferCount(); ++g) + trianglecount += mesh->getMeshBuffer(g)->getIndexCount() / 3; + + return trianglecount; +} + +//! Returns amount of polygons in mesh. +s32 CMeshManipulator::getPolyCount(scene::IAnimatedMesh *mesh) const +{ + if (mesh && mesh->getFrameCount() != 0) + return getPolyCount(mesh->getMesh(0)); + + return 0; +} + +//! create a new AnimatedMesh and adds the mesh to it +IAnimatedMesh *CMeshManipulator::createAnimatedMesh(scene::IMesh *mesh, scene::E_ANIMATED_MESH_TYPE type) const +{ + return new SAnimatedMesh(mesh, type); +} + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CMeshManipulator.h b/irr/src/CMeshManipulator.h new file mode 100644 index 000000000..0377d6a3a --- /dev/null +++ b/irr/src/CMeshManipulator.h @@ -0,0 +1,46 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IMeshManipulator.h" + +namespace irr +{ +namespace scene +{ + +//! An interface for easy manipulation of meshes. +/** Scale, set alpha value, flip surfaces, and so on. This exists for fixing +problems with wrong imported or exported meshes quickly after loading. It is +not intended for doing mesh modifications and/or animations during runtime. +*/ +class CMeshManipulator : public IMeshManipulator +{ +public: + //! Recalculates all normals of the mesh. + /** \param mesh: Mesh on which the operation is performed. + \param smooth: Whether to use smoothed normals. */ + void recalculateNormals(scene::IMesh *mesh, bool smooth = false, bool angleWeighted = false) const override; + + //! Recalculates all normals of the mesh buffer. + /** \param buffer: Mesh buffer on which the operation is performed. + \param smooth: Whether to use smoothed normals. */ + void recalculateNormals(IMeshBuffer *buffer, bool smooth = false, bool angleWeighted = false) const override; + + //! Clones a static IMesh into a modifiable SMesh. + SMesh *createMeshCopy(scene::IMesh *mesh) const override; + + //! Returns amount of polygons in mesh. + s32 getPolyCount(scene::IMesh *mesh) const override; + + //! Returns amount of polygons in mesh. + s32 getPolyCount(scene::IAnimatedMesh *mesh) const override; + + //! create a new AnimatedMesh and adds the mesh to it + IAnimatedMesh *createAnimatedMesh(scene::IMesh *mesh, scene::E_ANIMATED_MESH_TYPE type) const override; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CMeshSceneNode.cpp b/irr/src/CMeshSceneNode.cpp new file mode 100644 index 000000000..7ff6cad55 --- /dev/null +++ b/irr/src/CMeshSceneNode.cpp @@ -0,0 +1,262 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CMeshSceneNode.h" +#include "IVideoDriver.h" +#include "ISceneManager.h" +#include "S3DVertex.h" +#include "ICameraSceneNode.h" +#include "IMeshCache.h" +#include "IAnimatedMesh.h" +#include "IMaterialRenderer.h" +#include "IFileSystem.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CMeshSceneNode::CMeshSceneNode(IMesh *mesh, ISceneNode *parent, ISceneManager *mgr, s32 id, + const core::vector3df &position, const core::vector3df &rotation, + const core::vector3df &scale) : + IMeshSceneNode(parent, mgr, id, position, rotation, scale), + Mesh(0), + PassCount(0), ReadOnlyMaterials(false) +{ +#ifdef _DEBUG + setDebugName("CMeshSceneNode"); +#endif + + setMesh(mesh); +} + +//! destructor +CMeshSceneNode::~CMeshSceneNode() +{ + if (Mesh) + Mesh->drop(); +} + +//! frame +void CMeshSceneNode::OnRegisterSceneNode() +{ + if (IsVisible && Mesh) { + // because this node supports rendering of mixed mode meshes consisting of + // transparent and solid material at the same time, we need to go through all + // materials, check of what type they are and register this node for the right + // render pass according to that. + + video::IVideoDriver *driver = SceneManager->getVideoDriver(); + + PassCount = 0; + int transparentCount = 0; + int solidCount = 0; + + // count transparent and solid materials in this scene node + const u32 numMaterials = ReadOnlyMaterials ? Mesh->getMeshBufferCount() : Materials.size(); + for (u32 i = 0; i < numMaterials; ++i) { + const video::SMaterial &material = ReadOnlyMaterials ? Mesh->getMeshBuffer(i)->getMaterial() : Materials[i]; + + if (driver->needsTransparentRenderPass(material)) + ++transparentCount; + else + ++solidCount; + + if (solidCount && transparentCount) + break; + } + + // register according to material types counted + + if (solidCount) + SceneManager->registerNodeForRendering(this, scene::ESNRP_SOLID); + + if (transparentCount) + SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT); + + ISceneNode::OnRegisterSceneNode(); + } +} + +//! renders the node. +void CMeshSceneNode::render() +{ + video::IVideoDriver *driver = SceneManager->getVideoDriver(); + + if (!Mesh || !driver) + return; + + const bool isTransparentPass = + SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT; + + ++PassCount; + + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); + Box = Mesh->getBoundingBox(); + + for (u32 i = 0; i < Mesh->getMeshBufferCount(); ++i) { + scene::IMeshBuffer *mb = Mesh->getMeshBuffer(i); + if (mb) { + const video::SMaterial &material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i]; + + const bool transparent = driver->needsTransparentRenderPass(material); + + // only render transparent buffer if this is the transparent render pass + // and solid only in solid pass + if (transparent == isTransparentPass) { + driver->setMaterial(material); + driver->drawMeshBuffer(mb); + } + } + } + + // for debug purposes only: + if (DebugDataVisible && PassCount == 1) { + video::SMaterial m; + m.Lighting = false; + m.AntiAliasing = 0; + driver->setMaterial(m); + + if (DebugDataVisible & scene::EDS_BBOX) { + driver->draw3DBox(Box, video::SColor(255, 255, 255, 255)); + } + if (DebugDataVisible & scene::EDS_BBOX_BUFFERS) { + for (u32 g = 0; g < Mesh->getMeshBufferCount(); ++g) { + driver->draw3DBox( + Mesh->getMeshBuffer(g)->getBoundingBox(), + video::SColor(255, 190, 128, 128)); + } + } + + if (DebugDataVisible & scene::EDS_NORMALS) { + // draw normals + const f32 debugNormalLength = 1.f; + const video::SColor debugNormalColor = video::SColor(255, 34, 221, 221); + const u32 count = Mesh->getMeshBufferCount(); + + for (u32 i = 0; i != count; ++i) { + driver->drawMeshBufferNormals(Mesh->getMeshBuffer(i), debugNormalLength, debugNormalColor); + } + } + + // show mesh + if (DebugDataVisible & scene::EDS_MESH_WIRE_OVERLAY) { + m.Wireframe = true; + driver->setMaterial(m); + + for (u32 g = 0; g < Mesh->getMeshBufferCount(); ++g) { + driver->drawMeshBuffer(Mesh->getMeshBuffer(g)); + } + } + } +} + +//! Removes a child from this scene node. +//! Implemented here, to be able to remove the shadow properly, if there is one, +//! or to remove attached childs. +bool CMeshSceneNode::removeChild(ISceneNode *child) +{ + return ISceneNode::removeChild(child); +} + +//! returns the axis aligned bounding box of this node +const core::aabbox3d &CMeshSceneNode::getBoundingBox() const +{ + return Mesh ? Mesh->getBoundingBox() : Box; +} + +//! returns the material based on the zero based index i. To get the amount +//! of materials used by this scene node, use getMaterialCount(). +//! This function is needed for inserting the node into the scene hierarchy on a +//! optimal position for minimizing renderstate changes, but can also be used +//! to directly modify the material of a scene node. +video::SMaterial &CMeshSceneNode::getMaterial(u32 i) +{ + if (Mesh && ReadOnlyMaterials && i < Mesh->getMeshBufferCount()) { + ReadOnlyMaterial = Mesh->getMeshBuffer(i)->getMaterial(); + return ReadOnlyMaterial; + } + + if (i >= Materials.size()) + return ISceneNode::getMaterial(i); + + return Materials[i]; +} + +//! returns amount of materials used by this scene node. +u32 CMeshSceneNode::getMaterialCount() const +{ + if (Mesh && ReadOnlyMaterials) + return Mesh->getMeshBufferCount(); + + return Materials.size(); +} + +//! Sets a new mesh +void CMeshSceneNode::setMesh(IMesh *mesh) +{ + if (mesh) { + mesh->grab(); + if (Mesh) + Mesh->drop(); + + Mesh = mesh; + copyMaterials(); + } +} + +void CMeshSceneNode::copyMaterials() +{ + Materials.clear(); + + if (Mesh) { + video::SMaterial mat; + + for (u32 i = 0; i < Mesh->getMeshBufferCount(); ++i) { + IMeshBuffer *mb = Mesh->getMeshBuffer(i); + if (mb) + mat = mb->getMaterial(); + + Materials.push_back(mat); + } + } +} + +//! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. +/* In this way it is possible to change the materials a mesh causing all mesh scene nodes +referencing this mesh to change too. */ +void CMeshSceneNode::setReadOnlyMaterials(bool readonly) +{ + ReadOnlyMaterials = readonly; +} + +//! Returns if the scene node should not copy the materials of the mesh but use them in a read only style +bool CMeshSceneNode::isReadOnlyMaterials() const +{ + return ReadOnlyMaterials; +} + +//! Creates a clone of this scene node and its children. +ISceneNode *CMeshSceneNode::clone(ISceneNode *newParent, ISceneManager *newManager) +{ + if (!newParent) + newParent = Parent; + if (!newManager) + newManager = SceneManager; + + CMeshSceneNode *nb = new CMeshSceneNode(Mesh, newParent, + newManager, ID, RelativeTranslation, RelativeRotation, RelativeScale); + + nb->cloneMembers(this, newManager); + nb->ReadOnlyMaterials = ReadOnlyMaterials; + nb->Materials = Materials; + + if (newParent) + nb->drop(); + return nb; +} + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CMeshSceneNode.h b/irr/src/CMeshSceneNode.h new file mode 100644 index 000000000..a00928748 --- /dev/null +++ b/irr/src/CMeshSceneNode.h @@ -0,0 +1,85 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IMeshSceneNode.h" +#include "IMesh.h" + +namespace irr +{ +namespace scene +{ + +class CMeshSceneNode : public IMeshSceneNode +{ +public: + //! constructor + CMeshSceneNode(IMesh *mesh, ISceneNode *parent, ISceneManager *mgr, s32 id, + const core::vector3df &position = core::vector3df(0, 0, 0), + const core::vector3df &rotation = core::vector3df(0, 0, 0), + const core::vector3df &scale = core::vector3df(1.0f, 1.0f, 1.0f)); + + //! destructor + virtual ~CMeshSceneNode(); + + //! frame + void OnRegisterSceneNode() override; + + //! renders the node. + void render() override; + + //! returns the axis aligned bounding box of this node + const core::aabbox3d &getBoundingBox() const override; + + //! returns the material based on the zero based index i. To get the amount + //! of materials used by this scene node, use getMaterialCount(). + //! This function is needed for inserting the node into the scene hierarchy on a + //! optimal position for minimizing renderstate changes, but can also be used + //! to directly modify the material of a scene node. + video::SMaterial &getMaterial(u32 i) override; + + //! returns amount of materials used by this scene node. + u32 getMaterialCount() const override; + + //! Returns type of the scene node + ESCENE_NODE_TYPE getType() const override { return ESNT_MESH; } + + //! Sets a new mesh + void setMesh(IMesh *mesh) override; + + //! Returns the current mesh + IMesh *getMesh(void) override { return Mesh; } + + //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. + /* In this way it is possible to change the materials a mesh causing all mesh scene nodes + referencing this mesh to change too. */ + void setReadOnlyMaterials(bool readonly) override; + + //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style + bool isReadOnlyMaterials() const override; + + //! Creates a clone of this scene node and its children. + ISceneNode *clone(ISceneNode *newParent = 0, ISceneManager *newManager = 0) override; + + //! Removes a child from this scene node. + //! Implemented here, to be able to remove the shadow properly, if there is one, + //! or to remove attached child. + bool removeChild(ISceneNode *child) override; + +protected: + void copyMaterials(); + + core::array Materials; + core::aabbox3d Box; + video::SMaterial ReadOnlyMaterial; + + IMesh *Mesh; + + s32 PassCount; + bool ReadOnlyMaterials; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CNSOGLManager.h b/irr/src/CNSOGLManager.h new file mode 100644 index 000000000..cdbb221b3 --- /dev/null +++ b/irr/src/CNSOGLManager.h @@ -0,0 +1,70 @@ +// Copyright (C) 2014 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#pragma once + +#ifdef _IRR_COMPILE_WITH_NSOGL_MANAGER_ + +#include "SIrrCreationParameters.h" +#include "SExposedVideoData.h" +#include "IContextManager.h" +#include "SColor.h" + +#import + +namespace irr +{ +namespace video +{ +// NSOpenGL manager. +class CNSOGLManager : public IContextManager +{ +public: + //! Constructor. + CNSOGLManager(); + + //! Destructor + ~CNSOGLManager(); + + // Initialize + bool initialize(const SIrrlichtCreationParameters ¶ms, const SExposedVideoData &data) override; + + // Terminate + void terminate() override; + + // Create surface. + bool generateSurface() override; + + // Destroy surface. + void destroySurface() override; + + // Create context. + bool generateContext() override; + + // Destroy EGL context. + void destroyContext() override; + + //! Get current context + const SExposedVideoData &getContext() const; + + //! Change render context, disable old and activate new defined by videoData + bool activateContext(const SExposedVideoData &videoData, bool restorePrimaryOnZero) override; + + // Get procedure address. + void *getProcAddress(const std::string &procName) override; + + // Swap buffers. + bool swapBuffers() override; + +private: + SIrrlichtCreationParameters Params; + SExposedVideoData PrimaryContext; + SExposedVideoData CurrentContext; + + NSOpenGLPixelFormat *PixelFormat; +}; +} +} + +#endif diff --git a/irr/src/CNSOGLManager.mm b/irr/src/CNSOGLManager.mm new file mode 100644 index 000000000..c1e543e53 --- /dev/null +++ b/irr/src/CNSOGLManager.mm @@ -0,0 +1,234 @@ +// Copyright (C) 2014 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#include "CNSOGLManager.h" + +#ifdef _IRR_COMPILE_WITH_NSOGL_MANAGER_ + +#include +#include "os.h" + +namespace irr +{ +namespace video +{ + +CNSOGLManager::CNSOGLManager() : + PrimaryContext(SExposedVideoData(0)), PixelFormat(nil) +{ +#ifdef _DEBUG + setDebugName("CNSOGLManager"); +#endif +} + +CNSOGLManager::~CNSOGLManager() +{ +} + +bool CNSOGLManager::initialize(const SIrrlichtCreationParameters ¶ms, const SExposedVideoData &videodata) +{ + Params = params; + + return true; +} + +void CNSOGLManager::terminate() +{ +} + +bool CNSOGLManager::generateSurface() +{ + if (Params.DriverType == video::EDT_OPENGL) { + int alphaSize = Params.WithAlphaChannel ? 4 : 0; + int depthSize = Params.ZBufferBits; + + if (Params.WithAlphaChannel && Params.Bits == 32) + alphaSize = 8; + + NSOpenGLPixelFormatAttribute Attribs[] = { + NSOpenGLPFANoRecovery, + NSOpenGLPFAAccelerated, + NSOpenGLPFADoubleBuffer, + NSOpenGLPFADepthSize, static_cast(depthSize), + NSOpenGLPFAColorSize, Params.Bits, + NSOpenGLPFAAlphaSize, static_cast(alphaSize), + NSOpenGLPFASampleBuffers, 1, + NSOpenGLPFASamples, Params.AntiAlias, + NSOpenGLPFAStencilSize, static_cast(Params.Stencilbuffer ? 1 : 0), + // NSOpenGLPFAFullScreen, + 0, + }; + + u32 Steps = 6; + + // Choose the best pixel format. + do { + switch (Steps) { + case 6: // decrease step. + --Steps; + break; + case 5: // samples + if (Attribs[12] > 2) + --Attribs[12]; + else { + Attribs[10] = 0; + Attribs[12] = 0; + --Steps; + } + break; + case 4: // alpha + if (Attribs[8]) { + Attribs[8] = 0; + + if (Params.AntiAlias) { + Attribs[10] = 1; + Attribs[12] = Params.AntiAlias; + Steps = 5; + } + } else + --Steps; + break; + case 3: // stencil + if (Attribs[14]) { + Attribs[14] = 0; + + if (Params.AntiAlias) { + Attribs[10] = 1; + Attribs[12] = Params.AntiAlias; + Steps = 5; + } + } else + --Steps; + break; + case 2: // depth size + if (Attribs[4] > 16) { + Attribs[4] = Attribs[4] - 8; + } else + --Steps; + break; + case 1: // buffer size + if (Attribs[6] > 16) { + Attribs[6] = Attribs[6] - 8; + } else + --Steps; + break; + default: + os::Printer::log("Could not get pixel format."); + return false; + } + + PixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:Attribs]; + } while (PixelFormat == nil); + + if (Params.AntiAlias && !Attribs[10]) + os::Printer::log("No multisampling."); + + if (Params.WithAlphaChannel && !Attribs[8]) + os::Printer::log("No alpha."); + + if (Params.Stencilbuffer && !Attribs[14]) + os::Printer::log("No stencil buffer."); + + if (Params.ZBufferBits > Attribs[4]) + os::Printer::log("No full depth buffer."); + + if (Params.Bits > Attribs[6]) + os::Printer::log("No full color buffer."); + } + + return true; +} + +void CNSOGLManager::destroySurface() +{ + [PixelFormat release]; + PixelFormat = nil; +} + +bool CNSOGLManager::generateContext() +{ + NSOpenGLContext *Context = [[NSOpenGLContext alloc] initWithFormat:PixelFormat shareContext:nil]; + + GLint Vsync = Params.Vsync ? 1 : 0; + [Context setValues:&Vsync forParameter:NSOpenGLCPSwapInterval]; + + if (Context == nil) { + os::Printer::log("Could not create OpenGL context.", ELL_ERROR); + return false; + } + + // set exposed data + CurrentContext.OpenGLOSX.Context = Context; + + if (!PrimaryContext.OpenGLOSX.Context) + PrimaryContext.OpenGLOSX.Context = CurrentContext.OpenGLOSX.Context; + + return true; +} + +const SExposedVideoData &CNSOGLManager::getContext() const +{ + return CurrentContext; +} + +bool CNSOGLManager::activateContext(const SExposedVideoData &videoData, bool restorePrimaryOnZero) +{ + // TODO: handle restorePrimaryOnZero + if (videoData.OpenGLOSX.Context) { + if ((NSOpenGLContext *)videoData.OpenGLOSX.Context != [NSOpenGLContext currentContext]) { + [(NSOpenGLContext *)videoData.OpenGLOSX.Context makeCurrentContext]; + + CurrentContext = videoData; + } + } + // set back to main context + else { + if ((NSOpenGLContext *)PrimaryContext.OpenGLOSX.Context != [NSOpenGLContext currentContext]) { + [(NSOpenGLContext *)PrimaryContext.OpenGLOSX.Context makeCurrentContext]; + + CurrentContext = PrimaryContext; + } + } + + return true; +} + +void CNSOGLManager::destroyContext() +{ + if (CurrentContext.OpenGLOSX.Context) { + if (PrimaryContext.OpenGLOSX.Context == CurrentContext.OpenGLOSX.Context) + PrimaryContext.OpenGLOSX.Context = nil; + + [(NSOpenGLContext *)CurrentContext.OpenGLOSX.Context makeCurrentContext]; + [(NSOpenGLContext *)CurrentContext.OpenGLOSX.Context clearDrawable]; + [(NSOpenGLContext *)CurrentContext.OpenGLOSX.Context release]; + [NSOpenGLContext clearCurrentContext]; + + CurrentContext.OpenGLOSX.Context = nil; + } +} + +// It appears that there is no separate GL proc address getter on OSX. +// https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_entrypts/opengl_entrypts.html +void *CNSOGLManager::getProcAddress(const std::string &procName) +{ + NSSymbol symbol = NULL; + // Allocate a buffer for the name, an underscore prefix, and a cstring terminator. + std::string mangledName = "_" + procName; + if (NSIsSymbolNameDefined(mangledName.c_str())) + symbol = NSLookupAndBindSymbol(mangledName.c_str()); + return symbol ? NSAddressOfSymbol(symbol) : NULL; +} + +bool CNSOGLManager::swapBuffers() +{ + [(NSOpenGLContext *)CurrentContext.OpenGLOSX.Context flushBuffer]; + + return true; +} + +} +} + +#endif diff --git a/irr/src/CNullDriver.cpp b/irr/src/CNullDriver.cpp new file mode 100644 index 000000000..347569e6a --- /dev/null +++ b/irr/src/CNullDriver.cpp @@ -0,0 +1,1775 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CNullDriver.h" +#include "os.h" +#include "CImage.h" +#include "CAttributes.h" +#include "IReadFile.h" +#include "IWriteFile.h" +#include "IImageLoader.h" +#include "IImageWriter.h" +#include "IMaterialRenderer.h" +#include "IAnimatedMeshSceneNode.h" +#include "CMeshManipulator.h" +#include "CColorConverter.h" +#include "IReferenceCounted.h" +#include "IRenderTarget.h" + +namespace irr +{ +namespace video +{ + +//! creates a loader which is able to load windows bitmaps +IImageLoader *createImageLoaderBMP(); + +//! creates a loader which is able to load jpeg images +IImageLoader *createImageLoaderJPG(); + +//! creates a loader which is able to load targa images +IImageLoader *createImageLoaderTGA(); + +//! creates a loader which is able to load png images +IImageLoader *createImageLoaderPNG(); + +//! creates a writer which is able to save jpg images +IImageWriter *createImageWriterJPG(); + +//! creates a writer which is able to save png images +IImageWriter *createImageWriterPNG(); + +namespace +{ +//! no-op material renderer +class CDummyMaterialRenderer : public IMaterialRenderer +{ +public: + CDummyMaterialRenderer() {} +}; +} + +//! constructor +CNullDriver::CNullDriver(io::IFileSystem *io, const core::dimension2d &screenSize) : + SharedRenderTarget(0), CurrentRenderTarget(0), CurrentRenderTargetSize(0, 0), FileSystem(io), MeshManipulator(0), + ViewPort(0, 0, 0, 0), ScreenSize(screenSize), PrimitivesDrawn(0), MinVertexCountForVBO(500), + TextureCreationFlags(0), OverrideMaterial2DEnabled(false), AllowZWriteOnTransparent(false) +{ +#ifdef _DEBUG + setDebugName("CNullDriver"); +#endif + + DriverAttributes = new io::CAttributes(); + DriverAttributes->addInt("MaxTextures", MATERIAL_MAX_TEXTURES); + DriverAttributes->addInt("MaxSupportedTextures", MATERIAL_MAX_TEXTURES); + DriverAttributes->addInt("MaxAnisotropy", 1); + // DriverAttributes->addInt("MaxUserClipPlanes", 0); + // DriverAttributes->addInt("MaxAuxBuffers", 0); + DriverAttributes->addInt("MaxMultipleRenderTargets", 1); + DriverAttributes->addInt("MaxIndices", -1); + DriverAttributes->addInt("MaxTextureSize", -1); + // DriverAttributes->addInt("MaxGeometryVerticesOut", 0); + // DriverAttributes->addFloat("MaxTextureLODBias", 0.f); + DriverAttributes->addInt("Version", 1); + // DriverAttributes->addInt("ShaderLanguageVersion", 0); + // DriverAttributes->addInt("AntiAlias", 0); + + setFog(); + + setTextureCreationFlag(ETCF_ALWAYS_32_BIT, true); + setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, true); + setTextureCreationFlag(ETCF_AUTO_GENERATE_MIP_MAPS, true); + setTextureCreationFlag(ETCF_ALLOW_MEMORY_COPY, true); + + ViewPort = core::rect(core::position2d(0, 0), core::dimension2di(screenSize)); + + // create manipulator + MeshManipulator = new scene::CMeshManipulator(); + + if (FileSystem) + FileSystem->grab(); + + // create surface loaders and writers + SurfaceLoader.push_back(video::createImageLoaderTGA()); + SurfaceLoader.push_back(video::createImageLoaderPNG()); + SurfaceLoader.push_back(video::createImageLoaderJPG()); + SurfaceLoader.push_back(video::createImageLoaderBMP()); + + SurfaceWriter.push_back(video::createImageWriterJPG()); + SurfaceWriter.push_back(video::createImageWriterPNG()); + + // set ExposedData to 0 + memset((void *)&ExposedData, 0, sizeof(ExposedData)); + for (u32 i = 0; i < video::EVDF_COUNT; ++i) + FeatureEnabled[i] = true; + + InitMaterial2D.AntiAliasing = video::EAAM_OFF; + InitMaterial2D.Lighting = false; + InitMaterial2D.ZWriteEnable = video::EZW_OFF; + InitMaterial2D.ZBuffer = video::ECFN_DISABLED; + InitMaterial2D.UseMipMaps = false; + InitMaterial2D.forEachTexture([](auto &tex) { + // Using ETMINF_LINEAR_MIPMAP_NEAREST (bilinear) for 2D graphics looks + // much better and doesn't have any downsides (e.g. regarding pixel art). + tex.MinFilter = video::ETMINF_LINEAR_MIPMAP_NEAREST; + tex.MagFilter = video::ETMAGF_NEAREST; + tex.TextureWrapU = video::ETC_REPEAT; + tex.TextureWrapV = video::ETC_REPEAT; + tex.TextureWrapW = video::ETC_REPEAT; + }); + OverrideMaterial2D = InitMaterial2D; +} + +//! destructor +CNullDriver::~CNullDriver() +{ + if (DriverAttributes) + DriverAttributes->drop(); + + if (FileSystem) + FileSystem->drop(); + + if (MeshManipulator) + MeshManipulator->drop(); + + removeAllRenderTargets(); + + deleteAllTextures(); + + u32 i; + for (i = 0; i < SurfaceLoader.size(); ++i) + SurfaceLoader[i]->drop(); + + for (i = 0; i < SurfaceWriter.size(); ++i) + SurfaceWriter[i]->drop(); + + // delete material renderers + deleteMaterialRenders(); + + // delete hardware mesh buffers + removeAllHardwareBuffers(); +} + +//! Adds an external surface loader to the engine. +void CNullDriver::addExternalImageLoader(IImageLoader *loader) +{ + if (!loader) + return; + + loader->grab(); + SurfaceLoader.push_back(loader); +} + +//! Adds an external surface writer to the engine. +void CNullDriver::addExternalImageWriter(IImageWriter *writer) +{ + if (!writer) + return; + + writer->grab(); + SurfaceWriter.push_back(writer); +} + +//! Retrieve the number of image loaders +u32 CNullDriver::getImageLoaderCount() const +{ + return SurfaceLoader.size(); +} + +//! Retrieve the given image loader +IImageLoader *CNullDriver::getImageLoader(u32 n) +{ + if (n < SurfaceLoader.size()) + return SurfaceLoader[n]; + return 0; +} + +//! Retrieve the number of image writers +u32 CNullDriver::getImageWriterCount() const +{ + return SurfaceWriter.size(); +} + +//! Retrieve the given image writer +IImageWriter *CNullDriver::getImageWriter(u32 n) +{ + if (n < SurfaceWriter.size()) + return SurfaceWriter[n]; + return 0; +} + +//! deletes all textures +void CNullDriver::deleteAllTextures() +{ + // we need to remove previously set textures which might otherwise be kept in the + // last set material member. Could be optimized to reduce state changes. + setMaterial(SMaterial()); + + // reset render targets. + + for (u32 i = 0; i < RenderTargets.size(); ++i) + RenderTargets[i]->setTexture(0, 0); + + // remove textures. + + for (u32 i = 0; i < Textures.size(); ++i) + Textures[i].Surface->drop(); + + Textures.clear(); + + SharedDepthTextures.clear(); +} + +bool CNullDriver::beginScene(u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil, const SExposedVideoData &videoData, core::rect *sourceRect) +{ + PrimitivesDrawn = 0; + return true; +} + +bool CNullDriver::endScene() +{ + FPSCounter.registerFrame(os::Timer::getRealTime(), PrimitivesDrawn); + updateAllHardwareBuffers(); + updateAllOcclusionQueries(); + return true; +} + +//! Disable a feature of the driver. +void CNullDriver::disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag) +{ + FeatureEnabled[feature] = !flag; +} + +//! queries the features of the driver, returns true if feature is available +bool CNullDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const +{ + return false; +} + +//! Get attributes of the actual video driver +const io::IAttributes &CNullDriver::getDriverAttributes() const +{ + return *DriverAttributes; +} + +//! sets transformation +void CNullDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4 &mat) +{ +} + +//! Returns the transformation set by setTransform +const core::matrix4 &CNullDriver::getTransform(E_TRANSFORMATION_STATE state) const +{ + return TransformationMatrix; +} + +//! sets a material +void CNullDriver::setMaterial(const SMaterial &material) +{ +} + +//! Removes a texture from the texture cache and deletes it, freeing lot of +//! memory. +void CNullDriver::removeTexture(ITexture *texture) +{ + if (!texture) + return; + SSurface s; + s.Surface = texture; + + s32 last; + s32 first = Textures.binary_search_multi(s, last); + if (first == -1) + return; + for (u32 i = first; i <= (u32)last; i++) { + if (Textures[i].Surface == texture) { + texture->drop(); + Textures.erase(i); + return; + } + } +} + +//! Removes all texture from the texture cache and deletes them, freeing lot of +//! memory. +void CNullDriver::removeAllTextures() +{ + setMaterial(SMaterial()); + deleteAllTextures(); +} + +//! Returns amount of textures currently loaded +u32 CNullDriver::getTextureCount() const +{ + return Textures.size(); +} + +ITexture *CNullDriver::addTexture(const core::dimension2d &size, const io::path &name, ECOLOR_FORMAT format) +{ + if (0 == name.size()) { + os::Printer::log("Could not create ITexture, texture needs to have a non-empty name.", ELL_WARNING); + return 0; + } + + IImage *image = new CImage(format, size); + ITexture *t = 0; + + if (checkImage(image)) { + t = createDeviceDependentTexture(name, image); + } + + image->drop(); + + if (t) { + addTexture(t); + t->drop(); + } + + return t; +} + +ITexture *CNullDriver::addTexture(const io::path &name, IImage *image) +{ + if (0 == name.size()) { + os::Printer::log("Could not create ITexture, texture needs to have a non-empty name.", ELL_WARNING); + return 0; + } + + if (!image) + return 0; + + ITexture *t = 0; + + if (checkImage(image)) { + t = createDeviceDependentTexture(name, image); + } + + if (t) { + addTexture(t); + t->drop(); + } + + return t; +} + +ITexture *CNullDriver::addTextureCubemap(const io::path &name, IImage *imagePosX, IImage *imageNegX, IImage *imagePosY, + IImage *imageNegY, IImage *imagePosZ, IImage *imageNegZ) +{ + if (0 == name.size() || !imagePosX || !imageNegX || !imagePosY || !imageNegY || !imagePosZ || !imageNegZ) + return 0; + + ITexture *t = 0; + + core::array imageArray(6); + imageArray.push_back(imagePosX); + imageArray.push_back(imageNegX); + imageArray.push_back(imagePosY); + imageArray.push_back(imageNegY); + imageArray.push_back(imagePosZ); + imageArray.push_back(imageNegZ); + + if (checkImage(imageArray)) { + t = createDeviceDependentTextureCubemap(name, imageArray); + } + + if (t) { + addTexture(t); + t->drop(); + } + + return t; +} + +ITexture *CNullDriver::addTextureCubemap(const irr::u32 sideLen, const io::path &name, ECOLOR_FORMAT format) +{ + if (0 == sideLen) + return 0; + + if (0 == name.size()) { + os::Printer::log("Could not create ITexture, texture needs to have a non-empty name.", ELL_WARNING); + return 0; + } + + core::array imageArray(6); + for (int i = 0; i < 6; ++i) + imageArray.push_back(new CImage(format, core::dimension2du(sideLen, sideLen))); + + ITexture *t = 0; + if (checkImage(imageArray)) { + t = createDeviceDependentTextureCubemap(name, imageArray); + + if (t) { + addTexture(t); + t->drop(); + } + } + + for (int i = 0; i < 6; ++i) + imageArray[i]->drop(); + + return t; +} + +//! loads a Texture +ITexture *CNullDriver::getTexture(const io::path &filename) +{ + // Identify textures by their absolute filenames if possible. + const io::path absolutePath = FileSystem->getAbsolutePath(filename); + + ITexture *texture = findTexture(absolutePath); + if (texture) { + texture->updateSource(ETS_FROM_CACHE); + return texture; + } + + // Then try the raw filename, which might be in an Archive + texture = findTexture(filename); + if (texture) { + texture->updateSource(ETS_FROM_CACHE); + return texture; + } + + // Now try to open the file using the complete path. + io::IReadFile *file = FileSystem->createAndOpenFile(absolutePath); + + if (!file) { + // Try to open it using the raw filename. + file = FileSystem->createAndOpenFile(filename); + } + + if (file) { + // Re-check name for actual archive names + texture = findTexture(file->getFileName()); + if (texture) { + texture->updateSource(ETS_FROM_CACHE); + file->drop(); + return texture; + } + + texture = loadTextureFromFile(file); + file->drop(); + + if (texture) { + texture->updateSource(ETS_FROM_FILE); + addTexture(texture); + texture->drop(); // drop it because we created it, one grab too much + } else + os::Printer::log("Could not load texture", filename, ELL_ERROR); + return texture; + } else { + os::Printer::log("Could not open file of texture", filename, ELL_WARNING); + return 0; + } +} + +//! loads a Texture +ITexture *CNullDriver::getTexture(io::IReadFile *file) +{ + ITexture *texture = 0; + + if (file) { + texture = findTexture(file->getFileName()); + + if (texture) { + texture->updateSource(ETS_FROM_CACHE); + return texture; + } + + texture = loadTextureFromFile(file); + + if (texture) { + texture->updateSource(ETS_FROM_FILE); + addTexture(texture); + texture->drop(); // drop it because we created it, one grab too much + } + + if (!texture) + os::Printer::log("Could not load texture", file->getFileName(), ELL_WARNING); + } + + return texture; +} + +//! opens the file and loads it into the surface +video::ITexture *CNullDriver::loadTextureFromFile(io::IReadFile *file, const io::path &hashName) +{ + ITexture *texture = nullptr; + + IImage *image = createImageFromFile(file); + if (!image) + return nullptr; + + if (checkImage(image)) { + texture = createDeviceDependentTexture(hashName.size() ? hashName : file->getFileName(), image); + if (texture) + os::Printer::log("Loaded texture", file->getFileName(), ELL_DEBUG); + } + + image->drop(); + + return texture; +} + +//! adds a surface, not loaded or created by the Irrlicht Engine +void CNullDriver::addTexture(video::ITexture *texture) +{ + if (texture) { + SSurface s; + s.Surface = texture; + texture->grab(); + + Textures.push_back(s); + + // the new texture is now at the end of the texture list. when searching for + // the next new texture, the texture array will be sorted and the index of this texture + // will be changed. + } +} + +//! looks if the image is already loaded +video::ITexture *CNullDriver::findTexture(const io::path &filename) +{ + SSurface s; + SDummyTexture dummy(filename, ETT_2D); + s.Surface = &dummy; + + s32 index = Textures.binary_search(s); + if (index != -1) + return Textures[index].Surface; + + return 0; +} + +ITexture *CNullDriver::createDeviceDependentTexture(const io::path &name, IImage *image) +{ + SDummyTexture *dummy = new SDummyTexture(name, ETT_2D); + dummy->setSize(image->getDimension()); + return dummy; +} + +ITexture *CNullDriver::createDeviceDependentTextureCubemap(const io::path &name, const core::array &image) +{ + return new SDummyTexture(name, ETT_CUBEMAP); +} + +bool CNullDriver::setRenderTargetEx(IRenderTarget *target, u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil) +{ + return false; +} + +bool CNullDriver::setRenderTarget(ITexture *texture, u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil) +{ + if (texture) { + // create render target if require. + if (!SharedRenderTarget) + SharedRenderTarget = addRenderTarget(); + + ITexture *depthTexture = 0; + + // try to find available depth texture with require size. + for (u32 i = 0; i < SharedDepthTextures.size(); ++i) { + if (SharedDepthTextures[i]->getSize() == texture->getSize()) { + depthTexture = SharedDepthTextures[i]; + + break; + } + } + + // create depth texture if require. + if (!depthTexture) { + depthTexture = addRenderTargetTexture(texture->getSize(), "IRR_DEPTH_STENCIL", video::ECF_D24S8); + SharedDepthTextures.push_back(depthTexture); + } + + SharedRenderTarget->setTexture(texture, depthTexture); + + return setRenderTargetEx(SharedRenderTarget, clearFlag, clearColor, clearDepth, clearStencil); + } else { + return setRenderTargetEx(0, clearFlag, clearColor, clearDepth, clearStencil); + } +} + +//! sets a viewport +void CNullDriver::setViewPort(const core::rect &area) +{ +} + +//! gets the area of the current viewport +const core::rect &CNullDriver::getViewPort() const +{ + return ViewPort; +} + +//! draws a vertex primitive list +void CNullDriver::drawVertexPrimitiveList(const void *vertices, u32 vertexCount, const void *indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) +{ + if ((iType == EIT_16BIT) && (vertexCount > 65536)) + os::Printer::log("Too many vertices for 16bit index type, render artifacts may occur."); + PrimitivesDrawn += primitiveCount; +} + +//! draws a vertex primitive list in 2d +void CNullDriver::draw2DVertexPrimitiveList(const void *vertices, u32 vertexCount, const void *indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) +{ + if ((iType == EIT_16BIT) && (vertexCount > 65536)) + os::Printer::log("Too many vertices for 16bit index type, render artifacts may occur."); + PrimitivesDrawn += primitiveCount; +} + +//! Draws a 3d line. +void CNullDriver::draw3DLine(const core::vector3df &start, + const core::vector3df &end, SColor color) +{ +} + +//! Draws a 3d axis aligned box. +void CNullDriver::draw3DBox(const core::aabbox3d &box, SColor color) +{ + core::vector3df edges[8]; + box.getEdges(edges); + + // TODO: optimize into one big drawIndexPrimitive call. + + draw3DLine(edges[5], edges[1], color); + draw3DLine(edges[1], edges[3], color); + draw3DLine(edges[3], edges[7], color); + draw3DLine(edges[7], edges[5], color); + draw3DLine(edges[0], edges[2], color); + draw3DLine(edges[2], edges[6], color); + draw3DLine(edges[6], edges[4], color); + draw3DLine(edges[4], edges[0], color); + draw3DLine(edges[1], edges[0], color); + draw3DLine(edges[3], edges[2], color); + draw3DLine(edges[7], edges[6], color); + draw3DLine(edges[5], edges[4], color); +} + +//! draws an 2d image +void CNullDriver::draw2DImage(const video::ITexture *texture, const core::position2d &destPos, bool useAlphaChannelOfTexture) +{ + if (!texture) + return; + + draw2DImage(texture, destPos, core::rect(core::position2d(0, 0), core::dimension2di(texture->getOriginalSize())), + 0, + SColor(255, 255, 255, 255), + useAlphaChannelOfTexture); +} + +//! draws a set of 2d images, using a color and the alpha channel of the +//! texture if desired. +void CNullDriver::draw2DImageBatch(const video::ITexture *texture, + const core::array> &positions, + const core::array> &sourceRects, + const core::rect *clipRect, + SColor color, + bool useAlphaChannelOfTexture) +{ + const irr::u32 drawCount = core::min_(positions.size(), sourceRects.size()); + + for (u32 i = 0; i < drawCount; ++i) { + draw2DImage(texture, positions[i], sourceRects[i], + clipRect, color, useAlphaChannelOfTexture); + } +} + +//! Draws a part of the texture into the rectangle. +void CNullDriver::draw2DImage(const video::ITexture *texture, const core::rect &destRect, + const core::rect &sourceRect, const core::rect *clipRect, + const video::SColor *const colors, bool useAlphaChannelOfTexture) +{ + if (destRect.isValid()) + draw2DImage(texture, core::position2d(destRect.UpperLeftCorner), + sourceRect, clipRect, colors ? colors[0] : video::SColor(0xffffffff), + useAlphaChannelOfTexture); +} + +//! Draws a 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. +void CNullDriver::draw2DImage(const video::ITexture *texture, const core::position2d &destPos, + const core::rect &sourceRect, + const core::rect *clipRect, SColor color, + bool useAlphaChannelOfTexture) +{ +} + +//! Draw a 2d rectangle +void CNullDriver::draw2DRectangle(SColor color, const core::rect &pos, const core::rect *clip) +{ + draw2DRectangle(pos, color, color, color, color, clip); +} + +//! Draws a 2d rectangle with a gradient. +void CNullDriver::draw2DRectangle(const core::rect &pos, + SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, + const core::rect *clip) +{ +} + +//! Draws a 2d line. +void CNullDriver::draw2DLine(const core::position2d &start, + const core::position2d &end, SColor color) +{ +} + +//! returns color format +ECOLOR_FORMAT CNullDriver::getColorFormat() const +{ + return ECF_R5G6B5; +} + +//! returns screen size +const core::dimension2d &CNullDriver::getScreenSize() const +{ + return ScreenSize; +} + +//! get current render target +IRenderTarget *CNullDriver::getCurrentRenderTarget() const +{ + return CurrentRenderTarget; +} + +const core::dimension2d &CNullDriver::getCurrentRenderTargetSize() const +{ + if (CurrentRenderTargetSize.Width == 0) + return ScreenSize; + else + return CurrentRenderTargetSize; +} + +// returns current frames per second value +s32 CNullDriver::getFPS() const +{ + return FPSCounter.getFPS(); +} + +//! returns amount of primitives (mostly triangles) were drawn in the last frame. +//! very useful method for statistics. +u32 CNullDriver::getPrimitiveCountDrawn(u32 param) const +{ + return (0 == param) ? FPSCounter.getPrimitive() : (1 == param) ? FPSCounter.getPrimitiveAverage() + : FPSCounter.getPrimitiveTotal(); +} + +//! Sets the dynamic ambient light color. The default color is +//! (0,0,0,0) which means it is dark. +//! \param color: New color of the ambient light. +void CNullDriver::setAmbientLight(const SColorf &color) +{ + AmbientLight = color; +} + +const SColorf &CNullDriver::getAmbientLight() const +{ + return AmbientLight; +} + +//! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 +//! driver, it would return "Direct3D8". + +const char *CNullDriver::getName() const +{ + return "Irrlicht NullDevice"; +} + +//! Creates a boolean alpha channel of the texture based of an color key. +void CNullDriver::makeColorKeyTexture(video::ITexture *texture, + video::SColor color) const +{ + if (!texture) + return; + + if (texture->getColorFormat() != ECF_A1R5G5B5 && + texture->getColorFormat() != ECF_A8R8G8B8) { + os::Printer::log("Error: Unsupported texture color format for making color key channel.", ELL_ERROR); + return; + } + + if (texture->getColorFormat() == ECF_A1R5G5B5) { + u16 *p = (u16 *)texture->lock(); + + if (!p) { + os::Printer::log("Could not lock texture for making color key channel.", ELL_ERROR); + return; + } + + const core::dimension2d dim = texture->getSize(); + const u32 pitch = texture->getPitch() / 2; + + // color with alpha disabled (i.e. fully transparent) + const u16 refZeroAlpha = (0x7fff & color.toA1R5G5B5()); + + const u32 pixels = pitch * dim.Height; + + for (u32 pixel = 0; pixel < pixels; ++pixel) { + // If the color matches the reference color, ignoring alphas, + // set the alpha to zero. + if (((*p) & 0x7fff) == refZeroAlpha) + (*p) = refZeroAlpha; + + ++p; + } + + texture->unlock(); + } else { + u32 *p = (u32 *)texture->lock(); + + if (!p) { + os::Printer::log("Could not lock texture for making color key channel.", ELL_ERROR); + return; + } + + core::dimension2d dim = texture->getSize(); + u32 pitch = texture->getPitch() / 4; + + // color with alpha disabled (fully transparent) + const u32 refZeroAlpha = 0x00ffffff & color.color; + + const u32 pixels = pitch * dim.Height; + for (u32 pixel = 0; pixel < pixels; ++pixel) { + // If the color matches the reference color, ignoring alphas, + // set the alpha to zero. + if (((*p) & 0x00ffffff) == refZeroAlpha) + (*p) = refZeroAlpha; + + ++p; + } + + texture->unlock(); + } + texture->regenerateMipMapLevels(); +} + +//! Creates an boolean alpha channel of the texture based of an color key position. +void CNullDriver::makeColorKeyTexture(video::ITexture *texture, + core::position2d colorKeyPixelPos) const +{ + if (!texture) + return; + + if (texture->getColorFormat() != ECF_A1R5G5B5 && + texture->getColorFormat() != ECF_A8R8G8B8) { + os::Printer::log("Error: Unsupported texture color format for making color key channel.", ELL_ERROR); + return; + } + + SColor colorKey; + + if (texture->getColorFormat() == ECF_A1R5G5B5) { + u16 *p = (u16 *)texture->lock(ETLM_READ_ONLY); + + if (!p) { + os::Printer::log("Could not lock texture for making color key channel.", ELL_ERROR); + return; + } + + u32 pitch = texture->getPitch() / 2; + + const u16 key16Bit = 0x7fff & p[colorKeyPixelPos.Y * pitch + colorKeyPixelPos.X]; + + colorKey = video::A1R5G5B5toA8R8G8B8(key16Bit); + } else { + u32 *p = (u32 *)texture->lock(ETLM_READ_ONLY); + + if (!p) { + os::Printer::log("Could not lock texture for making color key channel.", ELL_ERROR); + return; + } + + u32 pitch = texture->getPitch() / 4; + colorKey = 0x00ffffff & p[colorKeyPixelPos.Y * pitch + colorKeyPixelPos.X]; + } + + texture->unlock(); + makeColorKeyTexture(texture, colorKey); +} + +//! Returns the maximum amount of primitives (mostly vertices) which +//! the device is able to render with one drawIndexedTriangleList +//! call. +u32 CNullDriver::getMaximalPrimitiveCount() const +{ + return 0xFFFFFFFF; +} + +//! checks triangle count and print warning if wrong +bool CNullDriver::checkPrimitiveCount(u32 prmCount) const +{ + const u32 m = getMaximalPrimitiveCount(); + + if (prmCount > m) { + char tmp[128]; + snprintf_irr(tmp, sizeof(tmp), "Could not draw triangles, too many primitives(%u), maximum is %u.", prmCount, m); + os::Printer::log(tmp, ELL_ERROR); + return false; + } + + return true; +} + +bool CNullDriver::checkImage(IImage *image) const +{ + return true; +} + +bool CNullDriver::checkImage(const core::array &image) const +{ + if (!image.size()) + return false; + + ECOLOR_FORMAT lastFormat = image[0]->getColorFormat(); + core::dimension2d lastSize = image[0]->getDimension(); + + for (u32 i = 0; i < image.size(); ++i) { + ECOLOR_FORMAT format = image[i]->getColorFormat(); + core::dimension2d size = image[i]->getDimension(); + + if (!checkImage(image[i])) + return false; + + if (format != lastFormat || size != lastSize) + return false; + } + return true; +} + +//! Enables or disables a texture creation flag. +void CNullDriver::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled) +{ + if (enabled && ((flag == ETCF_ALWAYS_16_BIT) || (flag == ETCF_ALWAYS_32_BIT) || (flag == ETCF_OPTIMIZED_FOR_QUALITY) || (flag == ETCF_OPTIMIZED_FOR_SPEED))) { + // disable other formats + setTextureCreationFlag(ETCF_ALWAYS_16_BIT, false); + setTextureCreationFlag(ETCF_ALWAYS_32_BIT, false); + setTextureCreationFlag(ETCF_OPTIMIZED_FOR_QUALITY, false); + setTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED, false); + } + + // set flag + TextureCreationFlags = (TextureCreationFlags & (~flag)) | + ((((u32)!enabled) - 1) & flag); +} + +//! Returns if a texture creation flag is enabled or disabled. +bool CNullDriver::getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const +{ + return (TextureCreationFlags & flag) != 0; +} + +IImage *CNullDriver::createImageFromFile(const io::path &filename) +{ + if (!filename.size()) + return nullptr; + + io::IReadFile *file = FileSystem->createAndOpenFile(filename); + if (!file) { + os::Printer::log("Could not open file of image", filename, ELL_WARNING); + return nullptr; + } + + IImage *image = createImageFromFile(file); + file->drop(); + return image; +} + +IImage *CNullDriver::createImageFromFile(io::IReadFile *file) +{ + if (!file) + return nullptr; + + // try to load file based on file extension + for (int i = SurfaceLoader.size() - 1; i >= 0; --i) { + if (!SurfaceLoader[i]->isALoadableFileExtension(file->getFileName())) + continue; + + file->seek(0); // reset file position which might have changed due to previous loadImage calls + if (IImage *image = SurfaceLoader[i]->loadImage(file)) + return image; + } + + // try to load file based on what is in it + for (int i = SurfaceLoader.size() - 1; i >= 0; --i) { + if (SurfaceLoader[i]->isALoadableFileExtension(file->getFileName())) + continue; // extension was tried above already + file->seek(0); // dito + if (!SurfaceLoader[i]->isALoadableFileFormat(file)) + continue; + + file->seek(0); + if (IImage *image = SurfaceLoader[i]->loadImage(file)) + return image; + } + + return nullptr; +} + +//! Writes the provided image to disk file +bool CNullDriver::writeImageToFile(IImage *image, const io::path &filename, u32 param) +{ + io::IWriteFile *file = FileSystem->createAndWriteFile(filename); + if (!file) + return false; + + bool result = writeImageToFile(image, file, param); + file->drop(); + + return result; +} + +//! Writes the provided image to a file. +bool CNullDriver::writeImageToFile(IImage *image, io::IWriteFile *file, u32 param) +{ + if (!file) + return false; + + for (s32 i = SurfaceWriter.size() - 1; i >= 0; --i) { + if (SurfaceWriter[i]->isAWriteableFileExtension(file->getFileName())) { + bool written = SurfaceWriter[i]->writeImage(file, image, param); + if (written) + return true; + } + } + return false; // failed to write +} + +//! Creates a software image from a byte array. +IImage *CNullDriver::createImageFromData(ECOLOR_FORMAT format, + const core::dimension2d &size, void *data, bool ownForeignMemory, + bool deleteMemory) +{ + return new CImage(format, size, data, ownForeignMemory, deleteMemory); +} + +//! Creates an empty software image. +IImage *CNullDriver::createImage(ECOLOR_FORMAT format, const core::dimension2d &size) +{ + return new CImage(format, size); +} + +//! Creates a software image from part of a texture. +IImage *CNullDriver::createImage(ITexture *texture, const core::position2d &pos, const core::dimension2d &size) +{ + if ((pos == core::position2di(0, 0)) && (size == texture->getSize())) { + void *data = texture->lock(ETLM_READ_ONLY); + if (!data) + return 0; + IImage *image = new CImage(texture->getColorFormat(), size, data, false, false); + texture->unlock(); + return image; + } else { + // make sure to avoid buffer overruns + // make the vector a separate variable for g++ 3.x + const core::vector2d leftUpper(core::clamp(static_cast(pos.X), 0u, texture->getSize().Width), + core::clamp(static_cast(pos.Y), 0u, texture->getSize().Height)); + const core::rect clamped(leftUpper, + core::dimension2du(core::clamp(static_cast(size.Width), 0u, texture->getSize().Width), + core::clamp(static_cast(size.Height), 0u, texture->getSize().Height))); + if (!clamped.isValid()) + return 0; + u8 *src = static_cast(texture->lock(ETLM_READ_ONLY)); + if (!src) + return 0; + IImage *image = new CImage(texture->getColorFormat(), clamped.getSize()); + u8 *dst = static_cast(image->getData()); + src += clamped.UpperLeftCorner.Y * texture->getPitch() + image->getBytesPerPixel() * clamped.UpperLeftCorner.X; + for (u32 i = 0; i < clamped.getHeight(); ++i) { + video::CColorConverter::convert_viaFormat(src, texture->getColorFormat(), clamped.getWidth(), dst, image->getColorFormat()); + src += texture->getPitch(); + dst += image->getPitch(); + } + texture->unlock(); + return image; + } +} + +//! Sets the fog mode. +void CNullDriver::setFog(SColor color, E_FOG_TYPE fogType, f32 start, f32 end, + f32 density, bool pixelFog, bool rangeFog) +{ + FogColor = color; + FogType = fogType; + FogStart = start; + FogEnd = end; + FogDensity = density; + PixelFog = pixelFog; + RangeFog = rangeFog; +} + +//! Gets the fog mode. +void CNullDriver::getFog(SColor &color, E_FOG_TYPE &fogType, f32 &start, f32 &end, + f32 &density, bool &pixelFog, bool &rangeFog) +{ + color = FogColor; + fogType = FogType; + start = FogStart; + end = FogEnd; + density = FogDensity; + pixelFog = PixelFog; + rangeFog = RangeFog; +} + +//! Draws a mesh buffer +void CNullDriver::drawMeshBuffer(const scene::IMeshBuffer *mb) +{ + if (!mb) + return; + + // IVertexBuffer and IIndexBuffer later + SHWBufferLink *HWBuffer = getBufferLink(mb); + + if (HWBuffer) + drawHardwareBuffer(HWBuffer); + else + drawVertexPrimitiveList(mb->getVertices(), mb->getVertexCount(), mb->getIndices(), mb->getPrimitiveCount(), mb->getVertexType(), mb->getPrimitiveType(), mb->getIndexType()); +} + +//! Draws the normals of a mesh buffer +void CNullDriver::drawMeshBufferNormals(const scene::IMeshBuffer *mb, f32 length, SColor color) +{ + const u32 count = mb->getVertexCount(); + const bool normalize = mb->getMaterial().NormalizeNormals; + + for (u32 i = 0; i < count; ++i) { + core::vector3df normalizedNormal = mb->getNormal(i); + if (normalize) + normalizedNormal.normalize(); + + const core::vector3df &pos = mb->getPosition(i); + draw3DLine(pos, pos + (normalizedNormal * length), color); + } +} + +CNullDriver::SHWBufferLink *CNullDriver::getBufferLink(const scene::IMeshBuffer *mb) +{ + if (!mb || !isHardwareBufferRecommend(mb)) + return 0; + + // search for hardware links + SHWBufferLink *HWBuffer = reinterpret_cast(mb->getHWBuffer()); + if (HWBuffer) + return HWBuffer; + + return createHardwareBuffer(mb); // no hardware links, and mesh wants one, create it +} + +//! Update all hardware buffers, remove unused ones +void CNullDriver::updateAllHardwareBuffers() +{ + auto it = HWBufferList.begin(); + while (it != HWBufferList.end()) { + SHWBufferLink *Link = *it; + ++it; + + if (!Link->MeshBuffer || Link->MeshBuffer->getReferenceCount() == 1) + deleteHardwareBuffer(Link); + } +} + +void CNullDriver::deleteHardwareBuffer(SHWBufferLink *HWBuffer) +{ + if (!HWBuffer) + return; + HWBufferList.erase(HWBuffer->listPosition); + delete HWBuffer; +} + +//! Remove hardware buffer +void CNullDriver::removeHardwareBuffer(const scene::IMeshBuffer *mb) +{ + if (!mb) + return; + SHWBufferLink *HWBuffer = reinterpret_cast(mb->getHWBuffer()); + if (HWBuffer) + deleteHardwareBuffer(HWBuffer); +} + +//! Remove all hardware buffers +void CNullDriver::removeAllHardwareBuffers() +{ + while (!HWBufferList.empty()) + deleteHardwareBuffer(HWBufferList.front()); +} + +bool CNullDriver::isHardwareBufferRecommend(const scene::IMeshBuffer *mb) +{ + if (!mb || (mb->getHardwareMappingHint_Index() == scene::EHM_NEVER && mb->getHardwareMappingHint_Vertex() == scene::EHM_NEVER)) + return false; + + if (mb->getVertexCount() < MinVertexCountForVBO) + return false; + + return true; +} + +//! Create occlusion query. +/** Use node for identification and mesh for occlusion test. */ +void CNullDriver::addOcclusionQuery(scene::ISceneNode *node, const scene::IMesh *mesh) +{ + if (!node) + return; + if (!mesh) { + if ((node->getType() != scene::ESNT_MESH) && (node->getType() != scene::ESNT_ANIMATED_MESH)) + return; + else if (node->getType() == scene::ESNT_MESH) + mesh = static_cast(node)->getMesh(); + else + mesh = static_cast(node)->getMesh()->getMesh(0); + if (!mesh) + return; + } + + // search for query + s32 index = OcclusionQueries.linear_search(SOccQuery(node)); + if (index != -1) { + if (OcclusionQueries[index].Mesh != mesh) { + OcclusionQueries[index].Mesh->drop(); + OcclusionQueries[index].Mesh = mesh; + mesh->grab(); + } + } else { + OcclusionQueries.push_back(SOccQuery(node, mesh)); + node->setAutomaticCulling(node->getAutomaticCulling() | scene::EAC_OCC_QUERY); + } +} + +//! Remove occlusion query. +void CNullDriver::removeOcclusionQuery(scene::ISceneNode *node) +{ + // search for query + s32 index = OcclusionQueries.linear_search(SOccQuery(node)); + if (index != -1) { + node->setAutomaticCulling(node->getAutomaticCulling() & ~scene::EAC_OCC_QUERY); + OcclusionQueries.erase(index); + } +} + +//! Remove all occlusion queries. +void CNullDriver::removeAllOcclusionQueries() +{ + for (s32 i = OcclusionQueries.size() - 1; i >= 0; --i) { + removeOcclusionQuery(OcclusionQueries[i].Node); + } +} + +//! Run occlusion query. Draws mesh stored in query. +/** If the mesh shall be rendered visible, use +flag to enable the proper material setting. */ +void CNullDriver::runOcclusionQuery(scene::ISceneNode *node, bool visible) +{ + if (!node) + return; + s32 index = OcclusionQueries.linear_search(SOccQuery(node)); + if (index == -1) + return; + OcclusionQueries[index].Run = 0; + if (!visible) { + SMaterial mat; + mat.Lighting = false; + mat.AntiAliasing = 0; + mat.ColorMask = ECP_NONE; + mat.GouraudShading = false; + mat.ZWriteEnable = EZW_OFF; + setMaterial(mat); + } + setTransform(video::ETS_WORLD, node->getAbsoluteTransformation()); + const scene::IMesh *mesh = OcclusionQueries[index].Mesh; + for (u32 i = 0; i < mesh->getMeshBufferCount(); ++i) { + if (visible) + setMaterial(mesh->getMeshBuffer(i)->getMaterial()); + drawMeshBuffer(mesh->getMeshBuffer(i)); + } +} + +//! Run all occlusion queries. Draws all meshes stored in queries. +/** If the meshes shall not be rendered visible, use +overrideMaterial to disable the color and depth buffer. */ +void CNullDriver::runAllOcclusionQueries(bool visible) +{ + for (u32 i = 0; i < OcclusionQueries.size(); ++i) + runOcclusionQuery(OcclusionQueries[i].Node, visible); +} + +//! Update occlusion query. Retrieves results from GPU. +/** If the query shall not block, set the flag to false. +Update might not occur in this case, though */ +void CNullDriver::updateOcclusionQuery(scene::ISceneNode *node, bool block) +{ +} + +//! Update all occlusion queries. Retrieves results from GPU. +/** If the query shall not block, set the flag to false. +Update might not occur in this case, though */ +void CNullDriver::updateAllOcclusionQueries(bool block) +{ + for (u32 i = 0; i < OcclusionQueries.size(); ++i) { + if (OcclusionQueries[i].Run == u32(~0)) + continue; + updateOcclusionQuery(OcclusionQueries[i].Node, block); + ++OcclusionQueries[i].Run; + if (OcclusionQueries[i].Run > 1000) + removeOcclusionQuery(OcclusionQueries[i].Node); + } +} + +//! Return query result. +/** Return value is the number of visible pixels/fragments. +The value is a safe approximation, i.e. can be larger then the +actual value of pixels. */ +u32 CNullDriver::getOcclusionQueryResult(scene::ISceneNode *node) const +{ + return ~0; +} + +//! Create render target. +IRenderTarget *CNullDriver::addRenderTarget() +{ + return 0; +} + +//! Remove render target. +void CNullDriver::removeRenderTarget(IRenderTarget *renderTarget) +{ + if (!renderTarget) + return; + + for (u32 i = 0; i < RenderTargets.size(); ++i) { + if (RenderTargets[i] == renderTarget) { + RenderTargets[i]->drop(); + RenderTargets.erase(i); + + return; + } + } +} + +//! Remove all render targets. +void CNullDriver::removeAllRenderTargets() +{ + for (u32 i = 0; i < RenderTargets.size(); ++i) + RenderTargets[i]->drop(); + + RenderTargets.clear(); + + SharedRenderTarget = 0; +} + +//! Only used by the internal engine. Used to notify the driver that +//! the window was resized. +void CNullDriver::OnResize(const core::dimension2d &size) +{ + if (ViewPort.getWidth() == (s32)ScreenSize.Width && + ViewPort.getHeight() == (s32)ScreenSize.Height) + ViewPort = core::rect(core::position2d(0, 0), + core::dimension2di(size)); + + ScreenSize = size; +} + +// adds a material renderer and drops it afterwards. To be used for internal creation +s32 CNullDriver::addAndDropMaterialRenderer(IMaterialRenderer *m) +{ + s32 i = addMaterialRenderer(m); + + if (m) + m->drop(); + + return i; +} + +//! Adds a new material renderer to the video device. +s32 CNullDriver::addMaterialRenderer(IMaterialRenderer *renderer, const char *name) +{ + if (!renderer) + return -1; + + SMaterialRenderer r; + r.Renderer = renderer; + r.Name = name; + + if (name == 0 && MaterialRenderers.size() < numBuiltInMaterials) { + // set name of built in renderer so that we don't have to implement name + // setting in all available renderers. + r.Name = sBuiltInMaterialTypeNames[MaterialRenderers.size()]; + } + + MaterialRenderers.push_back(r); + renderer->grab(); + + return MaterialRenderers.size() - 1; +} + +//! Sets the name of a material renderer. +void CNullDriver::setMaterialRendererName(u32 idx, const char *name) +{ + if (idx < numBuiltInMaterials || idx >= MaterialRenderers.size()) + return; + + MaterialRenderers[idx].Name = name; +} + +void CNullDriver::swapMaterialRenderers(u32 idx1, u32 idx2, bool swapNames) +{ + if (idx1 < MaterialRenderers.size() && idx2 < MaterialRenderers.size()) { + irr::core::swap(MaterialRenderers[idx1].Renderer, MaterialRenderers[idx2].Renderer); + if (swapNames) + irr::core::swap(MaterialRenderers[idx1].Name, MaterialRenderers[idx2].Name); + } +} + +//! Returns driver and operating system specific data about the IVideoDriver. +const SExposedVideoData &CNullDriver::getExposedVideoData() +{ + return ExposedData; +} + +//! Returns type of video driver +E_DRIVER_TYPE CNullDriver::getDriverType() const +{ + return EDT_NULL; +} + +//! deletes all material renderers +void CNullDriver::deleteMaterialRenders() +{ + // delete material renderers + for (u32 i = 0; i < MaterialRenderers.size(); ++i) + if (MaterialRenderers[i].Renderer) + MaterialRenderers[i].Renderer->drop(); + + MaterialRenderers.clear(); +} + +//! Returns pointer to material renderer or null +IMaterialRenderer *CNullDriver::getMaterialRenderer(u32 idx) const +{ + if (idx < MaterialRenderers.size()) + return MaterialRenderers[idx].Renderer; + else + return 0; +} + +//! Returns amount of currently available material renderers. +u32 CNullDriver::getMaterialRendererCount() const +{ + return MaterialRenderers.size(); +} + +//! Returns name of the material renderer +const char *CNullDriver::getMaterialRendererName(u32 idx) const +{ + if (idx < MaterialRenderers.size()) + return MaterialRenderers[idx].Name.c_str(); + + return 0; +} + +//! Returns pointer to the IGPUProgrammingServices interface. +IGPUProgrammingServices *CNullDriver::getGPUProgrammingServices() +{ + return this; +} + +//! Adds a new material renderer to the VideoDriver, based on a high level shading language. +s32 CNullDriver::addHighLevelShaderMaterial( + const c8 *vertexShaderProgram, + const c8 *vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, + const c8 *pixelShaderProgram, + const c8 *pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, + const c8 *geometryShaderProgram, + const c8 *geometryShaderEntryPointName, + E_GEOMETRY_SHADER_TYPE gsCompileTarget, + scene::E_PRIMITIVE_TYPE inType, scene::E_PRIMITIVE_TYPE outType, + u32 verticesOut, + IShaderConstantSetCallBack *callback, + E_MATERIAL_TYPE baseMaterial, + s32 userData) +{ + os::Printer::log("High level shader materials not available (yet) in this driver, sorry"); + return -1; +} + +s32 CNullDriver::addHighLevelShaderMaterialFromFiles( + const io::path &vertexShaderProgramFileName, + const c8 *vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, + const io::path &pixelShaderProgramFileName, + const c8 *pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, + const io::path &geometryShaderProgramFileName, + const c8 *geometryShaderEntryPointName, + E_GEOMETRY_SHADER_TYPE gsCompileTarget, + scene::E_PRIMITIVE_TYPE inType, scene::E_PRIMITIVE_TYPE outType, + u32 verticesOut, + IShaderConstantSetCallBack *callback, + E_MATERIAL_TYPE baseMaterial, + s32 userData) +{ + io::IReadFile *vsfile = 0; + io::IReadFile *psfile = 0; + io::IReadFile *gsfile = 0; + + if (vertexShaderProgramFileName.size()) { + vsfile = FileSystem->createAndOpenFile(vertexShaderProgramFileName); + if (!vsfile) { + os::Printer::log("Could not open vertex shader program file", + vertexShaderProgramFileName, ELL_WARNING); + } + } + + if (pixelShaderProgramFileName.size()) { + psfile = FileSystem->createAndOpenFile(pixelShaderProgramFileName); + if (!psfile) { + os::Printer::log("Could not open pixel shader program file", + pixelShaderProgramFileName, ELL_WARNING); + } + } + + if (geometryShaderProgramFileName.size()) { + gsfile = FileSystem->createAndOpenFile(geometryShaderProgramFileName); + if (!gsfile) { + os::Printer::log("Could not open geometry shader program file", + geometryShaderProgramFileName, ELL_WARNING); + } + } + + s32 result = addHighLevelShaderMaterialFromFiles( + vsfile, vertexShaderEntryPointName, vsCompileTarget, + psfile, pixelShaderEntryPointName, psCompileTarget, + gsfile, geometryShaderEntryPointName, gsCompileTarget, + inType, outType, verticesOut, + callback, baseMaterial, userData); + + if (psfile) + psfile->drop(); + + if (vsfile) + vsfile->drop(); + + if (gsfile) + gsfile->drop(); + + return result; +} + +s32 CNullDriver::addHighLevelShaderMaterialFromFiles( + io::IReadFile *vertexShaderProgram, + const c8 *vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, + io::IReadFile *pixelShaderProgram, + const c8 *pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, + io::IReadFile *geometryShaderProgram, + const c8 *geometryShaderEntryPointName, + E_GEOMETRY_SHADER_TYPE gsCompileTarget, + scene::E_PRIMITIVE_TYPE inType, scene::E_PRIMITIVE_TYPE outType, + u32 verticesOut, + IShaderConstantSetCallBack *callback, + E_MATERIAL_TYPE baseMaterial, + s32 userData) +{ + c8 *vs = 0; + c8 *ps = 0; + c8 *gs = 0; + + if (vertexShaderProgram) { + const long size = vertexShaderProgram->getSize(); + if (size) { + vs = new c8[size + 1]; + vertexShaderProgram->read(vs, size); + vs[size] = 0; + } + } + + if (pixelShaderProgram) { + const long size = pixelShaderProgram->getSize(); + if (size) { + // if both handles are the same we must reset the file + if (pixelShaderProgram == vertexShaderProgram) + pixelShaderProgram->seek(0); + ps = new c8[size + 1]; + pixelShaderProgram->read(ps, size); + ps[size] = 0; + } + } + + if (geometryShaderProgram) { + const long size = geometryShaderProgram->getSize(); + if (size) { + // if both handles are the same we must reset the file + if ((geometryShaderProgram == vertexShaderProgram) || + (geometryShaderProgram == pixelShaderProgram)) + geometryShaderProgram->seek(0); + gs = new c8[size + 1]; + geometryShaderProgram->read(gs, size); + gs[size] = 0; + } + } + + s32 result = this->addHighLevelShaderMaterial( + vs, vertexShaderEntryPointName, vsCompileTarget, + ps, pixelShaderEntryPointName, psCompileTarget, + gs, geometryShaderEntryPointName, gsCompileTarget, + inType, outType, verticesOut, + callback, baseMaterial, userData); + + delete[] vs; + delete[] ps; + delete[] gs; + + return result; +} + +void CNullDriver::deleteShaderMaterial(s32 material) +{ + const u32 idx = (u32)material; + if (idx < numBuiltInMaterials || idx >= MaterialRenderers.size()) + return; + + // if this is the last material we can drop it without consequence + if (idx == MaterialRenderers.size() - 1) { + if (MaterialRenderers[idx].Renderer) + MaterialRenderers[idx].Renderer->drop(); + MaterialRenderers.erase(idx); + return; + } + // otherwise replace with a dummy renderer, we have to preserve the IDs + auto &ref = MaterialRenderers[idx]; + if (ref.Renderer) + ref.Renderer->drop(); + ref.Renderer = new CDummyMaterialRenderer(); + ref.Name.clear(); +} + +//! Creates a render target texture. +ITexture *CNullDriver::addRenderTargetTexture(const core::dimension2d &size, + const io::path &name, const ECOLOR_FORMAT format) +{ + return 0; +} + +ITexture *CNullDriver::addRenderTargetTextureCubemap(const irr::u32 sideLen, + const io::path &name, const ECOLOR_FORMAT format) +{ + return 0; +} + +void CNullDriver::clearBuffers(u16 flag, SColor color, f32 depth, u8 stencil) +{ +} + +//! Returns a pointer to the mesh manipulator. +scene::IMeshManipulator *CNullDriver::getMeshManipulator() +{ + return MeshManipulator; +} + +//! Returns an image created from the last rendered frame. +IImage *CNullDriver::createScreenShot(video::ECOLOR_FORMAT format, video::E_RENDER_TARGET target) +{ + return 0; +} + +// prints renderer version +void CNullDriver::printVersion() +{ + core::stringc namePrint = "Using renderer: "; + namePrint += getName(); + os::Printer::log(namePrint.c_str(), ELL_INFORMATION); +} + +//! creates a video driver +IVideoDriver *createNullDriver(io::IFileSystem *io, const core::dimension2d &screenSize) +{ + CNullDriver *nullDriver = new CNullDriver(io, screenSize); + + // create empty material renderers + for (u32 i = 0; sBuiltInMaterialTypeNames[i]; ++i) { + IMaterialRenderer *imr = new IMaterialRenderer(); + nullDriver->addMaterialRenderer(imr); + imr->drop(); + } + + return nullDriver; +} + +//! Set/unset a clipping plane. +//! There are at least 6 clipping planes available for the user to set at will. +//! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. +//! \param plane: The plane itself. +//! \param enable: If true, enable the clipping plane else disable it. +bool CNullDriver::setClipPlane(u32 index, const core::plane3df &plane, bool enable) +{ + return false; +} + +//! Enable/disable a clipping plane. +void CNullDriver::enableClipPlane(u32 index, bool enable) +{ + // not necessary +} + +void CNullDriver::setMinHardwareBufferVertexCount(u32 count) +{ + MinVertexCountForVBO = count; +} + +SOverrideMaterial &CNullDriver::getOverrideMaterial() +{ + return OverrideMaterial; +} + +//! Get the 2d override material for altering its values +SMaterial &CNullDriver::getMaterial2D() +{ + return OverrideMaterial2D; +} + +//! Enable the 2d override material +void CNullDriver::enableMaterial2D(bool enable) +{ + OverrideMaterial2DEnabled = enable; +} + +core::dimension2du CNullDriver::getMaxTextureSize() const +{ + return core::dimension2du(0x10000, 0x10000); // maybe large enough +} + +bool CNullDriver::needsTransparentRenderPass(const irr::video::SMaterial &material) const +{ + // TODO: I suspect it would be nice if the material had an enum for further control. + // Especially it probably makes sense to allow disabling transparent render pass as soon as material.ZWriteEnable is on. + // But then we might want an enum for the renderpass in material instead of just a transparency flag in material - and that's more work. + // Or we could at least set return false when material.ZWriteEnable is EZW_ON? Still considering that... + // Be careful - this function is deeply connected to getWriteZBuffer as transparent render passes are usually about rendering with + // zwrite disabled and getWriteZBuffer calls this function. + + video::IMaterialRenderer *rnd = getMaterialRenderer(material.MaterialType); + // TODO: I suspect IMaterialRenderer::isTransparent also often could use SMaterial as parameter + // We could for example then get rid of IsTransparent function in SMaterial and move that to the software material renderer. + if (rnd && rnd->isTransparent()) + return true; + + return false; +} + +//! Color conversion convenience function +/** Convert an image (as array of pixels) from source to destination +array, thereby converting the color format. The pixel size is +determined by the color formats. +\param sP Pointer to source +\param sF Color format of source +\param sN Number of pixels to convert, both array must be large enough +\param dP Pointer to destination +\param dF Color format of destination +*/ +void CNullDriver::convertColor(const void *sP, ECOLOR_FORMAT sF, s32 sN, + void *dP, ECOLOR_FORMAT dF) const +{ + video::CColorConverter::convert_viaFormat(sP, sF, sN, dP, dF); +} + +} // end namespace +} // end namespace diff --git a/irr/src/CNullDriver.h b/irr/src/CNullDriver.h new file mode 100644 index 000000000..d47212c0f --- /dev/null +++ b/irr/src/CNullDriver.h @@ -0,0 +1,742 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IVideoDriver.h" +#include "IFileSystem.h" +#include "IGPUProgrammingServices.h" +#include "irrArray.h" +#include "irrString.h" +#include "IAttributes.h" +#include "IMesh.h" +#include "IMeshBuffer.h" +#include "IMeshSceneNode.h" +#include "CFPSCounter.h" +#include "S3DVertex.h" +#include "SVertexIndex.h" +#include "SExposedVideoData.h" +#include + +namespace irr +{ +namespace io +{ +class IWriteFile; +class IReadFile; +} // end namespace io +namespace video +{ +class IImageLoader; +class IImageWriter; + +class CNullDriver : public IVideoDriver, public IGPUProgrammingServices +{ +public: + //! constructor + CNullDriver(io::IFileSystem *io, const core::dimension2d &screenSize); + + //! destructor + virtual ~CNullDriver(); + + virtual bool beginScene(u16 clearFlag, SColor clearColor = SColor(255, 0, 0, 0), f32 clearDepth = 1.f, u8 clearStencil = 0, + const SExposedVideoData &videoData = SExposedVideoData(), core::rect *sourceRect = 0) override; + + bool endScene() override; + + //! Disable a feature of the driver. + void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag = true) override; + + //! queries the features of the driver, returns true if feature is available + bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const override; + + //! Get attributes of the actual video driver + const io::IAttributes &getDriverAttributes() const override; + + //! sets transformation + void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4 &mat) override; + + //! Retrieve the number of image loaders + u32 getImageLoaderCount() const override; + + //! Retrieve the given image loader + IImageLoader *getImageLoader(u32 n) override; + + //! Retrieve the number of image writers + u32 getImageWriterCount() const override; + + //! Retrieve the given image writer + IImageWriter *getImageWriter(u32 n) override; + + //! sets a material + void setMaterial(const SMaterial &material) override; + + //! loads a Texture + ITexture *getTexture(const io::path &filename) override; + + //! loads a Texture + ITexture *getTexture(io::IReadFile *file) override; + + //! Returns amount of textures currently loaded + u32 getTextureCount() const override; + + ITexture *addTexture(const core::dimension2d &size, const io::path &name, ECOLOR_FORMAT format = ECF_A8R8G8B8) override; + + ITexture *addTexture(const io::path &name, IImage *image) override; + + virtual ITexture *addTextureCubemap(const io::path &name, IImage *imagePosX, IImage *imageNegX, IImage *imagePosY, + IImage *imageNegY, IImage *imagePosZ, IImage *imageNegZ) override; + + ITexture *addTextureCubemap(const irr::u32 sideLen, const io::path &name, ECOLOR_FORMAT format = ECF_A8R8G8B8) override; + + virtual bool setRenderTargetEx(IRenderTarget *target, u16 clearFlag, SColor clearColor = SColor(255, 0, 0, 0), + f32 clearDepth = 1.f, u8 clearStencil = 0) override; + + virtual bool setRenderTarget(ITexture *texture, u16 clearFlag, SColor clearColor = SColor(255, 0, 0, 0), + f32 clearDepth = 1.f, u8 clearStencil = 0) override; + + //! sets a viewport + void setViewPort(const core::rect &area) override; + + //! gets the area of the current viewport + const core::rect &getViewPort() const override; + + //! draws a vertex primitive list + virtual void drawVertexPrimitiveList(const void *vertices, u32 vertexCount, + const void *indexList, u32 primitiveCount, + E_VERTEX_TYPE vType = EVT_STANDARD, scene::E_PRIMITIVE_TYPE pType = scene::EPT_TRIANGLES, + E_INDEX_TYPE iType = EIT_16BIT) override; + + //! draws a vertex primitive list in 2d + virtual void draw2DVertexPrimitiveList(const void *vertices, u32 vertexCount, + const void *indexList, u32 primitiveCount, + E_VERTEX_TYPE vType = EVT_STANDARD, scene::E_PRIMITIVE_TYPE pType = scene::EPT_TRIANGLES, + E_INDEX_TYPE iType = EIT_16BIT) override; + + //! Draws a 3d line. + virtual void draw3DLine(const core::vector3df &start, + const core::vector3df &end, SColor color = SColor(255, 255, 255, 255)) override; + + //! Draws a 3d axis aligned box. + virtual void draw3DBox(const core::aabbox3d &box, + SColor color = SColor(255, 255, 255, 255)) override; + + //! draws an 2d image + void draw2DImage(const video::ITexture *texture, const core::position2d &destPos, bool useAlphaChannelOfTexture) override; + + //! Draws a set of 2d images, using a color and the alpha channel of the texture. + /** All drawings are clipped against clipRect (if != 0). + The subtextures are defined by the array of sourceRects and are + positioned using the array of positions. + \param texture Texture to be drawn. + \param pos Array of upper left 2d destinations where the images + will be drawn. + \param sourceRects Source rectangles of the image. + \param clipRect Pointer to rectangle on the screen where the + images are clipped to. + If this pointer is 0 then the image is not clipped. + \param color Color with which the image is drawn. + Note that the alpha component is used. If alpha is other than + 255, the image will be transparent. + \param useAlphaChannelOfTexture: If true, the alpha channel of + the texture is used to draw the image. */ + virtual void draw2DImageBatch(const video::ITexture *texture, + const core::array> &positions, + const core::array> &sourceRects, + const core::rect *clipRect = 0, + SColor color = SColor(255, 255, 255, 255), + bool useAlphaChannelOfTexture = false) override; + + //! Draws a 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. + virtual void draw2DImage(const video::ITexture *texture, const core::position2d &destPos, + const core::rect &sourceRect, const core::rect *clipRect = 0, + SColor color = SColor(255, 255, 255, 255), bool useAlphaChannelOfTexture = false) override; + + //! Draws a part of the texture into the rectangle. + virtual void draw2DImage(const video::ITexture *texture, const core::rect &destRect, + const core::rect &sourceRect, const core::rect *clipRect = 0, + const video::SColor *const colors = 0, bool useAlphaChannelOfTexture = false) override; + + //! Draws a 2d rectangle + void draw2DRectangle(SColor color, const core::rect &pos, const core::rect *clip = 0) override; + + //! Draws a 2d rectangle with a gradient. + virtual void draw2DRectangle(const core::rect &pos, + SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, + const core::rect *clip = 0) override; + + //! Draws a 2d line. + virtual void draw2DLine(const core::position2d &start, + const core::position2d &end, + SColor color = SColor(255, 255, 255, 255)) override; + + virtual void setFog(SColor color = SColor(0, 255, 255, 255), + E_FOG_TYPE fogType = EFT_FOG_LINEAR, + f32 start = 50.0f, f32 end = 100.0f, f32 density = 0.01f, + bool pixelFog = false, bool rangeFog = false) override; + + virtual void getFog(SColor &color, E_FOG_TYPE &fogType, + f32 &start, f32 &end, f32 &density, + bool &pixelFog, bool &rangeFog) override; + + //! get color format of the current color buffer + ECOLOR_FORMAT getColorFormat() const override; + + //! get screen size + const core::dimension2d &getScreenSize() const override; + + //! get current render target + IRenderTarget *getCurrentRenderTarget() const; + + //! get render target size + const core::dimension2d &getCurrentRenderTargetSize() const override; + + // get current frames per second value + s32 getFPS() const override; + + //! returns amount of primitives (mostly triangles) were drawn in the last frame. + //! very useful method for statistics. + u32 getPrimitiveCountDrawn(u32 param = 0) const override; + + //! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 + //! driver, it would return "Direct3D8.1". + const char *getName() const override; + + //! Sets the dynamic ambient light color. The default color is + //! (0,0,0,0) which means it is dark. + //! \param color: New color of the ambient light. + void setAmbientLight(const SColorf &color) override; + + //! Get the global ambient light currently used by the driver + const SColorf &getAmbientLight() const override; + + //! Adds an external image loader to the engine. + void addExternalImageLoader(IImageLoader *loader) override; + + //! Adds an external image writer to the engine. + void addExternalImageWriter(IImageWriter *writer) override; + + //! Removes a texture from the texture cache and deletes it, freeing lot of + //! memory. + void removeTexture(ITexture *texture) override; + + //! Removes all texture from the texture cache and deletes them, freeing lot of + //! memory. + void removeAllTextures() override; + + //! Creates a render target texture. + virtual ITexture *addRenderTargetTexture(const core::dimension2d &size, + const io::path &name, const ECOLOR_FORMAT format = ECF_UNKNOWN) override; + + //! Creates a render target texture for a cubemap + ITexture *addRenderTargetTextureCubemap(const irr::u32 sideLen, + const io::path &name, const ECOLOR_FORMAT format) override; + + //! Creates an 1bit alpha channel of the texture based of an color key. + void makeColorKeyTexture(video::ITexture *texture, video::SColor color) const override; + + //! Creates an 1bit alpha channel of the texture based of an color key position. + virtual void makeColorKeyTexture(video::ITexture *texture, + core::position2d colorKeyPixelPos) const override; + + //! Returns the maximum amount of primitives (mostly vertices) which + //! the device is able to render with one drawIndexedTriangleList + //! call. + u32 getMaximalPrimitiveCount() const override; + + //! Enables or disables a texture creation flag. + void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled) override; + + //! Returns if a texture creation flag is enabled or disabled. + bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const override; + + IImage *createImageFromFile(const io::path &filename) override; + + IImage *createImageFromFile(io::IReadFile *file) override; + + //! Creates a software image from a byte array. + /** \param useForeignMemory: If true, the image will use the data pointer + directly and own it from now on, which means it will also try to delete [] the + data when the image will be destructed. If false, the memory will by copied. */ + virtual IImage *createImageFromData(ECOLOR_FORMAT format, + const core::dimension2d &size, void *data, bool ownForeignMemory = false, + bool deleteMemory = true) override; + + //! Creates an empty software image. + IImage *createImage(ECOLOR_FORMAT format, const core::dimension2d &size) override; + + //! Creates a software image from part of a texture. + virtual IImage *createImage(ITexture *texture, + const core::position2d &pos, + const core::dimension2d &size) override; + + //! Draws a mesh buffer + void drawMeshBuffer(const scene::IMeshBuffer *mb) override; + + //! Draws the normals of a mesh buffer + virtual void drawMeshBufferNormals(const scene::IMeshBuffer *mb, f32 length = 10.f, + SColor color = 0xffffffff) override; + + //! Check if the driver supports creating textures with the given color format + bool queryTextureFormat(ECOLOR_FORMAT format) const override + { + return false; + } + +protected: + struct SHWBufferLink + { + SHWBufferLink(const scene::IMeshBuffer *_MeshBuffer) : + MeshBuffer(_MeshBuffer), + ChangedID_Vertex(0), ChangedID_Index(0), + Mapped_Vertex(scene::EHM_NEVER), Mapped_Index(scene::EHM_NEVER) + { + if (MeshBuffer) { + MeshBuffer->grab(); + MeshBuffer->setHWBuffer(reinterpret_cast(this)); + } + } + + virtual ~SHWBufferLink() + { + if (MeshBuffer) { + MeshBuffer->setHWBuffer(NULL); + MeshBuffer->drop(); + } + } + + const scene::IMeshBuffer *MeshBuffer; + u32 ChangedID_Vertex; + u32 ChangedID_Index; + scene::E_HARDWARE_MAPPING Mapped_Vertex; + scene::E_HARDWARE_MAPPING Mapped_Index; + std::list::iterator listPosition; + }; + + //! Gets hardware buffer link from a meshbuffer (may create or update buffer) + virtual SHWBufferLink *getBufferLink(const scene::IMeshBuffer *mb); + + //! updates hardware buffer if needed (only some drivers can) + virtual bool updateHardwareBuffer(SHWBufferLink *HWBuffer) { return false; } + + //! Draw hardware buffer (only some drivers can) + virtual void drawHardwareBuffer(SHWBufferLink *HWBuffer) {} + + //! Delete hardware buffer + virtual void deleteHardwareBuffer(SHWBufferLink *HWBuffer); + + //! Create hardware buffer from mesh (only some drivers can) + virtual SHWBufferLink *createHardwareBuffer(const scene::IMeshBuffer *mb) { return 0; } + +public: + //! Remove hardware buffer + void removeHardwareBuffer(const scene::IMeshBuffer *mb) override; + + //! Remove all hardware buffers + void removeAllHardwareBuffers() override; + + //! Update all hardware buffers, remove unused ones + virtual void updateAllHardwareBuffers(); + + //! is vbo recommended on this mesh? + virtual bool isHardwareBufferRecommend(const scene::IMeshBuffer *mb); + + //! Create occlusion query. + /** Use node for identification and mesh for occlusion test. */ + virtual void addOcclusionQuery(scene::ISceneNode *node, + const scene::IMesh *mesh = 0) override; + + //! Remove occlusion query. + void removeOcclusionQuery(scene::ISceneNode *node) override; + + //! Remove all occlusion queries. + void removeAllOcclusionQueries() override; + + //! Run occlusion query. Draws mesh stored in query. + /** If the mesh shall not be rendered visible, use + overrideMaterial to disable the color and depth buffer. */ + void runOcclusionQuery(scene::ISceneNode *node, bool visible = false) override; + + //! Run all occlusion queries. Draws all meshes stored in queries. + /** If the meshes shall not be rendered visible, use + overrideMaterial to disable the color and depth buffer. */ + void runAllOcclusionQueries(bool visible = false) override; + + //! Update occlusion query. Retrieves results from GPU. + /** If the query shall not block, set the flag to false. + Update might not occur in this case, though */ + void updateOcclusionQuery(scene::ISceneNode *node, bool block = true) override; + + //! Update all occlusion queries. Retrieves results from GPU. + /** If the query shall not block, set the flag to false. + Update might not occur in this case, though */ + void updateAllOcclusionQueries(bool block = true) override; + + //! Return query result. + /** Return value is the number of visible pixels/fragments. + The value is a safe approximation, i.e. can be larger than the + actual value of pixels. */ + u32 getOcclusionQueryResult(scene::ISceneNode *node) const override; + + //! Create render target. + IRenderTarget *addRenderTarget() override; + + //! Remove render target. + void removeRenderTarget(IRenderTarget *renderTarget) override; + + //! Remove all render targets. + void removeAllRenderTargets() override; + + //! Only used by the engine internally. + /** Used to notify the driver that the window was resized. */ + void OnResize(const core::dimension2d &size) override; + + //! Adds a new material renderer to the video device. + virtual s32 addMaterialRenderer(IMaterialRenderer *renderer, + const char *name = 0) override; + + //! Returns driver and operating system specific data about the IVideoDriver. + const SExposedVideoData &getExposedVideoData() override; + + //! Returns type of video driver + E_DRIVER_TYPE getDriverType() const override; + + //! Returns the transformation set by setTransform + const core::matrix4 &getTransform(E_TRANSFORMATION_STATE state) const override; + + //! Returns pointer to the IGPUProgrammingServices interface. + IGPUProgrammingServices *getGPUProgrammingServices() override; + + //! Returns pointer to material renderer or null + IMaterialRenderer *getMaterialRenderer(u32 idx) const override; + + //! Returns amount of currently available material renderers. + u32 getMaterialRendererCount() const override; + + //! Returns name of the material renderer + const char *getMaterialRendererName(u32 idx) const override; + + //! Adds a new material renderer to the VideoDriver, based on a high level shading language. + virtual s32 addHighLevelShaderMaterial( + const c8 *vertexShaderProgram, + const c8 *vertexShaderEntryPointName = 0, + E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, + const c8 *pixelShaderProgram = 0, + const c8 *pixelShaderEntryPointName = 0, + E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, + const c8 *geometryShaderProgram = 0, + const c8 *geometryShaderEntryPointName = "main", + E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0, + scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES, + scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP, + u32 verticesOut = 0, + IShaderConstantSetCallBack *callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0) override; + + virtual s32 addHighLevelShaderMaterialFromFiles( + const io::path &vertexShaderProgramFile, + const c8 *vertexShaderEntryPointName = "main", + E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, + const io::path &pixelShaderProgramFile = "", + const c8 *pixelShaderEntryPointName = "main", + E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, + const io::path &geometryShaderProgramFileName = "", + const c8 *geometryShaderEntryPointName = "main", + E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0, + scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES, + scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP, + u32 verticesOut = 0, + IShaderConstantSetCallBack *callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0) override; + + virtual s32 addHighLevelShaderMaterialFromFiles( + io::IReadFile *vertexShaderProgram, + const c8 *vertexShaderEntryPointName = "main", + E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, + io::IReadFile *pixelShaderProgram = 0, + const c8 *pixelShaderEntryPointName = "main", + E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, + io::IReadFile *geometryShaderProgram = 0, + const c8 *geometryShaderEntryPointName = "main", + E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0, + scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES, + scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP, + u32 verticesOut = 0, + IShaderConstantSetCallBack *callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0) override; + + virtual void deleteShaderMaterial(s32 material) override; + + //! Returns a pointer to the mesh manipulator. + scene::IMeshManipulator *getMeshManipulator() override; + + void clearBuffers(u16 flag, SColor color = SColor(255, 0, 0, 0), f32 depth = 1.f, u8 stencil = 0) override; + + //! Returns an image created from the last rendered frame. + IImage *createScreenShot(video::ECOLOR_FORMAT format = video::ECF_UNKNOWN, video::E_RENDER_TARGET target = video::ERT_FRAME_BUFFER) override; + + //! Writes the provided image to disk file + bool writeImageToFile(IImage *image, const io::path &filename, u32 param = 0) override; + + //! Writes the provided image to a file. + bool writeImageToFile(IImage *image, io::IWriteFile *file, u32 param = 0) override; + + //! Sets the name of a material renderer. + void setMaterialRendererName(u32 idx, const char *name) override; + + //! Swap the material renderers used for certain id's + void swapMaterialRenderers(u32 idx1, u32 idx2, bool swapNames) override; + + //! looks if the image is already loaded + video::ITexture *findTexture(const io::path &filename) override; + + //! Set/unset a clipping plane. + //! There are at least 6 clipping planes available for the user to set at will. + //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. + //! \param plane: The plane itself. + //! \param enable: If true, enable the clipping plane else disable it. + bool setClipPlane(u32 index, const core::plane3df &plane, bool enable = false) override; + + //! Enable/disable a clipping plane. + //! There are at least 6 clipping planes available for the user to set at will. + //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. + //! \param enable: If true, enable the clipping plane else disable it. + void enableClipPlane(u32 index, bool enable) override; + + //! Returns the graphics card vendor name. + core::stringc getVendorInfo() override { return "Not available on this driver."; } + + //! Set the minimum number of vertices for which a hw buffer will be created + /** \param count Number of vertices to set as minimum. */ + void setMinHardwareBufferVertexCount(u32 count) override; + + //! Get the global Material, which might override local materials. + /** Depending on the enable flags, values from this Material + are used to override those of local materials of some + meshbuffer being rendered. */ + SOverrideMaterial &getOverrideMaterial() override; + + //! Get the 2d override material for altering its values + SMaterial &getMaterial2D() override; + + //! Enable the 2d override material + void enableMaterial2D(bool enable = true) override; + + //! Only used by the engine internally. + void setAllowZWriteOnTransparent(bool flag) override + { + AllowZWriteOnTransparent = flag; + } + + //! Returns the maximum texture size supported. + core::dimension2du getMaxTextureSize() const override; + + //! Used by some SceneNodes to check if a material should be rendered in the transparent render pass + bool needsTransparentRenderPass(const irr::video::SMaterial &material) const override; + + //! Color conversion convenience function + /** Convert an image (as array of pixels) from source to destination + array, thereby converting the color format. The pixel size is + determined by the color formats. + \param sP Pointer to source + \param sF Color format of source + \param sN Number of pixels to convert, both array must be large enough + \param dP Pointer to destination + \param dF Color format of destination + */ + virtual void convertColor(const void *sP, ECOLOR_FORMAT sF, s32 sN, + void *dP, ECOLOR_FORMAT dF) const override; + + bool checkDriverReset() override { return false; } + +protected: + //! deletes all textures + void deleteAllTextures(); + + //! opens the file and loads it into the surface + ITexture *loadTextureFromFile(io::IReadFile *file, const io::path &hashName = ""); + + //! adds a surface, not loaded or created by the Irrlicht Engine + void addTexture(ITexture *surface); + + virtual ITexture *createDeviceDependentTexture(const io::path &name, IImage *image); + + virtual ITexture *createDeviceDependentTextureCubemap(const io::path &name, const core::array &image); + + //! checks triangle count and print warning if wrong + bool checkPrimitiveCount(u32 prmcnt) const; + + bool checkImage(IImage *image) const; + + bool checkImage(const core::array &image) const; + + // adds a material renderer and drops it afterwards. To be used for internal creation + s32 addAndDropMaterialRenderer(IMaterialRenderer *m); + + //! deletes all material renderers + void deleteMaterialRenders(); + + // prints renderer version + void printVersion(); + + inline bool getWriteZBuffer(const SMaterial &material) const + { + switch (material.ZWriteEnable) { + case video::EZW_OFF: + return false; + case video::EZW_AUTO: + return AllowZWriteOnTransparent || !needsTransparentRenderPass(material); + case video::EZW_ON: + return true; + } + return true; // never should get here, but some compilers don't know and complain + } + + struct SSurface + { + video::ITexture *Surface; + + bool operator<(const SSurface &other) const + { + return Surface->getName() < other.Surface->getName(); + } + }; + + struct SMaterialRenderer + { + core::stringc Name; + IMaterialRenderer *Renderer; + }; + + struct SDummyTexture : public ITexture + { + SDummyTexture(const io::path &name, E_TEXTURE_TYPE type) : + ITexture(name, type){}; + + void setSize(const core::dimension2d &size) { Size = OriginalSize = size; } + + void *lock(E_TEXTURE_LOCK_MODE mode = ETLM_READ_WRITE, u32 mipmapLevel = 0, u32 layer = 0, E_TEXTURE_LOCK_FLAGS lockFlags = ETLF_FLIP_Y_UP_RTT) override { return 0; } + void unlock() override {} + void regenerateMipMapLevels(void *data = 0, u32 layer = 0) override {} + }; + core::array Textures; + + struct SOccQuery + { + SOccQuery(scene::ISceneNode *node, const scene::IMesh *mesh = 0) : + Node(node), Mesh(mesh), PID(0), Result(0xffffffff), Run(0xffffffff) + { + if (Node) + Node->grab(); + if (Mesh) + Mesh->grab(); + } + + SOccQuery(const SOccQuery &other) : + Node(other.Node), Mesh(other.Mesh), PID(other.PID), Result(other.Result), Run(other.Run) + { + if (Node) + Node->grab(); + if (Mesh) + Mesh->grab(); + } + + ~SOccQuery() + { + if (Node) + Node->drop(); + if (Mesh) + Mesh->drop(); + } + + SOccQuery &operator=(const SOccQuery &other) + { + Node = other.Node; + Mesh = other.Mesh; + PID = other.PID; + Result = other.Result; + Run = other.Run; + if (Node) + Node->grab(); + if (Mesh) + Mesh->grab(); + return *this; + } + + bool operator==(const SOccQuery &other) const + { + return other.Node == Node; + } + + scene::ISceneNode *Node; + const scene::IMesh *Mesh; + union + { + void *PID; + unsigned int UID; + }; + u32 Result; + u32 Run; + }; + core::array OcclusionQueries; + + core::array RenderTargets; + + // Shared objects used with simplified IVideoDriver::setRenderTarget method with ITexture* param. + IRenderTarget *SharedRenderTarget; + core::array SharedDepthTextures; + + IRenderTarget *CurrentRenderTarget; + core::dimension2d CurrentRenderTargetSize; + + core::array SurfaceLoader; + core::array SurfaceWriter; + core::array MaterialRenderers; + + std::list HWBufferList; + + io::IFileSystem *FileSystem; + + //! mesh manipulator + scene::IMeshManipulator *MeshManipulator; + + core::rect ViewPort; + core::dimension2d ScreenSize; + core::matrix4 TransformationMatrix; + + CFPSCounter FPSCounter; + + u32 PrimitivesDrawn; + u32 MinVertexCountForVBO; + + u32 TextureCreationFlags; + + f32 FogStart; + f32 FogEnd; + f32 FogDensity; + SColor FogColor; + SExposedVideoData ExposedData; + + io::IAttributes *DriverAttributes; + + SOverrideMaterial OverrideMaterial; + SMaterial OverrideMaterial2D; + SMaterial InitMaterial2D; + bool OverrideMaterial2DEnabled; + + E_FOG_TYPE FogType; + bool PixelFog; + bool RangeFog; + bool AllowZWriteOnTransparent; + + bool FeatureEnabled[video::EVDF_COUNT]; + + SColorf AmbientLight; +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/src/COBJMeshFileLoader.cpp b/irr/src/COBJMeshFileLoader.cpp new file mode 100644 index 000000000..4c5a5328d --- /dev/null +++ b/irr/src/COBJMeshFileLoader.cpp @@ -0,0 +1,549 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "COBJMeshFileLoader.h" +#include "IMeshManipulator.h" +#include "IVideoDriver.h" +#include "SMesh.h" +#include "SMeshBuffer.h" +#include "SAnimatedMesh.h" +#include "IReadFile.h" +#include "IAttributes.h" +#include "fast_atof.h" +#include "coreutil.h" +#include "os.h" + +namespace irr +{ +namespace scene +{ + +#ifdef _DEBUG +#define _IRR_DEBUG_OBJ_LOADER_ +#endif + +//! Constructor +COBJMeshFileLoader::COBJMeshFileLoader(scene::ISceneManager *smgr) : + SceneManager(smgr) +{ +#ifdef _DEBUG + setDebugName("COBJMeshFileLoader"); +#endif +} + +//! destructor +COBJMeshFileLoader::~COBJMeshFileLoader() +{ +} + +//! returns true if the file maybe is able to be loaded by this class +//! based on the file extension (e.g. ".bsp") +bool COBJMeshFileLoader::isALoadableFileExtension(const io::path &filename) const +{ + return core::hasFileExtension(filename, "obj"); +} + +//! creates/loads an animated mesh from the file. +//! \return Pointer to the created mesh. Returns 0 if loading failed. +//! If you no longer need the mesh, you should call IAnimatedMesh::drop(). +//! See IReferenceCounted::drop() for more information. +IAnimatedMesh *COBJMeshFileLoader::createMesh(io::IReadFile *file) +{ + if (!file) + return 0; + + const long filesize = file->getSize(); + if (!filesize) + return 0; + + const u32 WORD_BUFFER_LENGTH = 512; + + core::array vertexBuffer(1000); + core::array normalsBuffer(1000); + core::array textureCoordBuffer(1000); + + SObjMtl *currMtl = new SObjMtl(); + Materials.push_back(currMtl); + u32 smoothingGroup = 0; + + const io::path fullName = file->getFileName(); + + c8 *buf = new c8[filesize + 1]; // plus null-terminator + memset(buf, 0, filesize + 1); + file->read((void *)buf, filesize); + const c8 *const bufEnd = buf + filesize; + + // Process obj information + const c8 *bufPtr = buf; + core::stringc grpName, mtlName; + bool mtlChanged = false; + bool useGroups = !SceneManager->getParameters()->getAttributeAsBool(OBJ_LOADER_IGNORE_GROUPS); + bool useMaterials = !SceneManager->getParameters()->getAttributeAsBool(OBJ_LOADER_IGNORE_MATERIAL_FILES); + [[maybe_unused]] irr::u32 lineNr = 1; // only counts non-empty lines, still useful in debugging to locate errors + core::array faceCorners; + faceCorners.reallocate(32); // should be large enough + const core::stringc TAG_OFF = "off"; + irr::u32 degeneratedFaces = 0; + + while (bufPtr != bufEnd) { + switch (bufPtr[0]) { + case 'm': // mtllib (material) + { + if (useMaterials) { + c8 name[WORD_BUFFER_LENGTH]; + bufPtr = goAndCopyNextWord(name, bufPtr, WORD_BUFFER_LENGTH, bufEnd); +#ifdef _IRR_DEBUG_OBJ_LOADER_ + os::Printer::log("Ignoring material file", name); +#endif + } + } break; + + case 'v': // v, vn, vt + switch (bufPtr[1]) { + case ' ': // vertex + { + core::vector3df vec; + bufPtr = readVec3(bufPtr, vec, bufEnd); + vertexBuffer.push_back(vec); + } break; + + case 'n': // normal + { + core::vector3df vec; + bufPtr = readVec3(bufPtr, vec, bufEnd); + normalsBuffer.push_back(vec); + } break; + + case 't': // texcoord + { + core::vector2df vec; + bufPtr = readUV(bufPtr, vec, bufEnd); + textureCoordBuffer.push_back(vec); + } break; + } + break; + + case 'g': // group name + { + c8 grp[WORD_BUFFER_LENGTH]; + bufPtr = goAndCopyNextWord(grp, bufPtr, WORD_BUFFER_LENGTH, bufEnd); +#ifdef _IRR_DEBUG_OBJ_LOADER_ + os::Printer::log("Loaded group start", grp, ELL_DEBUG); +#endif + if (useGroups) { + if (0 != grp[0]) + grpName = grp; + else + grpName = "default"; + } + mtlChanged = true; + } break; + + case 's': // smoothing can be a group or off (equiv. to 0) + { + c8 smooth[WORD_BUFFER_LENGTH]; + bufPtr = goAndCopyNextWord(smooth, bufPtr, WORD_BUFFER_LENGTH, bufEnd); +#ifdef _IRR_DEBUG_OBJ_LOADER_ + os::Printer::log("Loaded smoothing group start", smooth, ELL_DEBUG); +#endif + if (TAG_OFF == smooth) + smoothingGroup = 0; + else + smoothingGroup = core::strtoul10(smooth); + + (void)smoothingGroup; // disable unused variable warnings + } break; + + case 'u': // usemtl + // get name of material + { + c8 matName[WORD_BUFFER_LENGTH]; + bufPtr = goAndCopyNextWord(matName, bufPtr, WORD_BUFFER_LENGTH, bufEnd); +#ifdef _IRR_DEBUG_OBJ_LOADER_ + os::Printer::log("Loaded material start", matName, ELL_DEBUG); +#endif + mtlName = matName; + mtlChanged = true; + } + break; + + case 'f': // face + { + c8 vertexWord[WORD_BUFFER_LENGTH]; // for retrieving vertex data + video::S3DVertex v; + // Assign vertex color from currently active material's diffuse color + if (mtlChanged) { + // retrieve the material + SObjMtl *useMtl = findMtl(mtlName, grpName); + // only change material if we found it + if (useMtl) + currMtl = useMtl; + mtlChanged = false; + } + if (currMtl) + v.Color = currMtl->Meshbuffer->Material.DiffuseColor; + + // get all vertices data in this face (current line of obj file) + const core::stringc wordBuffer = copyLine(bufPtr, bufEnd); + const c8 *linePtr = wordBuffer.c_str(); + const c8 *const endPtr = linePtr + wordBuffer.size(); + + faceCorners.set_used(0); // fast clear + + // read in all vertices + linePtr = goNextWord(linePtr, endPtr); + while (0 != linePtr[0]) { + // Array to communicate with retrieveVertexIndices() + // sends the buffer sizes and gets the actual indices + // if index not set returns -1 + s32 Idx[3]; + Idx[0] = Idx[1] = Idx[2] = -1; + + // read in next vertex's data + u32 wlength = copyWord(vertexWord, linePtr, WORD_BUFFER_LENGTH, endPtr); + // this function will also convert obj's 1-based index to c++'s 0-based index + retrieveVertexIndices(vertexWord, Idx, vertexWord + wlength + 1, vertexBuffer.size(), textureCoordBuffer.size(), normalsBuffer.size()); + if (Idx[0] >= 0 && Idx[0] < (irr::s32)vertexBuffer.size()) + v.Pos = vertexBuffer[Idx[0]]; + else { + os::Printer::log("Invalid vertex index in this line", wordBuffer.c_str(), ELL_ERROR); + delete[] buf; + cleanUp(); + return 0; + } + if (Idx[1] >= 0 && Idx[1] < (irr::s32)textureCoordBuffer.size()) + v.TCoords = textureCoordBuffer[Idx[1]]; + else + v.TCoords.set(0.0f, 0.0f); + if (Idx[2] >= 0 && Idx[2] < (irr::s32)normalsBuffer.size()) + v.Normal = normalsBuffer[Idx[2]]; + else { + v.Normal.set(0.0f, 0.0f, 0.0f); + currMtl->RecalculateNormals = true; + } + + int vertLocation; + auto n = currMtl->VertMap.find(v); + if (n != currMtl->VertMap.end()) { + vertLocation = n->second; + } else { + currMtl->Meshbuffer->Vertices.push_back(v); + vertLocation = currMtl->Meshbuffer->Vertices.size() - 1; + currMtl->VertMap.emplace(v, vertLocation); + } + + faceCorners.push_back(vertLocation); + + // go to next vertex + linePtr = goNextWord(linePtr, endPtr); + } + + if (faceCorners.size() < 3) { + os::Printer::log("Too few vertices in this line", wordBuffer.c_str(), ELL_ERROR); + delete[] buf; + cleanUp(); + return 0; + } + + // triangulate the face + const int c = faceCorners[0]; + for (u32 i = 1; i < faceCorners.size() - 1; ++i) { + // Add a triangle + const int a = faceCorners[i + 1]; + const int b = faceCorners[i]; + if (a != b && a != c && b != c) { // ignore degenerated faces. We can get them when we merge vertices above in the VertMap. + currMtl->Meshbuffer->Indices.push_back(a); + currMtl->Meshbuffer->Indices.push_back(b); + currMtl->Meshbuffer->Indices.push_back(c); + } else { + ++degeneratedFaces; + } + } + } break; + + case '#': // comment + default: + break; + } // end switch(bufPtr[0]) + // eat up rest of line + bufPtr = goNextLine(bufPtr, bufEnd); + ++lineNr; + } // end while(bufPtr && (bufPtr-buf 0) { + irr::core::stringc log(degeneratedFaces); + log += " degenerated faces removed in "; + log += irr::core::stringc(fullName); + os::Printer::log(log.c_str(), ELL_INFORMATION); + } + + SMesh *mesh = new SMesh(); + + // Combine all the groups (meshbuffers) into the mesh + for (u32 m = 0; m < Materials.size(); ++m) { + if (Materials[m]->Meshbuffer->getIndexCount() > 0) { + Materials[m]->Meshbuffer->recalculateBoundingBox(); + if (Materials[m]->RecalculateNormals) + SceneManager->getMeshManipulator()->recalculateNormals(Materials[m]->Meshbuffer); + mesh->addMeshBuffer(Materials[m]->Meshbuffer); + } + } + + // Create the Animated mesh if there's anything in the mesh + SAnimatedMesh *animMesh = 0; + if (0 != mesh->getMeshBufferCount()) { + mesh->recalculateBoundingBox(); + animMesh = new SAnimatedMesh(); + animMesh->Type = EAMT_OBJ; + animMesh->addMesh(mesh); + animMesh->recalculateBoundingBox(); + } + + // Clean up the allocate obj file contents + delete[] buf; + // more cleaning up + cleanUp(); + mesh->drop(); + + return animMesh; +} + +//! Read RGB color +const c8 *COBJMeshFileLoader::readColor(const c8 *bufPtr, video::SColor &color, const c8 *const bufEnd) +{ + const u32 COLOR_BUFFER_LENGTH = 16; + c8 colStr[COLOR_BUFFER_LENGTH]; + + bufPtr = goAndCopyNextWord(colStr, bufPtr, COLOR_BUFFER_LENGTH, bufEnd); + color.setRed((u32)core::round32(core::fast_atof(colStr) * 255.f)); + bufPtr = goAndCopyNextWord(colStr, bufPtr, COLOR_BUFFER_LENGTH, bufEnd); + color.setGreen((u32)core::round32(core::fast_atof(colStr) * 255.f)); + bufPtr = goAndCopyNextWord(colStr, bufPtr, COLOR_BUFFER_LENGTH, bufEnd); + color.setBlue((u32)core::round32(core::fast_atof(colStr) * 255.f)); + return bufPtr; +} + +//! Read 3d vector of floats +const c8 *COBJMeshFileLoader::readVec3(const c8 *bufPtr, core::vector3df &vec, const c8 *const bufEnd) +{ + const u32 WORD_BUFFER_LENGTH = 256; + c8 wordBuffer[WORD_BUFFER_LENGTH]; + + bufPtr = goAndCopyNextWord(wordBuffer, bufPtr, WORD_BUFFER_LENGTH, bufEnd); + vec.X = -core::fast_atof(wordBuffer); // change handedness + bufPtr = goAndCopyNextWord(wordBuffer, bufPtr, WORD_BUFFER_LENGTH, bufEnd); + vec.Y = core::fast_atof(wordBuffer); + bufPtr = goAndCopyNextWord(wordBuffer, bufPtr, WORD_BUFFER_LENGTH, bufEnd); + vec.Z = core::fast_atof(wordBuffer); + return bufPtr; +} + +//! Read 2d vector of floats +const c8 *COBJMeshFileLoader::readUV(const c8 *bufPtr, core::vector2df &vec, const c8 *const bufEnd) +{ + const u32 WORD_BUFFER_LENGTH = 256; + c8 wordBuffer[WORD_BUFFER_LENGTH]; + + bufPtr = goAndCopyNextWord(wordBuffer, bufPtr, WORD_BUFFER_LENGTH, bufEnd); + vec.X = core::fast_atof(wordBuffer); + bufPtr = goAndCopyNextWord(wordBuffer, bufPtr, WORD_BUFFER_LENGTH, bufEnd); + vec.Y = 1 - core::fast_atof(wordBuffer); // change handedness + return bufPtr; +} + +//! Read boolean value represented as 'on' or 'off' +const c8 *COBJMeshFileLoader::readBool(const c8 *bufPtr, bool &tf, const c8 *const bufEnd) +{ + const u32 BUFFER_LENGTH = 8; + c8 tfStr[BUFFER_LENGTH]; + + bufPtr = goAndCopyNextWord(tfStr, bufPtr, BUFFER_LENGTH, bufEnd); + tf = strcmp(tfStr, "off") != 0; + return bufPtr; +} + +COBJMeshFileLoader::SObjMtl *COBJMeshFileLoader::findMtl(const core::stringc &mtlName, const core::stringc &grpName) +{ + COBJMeshFileLoader::SObjMtl *defMaterial = 0; + // search existing Materials for best match + // exact match does return immediately, only name match means a new group + for (u32 i = 0; i < Materials.size(); ++i) { + if (Materials[i]->Name == mtlName) { + if (Materials[i]->Group == grpName) + return Materials[i]; + else + defMaterial = Materials[i]; + } + } + // we found a partial match + if (defMaterial) { + Materials.push_back(new SObjMtl(*defMaterial)); + Materials.getLast()->Group = grpName; + return Materials.getLast(); + } + // we found a new group for a non-existent material + else if (grpName.size()) { + Materials.push_back(new SObjMtl(*Materials[0])); + Materials.getLast()->Group = grpName; + return Materials.getLast(); + } + return 0; +} + +//! skip space characters and stop on first non-space +const c8 *COBJMeshFileLoader::goFirstWord(const c8 *buf, const c8 *const bufEnd, bool acrossNewlines) +{ + // skip space characters + if (acrossNewlines) + while ((buf != bufEnd) && core::isspace(*buf)) + ++buf; + else + while ((buf != bufEnd) && core::isspace(*buf) && (*buf != '\n')) + ++buf; + + return buf; +} + +//! skip current word and stop at beginning of next one +const c8 *COBJMeshFileLoader::goNextWord(const c8 *buf, const c8 *const bufEnd, bool acrossNewlines) +{ + // skip current word + while ((buf != bufEnd) && !core::isspace(*buf)) + ++buf; + + return goFirstWord(buf, bufEnd, acrossNewlines); +} + +//! Read until line break is reached and stop at the next non-space character +const c8 *COBJMeshFileLoader::goNextLine(const c8 *buf, const c8 *const bufEnd) +{ + // look for newline characters + while (buf != bufEnd) { + // found it, so leave + if (*buf == '\n' || *buf == '\r') + break; + ++buf; + } + return goFirstWord(buf, bufEnd); +} + +u32 COBJMeshFileLoader::copyWord(c8 *outBuf, const c8 *const inBuf, u32 outBufLength, const c8 *const bufEnd) +{ + if (!outBufLength) + return 0; + if (!inBuf) { + *outBuf = 0; + return 0; + } + + u32 i = 0; + while (inBuf[i]) { + if (core::isspace(inBuf[i]) || &(inBuf[i]) == bufEnd) + break; + ++i; + } + + u32 length = core::min_(i, outBufLength - 1); + for (u32 j = 0; j < length; ++j) + outBuf[j] = inBuf[j]; + + outBuf[length] = 0; + return length; +} + +core::stringc COBJMeshFileLoader::copyLine(const c8 *inBuf, const c8 *bufEnd) +{ + if (!inBuf) + return core::stringc(); + + const c8 *ptr = inBuf; + while (ptr < bufEnd) { + if (*ptr == '\n' || *ptr == '\r') + break; + ++ptr; + } + // we must avoid the +1 in case the array is used up + return core::stringc(inBuf, (u32)(ptr - inBuf + ((ptr < bufEnd) ? 1 : 0))); +} + +const c8 *COBJMeshFileLoader::goAndCopyNextWord(c8 *outBuf, const c8 *inBuf, u32 outBufLength, const c8 *bufEnd) +{ + inBuf = goNextWord(inBuf, bufEnd, false); + copyWord(outBuf, inBuf, outBufLength, bufEnd); + return inBuf; +} + +bool COBJMeshFileLoader::retrieveVertexIndices(c8 *vertexData, s32 *idx, const c8 *bufEnd, u32 vbsize, u32 vtsize, u32 vnsize) +{ + const u32 BUFFER_LENGTH = 16; + c8 word[BUFFER_LENGTH]; + const c8 *p = goFirstWord(vertexData, bufEnd); + u32 idxType = 0; // 0 = posIdx, 1 = texcoordIdx, 2 = normalIdx + + u32 i = 0; + while (p != bufEnd) { + if (i >= BUFFER_LENGTH) { + return false; + } + if ((core::isdigit(*p)) || (*p == '-')) { + // build up the number + word[i++] = *p; + } else if (*p == '/' || *p == ' ' || *p == '\0') { + // number is completed. Convert and store it + word[i] = '\0'; + // if no number was found index will become 0 and later on -1 by decrement + idx[idxType] = core::strtol10(word); + if (idx[idxType] < 0) { + switch (idxType) { + case 0: + idx[idxType] += vbsize; + break; + case 1: + idx[idxType] += vtsize; + break; + case 2: + idx[idxType] += vnsize; + break; + } + } else + idx[idxType] -= 1; + + // reset the word + word[0] = '\0'; + i = 0; + + // go to the next kind of index type + if (*p == '/') { + if (++idxType > 2) { + // error checking, shouldn't reach here unless file is wrong + idxType = 0; + } + } else { + // set all missing values to disable (=-1) + while (++idxType < 3) + idx[idxType] = -1; + ++p; + break; // while + } + } + + // go to the next char + ++p; + } + + return true; +} + +void COBJMeshFileLoader::cleanUp() +{ + for (u32 i = 0; i < Materials.size(); ++i) { + Materials[i]->Meshbuffer->drop(); + delete Materials[i]; + } + + Materials.clear(); +} + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/COBJMeshFileLoader.h b/irr/src/COBJMeshFileLoader.h new file mode 100644 index 000000000..63e768e4f --- /dev/null +++ b/irr/src/COBJMeshFileLoader.h @@ -0,0 +1,109 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include +#include "IMeshLoader.h" +#include "ISceneManager.h" +#include "irrString.h" +#include "SMeshBuffer.h" + +namespace irr +{ +namespace scene +{ + +//! Meshloader capable of loading obj meshes. +class COBJMeshFileLoader : public IMeshLoader +{ +public: + //! Constructor + COBJMeshFileLoader(scene::ISceneManager *smgr); + + //! destructor + virtual ~COBJMeshFileLoader(); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".obj") + bool isALoadableFileExtension(const io::path &filename) const override; + + //! creates/loads an animated mesh from the file. + //! \return Pointer to the created mesh. Returns 0 if loading failed. + //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). + //! See IReferenceCounted::drop() for more information. + IAnimatedMesh *createMesh(io::IReadFile *file) override; + +private: + struct SObjMtl + { + SObjMtl() : + Meshbuffer(0), Bumpiness(1.0f), Illumination(0), + RecalculateNormals(false) + { + Meshbuffer = new SMeshBuffer(); + Meshbuffer->Material.Shininess = 0.0f; + Meshbuffer->Material.AmbientColor = video::SColorf(0.2f, 0.2f, 0.2f, 1.0f).toSColor(); + Meshbuffer->Material.DiffuseColor = video::SColorf(0.8f, 0.8f, 0.8f, 1.0f).toSColor(); + Meshbuffer->Material.SpecularColor = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f).toSColor(); + } + + SObjMtl(const SObjMtl &o) : + Name(o.Name), Group(o.Group), + Bumpiness(o.Bumpiness), Illumination(o.Illumination), + RecalculateNormals(false) + { + Meshbuffer = new SMeshBuffer(); + Meshbuffer->Material = o.Meshbuffer->Material; + } + + std::map VertMap; + scene::SMeshBuffer *Meshbuffer; + core::stringc Name; + core::stringc Group; + f32 Bumpiness; + c8 Illumination; + bool RecalculateNormals; + }; + + // returns a pointer to the first printable character available in the buffer + const c8 *goFirstWord(const c8 *buf, const c8 *const bufEnd, bool acrossNewlines = true); + // returns a pointer to the first printable character after the first non-printable + const c8 *goNextWord(const c8 *buf, const c8 *const bufEnd, bool acrossNewlines = true); + // returns a pointer to the next printable character after the first line break + const c8 *goNextLine(const c8 *buf, const c8 *const bufEnd); + // copies the current word from the inBuf to the outBuf + u32 copyWord(c8 *outBuf, const c8 *inBuf, u32 outBufLength, const c8 *const pBufEnd); + // copies the current line from the inBuf to the outBuf + core::stringc copyLine(const c8 *inBuf, const c8 *const bufEnd); + + // combination of goNextWord followed by copyWord + const c8 *goAndCopyNextWord(c8 *outBuf, const c8 *inBuf, u32 outBufLength, const c8 *const pBufEnd); + + //! Find and return the material with the given name + SObjMtl *findMtl(const core::stringc &mtlName, const core::stringc &grpName); + + //! Read RGB color + const c8 *readColor(const c8 *bufPtr, video::SColor &color, const c8 *const pBufEnd); + //! Read 3d vector of floats + const c8 *readVec3(const c8 *bufPtr, core::vector3df &vec, const c8 *const pBufEnd); + //! Read 2d vector of floats + const c8 *readUV(const c8 *bufPtr, core::vector2df &vec, const c8 *const pBufEnd); + //! Read boolean value represented as 'on' or 'off' + const c8 *readBool(const c8 *bufPtr, bool &tf, const c8 *const bufEnd); + + // reads and convert to integer the vertex indices in a line of obj file's face statement + // -1 for the index if it doesn't exist + // indices are changed to 0-based index instead of 1-based from the obj file + bool retrieveVertexIndices(c8 *vertexData, s32 *idx, const c8 *bufEnd, u32 vbsize, u32 vtsize, u32 vnsize); + + void cleanUp(); + + scene::ISceneManager *SceneManager; + + core::array Materials; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/COGLESCommon.h b/irr/src/COGLESCommon.h new file mode 100644 index 000000000..24c96d14a --- /dev/null +++ b/irr/src/COGLESCommon.h @@ -0,0 +1,119 @@ +// Copyright (C) 2015 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#ifdef _IRR_COMPILE_WITH_OGLES1_ + +#if defined(_IRR_COMPILE_WITH_IOS_DEVICE_) +#include +#include +#elif defined(_IRR_OGLES1_USE_KHRONOS_API_HEADERS_) +#include +#include +typedef char GLchar; +#else // or only when defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_) ? +#include +#include +#include +#endif + +#ifndef GL_BGRA +#define GL_BGRA 0x80E1; +#endif + +// Blending definitions. + +#if defined(GL_OES_blend_subtract) +#define GL_FUNC_ADD GL_FUNC_ADD_OES +#else +#define GL_FUNC_ADD 0 +#endif + +// FBO definitions. + +#ifdef GL_OES_framebuffer_object +#define GL_NONE 0 // iOS has missing definition of GL_NONE_OES +#define GL_FRAMEBUFFER GL_FRAMEBUFFER_OES +#define GL_DEPTH_COMPONENT16 GL_DEPTH_COMPONENT16_OES +#define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_OES +#define GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_OES +#define GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_OES +#define GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 1 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 2 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES +#define GL_FRAMEBUFFER_UNSUPPORTED GL_FRAMEBUFFER_UNSUPPORTED_OES +#else +#define GL_NONE 0 +#define GL_FRAMEBUFFER 0 +#define GL_DEPTH_COMPONENT16 0 +#define GL_COLOR_ATTACHMENT0 0 +#define GL_DEPTH_ATTACHMENT 0 +#define GL_STENCIL_ATTACHMENT 0 +#define GL_FRAMEBUFFER_COMPLETE 0 +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 1 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 2 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 3 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS 4 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 5 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 6 +#define GL_FRAMEBUFFER_UNSUPPORTED 7 +#endif + +#define GL_DEPTH_COMPONENT 0x1902 + +// Texture definitions. + +#ifdef GL_OES_texture_cube_map +#define GL_TEXTURE_CUBE_MAP GL_TEXTURE_CUBE_MAP_OES +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES +#else +#define GL_TEXTURE_CUBE_MAP 0 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0 +#endif + +// to check if this header is in the current compile unit (different GL implementation used different "GLCommon" headers in Irrlicht +#define IRR_COMPILE_GLES_COMMON + +namespace irr +{ +namespace video +{ + +// Forward declarations. + +class COpenGLCoreFeature; + +template +class COpenGLCoreTexture; + +template +class COpenGLCoreRenderTarget; + +template +class COpenGLCoreCacheHandler; + +class COGLES1Driver; +typedef COpenGLCoreTexture COGLES1Texture; +typedef COpenGLCoreRenderTarget COGLES1RenderTarget; +typedef COpenGLCoreCacheHandler COGLES1CacheHandler; + +} +} + +#endif diff --git a/irr/src/COGLESCoreExtensionHandler.h b/irr/src/COGLESCoreExtensionHandler.h new file mode 100644 index 000000000..4c691aaf9 --- /dev/null +++ b/irr/src/COGLESCoreExtensionHandler.h @@ -0,0 +1,189 @@ +// Copyright (C) 2017 Michael Zeilfelder +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#pragma once + +// Can be included from different ES versions +// (this is also the reason why this file is header-only as correct OGL ES headers have to be included first) + +#include "irrMath.h" +#include "COpenGLCoreFeature.h" + +namespace irr +{ +namespace video +{ + +class COGLESCoreExtensionHandler +{ +public: + // Enums used internally to check for ES extensions quickly. + // We buffer all extensions on start once in an array. + // All OpenGL ES versions share the same extensions (WebGL adds it's own extensions on top of ES2) + enum EOGLESFeatures + { + // If you update this enum also update the corresponding OGLESFeatureStrings string-array + IRR_GL_APPLE_texture_2D_limited_npot, + IRR_GL_APPLE_texture_format_BGRA8888, + IRR_GL_EXT_blend_minmax, + IRR_GL_EXT_read_format_bgra, + IRR_GL_EXT_texture_filter_anisotropic, + IRR_GL_EXT_texture_format_BGRA8888, + IRR_GL_EXT_texture_lod_bias, + IRR_GL_EXT_texture_rg, + IRR_GL_IMG_read_format, + IRR_GL_IMG_texture_format_BGRA8888, + IRR_GL_IMG_user_clip_plane, + IRR_GL_OES_blend_func_separate, + IRR_GL_OES_blend_subtract, + IRR_GL_OES_depth_texture, + IRR_GL_OES_depth24, + IRR_GL_OES_depth32, + IRR_GL_OES_element_index_uint, + IRR_GL_OES_framebuffer_object, + IRR_GL_OES_packed_depth_stencil, + IRR_GL_OES_point_size_array, + IRR_GL_OES_point_sprite, + IRR_GL_OES_read_format, + IRR_GL_OES_stencil_wrap, + IRR_GL_OES_texture_float, + IRR_GL_OES_texture_half_float, + IRR_GL_OES_texture_mirrored_repeat, + IRR_GL_OES_texture_npot, + + IRR_OGLES_Feature_Count + }; + + COGLESCoreExtensionHandler() : + Version(0), MaxAnisotropy(1), MaxIndices(0xffff), + MaxTextureSize(1), MaxTextureLODBias(0.f), StencilBuffer(false) + { + for (u32 i = 0; i < IRR_OGLES_Feature_Count; ++i) + FeatureAvailable[i] = false; + + DimAliasedLine[0] = 1.f; + DimAliasedLine[1] = 1.f; + DimAliasedPoint[0] = 1.f; + DimAliasedPoint[1] = 1.f; + } + + virtual ~COGLESCoreExtensionHandler() {} + + const COpenGLCoreFeature &getFeature() const + { + return Feature; + } + + void dump() const + { + for (u32 i = 0; i < IRR_OGLES_Feature_Count; ++i) + os::Printer::log(getFeatureString(i), FeatureAvailable[i] ? " true" : " false"); + } + + bool queryGLESFeature(EOGLESFeatures feature) const + { + return FeatureAvailable[feature]; + } + +protected: + const char *getFeatureString(size_t index) const + { + // One for each EOGLESFeatures + static const char *const OGLESFeatureStrings[IRR_OGLES_Feature_Count] = { + "GL_APPLE_texture_2D_limited_npot", + "GL_APPLE_texture_format_BGRA8888", + "GL_EXT_blend_minmax", + "GL_EXT_read_format_bgra", + "GL_EXT_texture_filter_anisotropic", + "GL_EXT_texture_format_BGRA8888", + "GL_EXT_texture_lod_bias", + "GL_EXT_texture_rg", + "GL_IMG_read_format", + "GL_IMG_texture_format_BGRA8888", + "GL_IMG_user_clip_plane", + "GL_OES_blend_func_separate", + "GL_OES_blend_subtract", + "GL_OES_depth_texture", + "GL_OES_depth24", + "GL_OES_depth32", + "GL_OES_element_index_uint", + "GL_OES_framebuffer_object", + "GL_OES_packed_depth_stencil", + "GL_OES_point_size_array", + "GL_OES_point_sprite", + "GL_OES_read_format", + "GL_OES_stencil_wrap", + "GL_OES_texture_float", + "GL_OES_texture_half_float", + "GL_OES_texture_mirrored_repeat", + "GL_OES_texture_npot", + }; + + return OGLESFeatureStrings[index]; + } + + void getGLVersion() + { + Version = 0; + s32 multiplier = 100; + + core::stringc version(glGetString(GL_VERSION)); + + for (u32 i = 0; i < version.size(); ++i) { + if (version[i] >= '0' && version[i] <= '9') { + if (multiplier > 1) { + Version += static_cast(core::floor32(atof(&(version[i]))) * multiplier); + multiplier /= 10; + } else { + break; + } + } + } + } + + void getGLExtensions() + { + core::stringc extensions = glGetString(GL_EXTENSIONS); + os::Printer::log(extensions.c_str()); + + const u32 size = extensions.size() + 1; + c8 *str = new c8[size]; + strncpy(str, extensions.c_str(), extensions.size()); + str[extensions.size()] = ' '; + c8 *p = str; + + for (u32 i = 0; i < size; ++i) { + if (str[i] == ' ') { + str[i] = 0; + if (*p) + for (size_t j = 0; j < IRR_OGLES_Feature_Count; ++j) { + if (!strcmp(getFeatureString(j), p)) { + FeatureAvailable[j] = true; + break; + } + } + + p = p + strlen(p) + 1; + } + } + + delete[] str; + } + + COpenGLCoreFeature Feature; + + u16 Version; + u8 MaxAnisotropy; + u32 MaxIndices; + u32 MaxTextureSize; + f32 MaxTextureLODBias; + //! Minimal and maximal supported thickness for lines without smoothing + float DimAliasedLine[2]; + //! Minimal and maximal supported thickness for points without smoothing + float DimAliasedPoint[2]; + bool StencilBuffer; + bool FeatureAvailable[IRR_OGLES_Feature_Count]; +}; +} +} diff --git a/irr/src/COGLESDriver.cpp b/irr/src/COGLESDriver.cpp new file mode 100644 index 000000000..2cd8430f2 --- /dev/null +++ b/irr/src/COGLESDriver.cpp @@ -0,0 +1,2403 @@ +// Copyright (C) 2002-2008 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "COGLESDriver.h" +#include +#include "CNullDriver.h" +#include "IContextManager.h" + +#ifdef _IRR_COMPILE_WITH_OGLES1_ + +#include "COpenGLCoreTexture.h" +#include "COpenGLCoreRenderTarget.h" +#include "COpenGLCoreCacheHandler.h" + +#include "COGLESMaterialRenderer.h" + +#include "EVertexAttributes.h" +#include "CImage.h" +#include "os.h" + +#ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_ +#include "android_native_app_glue.h" +#endif + +namespace irr +{ +namespace video +{ + +COGLES1Driver::COGLES1Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager) : + CNullDriver(io, params.WindowSize), COGLES1ExtensionHandler(), CacheHandler(0), CurrentRenderMode(ERM_NONE), + ResetRenderStates(true), Transformation3DChanged(true), AntiAlias(params.AntiAlias), + ColorFormat(ECF_R8G8B8), Params(params), ContextManager(contextManager) +{ +#ifdef _DEBUG + setDebugName("COGLESDriver"); +#endif + + core::dimension2d windowSize(0, 0); + + if (!ContextManager) + return; + + ContextManager->grab(); + ContextManager->generateSurface(); + ContextManager->generateContext(); + ExposedData = ContextManager->getContext(); + ContextManager->activateContext(ExposedData, false); + + windowSize = params.WindowSize; + + genericDriverInit(windowSize, params.Stencilbuffer); +} + +COGLES1Driver::~COGLES1Driver() +{ + deleteMaterialRenders(); + + CacheHandler->getTextureCache().clear(); + + removeAllRenderTargets(); + deleteAllTextures(); + removeAllOcclusionQueries(); + removeAllHardwareBuffers(); + + delete CacheHandler; + + if (ContextManager) { + ContextManager->destroyContext(); + ContextManager->destroySurface(); + ContextManager->terminate(); + ContextManager->drop(); + } +} + +// ----------------------------------------------------------------------- +// METHODS +// ----------------------------------------------------------------------- + +bool COGLES1Driver::genericDriverInit(const core::dimension2d &screenSize, bool stencilBuffer) +{ + Name = glGetString(GL_VERSION); + printVersion(); + + // print renderer information + VendorName = glGetString(GL_VENDOR); + os::Printer::log(VendorName.c_str(), ELL_INFORMATION); + + // load extensions + initExtensions(); + + // reset cache handler + delete CacheHandler; + CacheHandler = new COGLES1CacheHandler(this); + + StencilBuffer = stencilBuffer; + + DriverAttributes->setAttribute("MaxTextures", (s32)Feature.MaxTextureUnits); + DriverAttributes->setAttribute("MaxSupportedTextures", (s32)Feature.MaxTextureUnits); + DriverAttributes->setAttribute("MaxAnisotropy", MaxAnisotropy); + DriverAttributes->setAttribute("MaxIndices", (s32)MaxIndices); + DriverAttributes->setAttribute("MaxTextureSize", (s32)MaxTextureSize); + DriverAttributes->setAttribute("MaxTextureLODBias", MaxTextureLODBias); + DriverAttributes->setAttribute("Version", Version); + DriverAttributes->setAttribute("AntiAlias", AntiAlias); + + glPixelStorei(GL_PACK_ALIGNMENT, 1); + + UserClipPlane.reallocate(MaxUserClipPlanes); + UserClipPlaneEnabled.resize(MaxUserClipPlanes); + + for (s32 i = 0; i < MaxUserClipPlanes; ++i) { + UserClipPlane.push_back(core::plane3df()); + UserClipPlaneEnabled[i] = false; + } + + for (s32 i = 0; i < ETS_COUNT; ++i) + setTransform(static_cast(i), core::IdentityMatrix); + + setAmbientLight(SColorf(0.0f, 0.0f, 0.0f, 0.0f)); + glClearDepthf(1.0f); + + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); + glHint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST); + glDepthFunc(GL_LEQUAL); + glFrontFace(GL_CW); + glAlphaFunc(GL_GREATER, 0.f); + + // create material renderers + createMaterialRenderers(); + + // set the renderstates + setRenderStates3DMode(); + + // set fog mode + setFog(FogColor, FogType, FogStart, FogEnd, FogDensity, PixelFog, RangeFog); + + // create matrix for flipping textures + TextureFlipMatrix.buildTextureTransform(0.0f, core::vector2df(0, 0), core::vector2df(0, 1.0f), core::vector2df(1.0f, -1.0f)); + + // We need to reset once more at the beginning of the first rendering. + // This fixes problems with intermediate changes to the material during texture load. + ResetRenderStates = true; + + testGLError(__LINE__); + + return true; +} + +void COGLES1Driver::createMaterialRenderers() +{ + addAndDropMaterialRenderer(new COGLES1MaterialRenderer_SOLID(this)); + addAndDropMaterialRenderer(new COGLES1MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(this)); + addAndDropMaterialRenderer(new COGLES1MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(this)); + addAndDropMaterialRenderer(new COGLES1MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(this)); + addAndDropMaterialRenderer(new COGLES1MaterialRenderer_ONETEXTURE_BLEND(this)); +} + +bool COGLES1Driver::beginScene(u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil, const SExposedVideoData &videoData, core::rect *sourceRect) +{ + CNullDriver::beginScene(clearFlag, clearColor, clearDepth, clearStencil, videoData, sourceRect); + + if (ContextManager) + ContextManager->activateContext(videoData, true); + + clearBuffers(clearFlag, clearColor, clearDepth, clearStencil); + + return true; +} + +bool COGLES1Driver::endScene() +{ + CNullDriver::endScene(); + + glFlush(); + + if (ContextManager) + return ContextManager->swapBuffers(); + + return false; +} + +//! Returns the transformation set by setTransform +const core::matrix4 &COGLES1Driver::getTransform(E_TRANSFORMATION_STATE state) const +{ + return Matrices[state]; +} + +//! sets transformation +void COGLES1Driver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4 &mat) +{ + Matrices[state] = mat; + Transformation3DChanged = true; + + switch (state) { + case ETS_VIEW: + case ETS_WORLD: { + // OGLES1 only has a model matrix, view and world is not existent. so lets fake these two. + glMatrixMode(GL_MODELVIEW); + glLoadMatrixf((Matrices[ETS_VIEW] * Matrices[ETS_WORLD]).pointer()); + // we have to update the clip planes to the latest view matrix + for (u32 i = 0; i < MaxUserClipPlanes; ++i) + if (UserClipPlaneEnabled[i]) + uploadClipPlane(i); + } break; + case ETS_PROJECTION: { + GLfloat glmat[16]; + getGLMatrix(glmat, mat); + // flip z to compensate OGLES1s right-hand coordinate system + glmat[12] *= -1.0f; + glMatrixMode(GL_PROJECTION); + glLoadMatrixf(glmat); + } break; + default: + break; + } +} + +bool COGLES1Driver::updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer) +{ + if (!HWBuffer) + return false; + + const scene::IMeshBuffer *mb = HWBuffer->MeshBuffer; + const void *vertices = mb->getVertices(); + const u32 vertexCount = mb->getVertexCount(); + const E_VERTEX_TYPE vType = mb->getVertexType(); + const u32 vertexSize = getVertexPitchFromType(vType); + + // buffer vertex data, and convert colours... + core::array buffer(vertexSize * vertexCount); + buffer.set_used(vertexSize * vertexCount); + memcpy(buffer.pointer(), vertices, vertexSize * vertexCount); + + // in order to convert the colors into opengl format (RGBA) + switch (vType) { + case EVT_STANDARD: { + S3DVertex *pb = reinterpret_cast(buffer.pointer()); + const S3DVertex *po = static_cast(vertices); + for (u32 i = 0; i < vertexCount; i++) { + po[i].Color.toOpenGLColor((u8 *)&(pb[i].Color.color)); + } + } break; + case EVT_2TCOORDS: { + S3DVertex2TCoords *pb = reinterpret_cast(buffer.pointer()); + const S3DVertex2TCoords *po = static_cast(vertices); + for (u32 i = 0; i < vertexCount; i++) { + po[i].Color.toOpenGLColor((u8 *)&(pb[i].Color.color)); + } + } break; + case EVT_TANGENTS: { + S3DVertexTangents *pb = reinterpret_cast(buffer.pointer()); + const S3DVertexTangents *po = static_cast(vertices); + for (u32 i = 0; i < vertexCount; i++) { + po[i].Color.toOpenGLColor((u8 *)&(pb[i].Color.color)); + } + } break; + default: { + return false; + } + } + + // get or create buffer + bool newBuffer = false; + if (!HWBuffer->vbo_verticesID) { + glGenBuffers(1, &HWBuffer->vbo_verticesID); + if (!HWBuffer->vbo_verticesID) + return false; + newBuffer = true; + } else if (HWBuffer->vbo_verticesSize < vertexCount * vertexSize) { + newBuffer = true; + } + + glBindBuffer(GL_ARRAY_BUFFER, HWBuffer->vbo_verticesID); + + // copy data to graphics card + if (!newBuffer) + glBufferSubData(GL_ARRAY_BUFFER, 0, vertexCount * vertexSize, buffer.const_pointer()); + else { + HWBuffer->vbo_verticesSize = vertexCount * vertexSize; + + if (HWBuffer->Mapped_Vertex == scene::EHM_STATIC) + glBufferData(GL_ARRAY_BUFFER, vertexCount * vertexSize, buffer.const_pointer(), GL_STATIC_DRAW); + else + glBufferData(GL_ARRAY_BUFFER, vertexCount * vertexSize, buffer.const_pointer(), GL_DYNAMIC_DRAW); + } + + glBindBuffer(GL_ARRAY_BUFFER, 0); + + return (!testGLError(__LINE__)); +} + +bool COGLES1Driver::updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer) +{ + if (!HWBuffer) + return false; + + const scene::IMeshBuffer *mb = HWBuffer->MeshBuffer; + + const void *indices = mb->getIndices(); + u32 indexCount = mb->getIndexCount(); + + GLenum indexSize; + switch (mb->getIndexType()) { + case (EIT_16BIT): { + indexSize = sizeof(u16); + break; + } + case (EIT_32BIT): { + indexSize = sizeof(u32); + break; + } + default: { + return false; + } + } + + // get or create buffer + bool newBuffer = false; + if (!HWBuffer->vbo_indicesID) { + glGenBuffers(1, &HWBuffer->vbo_indicesID); + if (!HWBuffer->vbo_indicesID) + return false; + newBuffer = true; + } else if (HWBuffer->vbo_indicesSize < indexCount * indexSize) { + newBuffer = true; + } + + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, HWBuffer->vbo_indicesID); + + // copy data to graphics card + if (!newBuffer) + glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, indexCount * indexSize, indices); + else { + HWBuffer->vbo_indicesSize = indexCount * indexSize; + + if (HWBuffer->Mapped_Index == scene::EHM_STATIC) + glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, GL_STATIC_DRAW); + else + glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, GL_DYNAMIC_DRAW); + } + + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + + return (!testGLError(__LINE__)); +} + +//! updates hardware buffer if needed +bool COGLES1Driver::updateHardwareBuffer(SHWBufferLink *HWBuffer) +{ + if (!HWBuffer) + return false; + + if (HWBuffer->Mapped_Vertex != scene::EHM_NEVER) { + if (HWBuffer->ChangedID_Vertex != HWBuffer->MeshBuffer->getChangedID_Vertex() || !static_cast(HWBuffer)->vbo_verticesID) { + + HWBuffer->ChangedID_Vertex = HWBuffer->MeshBuffer->getChangedID_Vertex(); + + if (!updateVertexHardwareBuffer(static_cast(HWBuffer))) + return false; + } + } + + if (HWBuffer->Mapped_Index != scene::EHM_NEVER) { + if (HWBuffer->ChangedID_Index != HWBuffer->MeshBuffer->getChangedID_Index() || !((SHWBufferLink_opengl *)HWBuffer)->vbo_indicesID) { + + HWBuffer->ChangedID_Index = HWBuffer->MeshBuffer->getChangedID_Index(); + + if (!updateIndexHardwareBuffer(static_cast(HWBuffer))) + return false; + } + } + + return true; +} + +//! Create hardware buffer from meshbuffer +COGLES1Driver::SHWBufferLink *COGLES1Driver::createHardwareBuffer(const scene::IMeshBuffer *mb) +{ + if (!mb || (mb->getHardwareMappingHint_Index() == scene::EHM_NEVER && mb->getHardwareMappingHint_Vertex() == scene::EHM_NEVER)) + return 0; + + SHWBufferLink_opengl *HWBuffer = new SHWBufferLink_opengl(mb); + + // add to map + HWBuffer->listPosition = HWBufferList.insert(HWBufferList.end(), HWBuffer); + + HWBuffer->ChangedID_Vertex = HWBuffer->MeshBuffer->getChangedID_Vertex(); + HWBuffer->ChangedID_Index = HWBuffer->MeshBuffer->getChangedID_Index(); + HWBuffer->Mapped_Vertex = mb->getHardwareMappingHint_Vertex(); + HWBuffer->Mapped_Index = mb->getHardwareMappingHint_Index(); + HWBuffer->vbo_verticesID = 0; + HWBuffer->vbo_indicesID = 0; + HWBuffer->vbo_verticesSize = 0; + HWBuffer->vbo_indicesSize = 0; + + if (!updateHardwareBuffer(HWBuffer)) { + deleteHardwareBuffer(HWBuffer); + return 0; + } + + return HWBuffer; +} + +void COGLES1Driver::deleteHardwareBuffer(SHWBufferLink *_HWBuffer) +{ + if (!_HWBuffer) + return; + + SHWBufferLink_opengl *HWBuffer = static_cast(_HWBuffer); + if (HWBuffer->vbo_verticesID) { + glDeleteBuffers(1, &HWBuffer->vbo_verticesID); + HWBuffer->vbo_verticesID = 0; + } + if (HWBuffer->vbo_indicesID) { + glDeleteBuffers(1, &HWBuffer->vbo_indicesID); + HWBuffer->vbo_indicesID = 0; + } + + CNullDriver::deleteHardwareBuffer(_HWBuffer); +} + +//! Draw hardware buffer +void COGLES1Driver::drawHardwareBuffer(SHWBufferLink *_HWBuffer) +{ + if (!_HWBuffer) + return; + + SHWBufferLink_opengl *HWBuffer = static_cast(_HWBuffer); + + updateHardwareBuffer(HWBuffer); // check if update is needed + + const scene::IMeshBuffer *mb = HWBuffer->MeshBuffer; + const void *vertices = mb->getVertices(); + const void *indexList = mb->getIndices(); + + if (HWBuffer->Mapped_Vertex != scene::EHM_NEVER) { + glBindBuffer(GL_ARRAY_BUFFER, HWBuffer->vbo_verticesID); + vertices = 0; + } + + if (HWBuffer->Mapped_Index != scene::EHM_NEVER) { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, HWBuffer->vbo_indicesID); + indexList = 0; + } + + drawVertexPrimitiveList(vertices, mb->getVertexCount(), indexList, + mb->getPrimitiveCount(), mb->getVertexType(), + mb->getPrimitiveType(), mb->getIndexType()); + + if (HWBuffer->Mapped_Vertex != scene::EHM_NEVER) + glBindBuffer(GL_ARRAY_BUFFER, 0); + + if (HWBuffer->Mapped_Index != scene::EHM_NEVER) + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); +} + +IRenderTarget *COGLES1Driver::addRenderTarget() +{ + COGLES1RenderTarget *renderTarget = new COGLES1RenderTarget(this); + RenderTargets.push_back(renderTarget); + + return renderTarget; +} + +// small helper function to create vertex buffer object adress offsets +static inline u8 *buffer_offset(const long offset) +{ + return ((u8 *)0 + offset); +} + +//! draws a vertex primitive list +void COGLES1Driver::drawVertexPrimitiveList(const void *vertices, u32 vertexCount, + const void *indexList, u32 primitiveCount, + E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) +{ + if (!checkPrimitiveCount(primitiveCount)) + return; + + setRenderStates3DMode(); + + drawVertexPrimitiveList2d3d(vertices, vertexCount, (const u16 *)indexList, primitiveCount, vType, pType, iType); +} + +void COGLES1Driver::drawVertexPrimitiveList2d3d(const void *vertices, u32 vertexCount, + const void *indexList, u32 primitiveCount, + E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType, bool threed) +{ + if (!primitiveCount || !vertexCount) + return; + + if (!threed && !checkPrimitiveCount(primitiveCount)) + return; + + CNullDriver::drawVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType, iType); + + if (vertices) { + // convert colors to gl color format. + vertexCount *= 4; // reused as color component count + ColorBuffer.set_used(vertexCount); + u32 i; + + switch (vType) { + case EVT_STANDARD: { + const S3DVertex *p = static_cast(vertices); + for (i = 0; i < vertexCount; i += 4) { + p->Color.toOpenGLColor(&ColorBuffer[i]); + ++p; + } + } break; + case EVT_2TCOORDS: { + const S3DVertex2TCoords *p = static_cast(vertices); + for (i = 0; i < vertexCount; i += 4) { + p->Color.toOpenGLColor(&ColorBuffer[i]); + ++p; + } + } break; + case EVT_TANGENTS: { + const S3DVertexTangents *p = static_cast(vertices); + for (i = 0; i < vertexCount; i += 4) { + p->Color.toOpenGLColor(&ColorBuffer[i]); + ++p; + } + } break; + } + } + + // draw everything + glClientActiveTexture(GL_TEXTURE0); + glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_VERTEX_ARRAY); + if ((pType != scene::EPT_POINTS) && (pType != scene::EPT_POINT_SPRITES)) + glEnableClientState(GL_TEXTURE_COORD_ARRAY); +#ifdef GL_OES_point_size_array + else if (FeatureAvailable[COGLESCoreExtensionHandler::IRR_GL_OES_point_size_array] && (Material.Thickness == 0.0f)) + glEnableClientState(GL_POINT_SIZE_ARRAY_OES); +#endif + if (threed && (pType != scene::EPT_POINTS) && (pType != scene::EPT_POINT_SPRITES)) + glEnableClientState(GL_NORMAL_ARRAY); + + if (vertices) + glColorPointer(4, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); + + switch (vType) { + case EVT_STANDARD: + if (vertices) { + if (threed) + glNormalPointer(GL_FLOAT, sizeof(S3DVertex), &(static_cast(vertices))[0].Normal); + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast(vertices))[0].TCoords); + glVertexPointer((threed ? 3 : 2), GL_FLOAT, sizeof(S3DVertex), &(static_cast(vertices))[0].Pos); + } else { + glNormalPointer(GL_FLOAT, sizeof(S3DVertex), buffer_offset(12)); + glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(S3DVertex), buffer_offset(24)); + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), buffer_offset(28)); + glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex), 0); + } + + if (Feature.MaxTextureUnits > 0 && CacheHandler->getTextureCache().get(1)) { + glClientActiveTexture(GL_TEXTURE0 + 1); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + if (vertices) + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast(vertices))[0].TCoords); + else + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), buffer_offset(28)); + } + break; + case EVT_2TCOORDS: + if (vertices) { + if (threed) + glNormalPointer(GL_FLOAT, sizeof(S3DVertex2TCoords), &(static_cast(vertices))[0].Normal); + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &(static_cast(vertices))[0].TCoords); + glVertexPointer((threed ? 3 : 2), GL_FLOAT, sizeof(S3DVertex2TCoords), &(static_cast(vertices))[0].Pos); + } else { + glNormalPointer(GL_FLOAT, sizeof(S3DVertex2TCoords), buffer_offset(12)); + glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(S3DVertex2TCoords), buffer_offset(24)); + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), buffer_offset(28)); + glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex2TCoords), buffer_offset(0)); + } + + if (Feature.MaxTextureUnits > 0) { + glClientActiveTexture(GL_TEXTURE0 + 1); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + if (vertices) + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &(static_cast(vertices))[0].TCoords2); + else + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), buffer_offset(36)); + } + break; + case EVT_TANGENTS: + if (vertices) { + if (threed) + glNormalPointer(GL_FLOAT, sizeof(S3DVertexTangents), &(static_cast(vertices))[0].Normal); + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), &(static_cast(vertices))[0].TCoords); + glVertexPointer((threed ? 3 : 2), GL_FLOAT, sizeof(S3DVertexTangents), &(static_cast(vertices))[0].Pos); + } else { + glNormalPointer(GL_FLOAT, sizeof(S3DVertexTangents), buffer_offset(12)); + glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(S3DVertexTangents), buffer_offset(24)); + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), buffer_offset(28)); + glVertexPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), buffer_offset(0)); + } + + if (Feature.MaxTextureUnits > 0) { + glClientActiveTexture(GL_TEXTURE0 + 1); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + if (vertices) + glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &(static_cast(vertices))[0].Tangent); + else + glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), buffer_offset(36)); + + glClientActiveTexture(GL_TEXTURE0 + 2); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + if (vertices) + glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &(static_cast(vertices))[0].Binormal); + else + glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), buffer_offset(48)); + } + break; + } + + GLenum indexSize = 0; + + switch (iType) { + case (EIT_16BIT): { + indexSize = GL_UNSIGNED_SHORT; + break; + } + case (EIT_32BIT): { +#ifdef GL_OES_element_index_uint +#ifndef GL_UNSIGNED_INT +#define GL_UNSIGNED_INT 0x1405 +#endif + if (FeatureAvailable[COGLESCoreExtensionHandler::IRR_GL_OES_element_index_uint]) + indexSize = GL_UNSIGNED_INT; + else +#endif + indexSize = GL_UNSIGNED_SHORT; + break; + } + } + + switch (pType) { + case scene::EPT_POINTS: + case scene::EPT_POINT_SPRITES: { +#ifdef GL_OES_point_sprite + if (pType == scene::EPT_POINT_SPRITES && FeatureAvailable[COGLESCoreExtensionHandler::IRR_GL_OES_point_sprite]) + glEnable(GL_POINT_SPRITE_OES); +#endif + // if ==0 we use the point size array + if (Material.Thickness != 0.f) { + float quadratic[] = {0.0f, 0.0f, 10.01f}; + glPointParameterfv(GL_POINT_DISTANCE_ATTENUATION, quadratic); + float maxParticleSize = 1.0f; + glGetFloatv(GL_POINT_SIZE_MAX, &maxParticleSize); + // maxParticleSize=maxParticleSize 0) { + if (vType == EVT_TANGENTS) { + glClientActiveTexture(GL_TEXTURE0 + 2); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } + if ((vType != EVT_STANDARD) || CacheHandler->getTextureCache().get(1)) { + glClientActiveTexture(GL_TEXTURE0 + 1); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } + glClientActiveTexture(GL_TEXTURE0); + } + +#ifdef GL_OES_point_size_array + if (FeatureAvailable[COGLESCoreExtensionHandler::IRR_GL_OES_point_size_array] && (Material.Thickness == 0.0f)) + glDisableClientState(GL_POINT_SIZE_ARRAY_OES); +#endif + + glDisableClientState(GL_COLOR_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); +} + +//! draws a 2d image, using a color and the alpha channel of the texture +void COGLES1Driver::draw2DImage(const video::ITexture *texture, + const core::position2d &pos, + const core::rect &sourceRect, + const core::rect *clipRect, SColor color, + bool useAlphaChannelOfTexture) +{ + if (!texture) + return; + + if (!sourceRect.isValid()) + return; + + core::position2d targetPos(pos); + core::position2d sourcePos(sourceRect.UpperLeftCorner); + core::dimension2d sourceSize(sourceRect.getSize()); + if (clipRect) { + if (targetPos.X < clipRect->UpperLeftCorner.X) { + sourceSize.Width += targetPos.X - clipRect->UpperLeftCorner.X; + if (sourceSize.Width <= 0) + return; + + sourcePos.X -= targetPos.X - clipRect->UpperLeftCorner.X; + targetPos.X = clipRect->UpperLeftCorner.X; + } + + if (targetPos.X + sourceSize.Width > clipRect->LowerRightCorner.X) { + sourceSize.Width -= (targetPos.X + sourceSize.Width) - clipRect->LowerRightCorner.X; + if (sourceSize.Width <= 0) + return; + } + + if (targetPos.Y < clipRect->UpperLeftCorner.Y) { + sourceSize.Height += targetPos.Y - clipRect->UpperLeftCorner.Y; + if (sourceSize.Height <= 0) + return; + + sourcePos.Y -= targetPos.Y - clipRect->UpperLeftCorner.Y; + targetPos.Y = clipRect->UpperLeftCorner.Y; + } + + if (targetPos.Y + sourceSize.Height > clipRect->LowerRightCorner.Y) { + sourceSize.Height -= (targetPos.Y + sourceSize.Height) - clipRect->LowerRightCorner.Y; + if (sourceSize.Height <= 0) + return; + } + } + + // clip these coordinates + + if (targetPos.X < 0) { + sourceSize.Width += targetPos.X; + if (sourceSize.Width <= 0) + return; + + sourcePos.X -= targetPos.X; + targetPos.X = 0; + } + + const core::dimension2d &renderTargetSize = getCurrentRenderTargetSize(); + + if (targetPos.X + sourceSize.Width > (s32)renderTargetSize.Width) { + sourceSize.Width -= (targetPos.X + sourceSize.Width) - renderTargetSize.Width; + if (sourceSize.Width <= 0) + return; + } + + if (targetPos.Y < 0) { + sourceSize.Height += targetPos.Y; + if (sourceSize.Height <= 0) + return; + + sourcePos.Y -= targetPos.Y; + targetPos.Y = 0; + } + + if (targetPos.Y + sourceSize.Height > (s32)renderTargetSize.Height) { + sourceSize.Height -= (targetPos.Y + sourceSize.Height) - renderTargetSize.Height; + if (sourceSize.Height <= 0) + return; + } + + // ok, we've clipped everything. + // now draw it. + + // texcoords need to be flipped horizontally for RTTs + const bool isRTT = texture->isRenderTarget(); + const core::dimension2d &ss = texture->getOriginalSize(); + const f32 invW = 1.f / static_cast(ss.Width); + const f32 invH = 1.f / static_cast(ss.Height); + const core::rect tcoords( + sourcePos.X * invW, + (isRTT ? (sourcePos.Y + sourceSize.Height) : sourcePos.Y) * invH, + (sourcePos.X + sourceSize.Width) * invW, + (isRTT ? sourcePos.Y : (sourcePos.Y + sourceSize.Height)) * invH); + + const core::rect poss(targetPos, sourceSize); + + if (!CacheHandler->getTextureCache().set(0, texture)) + return; + + setRenderStates2DMode(color.getAlpha() < 255, true, useAlphaChannelOfTexture); + + u16 indices[] = {0, 1, 2, 3}; + S3DVertex vertices[4]; + vertices[0] = S3DVertex((f32)poss.UpperLeftCorner.X, (f32)poss.UpperLeftCorner.Y, 0, 0, 0, 1, color, tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); + vertices[1] = S3DVertex((f32)poss.LowerRightCorner.X, (f32)poss.UpperLeftCorner.Y, 0, 0, 0, 1, color, tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); + vertices[2] = S3DVertex((f32)poss.LowerRightCorner.X, (f32)poss.LowerRightCorner.Y, 0, 0, 0, 1, color, tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); + vertices[3] = S3DVertex((f32)poss.UpperLeftCorner.X, (f32)poss.LowerRightCorner.Y, 0, 0, 0, 1, color, tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); + drawVertexPrimitiveList2d3d(vertices, 4, indices, 2, video::EVT_STANDARD, scene::EPT_TRIANGLE_FAN, EIT_16BIT, false); +} + +//! The same, but with a four element array of colors, one for each vertex +void COGLES1Driver::draw2DImage(const video::ITexture *texture, const core::rect &destRect, + const core::rect &sourceRect, const core::rect *clipRect, + const video::SColor *const colors, bool useAlphaChannelOfTexture) +{ + if (!texture) + return; + + // texcoords need to be flipped horizontally for RTTs + const bool isRTT = texture->isRenderTarget(); + const core::dimension2du &ss = texture->getOriginalSize(); + const f32 invW = 1.f / static_cast(ss.Width); + const f32 invH = 1.f / static_cast(ss.Height); + const core::rect tcoords( + sourceRect.UpperLeftCorner.X * invW, + (isRTT ? sourceRect.LowerRightCorner.Y : sourceRect.UpperLeftCorner.Y) * invH, + sourceRect.LowerRightCorner.X * invW, + (isRTT ? sourceRect.UpperLeftCorner.Y : sourceRect.LowerRightCorner.Y) * invH); + + const video::SColor temp[4] = { + 0xFFFFFFFF, + 0xFFFFFFFF, + 0xFFFFFFFF, + 0xFFFFFFFF, + }; + + const video::SColor *const useColor = colors ? colors : temp; + + if (!CacheHandler->getTextureCache().set(0, texture)) + return; + + setRenderStates2DMode(useColor[0].getAlpha() < 255 || useColor[1].getAlpha() < 255 || + useColor[2].getAlpha() < 255 || useColor[3].getAlpha() < 255, + true, useAlphaChannelOfTexture); + + if (clipRect) { + if (!clipRect->isValid()) + return; + + glEnable(GL_SCISSOR_TEST); + const core::dimension2d &renderTargetSize = getCurrentRenderTargetSize(); + glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y, + clipRect->getWidth(), clipRect->getHeight()); + } + + u16 indices[] = {0, 1, 2, 3}; + S3DVertex vertices[4]; + vertices[0] = S3DVertex((f32)destRect.UpperLeftCorner.X, (f32)destRect.UpperLeftCorner.Y, 0, 0, 0, 1, useColor[0], tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); + vertices[1] = S3DVertex((f32)destRect.LowerRightCorner.X, (f32)destRect.UpperLeftCorner.Y, 0, 0, 0, 1, useColor[3], tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); + vertices[2] = S3DVertex((f32)destRect.LowerRightCorner.X, (f32)destRect.LowerRightCorner.Y, 0, 0, 0, 1, useColor[2], tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); + vertices[3] = S3DVertex((f32)destRect.UpperLeftCorner.X, (f32)destRect.LowerRightCorner.Y, 0, 0, 0, 1, useColor[1], tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); + drawVertexPrimitiveList2d3d(vertices, 4, indices, 2, video::EVT_STANDARD, scene::EPT_TRIANGLE_FAN, EIT_16BIT, false); + + if (clipRect) + glDisable(GL_SCISSOR_TEST); +} + +void COGLES1Driver::draw2DImage(const video::ITexture *texture, u32 layer, bool flip) +{ + if (!texture || !CacheHandler->getTextureCache().set(0, texture)) + return; + + setRenderStates2DMode(false, true, true); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + Transformation3DChanged = true; + + u16 indices[] = {0, 1, 2, 3}; + S3DVertex vertices[4]; + + vertices[0].Pos = core::vector3df(-1.f, 1.f, 0.f); + vertices[1].Pos = core::vector3df(1.f, 1.f, 0.f); + vertices[2].Pos = core::vector3df(1.f, -1.f, 0.f); + vertices[3].Pos = core::vector3df(-1.f, -1.f, 0.f); + + f32 modificator = (flip) ? 1.f : 0.f; + + vertices[0].TCoords = core::vector2df(0.f, 0.f + modificator); + vertices[1].TCoords = core::vector2df(1.f, 0.f + modificator); + vertices[2].TCoords = core::vector2df(1.f, 1.f - modificator); + vertices[3].TCoords = core::vector2df(0.f, 1.f - modificator); + + vertices[0].Color = 0xFFFFFFFF; + vertices[1].Color = 0xFFFFFFFF; + vertices[2].Color = 0xFFFFFFFF; + vertices[3].Color = 0xFFFFFFFF; + + drawVertexPrimitiveList2d3d(vertices, 4, indices, 2, video::EVT_STANDARD, scene::EPT_TRIANGLE_FAN, EIT_16BIT, false); +} + +//! draws a set of 2d images, using a color and the alpha channel of the texture if desired. +void COGLES1Driver::draw2DImageBatch(const video::ITexture *texture, + const core::array> &positions, + const core::array> &sourceRects, + const core::rect *clipRect, + SColor color, + bool useAlphaChannelOfTexture) +{ + if (!texture) + return; + + const u32 drawCount = core::min_(positions.size(), sourceRects.size()); + if (!drawCount) + return; + + const core::dimension2d &ss = texture->getOriginalSize(); + if (!ss.Width || !ss.Height) + return; + const f32 invW = 1.f / static_cast(ss.Width); + const f32 invH = 1.f / static_cast(ss.Height); + const core::dimension2d &renderTargetSize = getCurrentRenderTargetSize(); + + if (!CacheHandler->getTextureCache().set(0, texture)) + return; + + setRenderStates2DMode(color.getAlpha() < 255, true, useAlphaChannelOfTexture); + + core::array vertices; + core::array quadIndices; + vertices.reallocate(drawCount * 4); + quadIndices.reallocate(drawCount * 6); + + for (u32 i = 0; i < drawCount; ++i) { + if (!sourceRects[i].isValid()) + continue; + + core::position2d targetPos(positions[i]); + core::position2d sourcePos(sourceRects[i].UpperLeftCorner); + // This needs to be signed as it may go negative. + core::dimension2d sourceSize(sourceRects[i].getSize()); + if (clipRect) { + if (targetPos.X < clipRect->UpperLeftCorner.X) { + sourceSize.Width += targetPos.X - clipRect->UpperLeftCorner.X; + if (sourceSize.Width <= 0) + continue; + + sourcePos.X -= targetPos.X - clipRect->UpperLeftCorner.X; + targetPos.X = clipRect->UpperLeftCorner.X; + } + + if (targetPos.X + sourceSize.Width > clipRect->LowerRightCorner.X) { + sourceSize.Width -= (targetPos.X + sourceSize.Width) - clipRect->LowerRightCorner.X; + if (sourceSize.Width <= 0) + continue; + } + + if (targetPos.Y < clipRect->UpperLeftCorner.Y) { + sourceSize.Height += targetPos.Y - clipRect->UpperLeftCorner.Y; + if (sourceSize.Height <= 0) + continue; + + sourcePos.Y -= targetPos.Y - clipRect->UpperLeftCorner.Y; + targetPos.Y = clipRect->UpperLeftCorner.Y; + } + + if (targetPos.Y + sourceSize.Height > clipRect->LowerRightCorner.Y) { + sourceSize.Height -= (targetPos.Y + sourceSize.Height) - clipRect->LowerRightCorner.Y; + if (sourceSize.Height <= 0) + continue; + } + } + + // clip these coordinates + + if (targetPos.X < 0) { + sourceSize.Width += targetPos.X; + if (sourceSize.Width <= 0) + continue; + + sourcePos.X -= targetPos.X; + targetPos.X = 0; + } + + if (targetPos.X + sourceSize.Width > (s32)renderTargetSize.Width) { + sourceSize.Width -= (targetPos.X + sourceSize.Width) - renderTargetSize.Width; + if (sourceSize.Width <= 0) + continue; + } + + if (targetPos.Y < 0) { + sourceSize.Height += targetPos.Y; + if (sourceSize.Height <= 0) + continue; + + sourcePos.Y -= targetPos.Y; + targetPos.Y = 0; + } + + if (targetPos.Y + sourceSize.Height > (s32)renderTargetSize.Height) { + sourceSize.Height -= (targetPos.Y + sourceSize.Height) - renderTargetSize.Height; + if (sourceSize.Height <= 0) + continue; + } + + // ok, we've clipped everything. + + const core::rect tcoords( + sourcePos.X * invW, + sourcePos.Y * invH, + (sourcePos.X + sourceSize.Width) * invW, + (sourcePos.Y + sourceSize.Height) * invH); + + const core::rect poss(targetPos, sourceSize); + + const u32 vstart = vertices.size(); + + vertices.push_back(S3DVertex((f32)poss.UpperLeftCorner.X, (f32)poss.UpperLeftCorner.Y, 0, 0, 0, 1, color, tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y)); + vertices.push_back(S3DVertex((f32)poss.LowerRightCorner.X, (f32)poss.UpperLeftCorner.Y, 0, 0, 0, 1, color, tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y)); + vertices.push_back(S3DVertex((f32)poss.LowerRightCorner.X, (f32)poss.LowerRightCorner.Y, 0, 0, 0, 1, color, tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y)); + vertices.push_back(S3DVertex((f32)poss.UpperLeftCorner.X, (f32)poss.LowerRightCorner.Y, 0, 0, 0, 1, color, tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y)); + + quadIndices.push_back(vstart); + quadIndices.push_back(vstart + 1); + quadIndices.push_back(vstart + 2); + quadIndices.push_back(vstart); + quadIndices.push_back(vstart + 2); + quadIndices.push_back(vstart + 3); + } + if (vertices.size()) + drawVertexPrimitiveList2d3d(vertices.pointer(), vertices.size(), + quadIndices.pointer(), vertices.size() / 2, + video::EVT_STANDARD, scene::EPT_TRIANGLES, + EIT_16BIT, false); +} + +//! draw a 2d rectangle +void COGLES1Driver::draw2DRectangle(SColor color, const core::rect &position, + const core::rect *clip) +{ + setRenderStates2DMode(color.getAlpha() < 255, false, false); + + core::rect pos = position; + + if (clip) + pos.clipAgainst(*clip); + + if (!pos.isValid()) + return; + + u16 indices[] = {0, 1, 2, 3}; + S3DVertex vertices[4]; + vertices[0] = S3DVertex((f32)pos.UpperLeftCorner.X, (f32)pos.UpperLeftCorner.Y, 0, 0, 0, 1, color, 0, 0); + vertices[1] = S3DVertex((f32)pos.LowerRightCorner.X, (f32)pos.UpperLeftCorner.Y, 0, 0, 0, 1, color, 0, 0); + vertices[2] = S3DVertex((f32)pos.LowerRightCorner.X, (f32)pos.LowerRightCorner.Y, 0, 0, 0, 1, color, 0, 0); + vertices[3] = S3DVertex((f32)pos.UpperLeftCorner.X, (f32)pos.LowerRightCorner.Y, 0, 0, 0, 1, color, 0, 0); + drawVertexPrimitiveList2d3d(vertices, 4, indices, 2, video::EVT_STANDARD, scene::EPT_TRIANGLE_FAN, EIT_16BIT, false); +} + +//! draw an 2d rectangle +void COGLES1Driver::draw2DRectangle(const core::rect &position, + SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, + const core::rect *clip) +{ + core::rect pos = position; + + if (clip) + pos.clipAgainst(*clip); + + if (!pos.isValid()) + return; + + setRenderStates2DMode(colorLeftUp.getAlpha() < 255 || + colorRightUp.getAlpha() < 255 || + colorLeftDown.getAlpha() < 255 || + colorRightDown.getAlpha() < 255, + false, false); + + u16 indices[] = {0, 1, 2, 3}; + S3DVertex vertices[4]; + vertices[0] = S3DVertex((f32)pos.UpperLeftCorner.X, (f32)pos.UpperLeftCorner.Y, 0, 0, 0, 1, colorLeftUp, 0, 0); + vertices[1] = S3DVertex((f32)pos.LowerRightCorner.X, (f32)pos.UpperLeftCorner.Y, 0, 0, 0, 1, colorRightUp, 0, 0); + vertices[2] = S3DVertex((f32)pos.LowerRightCorner.X, (f32)pos.LowerRightCorner.Y, 0, 0, 0, 1, colorRightDown, 0, 0); + vertices[3] = S3DVertex((f32)pos.UpperLeftCorner.X, (f32)pos.LowerRightCorner.Y, 0, 0, 0, 1, colorLeftDown, 0, 0); + drawVertexPrimitiveList2d3d(vertices, 4, indices, 2, video::EVT_STANDARD, scene::EPT_TRIANGLE_FAN, EIT_16BIT, false); +} + +//! Draws a 2d line. +void COGLES1Driver::draw2DLine(const core::position2d &start, + const core::position2d &end, + SColor color) +{ + setRenderStates2DMode(color.getAlpha() < 255, false, false); + + u16 indices[] = {0, 1}; + S3DVertex vertices[2]; + vertices[0] = S3DVertex((f32)start.X, (f32)start.Y, 0, 0, 0, 1, color, 0, 0); + vertices[1] = S3DVertex((f32)end.X, (f32)end.Y, 0, 0, 0, 1, color, 1, 1); + drawVertexPrimitiveList2d3d(vertices, 2, indices, 1, video::EVT_STANDARD, scene::EPT_LINES, EIT_16BIT, false); +} + +//! creates a matrix in supplied GLfloat array to pass to OGLES1 +inline void COGLES1Driver::getGLMatrix(GLfloat gl_matrix[16], const core::matrix4 &m) +{ + memcpy(gl_matrix, m.pointer(), 16 * sizeof(f32)); +} + +//! creates a opengltexturematrix from a D3D style texture matrix +inline void COGLES1Driver::getGLTextureMatrix(GLfloat *o, const core::matrix4 &m) +{ + o[0] = m[0]; + o[1] = m[1]; + o[2] = 0.f; + o[3] = 0.f; + + o[4] = m[4]; + o[5] = m[5]; + o[6] = 0.f; + o[7] = 0.f; + + o[8] = 0.f; + o[9] = 0.f; + o[10] = 1.f; + o[11] = 0.f; + + o[12] = m[8]; + o[13] = m[9]; + o[14] = 0.f; + o[15] = 1.f; +} + +ITexture *COGLES1Driver::createDeviceDependentTexture(const io::path &name, IImage *image) +{ + core::array imageArray(1); + imageArray.push_back(image); + + COGLES1Texture *texture = new COGLES1Texture(name, imageArray, ETT_2D, this); + + return texture; +} + +ITexture *COGLES1Driver::createDeviceDependentTextureCubemap(const io::path &name, const core::array &image) +{ + COGLES1Texture *texture = new COGLES1Texture(name, image, ETT_CUBEMAP, this); + + return texture; +} + +//! Sets a material. All 3d drawing functions draw geometry now using this material. +void COGLES1Driver::setMaterial(const SMaterial &material) +{ + Material = material; + OverrideMaterial.apply(Material); + + for (u32 i = 0; i < Feature.MaxTextureUnits; ++i) + setTransform((E_TRANSFORMATION_STATE)(ETS_TEXTURE_0 + i), material.getTextureMatrix(i)); +} + +//! prints error if an error happened. +bool COGLES1Driver::testGLError(int code) +{ +#ifdef _DEBUG + GLenum g = glGetError(); + switch (g) { + case GL_NO_ERROR: + return false; + case GL_INVALID_ENUM: + os::Printer::log("GL_INVALID_ENUM", core::stringc(code).c_str(), ELL_ERROR); + break; + case GL_INVALID_VALUE: + os::Printer::log("GL_INVALID_VALUE", core::stringc(code).c_str(), ELL_ERROR); + break; + case GL_INVALID_OPERATION: + os::Printer::log("GL_INVALID_OPERATION", core::stringc(code).c_str(), ELL_ERROR); + break; + case GL_STACK_OVERFLOW: + os::Printer::log("GL_STACK_OVERFLOW", core::stringc(code).c_str(), ELL_ERROR); + break; + case GL_STACK_UNDERFLOW: + os::Printer::log("GL_STACK_UNDERFLOW", core::stringc(code).c_str(), ELL_ERROR); + break; + case GL_OUT_OF_MEMORY: + os::Printer::log("GL_OUT_OF_MEMORY", core::stringc(code).c_str(), ELL_ERROR); + break; + }; + // _IRR_DEBUG_BREAK_IF(true); + return true; +#else + return false; +#endif +} + +//! sets the needed renderstates +void COGLES1Driver::setRenderStates3DMode() +{ + if (CurrentRenderMode != ERM_3D) { + // Reset Texture Stages + CacheHandler->setBlend(false); + glDisable(GL_ALPHA_TEST); + CacheHandler->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + // switch back the matrices + glMatrixMode(GL_MODELVIEW); + glLoadMatrixf((Matrices[ETS_VIEW] * Matrices[ETS_WORLD]).pointer()); + + GLfloat glmat[16]; + getGLMatrix(glmat, Matrices[ETS_PROJECTION]); + glmat[12] *= -1.0f; + glMatrixMode(GL_PROJECTION); + glLoadMatrixf(glmat); + + ResetRenderStates = true; + } + + if (ResetRenderStates || LastMaterial != Material) { + // unset old material + + if (LastMaterial.MaterialType != Material.MaterialType && + static_cast(LastMaterial.MaterialType) < MaterialRenderers.size()) + MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial(); + + // set new material. + if (static_cast(Material.MaterialType) < MaterialRenderers.size()) + MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial( + Material, LastMaterial, ResetRenderStates, this); + + LastMaterial = Material; + CacheHandler->correctCacheMaterial(LastMaterial); + ResetRenderStates = false; + } + + if (static_cast(Material.MaterialType) < MaterialRenderers.size()) + MaterialRenderers[Material.MaterialType].Renderer->OnRender(this, video::EVT_STANDARD); + + CurrentRenderMode = ERM_3D; +} + +GLint COGLES1Driver::getTextureWrapMode(u8 clamp) const +{ + switch (clamp) { + case ETC_CLAMP: + // return GL_CLAMP; not supported in ogl-es + return GL_CLAMP_TO_EDGE; + break; + case ETC_CLAMP_TO_EDGE: + return GL_CLAMP_TO_EDGE; + break; + case ETC_CLAMP_TO_BORDER: + // return GL_CLAMP_TO_BORDER; not supported in ogl-es + return GL_CLAMP_TO_EDGE; + break; + case ETC_MIRROR: +#ifdef GL_OES_texture_mirrored_repeat + if (FeatureAvailable[COGLESCoreExtensionHandler::IRR_GL_OES_texture_mirrored_repeat]) + return GL_MIRRORED_REPEAT_OES; + else +#endif + return GL_REPEAT; + break; + // the next three are not yet supported at all + case ETC_MIRROR_CLAMP: + case ETC_MIRROR_CLAMP_TO_EDGE: + case ETC_MIRROR_CLAMP_TO_BORDER: +#ifdef GL_OES_texture_mirrored_repeat + if (FeatureAvailable[COGLESCoreExtensionHandler::IRR_GL_OES_texture_mirrored_repeat]) + return GL_MIRRORED_REPEAT_OES; + else +#endif + return GL_CLAMP_TO_EDGE; + break; + case ETC_REPEAT: + default: + return GL_REPEAT; + break; + } +} + +//! Can be called by an IMaterialRenderer to make its work easier. +void COGLES1Driver::setBasicRenderStates(const SMaterial &material, const SMaterial &lastmaterial, + bool resetAllRenderStates) +{ + if (resetAllRenderStates || + lastmaterial.ColorMaterial != material.ColorMaterial) { + // we only have diffuse_and_ambient in ogl-es + if (material.ColorMaterial == ECM_DIFFUSE_AND_AMBIENT) + glEnable(GL_COLOR_MATERIAL); + else + glDisable(GL_COLOR_MATERIAL); + } + + if (resetAllRenderStates || + lastmaterial.AmbientColor != material.AmbientColor || + lastmaterial.DiffuseColor != material.DiffuseColor || + lastmaterial.EmissiveColor != material.EmissiveColor || + lastmaterial.ColorMaterial != material.ColorMaterial) { + GLfloat color[4]; + + const f32 inv = 1.0f / 255.0f; + + if ((material.ColorMaterial != video::ECM_AMBIENT) && + (material.ColorMaterial != video::ECM_DIFFUSE_AND_AMBIENT)) { + color[0] = material.AmbientColor.getRed() * inv; + color[1] = material.AmbientColor.getGreen() * inv; + color[2] = material.AmbientColor.getBlue() * inv; + color[3] = material.AmbientColor.getAlpha() * inv; + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color); + } + + if ((material.ColorMaterial != video::ECM_DIFFUSE) && + (material.ColorMaterial != video::ECM_DIFFUSE_AND_AMBIENT)) { + color[0] = material.DiffuseColor.getRed() * inv; + color[1] = material.DiffuseColor.getGreen() * inv; + color[2] = material.DiffuseColor.getBlue() * inv; + color[3] = material.DiffuseColor.getAlpha() * inv; + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color); + } + + if (material.ColorMaterial != video::ECM_EMISSIVE) { + color[0] = material.EmissiveColor.getRed() * inv; + color[1] = material.EmissiveColor.getGreen() * inv; + color[2] = material.EmissiveColor.getBlue() * inv; + color[3] = material.EmissiveColor.getAlpha() * inv; + glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, color); + } + } + + if (resetAllRenderStates || + lastmaterial.SpecularColor != material.SpecularColor || + lastmaterial.Shininess != material.Shininess) { + GLfloat color[] = {0.f, 0.f, 0.f, 1.f}; + const f32 inv = 1.0f / 255.0f; + + // disable Specular colors if no shininess is set + if ((material.Shininess != 0.0f) && + (material.ColorMaterial != video::ECM_SPECULAR)) { +#ifdef GL_EXT_separate_specular_color + if (FeatureAvailable[IRR_EXT_separate_specular_color]) + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); +#endif + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material.Shininess); + color[0] = material.SpecularColor.getRed() * inv; + color[1] = material.SpecularColor.getGreen() * inv; + color[2] = material.SpecularColor.getBlue() * inv; + color[3] = material.SpecularColor.getAlpha() * inv; + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color); + } +#ifdef GL_EXT_separate_specular_color + else if (FeatureAvailable[IRR_EXT_separate_specular_color]) + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR); +#endif + } + + // TODO ogl-es + // fillmode + // if (resetAllRenderStates || (lastmaterial.Wireframe != material.Wireframe) || (lastmaterial.PointCloud != material.PointCloud)) + // glPolygonMode(GL_FRONT_AND_BACK, material.Wireframe ? GL_LINE : material.PointCloud? GL_POINT : GL_FILL); + + // shademode + if (resetAllRenderStates || (lastmaterial.GouraudShading != material.GouraudShading)) { + if (material.GouraudShading) + glShadeModel(GL_SMOOTH); + else + glShadeModel(GL_FLAT); + } + + // lighting + if (resetAllRenderStates || (lastmaterial.Lighting != material.Lighting)) { + if (material.Lighting) + glEnable(GL_LIGHTING); + else + glDisable(GL_LIGHTING); + } + + // zbuffer + if (resetAllRenderStates || lastmaterial.ZBuffer != material.ZBuffer) { + switch (material.ZBuffer) { + case ECFN_DISABLED: + glDisable(GL_DEPTH_TEST); + break; + case ECFN_LESSEQUAL: + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LEQUAL); + break; + case ECFN_EQUAL: + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_EQUAL); + break; + case ECFN_LESS: + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + break; + case ECFN_NOTEQUAL: + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_NOTEQUAL); + break; + case ECFN_GREATEREQUAL: + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_GEQUAL); + break; + case ECFN_GREATER: + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_GREATER); + break; + case ECFN_ALWAYS: + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_ALWAYS); + break; + case ECFN_NEVER: + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_NEVER); + break; + } + } + + // zwrite + if (getWriteZBuffer(material)) { + glDepthMask(GL_TRUE); + } else { + glDepthMask(GL_FALSE); + } + + // back face culling + if (resetAllRenderStates || (lastmaterial.FrontfaceCulling != material.FrontfaceCulling) || (lastmaterial.BackfaceCulling != material.BackfaceCulling)) { + if ((material.FrontfaceCulling) && (material.BackfaceCulling)) { + glCullFace(GL_FRONT_AND_BACK); + glEnable(GL_CULL_FACE); + } else if (material.BackfaceCulling) { + glCullFace(GL_BACK); + glEnable(GL_CULL_FACE); + } else if (material.FrontfaceCulling) { + glCullFace(GL_FRONT); + glEnable(GL_CULL_FACE); + } else + glDisable(GL_CULL_FACE); + } + + // fog + if (resetAllRenderStates || lastmaterial.FogEnable != material.FogEnable) { + if (material.FogEnable) + glEnable(GL_FOG); + else + glDisable(GL_FOG); + } + + // normalization + if (resetAllRenderStates || lastmaterial.NormalizeNormals != material.NormalizeNormals) { + if (material.NormalizeNormals) + glEnable(GL_NORMALIZE); + else + glDisable(GL_NORMALIZE); + } + + // Color Mask + if (resetAllRenderStates || lastmaterial.ColorMask != material.ColorMask) { + glColorMask( + (material.ColorMask & ECP_RED) ? GL_TRUE : GL_FALSE, + (material.ColorMask & ECP_GREEN) ? GL_TRUE : GL_FALSE, + (material.ColorMask & ECP_BLUE) ? GL_TRUE : GL_FALSE, + (material.ColorMask & ECP_ALPHA) ? GL_TRUE : GL_FALSE); + } + + // Blend Equation + if (material.BlendOperation == EBO_NONE) + CacheHandler->setBlend(false); + else { + CacheHandler->setBlend(true); + + if (queryFeature(EVDF_BLEND_OPERATIONS)) { + switch (material.BlendOperation) { + case EBO_ADD: +#if defined(GL_OES_blend_subtract) + CacheHandler->setBlendEquation(GL_FUNC_ADD_OES); +#endif + break; + case EBO_SUBTRACT: +#if defined(GL_OES_blend_subtract) + CacheHandler->setBlendEquation(GL_FUNC_SUBTRACT_OES); +#endif + break; + case EBO_REVSUBTRACT: +#if defined(GL_OES_blend_subtract) + CacheHandler->setBlendEquation(GL_FUNC_REVERSE_SUBTRACT_OES); +#endif + break; + default: + break; + } + } + } + + // Blend Factor + if (IR(material.BlendFactor) & 0xFFFFFFFF // TODO: why the & 0xFFFFFFFF? + && material.MaterialType != EMT_ONETEXTURE_BLEND) { + E_BLEND_FACTOR srcRGBFact = EBF_ZERO; + E_BLEND_FACTOR dstRGBFact = EBF_ZERO; + E_BLEND_FACTOR srcAlphaFact = EBF_ZERO; + E_BLEND_FACTOR dstAlphaFact = EBF_ZERO; + E_MODULATE_FUNC modulo = EMFN_MODULATE_1X; + u32 alphaSource = 0; + + unpack_textureBlendFuncSeparate(srcRGBFact, dstRGBFact, srcAlphaFact, dstAlphaFact, modulo, alphaSource, material.BlendFactor); + + if (queryFeature(EVDF_BLEND_SEPARATE)) { + CacheHandler->setBlendFuncSeparate(getGLBlend(srcRGBFact), getGLBlend(dstRGBFact), + getGLBlend(srcAlphaFact), getGLBlend(dstAlphaFact)); + } else { + CacheHandler->setBlendFunc(getGLBlend(srcRGBFact), getGLBlend(dstRGBFact)); + } + } + + // TODO: Polygon Offset. Not sure if it was left out deliberately or if it won't work with this driver. + + // thickness + if (resetAllRenderStates || lastmaterial.Thickness != material.Thickness) { + if (AntiAlias) { + // glPointSize(core::clamp(static_cast(material.Thickness), DimSmoothedPoint[0], DimSmoothedPoint[1])); + // we don't use point smoothing + glPointSize(core::clamp(static_cast(material.Thickness), DimAliasedPoint[0], DimAliasedPoint[1])); + } else { + glPointSize(core::clamp(static_cast(material.Thickness), DimAliasedPoint[0], DimAliasedPoint[1])); + glLineWidth(core::clamp(static_cast(material.Thickness), DimAliasedLine[0], DimAliasedLine[1])); + } + } + + // Anti aliasing + if (resetAllRenderStates || lastmaterial.AntiAliasing != material.AntiAliasing) { + if (material.AntiAliasing & EAAM_ALPHA_TO_COVERAGE) + glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE); + else if (lastmaterial.AntiAliasing & EAAM_ALPHA_TO_COVERAGE) + glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); + + if ((AntiAlias >= 2) && (material.AntiAliasing & (EAAM_SIMPLE | EAAM_QUALITY))) + glEnable(GL_MULTISAMPLE); + else + glDisable(GL_MULTISAMPLE); + } + + // Texture parameters + setTextureRenderStates(material, resetAllRenderStates); +} + +//! Compare in SMaterial doesn't check texture parameters, so we should call this on each OnRender call. +void COGLES1Driver::setTextureRenderStates(const SMaterial &material, bool resetAllRenderstates) +{ + // Set textures to TU/TIU and apply filters to them + + for (s32 i = Feature.MaxTextureUnits - 1; i >= 0; --i) { + CacheHandler->getTextureCache().set(i, material.TextureLayers[i].Texture); + + const COGLES1Texture *tmpTexture = CacheHandler->getTextureCache().get(i); + + if (!tmpTexture) + continue; + + GLenum tmpTextureType = tmpTexture->getOpenGLTextureType(); + + CacheHandler->setActiveTexture(GL_TEXTURE0 + i); + + { + const bool isRTT = tmpTexture->isRenderTarget(); + + glMatrixMode(GL_TEXTURE); + + if (!isRTT && Matrices[ETS_TEXTURE_0 + i].isIdentity()) + glLoadIdentity(); + else { + GLfloat glmat[16]; + if (isRTT) + getGLTextureMatrix(glmat, Matrices[ETS_TEXTURE_0 + i] * TextureFlipMatrix); + else + getGLTextureMatrix(glmat, Matrices[ETS_TEXTURE_0 + i]); + glLoadMatrixf(glmat); + } + } + + COGLES1Texture::SStatesCache &statesCache = tmpTexture->getStatesCache(); + + if (resetAllRenderstates) + statesCache.IsCached = false; + +#if defined(GL_EXT_texture_lod_bias) + if (FeatureAvailable[COGLESCoreExtensionHandler::IRR_GL_EXT_texture_lod_bias]) { + if (material.TextureLayers[i].LODBias) { + const float tmp = core::clamp(material.TextureLayers[i].LODBias * 0.125f, -MaxTextureLODBias, MaxTextureLODBias); + glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, tmp); + } else + glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0.f); + } +#endif + + if (!statesCache.IsCached || material.TextureLayers[i].MagFilter != statesCache.MagFilter) { + E_TEXTURE_MAG_FILTER magFilter = material.TextureLayers[i].MagFilter; + glTexParameteri(tmpTextureType, GL_TEXTURE_MAG_FILTER, + magFilter == ETMAGF_NEAREST ? GL_NEAREST : (assert(magFilter == ETMAGF_LINEAR), GL_LINEAR)); + + statesCache.MagFilter = magFilter; + } + + if (material.UseMipMaps && tmpTexture->hasMipMaps()) { + if (!statesCache.IsCached || material.TextureLayers[i].MinFilter != statesCache.MinFilter || + !statesCache.MipMapStatus) { + E_TEXTURE_MIN_FILTER minFilter = material.TextureLayers[i].MinFilter; + glTexParameteri(tmpTextureType, GL_TEXTURE_MIN_FILTER, + minFilter == ETMINF_NEAREST_MIPMAP_NEAREST ? GL_NEAREST_MIPMAP_NEAREST : minFilter == ETMINF_LINEAR_MIPMAP_NEAREST ? GL_LINEAR_MIPMAP_NEAREST + : minFilter == ETMINF_NEAREST_MIPMAP_LINEAR ? GL_NEAREST_MIPMAP_LINEAR + : (assert(minFilter == ETMINF_LINEAR_MIPMAP_LINEAR), GL_LINEAR_MIPMAP_LINEAR)); + + statesCache.MinFilter = minFilter; + statesCache.MipMapStatus = true; + } + } else { + if (!statesCache.IsCached || material.TextureLayers[i].MinFilter != statesCache.MinFilter || + statesCache.MipMapStatus) { + E_TEXTURE_MIN_FILTER minFilter = material.TextureLayers[i].MinFilter; + glTexParameteri(tmpTextureType, GL_TEXTURE_MIN_FILTER, + (minFilter == ETMINF_NEAREST_MIPMAP_NEAREST || minFilter == ETMINF_NEAREST_MIPMAP_LINEAR) ? GL_NEAREST : (assert(minFilter == ETMINF_LINEAR_MIPMAP_NEAREST || minFilter == ETMINF_LINEAR_MIPMAP_LINEAR), GL_LINEAR)); + + statesCache.MinFilter = minFilter; + statesCache.MipMapStatus = false; + } + } + +#ifdef GL_EXT_texture_filter_anisotropic + if (FeatureAvailable[COGLESCoreExtensionHandler::IRR_GL_EXT_texture_filter_anisotropic] && + (!statesCache.IsCached || material.TextureLayers[i].AnisotropicFilter != statesCache.AnisotropicFilter)) { + glTexParameteri(tmpTextureType, GL_TEXTURE_MAX_ANISOTROPY_EXT, + material.TextureLayers[i].AnisotropicFilter > 1 ? core::min_(MaxAnisotropy, material.TextureLayers[i].AnisotropicFilter) : 1); + + statesCache.AnisotropicFilter = material.TextureLayers[i].AnisotropicFilter; + } +#endif + + if (!statesCache.IsCached || material.TextureLayers[i].TextureWrapU != statesCache.WrapU) { + glTexParameteri(tmpTextureType, GL_TEXTURE_WRAP_S, getTextureWrapMode(material.TextureLayers[i].TextureWrapU)); + statesCache.WrapU = material.TextureLayers[i].TextureWrapU; + } + + if (!statesCache.IsCached || material.TextureLayers[i].TextureWrapV != statesCache.WrapV) { + glTexParameteri(tmpTextureType, GL_TEXTURE_WRAP_T, getTextureWrapMode(material.TextureLayers[i].TextureWrapV)); + statesCache.WrapV = material.TextureLayers[i].TextureWrapV; + } + + statesCache.IsCached = true; + } + + // be sure to leave in texture stage 0 + CacheHandler->setActiveTexture(GL_TEXTURE0); +} + +//! sets the needed renderstates +void COGLES1Driver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel) +{ + if (CurrentRenderMode != ERM_2D || Transformation3DChanged) { + // unset last 3d material + if (CurrentRenderMode == ERM_3D) { + if (static_cast(LastMaterial.MaterialType) < MaterialRenderers.size()) + MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial(); + } + if (Transformation3DChanged) { + glMatrixMode(GL_PROJECTION); + + const core::dimension2d &renderTargetSize = getCurrentRenderTargetSize(); + core::matrix4 m(core::matrix4::EM4CONST_NOTHING); + m.buildProjectionMatrixOrthoLH(f32(renderTargetSize.Width), f32(-(s32)(renderTargetSize.Height)), -1.0f, 1.0f); + m.setTranslation(core::vector3df(-1, 1, 0)); + glLoadMatrixf(m.pointer()); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + Transformation3DChanged = false; + } + } + + Material = (OverrideMaterial2DEnabled) ? OverrideMaterial2D : InitMaterial2D; + Material.Lighting = false; + Material.TextureLayers[0].Texture = (texture) ? const_cast(CacheHandler->getTextureCache().get(0)) : 0; + setTransform(ETS_TEXTURE_0, core::IdentityMatrix); + + setBasicRenderStates(Material, LastMaterial, false); + + LastMaterial = Material; + CacheHandler->correctCacheMaterial(LastMaterial); + + // no alphaChannel without texture + alphaChannel &= texture; + + if (alphaChannel || alpha) { + CacheHandler->setBlend(true); + CacheHandler->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + CacheHandler->setBlendEquation(GL_FUNC_ADD); + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER, 0.f); + } else { + CacheHandler->setBlend(false); + glDisable(GL_ALPHA_TEST); + } + + if (texture) { + // Due to the transformation change, the previous line would call a reset each frame + // but we can safely reset the variable as it was false before + Transformation3DChanged = false; + + if (alphaChannel) { + // if alpha and alpha texture just modulate, otherwise use only the alpha channel + if (alpha) { + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + } else { + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); + glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_TEXTURE); + // rgb always modulates + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE); + glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PRIMARY_COLOR); + } + } else { + if (alpha) { + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); + glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PRIMARY_COLOR); + // rgb always modulates + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE); + glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PRIMARY_COLOR); + } else { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + } + } + } + + CurrentRenderMode = ERM_2D; +} + +//! \return Returns the name of the video driver. +const char *COGLES1Driver::getName() const +{ + return Name.c_str(); +} + +//! Sets the dynamic ambient light color. +void COGLES1Driver::setAmbientLight(const SColorf &color) +{ + CNullDriver::setAmbientLight(color); + GLfloat data[4] = {color.r, color.g, color.b, color.a}; + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, data); +} + +// this code was sent in by Oliver Klems, thank you +void COGLES1Driver::setViewPort(const core::rect &area) +{ + core::rect vp = area; + core::rect rendert(0, 0, getCurrentRenderTargetSize().Width, getCurrentRenderTargetSize().Height); + vp.clipAgainst(rendert); + + if (vp.getHeight() > 0 && vp.getWidth() > 0) + CacheHandler->setViewport(vp.UpperLeftCorner.X, getCurrentRenderTargetSize().Height - vp.UpperLeftCorner.Y - vp.getHeight(), vp.getWidth(), vp.getHeight()); + + ViewPort = vp; +} + +void COGLES1Driver::setViewPortRaw(u32 width, u32 height) +{ + CacheHandler->setViewport(0, 0, width, height); + ViewPort = core::recti(0, 0, width, height); +} + +//! Sets the fog mode. +void COGLES1Driver::setFog(SColor c, E_FOG_TYPE fogType, f32 start, + f32 end, f32 density, bool pixelFog, bool rangeFog) +{ + CNullDriver::setFog(c, fogType, start, end, density, pixelFog, rangeFog); + + glFogf(GL_FOG_MODE, GLfloat((fogType == EFT_FOG_LINEAR) ? GL_LINEAR : (fogType == EFT_FOG_EXP) ? GL_EXP + : GL_EXP2)); + +#ifdef GL_EXT_fog_coord + if (FeatureAvailable[IRR_EXT_fog_coord]) + glFogi(GL_FOG_COORDINATE_SOURCE, GL_FRAGMENT_DEPTH); +#endif + + if (fogType == EFT_FOG_LINEAR) { + glFogf(GL_FOG_START, start); + glFogf(GL_FOG_END, end); + } else + glFogf(GL_FOG_DENSITY, density); + + if (pixelFog) + glHint(GL_FOG_HINT, GL_NICEST); + else + glHint(GL_FOG_HINT, GL_FASTEST); + + SColorf color(c); + GLfloat data[4] = {color.r, color.g, color.b, color.a}; + glFogfv(GL_FOG_COLOR, data); +} + +//! Draws a 3d line. +void COGLES1Driver::draw3DLine(const core::vector3df &start, + const core::vector3df &end, SColor color) +{ + setRenderStates3DMode(); + + u16 indices[] = {0, 1}; + S3DVertex vertices[2]; + vertices[0] = S3DVertex(start.X, start.Y, start.Z, 0, 0, 1, color, 0, 0); + vertices[1] = S3DVertex(end.X, end.Y, end.Z, 0, 0, 1, color, 0, 0); + drawVertexPrimitiveList2d3d(vertices, 2, indices, 1, video::EVT_STANDARD, scene::EPT_LINES); +} + +//! Only used by the internal engine. Used to notify the driver that +//! the window was resized. +void COGLES1Driver::OnResize(const core::dimension2d &size) +{ + CNullDriver::OnResize(size); + CacheHandler->setViewport(0, 0, size.Width, size.Height); + Transformation3DChanged = true; +} + +//! Returns type of video driver +E_DRIVER_TYPE COGLES1Driver::getDriverType() const +{ + return EDT_OGLES1; +} + +//! returns color format +ECOLOR_FORMAT COGLES1Driver::getColorFormat() const +{ + return ColorFormat; +} + +//! Get a vertex shader constant index. +s32 COGLES1Driver::getVertexShaderConstantID(const c8 *name) +{ + return getPixelShaderConstantID(name); +} + +//! Get a pixel shader constant index. +s32 COGLES1Driver::getPixelShaderConstantID(const c8 *name) +{ + os::Printer::log("Error: Please use IMaterialRendererServices from IShaderConstantSetCallBack::OnSetConstants not VideoDriver->getPixelShaderConstantID()."); + return -1; +} + +//! Sets a constant for the vertex shader based on an index. +bool COGLES1Driver::setVertexShaderConstant(s32 index, const f32 *floats, int count) +{ + // pass this along, as in GLSL the same routine is used for both vertex and fragment shaders + return setPixelShaderConstant(index, floats, count); +} + +//! Int interface for the above. +bool COGLES1Driver::setVertexShaderConstant(s32 index, const s32 *ints, int count) +{ + return setPixelShaderConstant(index, ints, count); +} + +bool COGLES1Driver::setVertexShaderConstant(s32 index, const u32 *ints, int count) +{ + return setPixelShaderConstant(index, ints, count); +} + +//! Sets a constant for the pixel shader based on an index. +bool COGLES1Driver::setPixelShaderConstant(s32 index, const f32 *floats, int count) +{ + os::Printer::log("Error: Please use IMaterialRendererServices from IShaderConstantSetCallBack::OnSetConstants not VideoDriver->setPixelShaderConstant()."); + return false; +} + +//! Int interface for the above. +bool COGLES1Driver::setPixelShaderConstant(s32 index, const s32 *ints, int count) +{ + os::Printer::log("Error: Please use IMaterialRendererServices from IShaderConstantSetCallBack::OnSetConstants not VideoDriver->setPixelShaderConstant()."); + return false; +} + +bool COGLES1Driver::setPixelShaderConstant(s32 index, const u32 *ints, int count) +{ + os::Printer::log("Error: Please use IMaterialRendererServices from IShaderConstantSetCallBack::OnSetConstants not VideoDriver->setPixelShaderConstant()."); + return false; +} + +//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry. +s32 COGLES1Driver::addHighLevelShaderMaterial( + const c8 *vertexShaderProgram, + const c8 *vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, + const c8 *pixelShaderProgram, + const c8 *pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, + const c8 *geometryShaderProgram, + const c8 *geometryShaderEntryPointName, + E_GEOMETRY_SHADER_TYPE gsCompileTarget, + scene::E_PRIMITIVE_TYPE inType, + scene::E_PRIMITIVE_TYPE outType, + u32 verticesOut, + IShaderConstantSetCallBack *callback, + E_MATERIAL_TYPE baseMaterial, + s32 userData) +{ + os::Printer::log("No shader support."); + return -1; +} + +//! Returns a pointer to the IVideoDriver interface. (Implementation for +//! IMaterialRendererServices) +IVideoDriver *COGLES1Driver::getVideoDriver() +{ + return this; +} + +//! Returns pointer to the IGPUProgrammingServices interface. +IGPUProgrammingServices *COGLES1Driver::getGPUProgrammingServices() +{ + return this; +} + +ITexture *COGLES1Driver::addRenderTargetTexture(const core::dimension2d &size, + const io::path &name, const ECOLOR_FORMAT format) +{ + // disable mip-mapping + bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS); + setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false); + + bool supportForFBO = (Feature.ColorAttachment > 0); + + core::dimension2du destSize(size); + + if (!supportForFBO) { + destSize = core::dimension2d(core::min_(size.Width, ScreenSize.Width), core::min_(size.Height, ScreenSize.Height)); + destSize = destSize.getOptimalSize((size == size.getOptimalSize()), false, false); + } + + COGLES1Texture *renderTargetTexture = new COGLES1Texture(name, destSize, ETT_2D, format, this); + addTexture(renderTargetTexture); + renderTargetTexture->drop(); + + // restore mip-mapping + setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, generateMipLevels); + + return renderTargetTexture; +} + +ITexture *COGLES1Driver::addRenderTargetTextureCubemap(const irr::u32 sideLen, const io::path &name, const ECOLOR_FORMAT format) +{ + // disable mip-mapping + bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS); + setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false); + + bool supportForFBO = (Feature.ColorAttachment > 0); + + const core::dimension2d size(sideLen, sideLen); + core::dimension2du destSize(size); + + if (!supportForFBO) { + destSize = core::dimension2d(core::min_(size.Width, ScreenSize.Width), core::min_(size.Height, ScreenSize.Height)); + destSize = destSize.getOptimalSize((size == size.getOptimalSize()), false, false); + } + + COGLES1Texture *renderTargetTexture = new COGLES1Texture(name, destSize, ETT_CUBEMAP, format, this); + addTexture(renderTargetTexture); + renderTargetTexture->drop(); + + // restore mip-mapping + setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, generateMipLevels); + + return renderTargetTexture; +} + +//! Returns the maximum amount of primitives +u32 COGLES1Driver::getMaximalPrimitiveCount() const +{ + return 65535; +} + +bool COGLES1Driver::setRenderTargetEx(IRenderTarget *target, u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil) +{ + if (target && target->getDriverType() != EDT_OGLES1) { + os::Printer::log("Fatal Error: Tried to set a render target not owned by OpenGL driver.", ELL_ERROR); + return false; + } + + bool supportForFBO = (Feature.ColorAttachment > 0); + + core::dimension2d destRenderTargetSize(0, 0); + + if (target) { + COGLES1RenderTarget *renderTarget = static_cast(target); + + if (supportForFBO) { + CacheHandler->setFBO(renderTarget->getBufferID()); + renderTarget->update(); + } + + destRenderTargetSize = renderTarget->getSize(); + + setViewPortRaw(destRenderTargetSize.Width, destRenderTargetSize.Height); + } else { + if (supportForFBO) + CacheHandler->setFBO(0); + else { + COGLES1RenderTarget *prevRenderTarget = static_cast(CurrentRenderTarget); + COGLES1Texture *renderTargetTexture = static_cast(prevRenderTarget->getTexture()); + + if (renderTargetTexture) { + const COGLES1Texture *prevTexture = CacheHandler->getTextureCache().get(0); + + CacheHandler->getTextureCache().set(0, renderTargetTexture); + + const core::dimension2d size = renderTargetTexture->getSize(); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, size.Width, size.Height); + + CacheHandler->getTextureCache().set(0, prevTexture); + } + } + + destRenderTargetSize = core::dimension2d(0, 0); + + setViewPortRaw(ScreenSize.Width, ScreenSize.Height); + } + + if (CurrentRenderTargetSize != destRenderTargetSize) { + CurrentRenderTargetSize = destRenderTargetSize; + + Transformation3DChanged = true; + } + + CurrentRenderTarget = target; + + if (!supportForFBO) { + clearFlag |= ECBF_COLOR; + clearFlag |= ECBF_DEPTH; + } + + clearBuffers(clearFlag, clearColor, clearDepth, clearStencil); + + return true; +} + +void COGLES1Driver::clearBuffers(u16 flag, SColor color, f32 depth, u8 stencil) +{ + GLbitfield mask = 0; + + if (flag & ECBF_COLOR) { + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + + const f32 inv = 1.0f / 255.0f; + glClearColor(color.getRed() * inv, color.getGreen() * inv, + color.getBlue() * inv, color.getAlpha() * inv); + + mask |= GL_COLOR_BUFFER_BIT; + } + + if (flag & ECBF_DEPTH) { + glDepthMask(GL_TRUE); + glClearDepthf(depth); + mask |= GL_DEPTH_BUFFER_BIT; + } + + if (flag & ECBF_STENCIL) { + glClearStencil(stencil); + mask |= GL_STENCIL_BUFFER_BIT; + } + + if (mask) + glClear(mask); +} + +//! Returns an image created from the last rendered frame. +// We want to read the front buffer to get the latest render finished. +// This is not possible under ogl-es, though, so one has to call this method +// outside of the render loop only. +IImage *COGLES1Driver::createScreenShot(video::ECOLOR_FORMAT format, video::E_RENDER_TARGET target) +{ + if (target == video::ERT_MULTI_RENDER_TEXTURES || target == video::ERT_RENDER_TEXTURE || target == video::ERT_STEREO_BOTH_BUFFERS) + return 0; + GLint internalformat = GL_RGBA; + GLint type = GL_UNSIGNED_BYTE; + if (false && (FeatureAvailable[COGLESCoreExtensionHandler::IRR_GL_IMG_read_format] || FeatureAvailable[COGLESCoreExtensionHandler::IRR_GL_OES_read_format] || FeatureAvailable[COGLESCoreExtensionHandler::IRR_GL_EXT_read_format_bgra])) { +#ifdef GL_IMPLEMENTATION_COLOR_READ_TYPE_OES + glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES, &internalformat); + glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES, &type); +#endif + // there are formats we don't support ATM + if (GL_UNSIGNED_SHORT_4_4_4_4 == type) + type = GL_UNSIGNED_SHORT_5_5_5_1; +#ifdef GL_EXT_read_format_bgra + else if (GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT == type) + type = GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT; +#endif + } + + IImage *newImage = 0; + if ((GL_RGBA == internalformat) +#ifdef GL_EXT_read_format_bgra + || (GL_BGRA_EXT == internalformat) +#endif + ) { + if (GL_UNSIGNED_BYTE == type) + newImage = new CImage(ECF_A8R8G8B8, ScreenSize); + else + newImage = new CImage(ECF_A1R5G5B5, ScreenSize); + } else { + if (GL_UNSIGNED_BYTE == type) + newImage = new CImage(ECF_R8G8B8, ScreenSize); + else + newImage = new CImage(ECF_R5G6B5, ScreenSize); + } + + u8 *pixels = static_cast(newImage->getData()); + if (!pixels) { + newImage->drop(); + return 0; + } + + glReadPixels(0, 0, ScreenSize.Width, ScreenSize.Height, internalformat, type, pixels); + + // opengl images are horizontally flipped, so we have to fix that here. + const s32 pitch = newImage->getPitch(); + u8 *p2 = pixels + (ScreenSize.Height - 1) * pitch; + u8 *tmpBuffer = new u8[pitch]; + for (u32 i = 0; i < ScreenSize.Height; i += 2) { + memcpy(tmpBuffer, pixels, pitch); + memcpy(pixels, p2, pitch); + memcpy(p2, tmpBuffer, pitch); + pixels += pitch; + p2 -= pitch; + } + delete[] tmpBuffer; + + if (testGLError(__LINE__)) { + newImage->drop(); + return 0; + } + + return newImage; +} + +void COGLES1Driver::removeTexture(ITexture *texture) +{ + CacheHandler->getTextureCache().remove(texture); + CNullDriver::removeTexture(texture); +} + +//! Set/unset a clipping plane. +bool COGLES1Driver::setClipPlane(u32 index, const core::plane3df &plane, bool enable) +{ + if (index >= MaxUserClipPlanes) + return false; + + UserClipPlane[index] = plane; + enableClipPlane(index, enable); + return true; +} + +void COGLES1Driver::uploadClipPlane(u32 index) +{ + // opengl needs an array of doubles for the plane equation + float clip_plane[4]; + clip_plane[0] = UserClipPlane[index].Normal.X; + clip_plane[1] = UserClipPlane[index].Normal.Y; + clip_plane[2] = UserClipPlane[index].Normal.Z; + clip_plane[3] = UserClipPlane[index].D; + glClipPlanef(GL_CLIP_PLANE0 + index, clip_plane); +} + +//! Enable/disable a clipping plane. +void COGLES1Driver::enableClipPlane(u32 index, bool enable) +{ + if (index >= MaxUserClipPlanes) + return; + if (enable) { + if (!UserClipPlaneEnabled[index]) { + uploadClipPlane(index); + glEnable(GL_CLIP_PLANE0 + index); + } + } else + glDisable(GL_CLIP_PLANE0 + index); + + UserClipPlaneEnabled[index] = enable; +} + +core::dimension2du COGLES1Driver::getMaxTextureSize() const +{ + return core::dimension2du(MaxTextureSize, MaxTextureSize); +} + +GLenum COGLES1Driver::getGLBlend(E_BLEND_FACTOR factor) const +{ + static GLenum const blendTable[] = { + GL_ZERO, + GL_ONE, + GL_DST_COLOR, + GL_ONE_MINUS_DST_COLOR, + GL_SRC_COLOR, + GL_ONE_MINUS_SRC_COLOR, + GL_SRC_ALPHA, + GL_ONE_MINUS_SRC_ALPHA, + GL_DST_ALPHA, + GL_ONE_MINUS_DST_ALPHA, + GL_SRC_ALPHA_SATURATE, + }; + + return blendTable[factor]; +} + +GLenum COGLES1Driver::getZBufferBits() const +{ + GLenum bits = 0; + + switch (Params.ZBufferBits) { + case 24: +#if defined(GL_OES_depth24) + if (queryGLESFeature(COGLESCoreExtensionHandler::IRR_GL_OES_depth24)) + bits = GL_DEPTH_COMPONENT24_OES; + else +#endif + bits = GL_DEPTH_COMPONENT16; + break; + case 32: +#if defined(GL_OES_depth32) + if (queryGLESFeature(COGLESCoreExtensionHandler::IRR_GL_OES_depth32)) + bits = GL_DEPTH_COMPONENT32_OES; + else +#endif + bits = GL_DEPTH_COMPONENT16; + break; + default: + bits = GL_DEPTH_COMPONENT16; + break; + } + + return bits; +} + +bool COGLES1Driver::getColorFormatParameters(ECOLOR_FORMAT format, GLint &internalFormat, GLenum &pixelFormat, + GLenum &pixelType, void (**converter)(const void *, s32, void *)) const +{ + bool supported = false; + internalFormat = GL_RGBA; + pixelFormat = GL_RGBA; + pixelType = GL_UNSIGNED_BYTE; + *converter = 0; + + switch (format) { + case ECF_A1R5G5B5: + supported = true; + internalFormat = GL_RGBA; + pixelFormat = GL_RGBA; + pixelType = GL_UNSIGNED_SHORT_5_5_5_1; + *converter = CColorConverter::convert_A1R5G5B5toR5G5B5A1; + break; + case ECF_R5G6B5: + supported = true; + internalFormat = GL_RGB; + pixelFormat = GL_RGB; + pixelType = GL_UNSIGNED_SHORT_5_6_5; + break; + case ECF_R8G8B8: + supported = true; + internalFormat = GL_RGB; + pixelFormat = GL_RGB; + pixelType = GL_UNSIGNED_BYTE; + break; + case ECF_A8R8G8B8: + supported = true; + if (queryGLESFeature(COGLESCoreExtensionHandler::IRR_GL_IMG_texture_format_BGRA8888) || + queryGLESFeature(COGLESCoreExtensionHandler::IRR_GL_EXT_texture_format_BGRA8888) || + queryGLESFeature(COGLESCoreExtensionHandler::IRR_GL_APPLE_texture_format_BGRA8888)) { + internalFormat = GL_BGRA; + pixelFormat = GL_BGRA; + } else { + internalFormat = GL_RGBA; + pixelFormat = GL_RGBA; + *converter = CColorConverter::convert_A8R8G8B8toA8B8G8R8; + } + pixelType = GL_UNSIGNED_BYTE; + break; + case ECF_D16: + supported = true; + internalFormat = GL_DEPTH_COMPONENT16; + pixelFormat = GL_DEPTH_COMPONENT; + pixelType = GL_UNSIGNED_SHORT; + break; + case ECF_D32: +#if defined(GL_OES_depth32) + if (queryGLESFeature(COGLESCoreExtensionHandler::IRR_GL_OES_depth32)) { + supported = true; + internalFormat = GL_DEPTH_COMPONENT32_OES; + pixelFormat = GL_DEPTH_COMPONENT; + pixelType = GL_UNSIGNED_INT; + } +#endif + break; + case ECF_D24S8: +#ifdef GL_OES_packed_depth_stencil + if (queryGLESFeature(COGLESCoreExtensionHandler::IRR_GL_OES_packed_depth_stencil)) { + supported = true; + internalFormat = GL_DEPTH24_STENCIL8_OES; + pixelFormat = GL_DEPTH_STENCIL_OES; + pixelType = GL_UNSIGNED_INT_24_8_OES; + } +#endif + break; + case ECF_R8: + break; + case ECF_R8G8: + break; + case ECF_R16: + break; + case ECF_R16G16: + break; + case ECF_R16F: + break; + case ECF_G16R16F: + break; + case ECF_A16B16G16R16F: + break; + case ECF_R32F: + break; + case ECF_G32R32F: + break; + case ECF_A32B32G32R32F: + break; + default: + break; + } + +#ifdef _IRR_IOS_PLATFORM_ + if (internalFormat == GL_BGRA) + internalFormat = GL_RGBA; +#endif + + return supported; +} + +bool COGLES1Driver::queryTextureFormat(ECOLOR_FORMAT format) const +{ + GLint dummyInternalFormat; + GLenum dummyPixelFormat; + GLenum dummyPixelType; + void (*dummyConverter)(const void *, s32, void *); + return getColorFormatParameters(format, dummyInternalFormat, dummyPixelFormat, dummyPixelType, &dummyConverter); +} + +bool COGLES1Driver::needsTransparentRenderPass(const irr::video::SMaterial &material) const +{ + return CNullDriver::needsTransparentRenderPass(material) || material.isAlphaBlendOperation(); +} + +COGLES1CacheHandler *COGLES1Driver::getCacheHandler() const +{ + return CacheHandler; +} + +} // end namespace +} // end namespace + +#endif // _IRR_COMPILE_WITH_OGLES1_ + +namespace irr +{ +namespace video +{ + +#ifndef _IRR_COMPILE_WITH_OGLES1_ +class IVideoDriver; +class IContextManager; +#endif + +IVideoDriver *createOGLES1Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager) +{ +#ifdef _IRR_COMPILE_WITH_OGLES1_ + return new COGLES1Driver(params, io, contextManager); +#else + return 0; +#endif // _IRR_COMPILE_WITH_OGLES1_ +} + +} // end namespace +} // end namespace diff --git a/irr/src/COGLESDriver.h b/irr/src/COGLESDriver.h new file mode 100644 index 000000000..82b4a1793 --- /dev/null +++ b/irr/src/COGLESDriver.h @@ -0,0 +1,325 @@ +// Copyright (C) 2002-20014 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#pragma once + +#include "SIrrCreationParameters.h" + +#ifdef _IRR_COMPILE_WITH_OGLES1_ + +#include "CNullDriver.h" +#include "IMaterialRendererServices.h" +#include "EDriverFeatures.h" +#include "fast_atof.h" +#include "COGLESExtensionHandler.h" +#include "IContextManager.h" + +namespace irr +{ +namespace video +{ + +class COGLES1Driver : public CNullDriver, public IMaterialRendererServices, public COGLES1ExtensionHandler +{ + friend class COpenGLCoreTexture; + +public: + //! constructor + COGLES1Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager); + + //! destructor + virtual ~COGLES1Driver(); + + virtual bool beginScene(u16 clearFlag, SColor clearColor = SColor(255, 0, 0, 0), f32 clearDepth = 1.f, u8 clearStencil = 0, + const SExposedVideoData &videoData = SExposedVideoData(), core::rect *sourceRect = 0) override; + + bool endScene() override; + + //! sets transformation + void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4 &mat) override; + + struct SHWBufferLink_opengl : public SHWBufferLink + { + SHWBufferLink_opengl(const scene::IMeshBuffer *_MeshBuffer) : + SHWBufferLink(_MeshBuffer), vbo_verticesID(0), vbo_indicesID(0) {} + + GLuint vbo_verticesID; // tmp + GLuint vbo_indicesID; // tmp + + GLuint vbo_verticesSize; // tmp + GLuint vbo_indicesSize; // tmp + }; + + bool updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer); + bool updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer); + + //! updates hardware buffer if needed + bool updateHardwareBuffer(SHWBufferLink *HWBuffer) override; + + //! Create hardware buffer from mesh + SHWBufferLink *createHardwareBuffer(const scene::IMeshBuffer *mb) override; + + //! Delete hardware buffer (only some drivers can) + void deleteHardwareBuffer(SHWBufferLink *HWBuffer) override; + + //! Draw hardware buffer + void drawHardwareBuffer(SHWBufferLink *HWBuffer) override; + + IRenderTarget *addRenderTarget() override; + + //! draws a vertex primitive list + virtual void drawVertexPrimitiveList(const void *vertices, u32 vertexCount, + const void *indexList, u32 primitiveCount, + E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) override; + + void drawVertexPrimitiveList2d3d(const void *vertices, u32 vertexCount, const void *indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType = EIT_16BIT, bool threed = true); + + //! queries the features of the driver, returns true if feature is available + bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const override + { + // return FeatureEnabled[feature] && COGLES1ExtensionHandler::queryFeature(feature); + return COGLES1ExtensionHandler::queryFeature(feature); + } + + //! Sets a material. + void setMaterial(const SMaterial &material) override; + + virtual void draw2DImage(const video::ITexture *texture, const core::position2d &destPos, + const core::rect &sourceRect, const core::rect *clipRect = 0, + SColor color = SColor(255, 255, 255, 255), bool useAlphaChannelOfTexture = false) override; + + virtual void draw2DImage(const video::ITexture *texture, const core::rect &destRect, + const core::rect &sourceRect, const core::rect *clipRect = 0, + const video::SColor *const colors = 0, bool useAlphaChannelOfTexture = false) override; + + virtual void draw2DImage(const video::ITexture *texture, u32 layer, bool flip); + + //! draws a set of 2d images, using a color and the alpha channel of the texture if desired. + virtual void draw2DImageBatch(const video::ITexture *texture, + const core::array> &positions, + const core::array> &sourceRects, + const core::rect *clipRect = 0, + SColor color = SColor(255, 255, 255, 255), + bool useAlphaChannelOfTexture = false) override; + + //! draw an 2d rectangle + virtual void draw2DRectangle(SColor color, const core::rect &pos, + const core::rect *clip = 0) override; + + //! Draws an 2d rectangle with a gradient. + virtual void draw2DRectangle(const core::rect &pos, + SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, + const core::rect *clip = 0) override; + + //! Draws a 2d line. + virtual void draw2DLine(const core::position2d &start, + const core::position2d &end, + SColor color = SColor(255, 255, 255, 255)) override; + + //! Draws a 3d line. + virtual void draw3DLine(const core::vector3df &start, + const core::vector3df &end, + SColor color = SColor(255, 255, 255, 255)) override; + + //! Returns the name of the video driver. + const char *getName() const override; + + //! Sets the dynamic ambient light color. + void setAmbientLight(const SColorf &color) override; + + //! sets a viewport + void setViewPort(const core::rect &area) override; + + //! Sets the fog mode. + virtual void setFog(SColor color, E_FOG_TYPE fogType, f32 start, + f32 end, f32 density, bool pixelFog, bool rangeFog) override; + + //! Only used internally by the engine + void OnResize(const core::dimension2d &size) override; + + //! Returns type of video driver + E_DRIVER_TYPE getDriverType() const override; + + //! get color format of the current color buffer + ECOLOR_FORMAT getColorFormat() const override; + + //! Returns the transformation set by setTransform + const core::matrix4 &getTransform(E_TRANSFORMATION_STATE state) const override; + + //! Can be called by an IMaterialRenderer to make its work easier. + virtual void setBasicRenderStates(const SMaterial &material, const SMaterial &lastmaterial, + bool resetAllRenderstates) override; + + //! Compare in SMaterial doesn't check texture parameters, so we should call this on each OnRender call. + virtual void setTextureRenderStates(const SMaterial &material, bool resetAllRenderstates); + + //! Get a vertex shader constant index. + s32 getVertexShaderConstantID(const c8 *name) override; + + //! Get a pixel shader constant index. + s32 getPixelShaderConstantID(const c8 *name) override; + + //! Sets a constant for the vertex shader based on an index. + bool setVertexShaderConstant(s32 index, const f32 *floats, int count) override; + + //! Int interface for the above. + bool setVertexShaderConstant(s32 index, const s32 *ints, int count) override; + + //! Uint interface for the above. + bool setVertexShaderConstant(s32 index, const u32 *ints, int count) override; + + //! Sets a constant for the pixel shader based on an index. + bool setPixelShaderConstant(s32 index, const f32 *floats, int count) override; + + //! Int interface for the above. + bool setPixelShaderConstant(s32 index, const s32 *ints, int count) override; + + //! Uint interface for the above. + bool setPixelShaderConstant(s32 index, const u32 *ints, int count) override; + + //! Adds a new material renderer to the VideoDriver + virtual s32 addHighLevelShaderMaterial(const c8 *vertexShaderProgram, const c8 *vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, const c8 *pixelShaderProgram, const c8 *pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, const c8 *geometryShaderProgram, const c8 *geometryShaderEntryPointName, + E_GEOMETRY_SHADER_TYPE gsCompileTarget, scene::E_PRIMITIVE_TYPE inType, scene::E_PRIMITIVE_TYPE outType, + u32 verticesOut, IShaderConstantSetCallBack *callback, E_MATERIAL_TYPE baseMaterial, + s32 userData) override; + + //! Returns pointer to the IGPUProgrammingServices interface. + IGPUProgrammingServices *getGPUProgrammingServices() override; + + //! Returns a pointer to the IVideoDriver interface. + IVideoDriver *getVideoDriver() override; + + //! Returns the maximum amount of primitives + u32 getMaximalPrimitiveCount() const override; + + virtual ITexture *addRenderTargetTexture(const core::dimension2d &size, + const io::path &name, const ECOLOR_FORMAT format = ECF_UNKNOWN) override; + + //! Creates a render target texture for a cubemap + ITexture *addRenderTargetTextureCubemap(const irr::u32 sideLen, + const io::path &name, const ECOLOR_FORMAT format) override; + + virtual bool setRenderTargetEx(IRenderTarget *target, u16 clearFlag, SColor clearColor = SColor(255, 0, 0, 0), + f32 clearDepth = 1.f, u8 clearStencil = 0) override; + + void clearBuffers(u16 flag, SColor color = SColor(255, 0, 0, 0), f32 depth = 1.f, u8 stencil = 0) override; + + //! Returns an image created from the last rendered frame. + IImage *createScreenShot(video::ECOLOR_FORMAT format = video::ECF_UNKNOWN, video::E_RENDER_TARGET target = video::ERT_FRAME_BUFFER) override; + + //! checks if an OpenGL error has happened and prints it (+ some internal code which is usually the line number) + bool testGLError(int code = 0); + + //! Set/unset a clipping plane. + bool setClipPlane(u32 index, const core::plane3df &plane, bool enable = false) override; + + //! Enable/disable a clipping plane. + void enableClipPlane(u32 index, bool enable) override; + + //! Returns the graphics card vendor name. + core::stringc getVendorInfo() override + { + return VendorName; + } + + //! Get the maximal texture size for this driver + core::dimension2du getMaxTextureSize() const override; + + void removeTexture(ITexture *texture) override; + + //! Check if the driver supports creating textures with the given color format + bool queryTextureFormat(ECOLOR_FORMAT format) const override; + + //! Used by some SceneNodes to check if a material should be rendered in the transparent render pass + bool needsTransparentRenderPass(const irr::video::SMaterial &material) const override; + + //! Convert E_BLEND_FACTOR to OpenGL equivalent + GLenum getGLBlend(E_BLEND_FACTOR factor) const; + + //! Get ZBuffer bits. + GLenum getZBufferBits() const; + + bool getColorFormatParameters(ECOLOR_FORMAT format, GLint &internalFormat, GLenum &pixelFormat, + GLenum &pixelType, void (**converter)(const void *, s32, void *)) const; + + COGLES1CacheHandler *getCacheHandler() const; + +private: + void uploadClipPlane(u32 index); + + //! inits the opengl-es driver + bool genericDriverInit(const core::dimension2d &screenSize, bool stencilBuffer); + + ITexture *createDeviceDependentTexture(const io::path &name, IImage *image) override; + + ITexture *createDeviceDependentTextureCubemap(const io::path &name, const core::array &image) override; + + //! creates a transposed matrix in supplied GLfloat array to pass to OGLES1 + inline void getGLMatrix(GLfloat gl_matrix[16], const core::matrix4 &m); + inline void getGLTextureMatrix(GLfloat gl_matrix[16], const core::matrix4 &m); + + //! Set GL pipeline to desired texture wrap modes of the material + void setWrapMode(const SMaterial &material); + + //! Get OpenGL wrap enum from Irrlicht enum + GLint getTextureWrapMode(u8 clamp) const; + + //! sets the needed renderstates + void setRenderStates3DMode(); + + //! sets the needed renderstates + void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel); + + void createMaterialRenderers(); + + //! Assign a hardware light to the specified requested light, if any + //! free hardware lights exist. + //! \param[in] lightIndex: the index of the requesting light + void assignHardwareLight(u32 lightIndex); + + //! Same as `CacheHandler->setViewport`, but also sets `ViewPort` + virtual void setViewPortRaw(u32 width, u32 height); + + COGLES1CacheHandler *CacheHandler; + + core::stringc Name; + core::matrix4 Matrices[ETS_COUNT]; + core::array ColorBuffer; + + //! enumeration for rendering modes such as 2d and 3d for minimizing the switching of renderStates. + enum E_RENDER_MODE + { + ERM_NONE = 0, // no render state has been set yet. + ERM_2D, // 2d drawing rendermode + ERM_3D // 3d rendering mode + }; + + E_RENDER_MODE CurrentRenderMode; + //! bool to make all renderstates reset if set to true. + bool ResetRenderStates; + bool Transformation3DChanged; + u8 AntiAlias; + + SMaterial Material, LastMaterial; + core::array UserClipPlane; + std::vector UserClipPlaneEnabled; + + core::stringc VendorName; + + core::matrix4 TextureFlipMatrix; + + //! Color buffer format + ECOLOR_FORMAT ColorFormat; + + SIrrlichtCreationParameters Params; + + IContextManager *ContextManager; +}; + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_OGLES1_ diff --git a/irr/src/COGLESExtensionHandler.cpp b/irr/src/COGLESExtensionHandler.cpp new file mode 100644 index 000000000..ba2c0c9bf --- /dev/null +++ b/irr/src/COGLESExtensionHandler.cpp @@ -0,0 +1,94 @@ +// Copyright (C) 2008 Christian Stehno +// Heavily based on the OpenGL driver implemented by Nikolaus Gebhardt +// 2017 modified by Michael Zeilfelder (unifying extension handlers) +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#include "COGLESExtensionHandler.h" + +#ifdef _IRR_COMPILE_WITH_OGLES1_ + +#include "irrString.h" +#include "SMaterial.h" +#include "fast_atof.h" + +#if defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_) || defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) +#include +#else +#include +#endif + +namespace irr +{ +namespace video +{ + +COGLES1ExtensionHandler::COGLES1ExtensionHandler() : + COGLESCoreExtensionHandler(), + MaxUserClipPlanes(0), MaxLights(0), pGlBlendEquationOES(0), pGlBlendFuncSeparateOES(0), + pGlBindFramebufferOES(0), pGlDeleteFramebuffersOES(0), + pGlGenFramebuffersOES(0), pGlCheckFramebufferStatusOES(0), + pGlFramebufferTexture2DOES(0), pGlGenerateMipmapOES(0) +{ +} + +void COGLES1ExtensionHandler::initExtensions() +{ + getGLVersion(); + + if (Version >= 100) + os::Printer::log("OpenGL ES driver version is 1.1.", ELL_INFORMATION); + else + os::Printer::log("OpenGL ES driver version is 1.0.", ELL_WARNING); + + getGLExtensions(); + + GLint val = 0; + + if (Version > 100 || FeatureAvailable[IRR_GL_IMG_user_clip_plane]) { + glGetIntegerv(GL_MAX_CLIP_PLANES, &val); + MaxUserClipPlanes = static_cast(val); + } + + glGetIntegerv(GL_MAX_LIGHTS, &val); + MaxLights = static_cast(val); + + glGetIntegerv(GL_MAX_TEXTURE_UNITS, &val); + Feature.MaxTextureUnits = static_cast(val); + +#ifdef GL_EXT_texture_filter_anisotropic + if (FeatureAvailable[IRR_GL_EXT_texture_filter_anisotropic]) { + glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &val); + MaxAnisotropy = static_cast(val); + } +#endif +#ifdef GL_MAX_ELEMENTS_INDICES + glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &val); + MaxIndices = val; +#endif + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &val); + MaxTextureSize = static_cast(val); +#ifdef GL_EXT_texture_lod_bias + if (FeatureAvailable[IRR_GL_EXT_texture_lod_bias]) + glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS_EXT, &MaxTextureLODBias); +#endif + glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine); + glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint); + + Feature.MaxTextureUnits = core::min_(Feature.MaxTextureUnits, static_cast(MATERIAL_MAX_TEXTURES)); + Feature.ColorAttachment = 1; + + pGlBlendEquationOES = (PFNGLBLENDEQUATIONOESPROC)eglGetProcAddress("glBlendEquationOES"); + pGlBlendFuncSeparateOES = (PFNGLBLENDFUNCSEPARATEOESPROC)eglGetProcAddress("glBlendFuncSeparateOES"); + pGlBindFramebufferOES = (PFNGLBINDFRAMEBUFFEROESPROC)eglGetProcAddress("glBindFramebufferOES"); + pGlDeleteFramebuffersOES = (PFNGLDELETEFRAMEBUFFERSOESPROC)eglGetProcAddress("glDeleteFramebuffersOES"); + pGlGenFramebuffersOES = (PFNGLGENFRAMEBUFFERSOESPROC)eglGetProcAddress("glGenFramebuffersOES"); + pGlCheckFramebufferStatusOES = (PFNGLCHECKFRAMEBUFFERSTATUSOESPROC)eglGetProcAddress("glCheckFramebufferStatusOES"); + pGlFramebufferTexture2DOES = (PFNGLFRAMEBUFFERTEXTURE2DOESPROC)eglGetProcAddress("glFramebufferTexture2DOES"); + pGlGenerateMipmapOES = (PFNGLGENERATEMIPMAPOESPROC)eglGetProcAddress("glGenerateMipmapOES"); +} + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_OGLES2_ diff --git a/irr/src/COGLESExtensionHandler.h b/irr/src/COGLESExtensionHandler.h new file mode 100644 index 000000000..d9e1ac4bc --- /dev/null +++ b/irr/src/COGLESExtensionHandler.h @@ -0,0 +1,190 @@ +// Copyright (C) 2008 Christian Stehno +// Heavily based on the OpenGL driver implemented by Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#pragma once + +#ifdef _IRR_COMPILE_WITH_OGLES1_ + +#include "EDriverFeatures.h" +#include "irrTypes.h" +#include "os.h" + +#include "COGLESCommon.h" + +#include "COGLESCoreExtensionHandler.h" + +namespace irr +{ +namespace video +{ + +class COGLES1ExtensionHandler : public COGLESCoreExtensionHandler +{ +public: + COGLES1ExtensionHandler(); + + void initExtensions(); + + bool queryFeature(video::E_VIDEO_DRIVER_FEATURE feature) const + { + switch (feature) { + case EVDF_RENDER_TO_TARGET: + case EVDF_HARDWARE_TL: + case EVDF_MULTITEXTURE: + case EVDF_BILINEAR_FILTER: + case EVDF_MIP_MAP: + case EVDF_TEXTURE_NSQUARE: + case EVDF_STENCIL_BUFFER: + case EVDF_ALPHA_TO_COVERAGE: + case EVDF_COLOR_MASK: + case EVDF_POLYGON_OFFSET: + case EVDF_TEXTURE_MATRIX: + return true; + case EVDF_TEXTURE_NPOT: + return FeatureAvailable[IRR_GL_APPLE_texture_2D_limited_npot] || FeatureAvailable[IRR_GL_OES_texture_npot]; + case EVDF_MIP_MAP_AUTO_UPDATE: + return Version > 100; + case EVDF_BLEND_OPERATIONS: + return FeatureAvailable[IRR_GL_OES_blend_subtract]; + case EVDF_BLEND_SEPARATE: + return FeatureAvailable[IRR_GL_OES_blend_func_separate]; + case EVDF_FRAMEBUFFER_OBJECT: + return FeatureAvailable[IRR_GL_OES_framebuffer_object]; + case EVDF_VERTEX_BUFFER_OBJECT: + return Version > 100; + default: + return true; + }; + } + + inline void irrGlActiveTexture(GLenum texture) + { + glActiveTexture(texture); + } + + inline void irrGlCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, + GLsizei imageSize, const void *data) + { + glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); + } + + inline void irrGlCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + GLenum format, GLsizei imageSize, const void *data) + { + glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); + } + + inline void irrGlUseProgram(GLuint prog) + { + } + + inline void irrGlBindFramebuffer(GLenum target, GLuint framebuffer) + { + if (pGlBindFramebufferOES) + pGlBindFramebufferOES(target, framebuffer); + } + + inline void irrGlDeleteFramebuffers(GLsizei n, const GLuint *framebuffers) + { + if (pGlDeleteFramebuffersOES) + pGlDeleteFramebuffersOES(n, framebuffers); + } + + inline void irrGlGenFramebuffers(GLsizei n, GLuint *framebuffers) + { + if (pGlGenFramebuffersOES) + pGlGenFramebuffersOES(n, framebuffers); + } + + inline GLenum irrGlCheckFramebufferStatus(GLenum target) + { + if (pGlCheckFramebufferStatusOES) + return pGlCheckFramebufferStatusOES(target); + else + return 0; + } + + inline void irrGlFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) + { + if (pGlFramebufferTexture2DOES) + pGlFramebufferTexture2DOES(target, attachment, textarget, texture, level); + } + + inline void irrGlGenerateMipmap(GLenum target) + { + if (pGlGenerateMipmapOES) + pGlGenerateMipmapOES(target); + } + + inline void irrGlActiveStencilFace(GLenum face) + { + } + + inline void irrGlDrawBuffer(GLenum mode) + { + } + + inline void irrGlDrawBuffers(GLsizei n, const GLenum *bufs) + { + } + + inline void irrGlBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) + { + if (pGlBlendFuncSeparateOES) + pGlBlendFuncSeparateOES(srcRGB, dstRGB, srcAlpha, dstAlpha); + } + + inline void irrGlBlendEquation(GLenum mode) + { + if (pGlBlendEquationOES) + pGlBlendEquationOES(mode); + } + + inline void irrGlEnableIndexed(GLenum target, GLuint index) + { + } + + inline void irrGlDisableIndexed(GLenum target, GLuint index) + { + } + + inline void irrGlColorMaskIndexed(GLuint buf, GLboolean r, GLboolean g, GLboolean b, GLboolean a) + { + } + + inline void irrGlBlendFuncIndexed(GLuint buf, GLenum src, GLenum dst) + { + } + + inline void irrGlBlendFuncSeparateIndexed(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) + { + } + + inline void irrGlBlendEquationIndexed(GLuint buf, GLenum mode) + { + } + + inline void irrGlBlendEquationSeparateIndexed(GLuint buf, GLenum modeRGB, GLenum modeAlpha) + { + } + +protected: + u8 MaxUserClipPlanes; + u8 MaxLights; + + PFNGLBLENDEQUATIONOESPROC pGlBlendEquationOES; + PFNGLBLENDFUNCSEPARATEOESPROC pGlBlendFuncSeparateOES; + PFNGLBINDFRAMEBUFFEROESPROC pGlBindFramebufferOES; + PFNGLDELETEFRAMEBUFFERSOESPROC pGlDeleteFramebuffersOES; + PFNGLGENFRAMEBUFFERSOESPROC pGlGenFramebuffersOES; + PFNGLCHECKFRAMEBUFFERSTATUSOESPROC pGlCheckFramebufferStatusOES; + PFNGLFRAMEBUFFERTEXTURE2DOESPROC pGlFramebufferTexture2DOES; + PFNGLGENERATEMIPMAPOESPROC pGlGenerateMipmapOES; +}; + +} +} + +#endif diff --git a/irr/src/COGLESMaterialRenderer.h b/irr/src/COGLESMaterialRenderer.h new file mode 100644 index 000000000..69d1b81ff --- /dev/null +++ b/irr/src/COGLESMaterialRenderer.h @@ -0,0 +1,286 @@ +// Copyright (C) 2002-2008 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#ifdef _IRR_COMPILE_WITH_OGLES1_ + +#include "COGLESDriver.h" +#include "IMaterialRenderer.h" + +namespace irr +{ +namespace video +{ + +//! Base class for all internal OGLES1 material renderers +class COGLES1MaterialRenderer : public IMaterialRenderer +{ +public: + //! Constructor + COGLES1MaterialRenderer(video::COGLES1Driver *driver) : + Driver(driver) + { + } + +protected: + video::COGLES1Driver *Driver; +}; + +//! Solid material renderer +class COGLES1MaterialRenderer_SOLID : public COGLES1MaterialRenderer +{ +public: + COGLES1MaterialRenderer_SOLID(video::COGLES1Driver *d) : + COGLES1MaterialRenderer(d) {} + + virtual void OnSetMaterial(const SMaterial &material, const SMaterial &lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices *services) + { + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + if (resetAllRenderstates || (material.MaterialType != lastMaterial.MaterialType)) { + // thanks to Murphy, the following line removed some + // bugs with several OGLES1 implementations. + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + } + } +}; + +//! Generic Texture Blend +class COGLES1MaterialRenderer_ONETEXTURE_BLEND : public COGLES1MaterialRenderer +{ +public: + COGLES1MaterialRenderer_ONETEXTURE_BLEND(video::COGLES1Driver *d) : + COGLES1MaterialRenderer(d) {} + + virtual void OnSetMaterial(const SMaterial &material, const SMaterial &lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices *services) + { + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + // if (material.MaterialType != lastMaterial.MaterialType || + // material.MaterialTypeParam != lastMaterial.MaterialTypeParam || + // resetAllRenderstates) + { + E_BLEND_FACTOR srcRGBFact, dstRGBFact, srcAlphaFact, dstAlphaFact; + E_MODULATE_FUNC modulate; + u32 alphaSource; + unpack_textureBlendFuncSeparate(srcRGBFact, dstRGBFact, srcAlphaFact, dstAlphaFact, modulate, alphaSource, material.MaterialTypeParam); + + Driver->getCacheHandler()->setBlend(true); + + if (Driver->queryFeature(EVDF_BLEND_SEPARATE)) { + Driver->getCacheHandler()->setBlendFuncSeparate(Driver->getGLBlend(srcRGBFact), Driver->getGLBlend(dstRGBFact), + Driver->getGLBlend(srcAlphaFact), Driver->getGLBlend(dstAlphaFact)); + } else { + Driver->getCacheHandler()->setBlendFunc(Driver->getGLBlend(srcRGBFact), Driver->getGLBlend(dstRGBFact)); + } + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE); + glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS); + + glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, (f32)modulate); + + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER, 0.f); + + if (textureBlendFunc_hasAlpha(srcRGBFact) || textureBlendFunc_hasAlpha(dstRGBFact) || + textureBlendFunc_hasAlpha(srcAlphaFact) || textureBlendFunc_hasAlpha(dstAlphaFact)) { + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); + glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_TEXTURE); + + glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PRIMARY_COLOR); + } + } + } + + virtual void OnUnsetMaterial() + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, 1.f); + glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS); + + Driver->getCacheHandler()->setBlend(false); + glDisable(GL_ALPHA_TEST); + } + + //! Returns if the material is transparent. + /** Is not always transparent, but mostly. */ + virtual bool isTransparent() const + { + return true; + } + +private: + u32 getGLBlend(E_BLEND_FACTOR factor) const + { + u32 r = 0; + switch (factor) { + case EBF_ZERO: + r = GL_ZERO; + break; + case EBF_ONE: + r = GL_ONE; + break; + case EBF_DST_COLOR: + r = GL_DST_COLOR; + break; + case EBF_ONE_MINUS_DST_COLOR: + r = GL_ONE_MINUS_DST_COLOR; + break; + case EBF_SRC_COLOR: + r = GL_SRC_COLOR; + break; + case EBF_ONE_MINUS_SRC_COLOR: + r = GL_ONE_MINUS_SRC_COLOR; + break; + case EBF_SRC_ALPHA: + r = GL_SRC_ALPHA; + break; + case EBF_ONE_MINUS_SRC_ALPHA: + r = GL_ONE_MINUS_SRC_ALPHA; + break; + case EBF_DST_ALPHA: + r = GL_DST_ALPHA; + break; + case EBF_ONE_MINUS_DST_ALPHA: + r = GL_ONE_MINUS_DST_ALPHA; + break; + case EBF_SRC_ALPHA_SATURATE: + r = GL_SRC_ALPHA_SATURATE; + break; + } + return r; + } +}; + +//! Transparent vertex alpha material renderer +class COGLES1MaterialRenderer_TRANSPARENT_VERTEX_ALPHA : public COGLES1MaterialRenderer +{ +public: + COGLES1MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(video::COGLES1Driver *d) : + COGLES1MaterialRenderer(d) {} + + virtual void OnSetMaterial(const SMaterial &material, const SMaterial &lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices *services) + { + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + Driver->getCacheHandler()->setBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + Driver->getCacheHandler()->setBlend(true); + + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) { + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); + glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PRIMARY_COLOR); + + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PRIMARY_COLOR); + glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_TEXTURE); + } + } + + virtual void OnUnsetMaterial() + { + // default values + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_TEXTURE); + glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_PREVIOUS); + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE); + glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS); + + Driver->getCacheHandler()->setBlend(false); + } + + //! Returns if the material is transparent. + virtual bool isTransparent() const + { + return true; + } +}; + +//! Transparent alpha channel material renderer +class COGLES1MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL : public COGLES1MaterialRenderer +{ +public: + COGLES1MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(video::COGLES1Driver *d) : + COGLES1MaterialRenderer(d) {} + + virtual void OnSetMaterial(const SMaterial &material, const SMaterial &lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices *services) + { + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + Driver->getCacheHandler()->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + Driver->getCacheHandler()->setBlend(true); + + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates || material.MaterialTypeParam != lastMaterial.MaterialTypeParam) { + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE); + glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS); + + glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); + glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_TEXTURE); + + glEnable(GL_ALPHA_TEST); + + glAlphaFunc(GL_GREATER, material.MaterialTypeParam); + } + } + + virtual void OnUnsetMaterial() + { + glDisable(GL_ALPHA_TEST); + Driver->getCacheHandler()->setBlend(false); + } + + //! Returns if the material is transparent. + virtual bool isTransparent() const + { + return true; + } +}; + +//! Transparent alpha channel material renderer +class COGLES1MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF : public COGLES1MaterialRenderer +{ +public: + COGLES1MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(video::COGLES1Driver *d) : + COGLES1MaterialRenderer(d) {} + + virtual void OnSetMaterial(const SMaterial &material, const SMaterial &lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices *services) + { + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) { + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER, 0.5f); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + } + } + + virtual void OnUnsetMaterial() + { + glDisable(GL_ALPHA_TEST); + } + + //! Returns if the material is transparent. + virtual bool isTransparent() const + { + return false; // this material is not really transparent because it does no blending. + } +}; + +} // end namespace video +} // end namespace irr + +#endif diff --git a/irr/src/COSOperator.cpp b/irr/src/COSOperator.cpp new file mode 100644 index 000000000..b26463799 --- /dev/null +++ b/irr/src/COSOperator.cpp @@ -0,0 +1,268 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "COSOperator.h" + +#ifdef _IRR_WINDOWS_API_ +#include +#else +#include +#include +#ifndef _IRR_ANDROID_PLATFORM_ +#include +#ifdef _IRR_OSX_PLATFORM_ +#include +#endif +#endif +#endif + +#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) +#include +#include +#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) +#include "CIrrDeviceLinux.h" +#endif +#if defined(_IRR_COMPILE_WITH_OSX_DEVICE_) +#import +#endif + +#include "fast_atof.h" + +#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) +static const bool sdl_supports_primary_selection = [] { +#if SDL_VERSION_ATLEAST(2, 25, 0) + SDL_version linked_version; + SDL_GetVersion(&linked_version); + return (linked_version.major == 2 && linked_version.minor >= 25) || linked_version.major > 2; +#else + return false; +#endif +}(); +#endif + +namespace irr +{ + +#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) +// constructor linux +COSOperator::COSOperator(const core::stringc &osVersion, CIrrDeviceLinux *device) : + OperatingSystem(osVersion), IrrDeviceLinux(device) +{ +} +#endif + +// constructor +COSOperator::COSOperator(const core::stringc &osVersion) : + OperatingSystem(osVersion) +{ +#ifdef _DEBUG + setDebugName("COSOperator"); +#endif +} + +COSOperator::~COSOperator() +{ +#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ + SDL_free(ClipboardSelectionText); + SDL_free(PrimarySelectionText); +#endif +} + +//! returns the current operating system version as string. +const core::stringc &COSOperator::getOperatingSystemVersion() const +{ + return OperatingSystem; +} + +//! copies text to the clipboard +void COSOperator::copyToClipboard(const c8 *text) const +{ + if (strlen(text) == 0) + return; + +#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) + SDL_SetClipboardText(text); + +#elif defined(_IRR_WINDOWS_API_) + if (!OpenClipboard(NULL) || text == 0) + return; + + EmptyClipboard(); + + core::stringw tempbuffer; + core::utf8ToWString(tempbuffer, text); + const u32 size = (tempbuffer.size() + 1) * sizeof(wchar_t); + + HGLOBAL clipbuffer; + void *buffer; + + clipbuffer = GlobalAlloc(GMEM_MOVEABLE, size); + buffer = GlobalLock(clipbuffer); + + memcpy(buffer, tempbuffer.c_str(), size); + + GlobalUnlock(clipbuffer); + SetClipboardData(CF_UNICODETEXT, clipbuffer); + CloseClipboard(); + +#elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_) + NSString *str = nil; + NSPasteboard *board = nil; + + if ((text != NULL) && (strlen(text) > 0)) { + str = [NSString stringWithCString:text encoding:NSUTF8StringEncoding]; + board = [NSPasteboard generalPasteboard]; + [board declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:NSApp]; + [board setString:str forType:NSStringPboardType]; + } + +#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) + if (IrrDeviceLinux) + IrrDeviceLinux->copyToClipboard(text); +#endif +} + +//! copies text to the primary selection +void COSOperator::copyToPrimarySelection(const c8 *text) const +{ + if (strlen(text) == 0) + return; + +#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) +#if SDL_VERSION_ATLEAST(2, 25, 0) + if (sdl_supports_primary_selection) + SDL_SetPrimarySelectionText(text); +#endif + +#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) + if (IrrDeviceLinux) + IrrDeviceLinux->copyToPrimarySelection(text); +#endif +} + +//! gets text from the clipboard +const c8 *COSOperator::getTextFromClipboard() const +{ +#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) + SDL_free(ClipboardSelectionText); + ClipboardSelectionText = SDL_GetClipboardText(); + return ClipboardSelectionText; + +#elif defined(_IRR_WINDOWS_API_) + if (!OpenClipboard(NULL)) + return 0; + + HANDLE hData = GetClipboardData(CF_UNICODETEXT); + if (hData == NULL) // Probably not in Unicode text format + return 0; + + wchar_t *buffer = (wchar_t *)GlobalLock(hData); + + core::wStringToUTF8(ClipboardBuf, buffer); + + GlobalUnlock(hData); + CloseClipboard(); + + return ClipboardBuf.c_str(); + +#elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_) + NSString *str = nil; + NSPasteboard *board = nil; + char *result = 0; + + board = [NSPasteboard generalPasteboard]; + str = [board stringForType:NSStringPboardType]; + + if (str != nil) + result = (char *)[str cStringUsingEncoding:NSUTF8StringEncoding]; + + return (result); + +#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) + if (IrrDeviceLinux) + return IrrDeviceLinux->getTextFromClipboard(); + return 0; + +#else + + return 0; +#endif +} + +//! gets text from the primary selection +const c8 *COSOperator::getTextFromPrimarySelection() const +{ +#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) +#if SDL_VERSION_ATLEAST(2, 25, 0) + if (sdl_supports_primary_selection) { + SDL_free(PrimarySelectionText); + PrimarySelectionText = SDL_GetPrimarySelectionText(); + return PrimarySelectionText; + } +#endif + return 0; + +#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) + if (IrrDeviceLinux) + return IrrDeviceLinux->getTextFromPrimarySelection(); + return 0; + +#else + + return 0; +#endif +} + +bool COSOperator::getSystemMemory(u32 *Total, u32 *Avail) const +{ +#if defined(_IRR_WINDOWS_API_) + + MEMORYSTATUSEX MemoryStatusEx; + MemoryStatusEx.dwLength = sizeof(MEMORYSTATUSEX); + + // cannot fail + GlobalMemoryStatusEx(&MemoryStatusEx); + + if (Total) + *Total = (u32)(MemoryStatusEx.ullTotalPhys >> 10); + if (Avail) + *Avail = (u32)(MemoryStatusEx.ullAvailPhys >> 10); + return true; + +#elif defined(_IRR_POSIX_API_) && defined(_SC_PHYS_PAGES) && defined(_SC_AVPHYS_PAGES) + long ps = sysconf(_SC_PAGESIZE); + long pp = sysconf(_SC_PHYS_PAGES); + long ap = sysconf(_SC_AVPHYS_PAGES); + + if (ps == -1 || (Total && pp == -1) || (Avail && ap == -1)) + return false; + + if (Total) + *Total = (u32)((pp >> 10) * ps); + if (Avail) + *Avail = (u32)((ap >> 10) * ps); + return true; +#elif defined(_IRR_OSX_PLATFORM_) + int mib[2]; + int64_t physical_memory; + size_t length; + + // Get the Physical memory size + mib[0] = CTL_HW; + mib[1] = HW_MEMSIZE; + length = sizeof(int64_t); + sysctl(mib, 2, &physical_memory, &length, NULL, 0); + + if (Total) + *Total = (u32)(physical_memory >> 10); + if (Avail) + *Avail = (u32)(physical_memory >> 10); // we don't know better + return true; +#else + // TODO: implement for others + return false; +#endif +} + +} // end namespace diff --git a/irr/src/COSOperator.h b/irr/src/COSOperator.h new file mode 100644 index 000000000..c1059bffc --- /dev/null +++ b/irr/src/COSOperator.h @@ -0,0 +1,74 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IOSOperator.h" + +namespace irr +{ + +class CIrrDeviceLinux; + +//! The OSOperator provides OS-specific methods and information. +class COSOperator : public IOSOperator +{ +public: + // constructor +#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) + COSOperator(const core::stringc &osversion, CIrrDeviceLinux *device); +#endif + COSOperator(const core::stringc &osversion); + + ~COSOperator(); + + COSOperator(const COSOperator &) = delete; + COSOperator &operator=(const COSOperator &) = delete; + + //! Get the current OS version as string. + const core::stringc &getOperatingSystemVersion() const override; + + //! Copies text to the clipboard + //! \param text: text in utf-8 + void copyToClipboard(const c8 *text) const override; + + //! Copies text to the primary selection + //! This is a no-op on some platforms. + //! \param text: text in utf-8 + void copyToPrimarySelection(const c8 *text) const override; + + //! Get text from the clipboard + //! \return Returns 0 if no string is in there, otherwise an utf-8 string. + const c8 *getTextFromClipboard() const override; + + //! Get text from the primary selection + //! This is a no-op on some platforms. + //! \return Returns 0 if no string is in there, otherwise an utf-8 string. + const c8 *getTextFromPrimarySelection() const override; + + //! Get the total and available system RAM + /** \param totalBytes: will contain the total system memory in Kilobytes (1024 B) + \param availableBytes: will contain the available memory in Kilobytes (1024 B) + \return True if successful, false if not */ + bool getSystemMemory(u32 *Total, u32 *Avail) const override; + +private: + core::stringc OperatingSystem; + +#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) + CIrrDeviceLinux *IrrDeviceLinux; +#endif + +#ifdef _IRR_WINDOWS_API_ + mutable core::stringc ClipboardBuf; +#endif + +#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ + // These need to be freed with SDL_free + mutable char *ClipboardSelectionText = nullptr; + mutable char *PrimarySelectionText = nullptr; +#endif +}; + +} // end namespace diff --git a/irr/src/COpenGLCacheHandler.cpp b/irr/src/COpenGLCacheHandler.cpp new file mode 100644 index 000000000..577967c56 --- /dev/null +++ b/irr/src/COpenGLCacheHandler.cpp @@ -0,0 +1,123 @@ +// Copyright (C) 2015 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#include "COpenGLCacheHandler.h" + +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#include "COpenGLDriver.h" + +namespace irr +{ +namespace video +{ + +/* COpenGLCacheHandler */ + +COpenGLCacheHandler::COpenGLCacheHandler(COpenGLDriver *driver) : + COpenGLCoreCacheHandler(driver), AlphaMode(GL_ALWAYS), AlphaRef(0.f), AlphaTest(false), + MatrixMode(GL_MODELVIEW), ClientActiveTexture(GL_TEXTURE0), ClientStateVertex(false), + ClientStateNormal(false), ClientStateColor(false), ClientStateTexCoord0(false) +{ + // Initial OpenGL values from specification. + + glAlphaFunc(AlphaMode, AlphaRef); + glDisable(GL_ALPHA_TEST); + + glMatrixMode(MatrixMode); + + Driver->irrGlClientActiveTexture(ClientActiveTexture); + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); +} + +COpenGLCacheHandler::~COpenGLCacheHandler() +{ +} + +void COpenGLCacheHandler::setAlphaFunc(GLenum mode, GLclampf ref) +{ + if (AlphaMode != mode || AlphaRef != ref) { + glAlphaFunc(mode, ref); + + AlphaMode = mode; + AlphaRef = ref; + } +} + +void COpenGLCacheHandler::setAlphaTest(bool enable) +{ + if (AlphaTest != enable) { + if (enable) + glEnable(GL_ALPHA_TEST); + else + glDisable(GL_ALPHA_TEST); + AlphaTest = enable; + } +} + +void COpenGLCacheHandler::setClientState(bool vertex, bool normal, bool color, bool texCoord0) +{ + if (ClientStateVertex != vertex) { + if (vertex) + glEnableClientState(GL_VERTEX_ARRAY); + else + glDisableClientState(GL_VERTEX_ARRAY); + + ClientStateVertex = vertex; + } + + if (ClientStateNormal != normal) { + if (normal) + glEnableClientState(GL_NORMAL_ARRAY); + else + glDisableClientState(GL_NORMAL_ARRAY); + + ClientStateNormal = normal; + } + + if (ClientStateColor != color) { + if (color) + glEnableClientState(GL_COLOR_ARRAY); + else + glDisableClientState(GL_COLOR_ARRAY); + + ClientStateColor = color; + } + + if (ClientStateTexCoord0 != texCoord0) { + setClientActiveTexture(GL_TEXTURE0_ARB); + + if (texCoord0) + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + else + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + + ClientStateTexCoord0 = texCoord0; + } +} + +void COpenGLCacheHandler::setMatrixMode(GLenum mode) +{ + if (MatrixMode != mode) { + glMatrixMode(mode); + MatrixMode = mode; + } +} + +void COpenGLCacheHandler::setClientActiveTexture(GLenum texture) +{ + if (ClientActiveTexture != texture) { + Driver->irrGlClientActiveTexture(texture); + ClientActiveTexture = texture; + } +} + +} // end namespace +} // end namespace + +#endif // _IRR_COMPILE_WITH_OPENGL_ diff --git a/irr/src/COpenGLCacheHandler.h b/irr/src/COpenGLCacheHandler.h new file mode 100644 index 000000000..968e452d7 --- /dev/null +++ b/irr/src/COpenGLCacheHandler.h @@ -0,0 +1,62 @@ +// Copyright (C) 2015 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#pragma once + +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#include "COpenGLCommon.h" + +#include "COpenGLCoreFeature.h" +#include "COpenGLCoreTexture.h" +#include "COpenGLCoreCacheHandler.h" + +namespace irr +{ +namespace video +{ + +class COpenGLCacheHandler : public COpenGLCoreCacheHandler +{ +public: + COpenGLCacheHandler(COpenGLDriver *driver); + virtual ~COpenGLCacheHandler(); + + // Alpha calls. + + void setAlphaFunc(GLenum mode, GLclampf ref); + + void setAlphaTest(bool enable); + + // Client state calls. + + void setClientState(bool vertex, bool normal, bool color, bool texCoord0); + + // Matrix calls. + + void setMatrixMode(GLenum mode); + + // Texture calls. + + void setClientActiveTexture(GLenum texture); + +protected: + GLenum AlphaMode; + GLclampf AlphaRef; + bool AlphaTest; + + GLenum MatrixMode; + + GLenum ClientActiveTexture; + + bool ClientStateVertex; + bool ClientStateNormal; + bool ClientStateColor; + bool ClientStateTexCoord0; +}; + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_OPENGL_ diff --git a/irr/src/COpenGLCommon.h b/irr/src/COpenGLCommon.h new file mode 100644 index 000000000..3b43b35a4 --- /dev/null +++ b/irr/src/COpenGLCommon.h @@ -0,0 +1,48 @@ +// Copyright (C) 2015 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) && defined(IRR_PREFER_SDL_GL_HEADER) +#include +#include +#else +#include "vendor/gl.h" +#endif + +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT + +// To check if this header is in the current compile unit (different GL driver implementations use different "GLCommon" headers in Irrlicht) +#define IRR_COMPILE_GL_COMMON + +namespace irr +{ +namespace video +{ + +// Forward declarations. + +class COpenGLCoreFeature; + +template +class COpenGLCoreTexture; + +template +class COpenGLCoreRenderTarget; + +template +class COpenGLCoreCacheHandler; + +class COpenGLDriver; +typedef COpenGLCoreTexture COpenGLTexture; +typedef COpenGLCoreRenderTarget COpenGLRenderTarget; +class COpenGLCacheHandler; + +} +} + +#endif diff --git a/irr/src/COpenGLCoreCacheHandler.h b/irr/src/COpenGLCoreCacheHandler.h new file mode 100644 index 000000000..ae3661313 --- /dev/null +++ b/irr/src/COpenGLCoreCacheHandler.h @@ -0,0 +1,595 @@ +// Copyright (C) 2015 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "SMaterial.h" +#include "ITexture.h" + +#include "mt_opengl.h" + +namespace irr +{ +namespace video +{ + +enum ESetTextureActive +{ + EST_ACTIVE_ALWAYS, // texture unit always active after set call + EST_ACTIVE_ON_CHANGE // texture unit only active after call when texture changed in cache +}; + +template +class COpenGLCoreCacheHandler +{ + class STextureCache + { + public: + STextureCache(COpenGLCoreCacheHandler &cacheHandler, E_DRIVER_TYPE driverType, u32 textureCount) : + CacheHandler(cacheHandler), DriverType(driverType), TextureCount(textureCount) + { + for (u32 i = 0; i < MATERIAL_MAX_TEXTURES; ++i) { + Texture[i] = 0; + } + } + + ~STextureCache() + { + clear(); + } + + const TOpenGLTexture *operator[](int index) const + { + if (static_cast(index) < MATERIAL_MAX_TEXTURES) + return Texture[static_cast(index)]; + + return 0; + } + + const TOpenGLTexture *get(u32 index) const + { + if (index < MATERIAL_MAX_TEXTURES) + return Texture[index]; + + return 0; + } + + bool set(u32 index, const ITexture *texture, ESetTextureActive esa = EST_ACTIVE_ALWAYS) + { + bool status = false; + + E_DRIVER_TYPE type = DriverType; + + if (index < MATERIAL_MAX_TEXTURES && index < TextureCount) { + if (esa == EST_ACTIVE_ALWAYS) + CacheHandler.setActiveTexture(GL_TEXTURE0 + index); + + const TOpenGLTexture *prevTexture = Texture[index]; + + if (texture != prevTexture) { + if (esa == EST_ACTIVE_ON_CHANGE) + CacheHandler.setActiveTexture(GL_TEXTURE0 + index); + + if (texture) { + type = texture->getDriverType(); + + if (type == DriverType) { + texture->grab(); + + const TOpenGLTexture *curTexture = static_cast(texture); + const GLenum curTextureType = curTexture->getOpenGLTextureType(); + const GLenum prevTextureType = (prevTexture) ? prevTexture->getOpenGLTextureType() : curTextureType; + + if (curTextureType != prevTextureType) { + GL.BindTexture(prevTextureType, 0); + +#if (defined(IRR_COMPILE_GL_COMMON) || defined(IRR_COMPILE_GLES_COMMON)) + GL.Disable(prevTextureType); + GL.Enable(curTextureType); +#endif + } +#if (defined(IRR_COMPILE_GL_COMMON) || defined(IRR_COMPILE_GLES_COMMON)) + else if (!prevTexture) + GL.Enable(curTextureType); +#endif + + GL.BindTexture(curTextureType, static_cast(texture)->getOpenGLTextureName()); + } else { + texture = 0; + + os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR); + os::Printer::log("Texture type", irr::core::stringc((int)type), ELL_ERROR); + os::Printer::log("Driver (or cache handler) type", irr::core::stringc((int)DriverType), ELL_ERROR); + } + } + + if (!texture && prevTexture) { + const GLenum prevTextureType = prevTexture->getOpenGLTextureType(); + + GL.BindTexture(prevTextureType, 0); + +#if (defined(IRR_COMPILE_GL_COMMON) || defined(IRR_COMPILE_GLES_COMMON)) + GL.Disable(prevTextureType); +#endif + } + + Texture[index] = static_cast(texture); + + if (prevTexture) + prevTexture->drop(); + } + + status = true; + } + + return (status && type == DriverType); + } + + void remove(ITexture *texture) + { + if (!texture) + return; + + for (u32 i = 0; i < MATERIAL_MAX_TEXTURES; ++i) { + if (Texture[i] == texture) { + Texture[i] = 0; + + texture->drop(); + } + } + } + + void clear() + { + for (u32 i = 0; i < MATERIAL_MAX_TEXTURES; ++i) { + if (Texture[i]) { + const TOpenGLTexture *prevTexture = Texture[i]; + + Texture[i] = 0; + + prevTexture->drop(); + } + } + } + + private: + COpenGLCoreCacheHandler &CacheHandler; + + E_DRIVER_TYPE DriverType; + + const TOpenGLTexture *Texture[MATERIAL_MAX_TEXTURES]; + u32 TextureCount; + }; + +public: + COpenGLCoreCacheHandler(TOpenGLDriver *driver) : + Driver(driver), +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable : 4355) // Warning: "'this' : used in base member initializer list. ". It's OK, we don't use the reference in STextureCache constructor. +#endif + TextureCache(STextureCache(*this, driver->getDriverType(), driver->getFeature().MaxTextureUnits)), +#if defined(_MSC_VER) +#pragma warning(pop) +#endif + FrameBufferCount(0), BlendEquation(0), BlendSourceRGB(0), + BlendDestinationRGB(0), BlendSourceAlpha(0), BlendDestinationAlpha(0), Blend(0), BlendEquationInvalid(false), BlendFuncInvalid(false), BlendInvalid(false), + ColorMask(0), ColorMaskInvalid(false), CullFaceMode(GL_BACK), CullFace(false), DepthFunc(GL_LESS), DepthMask(true), DepthTest(false), FrameBufferID(0), + ProgramID(0), ActiveTexture(GL_TEXTURE0), ViewportX(0), ViewportY(0) + { + const COpenGLCoreFeature &feature = Driver->getFeature(); + + FrameBufferCount = core::max_(static_cast(1), static_cast(feature.MultipleRenderTarget)); + + BlendEquation = new GLenum[FrameBufferCount]; + BlendSourceRGB = new GLenum[FrameBufferCount]; + BlendDestinationRGB = new GLenum[FrameBufferCount]; + BlendSourceAlpha = new GLenum[FrameBufferCount]; + BlendDestinationAlpha = new GLenum[FrameBufferCount]; + Blend = new bool[FrameBufferCount]; + ColorMask = new u8[FrameBufferCount]; + + // Initial OpenGL values from specification. + + if (feature.BlendOperation) { + Driver->irrGlBlendEquation(GL_FUNC_ADD); + } + + for (u32 i = 0; i < FrameBufferCount; ++i) { + BlendEquation[i] = GL_FUNC_ADD; + + BlendSourceRGB[i] = GL_ONE; + BlendDestinationRGB[i] = GL_ZERO; + BlendSourceAlpha[i] = GL_ONE; + BlendDestinationAlpha[i] = GL_ZERO; + + Blend[i] = false; + ColorMask[i] = ECP_ALL; + } + + GL.BlendFunc(GL_ONE, GL_ZERO); + GL.Disable(GL_BLEND); + + GL.ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + + GL.CullFace(CullFaceMode); + GL.Disable(GL_CULL_FACE); + + GL.DepthFunc(DepthFunc); + GL.DepthMask(GL_TRUE); + GL.Disable(GL_DEPTH_TEST); + + Driver->irrGlActiveTexture(ActiveTexture); + +#if (defined(IRR_COMPILE_GL_COMMON) || defined(IRR_COMPILE_GLES_COMMON)) + GL.Disable(GL_TEXTURE_2D); +#endif + + const core::dimension2d ScreenSize = Driver->getScreenSize(); + ViewportWidth = ScreenSize.Width; + ViewportHeight = ScreenSize.Height; + GL.Viewport(ViewportX, ViewportY, ViewportWidth, ViewportHeight); + } + + virtual ~COpenGLCoreCacheHandler() + { + delete[] BlendEquation; + delete[] BlendSourceRGB; + delete[] BlendDestinationRGB; + delete[] BlendSourceAlpha; + delete[] BlendDestinationAlpha; + delete[] Blend; + + delete[] ColorMask; + } + + E_DRIVER_TYPE getDriverType() const + { + return Driver->getDriverType(); + } + + STextureCache &getTextureCache() + { + return TextureCache; + } + + // Blending calls. + + void setBlendEquation(GLenum mode) + { + if (BlendEquation[0] != mode || BlendEquationInvalid) { + Driver->irrGlBlendEquation(mode); + + for (GLuint i = 0; i < FrameBufferCount; ++i) + BlendEquation[i] = mode; + + BlendEquationInvalid = false; + } + } + + void setBlendEquationIndexed(GLuint index, GLenum mode) + { + if (index < FrameBufferCount && BlendEquation[index] != mode) { + Driver->irrGlBlendEquationIndexed(index, mode); + + BlendEquation[index] = mode; + BlendEquationInvalid = true; + } + } + + void setBlendFunc(GLenum source, GLenum destination) + { + if (BlendSourceRGB[0] != source || BlendDestinationRGB[0] != destination || + BlendSourceAlpha[0] != source || BlendDestinationAlpha[0] != destination || + BlendFuncInvalid) { + GL.BlendFunc(source, destination); + + for (GLuint i = 0; i < FrameBufferCount; ++i) { + BlendSourceRGB[i] = source; + BlendDestinationRGB[i] = destination; + BlendSourceAlpha[i] = source; + BlendDestinationAlpha[i] = destination; + } + + BlendFuncInvalid = false; + } + } + + void setBlendFuncSeparate(GLenum sourceRGB, GLenum destinationRGB, GLenum sourceAlpha, GLenum destinationAlpha) + { + if (sourceRGB != sourceAlpha || destinationRGB != destinationAlpha) { + if (BlendSourceRGB[0] != sourceRGB || BlendDestinationRGB[0] != destinationRGB || + BlendSourceAlpha[0] != sourceAlpha || BlendDestinationAlpha[0] != destinationAlpha || + BlendFuncInvalid) { + Driver->irrGlBlendFuncSeparate(sourceRGB, destinationRGB, sourceAlpha, destinationAlpha); + + for (GLuint i = 0; i < FrameBufferCount; ++i) { + BlendSourceRGB[i] = sourceRGB; + BlendDestinationRGB[i] = destinationRGB; + BlendSourceAlpha[i] = sourceAlpha; + BlendDestinationAlpha[i] = destinationAlpha; + } + + BlendFuncInvalid = false; + } + } else { + setBlendFunc(sourceRGB, destinationRGB); + } + } + + void setBlendFuncIndexed(GLuint index, GLenum source, GLenum destination) + { + if (index < FrameBufferCount && (BlendSourceRGB[index] != source || BlendDestinationRGB[index] != destination || + BlendSourceAlpha[index] != source || BlendDestinationAlpha[index] != destination)) { + Driver->irrGlBlendFuncIndexed(index, source, destination); + + BlendSourceRGB[index] = source; + BlendDestinationRGB[index] = destination; + BlendSourceAlpha[index] = source; + BlendDestinationAlpha[index] = destination; + BlendFuncInvalid = true; + } + } + + void setBlendFuncSeparateIndexed(GLuint index, GLenum sourceRGB, GLenum destinationRGB, GLenum sourceAlpha, GLenum destinationAlpha) + { + if (sourceRGB != sourceAlpha || destinationRGB != destinationAlpha) { + if (index < FrameBufferCount && (BlendSourceRGB[index] != sourceRGB || BlendDestinationRGB[index] != destinationRGB || + BlendSourceAlpha[index] != sourceAlpha || BlendDestinationAlpha[index] != destinationAlpha)) { + Driver->irrGlBlendFuncSeparateIndexed(index, sourceRGB, destinationRGB, sourceAlpha, destinationAlpha); + + BlendSourceRGB[index] = sourceRGB; + BlendDestinationRGB[index] = destinationRGB; + BlendSourceAlpha[index] = sourceAlpha; + BlendDestinationAlpha[index] = destinationAlpha; + BlendFuncInvalid = true; + } + } else { + setBlendFuncIndexed(index, sourceRGB, destinationRGB); + } + } + + void setBlend(bool enable) + { + if (Blend[0] != enable || BlendInvalid) { + if (enable) + GL.Enable(GL_BLEND); + else + GL.Disable(GL_BLEND); + + for (GLuint i = 0; i < FrameBufferCount; ++i) + Blend[i] = enable; + + BlendInvalid = false; + } + } + + void setBlendIndexed(GLuint index, bool enable) + { + if (index < FrameBufferCount && Blend[index] != enable) { + if (enable) + Driver->irrGlEnableIndexed(GL_BLEND, index); + else + Driver->irrGlDisableIndexed(GL_BLEND, index); + + Blend[index] = enable; + BlendInvalid = true; + } + } + + // Color Mask. + + void getColorMask(u8 &mask) + { + mask = ColorMask[0]; + } + + void setColorMask(u8 mask) + { + if (ColorMask[0] != mask || ColorMaskInvalid) { + GL.ColorMask((mask & ECP_RED) ? GL_TRUE : GL_FALSE, (mask & ECP_GREEN) ? GL_TRUE : GL_FALSE, (mask & ECP_BLUE) ? GL_TRUE : GL_FALSE, (mask & ECP_ALPHA) ? GL_TRUE : GL_FALSE); + + for (GLuint i = 0; i < FrameBufferCount; ++i) + ColorMask[i] = mask; + + ColorMaskInvalid = false; + } + } + + void setColorMaskIndexed(GLuint index, u8 mask) + { + if (index < FrameBufferCount && ColorMask[index] != mask) { + Driver->irrGlColorMaskIndexed(index, (mask & ECP_RED) ? GL_TRUE : GL_FALSE, (mask & ECP_GREEN) ? GL_TRUE : GL_FALSE, (mask & ECP_BLUE) ? GL_TRUE : GL_FALSE, (mask & ECP_ALPHA) ? GL_TRUE : GL_FALSE); + + ColorMask[index] = mask; + ColorMaskInvalid = true; + } + } + + // Cull face calls. + + void setCullFaceFunc(GLenum mode) + { + if (CullFaceMode != mode) { + GL.CullFace(mode); + CullFaceMode = mode; + } + } + + void setCullFace(bool enable) + { + if (CullFace != enable) { + if (enable) + GL.Enable(GL_CULL_FACE); + else + GL.Disable(GL_CULL_FACE); + + CullFace = enable; + } + } + + // Depth calls. + + void setDepthFunc(GLenum mode) + { + if (DepthFunc != mode) { + GL.DepthFunc(mode); + DepthFunc = mode; + } + } + + void getDepthMask(bool &depth) + { + depth = DepthMask; + } + + void setDepthMask(bool enable) + { + if (DepthMask != enable) { + if (enable) + GL.DepthMask(GL_TRUE); + else + GL.DepthMask(GL_FALSE); + + DepthMask = enable; + } + } + + void getDepthTest(bool &enable) + { + enable = DepthTest; + } + + void setDepthTest(bool enable) + { + if (DepthTest != enable) { + if (enable) + GL.Enable(GL_DEPTH_TEST); + else + GL.Disable(GL_DEPTH_TEST); + + DepthTest = enable; + } + } + + // FBO calls. + + void getFBO(GLuint &frameBufferID) const + { + frameBufferID = FrameBufferID; + } + + void setFBO(GLuint frameBufferID) + { + if (FrameBufferID != frameBufferID) { + Driver->irrGlBindFramebuffer(GL_FRAMEBUFFER, frameBufferID); + FrameBufferID = frameBufferID; + } + } + + // Shaders calls. + + void getProgram(GLuint &programID) const + { + programID = ProgramID; + } + + void setProgram(GLuint programID) + { + if (ProgramID != programID) { + Driver->irrGlUseProgram(programID); + ProgramID = programID; + } + } + + // Texture calls. + + void getActiveTexture(GLenum &texture) const + { + texture = ActiveTexture; + } + + void setActiveTexture(GLenum texture) + { + if (ActiveTexture != texture) { + Driver->irrGlActiveTexture(texture); + ActiveTexture = texture; + } + } + + // Viewport calls. + + void getViewport(GLint &viewportX, GLint &viewportY, GLsizei &viewportWidth, GLsizei &viewportHeight) const + { + viewportX = ViewportX; + viewportY = ViewportY; + viewportWidth = ViewportWidth; + viewportHeight = ViewportHeight; + } + + void setViewport(GLint viewportX, GLint viewportY, GLsizei viewportWidth, GLsizei viewportHeight) + { + if (ViewportX != viewportX || ViewportY != viewportY || ViewportWidth != viewportWidth || ViewportHeight != viewportHeight) { + GL.Viewport(viewportX, viewportY, viewportWidth, viewportHeight); + ViewportX = viewportX; + ViewportY = viewportY; + ViewportWidth = viewportWidth; + ViewportHeight = viewportHeight; + } + } + + //! Compare material to current cache and update it when there are differences + // Some material renderers do change the cache beyond the original material settings + // This corrects the material to represent the current cache state again. + void correctCacheMaterial(irr::video::SMaterial &material) + { + // Fix textures which got removed + for (u32 i = 0; i < MATERIAL_MAX_TEXTURES; ++i) { + if (material.TextureLayers[i].Texture && !TextureCache[i]) { + material.TextureLayers[i].Texture = 0; + } + } + } + +protected: + TOpenGLDriver *Driver; + + STextureCache TextureCache; + + GLuint FrameBufferCount; + + GLenum *BlendEquation; + GLenum *BlendSourceRGB; + GLenum *BlendDestinationRGB; + GLenum *BlendSourceAlpha; + GLenum *BlendDestinationAlpha; + bool *Blend; + bool BlendEquationInvalid; + bool BlendFuncInvalid; + bool BlendInvalid; + + u8 *ColorMask; + bool ColorMaskInvalid; + + GLenum CullFaceMode; + bool CullFace; + + GLenum DepthFunc; + bool DepthMask; + bool DepthTest; + + GLuint FrameBufferID; + + GLuint ProgramID; + + GLenum ActiveTexture; + + GLint ViewportX; + GLint ViewportY; + GLsizei ViewportWidth; + GLsizei ViewportHeight; +}; + +} +} diff --git a/irr/src/COpenGLCoreFeature.h b/irr/src/COpenGLCoreFeature.h new file mode 100644 index 000000000..dc3d40e04 --- /dev/null +++ b/irr/src/COpenGLCoreFeature.h @@ -0,0 +1,34 @@ +// Copyright (C) 2015 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" + +namespace irr +{ +namespace video +{ + +class COpenGLCoreFeature +{ +public: + COpenGLCoreFeature() : + BlendOperation(false), ColorAttachment(0), MultipleRenderTarget(0), MaxTextureUnits(1) + { + } + + virtual ~COpenGLCoreFeature() + { + } + + bool BlendOperation; + + u8 ColorAttachment; + u8 MultipleRenderTarget; + u8 MaxTextureUnits; +}; + +} +} diff --git a/irr/src/COpenGLCoreRenderTarget.h b/irr/src/COpenGLCoreRenderTarget.h new file mode 100644 index 000000000..105cdd702 --- /dev/null +++ b/irr/src/COpenGLCoreRenderTarget.h @@ -0,0 +1,353 @@ +// Copyright (C) 2015 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IRenderTarget.h" + +#ifndef GL_FRAMEBUFFER_INCOMPLETE_FORMATS +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT +#endif + +#ifndef GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT +#endif + +namespace irr +{ +namespace video +{ + +template +class COpenGLCoreRenderTarget : public IRenderTarget +{ +public: + COpenGLCoreRenderTarget(TOpenGLDriver *driver) : + AssignedDepth(false), AssignedStencil(false), RequestTextureUpdate(false), RequestDepthStencilUpdate(false), + BufferID(0), ColorAttachment(0), MultipleRenderTarget(0), Driver(driver) + { +#ifdef _DEBUG + setDebugName("COpenGLCoreRenderTarget"); +#endif + + DriverType = Driver->getDriverType(); + + Size = Driver->getScreenSize(); + + ColorAttachment = Driver->getFeature().ColorAttachment; + MultipleRenderTarget = Driver->getFeature().MultipleRenderTarget; + + if (ColorAttachment > 0) + Driver->irrGlGenFramebuffers(1, &BufferID); + + AssignedTextures.set_used(static_cast(ColorAttachment)); + + for (u32 i = 0; i < AssignedTextures.size(); ++i) + AssignedTextures[i] = GL_NONE; + } + + virtual ~COpenGLCoreRenderTarget() + { + if (ColorAttachment > 0 && BufferID != 0) + Driver->irrGlDeleteFramebuffers(1, &BufferID); + + for (u32 i = 0; i < Textures.size(); ++i) { + if (Textures[i]) + Textures[i]->drop(); + } + + if (DepthStencil) + DepthStencil->drop(); + } + + void setTextures(ITexture *const *textures, u32 numTextures, ITexture *depthStencil, const E_CUBE_SURFACE *cubeSurfaces, u32 numCubeSurfaces) override + { + bool needSizeUpdate = false; + + // Set color attachments. + if (!Textures.equals(textures, numTextures) || !CubeSurfaces.equals(cubeSurfaces, numCubeSurfaces)) { + needSizeUpdate = true; + + core::array prevTextures(Textures); + + if (numTextures > static_cast(ColorAttachment)) { + core::stringc message = "This GPU supports up to "; + message += static_cast(ColorAttachment); + message += " textures per render target."; + + os::Printer::log(message.c_str(), ELL_WARNING); + } + + Textures.set_used(core::min_(numTextures, static_cast(ColorAttachment))); + + for (u32 i = 0; i < Textures.size(); ++i) { + TOpenGLTexture *currentTexture = (textures[i] && textures[i]->getDriverType() == DriverType) ? static_cast(textures[i]) : 0; + + GLuint textureID = 0; + + if (currentTexture) { + textureID = currentTexture->getOpenGLTextureName(); + } + + if (textureID != 0) { + Textures[i] = textures[i]; + Textures[i]->grab(); + } else { + Textures[i] = 0; + } + } + + for (u32 i = 0; i < prevTextures.size(); ++i) { + if (prevTextures[i]) + prevTextures[i]->drop(); + } + + RequestTextureUpdate = true; + } + + if (!CubeSurfaces.equals(cubeSurfaces, numCubeSurfaces)) { + CubeSurfaces.set_data(cubeSurfaces, numCubeSurfaces); + RequestTextureUpdate = true; + } + + // Set depth and stencil attachments. + if (DepthStencil != depthStencil) { + if (DepthStencil) { + DepthStencil->drop(); + DepthStencil = 0; + } + + needSizeUpdate = true; + TOpenGLTexture *currentTexture = (depthStencil && depthStencil->getDriverType() == DriverType) ? static_cast(depthStencil) : 0; + + if (currentTexture) { + if (currentTexture->getType() == ETT_2D) { + GLuint textureID = currentTexture->getOpenGLTextureName(); + + const ECOLOR_FORMAT textureFormat = (textureID != 0) ? depthStencil->getColorFormat() : ECF_UNKNOWN; + if (IImage::isDepthFormat(textureFormat)) { + DepthStencil = depthStencil; + DepthStencil->grab(); + } else { + os::Printer::log("Ignoring depth/stencil texture without depth color format.", ELL_WARNING); + } + } else { + os::Printer::log("This driver doesn't support depth/stencil to cubemaps.", ELL_WARNING); + } + } + + RequestDepthStencilUpdate = true; + } + + if (needSizeUpdate) { + // Set size required for a viewport. + + ITexture *firstTexture = getTexture(); + + if (firstTexture) + Size = firstTexture->getSize(); + else { + if (DepthStencil) + Size = DepthStencil->getSize(); + else + Size = Driver->getScreenSize(); + } + } + } + + void update() + { + if (RequestTextureUpdate || RequestDepthStencilUpdate) { + // Set color attachments. + + if (RequestTextureUpdate) { + // Set new color textures. + + const u32 textureSize = core::min_(Textures.size(), AssignedTextures.size()); + + for (u32 i = 0; i < textureSize; ++i) { + TOpenGLTexture *currentTexture = static_cast(Textures[i]); + GLuint textureID = currentTexture ? currentTexture->getOpenGLTextureName() : 0; + + if (textureID != 0) { + AssignedTextures[i] = GL_COLOR_ATTACHMENT0 + i; + GLenum textarget = currentTexture->getType() == ETT_2D ? GL_TEXTURE_2D : GL_TEXTURE_CUBE_MAP_POSITIVE_X + (int)CubeSurfaces[i]; + Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, AssignedTextures[i], textarget, textureID, 0); +#ifdef _DEBUG + Driver->testGLError(__LINE__); +#endif + } else if (AssignedTextures[i] != GL_NONE) { + AssignedTextures[i] = GL_NONE; + Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, AssignedTextures[i], GL_TEXTURE_2D, 0, 0); + + os::Printer::log("Error: Could not set render target.", ELL_ERROR); + } + } + + // Reset other render target channels. + + for (u32 i = textureSize; i < AssignedTextures.size(); ++i) { + if (AssignedTextures[i] != GL_NONE) { + Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, AssignedTextures[i], GL_TEXTURE_2D, 0, 0); + AssignedTextures[i] = GL_NONE; + } + } + + RequestTextureUpdate = false; + } + + // Set depth and stencil attachments. + + if (RequestDepthStencilUpdate) { + const ECOLOR_FORMAT textureFormat = (DepthStencil) ? DepthStencil->getColorFormat() : ECF_UNKNOWN; + + if (IImage::isDepthFormat(textureFormat)) { + GLuint textureID = static_cast(DepthStencil)->getOpenGLTextureName(); + +#ifdef _IRR_EMSCRIPTEN_PLATFORM_ // The WEBGL_depth_texture extension does not allow attaching stencil+depth separate. + if (textureFormat == ECF_D24S8) { + GLenum attachment = 0x821A; // GL_DEPTH_STENCIL_ATTACHMENT + Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, textureID, 0); + AssignedStencil = true; + } else { + Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, textureID, 0); + AssignedStencil = false; + } +#else + Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, textureID, 0); + + if (textureFormat == ECF_D24S8) { + Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, textureID, 0); + + AssignedStencil = true; + } else { + if (AssignedStencil) + Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0); + + AssignedStencil = false; + } +#endif + AssignedDepth = true; + } else { + if (AssignedDepth) + Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0); + + if (AssignedStencil) + Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0); + + AssignedDepth = false; + AssignedStencil = false; + } +#ifdef _DEBUG + Driver->testGLError(__LINE__); +#endif + + RequestDepthStencilUpdate = false; + } + + // Configure drawing operation. + + if (ColorAttachment > 0 && BufferID != 0) { + const u32 textureSize = Textures.size(); + + if (textureSize == 0) + Driver->irrGlDrawBuffer(GL_NONE); + else if (textureSize == 1 || MultipleRenderTarget == 0) + Driver->irrGlDrawBuffer(GL_COLOR_ATTACHMENT0); + else { + const u32 bufferCount = core::min_(MultipleRenderTarget, core::min_(textureSize, AssignedTextures.size())); + + Driver->irrGlDrawBuffers(bufferCount, AssignedTextures.pointer()); + } + +#ifdef _DEBUG + Driver->testGLError(__LINE__); +#endif + } + +#ifdef _DEBUG + checkFBO(Driver); +#endif + } + } + + GLuint getBufferID() const + { + return BufferID; + } + + const core::dimension2d &getSize() const + { + return Size; + } + + ITexture *getTexture() const + { + for (u32 i = 0; i < Textures.size(); ++i) { + if (Textures[i]) + return Textures[i]; + } + + return 0; + } + +protected: + bool checkFBO(TOpenGLDriver *driver) + { + if (ColorAttachment == 0) + return true; + + GLenum status = driver->irrGlCheckFramebufferStatus(GL_FRAMEBUFFER); + + switch (status) { + case GL_FRAMEBUFFER_COMPLETE: + return true; + case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: + os::Printer::log("FBO has invalid read buffer", ELL_ERROR); + break; + case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: + os::Printer::log("FBO has invalid draw buffer", ELL_ERROR); + break; + case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: + os::Printer::log("FBO has one or several incomplete image attachments", ELL_ERROR); + break; + case GL_FRAMEBUFFER_INCOMPLETE_FORMATS: + os::Printer::log("FBO has one or several image attachments with different internal formats", ELL_ERROR); + break; + case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: + os::Printer::log("FBO has one or several image attachments with different dimensions", ELL_ERROR); + break; + case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: + os::Printer::log("FBO missing an image attachment", ELL_ERROR); + break; + case GL_FRAMEBUFFER_UNSUPPORTED: + os::Printer::log("FBO format unsupported", ELL_ERROR); + break; + default: + os::Printer::log("FBO error", ELL_ERROR); + break; + } + + return false; + } + + core::array AssignedTextures; + bool AssignedDepth; + bool AssignedStencil; + + bool RequestTextureUpdate; + bool RequestDepthStencilUpdate; + + GLuint BufferID; + + core::dimension2d Size; + + u32 ColorAttachment; + u32 MultipleRenderTarget; + + TOpenGLDriver *Driver; +}; + +} +} diff --git a/irr/src/COpenGLCoreTexture.h b/irr/src/COpenGLCoreTexture.h new file mode 100644 index 000000000..45bf2f0be --- /dev/null +++ b/irr/src/COpenGLCoreTexture.h @@ -0,0 +1,608 @@ +// Copyright (C) 2015 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrArray.h" +#include "SMaterialLayer.h" +#include "ITexture.h" +#include "EDriverFeatures.h" +#include "os.h" +#include "CImage.h" +#include "CColorConverter.h" + +#include "mt_opengl.h" + +namespace irr +{ +namespace video +{ + +template +class COpenGLCoreTexture : public ITexture +{ +public: + struct SStatesCache + { + SStatesCache() : + WrapU(ETC_REPEAT), WrapV(ETC_REPEAT), WrapW(ETC_REPEAT), + LODBias(0), AnisotropicFilter(0), MinFilter(video::ETMINF_NEAREST_MIPMAP_NEAREST), + MagFilter(video::ETMAGF_NEAREST), MipMapStatus(false), IsCached(false) + { + } + + u8 WrapU; + u8 WrapV; + u8 WrapW; + s8 LODBias; + u8 AnisotropicFilter; + video::E_TEXTURE_MIN_FILTER MinFilter; + video::E_TEXTURE_MAG_FILTER MagFilter; + bool MipMapStatus; + bool IsCached; + }; + + COpenGLCoreTexture(const io::path &name, const core::array &images, E_TEXTURE_TYPE type, TOpenGLDriver *driver) : + ITexture(name, type), Driver(driver), TextureType(GL_TEXTURE_2D), + TextureName(0), InternalFormat(GL_RGBA), PixelFormat(GL_RGBA), PixelType(GL_UNSIGNED_BYTE), Converter(0), LockReadOnly(false), LockImage(0), LockLayer(0), + KeepImage(false), MipLevelStored(0), LegacyAutoGenerateMipMaps(false) + { + _IRR_DEBUG_BREAK_IF(images.size() == 0) + + DriverType = Driver->getDriverType(); + TextureType = TextureTypeIrrToGL(Type); + HasMipMaps = Driver->getTextureCreationFlag(ETCF_CREATE_MIP_MAPS); + KeepImage = Driver->getTextureCreationFlag(ETCF_ALLOW_MEMORY_COPY); + + getImageValues(images[0]); + if (!InternalFormat) + return; + + const core::array *tmpImages = &images; + + if (KeepImage || OriginalSize != Size || OriginalColorFormat != ColorFormat) { + Images.set_used(images.size()); + + for (u32 i = 0; i < images.size(); ++i) { + Images[i] = Driver->createImage(ColorFormat, Size); + + if (images[i]->getDimension() == Size) + images[i]->copyTo(Images[i]); + else + images[i]->copyToScaling(Images[i]); + + if (images[i]->getMipMapsData()) { + if (OriginalSize == Size && OriginalColorFormat == ColorFormat) { + Images[i]->setMipMapsData(images[i]->getMipMapsData(), false); + } else { + // TODO: handle at least mipmap with changing color format + os::Printer::log("COpenGLCoreTexture: Can't handle format changes for mipmap data. Mipmap data dropped", ELL_WARNING); + } + } + } + + tmpImages = &Images; + } + + GL.GenTextures(1, &TextureName); + + const COpenGLCoreTexture *prevTexture = Driver->getCacheHandler()->getTextureCache().get(0); + Driver->getCacheHandler()->getTextureCache().set(0, this); + + GL.TexParameteri(TextureType, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + GL.TexParameteri(TextureType, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + +#ifdef GL_GENERATE_MIPMAP_HINT + if (HasMipMaps) { + if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED)) + GL.Hint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST); + else if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_QUALITY)) + GL.Hint(GL_GENERATE_MIPMAP_HINT, GL_NICEST); + else + GL.Hint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE); + } +#endif + + for (u32 i = 0; i < (*tmpImages).size(); ++i) + uploadTexture(true, i, 0, (*tmpImages)[i]->getData()); + + if (HasMipMaps && !LegacyAutoGenerateMipMaps) { + // Create mipmaps (either from image mipmaps or generate them) + for (u32 i = 0; i < (*tmpImages).size(); ++i) { + void *mipmapsData = (*tmpImages)[i]->getMipMapsData(); + regenerateMipMapLevels(mipmapsData, i); + } + } + + if (!KeepImage) { + for (u32 i = 0; i < Images.size(); ++i) + Images[i]->drop(); + + Images.clear(); + } + + Driver->getCacheHandler()->getTextureCache().set(0, prevTexture); + + Driver->testGLError(__LINE__); + } + + COpenGLCoreTexture(const io::path &name, const core::dimension2d &size, E_TEXTURE_TYPE type, ECOLOR_FORMAT format, TOpenGLDriver *driver) : + ITexture(name, type), + Driver(driver), TextureType(GL_TEXTURE_2D), + TextureName(0), InternalFormat(GL_RGBA), PixelFormat(GL_RGBA), PixelType(GL_UNSIGNED_BYTE), Converter(0), LockReadOnly(false), LockImage(0), LockLayer(0), KeepImage(false), + MipLevelStored(0), LegacyAutoGenerateMipMaps(false) + { + DriverType = Driver->getDriverType(); + TextureType = TextureTypeIrrToGL(Type); + HasMipMaps = false; + IsRenderTarget = true; + + OriginalColorFormat = format; + + if (ECF_UNKNOWN == OriginalColorFormat) + ColorFormat = getBestColorFormat(Driver->getColorFormat()); + else + ColorFormat = OriginalColorFormat; + + OriginalSize = size; + Size = OriginalSize; + + Pitch = Size.Width * IImage::getBitsPerPixelFromFormat(ColorFormat) / 8; + + if (!Driver->getColorFormatParameters(ColorFormat, InternalFormat, PixelFormat, PixelType, &Converter)) { + os::Printer::log("COpenGLCoreTexture: Color format is not supported", ColorFormatNames[ColorFormat < ECF_UNKNOWN ? ColorFormat : ECF_UNKNOWN], ELL_ERROR); + return; + } + + GL.GenTextures(1, &TextureName); + + const COpenGLCoreTexture *prevTexture = Driver->getCacheHandler()->getTextureCache().get(0); + Driver->getCacheHandler()->getTextureCache().set(0, this); + + GL.TexParameteri(TextureType, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + GL.TexParameteri(TextureType, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + GL.TexParameteri(TextureType, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + GL.TexParameteri(TextureType, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + +#if defined(GL_VERSION_1_2) + GL.TexParameteri(TextureType, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); +#endif + + StatesCache.WrapU = ETC_CLAMP_TO_EDGE; + StatesCache.WrapV = ETC_CLAMP_TO_EDGE; + StatesCache.WrapW = ETC_CLAMP_TO_EDGE; + + switch (Type) { + case ETT_2D: + GL.TexImage2D(GL_TEXTURE_2D, 0, InternalFormat, Size.Width, Size.Height, 0, PixelFormat, PixelType, 0); + break; + case ETT_CUBEMAP: + GL.TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, InternalFormat, Size.Width, Size.Height, 0, PixelFormat, PixelType, 0); + GL.TexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, InternalFormat, Size.Width, Size.Height, 0, PixelFormat, PixelType, 0); + GL.TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, InternalFormat, Size.Width, Size.Height, 0, PixelFormat, PixelType, 0); + GL.TexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, InternalFormat, Size.Width, Size.Height, 0, PixelFormat, PixelType, 0); + GL.TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, InternalFormat, Size.Width, Size.Height, 0, PixelFormat, PixelType, 0); + GL.TexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, InternalFormat, Size.Width, Size.Height, 0, PixelFormat, PixelType, 0); + break; + } + + Driver->getCacheHandler()->getTextureCache().set(0, prevTexture); + if (Driver->testGLError(__LINE__)) { + char msg[256]; + snprintf_irr(msg, 256, "COpenGLCoreTexture: InternalFormat:0x%04x PixelFormat:0x%04x", (int)InternalFormat, (int)PixelFormat); + os::Printer::log(msg, ELL_ERROR); + } + } + + virtual ~COpenGLCoreTexture() + { + if (TextureName) + GL.DeleteTextures(1, &TextureName); + + if (LockImage) + LockImage->drop(); + + for (u32 i = 0; i < Images.size(); ++i) + Images[i]->drop(); + } + + void *lock(E_TEXTURE_LOCK_MODE mode = ETLM_READ_WRITE, u32 mipmapLevel = 0, u32 layer = 0, E_TEXTURE_LOCK_FLAGS lockFlags = ETLF_FLIP_Y_UP_RTT) override + { + if (LockImage) + return getLockImageData(MipLevelStored); + + if (IImage::isCompressedFormat(ColorFormat)) + return 0; + + LockReadOnly |= (mode == ETLM_READ_ONLY); + LockLayer = layer; + MipLevelStored = mipmapLevel; + + if (KeepImage) { + _IRR_DEBUG_BREAK_IF(LockLayer > Images.size()) + + if (mipmapLevel == 0 || (Images[LockLayer] && Images[LockLayer]->getMipMapsData(mipmapLevel))) { + LockImage = Images[LockLayer]; + LockImage->grab(); + } + } + + if (!LockImage) { + core::dimension2d lockImageSize(IImage::getMipMapsSize(Size, MipLevelStored)); + + // note: we save mipmap data also in the image because IImage doesn't allow saving single mipmap levels to the mipmap data + LockImage = Driver->createImage(ColorFormat, lockImageSize); + + if (LockImage && mode != ETLM_WRITE_ONLY) { + bool passed = true; + +#ifdef IRR_COMPILE_GL_COMMON + IImage *tmpImage = LockImage; // not sure yet if the size required by glGetTexImage is always correct, if not we might have to allocate a different tmpImage and convert colors later on. + + Driver->getCacheHandler()->getTextureCache().set(0, this); + Driver->testGLError(__LINE__); + + GLenum tmpTextureType = TextureType; + + if (tmpTextureType == GL_TEXTURE_CUBE_MAP) { + _IRR_DEBUG_BREAK_IF(layer > 5) + + tmpTextureType = GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer; + } + + GL.GetTexImage(tmpTextureType, MipLevelStored, PixelFormat, PixelType, tmpImage->getData()); + Driver->testGLError(__LINE__); + + if (IsRenderTarget && lockFlags == ETLF_FLIP_Y_UP_RTT) { + const s32 pitch = tmpImage->getPitch(); + + u8 *srcA = static_cast(tmpImage->getData()); + u8 *srcB = srcA + (tmpImage->getDimension().Height - 1) * pitch; + + u8 *tmpBuffer = new u8[pitch]; + + for (u32 i = 0; i < tmpImage->getDimension().Height; i += 2) { + memcpy(tmpBuffer, srcA, pitch); + memcpy(srcA, srcB, pitch); + memcpy(srcB, tmpBuffer, pitch); + srcA += pitch; + srcB -= pitch; + } + + delete[] tmpBuffer; + } +#elif (defined(IRR_COMPILE_GLES2_COMMON) || defined(IRR_COMPILE_GLES_COMMON)) + // TODO: on ES2 we can likely also work with glCopyTexImage2D instead of rendering which should be faster. + COpenGLCoreTexture *tmpTexture = new COpenGLCoreTexture("OGL_CORE_LOCK_TEXTURE", Size, ETT_2D, ColorFormat, Driver); + + GLuint tmpFBO = 0; + Driver->irrGlGenFramebuffers(1, &tmpFBO); + + GLint prevViewportX = 0; + GLint prevViewportY = 0; + GLsizei prevViewportWidth = 0; + GLsizei prevViewportHeight = 0; + Driver->getCacheHandler()->getViewport(prevViewportX, prevViewportY, prevViewportWidth, prevViewportHeight); + Driver->getCacheHandler()->setViewport(0, 0, Size.Width, Size.Height); + + GLuint prevFBO = 0; + Driver->getCacheHandler()->getFBO(prevFBO); + Driver->getCacheHandler()->setFBO(tmpFBO); + + Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tmpTexture->getOpenGLTextureName(), 0); + + GL.Clear(GL_COLOR_BUFFER_BIT); + + Driver->draw2DImage(this, layer, true); + + IImage *tmpImage = Driver->createImage(ECF_A8R8G8B8, Size); + GL.ReadPixels(0, 0, Size.Width, Size.Height, GL_RGBA, GL_UNSIGNED_BYTE, tmpImage->getData()); + + Driver->getCacheHandler()->setFBO(prevFBO); + Driver->getCacheHandler()->setViewport(prevViewportX, prevViewportY, prevViewportWidth, prevViewportHeight); + + Driver->irrGlDeleteFramebuffers(1, &tmpFBO); + delete tmpTexture; + + void *src = tmpImage->getData(); + void *dest = LockImage->getData(); + + switch (ColorFormat) { + case ECF_A1R5G5B5: + CColorConverter::convert_A8R8G8B8toA1B5G5R5(src, tmpImage->getDimension().getArea(), dest); + break; + case ECF_R5G6B5: + CColorConverter::convert_A8R8G8B8toR5G6B5(src, tmpImage->getDimension().getArea(), dest); + break; + case ECF_R8G8B8: + CColorConverter::convert_A8R8G8B8toB8G8R8(src, tmpImage->getDimension().getArea(), dest); + break; + case ECF_A8R8G8B8: + CColorConverter::convert_A8R8G8B8toA8B8G8R8(src, tmpImage->getDimension().getArea(), dest); + break; + default: + passed = false; + break; + } + tmpImage->drop(); +#endif + + if (!passed) { + LockImage->drop(); + LockImage = 0; + } + } + + Driver->testGLError(__LINE__); + } + + return (LockImage) ? getLockImageData(MipLevelStored) : 0; + } + + void unlock() override + { + if (!LockImage) + return; + + if (!LockReadOnly) { + const COpenGLCoreTexture *prevTexture = Driver->getCacheHandler()->getTextureCache().get(0); + Driver->getCacheHandler()->getTextureCache().set(0, this); + + uploadTexture(false, LockLayer, MipLevelStored, getLockImageData(MipLevelStored)); + + Driver->getCacheHandler()->getTextureCache().set(0, prevTexture); + } + + LockImage->drop(); + + LockReadOnly = false; + LockImage = 0; + LockLayer = 0; + } + + void regenerateMipMapLevels(void *data = 0, u32 layer = 0) override + { + if (!HasMipMaps || LegacyAutoGenerateMipMaps || (Size.Width <= 1 && Size.Height <= 1)) + return; + + const COpenGLCoreTexture *prevTexture = Driver->getCacheHandler()->getTextureCache().get(0); + Driver->getCacheHandler()->getTextureCache().set(0, this); + + if (data) { + u32 width = Size.Width; + u32 height = Size.Height; + u8 *tmpData = static_cast(data); + u32 dataSize = 0; + u32 level = 0; + + do { + if (width > 1) + width >>= 1; + + if (height > 1) + height >>= 1; + + dataSize = IImage::getDataSizeFromFormat(ColorFormat, width, height); + ++level; + + uploadTexture(true, layer, level, tmpData); + + tmpData += dataSize; + } while (width != 1 || height != 1); + } else { + Driver->irrGlGenerateMipmap(TextureType); + } + + Driver->getCacheHandler()->getTextureCache().set(0, prevTexture); + } + + GLenum getOpenGLTextureType() const + { + return TextureType; + } + + GLuint getOpenGLTextureName() const + { + return TextureName; + } + + SStatesCache &getStatesCache() const + { + return StatesCache; + } + +protected: + void *getLockImageData(irr::u32 miplevel) const + { + if (KeepImage && MipLevelStored > 0 && LockImage->getMipMapsData(MipLevelStored)) { + return LockImage->getMipMapsData(MipLevelStored); + } + return LockImage->getData(); + } + + ECOLOR_FORMAT getBestColorFormat(ECOLOR_FORMAT format) + { + // We only try for to adapt "simple" formats + ECOLOR_FORMAT destFormat = (format <= ECF_A8R8G8B8) ? ECF_A8R8G8B8 : format; + + switch (format) { + case ECF_A1R5G5B5: + if (!Driver->getTextureCreationFlag(ETCF_ALWAYS_32_BIT)) + destFormat = ECF_A1R5G5B5; + break; + case ECF_R5G6B5: + if (!Driver->getTextureCreationFlag(ETCF_ALWAYS_32_BIT)) + destFormat = ECF_R5G6B5; + break; + case ECF_A8R8G8B8: + if (Driver->getTextureCreationFlag(ETCF_ALWAYS_16_BIT) || + Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED)) + destFormat = ECF_A1R5G5B5; + break; + case ECF_R8G8B8: + // Note: Using ECF_A8R8G8B8 even when ETCF_ALWAYS_32_BIT is not set as 24 bit textures fail with too many cards + if (Driver->getTextureCreationFlag(ETCF_ALWAYS_16_BIT) || Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED)) + destFormat = ECF_A1R5G5B5; + default: + break; + } + + if (Driver->getTextureCreationFlag(ETCF_NO_ALPHA_CHANNEL)) { + switch (destFormat) { + case ECF_A1R5G5B5: + destFormat = ECF_R5G6B5; + break; + case ECF_A8R8G8B8: + destFormat = ECF_R8G8B8; + break; + default: + break; + } + } + + return destFormat; + } + + void getImageValues(const IImage *image) + { + OriginalColorFormat = image->getColorFormat(); + ColorFormat = getBestColorFormat(OriginalColorFormat); + + if (!Driver->getColorFormatParameters(ColorFormat, InternalFormat, PixelFormat, PixelType, &Converter)) { + os::Printer::log("getImageValues: Color format is not supported", ColorFormatNames[ColorFormat < ECF_UNKNOWN ? ColorFormat : ECF_UNKNOWN], ELL_ERROR); + InternalFormat = 0; + return; + } + + if (IImage::isCompressedFormat(image->getColorFormat())) { + KeepImage = false; + } + + OriginalSize = image->getDimension(); + Size = OriginalSize; + + if (Size.Width == 0 || Size.Height == 0) { + os::Printer::log("Invalid size of image for texture.", ELL_ERROR); + return; + } + + const f32 ratio = (f32)Size.Width / (f32)Size.Height; + + if ((Size.Width > Driver->MaxTextureSize) && (ratio >= 1.f)) { + Size.Width = Driver->MaxTextureSize; + Size.Height = (u32)(Driver->MaxTextureSize / ratio); + } else if (Size.Height > Driver->MaxTextureSize) { + Size.Height = Driver->MaxTextureSize; + Size.Width = (u32)(Driver->MaxTextureSize * ratio); + } + + bool needSquare = (!Driver->queryFeature(EVDF_TEXTURE_NSQUARE) || Type == ETT_CUBEMAP); + + Size = Size.getOptimalSize(!Driver->queryFeature(EVDF_TEXTURE_NPOT), needSquare, true, Driver->MaxTextureSize); + + Pitch = Size.Width * IImage::getBitsPerPixelFromFormat(ColorFormat) / 8; + } + + void uploadTexture(bool initTexture, u32 layer, u32 level, void *data) + { + if (!data) + return; + + u32 width = Size.Width >> level; + u32 height = Size.Height >> level; + if (width < 1) + width = 1; + if (height < 1) + height = 1; + + GLenum tmpTextureType = TextureType; + + if (tmpTextureType == GL_TEXTURE_CUBE_MAP) { + _IRR_DEBUG_BREAK_IF(layer > 5) + + tmpTextureType = GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer; + } + + if (!IImage::isCompressedFormat(ColorFormat)) { + CImage *tmpImage = 0; + void *tmpData = data; + + if (Converter) { + const core::dimension2d tmpImageSize(width, height); + + tmpImage = new CImage(ColorFormat, tmpImageSize); + tmpData = tmpImage->getData(); + + Converter(data, tmpImageSize.getArea(), tmpData); + } + + switch (TextureType) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP: + if (initTexture) + GL.TexImage2D(tmpTextureType, level, InternalFormat, width, height, 0, PixelFormat, PixelType, tmpData); + else + GL.TexSubImage2D(tmpTextureType, level, 0, 0, width, height, PixelFormat, PixelType, tmpData); + Driver->testGLError(__LINE__); + break; + default: + break; + } + + delete tmpImage; + } else { + u32 dataSize = IImage::getDataSizeFromFormat(ColorFormat, width, height); + + switch (TextureType) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP: + if (initTexture) + Driver->irrGlCompressedTexImage2D(tmpTextureType, level, InternalFormat, width, height, 0, dataSize, data); + else + Driver->irrGlCompressedTexSubImage2D(tmpTextureType, level, 0, 0, width, height, PixelFormat, dataSize, data); + Driver->testGLError(__LINE__); + break; + default: + break; + } + } + } + + GLenum TextureTypeIrrToGL(E_TEXTURE_TYPE type) const + { + switch (type) { + case ETT_2D: + return GL_TEXTURE_2D; + case ETT_CUBEMAP: + return GL_TEXTURE_CUBE_MAP; + } + + os::Printer::log("COpenGLCoreTexture::TextureTypeIrrToGL unknown texture type", ELL_WARNING); + return GL_TEXTURE_2D; + } + + TOpenGLDriver *Driver; + + GLenum TextureType; + GLuint TextureName; + GLint InternalFormat; + GLenum PixelFormat; + GLenum PixelType; + void (*Converter)(const void *, s32, void *); + + bool LockReadOnly; + IImage *LockImage; + u32 LockLayer; + + bool KeepImage; + core::array Images; + + u8 MipLevelStored; + bool LegacyAutoGenerateMipMaps; + + mutable SStatesCache StatesCache; +}; + +} +} diff --git a/irr/src/COpenGLDriver.cpp b/irr/src/COpenGLDriver.cpp new file mode 100644 index 000000000..ef560e331 --- /dev/null +++ b/irr/src/COpenGLDriver.cpp @@ -0,0 +1,3414 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "COpenGLDriver.h" +#include +#include "CNullDriver.h" +#include "IContextManager.h" + +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#include "os.h" + +#include "COpenGLCacheHandler.h" +#include "COpenGLMaterialRenderer.h" +#include "COpenGLSLMaterialRenderer.h" + +#include "COpenGLCoreTexture.h" +#include "COpenGLCoreRenderTarget.h" + +#include "mt_opengl.h" + +namespace irr +{ +namespace video +{ + +// Statics variables +const u16 COpenGLDriver::Quad2DIndices[4] = {0, 1, 2, 3}; + +COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager) : + CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), CacheHandler(0), CurrentRenderMode(ERM_NONE), ResetRenderStates(true), + Transformation3DChanged(true), AntiAlias(params.AntiAlias), ColorFormat(ECF_R8G8B8), FixedPipelineState(EOFPS_ENABLE), Params(params), + ContextManager(contextManager) +{ +#ifdef _DEBUG + setDebugName("COpenGLDriver"); +#endif +} + +bool COpenGLDriver::initDriver() +{ + ContextManager->generateSurface(); + ContextManager->generateContext(); + ExposedData = ContextManager->getContext(); + ContextManager->activateContext(ExposedData, false); + GL.LoadAllProcedures(ContextManager); + + genericDriverInit(); + +#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_X11_DEVICE_) + extGlSwapInterval(Params.Vsync ? 1 : 0); +#endif + + return true; +} + +//! destructor +COpenGLDriver::~COpenGLDriver() +{ + deleteMaterialRenders(); + + CacheHandler->getTextureCache().clear(); + // I get a blue screen on my laptop, when I do not delete the + // textures manually before releasing the dc. Oh how I love this. + removeAllRenderTargets(); + deleteAllTextures(); + removeAllOcclusionQueries(); + removeAllHardwareBuffers(); + + delete CacheHandler; + + if (ContextManager) { + ContextManager->destroyContext(); + ContextManager->destroySurface(); + ContextManager->terminate(); + ContextManager->drop(); + } +} + +// ----------------------------------------------------------------------- +// METHODS +// ----------------------------------------------------------------------- + +bool COpenGLDriver::genericDriverInit() +{ + if (ContextManager) + ContextManager->grab(); + + Name = "OpenGL "; + Name.append(glGetString(GL_VERSION)); + s32 pos = Name.findNext(' ', 7); + if (pos != -1) + Name = Name.subString(0, pos); + printVersion(); + + // print renderer information + const GLubyte *renderer = glGetString(GL_RENDERER); + const GLubyte *vendor = glGetString(GL_VENDOR); + if (renderer && vendor) { + os::Printer::log(reinterpret_cast(renderer), reinterpret_cast(vendor), ELL_INFORMATION); + VendorName = reinterpret_cast(vendor); + } + + u32 i; + + // load extensions + initExtensions(ContextManager, Params.Stencilbuffer); + + // reset cache handler + delete CacheHandler; + CacheHandler = new COpenGLCacheHandler(this); + + if (queryFeature(EVDF_ARB_GLSL)) { + char buf[32]; + const u32 maj = ShaderLanguageVersion / 100; + snprintf_irr(buf, 32, "%u.%u", maj, ShaderLanguageVersion - maj * 100); + os::Printer::log("GLSL version", buf, ELL_INFORMATION); + } else + os::Printer::log("GLSL not available.", ELL_INFORMATION); + DriverAttributes->setAttribute("MaxTextures", (s32)Feature.MaxTextureUnits); + DriverAttributes->setAttribute("MaxSupportedTextures", (s32)Feature.MaxTextureUnits); + DriverAttributes->setAttribute("MaxLights", MaxLights); + DriverAttributes->setAttribute("MaxAnisotropy", MaxAnisotropy); + DriverAttributes->setAttribute("MaxUserClipPlanes", MaxUserClipPlanes); + DriverAttributes->setAttribute("MaxAuxBuffers", MaxAuxBuffers); + DriverAttributes->setAttribute("MaxMultipleRenderTargets", (s32)Feature.MultipleRenderTarget); + DriverAttributes->setAttribute("MaxIndices", (s32)MaxIndices); + DriverAttributes->setAttribute("MaxTextureSize", (s32)MaxTextureSize); + DriverAttributes->setAttribute("MaxGeometryVerticesOut", (s32)MaxGeometryVerticesOut); + DriverAttributes->setAttribute("MaxTextureLODBias", MaxTextureLODBias); + DriverAttributes->setAttribute("Version", Version); + DriverAttributes->setAttribute("ShaderLanguageVersion", ShaderLanguageVersion); + DriverAttributes->setAttribute("AntiAlias", AntiAlias); + + glPixelStorei(GL_PACK_ALIGNMENT, 1); + + UserClipPlanes.reallocate(MaxUserClipPlanes); + for (i = 0; i < MaxUserClipPlanes; ++i) + UserClipPlanes.push_back(SUserClipPlane()); + + for (i = 0; i < ETS_COUNT; ++i) + setTransform(static_cast(i), core::IdentityMatrix); + + setAmbientLight(SColorf(0.0f, 0.0f, 0.0f, 0.0f)); +#ifdef GL_EXT_separate_specular_color + if (FeatureAvailable[IRR_EXT_separate_specular_color]) + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); +#endif + glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); + + // This is a fast replacement for NORMALIZE_NORMALS + // if ((Version>101) || FeatureAvailable[IRR_EXT_rescale_normal]) + // glEnable(GL_RESCALE_NORMAL_EXT); + + glClearDepth(1.0); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + glFrontFace(GL_CW); + // adjust flat coloring scheme to DirectX version +#if defined(GL_ARB_provoking_vertex) || defined(GL_EXT_provoking_vertex) + extGlProvokingVertex(GL_FIRST_VERTEX_CONVENTION_EXT); +#endif + + // Create built-in 2D quad for 2D rendering (both quads and lines). + Quad2DVertices[0] = S3DVertex(core::vector3df(-1.0f, 1.0f, 0.0f), core::vector3df(0.0f, 0.0f, 0.0f), SColor(255, 255, 255, 255), core::vector2df(0.0f, 1.0f)); + Quad2DVertices[1] = S3DVertex(core::vector3df(1.0f, 1.0f, 0.0f), core::vector3df(0.0f, 0.0f, 0.0f), SColor(255, 255, 255, 255), core::vector2df(1.0f, 1.0f)); + Quad2DVertices[2] = S3DVertex(core::vector3df(1.0f, -1.0f, 0.0f), core::vector3df(0.0f, 0.0f, 0.0f), SColor(255, 255, 255, 255), core::vector2df(1.0f, 0.0f)); + Quad2DVertices[3] = S3DVertex(core::vector3df(-1.0f, -1.0f, 0.0f), core::vector3df(0.0f, 0.0f, 0.0f), SColor(255, 255, 255, 255), core::vector2df(0.0f, 0.0f)); + + // create material renderers + createMaterialRenderers(); + + // set the renderstates + setRenderStates3DMode(); + + // set fog mode + setFog(FogColor, FogType, FogStart, FogEnd, FogDensity, PixelFog, RangeFog); + + // create matrix for flipping textures + TextureFlipMatrix.buildTextureTransform(0.0f, core::vector2df(0, 0), core::vector2df(0, 1.0f), core::vector2df(1.0f, -1.0f)); + + // We need to reset once more at the beginning of the first rendering. + // This fixes problems with intermediate changes to the material during texture load. + ResetRenderStates = true; + + return true; +} + +void COpenGLDriver::createMaterialRenderers() +{ + addAndDropMaterialRenderer(new COpenGLMaterialRenderer_SOLID(this)); + addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(this)); + addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(this)); + addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_VERTEX_ALPHA(this)); + addAndDropMaterialRenderer(new COpenGLMaterialRenderer_ONETEXTURE_BLEND(this)); +} + +bool COpenGLDriver::beginScene(u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil, const SExposedVideoData &videoData, core::rect *sourceRect) +{ + CNullDriver::beginScene(clearFlag, clearColor, clearDepth, clearStencil, videoData, sourceRect); + + if (ContextManager) + ContextManager->activateContext(videoData, true); + + clearBuffers(clearFlag, clearColor, clearDepth, clearStencil); + + return true; +} + +bool COpenGLDriver::endScene() +{ + CNullDriver::endScene(); + + glFlush(); + + bool status = false; + + if (ContextManager) + status = ContextManager->swapBuffers(); + + // todo: console device present + + return status; +} + +//! Returns the transformation set by setTransform +const core::matrix4 &COpenGLDriver::getTransform(E_TRANSFORMATION_STATE state) const +{ + return Matrices[state]; +} + +//! sets transformation +void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4 &mat) +{ + Matrices[state] = mat; + Transformation3DChanged = true; + + switch (state) { + case ETS_VIEW: + case ETS_WORLD: { + // OpenGL only has a model matrix, view and world is not existent. so lets fake these two. + CacheHandler->setMatrixMode(GL_MODELVIEW); + + // first load the viewing transformation for user clip planes + glLoadMatrixf((Matrices[ETS_VIEW]).pointer()); + + // we have to update the clip planes to the latest view matrix + for (u32 i = 0; i < MaxUserClipPlanes; ++i) + if (UserClipPlanes[i].Enabled) + uploadClipPlane(i); + + // now the real model-view matrix + glMultMatrixf(Matrices[ETS_WORLD].pointer()); + } break; + case ETS_PROJECTION: { + CacheHandler->setMatrixMode(GL_PROJECTION); + glLoadMatrixf(mat.pointer()); + } break; + default: + break; + } +} + +bool COpenGLDriver::updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer) +{ + if (!HWBuffer) + return false; + + if (!FeatureAvailable[IRR_ARB_vertex_buffer_object]) + return false; + +#if defined(GL_ARB_vertex_buffer_object) + const scene::IMeshBuffer *mb = HWBuffer->MeshBuffer; + const void *vertices = mb->getVertices(); + const u32 vertexCount = mb->getVertexCount(); + const E_VERTEX_TYPE vType = mb->getVertexType(); + const u32 vertexSize = getVertexPitchFromType(vType); + + const c8 *vbuf = static_cast(vertices); + core::array buffer; + if (!FeatureAvailable[IRR_ARB_vertex_array_bgra] && !FeatureAvailable[IRR_EXT_vertex_array_bgra]) { + // buffer vertex data, and convert colors... + buffer.set_used(vertexSize * vertexCount); + memcpy(buffer.pointer(), vertices, vertexSize * vertexCount); + vbuf = buffer.const_pointer(); + + // in order to convert the colors into opengl format (RGBA) + switch (vType) { + case EVT_STANDARD: { + S3DVertex *pb = reinterpret_cast(buffer.pointer()); + const S3DVertex *po = static_cast(vertices); + for (u32 i = 0; i < vertexCount; i++) { + po[i].Color.toOpenGLColor((u8 *)&(pb[i].Color)); + } + } break; + case EVT_2TCOORDS: { + S3DVertex2TCoords *pb = reinterpret_cast(buffer.pointer()); + const S3DVertex2TCoords *po = static_cast(vertices); + for (u32 i = 0; i < vertexCount; i++) { + po[i].Color.toOpenGLColor((u8 *)&(pb[i].Color)); + } + } break; + case EVT_TANGENTS: { + S3DVertexTangents *pb = reinterpret_cast(buffer.pointer()); + const S3DVertexTangents *po = static_cast(vertices); + for (u32 i = 0; i < vertexCount; i++) { + po[i].Color.toOpenGLColor((u8 *)&(pb[i].Color)); + } + } break; + default: { + return false; + } + } + } + + // get or create buffer + bool newBuffer = false; + if (!HWBuffer->vbo_verticesID) { + extGlGenBuffers(1, &HWBuffer->vbo_verticesID); + if (!HWBuffer->vbo_verticesID) + return false; + newBuffer = true; + } else if (HWBuffer->vbo_verticesSize < vertexCount * vertexSize) { + newBuffer = true; + } + + extGlBindBuffer(GL_ARRAY_BUFFER, HWBuffer->vbo_verticesID); + + // copy data to graphics card + if (!newBuffer) + extGlBufferSubData(GL_ARRAY_BUFFER, 0, vertexCount * vertexSize, vbuf); + else { + HWBuffer->vbo_verticesSize = vertexCount * vertexSize; + + if (HWBuffer->Mapped_Vertex == scene::EHM_STATIC) + extGlBufferData(GL_ARRAY_BUFFER, vertexCount * vertexSize, vbuf, GL_STATIC_DRAW); + else if (HWBuffer->Mapped_Vertex == scene::EHM_DYNAMIC) + extGlBufferData(GL_ARRAY_BUFFER, vertexCount * vertexSize, vbuf, GL_DYNAMIC_DRAW); + else // scene::EHM_STREAM + extGlBufferData(GL_ARRAY_BUFFER, vertexCount * vertexSize, vbuf, GL_STREAM_DRAW); + } + + extGlBindBuffer(GL_ARRAY_BUFFER, 0); + + return (!testGLError(__LINE__)); +#else + return false; +#endif +} + +bool COpenGLDriver::updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer) +{ + if (!HWBuffer) + return false; + + if (!FeatureAvailable[IRR_ARB_vertex_buffer_object]) + return false; + +#if defined(GL_ARB_vertex_buffer_object) + const scene::IMeshBuffer *mb = HWBuffer->MeshBuffer; + + const void *indices = mb->getIndices(); + u32 indexCount = mb->getIndexCount(); + + GLenum indexSize; + switch (mb->getIndexType()) { + case EIT_16BIT: { + indexSize = sizeof(u16); + break; + } + case EIT_32BIT: { + indexSize = sizeof(u32); + break; + } + default: { + return false; + } + } + + // get or create buffer + bool newBuffer = false; + if (!HWBuffer->vbo_indicesID) { + extGlGenBuffers(1, &HWBuffer->vbo_indicesID); + if (!HWBuffer->vbo_indicesID) + return false; + newBuffer = true; + } else if (HWBuffer->vbo_indicesSize < indexCount * indexSize) { + newBuffer = true; + } + + extGlBindBuffer(GL_ELEMENT_ARRAY_BUFFER, HWBuffer->vbo_indicesID); + + // copy data to graphics card + if (!newBuffer) + extGlBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, indexCount * indexSize, indices); + else { + HWBuffer->vbo_indicesSize = indexCount * indexSize; + + if (HWBuffer->Mapped_Index == scene::EHM_STATIC) + extGlBufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, GL_STATIC_DRAW); + else if (HWBuffer->Mapped_Index == scene::EHM_DYNAMIC) + extGlBufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, GL_DYNAMIC_DRAW); + else // scene::EHM_STREAM + extGlBufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, GL_STREAM_DRAW); + } + + extGlBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + + return (!testGLError(__LINE__)); +#else + return false; +#endif +} + +//! updates hardware buffer if needed +bool COpenGLDriver::updateHardwareBuffer(SHWBufferLink *HWBuffer) +{ + if (!HWBuffer) + return false; + + if (HWBuffer->Mapped_Vertex != scene::EHM_NEVER) { + if (HWBuffer->ChangedID_Vertex != HWBuffer->MeshBuffer->getChangedID_Vertex() || !((SHWBufferLink_opengl *)HWBuffer)->vbo_verticesID) { + + HWBuffer->ChangedID_Vertex = HWBuffer->MeshBuffer->getChangedID_Vertex(); + + if (!updateVertexHardwareBuffer((SHWBufferLink_opengl *)HWBuffer)) + return false; + } + } + + if (HWBuffer->Mapped_Index != scene::EHM_NEVER) { + if (HWBuffer->ChangedID_Index != HWBuffer->MeshBuffer->getChangedID_Index() || !((SHWBufferLink_opengl *)HWBuffer)->vbo_indicesID) { + + HWBuffer->ChangedID_Index = HWBuffer->MeshBuffer->getChangedID_Index(); + + if (!updateIndexHardwareBuffer((SHWBufferLink_opengl *)HWBuffer)) + return false; + } + } + + return true; +} + +//! Create hardware buffer from meshbuffer +COpenGLDriver::SHWBufferLink *COpenGLDriver::createHardwareBuffer(const scene::IMeshBuffer *mb) +{ +#if defined(GL_ARB_vertex_buffer_object) + if (!mb || (mb->getHardwareMappingHint_Index() == scene::EHM_NEVER && mb->getHardwareMappingHint_Vertex() == scene::EHM_NEVER)) + return 0; + + SHWBufferLink_opengl *HWBuffer = new SHWBufferLink_opengl(mb); + + // add to map + HWBuffer->listPosition = HWBufferList.insert(HWBufferList.end(), HWBuffer); + + HWBuffer->ChangedID_Vertex = HWBuffer->MeshBuffer->getChangedID_Vertex(); + HWBuffer->ChangedID_Index = HWBuffer->MeshBuffer->getChangedID_Index(); + HWBuffer->Mapped_Vertex = mb->getHardwareMappingHint_Vertex(); + HWBuffer->Mapped_Index = mb->getHardwareMappingHint_Index(); + HWBuffer->vbo_verticesID = 0; + HWBuffer->vbo_indicesID = 0; + HWBuffer->vbo_verticesSize = 0; + HWBuffer->vbo_indicesSize = 0; + + if (!updateHardwareBuffer(HWBuffer)) { + deleteHardwareBuffer(HWBuffer); + return 0; + } + + return HWBuffer; +#else + return 0; +#endif +} + +void COpenGLDriver::deleteHardwareBuffer(SHWBufferLink *_HWBuffer) +{ + if (!_HWBuffer) + return; + +#if defined(GL_ARB_vertex_buffer_object) + SHWBufferLink_opengl *HWBuffer = (SHWBufferLink_opengl *)_HWBuffer; + if (HWBuffer->vbo_verticesID) { + extGlDeleteBuffers(1, &HWBuffer->vbo_verticesID); + HWBuffer->vbo_verticesID = 0; + } + if (HWBuffer->vbo_indicesID) { + extGlDeleteBuffers(1, &HWBuffer->vbo_indicesID); + HWBuffer->vbo_indicesID = 0; + } +#endif + + CNullDriver::deleteHardwareBuffer(_HWBuffer); +} + +//! Draw hardware buffer +void COpenGLDriver::drawHardwareBuffer(SHWBufferLink *_HWBuffer) +{ + if (!_HWBuffer) + return; + + updateHardwareBuffer(_HWBuffer); // check if update is needed + +#if defined(GL_ARB_vertex_buffer_object) + SHWBufferLink_opengl *HWBuffer = (SHWBufferLink_opengl *)_HWBuffer; + + const scene::IMeshBuffer *mb = HWBuffer->MeshBuffer; + const void *vertices = mb->getVertices(); + const void *indexList = mb->getIndices(); + + if (HWBuffer->Mapped_Vertex != scene::EHM_NEVER) { + extGlBindBuffer(GL_ARRAY_BUFFER, HWBuffer->vbo_verticesID); + vertices = 0; + } + + if (HWBuffer->Mapped_Index != scene::EHM_NEVER) { + extGlBindBuffer(GL_ELEMENT_ARRAY_BUFFER, HWBuffer->vbo_indicesID); + indexList = 0; + } + + drawVertexPrimitiveList(vertices, mb->getVertexCount(), indexList, mb->getPrimitiveCount(), mb->getVertexType(), mb->getPrimitiveType(), mb->getIndexType()); + + if (HWBuffer->Mapped_Vertex != scene::EHM_NEVER) + extGlBindBuffer(GL_ARRAY_BUFFER, 0); + if (HWBuffer->Mapped_Index != scene::EHM_NEVER) + extGlBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); +#endif +} + +//! Create occlusion query. +/** Use node for identification and mesh for occlusion test. */ +void COpenGLDriver::addOcclusionQuery(scene::ISceneNode *node, + const scene::IMesh *mesh) +{ + if (!queryFeature(EVDF_OCCLUSION_QUERY)) + return; + + CNullDriver::addOcclusionQuery(node, mesh); + const s32 index = OcclusionQueries.linear_search(SOccQuery(node)); + if ((index != -1) && (OcclusionQueries[index].UID == 0)) + extGlGenQueries(1, reinterpret_cast(&OcclusionQueries[index].UID)); +} + +//! Remove occlusion query. +void COpenGLDriver::removeOcclusionQuery(scene::ISceneNode *node) +{ + const s32 index = OcclusionQueries.linear_search(SOccQuery(node)); + if (index != -1) { + if (OcclusionQueries[index].UID != 0) + extGlDeleteQueries(1, reinterpret_cast(&OcclusionQueries[index].UID)); + CNullDriver::removeOcclusionQuery(node); + } +} + +//! Run occlusion query. Draws mesh stored in query. +/** If the mesh shall not be rendered visible, use +overrideMaterial to disable the color and depth buffer. */ +void COpenGLDriver::runOcclusionQuery(scene::ISceneNode *node, bool visible) +{ + if (!node) + return; + + const s32 index = OcclusionQueries.linear_search(SOccQuery(node)); + if (index != -1) { + if (OcclusionQueries[index].UID) + extGlBeginQuery( +#ifdef GL_ARB_occlusion_query + GL_SAMPLES_PASSED_ARB, +#else + 0, +#endif + OcclusionQueries[index].UID); + CNullDriver::runOcclusionQuery(node, visible); + if (OcclusionQueries[index].UID) + extGlEndQuery( +#ifdef GL_ARB_occlusion_query + GL_SAMPLES_PASSED_ARB); +#else + 0); +#endif + testGLError(__LINE__); + } +} + +//! Update occlusion query. Retrieves results from GPU. +/** If the query shall not block, set the flag to false. +Update might not occur in this case, though */ +void COpenGLDriver::updateOcclusionQuery(scene::ISceneNode *node, bool block) +{ + const s32 index = OcclusionQueries.linear_search(SOccQuery(node)); + if (index != -1) { + // not yet started + if (OcclusionQueries[index].Run == u32(~0)) + return; + GLint available = block ? GL_TRUE : GL_FALSE; + if (!block) { + extGlGetQueryObjectiv(OcclusionQueries[index].UID, +#ifdef GL_ARB_occlusion_query + GL_QUERY_RESULT_AVAILABLE_ARB, +#elif defined(GL_NV_occlusion_query) + GL_PIXEL_COUNT_AVAILABLE_NV, +#else + 0, +#endif + &available); + testGLError(__LINE__); + } + if (available == GL_TRUE) { + extGlGetQueryObjectiv(OcclusionQueries[index].UID, +#ifdef GL_ARB_occlusion_query + GL_QUERY_RESULT_ARB, +#elif defined(GL_NV_occlusion_query) + GL_PIXEL_COUNT_NV, +#else + 0, +#endif + &available); + if (queryFeature(EVDF_OCCLUSION_QUERY)) + OcclusionQueries[index].Result = available; + } + testGLError(__LINE__); + } +} + +//! Return query result. +/** Return value is the number of visible pixels/fragments. +The value is a safe approximation, i.e. can be larger than the +actual value of pixels. */ +u32 COpenGLDriver::getOcclusionQueryResult(scene::ISceneNode *node) const +{ + const s32 index = OcclusionQueries.linear_search(SOccQuery(node)); + if (index != -1) + return OcclusionQueries[index].Result; + else + return ~0; +} + +//! Create render target. +IRenderTarget *COpenGLDriver::addRenderTarget() +{ + COpenGLRenderTarget *renderTarget = new COpenGLRenderTarget(this); + RenderTargets.push_back(renderTarget); + + return renderTarget; +} + +// small helper function to create vertex buffer object address offsets +static inline const GLvoid *buffer_offset(const size_t offset) +{ + return (const GLvoid *)offset; +} + +//! draws a vertex primitive list +void COpenGLDriver::drawVertexPrimitiveList(const void *vertices, u32 vertexCount, + const void *indexList, u32 primitiveCount, + E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) +{ + if (!primitiveCount || !vertexCount) + return; + + if (!checkPrimitiveCount(primitiveCount)) + return; + + CNullDriver::drawVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType, iType); + + if (vertices && !FeatureAvailable[IRR_ARB_vertex_array_bgra] && !FeatureAvailable[IRR_EXT_vertex_array_bgra]) + getColorBuffer(vertices, vertexCount, vType); + + // draw everything + setRenderStates3DMode(); + + if ((pType != scene::EPT_POINTS) && (pType != scene::EPT_POINT_SPRITES)) + CacheHandler->setClientState(true, true, true, true); + else + CacheHandler->setClientState(true, false, true, false); + +// due to missing defines in OSX headers, we have to be more specific with this check +// #if defined(GL_ARB_vertex_array_bgra) || defined(GL_EXT_vertex_array_bgra) +#ifdef GL_BGRA + const GLint colorSize = (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) ? GL_BGRA : 4; +#else + const GLint colorSize = 4; +#endif + if (vertices) { + if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) { + switch (vType) { + case EVT_STANDARD: + glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast(vertices))[0].Color); + break; + case EVT_2TCOORDS: + glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex2TCoords), &(static_cast(vertices))[0].Color); + break; + case EVT_TANGENTS: + glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertexTangents), &(static_cast(vertices))[0].Color); + break; + } + } else { + // avoid passing broken pointer to OpenGL + _IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); + glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); + } + } + + switch (vType) { + case EVT_STANDARD: + if (vertices) { + glNormalPointer(GL_FLOAT, sizeof(S3DVertex), &(static_cast(vertices))[0].Normal); + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast(vertices))[0].TCoords); + glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex), &(static_cast(vertices))[0].Pos); + } else { + glNormalPointer(GL_FLOAT, sizeof(S3DVertex), buffer_offset(12)); + glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), buffer_offset(24)); + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), buffer_offset(28)); + glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex), 0); + } + + if (Feature.MaxTextureUnits > 0 && CacheHandler->getTextureCache()[1]) { + CacheHandler->setClientActiveTexture(GL_TEXTURE0 + 1); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + if (vertices) + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast(vertices))[0].TCoords); + else + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), buffer_offset(28)); + } + break; + case EVT_2TCOORDS: + if (vertices) { + glNormalPointer(GL_FLOAT, sizeof(S3DVertex2TCoords), &(static_cast(vertices))[0].Normal); + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &(static_cast(vertices))[0].TCoords); + glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex2TCoords), &(static_cast(vertices))[0].Pos); + } else { + glNormalPointer(GL_FLOAT, sizeof(S3DVertex2TCoords), buffer_offset(12)); + glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex2TCoords), buffer_offset(24)); + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), buffer_offset(28)); + glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex2TCoords), buffer_offset(0)); + } + + if (Feature.MaxTextureUnits > 0) { + CacheHandler->setClientActiveTexture(GL_TEXTURE0 + 1); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + if (vertices) + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &(static_cast(vertices))[0].TCoords2); + else + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), buffer_offset(36)); + } + break; + case EVT_TANGENTS: + if (vertices) { + glNormalPointer(GL_FLOAT, sizeof(S3DVertexTangents), &(static_cast(vertices))[0].Normal); + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), &(static_cast(vertices))[0].TCoords); + glVertexPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &(static_cast(vertices))[0].Pos); + } else { + glNormalPointer(GL_FLOAT, sizeof(S3DVertexTangents), buffer_offset(12)); + glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertexTangents), buffer_offset(24)); + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), buffer_offset(28)); + glVertexPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), buffer_offset(0)); + } + + if (Feature.MaxTextureUnits > 0) { + CacheHandler->setClientActiveTexture(GL_TEXTURE0 + 1); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + if (vertices) + glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &(static_cast(vertices))[0].Tangent); + else + glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), buffer_offset(36)); + + CacheHandler->setClientActiveTexture(GL_TEXTURE0 + 2); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + if (vertices) + glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &(static_cast(vertices))[0].Binormal); + else + glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), buffer_offset(48)); + } + break; + } + + renderArray(indexList, primitiveCount, pType, iType); + + if (Feature.MaxTextureUnits > 0) { + if (vType == EVT_TANGENTS) { + CacheHandler->setClientActiveTexture(GL_TEXTURE0 + 2); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } + if ((vType != EVT_STANDARD) || CacheHandler->getTextureCache()[1]) { + CacheHandler->setClientActiveTexture(GL_TEXTURE0 + 1); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } + CacheHandler->setClientActiveTexture(GL_TEXTURE0); + } +} + +void COpenGLDriver::getColorBuffer(const void *vertices, u32 vertexCount, E_VERTEX_TYPE vType) +{ + // convert colors to gl color format. + vertexCount *= 4; // reused as color component count + ColorBuffer.set_used(vertexCount); + u32 i; + + switch (vType) { + case EVT_STANDARD: { + const S3DVertex *p = static_cast(vertices); + for (i = 0; i < vertexCount; i += 4) { + p->Color.toOpenGLColor(&ColorBuffer[i]); + ++p; + } + } break; + case EVT_2TCOORDS: { + const S3DVertex2TCoords *p = static_cast(vertices); + for (i = 0; i < vertexCount; i += 4) { + p->Color.toOpenGLColor(&ColorBuffer[i]); + ++p; + } + } break; + case EVT_TANGENTS: { + const S3DVertexTangents *p = static_cast(vertices); + for (i = 0; i < vertexCount; i += 4) { + p->Color.toOpenGLColor(&ColorBuffer[i]); + ++p; + } + } break; + } +} + +void COpenGLDriver::renderArray(const void *indexList, u32 primitiveCount, + scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) +{ + GLenum indexSize = 0; + + switch (iType) { + case EIT_16BIT: { + indexSize = GL_UNSIGNED_SHORT; + break; + } + case EIT_32BIT: { + indexSize = GL_UNSIGNED_INT; + break; + } + } + + switch (pType) { + case scene::EPT_POINTS: + case scene::EPT_POINT_SPRITES: { +#ifdef GL_ARB_point_sprite + if (pType == scene::EPT_POINT_SPRITES && FeatureAvailable[IRR_ARB_point_sprite]) + glEnable(GL_POINT_SPRITE_ARB); +#endif + + // prepare size and attenuation (where supported) + GLfloat particleSize = Material.Thickness; + // if (AntiAlias) + // particleSize=core::clamp(particleSize, DimSmoothedPoint[0], DimSmoothedPoint[1]); + // else + particleSize = core::clamp(particleSize, DimAliasedPoint[0], DimAliasedPoint[1]); +#if defined(GL_VERSION_1_4) || defined(GL_ARB_point_parameters) || defined(GL_EXT_point_parameters) || defined(GL_SGIS_point_parameters) + const float att[] = {1.0f, 1.0f, 0.0f}; +#if defined(GL_VERSION_1_4) + extGlPointParameterfv(GL_POINT_DISTANCE_ATTENUATION, att); + // extGlPointParameterf(GL_POINT_SIZE_MIN,1.f); + extGlPointParameterf(GL_POINT_SIZE_MAX, particleSize); + extGlPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE, 1.0f); +#elif defined(GL_ARB_point_parameters) + extGlPointParameterfv(GL_POINT_DISTANCE_ATTENUATION_ARB, att); + // extGlPointParameterf(GL_POINT_SIZE_MIN_ARB,1.f); + extGlPointParameterf(GL_POINT_SIZE_MAX_ARB, particleSize); + extGlPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 1.0f); +#elif defined(GL_EXT_point_parameters) + extGlPointParameterfv(GL_DISTANCE_ATTENUATION_EXT, att); + // extGlPointParameterf(GL_POINT_SIZE_MIN_EXT,1.f); + extGlPointParameterf(GL_POINT_SIZE_MAX_EXT, particleSize); + extGlPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE_EXT, 1.0f); +#elif defined(GL_SGIS_point_parameters) + extGlPointParameterfv(GL_DISTANCE_ATTENUATION_SGIS, att); + // extGlPointParameterf(GL_POINT_SIZE_MIN_SGIS,1.f); + extGlPointParameterf(GL_POINT_SIZE_MAX_SGIS, particleSize); + extGlPointParameterf(GL_POINT_FADE_THRESHOLD_SIZE_SGIS, 1.0f); +#endif +#endif + glPointSize(particleSize); + +#ifdef GL_ARB_point_sprite + if (pType == scene::EPT_POINT_SPRITES && FeatureAvailable[IRR_ARB_point_sprite]) { + CacheHandler->setActiveTexture(GL_TEXTURE0_ARB); + glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE, GL_TRUE); + } +#endif + glDrawArrays(GL_POINTS, 0, primitiveCount); +#ifdef GL_ARB_point_sprite + if (pType == scene::EPT_POINT_SPRITES && FeatureAvailable[IRR_ARB_point_sprite]) { + glDisable(GL_POINT_SPRITE_ARB); + + CacheHandler->setActiveTexture(GL_TEXTURE0_ARB); + glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE, GL_FALSE); + } +#endif + } break; + case scene::EPT_LINE_STRIP: + glDrawElements(GL_LINE_STRIP, primitiveCount + 1, indexSize, indexList); + break; + case scene::EPT_LINE_LOOP: + glDrawElements(GL_LINE_LOOP, primitiveCount, indexSize, indexList); + break; + case scene::EPT_LINES: + glDrawElements(GL_LINES, primitiveCount * 2, indexSize, indexList); + break; + case scene::EPT_TRIANGLE_STRIP: + glDrawElements(GL_TRIANGLE_STRIP, primitiveCount + 2, indexSize, indexList); + break; + case scene::EPT_TRIANGLE_FAN: + glDrawElements(GL_TRIANGLE_FAN, primitiveCount + 2, indexSize, indexList); + break; + case scene::EPT_TRIANGLES: + glDrawElements(GL_TRIANGLES, primitiveCount * 3, indexSize, indexList); + break; + } +} + +//! draws a vertex primitive list in 2d +void COpenGLDriver::draw2DVertexPrimitiveList(const void *vertices, u32 vertexCount, + const void *indexList, u32 primitiveCount, + E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) +{ + if (!primitiveCount || !vertexCount) + return; + + if (!checkPrimitiveCount(primitiveCount)) + return; + + CNullDriver::draw2DVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType, iType); + + if (vertices && !FeatureAvailable[IRR_ARB_vertex_array_bgra] && !FeatureAvailable[IRR_EXT_vertex_array_bgra]) + getColorBuffer(vertices, vertexCount, vType); + + // draw everything + CacheHandler->getTextureCache().set(0, Material.getTexture(0)); + if (Material.MaterialType == EMT_ONETEXTURE_BLEND) { + E_BLEND_FACTOR srcFact; + E_BLEND_FACTOR dstFact; + E_MODULATE_FUNC modulo; + u32 alphaSource; + unpack_textureBlendFunc(srcFact, dstFact, modulo, alphaSource, Material.MaterialTypeParam); + setRenderStates2DMode(alphaSource & video::EAS_VERTEX_COLOR, (Material.getTexture(0) != 0), (alphaSource & video::EAS_TEXTURE) != 0); + } else + setRenderStates2DMode(Material.MaterialType == EMT_TRANSPARENT_VERTEX_ALPHA, (Material.getTexture(0) != 0), Material.MaterialType == EMT_TRANSPARENT_ALPHA_CHANNEL); + + if ((pType != scene::EPT_POINTS) && (pType != scene::EPT_POINT_SPRITES)) + CacheHandler->setClientState(true, false, true, true); + else + CacheHandler->setClientState(true, false, true, false); + +// due to missing defines in OSX headers, we have to be more specific with this check +// #if defined(GL_ARB_vertex_array_bgra) || defined(GL_EXT_vertex_array_bgra) +#ifdef GL_BGRA + const GLint colorSize = (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) ? GL_BGRA : 4; +#else + const GLint colorSize = 4; +#endif + if (vertices) { + if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) { + switch (vType) { + case EVT_STANDARD: + glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast(vertices))[0].Color); + break; + case EVT_2TCOORDS: + glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex2TCoords), &(static_cast(vertices))[0].Color); + break; + case EVT_TANGENTS: + glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertexTangents), &(static_cast(vertices))[0].Color); + break; + } + } else { + // avoid passing broken pointer to OpenGL + _IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); + glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); + } + } + + switch (vType) { + case EVT_STANDARD: + if (vertices) { + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast(vertices))[0].TCoords); + glVertexPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast(vertices))[0].Pos); + } else { + glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), buffer_offset(24)); + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), buffer_offset(28)); + glVertexPointer(2, GL_FLOAT, sizeof(S3DVertex), 0); + } + + if (Feature.MaxTextureUnits > 0 && CacheHandler->getTextureCache()[1]) { + CacheHandler->setClientActiveTexture(GL_TEXTURE0 + 1); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + if (vertices) + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast(vertices))[0].TCoords); + else + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), buffer_offset(28)); + } + break; + case EVT_2TCOORDS: + if (vertices) { + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &(static_cast(vertices))[0].TCoords); + glVertexPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &(static_cast(vertices))[0].Pos); + } else { + glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex2TCoords), buffer_offset(24)); + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), buffer_offset(28)); + glVertexPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), buffer_offset(0)); + } + + if (Feature.MaxTextureUnits > 0) { + CacheHandler->setClientActiveTexture(GL_TEXTURE0 + 1); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + if (vertices) + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &(static_cast(vertices))[0].TCoords2); + else + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), buffer_offset(36)); + } + break; + case EVT_TANGENTS: + if (vertices) { + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), &(static_cast(vertices))[0].TCoords); + glVertexPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), &(static_cast(vertices))[0].Pos); + } else { + glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertexTangents), buffer_offset(24)); + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), buffer_offset(28)); + glVertexPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), buffer_offset(0)); + } + + break; + } + + renderArray(indexList, primitiveCount, pType, iType); + + if (Feature.MaxTextureUnits > 0) { + if ((vType != EVT_STANDARD) || CacheHandler->getTextureCache()[1]) { + CacheHandler->setClientActiveTexture(GL_TEXTURE0 + 1); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } + CacheHandler->setClientActiveTexture(GL_TEXTURE0); + } +} + +void COpenGLDriver::draw2DImage(const video::ITexture *texture, const core::position2d &destPos, + const core::rect &sourceRect, const core::rect *clipRect, SColor color, + bool useAlphaChannelOfTexture) +{ + if (!texture) + return; + + if (!sourceRect.isValid()) + return; + + // clip these coordinates + core::rect targetRect(destPos, sourceRect.getSize()); + if (clipRect) { + targetRect.clipAgainst(*clipRect); + if (targetRect.getWidth() < 0 || targetRect.getHeight() < 0) + return; + } + + const core::dimension2d &renderTargetSize = getCurrentRenderTargetSize(); + targetRect.clipAgainst(core::rect(0, 0, (s32)renderTargetSize.Width, (s32)renderTargetSize.Height)); + if (targetRect.getWidth() < 0 || targetRect.getHeight() < 0) + return; + + // ok, we've clipped everything. + // now draw it. + const core::dimension2d sourceSize(targetRect.getSize()); + const core::position2d sourcePos(sourceRect.UpperLeftCorner + (targetRect.UpperLeftCorner - destPos)); + + const core::dimension2d &ss = texture->getOriginalSize(); + const f32 invW = 1.f / static_cast(ss.Width); + const f32 invH = 1.f / static_cast(ss.Height); + const core::rect tcoords( + sourcePos.X * invW, + sourcePos.Y * invH, + (sourcePos.X + sourceSize.Width) * invW, + (sourcePos.Y + sourceSize.Height) * invH); + + disableTextures(1); + if (!CacheHandler->getTextureCache().set(0, texture)) + return; + setRenderStates2DMode(color.getAlpha() < 255, true, useAlphaChannelOfTexture); + + Quad2DVertices[0].Color = color; + Quad2DVertices[1].Color = color; + Quad2DVertices[2].Color = color; + Quad2DVertices[3].Color = color; + + Quad2DVertices[0].Pos = core::vector3df((f32)targetRect.UpperLeftCorner.X, (f32)targetRect.UpperLeftCorner.Y, 0.0f); + Quad2DVertices[1].Pos = core::vector3df((f32)targetRect.LowerRightCorner.X, (f32)targetRect.UpperLeftCorner.Y, 0.0f); + Quad2DVertices[2].Pos = core::vector3df((f32)targetRect.LowerRightCorner.X, (f32)targetRect.LowerRightCorner.Y, 0.0f); + Quad2DVertices[3].Pos = core::vector3df((f32)targetRect.UpperLeftCorner.X, (f32)targetRect.LowerRightCorner.Y, 0.0f); + + Quad2DVertices[0].TCoords = core::vector2df(tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); + Quad2DVertices[1].TCoords = core::vector2df(tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); + Quad2DVertices[2].TCoords = core::vector2df(tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); + Quad2DVertices[3].TCoords = core::vector2df(tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); + + if (!FeatureAvailable[IRR_ARB_vertex_array_bgra] && !FeatureAvailable[IRR_EXT_vertex_array_bgra]) + getColorBuffer(Quad2DVertices, 4, EVT_STANDARD); + + CacheHandler->setClientState(true, false, true, true); + + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].TCoords); + glVertexPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].Pos); + +#ifdef GL_BGRA + const GLint colorSize = (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) ? GL_BGRA : 4; +#else + const GLint colorSize = 4; +#endif + if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) + glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].Color); + else { + _IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); + glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); + } + + glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_SHORT, Quad2DIndices); +} + +void COpenGLDriver::draw2DImage(const video::ITexture *texture, const core::rect &destRect, + const core::rect &sourceRect, const core::rect *clipRect, + const video::SColor *const colors, bool useAlphaChannelOfTexture) +{ + if (!texture) + return; + + const core::dimension2d &ss = texture->getOriginalSize(); + const f32 invW = 1.f / static_cast(ss.Width); + const f32 invH = 1.f / static_cast(ss.Height); + const core::rect tcoords( + sourceRect.UpperLeftCorner.X * invW, + sourceRect.UpperLeftCorner.Y * invH, + sourceRect.LowerRightCorner.X * invW, + sourceRect.LowerRightCorner.Y * invH); + + const video::SColor temp[4] = { + 0xFFFFFFFF, + 0xFFFFFFFF, + 0xFFFFFFFF, + 0xFFFFFFFF, + }; + + const video::SColor *const useColor = colors ? colors : temp; + + disableTextures(1); + if (!CacheHandler->getTextureCache().set(0, texture)) + return; + setRenderStates2DMode(useColor[0].getAlpha() < 255 || useColor[1].getAlpha() < 255 || + useColor[2].getAlpha() < 255 || useColor[3].getAlpha() < 255, + true, useAlphaChannelOfTexture); + + if (clipRect) { + if (!clipRect->isValid()) + return; + + glEnable(GL_SCISSOR_TEST); + const core::dimension2d &renderTargetSize = getCurrentRenderTargetSize(); + glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y, + clipRect->getWidth(), clipRect->getHeight()); + } + + Quad2DVertices[0].Color = useColor[0]; + Quad2DVertices[1].Color = useColor[3]; + Quad2DVertices[2].Color = useColor[2]; + Quad2DVertices[3].Color = useColor[1]; + + Quad2DVertices[0].Pos = core::vector3df((f32)destRect.UpperLeftCorner.X, (f32)destRect.UpperLeftCorner.Y, 0.0f); + Quad2DVertices[1].Pos = core::vector3df((f32)destRect.LowerRightCorner.X, (f32)destRect.UpperLeftCorner.Y, 0.0f); + Quad2DVertices[2].Pos = core::vector3df((f32)destRect.LowerRightCorner.X, (f32)destRect.LowerRightCorner.Y, 0.0f); + Quad2DVertices[3].Pos = core::vector3df((f32)destRect.UpperLeftCorner.X, (f32)destRect.LowerRightCorner.Y, 0.0f); + + Quad2DVertices[0].TCoords = core::vector2df(tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); + Quad2DVertices[1].TCoords = core::vector2df(tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); + Quad2DVertices[2].TCoords = core::vector2df(tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); + Quad2DVertices[3].TCoords = core::vector2df(tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); + + if (!FeatureAvailable[IRR_ARB_vertex_array_bgra] && !FeatureAvailable[IRR_EXT_vertex_array_bgra]) + getColorBuffer(Quad2DVertices, 4, EVT_STANDARD); + + CacheHandler->setClientState(true, false, true, true); + + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].TCoords); + glVertexPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].Pos); + +#ifdef GL_BGRA + const GLint colorSize = (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) ? GL_BGRA : 4; +#else + const GLint colorSize = 4; +#endif + if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) + glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].Color); + else { + _IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); + glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); + } + + glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_SHORT, Quad2DIndices); + + if (clipRect) + glDisable(GL_SCISSOR_TEST); +} + +void COpenGLDriver::draw2DImage(const video::ITexture *texture, u32 layer, bool flip) +{ + if (!texture || !CacheHandler->getTextureCache().set(0, texture)) + return; + + disableTextures(1); + + setRenderStates2DMode(false, true, true); + + CacheHandler->setMatrixMode(GL_PROJECTION); + glLoadIdentity(); + CacheHandler->setMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + Transformation3DChanged = true; + + CacheHandler->setClientState(true, false, false, true); + + const core::vector3df positionData[4] = { + core::vector3df(-1.f, 1.f, 0.f), + core::vector3df(1.f, 1.f, 0.f), + core::vector3df(1.f, -1.f, 0.f), + core::vector3df(-1.f, -1.f, 0.f)}; + + glVertexPointer(2, GL_FLOAT, sizeof(core::vector3df), positionData); + + if (texture && texture->getType() == ETT_CUBEMAP) { + const core::vector3df texcoordCubeData[6][4] = { + + // GL_TEXTURE_CUBE_MAP_POSITIVE_X + { + core::vector3df(1.f, 1.f, 1.f), + core::vector3df(1.f, 1.f, -1.f), + core::vector3df(1.f, -1.f, -1.f), + core::vector3df(1.f, -1.f, 1.f)}, + + // GL_TEXTURE_CUBE_MAP_NEGATIVE_X + { + core::vector3df(-1.f, 1.f, -1.f), + core::vector3df(-1.f, 1.f, 1.f), + core::vector3df(-1.f, -1.f, 1.f), + core::vector3df(-1.f, -1.f, -1.f)}, + + // GL_TEXTURE_CUBE_MAP_POSITIVE_Y + { + core::vector3df(-1.f, 1.f, -1.f), + core::vector3df(1.f, 1.f, -1.f), + core::vector3df(1.f, 1.f, 1.f), + core::vector3df(-1.f, 1.f, 1.f)}, + + // GL_TEXTURE_CUBE_MAP_NEGATIVE_Y + { + core::vector3df(-1.f, -1.f, 1.f), + core::vector3df(-1.f, -1.f, -1.f), + core::vector3df(1.f, -1.f, -1.f), + core::vector3df(1.f, -1.f, 1.f)}, + + // GL_TEXTURE_CUBE_MAP_POSITIVE_Z + { + core::vector3df(-1.f, 1.f, 1.f), + core::vector3df(-1.f, -1.f, 1.f), + core::vector3df(1.f, -1.f, 1.f), + core::vector3df(1.f, 1.f, 1.f)}, + + // GL_TEXTURE_CUBE_MAP_NEGATIVE_Z + { + core::vector3df(1.f, 1.f, -1.f), + core::vector3df(-1.f, 1.f, -1.f), + core::vector3df(-1.f, -1.f, -1.f), + core::vector3df(1.f, -1.f, -1.f)}}; + + const core::vector3df texcoordData[4] = { + texcoordCubeData[layer][(flip) ? 3 : 0], + texcoordCubeData[layer][(flip) ? 2 : 1], + texcoordCubeData[layer][(flip) ? 1 : 2], + texcoordCubeData[layer][(flip) ? 0 : 3]}; + + glTexCoordPointer(3, GL_FLOAT, sizeof(core::vector3df), texcoordData); + } else { + f32 modificator = (flip) ? 1.f : 0.f; + + core::vector2df texcoordData[4] = { + core::vector2df(0.f, 0.f + modificator), + core::vector2df(1.f, 0.f + modificator), + core::vector2df(1.f, 1.f - modificator), + core::vector2df(0.f, 1.f - modificator)}; + + glTexCoordPointer(2, GL_FLOAT, sizeof(core::vector2df), texcoordData); + } + + glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_SHORT, Quad2DIndices); +} + +//! draws a set of 2d images, using a color and the alpha channel of the +//! texture if desired. +void COpenGLDriver::draw2DImageBatch(const video::ITexture *texture, + const core::array> &positions, + const core::array> &sourceRects, + const core::rect *clipRect, + SColor color, + bool useAlphaChannelOfTexture) +{ + if (!texture) + return; + + const u32 drawCount = core::min_(positions.size(), sourceRects.size()); + + const core::dimension2d &ss = texture->getOriginalSize(); + const f32 invW = 1.f / static_cast(ss.Width); + const f32 invH = 1.f / static_cast(ss.Height); + const core::dimension2d &renderTargetSize = getCurrentRenderTargetSize(); + + disableTextures(1); + if (!CacheHandler->getTextureCache().set(0, texture)) + return; + setRenderStates2DMode(color.getAlpha() < 255, true, useAlphaChannelOfTexture); + + Quad2DVertices[0].Color = color; + Quad2DVertices[1].Color = color; + Quad2DVertices[2].Color = color; + Quad2DVertices[3].Color = color; + + if (!FeatureAvailable[IRR_ARB_vertex_array_bgra] && !FeatureAvailable[IRR_EXT_vertex_array_bgra]) + getColorBuffer(Quad2DVertices, 4, EVT_STANDARD); + + CacheHandler->setClientState(true, false, true, true); + + glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].TCoords); + glVertexPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].Pos); + +#ifdef GL_BGRA + const GLint colorSize = (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) ? GL_BGRA : 4; +#else + const GLint colorSize = 4; +#endif + if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) + glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].Color); + else { + _IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); + glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); + } + + for (u32 i = 0; i < drawCount; ++i) { + if (!sourceRects[i].isValid()) + continue; + + core::position2d targetPos(positions[i]); + core::position2d sourcePos(sourceRects[i].UpperLeftCorner); + // This needs to be signed as it may go negative. + core::dimension2d sourceSize(sourceRects[i].getSize()); + if (clipRect) { + if (targetPos.X < clipRect->UpperLeftCorner.X) { + sourceSize.Width += targetPos.X - clipRect->UpperLeftCorner.X; + if (sourceSize.Width <= 0) + continue; + + sourcePos.X -= targetPos.X - clipRect->UpperLeftCorner.X; + targetPos.X = clipRect->UpperLeftCorner.X; + } + + if (targetPos.X + sourceSize.Width > clipRect->LowerRightCorner.X) { + sourceSize.Width -= (targetPos.X + sourceSize.Width) - clipRect->LowerRightCorner.X; + if (sourceSize.Width <= 0) + continue; + } + + if (targetPos.Y < clipRect->UpperLeftCorner.Y) { + sourceSize.Height += targetPos.Y - clipRect->UpperLeftCorner.Y; + if (sourceSize.Height <= 0) + continue; + + sourcePos.Y -= targetPos.Y - clipRect->UpperLeftCorner.Y; + targetPos.Y = clipRect->UpperLeftCorner.Y; + } + + if (targetPos.Y + sourceSize.Height > clipRect->LowerRightCorner.Y) { + sourceSize.Height -= (targetPos.Y + sourceSize.Height) - clipRect->LowerRightCorner.Y; + if (sourceSize.Height <= 0) + continue; + } + } + + // clip these coordinates + + if (targetPos.X < 0) { + sourceSize.Width += targetPos.X; + if (sourceSize.Width <= 0) + continue; + + sourcePos.X -= targetPos.X; + targetPos.X = 0; + } + + if (targetPos.X + sourceSize.Width > (s32)renderTargetSize.Width) { + sourceSize.Width -= (targetPos.X + sourceSize.Width) - renderTargetSize.Width; + if (sourceSize.Width <= 0) + continue; + } + + if (targetPos.Y < 0) { + sourceSize.Height += targetPos.Y; + if (sourceSize.Height <= 0) + continue; + + sourcePos.Y -= targetPos.Y; + targetPos.Y = 0; + } + + if (targetPos.Y + sourceSize.Height > (s32)renderTargetSize.Height) { + sourceSize.Height -= (targetPos.Y + sourceSize.Height) - renderTargetSize.Height; + if (sourceSize.Height <= 0) + continue; + } + + // ok, we've clipped everything. + // now draw it. + + const core::rect tcoords( + sourcePos.X * invW, + sourcePos.Y * invH, + (sourcePos.X + sourceSize.Width) * invW, + (sourcePos.Y + sourceSize.Height) * invH); + + const core::rect poss(targetPos, sourceSize); + + Quad2DVertices[0].Pos = core::vector3df((f32)poss.UpperLeftCorner.X, (f32)poss.UpperLeftCorner.Y, 0.0f); + Quad2DVertices[1].Pos = core::vector3df((f32)poss.LowerRightCorner.X, (f32)poss.UpperLeftCorner.Y, 0.0f); + Quad2DVertices[2].Pos = core::vector3df((f32)poss.LowerRightCorner.X, (f32)poss.LowerRightCorner.Y, 0.0f); + Quad2DVertices[3].Pos = core::vector3df((f32)poss.UpperLeftCorner.X, (f32)poss.LowerRightCorner.Y, 0.0f); + + Quad2DVertices[0].TCoords = core::vector2df(tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); + Quad2DVertices[1].TCoords = core::vector2df(tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); + Quad2DVertices[2].TCoords = core::vector2df(tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); + Quad2DVertices[3].TCoords = core::vector2df(tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); + + glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_SHORT, Quad2DIndices); + } +} + +//! draw a 2d rectangle +void COpenGLDriver::draw2DRectangle(SColor color, const core::rect &position, + const core::rect *clip) +{ + disableTextures(); + setRenderStates2DMode(color.getAlpha() < 255, false, false); + + core::rect pos = position; + + if (clip) + pos.clipAgainst(*clip); + + if (!pos.isValid()) + return; + + glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); + glRectf(GLfloat(pos.UpperLeftCorner.X), GLfloat(pos.UpperLeftCorner.Y), + GLfloat(pos.LowerRightCorner.X), GLfloat(pos.LowerRightCorner.Y)); +} + +//! draw an 2d rectangle +void COpenGLDriver::draw2DRectangle(const core::rect &position, + SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, + const core::rect *clip) +{ + core::rect pos = position; + + if (clip) + pos.clipAgainst(*clip); + + if (!pos.isValid()) + return; + + disableTextures(); + + setRenderStates2DMode(colorLeftUp.getAlpha() < 255 || + colorRightUp.getAlpha() < 255 || + colorLeftDown.getAlpha() < 255 || + colorRightDown.getAlpha() < 255, + false, false); + + Quad2DVertices[0].Color = colorLeftUp; + Quad2DVertices[1].Color = colorRightUp; + Quad2DVertices[2].Color = colorRightDown; + Quad2DVertices[3].Color = colorLeftDown; + + Quad2DVertices[0].Pos = core::vector3df((f32)pos.UpperLeftCorner.X, (f32)pos.UpperLeftCorner.Y, 0.0f); + Quad2DVertices[1].Pos = core::vector3df((f32)pos.LowerRightCorner.X, (f32)pos.UpperLeftCorner.Y, 0.0f); + Quad2DVertices[2].Pos = core::vector3df((f32)pos.LowerRightCorner.X, (f32)pos.LowerRightCorner.Y, 0.0f); + Quad2DVertices[3].Pos = core::vector3df((f32)pos.UpperLeftCorner.X, (f32)pos.LowerRightCorner.Y, 0.0f); + + if (!FeatureAvailable[IRR_ARB_vertex_array_bgra] && !FeatureAvailable[IRR_EXT_vertex_array_bgra]) + getColorBuffer(Quad2DVertices, 4, EVT_STANDARD); + + CacheHandler->setClientState(true, false, true, false); + + glVertexPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].Pos); + +#ifdef GL_BGRA + const GLint colorSize = (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) ? GL_BGRA : 4; +#else + const GLint colorSize = 4; +#endif + if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) + glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].Color); + else { + _IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); + glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); + } + + glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_SHORT, Quad2DIndices); +} + +//! Draws a 2d line. +void COpenGLDriver::draw2DLine(const core::position2d &start, + const core::position2d &end, SColor color) +{ + { + disableTextures(); + setRenderStates2DMode(color.getAlpha() < 255, false, false); + + Quad2DVertices[0].Color = color; + Quad2DVertices[1].Color = color; + + Quad2DVertices[0].Pos = core::vector3df((f32)start.X, (f32)start.Y, 0.0f); + Quad2DVertices[1].Pos = core::vector3df((f32)end.X, (f32)end.Y, 0.0f); + + if (!FeatureAvailable[IRR_ARB_vertex_array_bgra] && !FeatureAvailable[IRR_EXT_vertex_array_bgra]) + getColorBuffer(Quad2DVertices, 2, EVT_STANDARD); + + CacheHandler->setClientState(true, false, true, false); + + glVertexPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].Pos); + +#ifdef GL_BGRA + const GLint colorSize = (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) ? GL_BGRA : 4; +#else + const GLint colorSize = 4; +#endif + if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) + glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].Color); + else { + _IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); + glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); + } + + glDrawElements(GL_LINES, 2, GL_UNSIGNED_SHORT, Quad2DIndices); + + // Draw sometimes non-drawn first & last pixel (search for "diamond exit rule") + // HACK this messes with alpha blending + glDrawArrays(GL_POINTS, 0, 1); + glDrawArrays(GL_POINTS, 1, 1); + } +} + +//! disables all textures beginning with the optional fromStage parameter. Otherwise all texture stages are disabled. +//! Returns whether disabling was successful or not. +bool COpenGLDriver::disableTextures(u32 fromStage) +{ + bool result = true; + for (u32 i = fromStage; i < Feature.MaxTextureUnits; ++i) { + result &= CacheHandler->getTextureCache().set(i, 0, EST_ACTIVE_ON_CHANGE); + } + return result; +} + +//! creates a matrix in supplied GLfloat array to pass to OpenGL +inline void COpenGLDriver::getGLMatrix(GLfloat gl_matrix[16], const core::matrix4 &m) +{ + memcpy(gl_matrix, m.pointer(), 16 * sizeof(f32)); +} + +//! creates a opengltexturematrix from a D3D style texture matrix +inline void COpenGLDriver::getGLTextureMatrix(GLfloat *o, const core::matrix4 &m) +{ + o[0] = m[0]; + o[1] = m[1]; + o[2] = 0.f; + o[3] = 0.f; + + o[4] = m[4]; + o[5] = m[5]; + o[6] = 0.f; + o[7] = 0.f; + + o[8] = 0.f; + o[9] = 0.f; + o[10] = 1.f; + o[11] = 0.f; + + o[12] = m[8]; + o[13] = m[9]; + o[14] = 0.f; + o[15] = 1.f; +} + +ITexture *COpenGLDriver::createDeviceDependentTexture(const io::path &name, IImage *image) +{ + core::array imageArray(1); + imageArray.push_back(image); + + COpenGLTexture *texture = new COpenGLTexture(name, imageArray, ETT_2D, this); + + return texture; +} + +ITexture *COpenGLDriver::createDeviceDependentTextureCubemap(const io::path &name, const core::array &image) +{ + COpenGLTexture *texture = new COpenGLTexture(name, image, ETT_CUBEMAP, this); + + return texture; +} + +void COpenGLDriver::disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag) +{ + CNullDriver::disableFeature(feature, flag); + + if (feature == EVDF_TEXTURE_CUBEMAP_SEAMLESS) { + if (queryFeature(feature)) + glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + else if (COpenGLExtensionHandler::queryFeature(feature)) + glDisable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + } +} + +//! Sets a material. All 3d drawing functions draw geometry now using this material. +void COpenGLDriver::setMaterial(const SMaterial &material) +{ + Material = material; + OverrideMaterial.apply(Material); + + for (u32 i = 0; i < Feature.MaxTextureUnits; ++i) { + const ITexture *texture = Material.getTexture(i); + CacheHandler->getTextureCache().set(i, texture, EST_ACTIVE_ON_CHANGE); + if (texture) { + setTransform((E_TRANSFORMATION_STATE)(ETS_TEXTURE_0 + i), material.getTextureMatrix(i)); + } + } +} + +//! prints error if an error happened. +bool COpenGLDriver::testGLError(int code) +{ +#ifdef _DEBUG + GLenum g = glGetError(); + switch (g) { + case GL_NO_ERROR: + return false; + case GL_INVALID_ENUM: + os::Printer::log("GL_INVALID_ENUM", core::stringc(code).c_str(), ELL_ERROR); + break; + case GL_INVALID_VALUE: + os::Printer::log("GL_INVALID_VALUE", core::stringc(code).c_str(), ELL_ERROR); + break; + case GL_INVALID_OPERATION: + os::Printer::log("GL_INVALID_OPERATION", core::stringc(code).c_str(), ELL_ERROR); + break; + case GL_STACK_OVERFLOW: + os::Printer::log("GL_STACK_OVERFLOW", core::stringc(code).c_str(), ELL_ERROR); + break; + case GL_STACK_UNDERFLOW: + os::Printer::log("GL_STACK_UNDERFLOW", core::stringc(code).c_str(), ELL_ERROR); + break; + case GL_OUT_OF_MEMORY: + os::Printer::log("GL_OUT_OF_MEMORY", core::stringc(code).c_str(), ELL_ERROR); + break; + case GL_TABLE_TOO_LARGE: + os::Printer::log("GL_TABLE_TOO_LARGE", core::stringc(code).c_str(), ELL_ERROR); + break; +#if defined(GL_EXT_framebuffer_object) + case GL_INVALID_FRAMEBUFFER_OPERATION_EXT: + os::Printer::log("GL_INVALID_FRAMEBUFFER_OPERATION", core::stringc(code).c_str(), ELL_ERROR); + break; +#endif + }; + // _IRR_DEBUG_BREAK_IF(true); + return true; +#else + return false; +#endif +} + +//! sets the needed renderstates +void COpenGLDriver::setRenderStates3DMode() +{ + if (CurrentRenderMode != ERM_3D) { + // Reset Texture Stages + CacheHandler->setBlend(false); + CacheHandler->setAlphaTest(false); + CacheHandler->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + CacheHandler->setActiveTexture(GL_TEXTURE0_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + // switch back the matrices + CacheHandler->setMatrixMode(GL_MODELVIEW); + glLoadMatrixf((Matrices[ETS_VIEW] * Matrices[ETS_WORLD]).pointer()); + + CacheHandler->setMatrixMode(GL_PROJECTION); + glLoadMatrixf(Matrices[ETS_PROJECTION].pointer()); + + ResetRenderStates = true; +#ifdef GL_EXT_clip_volume_hint + if (FeatureAvailable[IRR_EXT_clip_volume_hint]) + glHint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT, GL_NICEST); +#endif + } + + if (ResetRenderStates || LastMaterial != Material) { + // unset old material + + if (LastMaterial.MaterialType != Material.MaterialType && + static_cast(LastMaterial.MaterialType) < MaterialRenderers.size()) + MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial(); + + // set new material. + if (static_cast(Material.MaterialType) < MaterialRenderers.size()) + MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial( + Material, LastMaterial, ResetRenderStates, this); + + LastMaterial = Material; + CacheHandler->correctCacheMaterial(LastMaterial); + ResetRenderStates = false; + } + + if (static_cast(Material.MaterialType) < MaterialRenderers.size()) + MaterialRenderers[Material.MaterialType].Renderer->OnRender(this, video::EVT_STANDARD); + + CurrentRenderMode = ERM_3D; +} + +//! Get native wrap mode value +GLint COpenGLDriver::getTextureWrapMode(const u8 clamp) +{ + GLint mode = GL_REPEAT; + switch (clamp) { + case ETC_REPEAT: + mode = GL_REPEAT; + break; + case ETC_CLAMP: + mode = GL_CLAMP; + break; + case ETC_CLAMP_TO_EDGE: +#ifdef GL_VERSION_1_2 + if (Version > 101) + mode = GL_CLAMP_TO_EDGE; + else +#endif +#ifdef GL_SGIS_texture_edge_clamp + if (FeatureAvailable[IRR_SGIS_texture_edge_clamp]) + mode = GL_CLAMP_TO_EDGE_SGIS; + else +#endif + // fallback + mode = GL_CLAMP; + break; + case ETC_CLAMP_TO_BORDER: +#ifdef GL_VERSION_1_3 + if (Version > 102) + mode = GL_CLAMP_TO_BORDER; + else +#endif +#ifdef GL_ARB_texture_border_clamp + if (FeatureAvailable[IRR_ARB_texture_border_clamp]) + mode = GL_CLAMP_TO_BORDER_ARB; + else +#endif +#ifdef GL_SGIS_texture_border_clamp + if (FeatureAvailable[IRR_SGIS_texture_border_clamp]) + mode = GL_CLAMP_TO_BORDER_SGIS; + else +#endif + // fallback + mode = GL_CLAMP; + break; + case ETC_MIRROR: +#ifdef GL_VERSION_1_4 + if (Version > 103) + mode = GL_MIRRORED_REPEAT; + else +#endif +#ifdef GL_ARB_texture_border_clamp + if (FeatureAvailable[IRR_ARB_texture_mirrored_repeat]) + mode = GL_MIRRORED_REPEAT_ARB; + else +#endif +#ifdef GL_IBM_texture_mirrored_repeat + if (FeatureAvailable[IRR_IBM_texture_mirrored_repeat]) + mode = GL_MIRRORED_REPEAT_IBM; + else +#endif + mode = GL_REPEAT; + break; + case ETC_MIRROR_CLAMP: +#ifdef GL_EXT_texture_mirror_clamp + if (FeatureAvailable[IRR_EXT_texture_mirror_clamp]) + mode = GL_MIRROR_CLAMP_EXT; + else +#endif +#if defined(GL_ATI_texture_mirror_once) + if (FeatureAvailable[IRR_ATI_texture_mirror_once]) + mode = GL_MIRROR_CLAMP_ATI; + else +#endif + mode = GL_CLAMP; + break; + case ETC_MIRROR_CLAMP_TO_EDGE: +#ifdef GL_EXT_texture_mirror_clamp + if (FeatureAvailable[IRR_EXT_texture_mirror_clamp]) + mode = GL_MIRROR_CLAMP_TO_EDGE_EXT; + else +#endif +#if defined(GL_ATI_texture_mirror_once) + if (FeatureAvailable[IRR_ATI_texture_mirror_once]) + mode = GL_MIRROR_CLAMP_TO_EDGE_ATI; + else +#endif + mode = GL_CLAMP; + break; + case ETC_MIRROR_CLAMP_TO_BORDER: +#ifdef GL_EXT_texture_mirror_clamp + if (FeatureAvailable[IRR_EXT_texture_mirror_clamp]) + mode = GL_MIRROR_CLAMP_TO_BORDER_EXT; + else +#endif + mode = GL_CLAMP; + break; + } + return mode; +} + +//! Can be called by an IMaterialRenderer to make its work easier. +void COpenGLDriver::setBasicRenderStates(const SMaterial &material, const SMaterial &lastmaterial, + bool resetAllRenderStates) +{ + // Fixed pipeline isn't important for shader based materials + + E_OPENGL_FIXED_PIPELINE_STATE tempState = FixedPipelineState; + + if (resetAllRenderStates || tempState == EOFPS_ENABLE || tempState == EOFPS_DISABLE_TO_ENABLE) { + // material colors + if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE || + lastmaterial.ColorMaterial != material.ColorMaterial) { + switch (material.ColorMaterial) { + case ECM_NONE: + glDisable(GL_COLOR_MATERIAL); + break; + case ECM_DIFFUSE: + glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); + break; + case ECM_AMBIENT: + glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT); + break; + case ECM_EMISSIVE: + glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION); + break; + case ECM_SPECULAR: + glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); + break; + case ECM_DIFFUSE_AND_AMBIENT: + glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); + break; + } + if (material.ColorMaterial != ECM_NONE) + glEnable(GL_COLOR_MATERIAL); + } + + if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE || + lastmaterial.AmbientColor != material.AmbientColor || + lastmaterial.DiffuseColor != material.DiffuseColor || + lastmaterial.EmissiveColor != material.EmissiveColor || + lastmaterial.ColorMaterial != material.ColorMaterial) { + GLfloat color[4]; + + const f32 inv = 1.0f / 255.0f; + + if ((material.ColorMaterial != video::ECM_AMBIENT) && + (material.ColorMaterial != video::ECM_DIFFUSE_AND_AMBIENT)) { + color[0] = material.AmbientColor.getRed() * inv; + color[1] = material.AmbientColor.getGreen() * inv; + color[2] = material.AmbientColor.getBlue() * inv; + color[3] = material.AmbientColor.getAlpha() * inv; + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color); + } + + if ((material.ColorMaterial != video::ECM_DIFFUSE) && + (material.ColorMaterial != video::ECM_DIFFUSE_AND_AMBIENT)) { + color[0] = material.DiffuseColor.getRed() * inv; + color[1] = material.DiffuseColor.getGreen() * inv; + color[2] = material.DiffuseColor.getBlue() * inv; + color[3] = material.DiffuseColor.getAlpha() * inv; + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color); + } + + if (material.ColorMaterial != video::ECM_EMISSIVE) { + color[0] = material.EmissiveColor.getRed() * inv; + color[1] = material.EmissiveColor.getGreen() * inv; + color[2] = material.EmissiveColor.getBlue() * inv; + color[3] = material.EmissiveColor.getAlpha() * inv; + glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, color); + } + } + + if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE || + lastmaterial.SpecularColor != material.SpecularColor || + lastmaterial.Shininess != material.Shininess || + lastmaterial.ColorMaterial != material.ColorMaterial) { + GLfloat color[4] = {0.f, 0.f, 0.f, 1.f}; + const f32 inv = 1.0f / 255.0f; + + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material.Shininess); + // disable Specular colors if no shininess is set + if ((material.Shininess != 0.0f) && + (material.ColorMaterial != video::ECM_SPECULAR)) { +#ifdef GL_EXT_separate_specular_color + if (FeatureAvailable[IRR_EXT_separate_specular_color]) + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); +#endif + color[0] = material.SpecularColor.getRed() * inv; + color[1] = material.SpecularColor.getGreen() * inv; + color[2] = material.SpecularColor.getBlue() * inv; + color[3] = material.SpecularColor.getAlpha() * inv; + } +#ifdef GL_EXT_separate_specular_color + else if (FeatureAvailable[IRR_EXT_separate_specular_color]) + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR); +#endif + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color); + } + + // shademode + if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE || + lastmaterial.GouraudShading != material.GouraudShading) { + if (material.GouraudShading) + glShadeModel(GL_SMOOTH); + else + glShadeModel(GL_FLAT); + } + + // lighting + if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE || + lastmaterial.Lighting != material.Lighting) { + if (material.Lighting) + glEnable(GL_LIGHTING); + else + glDisable(GL_LIGHTING); + } + + // fog + if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE || + lastmaterial.FogEnable != material.FogEnable) { + if (material.FogEnable) + glEnable(GL_FOG); + else + glDisable(GL_FOG); + } + + // normalization + if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE || + lastmaterial.NormalizeNormals != material.NormalizeNormals) { + if (material.NormalizeNormals) + glEnable(GL_NORMALIZE); + else + glDisable(GL_NORMALIZE); + } + + // Set fixed pipeline as active. + tempState = EOFPS_ENABLE; + } else if (tempState == EOFPS_ENABLE_TO_DISABLE) { + glDisable(GL_COLOR_MATERIAL); + glDisable(GL_LIGHTING); + glDisable(GL_FOG); + glDisable(GL_NORMALIZE); + + // Set programmable pipeline as active. + tempState = EOFPS_DISABLE; + } + + // tempState == EOFPS_DISABLE - driver doesn't calls functions related to fixed pipeline. + + // fillmode - fixed pipeline call, but it emulate GL_LINES behaviour in rendering, so it stay here. + if (resetAllRenderStates || (lastmaterial.Wireframe != material.Wireframe) || (lastmaterial.PointCloud != material.PointCloud)) + glPolygonMode(GL_FRONT_AND_BACK, material.Wireframe ? GL_LINE : material.PointCloud ? GL_POINT + : GL_FILL); + + // ZBuffer + switch (material.ZBuffer) { + case ECFN_DISABLED: + CacheHandler->setDepthTest(false); + break; + case ECFN_LESSEQUAL: + CacheHandler->setDepthTest(true); + CacheHandler->setDepthFunc(GL_LEQUAL); + break; + case ECFN_EQUAL: + CacheHandler->setDepthTest(true); + CacheHandler->setDepthFunc(GL_EQUAL); + break; + case ECFN_LESS: + CacheHandler->setDepthTest(true); + CacheHandler->setDepthFunc(GL_LESS); + break; + case ECFN_NOTEQUAL: + CacheHandler->setDepthTest(true); + CacheHandler->setDepthFunc(GL_NOTEQUAL); + break; + case ECFN_GREATEREQUAL: + CacheHandler->setDepthTest(true); + CacheHandler->setDepthFunc(GL_GEQUAL); + break; + case ECFN_GREATER: + CacheHandler->setDepthTest(true); + CacheHandler->setDepthFunc(GL_GREATER); + break; + case ECFN_ALWAYS: + CacheHandler->setDepthTest(true); + CacheHandler->setDepthFunc(GL_ALWAYS); + break; + case ECFN_NEVER: + CacheHandler->setDepthTest(true); + CacheHandler->setDepthFunc(GL_NEVER); + break; + default: + break; + } + + // ZWrite + if (getWriteZBuffer(material)) { + CacheHandler->setDepthMask(true); + } else { + CacheHandler->setDepthMask(false); + } + + // Back face culling + if ((material.FrontfaceCulling) && (material.BackfaceCulling)) { + CacheHandler->setCullFaceFunc(GL_FRONT_AND_BACK); + CacheHandler->setCullFace(true); + } else if (material.BackfaceCulling) { + CacheHandler->setCullFaceFunc(GL_BACK); + CacheHandler->setCullFace(true); + } else if (material.FrontfaceCulling) { + CacheHandler->setCullFaceFunc(GL_FRONT); + CacheHandler->setCullFace(true); + } else { + CacheHandler->setCullFace(false); + } + + // Color Mask + CacheHandler->setColorMask(material.ColorMask); + + // Blend Equation + if (material.BlendOperation == EBO_NONE) + CacheHandler->setBlend(false); + else { + CacheHandler->setBlend(true); + +#if defined(GL_EXT_blend_subtract) || defined(GL_EXT_blend_minmax) || defined(GL_EXT_blend_logic_op) || defined(GL_VERSION_1_4) + if (queryFeature(EVDF_BLEND_OPERATIONS)) { + switch (material.BlendOperation) { + case EBO_SUBTRACT: +#if defined(GL_VERSION_1_4) + CacheHandler->setBlendEquation(GL_FUNC_SUBTRACT); +#elif defined(GL_EXT_blend_subtract) + CacheHandler->setBlendEquation(GL_FUNC_SUBTRACT_EXT); +#endif + break; + case EBO_REVSUBTRACT: +#if defined(GL_VERSION_1_4) + CacheHandler->setBlendEquation(GL_FUNC_REVERSE_SUBTRACT); +#elif defined(GL_EXT_blend_subtract) + CacheHandler->setBlendEquation(GL_FUNC_REVERSE_SUBTRACT_EXT); +#endif + break; + case EBO_MIN: +#if defined(GL_VERSION_1_4) + CacheHandler->setBlendEquation(GL_MIN); +#elif defined(GL_EXT_blend_minmax) + CacheHandler->setBlendEquation(GL_MIN_EXT); +#endif + break; + case EBO_MAX: +#if defined(GL_VERSION_1_4) + CacheHandler->setBlendEquation(GL_MAX); +#elif defined(GL_EXT_blend_minmax) + CacheHandler->setBlendEquation(GL_MAX_EXT); +#endif + break; + case EBO_MIN_FACTOR: +#if defined(GL_AMD_blend_minmax_factor) + if (FeatureAvailable[IRR_AMD_blend_minmax_factor]) + CacheHandler->setBlendEquation(GL_FACTOR_MIN_AMD); +#endif + // fallback in case of missing extension +#if defined(GL_VERSION_1_4) +#if defined(GL_AMD_blend_minmax_factor) + else +#endif + CacheHandler->setBlendEquation(GL_MIN); +#endif + break; + case EBO_MAX_FACTOR: +#if defined(GL_AMD_blend_minmax_factor) + if (FeatureAvailable[IRR_AMD_blend_minmax_factor]) + CacheHandler->setBlendEquation(GL_FACTOR_MAX_AMD); +#endif + // fallback in case of missing extension +#if defined(GL_VERSION_1_4) +#if defined(GL_AMD_blend_minmax_factor) + else +#endif + CacheHandler->setBlendEquation(GL_MAX); +#endif + break; + case EBO_MIN_ALPHA: +#if defined(GL_SGIX_blend_alpha_minmax) + if (FeatureAvailable[IRR_SGIX_blend_alpha_minmax]) + CacheHandler->setBlendEquation(GL_ALPHA_MIN_SGIX); + // fallback in case of missing extension + else if (FeatureAvailable[IRR_EXT_blend_minmax]) + CacheHandler->setBlendEquation(GL_MIN_EXT); +#endif + break; + case EBO_MAX_ALPHA: +#if defined(GL_SGIX_blend_alpha_minmax) + if (FeatureAvailable[IRR_SGIX_blend_alpha_minmax]) + CacheHandler->setBlendEquation(GL_ALPHA_MAX_SGIX); + // fallback in case of missing extension + else if (FeatureAvailable[IRR_EXT_blend_minmax]) + CacheHandler->setBlendEquation(GL_MAX_EXT); +#endif + break; + default: +#if defined(GL_VERSION_1_4) + CacheHandler->setBlendEquation(GL_FUNC_ADD); +#elif defined(GL_EXT_blend_subtract) || defined(GL_EXT_blend_minmax) || defined(GL_EXT_blend_logic_op) + CacheHandler->setBlendEquation(GL_FUNC_ADD_EXT); +#endif + break; + } + } +#endif + } + + // Blend Factor + if (IR(material.BlendFactor) & 0xFFFFFFFF // TODO: why the & 0xFFFFFFFF? + && material.MaterialType != EMT_ONETEXTURE_BLEND) { + E_BLEND_FACTOR srcRGBFact = EBF_ZERO; + E_BLEND_FACTOR dstRGBFact = EBF_ZERO; + E_BLEND_FACTOR srcAlphaFact = EBF_ZERO; + E_BLEND_FACTOR dstAlphaFact = EBF_ZERO; + E_MODULATE_FUNC modulo = EMFN_MODULATE_1X; + u32 alphaSource = 0; + + unpack_textureBlendFuncSeparate(srcRGBFact, dstRGBFact, srcAlphaFact, dstAlphaFact, modulo, alphaSource, material.BlendFactor); + + if (queryFeature(EVDF_BLEND_SEPARATE)) { + CacheHandler->setBlendFuncSeparate(getGLBlend(srcRGBFact), getGLBlend(dstRGBFact), + getGLBlend(srcAlphaFact), getGLBlend(dstAlphaFact)); + } else { + CacheHandler->setBlendFunc(getGLBlend(srcRGBFact), getGLBlend(dstRGBFact)); + } + } + + // Polygon Offset + if (queryFeature(EVDF_POLYGON_OFFSET) && (resetAllRenderStates || + lastmaterial.PolygonOffsetSlopeScale != material.PolygonOffsetSlopeScale || + lastmaterial.PolygonOffsetDepthBias != material.PolygonOffsetDepthBias)) { + glDisable(lastmaterial.Wireframe ? GL_POLYGON_OFFSET_LINE : lastmaterial.PointCloud ? GL_POLYGON_OFFSET_POINT + : GL_POLYGON_OFFSET_FILL); + if (material.PolygonOffsetSlopeScale || material.PolygonOffsetDepthBias) { + glEnable(material.Wireframe ? GL_POLYGON_OFFSET_LINE : material.PointCloud ? GL_POLYGON_OFFSET_POINT + : GL_POLYGON_OFFSET_FILL); + + glPolygonOffset(material.PolygonOffsetSlopeScale, material.PolygonOffsetDepthBias); + } else { + glPolygonOffset(0.0f, 0.f); + } + } + + // thickness + if (resetAllRenderStates || lastmaterial.Thickness != material.Thickness) { + if (AntiAlias) { + // glPointSize(core::clamp(static_cast(material.Thickness), DimSmoothedPoint[0], DimSmoothedPoint[1])); + // we don't use point smoothing + glPointSize(core::clamp(static_cast(material.Thickness), DimAliasedPoint[0], DimAliasedPoint[1])); + glLineWidth(core::clamp(static_cast(material.Thickness), DimSmoothedLine[0], DimSmoothedLine[1])); + } else { + glPointSize(core::clamp(static_cast(material.Thickness), DimAliasedPoint[0], DimAliasedPoint[1])); + glLineWidth(core::clamp(static_cast(material.Thickness), DimAliasedLine[0], DimAliasedLine[1])); + } + } + + // Anti aliasing + if ((resetAllRenderStates || lastmaterial.AntiAliasing != material.AntiAliasing) && FeatureAvailable[IRR_ARB_multisample]) { + if (material.AntiAliasing & EAAM_ALPHA_TO_COVERAGE) + glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB); + else if (lastmaterial.AntiAliasing & EAAM_ALPHA_TO_COVERAGE) + glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB); + + if ((AntiAlias >= 2) && (material.AntiAliasing & (EAAM_SIMPLE | EAAM_QUALITY))) { + glEnable(GL_MULTISAMPLE_ARB); +#ifdef GL_NV_multisample_filter_hint + if (FeatureAvailable[IRR_NV_multisample_filter_hint]) { + if ((material.AntiAliasing & EAAM_QUALITY) == EAAM_QUALITY) + glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST); + else + glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_FASTEST); + } +#endif + } else + glDisable(GL_MULTISAMPLE_ARB); + } + + // Texture parameters + setTextureRenderStates(material, resetAllRenderStates); + + // set current fixed pipeline state + FixedPipelineState = tempState; +} + +//! Compare in SMaterial doesn't check texture parameters, so we should call this on each OnRender call. +void COpenGLDriver::setTextureRenderStates(const SMaterial &material, bool resetAllRenderstates) +{ + // Set textures to TU/TIU and apply filters to them + + for (s32 i = Feature.MaxTextureUnits - 1; i >= 0; --i) { + bool fixedPipeline = false; + + if (FixedPipelineState == EOFPS_ENABLE || FixedPipelineState == EOFPS_DISABLE_TO_ENABLE) + fixedPipeline = true; + + const COpenGLTexture *tmpTexture = CacheHandler->getTextureCache().get(i); + + if (tmpTexture) { + CacheHandler->setActiveTexture(GL_TEXTURE0 + i); + + // Minetest uses the first texture matrix even with the programmable pipeline + if (fixedPipeline || i == 0) { + const bool isRTT = tmpTexture->isRenderTarget(); + + CacheHandler->setMatrixMode(GL_TEXTURE); + + if (!isRTT && Matrices[ETS_TEXTURE_0 + i].isIdentity()) + glLoadIdentity(); + else { + GLfloat glmat[16]; + if (isRTT) + getGLTextureMatrix(glmat, Matrices[ETS_TEXTURE_0 + i] * TextureFlipMatrix); + else + getGLTextureMatrix(glmat, Matrices[ETS_TEXTURE_0 + i]); + glLoadMatrixf(glmat); + } + } + + const GLenum tmpType = tmpTexture->getOpenGLTextureType(); + + COpenGLTexture::SStatesCache &statesCache = tmpTexture->getStatesCache(); + + if (resetAllRenderstates) + statesCache.IsCached = false; + +#ifdef GL_VERSION_2_1 + if (Version >= 201) { + if (!statesCache.IsCached || material.TextureLayers[i].LODBias != statesCache.LODBias) { + if (material.TextureLayers[i].LODBias) { + const float tmp = core::clamp(material.TextureLayers[i].LODBias * 0.125f, -MaxTextureLODBias, MaxTextureLODBias); + glTexParameterf(tmpType, GL_TEXTURE_LOD_BIAS, tmp); + } else + glTexParameterf(tmpType, GL_TEXTURE_LOD_BIAS, 0.f); + + statesCache.LODBias = material.TextureLayers[i].LODBias; + } + } else if (FeatureAvailable[IRR_EXT_texture_lod_bias]) { + if (material.TextureLayers[i].LODBias) { + const float tmp = core::clamp(material.TextureLayers[i].LODBias * 0.125f, -MaxTextureLODBias, MaxTextureLODBias); + glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, tmp); + } else + glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0.f); + } +#elif defined(GL_EXT_texture_lod_bias) + if (FeatureAvailable[IRR_EXT_texture_lod_bias]) { + if (material.TextureLayers[i].LODBias) { + const float tmp = core::clamp(material.TextureLayers[i].LODBias * 0.125f, -MaxTextureLODBias, MaxTextureLODBias); + glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, tmp); + } else + glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0.f); + } +#endif + + if (!statesCache.IsCached || material.TextureLayers[i].MagFilter != statesCache.MagFilter) { + E_TEXTURE_MAG_FILTER magFilter = material.TextureLayers[i].MagFilter; + glTexParameteri(tmpType, GL_TEXTURE_MAG_FILTER, + magFilter == ETMAGF_NEAREST ? GL_NEAREST : (assert(magFilter == ETMAGF_LINEAR), GL_LINEAR)); + + statesCache.MagFilter = magFilter; + } + + if (material.UseMipMaps && tmpTexture->hasMipMaps()) { + if (!statesCache.IsCached || material.TextureLayers[i].MinFilter != statesCache.MinFilter || + !statesCache.MipMapStatus) { + E_TEXTURE_MIN_FILTER minFilter = material.TextureLayers[i].MinFilter; + glTexParameteri(tmpType, GL_TEXTURE_MIN_FILTER, + minFilter == ETMINF_NEAREST_MIPMAP_NEAREST ? GL_NEAREST_MIPMAP_NEAREST : minFilter == ETMINF_LINEAR_MIPMAP_NEAREST ? GL_LINEAR_MIPMAP_NEAREST + : minFilter == ETMINF_NEAREST_MIPMAP_LINEAR ? GL_NEAREST_MIPMAP_LINEAR + : (assert(minFilter == ETMINF_LINEAR_MIPMAP_LINEAR), GL_LINEAR_MIPMAP_LINEAR)); + + statesCache.MinFilter = minFilter; + statesCache.MipMapStatus = true; + } + } else { + if (!statesCache.IsCached || material.TextureLayers[i].MinFilter != statesCache.MinFilter || + statesCache.MipMapStatus) { + E_TEXTURE_MIN_FILTER minFilter = material.TextureLayers[i].MinFilter; + glTexParameteri(tmpType, GL_TEXTURE_MIN_FILTER, + (minFilter == ETMINF_NEAREST_MIPMAP_NEAREST || minFilter == ETMINF_NEAREST_MIPMAP_LINEAR) ? GL_NEAREST : (assert(minFilter == ETMINF_LINEAR_MIPMAP_NEAREST || minFilter == ETMINF_LINEAR_MIPMAP_LINEAR), GL_LINEAR)); + + statesCache.MinFilter = minFilter; + statesCache.MipMapStatus = false; + } + } + +#ifdef GL_EXT_texture_filter_anisotropic + if (FeatureAvailable[IRR_EXT_texture_filter_anisotropic] && + (!statesCache.IsCached || material.TextureLayers[i].AnisotropicFilter != statesCache.AnisotropicFilter)) { + glTexParameteri(tmpType, GL_TEXTURE_MAX_ANISOTROPY_EXT, + material.TextureLayers[i].AnisotropicFilter > 1 ? core::min_(MaxAnisotropy, material.TextureLayers[i].AnisotropicFilter) : 1); + + statesCache.AnisotropicFilter = material.TextureLayers[i].AnisotropicFilter; + } +#endif + + if (!statesCache.IsCached || material.TextureLayers[i].TextureWrapU != statesCache.WrapU) { + glTexParameteri(tmpType, GL_TEXTURE_WRAP_S, getTextureWrapMode(material.TextureLayers[i].TextureWrapU)); + statesCache.WrapU = material.TextureLayers[i].TextureWrapU; + } + + if (!statesCache.IsCached || material.TextureLayers[i].TextureWrapV != statesCache.WrapV) { + glTexParameteri(tmpType, GL_TEXTURE_WRAP_T, getTextureWrapMode(material.TextureLayers[i].TextureWrapV)); + statesCache.WrapV = material.TextureLayers[i].TextureWrapV; + } + + if (!statesCache.IsCached || material.TextureLayers[i].TextureWrapW != statesCache.WrapW) { + glTexParameteri(tmpType, GL_TEXTURE_WRAP_R, getTextureWrapMode(material.TextureLayers[i].TextureWrapW)); + statesCache.WrapW = material.TextureLayers[i].TextureWrapW; + } + + statesCache.IsCached = true; + } + } +} + +//! Enable the 2d override material +void COpenGLDriver::enableMaterial2D(bool enable) +{ + if (!enable) + CurrentRenderMode = ERM_NONE; + CNullDriver::enableMaterial2D(enable); +} + +//! sets the needed renderstates +void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel) +{ + // 2d methods uses fixed pipeline + if (FixedPipelineState == COpenGLDriver::EOFPS_DISABLE) + FixedPipelineState = COpenGLDriver::EOFPS_DISABLE_TO_ENABLE; + else + FixedPipelineState = COpenGLDriver::EOFPS_ENABLE; + + bool resetAllRenderStates = false; + + if (CurrentRenderMode != ERM_2D || Transformation3DChanged) { + // unset last 3d material + if (CurrentRenderMode == ERM_3D) { + if (static_cast(LastMaterial.MaterialType) < MaterialRenderers.size()) + MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial(); + } + + if (Transformation3DChanged) { + CacheHandler->setMatrixMode(GL_PROJECTION); + + const core::dimension2d &renderTargetSize = getCurrentRenderTargetSize(); + core::matrix4 m(core::matrix4::EM4CONST_NOTHING); + m.buildProjectionMatrixOrthoLH(f32(renderTargetSize.Width), f32(-(s32)(renderTargetSize.Height)), -1.0f, 1.0f); + m.setTranslation(core::vector3df(-1, 1, 0)); + glLoadMatrixf(m.pointer()); + + CacheHandler->setMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.375f, 0.375f, 0.0f); + + Transformation3DChanged = false; + } + + CacheHandler->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + CacheHandler->setBlendEquation(GL_FUNC_ADD); + +#ifdef GL_EXT_clip_volume_hint + if (FeatureAvailable[IRR_EXT_clip_volume_hint]) + glHint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT, GL_FASTEST); +#endif + + resetAllRenderStates = true; + } + + SMaterial currentMaterial = (!OverrideMaterial2DEnabled) ? InitMaterial2D : OverrideMaterial2D; + currentMaterial.Lighting = false; + + if (texture) { + setTransform(ETS_TEXTURE_0, core::IdentityMatrix); + + // Due to the transformation change, the previous line would call a reset each frame + // but we can safely reset the variable as it was false before + Transformation3DChanged = false; + } else { + CacheHandler->getTextureCache().set(0, 0); + } + + setBasicRenderStates(currentMaterial, LastMaterial, resetAllRenderStates); + + LastMaterial = currentMaterial; + CacheHandler->correctCacheMaterial(LastMaterial); + + // no alphaChannel without texture + alphaChannel &= texture; + + if (alphaChannel || alpha) { + CacheHandler->setBlend(true); + CacheHandler->setAlphaTest(true); + CacheHandler->setAlphaFunc(GL_GREATER, 0.f); + } else { + CacheHandler->setBlend(false); + CacheHandler->setAlphaTest(false); + } + + if (texture) { + CacheHandler->setActiveTexture(GL_TEXTURE0_ARB); + + if (alphaChannel) { + // if alpha and alpha texture just modulate, otherwise use only the alpha channel + if (alpha) { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + } else { +#if defined(GL_ARB_texture_env_combine) || defined(GL_EXT_texture_env_combine) + if (FeatureAvailable[IRR_ARB_texture_env_combine] || FeatureAvailable[IRR_EXT_texture_env_combine]) { +#ifdef GL_ARB_texture_env_combine + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE); + // rgb always modulates + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PRIMARY_COLOR_ARB); +#else + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); + // rgb always modulates + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT); +#endif + } else +#endif + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + } + } else { + if (alpha) { +#if defined(GL_ARB_texture_env_combine) || defined(GL_EXT_texture_env_combine) + if (FeatureAvailable[IRR_ARB_texture_env_combine] || FeatureAvailable[IRR_EXT_texture_env_combine]) { +#ifdef GL_ARB_texture_env_combine + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PRIMARY_COLOR_ARB); + // rgb always modulates + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PRIMARY_COLOR_ARB); +#else + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT); + // rgb always modulates + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT); +#endif + } else +#endif + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + } else { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + } + } + } + + CurrentRenderMode = ERM_2D; +} + +//! \return Returns the name of the video driver. +const char *COpenGLDriver::getName() const +{ + return Name.c_str(); +} + +//! Sets the dynamic ambient light color. The default color is +//! (0,0,0,0) which means it is dark. +//! \param color: New color of the ambient light. +void COpenGLDriver::setAmbientLight(const SColorf &color) +{ + CNullDriver::setAmbientLight(color); + GLfloat data[4] = {color.r, color.g, color.b, color.a}; + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, data); +} + +// this code was sent in by Oliver Klems, thank you! (I modified the glViewport +// method just a bit. +void COpenGLDriver::setViewPort(const core::rect &area) +{ + core::rect vp = area; + core::rect rendert(0, 0, getCurrentRenderTargetSize().Width, getCurrentRenderTargetSize().Height); + vp.clipAgainst(rendert); + + if (vp.getHeight() > 0 && vp.getWidth() > 0) + CacheHandler->setViewport(vp.UpperLeftCorner.X, getCurrentRenderTargetSize().Height - vp.UpperLeftCorner.Y - vp.getHeight(), vp.getWidth(), vp.getHeight()); + + ViewPort = vp; +} + +void COpenGLDriver::setViewPortRaw(u32 width, u32 height) +{ + CacheHandler->setViewport(0, 0, width, height); + ViewPort = core::recti(0, 0, width, height); +} + +//! Sets the fog mode. +void COpenGLDriver::setFog(SColor c, E_FOG_TYPE fogType, f32 start, + f32 end, f32 density, bool pixelFog, bool rangeFog) +{ + CNullDriver::setFog(c, fogType, start, end, density, pixelFog, rangeFog); + + glFogf(GL_FOG_MODE, GLfloat((fogType == EFT_FOG_LINEAR) ? GL_LINEAR : (fogType == EFT_FOG_EXP) ? GL_EXP + : GL_EXP2)); + +#ifdef GL_EXT_fog_coord + if (FeatureAvailable[IRR_EXT_fog_coord]) + glFogi(GL_FOG_COORDINATE_SOURCE, GL_FRAGMENT_DEPTH); +#endif +#ifdef GL_NV_fog_distance + if (FeatureAvailable[IRR_NV_fog_distance]) { + if (rangeFog) + glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_RADIAL_NV); + else + glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV); + } +#endif + + if (fogType == EFT_FOG_LINEAR) { + glFogf(GL_FOG_START, start); + glFogf(GL_FOG_END, end); + } else + glFogf(GL_FOG_DENSITY, density); + + if (pixelFog) + glHint(GL_FOG_HINT, GL_NICEST); + else + glHint(GL_FOG_HINT, GL_FASTEST); + + SColorf color(c); + GLfloat data[4] = {color.r, color.g, color.b, color.a}; + glFogfv(GL_FOG_COLOR, data); +} + +//! Draws a 3d box. +void COpenGLDriver::draw3DBox(const core::aabbox3d &box, SColor color) +{ + core::vector3df edges[8]; + box.getEdges(edges); + + setRenderStates3DMode(); + + video::S3DVertex v[24]; + + for (u32 i = 0; i < 24; i++) + v[i].Color = color; + + v[0].Pos = edges[5]; + v[1].Pos = edges[1]; + v[2].Pos = edges[1]; + v[3].Pos = edges[3]; + v[4].Pos = edges[3]; + v[5].Pos = edges[7]; + v[6].Pos = edges[7]; + v[7].Pos = edges[5]; + v[8].Pos = edges[0]; + v[9].Pos = edges[2]; + v[10].Pos = edges[2]; + v[11].Pos = edges[6]; + v[12].Pos = edges[6]; + v[13].Pos = edges[4]; + v[14].Pos = edges[4]; + v[15].Pos = edges[0]; + v[16].Pos = edges[1]; + v[17].Pos = edges[0]; + v[18].Pos = edges[3]; + v[19].Pos = edges[2]; + v[20].Pos = edges[7]; + v[21].Pos = edges[6]; + v[22].Pos = edges[5]; + v[23].Pos = edges[4]; + + if (!FeatureAvailable[IRR_ARB_vertex_array_bgra] && !FeatureAvailable[IRR_EXT_vertex_array_bgra]) + getColorBuffer(v, 24, EVT_STANDARD); + + CacheHandler->setClientState(true, false, true, false); + + glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex), &(static_cast(v))[0].Pos); + +#ifdef GL_BGRA + const GLint colorSize = (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) ? GL_BGRA : 4; +#else + const GLint colorSize = 4; +#endif + if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) + glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast(v))[0].Color); + else { + _IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); + glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); + } + + glDrawArrays(GL_LINES, 0, 24); +} + +//! Draws a 3d line. +void COpenGLDriver::draw3DLine(const core::vector3df &start, + const core::vector3df &end, SColor color) +{ + setRenderStates3DMode(); + + Quad2DVertices[0].Color = color; + Quad2DVertices[1].Color = color; + + Quad2DVertices[0].Pos = core::vector3df((f32)start.X, (f32)start.Y, (f32)start.Z); + Quad2DVertices[1].Pos = core::vector3df((f32)end.X, (f32)end.Y, (f32)end.Z); + + if (!FeatureAvailable[IRR_ARB_vertex_array_bgra] && !FeatureAvailable[IRR_EXT_vertex_array_bgra]) + getColorBuffer(Quad2DVertices, 2, EVT_STANDARD); + + CacheHandler->setClientState(true, false, true, false); + + glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].Pos); + +#ifdef GL_BGRA + const GLint colorSize = (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) ? GL_BGRA : 4; +#else + const GLint colorSize = 4; +#endif + if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) + glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].Color); + else { + _IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); + glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); + } + + glDrawElements(GL_LINES, 2, GL_UNSIGNED_SHORT, Quad2DIndices); +} + +//! Removes a texture from the texture cache and deletes it, freeing lot of memory. +void COpenGLDriver::removeTexture(ITexture *texture) +{ + CacheHandler->getTextureCache().remove(texture); + CNullDriver::removeTexture(texture); +} + +//! Check if the driver supports creating textures with the given color format +bool COpenGLDriver::queryTextureFormat(ECOLOR_FORMAT format) const +{ + GLint dummyInternalFormat; + GLenum dummyPixelFormat; + GLenum dummyPixelType; + void (*dummyConverter)(const void *, s32, void *); + return getColorFormatParameters(format, dummyInternalFormat, dummyPixelFormat, dummyPixelType, &dummyConverter); +} + +bool COpenGLDriver::needsTransparentRenderPass(const irr::video::SMaterial &material) const +{ + return CNullDriver::needsTransparentRenderPass(material) || material.isAlphaBlendOperation(); +} + +//! Only used by the internal engine. Used to notify the driver that +//! the window was resized. +void COpenGLDriver::OnResize(const core::dimension2d &size) +{ + CNullDriver::OnResize(size); + CacheHandler->setViewport(0, 0, size.Width, size.Height); + Transformation3DChanged = true; +} + +//! Returns type of video driver +E_DRIVER_TYPE COpenGLDriver::getDriverType() const +{ + return EDT_OPENGL; +} + +//! returns color format +ECOLOR_FORMAT COpenGLDriver::getColorFormat() const +{ + return ColorFormat; +} + +//! Get a vertex shader constant index. +s32 COpenGLDriver::getVertexShaderConstantID(const c8 *name) +{ + return getPixelShaderConstantID(name); +} + +//! Get a pixel shader constant index. +s32 COpenGLDriver::getPixelShaderConstantID(const c8 *name) +{ + os::Printer::log("Error: Please call services->getPixelShaderConstantID(), not VideoDriver->getPixelShaderConstantID()."); + return -1; +} + +//! Sets a constant for the vertex shader based on an index. +bool COpenGLDriver::setVertexShaderConstant(s32 index, const f32 *floats, int count) +{ + // pass this along, as in GLSL the same routine is used for both vertex and fragment shaders + return setPixelShaderConstant(index, floats, count); +} + +//! Int interface for the above. +bool COpenGLDriver::setVertexShaderConstant(s32 index, const s32 *ints, int count) +{ + return setPixelShaderConstant(index, ints, count); +} + +//! Uint interface for the above. +bool COpenGLDriver::setVertexShaderConstant(s32 index, const u32 *ints, int count) +{ + return setPixelShaderConstant(index, ints, count); +} + +//! Sets a constant for the pixel shader based on an index. +bool COpenGLDriver::setPixelShaderConstant(s32 index, const f32 *floats, int count) +{ + os::Printer::log("Error: Please call services->setPixelShaderConstant(), not VideoDriver->setPixelShaderConstant()."); + return false; +} + +//! Int interface for the above. +bool COpenGLDriver::setPixelShaderConstant(s32 index, const s32 *ints, int count) +{ + os::Printer::log("Error: Please call services->setPixelShaderConstant(), not VideoDriver->setPixelShaderConstant()."); + return false; +} + +bool COpenGLDriver::setPixelShaderConstant(s32 index, const u32 *ints, int count) +{ + os::Printer::log("Error: Please call services->setPixelShaderConstant(), not VideoDriver->setPixelShaderConstant()."); + return false; +} + +//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry. +s32 COpenGLDriver::addHighLevelShaderMaterial( + const c8 *vertexShaderProgram, + const c8 *vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, + const c8 *pixelShaderProgram, + const c8 *pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, + const c8 *geometryShaderProgram, + const c8 *geometryShaderEntryPointName, + E_GEOMETRY_SHADER_TYPE gsCompileTarget, + scene::E_PRIMITIVE_TYPE inType, + scene::E_PRIMITIVE_TYPE outType, + u32 verticesOut, + IShaderConstantSetCallBack *callback, + E_MATERIAL_TYPE baseMaterial, + s32 userData) +{ + s32 nr = -1; + + COpenGLSLMaterialRenderer *r = new COpenGLSLMaterialRenderer( + this, nr, + vertexShaderProgram, vertexShaderEntryPointName, vsCompileTarget, + pixelShaderProgram, pixelShaderEntryPointName, psCompileTarget, + geometryShaderProgram, geometryShaderEntryPointName, gsCompileTarget, + inType, outType, verticesOut, + callback, baseMaterial, userData); + + r->drop(); + + return nr; +} + +//! Returns a pointer to the IVideoDriver interface. (Implementation for +//! IMaterialRendererServices) +IVideoDriver *COpenGLDriver::getVideoDriver() +{ + return this; +} + +ITexture *COpenGLDriver::addRenderTargetTexture(const core::dimension2d &size, + const io::path &name, const ECOLOR_FORMAT format) +{ + if (IImage::isCompressedFormat(format)) + return 0; + + // disable mip-mapping + bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS); + setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false); + + bool supportForFBO = (Feature.ColorAttachment > 0); + + core::dimension2du destSize(size); + + if (!supportForFBO) { + destSize = core::dimension2d(core::min_(size.Width, ScreenSize.Width), core::min_(size.Height, ScreenSize.Height)); + destSize = destSize.getOptimalSize((size == size.getOptimalSize()), false, false); + } + + COpenGLTexture *renderTargetTexture = new COpenGLTexture(name, destSize, ETT_2D, format, this); + addTexture(renderTargetTexture); + renderTargetTexture->drop(); + + // restore mip-mapping + setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, generateMipLevels); + + return renderTargetTexture; +} + +//! Creates a render target texture for a cubemap +ITexture *COpenGLDriver::addRenderTargetTextureCubemap(const irr::u32 sideLen, const io::path &name, const ECOLOR_FORMAT format) +{ + if (IImage::isCompressedFormat(format)) + return 0; + + // disable mip-mapping + bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS); + setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false); + + bool supportForFBO = (Feature.ColorAttachment > 0); + + const core::dimension2d size(sideLen, sideLen); + core::dimension2du destSize(size); + + if (!supportForFBO) { + destSize = core::dimension2d(core::min_(size.Width, ScreenSize.Width), core::min_(size.Height, ScreenSize.Height)); + destSize = destSize.getOptimalSize((size == size.getOptimalSize()), false, false); + } + + COpenGLTexture *renderTargetTexture = new COpenGLTexture(name, destSize, ETT_CUBEMAP, format, this); + addTexture(renderTargetTexture); + renderTargetTexture->drop(); + + // restore mip-mapping + setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, generateMipLevels); + + return renderTargetTexture; +} + +//! Returns the maximum amount of primitives (mostly vertices) which +//! the device is able to render with one drawIndexedTriangleList +//! call. +u32 COpenGLDriver::getMaximalPrimitiveCount() const +{ + return 0x7fffffff; +} + +bool COpenGLDriver::setRenderTargetEx(IRenderTarget *target, u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil) +{ + if (target && target->getDriverType() != EDT_OPENGL) { + os::Printer::log("Fatal Error: Tried to set a render target not owned by this driver.", ELL_ERROR); + return false; + } + + bool supportForFBO = (Feature.ColorAttachment > 0); + + core::dimension2d destRenderTargetSize(0, 0); + + if (target) { + COpenGLRenderTarget *renderTarget = static_cast(target); + + if (supportForFBO) { + CacheHandler->setFBO(renderTarget->getBufferID()); + renderTarget->update(); + } + + destRenderTargetSize = renderTarget->getSize(); + + setViewPortRaw(destRenderTargetSize.Width, destRenderTargetSize.Height); + } else { + if (supportForFBO) + CacheHandler->setFBO(0); + else { + COpenGLRenderTarget *prevRenderTarget = static_cast(CurrentRenderTarget); + COpenGLTexture *renderTargetTexture = static_cast(prevRenderTarget->getTexture()); + + if (renderTargetTexture) { + const COpenGLTexture *prevTexture = CacheHandler->getTextureCache()[0]; + + CacheHandler->getTextureCache().set(0, renderTargetTexture); + + const core::dimension2d size = renderTargetTexture->getSize(); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, size.Width, size.Height); + + CacheHandler->getTextureCache().set(0, prevTexture); + } + } + + destRenderTargetSize = core::dimension2d(0, 0); + + setViewPortRaw(ScreenSize.Width, ScreenSize.Height); + } + + if (CurrentRenderTargetSize != destRenderTargetSize) { + CurrentRenderTargetSize = destRenderTargetSize; + + Transformation3DChanged = true; + } + + CurrentRenderTarget = target; + + if (!supportForFBO) { + clearFlag |= ECBF_COLOR; + clearFlag |= ECBF_DEPTH; + } + + clearBuffers(clearFlag, clearColor, clearDepth, clearStencil); + + return true; +} + +void COpenGLDriver::clearBuffers(u16 flag, SColor color, f32 depth, u8 stencil) +{ + GLbitfield mask = 0; + u8 colorMask = 0; + bool depthMask = false; + + CacheHandler->getColorMask(colorMask); + CacheHandler->getDepthMask(depthMask); + + if (flag & ECBF_COLOR) { + CacheHandler->setColorMask(ECP_ALL); + + const f32 inv = 1.0f / 255.0f; + glClearColor(color.getRed() * inv, color.getGreen() * inv, + color.getBlue() * inv, color.getAlpha() * inv); + + mask |= GL_COLOR_BUFFER_BIT; + } + + if (flag & ECBF_DEPTH) { + CacheHandler->setDepthMask(true); + glClearDepth(depth); + mask |= GL_DEPTH_BUFFER_BIT; + } + + if (flag & ECBF_STENCIL) { + glClearStencil(stencil); + mask |= GL_STENCIL_BUFFER_BIT; + } + + if (mask) + glClear(mask); + + CacheHandler->setColorMask(colorMask); + CacheHandler->setDepthMask(depthMask); +} + +//! Returns an image created from the last rendered frame. +IImage *COpenGLDriver::createScreenShot(video::ECOLOR_FORMAT format, video::E_RENDER_TARGET target) +{ + if (target != video::ERT_FRAME_BUFFER) + return 0; + + if (format == video::ECF_UNKNOWN) + format = getColorFormat(); + + // TODO: Maybe we could support more formats (floating point and some of those beyond ECF_R8), didn't really try yet + if (IImage::isCompressedFormat(format) || IImage::isDepthFormat(format) || IImage::isFloatingPointFormat(format) || format >= ECF_R8) + return 0; + + // allows to read pixels in top-to-bottom order +#ifdef GL_MESA_pack_invert + if (FeatureAvailable[IRR_MESA_pack_invert]) + glPixelStorei(GL_PACK_INVERT_MESA, GL_TRUE); +#endif + + GLenum fmt; + GLenum type; + + switch (format) { + case ECF_A1R5G5B5: + fmt = GL_BGRA; + type = GL_UNSIGNED_SHORT_1_5_5_5_REV; + break; + case ECF_R5G6B5: + fmt = GL_RGB; + type = GL_UNSIGNED_SHORT_5_6_5; + break; + case ECF_R8G8B8: + fmt = GL_RGB; + type = GL_UNSIGNED_BYTE; + break; + case ECF_A8R8G8B8: + fmt = GL_BGRA; + if (Version > 101) + type = GL_UNSIGNED_INT_8_8_8_8_REV; + else + type = GL_UNSIGNED_BYTE; + break; + default: + fmt = GL_BGRA; + type = GL_UNSIGNED_BYTE; + break; + } + IImage *newImage = createImage(format, ScreenSize); + + u8 *pixels = 0; + if (newImage) + pixels = static_cast(newImage->getData()); + if (pixels) { + glReadBuffer(GL_FRONT); + glReadPixels(0, 0, ScreenSize.Width, ScreenSize.Height, fmt, type, pixels); + testGLError(__LINE__); + glReadBuffer(GL_BACK); + } + +#ifdef GL_MESA_pack_invert + if (FeatureAvailable[IRR_MESA_pack_invert]) + glPixelStorei(GL_PACK_INVERT_MESA, GL_FALSE); + else +#endif + if (pixels && newImage) { + // opengl images are horizontally flipped, so we have to fix that here. + const s32 pitch = newImage->getPitch(); + u8 *p2 = pixels + (ScreenSize.Height - 1) * pitch; + u8 *tmpBuffer = new u8[pitch]; + for (u32 i = 0; i < ScreenSize.Height; i += 2) { + memcpy(tmpBuffer, pixels, pitch); + // for (u32 j=0; jdrop(); + return 0; + } + } + return newImage; +} + +//! Set/unset a clipping plane. +bool COpenGLDriver::setClipPlane(u32 index, const core::plane3df &plane, bool enable) +{ + if (index >= MaxUserClipPlanes) + return false; + + UserClipPlanes[index].Plane = plane; + enableClipPlane(index, enable); + return true; +} + +void COpenGLDriver::uploadClipPlane(u32 index) +{ + // opengl needs an array of doubles for the plane equation + GLdouble clip_plane[4]; + clip_plane[0] = UserClipPlanes[index].Plane.Normal.X; + clip_plane[1] = UserClipPlanes[index].Plane.Normal.Y; + clip_plane[2] = UserClipPlanes[index].Plane.Normal.Z; + clip_plane[3] = UserClipPlanes[index].Plane.D; + glClipPlane(GL_CLIP_PLANE0 + index, clip_plane); +} + +//! Enable/disable a clipping plane. +void COpenGLDriver::enableClipPlane(u32 index, bool enable) +{ + if (index >= MaxUserClipPlanes) + return; + if (enable) { + if (!UserClipPlanes[index].Enabled) { + uploadClipPlane(index); + glEnable(GL_CLIP_PLANE0 + index); + } + } else + glDisable(GL_CLIP_PLANE0 + index); + + UserClipPlanes[index].Enabled = enable; +} + +core::dimension2du COpenGLDriver::getMaxTextureSize() const +{ + return core::dimension2du(MaxTextureSize, MaxTextureSize); +} + +//! Convert E_PRIMITIVE_TYPE to OpenGL equivalent +GLenum COpenGLDriver::primitiveTypeToGL(scene::E_PRIMITIVE_TYPE type) const +{ + switch (type) { + case scene::EPT_POINTS: + return GL_POINTS; + case scene::EPT_LINE_STRIP: + return GL_LINE_STRIP; + case scene::EPT_LINE_LOOP: + return GL_LINE_LOOP; + case scene::EPT_LINES: + return GL_LINES; + case scene::EPT_TRIANGLE_STRIP: + return GL_TRIANGLE_STRIP; + case scene::EPT_TRIANGLE_FAN: + return GL_TRIANGLE_FAN; + case scene::EPT_TRIANGLES: + return GL_TRIANGLES; + case scene::EPT_POINT_SPRITES: +#ifdef GL_ARB_point_sprite + return GL_POINT_SPRITE_ARB; +#else + return GL_POINTS; +#endif + } + return GL_TRIANGLES; +} + +GLenum COpenGLDriver::getGLBlend(E_BLEND_FACTOR factor) const +{ + GLenum r = 0; + switch (factor) { + case EBF_ZERO: + r = GL_ZERO; + break; + case EBF_ONE: + r = GL_ONE; + break; + case EBF_DST_COLOR: + r = GL_DST_COLOR; + break; + case EBF_ONE_MINUS_DST_COLOR: + r = GL_ONE_MINUS_DST_COLOR; + break; + case EBF_SRC_COLOR: + r = GL_SRC_COLOR; + break; + case EBF_ONE_MINUS_SRC_COLOR: + r = GL_ONE_MINUS_SRC_COLOR; + break; + case EBF_SRC_ALPHA: + r = GL_SRC_ALPHA; + break; + case EBF_ONE_MINUS_SRC_ALPHA: + r = GL_ONE_MINUS_SRC_ALPHA; + break; + case EBF_DST_ALPHA: + r = GL_DST_ALPHA; + break; + case EBF_ONE_MINUS_DST_ALPHA: + r = GL_ONE_MINUS_DST_ALPHA; + break; + case EBF_SRC_ALPHA_SATURATE: + r = GL_SRC_ALPHA_SATURATE; + break; + } + return r; +} + +GLenum COpenGLDriver::getZBufferBits() const +{ + GLenum bits = 0; + switch (Params.ZBufferBits) { + case 16: + bits = GL_DEPTH_COMPONENT16; + break; + case 24: + bits = GL_DEPTH_COMPONENT24; + break; + case 32: + bits = GL_DEPTH_COMPONENT32; + break; + default: + bits = GL_DEPTH_COMPONENT; + break; + } + return bits; +} + +bool COpenGLDriver::getColorFormatParameters(ECOLOR_FORMAT format, GLint &internalFormat, GLenum &pixelFormat, + GLenum &pixelType, void (**converter)(const void *, s32, void *)) const +{ + // NOTE: Converter variable not used here, but don't remove, it's used in the OGL-ES drivers. + + bool supported = false; + internalFormat = GL_RGBA; + pixelFormat = GL_RGBA; + pixelType = GL_UNSIGNED_BYTE; + + switch (format) { + case ECF_A1R5G5B5: + supported = true; + internalFormat = GL_RGBA; + pixelFormat = GL_BGRA_EXT; + pixelType = GL_UNSIGNED_SHORT_1_5_5_5_REV; + break; + case ECF_R5G6B5: + supported = true; + internalFormat = GL_RGB; + pixelFormat = GL_RGB; + pixelType = GL_UNSIGNED_SHORT_5_6_5; + break; + case ECF_R8G8B8: + supported = true; + internalFormat = GL_RGB; + pixelFormat = GL_RGB; + pixelType = GL_UNSIGNED_BYTE; + break; + case ECF_A8R8G8B8: + supported = true; + internalFormat = GL_RGBA; + pixelFormat = GL_BGRA_EXT; + if (Version > 101) + pixelType = GL_UNSIGNED_INT_8_8_8_8_REV; + break; + case ECF_D16: + supported = true; + internalFormat = GL_DEPTH_COMPONENT16; + pixelFormat = GL_DEPTH_COMPONENT; + pixelType = GL_UNSIGNED_SHORT; + break; + case ECF_D32: + supported = true; + internalFormat = GL_DEPTH_COMPONENT32; + pixelFormat = GL_DEPTH_COMPONENT; + pixelType = GL_UNSIGNED_INT; + break; + case ECF_D24S8: +#ifdef GL_VERSION_3_0 + if (Version >= 300) { + supported = true; + internalFormat = GL_DEPTH_STENCIL; + pixelFormat = GL_DEPTH_STENCIL; + pixelType = GL_UNSIGNED_INT_24_8; + } else +#endif +#ifdef GL_EXT_packed_depth_stencil + if (queryOpenGLFeature(COpenGLExtensionHandler::IRR_EXT_packed_depth_stencil)) { + supported = true; + internalFormat = GL_DEPTH_STENCIL_EXT; + pixelFormat = GL_DEPTH_STENCIL_EXT; + pixelType = GL_UNSIGNED_INT_24_8_EXT; + } +#endif + break; + case ECF_R8: + if (queryOpenGLFeature(COpenGLExtensionHandler::IRR_ARB_texture_rg)) { + supported = true; + internalFormat = GL_R8; + pixelFormat = GL_RED; + pixelType = GL_UNSIGNED_BYTE; + } + break; + case ECF_R8G8: + if (queryOpenGLFeature(COpenGLExtensionHandler::IRR_ARB_texture_rg)) { + supported = true; + internalFormat = GL_RG8; + pixelFormat = GL_RG; + pixelType = GL_UNSIGNED_BYTE; + } + break; + case ECF_R16: + if (queryOpenGLFeature(COpenGLExtensionHandler::IRR_ARB_texture_rg)) { + supported = true; + internalFormat = GL_R16; + pixelFormat = GL_RED; + pixelType = GL_UNSIGNED_SHORT; + } + break; + case ECF_R16G16: + if (queryOpenGLFeature(COpenGLExtensionHandler::IRR_ARB_texture_rg)) { + supported = true; + internalFormat = GL_RG16; + pixelFormat = GL_RG; + pixelType = GL_UNSIGNED_SHORT; + } + break; + case ECF_R16F: + if (queryOpenGLFeature(COpenGLExtensionHandler::IRR_ARB_texture_rg)) { + supported = true; + internalFormat = GL_R16F; + pixelFormat = GL_RED; +#ifdef GL_ARB_half_float_pixel + if (queryOpenGLFeature(COpenGLExtensionHandler::IRR_ARB_half_float_pixel)) + pixelType = GL_HALF_FLOAT_ARB; + else +#endif + pixelType = GL_FLOAT; + } + break; + case ECF_G16R16F: + if (queryOpenGLFeature(COpenGLExtensionHandler::IRR_ARB_texture_rg)) { + supported = true; + internalFormat = GL_RG16F; + pixelFormat = GL_RG; +#ifdef GL_ARB_half_float_pixel + if (queryOpenGLFeature(COpenGLExtensionHandler::IRR_ARB_half_float_pixel)) + pixelType = GL_HALF_FLOAT_ARB; + else +#endif + pixelType = GL_FLOAT; + } + break; + case ECF_A16B16G16R16F: + if (queryOpenGLFeature(COpenGLExtensionHandler::IRR_ARB_texture_float)) { + supported = true; + internalFormat = GL_RGBA16F_ARB; + pixelFormat = GL_RGBA; +#ifdef GL_ARB_half_float_pixel + if (queryOpenGLFeature(COpenGLExtensionHandler::IRR_ARB_half_float_pixel)) + pixelType = GL_HALF_FLOAT_ARB; + else +#endif + pixelType = GL_FLOAT; + } + break; + case ECF_R32F: + if (queryOpenGLFeature(COpenGLExtensionHandler::IRR_ARB_texture_rg)) { + supported = true; + internalFormat = GL_R32F; + pixelFormat = GL_RED; + pixelType = GL_FLOAT; + } + break; + case ECF_G32R32F: + if (queryOpenGLFeature(COpenGLExtensionHandler::IRR_ARB_texture_rg)) { + supported = true; + internalFormat = GL_RG32F; + pixelFormat = GL_RG; + pixelType = GL_FLOAT; + } + break; + case ECF_A32B32G32R32F: + if (queryOpenGLFeature(COpenGLExtensionHandler::IRR_ARB_texture_float)) { + supported = true; + internalFormat = GL_RGBA32F_ARB; + pixelFormat = GL_RGBA; + pixelType = GL_FLOAT; + } + break; + default: + break; + } + + return supported; +} + +COpenGLDriver::E_OPENGL_FIXED_PIPELINE_STATE COpenGLDriver::getFixedPipelineState() const +{ + return FixedPipelineState; +} + +void COpenGLDriver::setFixedPipelineState(COpenGLDriver::E_OPENGL_FIXED_PIPELINE_STATE state) +{ + FixedPipelineState = state; +} + +const SMaterial &COpenGLDriver::getCurrentMaterial() const +{ + return Material; +} + +COpenGLCacheHandler *COpenGLDriver::getCacheHandler() const +{ + return CacheHandler; +} + +} // end namespace +} // end namespace + +#endif // _IRR_COMPILE_WITH_OPENGL_ + +namespace irr +{ +namespace video +{ + +IVideoDriver *createOpenGLDriver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager) +{ +#ifdef _IRR_COMPILE_WITH_OPENGL_ + COpenGLDriver *ogl = new COpenGLDriver(params, io, contextManager); + + if (!ogl->initDriver()) { + ogl->drop(); + ogl = 0; + } + + return ogl; +#else + return 0; +#endif +} + +} // end namespace +} // end namespace diff --git a/irr/src/COpenGLDriver.h b/irr/src/COpenGLDriver.h new file mode 100644 index 000000000..6fe8ac37d --- /dev/null +++ b/irr/src/COpenGLDriver.h @@ -0,0 +1,437 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#pragma once + +#include "SIrrCreationParameters.h" + +namespace irr +{ +class CIrrDeviceWin32; +class CIrrDeviceLinux; +class CIrrDeviceSDL; +class CIrrDeviceMacOSX; +} + +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#include "IMaterialRendererServices.h" +#include "CNullDriver.h" + +#include "COpenGLExtensionHandler.h" +#include "IContextManager.h" + +namespace irr +{ + +namespace video +{ +class IContextManager; + +class COpenGLDriver : public CNullDriver, public IMaterialRendererServices, public COpenGLExtensionHandler +{ +public: + // Information about state of fixed pipeline activity. + enum E_OPENGL_FIXED_PIPELINE_STATE + { + EOFPS_ENABLE = 0, // fixed pipeline. + EOFPS_DISABLE, // programmable pipeline. + EOFPS_ENABLE_TO_DISABLE, // switch from fixed to programmable pipeline. + EOFPS_DISABLE_TO_ENABLE // switch from programmable to fixed pipeline. + }; + + COpenGLDriver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager); + + bool initDriver(); + + //! destructor + virtual ~COpenGLDriver(); + + virtual bool beginScene(u16 clearFlag, SColor clearColor = SColor(255, 0, 0, 0), f32 clearDepth = 1.f, u8 clearStencil = 0, + const SExposedVideoData &videoData = SExposedVideoData(), core::rect *sourceRect = 0) override; + + bool endScene() override; + + //! sets transformation + void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4 &mat) override; + + struct SHWBufferLink_opengl : public SHWBufferLink + { + SHWBufferLink_opengl(const scene::IMeshBuffer *_MeshBuffer) : + SHWBufferLink(_MeshBuffer), vbo_verticesID(0), vbo_indicesID(0) {} + + GLuint vbo_verticesID; // tmp + GLuint vbo_indicesID; // tmp + + GLuint vbo_verticesSize; // tmp + GLuint vbo_indicesSize; // tmp + }; + + //! updates hardware buffer if needed + bool updateHardwareBuffer(SHWBufferLink *HWBuffer) override; + + //! Create hardware buffer from mesh + SHWBufferLink *createHardwareBuffer(const scene::IMeshBuffer *mb) override; + + //! Delete hardware buffer (only some drivers can) + void deleteHardwareBuffer(SHWBufferLink *HWBuffer) override; + + //! Draw hardware buffer + void drawHardwareBuffer(SHWBufferLink *HWBuffer) override; + + //! Create occlusion query. + /** Use node for identification and mesh for occlusion test. */ + virtual void addOcclusionQuery(scene::ISceneNode *node, + const scene::IMesh *mesh = 0) override; + + //! Remove occlusion query. + void removeOcclusionQuery(scene::ISceneNode *node) override; + + //! Run occlusion query. Draws mesh stored in query. + /** If the mesh shall not be rendered visible, use + overrideMaterial to disable the color and depth buffer. */ + void runOcclusionQuery(scene::ISceneNode *node, bool visible = false) override; + + //! Update occlusion query. Retrieves results from GPU. + /** If the query shall not block, set the flag to false. + Update might not occur in this case, though */ + void updateOcclusionQuery(scene::ISceneNode *node, bool block = true) override; + + //! Return query result. + /** Return value is the number of visible pixels/fragments. + The value is a safe approximation, i.e. can be larger then the + actual value of pixels. */ + u32 getOcclusionQueryResult(scene::ISceneNode *node) const override; + + //! Create render target. + IRenderTarget *addRenderTarget() override; + + //! draws a vertex primitive list + virtual void drawVertexPrimitiveList(const void *vertices, u32 vertexCount, + const void *indexList, u32 primitiveCount, + E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) override; + + //! draws a vertex primitive list in 2d + virtual void draw2DVertexPrimitiveList(const void *vertices, u32 vertexCount, + const void *indexList, u32 primitiveCount, + E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) override; + + //! queries the features of the driver, returns true if feature is available + bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const override + { + return FeatureEnabled[feature] && COpenGLExtensionHandler::queryFeature(feature); + } + + //! Disable a feature of the driver. + void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag = true) override; + + //! Sets a material. All 3d drawing functions draw geometry now + //! using this material. + //! \param material: Material to be used from now on. + void setMaterial(const SMaterial &material) override; + + virtual void draw2DImage(const video::ITexture *texture, const core::position2d &destPos, + const core::rect &sourceRect, const core::rect *clipRect = 0, + SColor color = SColor(255, 255, 255, 255), bool useAlphaChannelOfTexture = false) override; + + virtual void draw2DImage(const video::ITexture *texture, const core::rect &destRect, + const core::rect &sourceRect, const core::rect *clipRect = 0, + const video::SColor *const colors = 0, bool useAlphaChannelOfTexture = false) override; + + // Explicitly bring in base class methods, otherwise + // this overload would hide them. + using CNullDriver::draw2DImage; + virtual void draw2DImage(const video::ITexture *texture, u32 layer, bool flip); + + //! draws a set of 2d images, using a color and the alpha channel of the + //! texture if desired. + void draw2DImageBatch(const video::ITexture *texture, + const core::array> &positions, + const core::array> &sourceRects, + const core::rect *clipRect, + SColor color, + bool useAlphaChannelOfTexture) override; + + //! draw an 2d rectangle + virtual void draw2DRectangle(SColor color, const core::rect &pos, + const core::rect *clip = 0) override; + + //! Draws an 2d rectangle with a gradient. + virtual void draw2DRectangle(const core::rect &pos, + SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, + const core::rect *clip = 0) override; + + //! Draws a 2d line. + virtual void draw2DLine(const core::position2d &start, + const core::position2d &end, + SColor color = SColor(255, 255, 255, 255)) override; + + //! Draws a 3d box + void draw3DBox(const core::aabbox3d &box, SColor color = SColor(255, 255, 255, 255)) override; + + //! Draws a 3d line. + virtual void draw3DLine(const core::vector3df &start, + const core::vector3df &end, + SColor color = SColor(255, 255, 255, 255)) override; + + //! \return Returns the name of the video driver. Example: In case of the Direct3D8 + //! driver, it would return "Direct3D8.1". + const char *getName() const override; + + //! Sets the dynamic ambient light color. The default color is + //! (0,0,0,0) which means it is dark. + //! \param color: New color of the ambient light. + void setAmbientLight(const SColorf &color) override; + + //! sets a viewport + void setViewPort(const core::rect &area) override; + + //! Sets the fog mode. + virtual void setFog(SColor color, E_FOG_TYPE fogType, f32 start, + f32 end, f32 density, bool pixelFog, bool rangeFog) override; + + //! Only used by the internal engine. Used to notify the driver that + //! the window was resized. + void OnResize(const core::dimension2d &size) override; + + //! Returns type of video driver + E_DRIVER_TYPE getDriverType() const override; + + //! get color format of the current color buffer + ECOLOR_FORMAT getColorFormat() const override; + + //! Returns the transformation set by setTransform + const core::matrix4 &getTransform(E_TRANSFORMATION_STATE state) const override; + + //! Can be called by an IMaterialRenderer to make its work easier. + virtual void setBasicRenderStates(const SMaterial &material, const SMaterial &lastmaterial, + bool resetAllRenderstates) override; + + //! Compare in SMaterial doesn't check texture parameters, so we should call this on each OnRender call. + virtual void setTextureRenderStates(const SMaterial &material, bool resetAllRenderstates); + + //! Get a vertex shader constant index. + s32 getVertexShaderConstantID(const c8 *name) override; + + //! Get a pixel shader constant index. + s32 getPixelShaderConstantID(const c8 *name) override; + + //! Sets a constant for the vertex shader based on an index. + bool setVertexShaderConstant(s32 index, const f32 *floats, int count) override; + + //! Int interface for the above. + bool setVertexShaderConstant(s32 index, const s32 *ints, int count) override; + + //! Uint interface for the above. + bool setVertexShaderConstant(s32 index, const u32 *ints, int count) override; + + //! Sets a constant for the pixel shader based on an index. + bool setPixelShaderConstant(s32 index, const f32 *floats, int count) override; + + //! Int interface for the above. + bool setPixelShaderConstant(s32 index, const s32 *ints, int count) override; + + //! Uint interface for the above. + bool setPixelShaderConstant(s32 index, const u32 *ints, int count) override; + + //! disables all textures beginning with the optional fromStage parameter. Otherwise all texture stages are disabled. + //! Returns whether disabling was successful or not. + bool disableTextures(u32 fromStage = 0); + + //! Adds a new material renderer to the VideoDriver, using GLSL to render geometry. + virtual s32 addHighLevelShaderMaterial( + const c8 *vertexShaderProgram, + const c8 *vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, + const c8 *pixelShaderProgram, + const c8 *pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, + const c8 *geometryShaderProgram, + const c8 *geometryShaderEntryPointName = "main", + E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0, + scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES, + scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP, + u32 verticesOut = 0, + IShaderConstantSetCallBack *callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0) override; + + //! Returns a pointer to the IVideoDriver interface. (Implementation for + //! IMaterialRendererServices) + IVideoDriver *getVideoDriver() override; + + //! Returns the maximum amount of primitives (mostly vertices) which + //! the device is able to render with one drawIndexedTriangleList + //! call. + u32 getMaximalPrimitiveCount() const override; + + virtual ITexture *addRenderTargetTexture(const core::dimension2d &size, + const io::path &name, const ECOLOR_FORMAT format = ECF_UNKNOWN) override; + + //! Creates a render target texture for a cubemap + ITexture *addRenderTargetTextureCubemap(const irr::u32 sideLen, + const io::path &name, const ECOLOR_FORMAT format) override; + + virtual bool setRenderTargetEx(IRenderTarget *target, u16 clearFlag, SColor clearColor = SColor(255, 0, 0, 0), + f32 clearDepth = 1.f, u8 clearStencil = 0) override; + + void clearBuffers(u16 flag, SColor color = SColor(255, 0, 0, 0), f32 depth = 1.f, u8 stencil = 0) override; + + //! Returns an image created from the last rendered frame. + IImage *createScreenShot(video::ECOLOR_FORMAT format = video::ECF_UNKNOWN, video::E_RENDER_TARGET target = video::ERT_FRAME_BUFFER) override; + + //! checks if an OpenGL error has happened and prints it (+ some internal code which is usually the line number) + //! for performance reasons only available in debug mode + bool testGLError(int code = 0); + + //! Set/unset a clipping plane. + //! There are at least 6 clipping planes available for the user to set at will. + //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. + //! \param plane: The plane itself. + //! \param enable: If true, enable the clipping plane else disable it. + bool setClipPlane(u32 index, const core::plane3df &plane, bool enable = false) override; + + //! Enable/disable a clipping plane. + //! There are at least 6 clipping planes available for the user to set at will. + //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. + //! \param enable: If true, enable the clipping plane else disable it. + void enableClipPlane(u32 index, bool enable) override; + + //! Enable the 2d override material + void enableMaterial2D(bool enable = true) override; + + //! Returns the graphics card vendor name. + core::stringc getVendorInfo() override { return VendorName; } + + //! Returns the maximum texture size supported. + core::dimension2du getMaxTextureSize() const override; + + //! Removes a texture from the texture cache and deletes it, freeing lot of memory. + void removeTexture(ITexture *texture) override; + + //! Check if the driver supports creating textures with the given color format + bool queryTextureFormat(ECOLOR_FORMAT format) const override; + + //! Used by some SceneNodes to check if a material should be rendered in the transparent render pass + bool needsTransparentRenderPass(const irr::video::SMaterial &material) const override; + + //! Convert E_PRIMITIVE_TYPE to OpenGL equivalent + GLenum primitiveTypeToGL(scene::E_PRIMITIVE_TYPE type) const; + + //! Convert E_BLEND_FACTOR to OpenGL equivalent + GLenum getGLBlend(E_BLEND_FACTOR factor) const; + + //! Get ZBuffer bits. + GLenum getZBufferBits() const; + + bool getColorFormatParameters(ECOLOR_FORMAT format, GLint &internalFormat, GLenum &pixelFormat, + GLenum &pixelType, void (**converter)(const void *, s32, void *)) const; + + //! Return info about fixed pipeline state. + E_OPENGL_FIXED_PIPELINE_STATE getFixedPipelineState() const; + + //! Set info about fixed pipeline state. + void setFixedPipelineState(E_OPENGL_FIXED_PIPELINE_STATE state); + + //! Get current material. + const SMaterial &getCurrentMaterial() const; + + COpenGLCacheHandler *getCacheHandler() const; + +private: + bool updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer); + bool updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer); + + void uploadClipPlane(u32 index); + + //! inits the parts of the open gl driver used on all platforms + bool genericDriverInit(); + + ITexture *createDeviceDependentTexture(const io::path &name, IImage *image) override; + + ITexture *createDeviceDependentTextureCubemap(const io::path &name, const core::array &image) override; + + //! creates a transposed matrix in supplied GLfloat array to pass to OpenGL + inline void getGLMatrix(GLfloat gl_matrix[16], const core::matrix4 &m); + inline void getGLTextureMatrix(GLfloat gl_matrix[16], const core::matrix4 &m); + + //! get native wrap mode value + GLint getTextureWrapMode(const u8 clamp); + + //! sets the needed renderstates + void setRenderStates3DMode(); + + //! sets the needed renderstates + void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel); + + void createMaterialRenderers(); + + //! Assign a hardware light to the specified requested light, if any + //! free hardware lights exist. + //! \param[in] lightIndex: the index of the requesting light + void assignHardwareLight(u32 lightIndex); + + //! helper function for render setup. + void getColorBuffer(const void *vertices, u32 vertexCount, E_VERTEX_TYPE vType); + + //! helper function doing the actual rendering. + void renderArray(const void *indexList, u32 primitiveCount, + scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); + + //! Same as `CacheHandler->setViewport`, but also sets `ViewPort` + virtual void setViewPortRaw(u32 width, u32 height); + + COpenGLCacheHandler *CacheHandler; + + core::stringc Name; + core::matrix4 Matrices[ETS_COUNT]; + core::array ColorBuffer; + + //! enumeration for rendering modes such as 2d and 3d for minimizing the switching of renderStates. + enum E_RENDER_MODE + { + ERM_NONE = 0, // no render state has been set yet. + ERM_2D, // 2d drawing rendermode + ERM_3D // 3d rendering mode + }; + + E_RENDER_MODE CurrentRenderMode; + //! bool to make all renderstates reset if set to true. + bool ResetRenderStates; + bool Transformation3DChanged; + u8 AntiAlias; + + SMaterial Material, LastMaterial; + + struct SUserClipPlane + { + SUserClipPlane() : + Enabled(false) {} + core::plane3df Plane; + bool Enabled; + }; + core::array UserClipPlanes; + + core::stringc VendorName; + + core::matrix4 TextureFlipMatrix; + + //! Color buffer format + ECOLOR_FORMAT ColorFormat; + + E_OPENGL_FIXED_PIPELINE_STATE FixedPipelineState; + + SIrrlichtCreationParameters Params; + + //! Built-in 2D quad for 2D rendering. + S3DVertex Quad2DVertices[4]; + static const u16 Quad2DIndices[4]; + + IContextManager *ContextManager; +}; + +} // end namespace video +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_OPENGL_ diff --git a/irr/src/COpenGLExtensionHandler.cpp b/irr/src/COpenGLExtensionHandler.cpp new file mode 100644 index 000000000..d5aade126 --- /dev/null +++ b/irr/src/COpenGLExtensionHandler.cpp @@ -0,0 +1,626 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "COpenGLExtensionHandler.h" + +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#include "irrString.h" +#include "SMaterial.h" +#include "fast_atof.h" +#include "IContextManager.h" + +namespace irr +{ +namespace video +{ + +bool COpenGLExtensionHandler::needsDSAFramebufferHack = true; + +COpenGLExtensionHandler::COpenGLExtensionHandler() : + StencilBuffer(false), TextureCompressionExtension(false), MaxLights(1), + MaxAnisotropy(1), MaxUserClipPlanes(0), MaxAuxBuffers(0), MaxIndices(65535), + MaxTextureSize(1), MaxGeometryVerticesOut(0), + MaxTextureLODBias(0.f), Version(0), ShaderLanguageVersion(0), + OcclusionQuerySupport(false), IsAtiRadeonX(false), pGlActiveTexture(0), pGlActiveTextureARB(0), pGlClientActiveTextureARB(0), + pGlGenProgramsARB(0), pGlGenProgramsNV(0), + pGlBindProgramARB(0), pGlBindProgramNV(0), + pGlDeleteProgramsARB(0), pGlDeleteProgramsNV(0), + pGlProgramStringARB(0), pGlLoadProgramNV(0), + pGlProgramLocalParameter4fvARB(0), + pGlCreateShaderObjectARB(0), pGlShaderSourceARB(0), + pGlCompileShaderARB(0), pGlCreateProgramObjectARB(0), pGlAttachObjectARB(0), + pGlLinkProgramARB(0), pGlUseProgramObjectARB(0), pGlDeleteObjectARB(0), + pGlCreateProgram(0), pGlUseProgram(0), + pGlDeleteProgram(0), pGlDeleteShader(0), + pGlGetAttachedObjectsARB(0), pGlGetAttachedShaders(0), + pGlCreateShader(0), pGlShaderSource(0), pGlCompileShader(0), + pGlAttachShader(0), pGlLinkProgram(0), + pGlGetInfoLogARB(0), pGlGetShaderInfoLog(0), pGlGetProgramInfoLog(0), + pGlGetObjectParameterivARB(0), pGlGetShaderiv(0), pGlGetProgramiv(0), + pGlGetUniformLocationARB(0), pGlGetUniformLocation(0), + pGlUniform1fvARB(0), pGlUniform2fvARB(0), pGlUniform3fvARB(0), pGlUniform4fvARB(0), + pGlUniform1ivARB(0), pGlUniform2ivARB(0), pGlUniform3ivARB(0), pGlUniform4ivARB(0), + pGlUniform1uiv(0), pGlUniform2uiv(0), pGlUniform3uiv(0), pGlUniform4uiv(0), + pGlUniformMatrix2fvARB(0), pGlUniformMatrix2x3fv(0), pGlUniformMatrix2x4fv(0), + pGlUniformMatrix3x2fv(0), pGlUniformMatrix3fvARB(0), pGlUniformMatrix3x4fv(0), + pGlUniformMatrix4x2fv(0), pGlUniformMatrix4x3fv(0), pGlUniformMatrix4fvARB(0), + pGlGetActiveUniformARB(0), pGlGetActiveUniform(0), + pGlPointParameterfARB(0), pGlPointParameterfvARB(0), + pGlStencilFuncSeparate(0), pGlStencilOpSeparate(0), + pGlStencilFuncSeparateATI(0), pGlStencilOpSeparateATI(0), + pGlCompressedTexImage2D(0), pGlCompressedTexSubImage2D(0), + // ARB framebuffer object + pGlBindFramebuffer(0), pGlDeleteFramebuffers(0), pGlGenFramebuffers(0), + pGlCheckFramebufferStatus(0), pGlFramebufferTexture2D(0), + pGlBindRenderbuffer(0), pGlDeleteRenderbuffers(0), pGlGenRenderbuffers(0), + pGlRenderbufferStorage(0), pGlFramebufferRenderbuffer(0), pGlGenerateMipmap(0), + // EXT framebuffer object + pGlBindFramebufferEXT(0), pGlDeleteFramebuffersEXT(0), pGlGenFramebuffersEXT(0), + pGlCheckFramebufferStatusEXT(0), pGlFramebufferTexture2DEXT(0), + pGlBindRenderbufferEXT(0), pGlDeleteRenderbuffersEXT(0), pGlGenRenderbuffersEXT(0), + pGlRenderbufferStorageEXT(0), pGlFramebufferRenderbufferEXT(0), pGlGenerateMipmapEXT(0), + pGlActiveStencilFaceEXT(0), + // MRTs + pGlDrawBuffersARB(0), pGlDrawBuffersATI(0), + pGlGenBuffersARB(0), pGlBindBufferARB(0), pGlBufferDataARB(0), pGlDeleteBuffersARB(0), + pGlBufferSubDataARB(0), pGlGetBufferSubDataARB(0), pGlMapBufferARB(0), pGlUnmapBufferARB(0), + pGlIsBufferARB(0), pGlGetBufferParameterivARB(0), pGlGetBufferPointervARB(0), + pGlProvokingVertexARB(0), pGlProvokingVertexEXT(0), + pGlProgramParameteriARB(0), pGlProgramParameteriEXT(0), + pGlGenQueriesARB(0), pGlDeleteQueriesARB(0), pGlIsQueryARB(0), + pGlBeginQueryARB(0), pGlEndQueryARB(0), pGlGetQueryivARB(0), + pGlGetQueryObjectivARB(0), pGlGetQueryObjectuivARB(0), + pGlGenOcclusionQueriesNV(0), pGlDeleteOcclusionQueriesNV(0), + pGlIsOcclusionQueryNV(0), pGlBeginOcclusionQueryNV(0), + pGlEndOcclusionQueryNV(0), pGlGetOcclusionQueryivNV(0), + pGlGetOcclusionQueryuivNV(0), + // Blend + pGlBlendFuncSeparateEXT(0), pGlBlendFuncSeparate(0), + pGlBlendEquationEXT(0), pGlBlendEquation(0), pGlBlendEquationSeparateEXT(0), pGlBlendEquationSeparate(0), + // Indexed + pGlEnableIndexedEXT(0), pGlDisableIndexedEXT(0), + pGlColorMaskIndexedEXT(0), + pGlBlendFuncIndexedAMD(0), pGlBlendFunciARB(0), pGlBlendFuncSeparateIndexedAMD(0), pGlBlendFuncSeparateiARB(0), + pGlBlendEquationIndexedAMD(0), pGlBlendEquationiARB(0), pGlBlendEquationSeparateIndexedAMD(0), pGlBlendEquationSeparateiARB(0), + // DSA + pGlTextureStorage2D(0), pGlTextureStorage3D(0), pGlTextureSubImage2D(0), pGlGetTextureImage(0), pGlNamedFramebufferTexture(0), + pGlTextureParameteri(0), pGlTextureParameterf(0), pGlTextureParameteriv(0), pGlTextureParameterfv(0), + pGlCreateTextures(0), pGlCreateFramebuffers(0), pGlBindTextures(0), pGlGenerateTextureMipmap(0), + // DSA with EXT or functions to simulate it + pGlTextureStorage2DEXT(0), pGlTexStorage2D(0), pGlTextureStorage3DEXT(0), pGlTexStorage3D(0), pGlTextureSubImage2DEXT(0), pGlGetTextureImageEXT(0), + pGlNamedFramebufferTextureEXT(0), pGlFramebufferTexture(0), pGlGenerateTextureMipmapEXT(0) +#if defined(GLX_SGI_swap_control) + , + pGlxSwapIntervalSGI(0) +#endif +#if defined(GLX_EXT_swap_control) + , + pGlxSwapIntervalEXT(0) +#endif +#if defined(WGL_EXT_swap_control) + , + pWglSwapIntervalEXT(0) +#endif +#if defined(GLX_MESA_swap_control) + , + pGlxSwapIntervalMESA(0) +#endif +{ + for (u32 i = 0; i < IRR_OpenGL_Feature_Count; ++i) + FeatureAvailable[i] = false; + DimAliasedLine[0] = 1.f; + DimAliasedLine[1] = 1.f; + DimAliasedPoint[0] = 1.f; + DimAliasedPoint[1] = 1.f; + DimSmoothedLine[0] = 1.f; + DimSmoothedLine[1] = 1.f; + DimSmoothedPoint[0] = 1.f; + DimSmoothedPoint[1] = 1.f; +} + +void COpenGLExtensionHandler::dump(ELOG_LEVEL logLevel) const +{ + for (u32 i = 0; i < IRR_OpenGL_Feature_Count; ++i) + os::Printer::log(OpenGLFeatureStrings[i], FeatureAvailable[i] ? " true" : " false", logLevel); +} + +void COpenGLExtensionHandler::initExtensions(video::IContextManager *cmgr, bool stencilBuffer) +{ + const f32 ogl_ver = core::fast_atof(reinterpret_cast(glGetString(GL_VERSION))); + Version = static_cast(core::floor32(ogl_ver) * 100 + core::round32(core::fract(ogl_ver) * 10.0f)); + if (Version >= 102) + os::Printer::log("OpenGL driver version is 1.2 or better.", ELL_INFORMATION); + else + os::Printer::log("OpenGL driver version is not 1.2 or better.", ELL_WARNING); + + { + const char *t = reinterpret_cast(glGetString(GL_EXTENSIONS)); + size_t len = 0; + c8 *str = 0; + if (t) { + len = strlen(t); + str = new c8[len + 1]; + } + c8 *p = str; + + for (size_t i = 0; i < len; ++i) { + str[i] = static_cast(t[i]); + + if (str[i] == ' ') { + str[i] = 0; + for (u32 j = 0; j < IRR_OpenGL_Feature_Count; ++j) { + if (!strcmp(OpenGLFeatureStrings[j], p)) { + FeatureAvailable[j] = true; + break; + } + } + + p = p + strlen(p) + 1; + } + } + + delete[] str; + } + + TextureCompressionExtension = FeatureAvailable[IRR_ARB_texture_compression]; + StencilBuffer = stencilBuffer; + + const char *renderer = (const char *)glGetString(GL_RENDERER); + if (renderer) { + IsAtiRadeonX = (strncmp(renderer, "ATI RADEON X", 12) == 0) || (strncmp(renderer, "ATI MOBILITY RADEON X", 21) == 0); + } + +#define IRR_OGL_LOAD_EXTENSION(x) cmgr->getProcAddress(x) + + // get multitexturing function pointers + pGlActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)IRR_OGL_LOAD_EXTENSION("glActiveTextureARB"); + pGlClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC)IRR_OGL_LOAD_EXTENSION("glClientActiveTextureARB"); + + // get fragment and vertex program function pointers + pGlGenProgramsARB = (PFNGLGENPROGRAMSARBPROC)IRR_OGL_LOAD_EXTENSION("glGenProgramsARB"); + pGlGenProgramsNV = (PFNGLGENPROGRAMSNVPROC)IRR_OGL_LOAD_EXTENSION("glGenProgramsNV"); + pGlBindProgramARB = (PFNGLBINDPROGRAMARBPROC)IRR_OGL_LOAD_EXTENSION("glBindProgramARB"); + pGlBindProgramNV = (PFNGLBINDPROGRAMNVPROC)IRR_OGL_LOAD_EXTENSION("glBindProgramNV"); + pGlProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC)IRR_OGL_LOAD_EXTENSION("glProgramStringARB"); + pGlLoadProgramNV = (PFNGLLOADPROGRAMNVPROC)IRR_OGL_LOAD_EXTENSION("glLoadProgramNV"); + pGlDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC)IRR_OGL_LOAD_EXTENSION("glDeleteProgramsARB"); + pGlDeleteProgramsNV = (PFNGLDELETEPROGRAMSNVPROC)IRR_OGL_LOAD_EXTENSION("glDeleteProgramsNV"); + pGlProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC)IRR_OGL_LOAD_EXTENSION("glProgramLocalParameter4fvARB"); + pGlCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)IRR_OGL_LOAD_EXTENSION("glCreateShaderObjectARB"); + pGlCreateShader = (PFNGLCREATESHADERPROC)IRR_OGL_LOAD_EXTENSION("glCreateShader"); + pGlShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)IRR_OGL_LOAD_EXTENSION("glShaderSourceARB"); + pGlShaderSource = (PFNGLSHADERSOURCEPROC)IRR_OGL_LOAD_EXTENSION("glShaderSource"); + pGlCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)IRR_OGL_LOAD_EXTENSION("glCompileShaderARB"); + pGlCompileShader = (PFNGLCOMPILESHADERPROC)IRR_OGL_LOAD_EXTENSION("glCompileShader"); + pGlCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)IRR_OGL_LOAD_EXTENSION("glCreateProgramObjectARB"); + pGlCreateProgram = (PFNGLCREATEPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glCreateProgram"); + pGlAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)IRR_OGL_LOAD_EXTENSION("glAttachObjectARB"); + pGlAttachShader = (PFNGLATTACHSHADERPROC)IRR_OGL_LOAD_EXTENSION("glAttachShader"); + pGlLinkProgramARB = (PFNGLLINKPROGRAMARBPROC)IRR_OGL_LOAD_EXTENSION("glLinkProgramARB"); + pGlLinkProgram = (PFNGLLINKPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glLinkProgram"); + pGlUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)IRR_OGL_LOAD_EXTENSION("glUseProgramObjectARB"); + pGlUseProgram = (PFNGLUSEPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glUseProgram"); + pGlDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)IRR_OGL_LOAD_EXTENSION("glDeleteObjectARB"); + pGlDeleteProgram = (PFNGLDELETEPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glDeleteProgram"); + pGlDeleteShader = (PFNGLDELETESHADERPROC)IRR_OGL_LOAD_EXTENSION("glDeleteShader"); + pGlGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC)IRR_OGL_LOAD_EXTENSION("glGetAttachedShaders"); + pGlGetAttachedObjectsARB = (PFNGLGETATTACHEDOBJECTSARBPROC)IRR_OGL_LOAD_EXTENSION("glGetAttachedObjectsARB"); + pGlGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)IRR_OGL_LOAD_EXTENSION("glGetInfoLogARB"); + pGlGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)IRR_OGL_LOAD_EXTENSION("glGetShaderInfoLog"); + pGlGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)IRR_OGL_LOAD_EXTENSION("glGetProgramInfoLog"); + pGlGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)IRR_OGL_LOAD_EXTENSION("glGetObjectParameterivARB"); + pGlGetShaderiv = (PFNGLGETSHADERIVPROC)IRR_OGL_LOAD_EXTENSION("glGetShaderiv"); + pGlGetProgramiv = (PFNGLGETPROGRAMIVPROC)IRR_OGL_LOAD_EXTENSION("glGetProgramiv"); + pGlGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)IRR_OGL_LOAD_EXTENSION("glGetUniformLocationARB"); + pGlGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)IRR_OGL_LOAD_EXTENSION("glGetUniformLocation"); + pGlUniform1fvARB = (PFNGLUNIFORM1FVARBPROC)IRR_OGL_LOAD_EXTENSION("glUniform1fvARB"); + pGlUniform2fvARB = (PFNGLUNIFORM2FVARBPROC)IRR_OGL_LOAD_EXTENSION("glUniform2fvARB"); + pGlUniform3fvARB = (PFNGLUNIFORM3FVARBPROC)IRR_OGL_LOAD_EXTENSION("glUniform3fvARB"); + pGlUniform4fvARB = (PFNGLUNIFORM4FVARBPROC)IRR_OGL_LOAD_EXTENSION("glUniform4fvARB"); + pGlUniform1ivARB = (PFNGLUNIFORM1IVARBPROC)IRR_OGL_LOAD_EXTENSION("glUniform1ivARB"); + pGlUniform2ivARB = (PFNGLUNIFORM2IVARBPROC)IRR_OGL_LOAD_EXTENSION("glUniform2ivARB"); + pGlUniform3ivARB = (PFNGLUNIFORM3IVARBPROC)IRR_OGL_LOAD_EXTENSION("glUniform3ivARB"); + pGlUniform4ivARB = (PFNGLUNIFORM4IVARBPROC)IRR_OGL_LOAD_EXTENSION("glUniform4ivARB"); + pGlUniform1uiv = (PFNGLUNIFORM1UIVPROC)IRR_OGL_LOAD_EXTENSION("glUniform1uiv"); + pGlUniform2uiv = (PFNGLUNIFORM2UIVPROC)IRR_OGL_LOAD_EXTENSION("glUniform2uiv"); + pGlUniform3uiv = (PFNGLUNIFORM3UIVPROC)IRR_OGL_LOAD_EXTENSION("glUniform3uiv"); + pGlUniform4uiv = (PFNGLUNIFORM4UIVPROC)IRR_OGL_LOAD_EXTENSION("glUniform4uiv"); + pGlUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix2fvARB"); + pGlUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix2x3fv"); + pGlUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix2x4fv"); + pGlUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix3x2fv"); + pGlUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix3fvARB"); + pGlUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix3x4fv"); + pGlUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix4x2fv"); + pGlUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix4x3fv"); + pGlUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix4fvARB"); + pGlGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC)IRR_OGL_LOAD_EXTENSION("glGetActiveUniformARB"); + pGlGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)IRR_OGL_LOAD_EXTENSION("glGetActiveUniform"); + + // get point parameter extension + pGlPointParameterfARB = (PFNGLPOINTPARAMETERFARBPROC)IRR_OGL_LOAD_EXTENSION("glPointParameterfARB"); + pGlPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC)IRR_OGL_LOAD_EXTENSION("glPointParameterfvARB"); + + // get stencil extension + pGlStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC)IRR_OGL_LOAD_EXTENSION("glStencilFuncSeparate"); + pGlStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)IRR_OGL_LOAD_EXTENSION("glStencilOpSeparate"); + pGlStencilFuncSeparateATI = (PFNGLSTENCILFUNCSEPARATEATIPROC)IRR_OGL_LOAD_EXTENSION("glStencilFuncSeparateATI"); + pGlStencilOpSeparateATI = (PFNGLSTENCILOPSEPARATEATIPROC)IRR_OGL_LOAD_EXTENSION("glStencilOpSeparateATI"); + + // compressed textures + pGlCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)IRR_OGL_LOAD_EXTENSION("glCompressedTexImage2D"); + pGlCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)IRR_OGL_LOAD_EXTENSION("glCompressedTexSubImage2D"); + + // ARB FrameBufferObjects + pGlBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glBindFramebuffer"); + pGlDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glDeleteFramebuffers"); + pGlGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glGenFramebuffers"); + pGlCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)IRR_OGL_LOAD_EXTENSION("glCheckFramebufferStatus"); + pGlFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)IRR_OGL_LOAD_EXTENSION("glFramebufferTexture2D"); + pGlBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glBindRenderbuffer"); + pGlDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glDeleteRenderbuffers"); + pGlGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glGenRenderbuffers"); + pGlRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)IRR_OGL_LOAD_EXTENSION("glRenderbufferStorage"); + pGlFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glFramebufferRenderbuffer"); + pGlGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)IRR_OGL_LOAD_EXTENSION("glGenerateMipmap"); + + // EXT FrameBufferObjects + pGlBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC)IRR_OGL_LOAD_EXTENSION("glBindFramebufferEXT"); + pGlDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC)IRR_OGL_LOAD_EXTENSION("glDeleteFramebuffersEXT"); + pGlGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)IRR_OGL_LOAD_EXTENSION("glGenFramebuffersEXT"); + pGlCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)IRR_OGL_LOAD_EXTENSION("glCheckFramebufferStatusEXT"); + pGlFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)IRR_OGL_LOAD_EXTENSION("glFramebufferTexture2DEXT"); + pGlBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC)IRR_OGL_LOAD_EXTENSION("glBindRenderbufferEXT"); + pGlDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC)IRR_OGL_LOAD_EXTENSION("glDeleteRenderbuffersEXT"); + pGlGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC)IRR_OGL_LOAD_EXTENSION("glGenRenderbuffersEXT"); + pGlRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC)IRR_OGL_LOAD_EXTENSION("glRenderbufferStorageEXT"); + pGlFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)IRR_OGL_LOAD_EXTENSION("glFramebufferRenderbufferEXT"); + pGlGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC)IRR_OGL_LOAD_EXTENSION("glGenerateMipmapEXT"); + pGlDrawBuffersARB = (PFNGLDRAWBUFFERSARBPROC)IRR_OGL_LOAD_EXTENSION("glDrawBuffersARB"); + pGlDrawBuffersATI = (PFNGLDRAWBUFFERSATIPROC)IRR_OGL_LOAD_EXTENSION("glDrawBuffersATI"); + + // get vertex buffer extension + pGlGenBuffersARB = (PFNGLGENBUFFERSARBPROC)IRR_OGL_LOAD_EXTENSION("glGenBuffersARB"); + pGlBindBufferARB = (PFNGLBINDBUFFERARBPROC)IRR_OGL_LOAD_EXTENSION("glBindBufferARB"); + pGlBufferDataARB = (PFNGLBUFFERDATAARBPROC)IRR_OGL_LOAD_EXTENSION("glBufferDataARB"); + pGlDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)IRR_OGL_LOAD_EXTENSION("glDeleteBuffersARB"); + pGlBufferSubDataARB = (PFNGLBUFFERSUBDATAARBPROC)IRR_OGL_LOAD_EXTENSION("glBufferSubDataARB"); + pGlGetBufferSubDataARB = (PFNGLGETBUFFERSUBDATAARBPROC)IRR_OGL_LOAD_EXTENSION("glGetBufferSubDataARB"); + pGlMapBufferARB = (PFNGLMAPBUFFERARBPROC)IRR_OGL_LOAD_EXTENSION("glMapBufferARB"); + pGlUnmapBufferARB = (PFNGLUNMAPBUFFERARBPROC)IRR_OGL_LOAD_EXTENSION("glUnmapBufferARB"); + pGlIsBufferARB = (PFNGLISBUFFERARBPROC)IRR_OGL_LOAD_EXTENSION("glIsBufferARB"); + pGlGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC)IRR_OGL_LOAD_EXTENSION("glGetBufferParameterivARB"); + pGlGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC)IRR_OGL_LOAD_EXTENSION("glGetBufferPointervARB"); + pGlProvokingVertexARB = (PFNGLPROVOKINGVERTEXPROC)IRR_OGL_LOAD_EXTENSION("glProvokingVertex"); + pGlProvokingVertexEXT = (PFNGLPROVOKINGVERTEXEXTPROC)IRR_OGL_LOAD_EXTENSION("glProvokingVertexEXT"); + pGlProgramParameteriARB = (PFNGLPROGRAMPARAMETERIARBPROC)IRR_OGL_LOAD_EXTENSION("glProgramParameteriARB"); + pGlProgramParameteriEXT = (PFNGLPROGRAMPARAMETERIEXTPROC)IRR_OGL_LOAD_EXTENSION("glProgramParameteriEXT"); + + // occlusion query + pGlGenQueriesARB = (PFNGLGENQUERIESARBPROC)IRR_OGL_LOAD_EXTENSION("glGenQueriesARB"); + pGlDeleteQueriesARB = (PFNGLDELETEQUERIESARBPROC)IRR_OGL_LOAD_EXTENSION("glDeleteQueriesARB"); + pGlIsQueryARB = (PFNGLISQUERYARBPROC)IRR_OGL_LOAD_EXTENSION("glIsQueryARB"); + pGlBeginQueryARB = (PFNGLBEGINQUERYARBPROC)IRR_OGL_LOAD_EXTENSION("glBeginQueryARB"); + pGlEndQueryARB = (PFNGLENDQUERYARBPROC)IRR_OGL_LOAD_EXTENSION("glEndQueryARB"); + pGlGetQueryivARB = (PFNGLGETQUERYIVARBPROC)IRR_OGL_LOAD_EXTENSION("glGetQueryivARB"); + pGlGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC)IRR_OGL_LOAD_EXTENSION("glGetQueryObjectivARB"); + pGlGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC)IRR_OGL_LOAD_EXTENSION("glGetQueryObjectuivARB"); + pGlGenOcclusionQueriesNV = (PFNGLGENOCCLUSIONQUERIESNVPROC)IRR_OGL_LOAD_EXTENSION("glGenOcclusionQueriesNV"); + pGlDeleteOcclusionQueriesNV = (PFNGLDELETEOCCLUSIONQUERIESNVPROC)IRR_OGL_LOAD_EXTENSION("glDeleteOcclusionQueriesNV"); + pGlIsOcclusionQueryNV = (PFNGLISOCCLUSIONQUERYNVPROC)IRR_OGL_LOAD_EXTENSION("glIsOcclusionQueryNV"); + pGlBeginOcclusionQueryNV = (PFNGLBEGINOCCLUSIONQUERYNVPROC)IRR_OGL_LOAD_EXTENSION("glBeginOcclusionQueryNV"); + pGlEndOcclusionQueryNV = (PFNGLENDOCCLUSIONQUERYNVPROC)IRR_OGL_LOAD_EXTENSION("glEndOcclusionQueryNV"); + pGlGetOcclusionQueryivNV = (PFNGLGETOCCLUSIONQUERYIVNVPROC)IRR_OGL_LOAD_EXTENSION("glGetOcclusionQueryivNV"); + pGlGetOcclusionQueryuivNV = (PFNGLGETOCCLUSIONQUERYUIVNVPROC)IRR_OGL_LOAD_EXTENSION("glGetOcclusionQueryuivNV"); + + // blend + pGlBlendFuncSeparateEXT = (PFNGLBLENDFUNCSEPARATEEXTPROC)IRR_OGL_LOAD_EXTENSION("glBlendFuncSeparateEXT"); + pGlBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)IRR_OGL_LOAD_EXTENSION("glBlendFuncSeparate"); + pGlBlendEquationEXT = (PFNGLBLENDEQUATIONEXTPROC)IRR_OGL_LOAD_EXTENSION("glBlendEquationEXT"); + pGlBlendEquation = (PFNGLBLENDEQUATIONPROC)IRR_OGL_LOAD_EXTENSION("glBlendEquation"); + pGlBlendEquationSeparateEXT = (PFNGLBLENDEQUATIONSEPARATEEXTPROC)IRR_OGL_LOAD_EXTENSION("glBlendEquationSeparateEXT"); + pGlBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC)IRR_OGL_LOAD_EXTENSION("glBlendEquationSeparate"); + + // indexed + pGlEnableIndexedEXT = (PFNGLENABLEINDEXEDEXTPROC)IRR_OGL_LOAD_EXTENSION("glEnableIndexedEXT"); + pGlDisableIndexedEXT = (PFNGLDISABLEINDEXEDEXTPROC)IRR_OGL_LOAD_EXTENSION("glDisableIndexedEXT"); + pGlColorMaskIndexedEXT = (PFNGLCOLORMASKINDEXEDEXTPROC)IRR_OGL_LOAD_EXTENSION("glColorMaskIndexedEXT"); + pGlBlendFuncIndexedAMD = (PFNGLBLENDFUNCINDEXEDAMDPROC)IRR_OGL_LOAD_EXTENSION("glBlendFuncIndexedAMD"); + pGlBlendFunciARB = (PFNGLBLENDFUNCIPROC)IRR_OGL_LOAD_EXTENSION("glBlendFunciARB"); + pGlBlendFuncSeparateIndexedAMD = (PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC)IRR_OGL_LOAD_EXTENSION("glBlendFuncSeparateIndexedAMD"); + pGlBlendFuncSeparateiARB = (PFNGLBLENDFUNCSEPARATEIPROC)IRR_OGL_LOAD_EXTENSION("glBlendFuncSeparateiARB"); + pGlBlendEquationIndexedAMD = (PFNGLBLENDEQUATIONINDEXEDAMDPROC)IRR_OGL_LOAD_EXTENSION("glBlendEquationIndexedAMD"); + pGlBlendEquationiARB = (PFNGLBLENDEQUATIONIPROC)IRR_OGL_LOAD_EXTENSION("glBlendEquationiARB"); + pGlBlendEquationSeparateIndexedAMD = (PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC)IRR_OGL_LOAD_EXTENSION("glBlendEquationSeparateIndexedAMD"); + pGlBlendEquationSeparateiARB = (PFNGLBLENDEQUATIONSEPARATEIPROC)IRR_OGL_LOAD_EXTENSION("glBlendEquationSeparateiARB"); + + pGlTextureStorage2D = (PFNGLTEXTURESTORAGE2DPROC)IRR_OGL_LOAD_EXTENSION("glTextureStorage2D"); + pGlTextureStorage3D = (PFNGLTEXTURESTORAGE3DPROC)IRR_OGL_LOAD_EXTENSION("glTextureStorage3D"); + pGlTextureSubImage2D = (PFNGLTEXTURESUBIMAGE2DPROC)IRR_OGL_LOAD_EXTENSION("glTextureSubImage2D"); + pGlGetTextureImage = (PFNGLGETTEXTUREIMAGEPROC)IRR_OGL_LOAD_EXTENSION("glGetTextureImage"); + pGlNamedFramebufferTexture = (PFNGLNAMEDFRAMEBUFFERTEXTUREPROC)IRR_OGL_LOAD_EXTENSION("glNamedFramebufferTexture"); + pGlTextureParameteri = (PFNGLTEXTUREPARAMETERIPROC)IRR_OGL_LOAD_EXTENSION("glTextureParameteri"); + pGlTextureParameterf = (PFNGLTEXTUREPARAMETERFPROC)IRR_OGL_LOAD_EXTENSION("glTextureParameterf"); + pGlTextureParameteriv = (PFNGLTEXTUREPARAMETERIVPROC)IRR_OGL_LOAD_EXTENSION("glTextureParameteriv"); + pGlTextureParameterfv = (PFNGLTEXTUREPARAMETERFVPROC)IRR_OGL_LOAD_EXTENSION("glTextureParameterfv"); + + pGlCreateTextures = (PFNGLCREATETEXTURESPROC)IRR_OGL_LOAD_EXTENSION("glCreateTextures"); + pGlCreateFramebuffers = (PFNGLCREATEFRAMEBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glCreateFramebuffers"); + pGlBindTextures = (PFNGLBINDTEXTURESPROC)IRR_OGL_LOAD_EXTENSION("glBindTextures"); + pGlGenerateTextureMipmap = (PFNGLGENERATETEXTUREMIPMAPPROC)IRR_OGL_LOAD_EXTENSION("glGenerateTextureMipmap"); + //============================== + pGlTextureStorage2DEXT = (PFNGLTEXTURESTORAGE2DEXTPROC)IRR_OGL_LOAD_EXTENSION("glTextureStorage2DEXT"); + pGlTexStorage2D = (PFNGLTEXSTORAGE2DPROC)IRR_OGL_LOAD_EXTENSION("glTexStorage2D"); + pGlTextureStorage3DEXT = (PFNGLTEXTURESTORAGE3DEXTPROC)IRR_OGL_LOAD_EXTENSION("glTextureStorage3DEXT"); + pGlTexStorage3D = (PFNGLTEXSTORAGE3DPROC)IRR_OGL_LOAD_EXTENSION("glTexStorage3D"); + pGlTextureSubImage2DEXT = (PFNGLTEXTURESUBIMAGE2DEXTPROC)IRR_OGL_LOAD_EXTENSION("glTextureSubImage2DEXT"); + pGlGetTextureImageEXT = (PFNGLGETTEXTUREIMAGEEXTPROC)IRR_OGL_LOAD_EXTENSION("glGetTextureImageEXT"); + pGlNamedFramebufferTextureEXT = (PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC)IRR_OGL_LOAD_EXTENSION("glNamedFramebufferTextureEXT"); + pGlFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)IRR_OGL_LOAD_EXTENSION("glFramebufferTexture"); + pGlActiveTexture = (PFNGLACTIVETEXTUREPROC)IRR_OGL_LOAD_EXTENSION("glActiveTexture"); + pGlGenerateTextureMipmapEXT = (PFNGLGENERATETEXTUREMIPMAPEXTPROC)IRR_OGL_LOAD_EXTENSION("glGenerateTextureMipmapEXT"); + +// get vsync extension +#if defined(WGL_EXT_swap_control) && !defined(_IRR_COMPILE_WITH_SDL_DEVICE_) + pWglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)IRR_OGL_LOAD_EXTENSION("wglSwapIntervalEXT"); +#endif +#if defined(GLX_SGI_swap_control) && !defined(_IRR_COMPILE_WITH_SDL_DEVICE_) + pGlxSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)IRR_OGL_LOAD_EXTENSION("glXSwapIntervalSGI"); +#endif +#if defined(GLX_EXT_swap_control) && !defined(_IRR_COMPILE_WITH_SDL_DEVICE_) + pGlxSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)IRR_OGL_LOAD_EXTENSION("glXSwapIntervalEXT"); +#endif +#if defined(GLX_MESA_swap_control) && !defined(_IRR_COMPILE_WITH_SDL_DEVICE_) + pGlxSwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)IRR_OGL_LOAD_EXTENSION("glXSwapIntervalMESA"); +#endif + + GLint num = 0; + // set some properties +#if defined(GL_ARB_multitexture) || defined(GL_VERSION_1_3) + if (Version > 102 || FeatureAvailable[IRR_ARB_multitexture]) { +#if defined(GL_MAX_TEXTURE_UNITS) + glGetIntegerv(GL_MAX_TEXTURE_UNITS, &num); +#elif defined(GL_MAX_TEXTURE_UNITS_ARB) + glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &num); +#endif + Feature.MaxTextureUnits = static_cast(num); // MULTITEXTURING (fixed function pipeline texture units) + } +#endif +#if defined(GL_ARB_vertex_shader) || defined(GL_VERSION_2_0) + if (Version >= 200 || FeatureAvailable[IRR_ARB_vertex_shader]) { + num = 0; +#if defined(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS) + glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &num); +#elif defined(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB) + glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, &num); +#endif + Feature.MaxTextureUnits = core::max_(Feature.MaxTextureUnits, static_cast(num)); + } +#endif + glGetIntegerv(GL_MAX_LIGHTS, &num); + MaxLights = static_cast(num); +#ifdef GL_EXT_texture_filter_anisotropic + if (FeatureAvailable[IRR_EXT_texture_filter_anisotropic]) { + glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &num); + MaxAnisotropy = static_cast(num); + } +#endif +#ifdef GL_VERSION_1_2 + if (Version > 101) { + glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &num); + MaxIndices = num; + } +#endif + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &num); + MaxTextureSize = static_cast(num); + if (queryFeature(EVDF_GEOMETRY_SHADER)) { +#if defined(GL_ARB_geometry_shader4) || defined(GL_EXT_geometry_shader4) || defined(GL_NV_geometry_shader4) + glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT, &num); + MaxGeometryVerticesOut = static_cast(num); +#elif defined(GL_NV_geometry_program4) + extGlGetProgramiv(GEOMETRY_PROGRAM_NV, GL_MAX_PROGRAM_OUTPUT_VERTICES_NV, &num); + MaxGeometryVerticesOut = static_cast(num); +#endif + } +#ifdef GL_EXT_texture_lod_bias + if (FeatureAvailable[IRR_EXT_texture_lod_bias]) + glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS_EXT, &MaxTextureLODBias); +#endif + glGetIntegerv(GL_MAX_CLIP_PLANES, &num); + MaxUserClipPlanes = static_cast(num); + glGetIntegerv(GL_AUX_BUFFERS, &num); + MaxAuxBuffers = static_cast(num); +#ifdef GL_ARB_draw_buffers + if (FeatureAvailable[IRR_ARB_draw_buffers]) { + glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &num); + Feature.MultipleRenderTarget = static_cast(num); + } +#endif +#if defined(GL_ATI_draw_buffers) +#ifdef GL_ARB_draw_buffers + else +#endif + if (FeatureAvailable[IRR_ATI_draw_buffers]) { + glGetIntegerv(GL_MAX_DRAW_BUFFERS_ATI, &num); + Feature.MultipleRenderTarget = static_cast(num); + } +#endif +#ifdef GL_ARB_framebuffer_object + if (FeatureAvailable[IRR_ARB_framebuffer_object]) { + glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &num); + Feature.ColorAttachment = static_cast(num); + } +#endif +#if defined(GL_EXT_framebuffer_object) +#ifdef GL_ARB_framebuffer_object + else +#endif + if (FeatureAvailable[IRR_EXT_framebuffer_object]) { + glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &num); + Feature.ColorAttachment = static_cast(num); + } +#endif + + glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine); + glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint); + glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, DimSmoothedLine); + glGetFloatv(GL_SMOOTH_POINT_SIZE_RANGE, DimSmoothedPoint); +#if defined(GL_ARB_shading_language_100) || defined(GL_VERSION_2_0) + if (FeatureAvailable[IRR_ARB_shading_language_100] || Version >= 200) { + glGetError(); // clean error buffer +#ifdef GL_SHADING_LANGUAGE_VERSION + const GLubyte *shaderVersion = glGetString(GL_SHADING_LANGUAGE_VERSION); +#else + const GLubyte *shaderVersion = glGetString(GL_SHADING_LANGUAGE_VERSION_ARB); +#endif + if (glGetError() == GL_INVALID_ENUM) + ShaderLanguageVersion = 100; + else { + const f32 sl_ver = core::fast_atof(reinterpret_cast(shaderVersion)); + ShaderLanguageVersion = static_cast(core::floor32(sl_ver) * 100 + core::round32(core::fract(sl_ver) * 10.0f)); + } + } +#endif + + if (!pGlActiveTextureARB || !pGlClientActiveTextureARB) { + Feature.MaxTextureUnits = 1; + os::Printer::log("Failed to load OpenGL's multitexture extension, proceeding without.", ELL_WARNING); + } else + Feature.MaxTextureUnits = core::min_(Feature.MaxTextureUnits, static_cast(MATERIAL_MAX_TEXTURES)); + +#ifdef GL_ARB_occlusion_query + if (FeatureAvailable[IRR_ARB_occlusion_query]) { + extGlGetQueryiv(GL_SAMPLES_PASSED_ARB, GL_QUERY_COUNTER_BITS_ARB, + &num); + OcclusionQuerySupport = (num > 0); + } else +#endif +#ifdef GL_NV_occlusion_query + if (FeatureAvailable[IRR_NV_occlusion_query]) { + glGetIntegerv(GL_PIXEL_COUNTER_BITS_NV, &num); + OcclusionQuerySupport = (num > 0); + } else +#endif + OcclusionQuerySupport = false; + + Feature.BlendOperation = (Version >= 104) || + FeatureAvailable[IRR_EXT_blend_minmax] || + FeatureAvailable[IRR_EXT_blend_subtract] || + FeatureAvailable[IRR_EXT_blend_logic_op]; + +#ifdef _DEBUG + if (FeatureAvailable[IRR_NVX_gpu_memory_info]) { + // undocumented flags, so use the RAW values + GLint val; + glGetIntegerv(0x9047, &val); + os::Printer::log("Dedicated video memory (kB)", core::stringc(val)); + glGetIntegerv(0x9048, &val); + os::Printer::log("Total video memory (kB)", core::stringc(val)); + glGetIntegerv(0x9049, &val); + os::Printer::log("Available video memory (kB)", core::stringc(val)); + } +#ifdef GL_ATI_meminfo + if (FeatureAvailable[IRR_ATI_meminfo]) { + GLint val[4]; + glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, val); + os::Printer::log("Free texture memory (kB)", core::stringc(val[0])); + glGetIntegerv(GL_VBO_FREE_MEMORY_ATI, val); + os::Printer::log("Free VBO memory (kB)", core::stringc(val[0])); + glGetIntegerv(GL_RENDERBUFFER_FREE_MEMORY_ATI, val); + os::Printer::log("Free render buffer memory (kB)", core::stringc(val[0])); + } +#endif + + if (queryFeature(EVDF_TEXTURE_CUBEMAP_SEAMLESS)) + glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + +#endif +} + +const COpenGLCoreFeature &COpenGLExtensionHandler::getFeature() const +{ + return Feature; +} + +bool COpenGLExtensionHandler::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const +{ + switch (feature) { + case EVDF_RENDER_TO_TARGET: + return true; + case EVDF_HARDWARE_TL: + return true; // we cannot tell other things + case EVDF_MULTITEXTURE: + return Feature.MaxTextureUnits > 1; + case EVDF_BILINEAR_FILTER: + return true; + case EVDF_MIP_MAP: + return true; + case EVDF_MIP_MAP_AUTO_UPDATE: + return !IsAtiRadeonX && (FeatureAvailable[IRR_SGIS_generate_mipmap] || FeatureAvailable[IRR_EXT_framebuffer_object] || FeatureAvailable[IRR_ARB_framebuffer_object]); + case EVDF_STENCIL_BUFFER: + return StencilBuffer; + case EVDF_VERTEX_SHADER_1_1: + case EVDF_ARB_VERTEX_PROGRAM_1: + return FeatureAvailable[IRR_ARB_vertex_program] || FeatureAvailable[IRR_NV_vertex_program1_1]; + case EVDF_PIXEL_SHADER_1_1: + case EVDF_PIXEL_SHADER_1_2: + case EVDF_ARB_FRAGMENT_PROGRAM_1: + return FeatureAvailable[IRR_ARB_fragment_program] || FeatureAvailable[IRR_NV_fragment_program]; + case EVDF_PIXEL_SHADER_2_0: + case EVDF_VERTEX_SHADER_2_0: + case EVDF_ARB_GLSL: + return (FeatureAvailable[IRR_ARB_shading_language_100] || Version >= 200); + case EVDF_TEXTURE_NSQUARE: + return true; // non-square is always supported + case EVDF_TEXTURE_NPOT: + // Some ATI cards seem to have only SW support in OpenGL 2.0 + // drivers if the extension is not exposed, so we skip this + // extra test for now! + // return (FeatureAvailable[IRR_ARB_texture_non_power_of_two]||Version>=200); + return (FeatureAvailable[IRR_ARB_texture_non_power_of_two]); + case EVDF_FRAMEBUFFER_OBJECT: + return FeatureAvailable[IRR_EXT_framebuffer_object] || FeatureAvailable[IRR_ARB_framebuffer_object]; + case EVDF_VERTEX_BUFFER_OBJECT: + return FeatureAvailable[IRR_ARB_vertex_buffer_object]; + case EVDF_COLOR_MASK: + return true; + case EVDF_ALPHA_TO_COVERAGE: + return FeatureAvailable[IRR_ARB_multisample]; + case EVDF_GEOMETRY_SHADER: + return FeatureAvailable[IRR_ARB_geometry_shader4] || FeatureAvailable[IRR_EXT_geometry_shader4] || FeatureAvailable[IRR_NV_geometry_program4] || FeatureAvailable[IRR_NV_geometry_shader4]; + case EVDF_MULTIPLE_RENDER_TARGETS: + return FeatureAvailable[IRR_ARB_draw_buffers] || FeatureAvailable[IRR_ATI_draw_buffers]; + case EVDF_MRT_BLEND: + case EVDF_MRT_COLOR_MASK: + return FeatureAvailable[IRR_EXT_draw_buffers2]; + case EVDF_MRT_BLEND_FUNC: + return FeatureAvailable[IRR_ARB_draw_buffers_blend] || FeatureAvailable[IRR_AMD_draw_buffers_blend]; + case EVDF_OCCLUSION_QUERY: + return FeatureAvailable[IRR_ARB_occlusion_query] && OcclusionQuerySupport; + case EVDF_POLYGON_OFFSET: + // both features supported with OpenGL 1.1 + return Version >= 101; + case EVDF_BLEND_OPERATIONS: + return Feature.BlendOperation; + case EVDF_BLEND_SEPARATE: + return (Version >= 104) || FeatureAvailable[IRR_EXT_blend_func_separate]; + case EVDF_TEXTURE_MATRIX: + return true; + case EVDF_TEXTURE_CUBEMAP: + return (Version >= 103) || FeatureAvailable[IRR_ARB_texture_cube_map] || FeatureAvailable[IRR_EXT_texture_cube_map]; + case EVDF_TEXTURE_CUBEMAP_SEAMLESS: + return FeatureAvailable[IRR_ARB_seamless_cube_map]; + case EVDF_DEPTH_CLAMP: + return FeatureAvailable[IRR_NV_depth_clamp] || FeatureAvailable[IRR_ARB_depth_clamp]; + + default: + return false; + }; +} + +} +} + +#endif diff --git a/irr/src/COpenGLExtensionHandler.h b/irr/src/COpenGLExtensionHandler.h new file mode 100644 index 000000000..ada1c9a3a --- /dev/null +++ b/irr/src/COpenGLExtensionHandler.h @@ -0,0 +1,2616 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#pragma once + +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#include "EDriverFeatures.h" +#include "irrTypes.h" +#include "os.h" + +#include "COpenGLCommon.h" + +#include "COpenGLCoreFeature.h" + +namespace irr +{ +namespace video +{ + +class IContextManager; + +static const char *const OpenGLFeatureStrings[] = { + "GL_3DFX_multisample", + "GL_3DFX_tbuffer", + "GL_3DFX_texture_compression_FXT1", + "GL_AMD_blend_minmax_factor", + "GL_AMD_conservative_depth", + "GL_AMD_debug_output", + "GL_AMD_depth_clamp_separate", + "GL_AMD_draw_buffers_blend", + "GL_AMD_interleaved_elements", + "GL_AMD_multi_draw_indirect", + "GL_AMD_name_gen_delete", + "GL_AMD_performance_monitor", + "GL_AMD_pinned_memory", + "GL_AMD_query_buffer_object", + "GL_AMD_sample_positions", + "GL_AMD_seamless_cubemap_per_texture", + "GL_AMD_shader_atomic_counter_ops", + "GL_AMD_shader_stencil_export", + "GL_AMD_shader_trinary_minmax", + "GL_AMD_sparse_texture", + "GL_AMD_stencil_operation_extended", + "GL_AMD_texture_texture4", + "GL_AMD_transform_feedback3_lines_triangles", + "GL_AMD_vertex_shader_layer", + "GL_AMD_vertex_shader_tessellator", + "GL_AMD_vertex_shader_viewport_index", + "GL_APPLE_aux_depth_stencil", + "GL_APPLE_client_storage", + "GL_APPLE_element_array", + "GL_APPLE_fence", + "GL_APPLE_float_pixels", + "GL_APPLE_flush_buffer_range", + "GL_APPLE_object_purgeable", + "GL_APPLE_rgb_422", + "GL_APPLE_row_bytes", + "GL_APPLE_specular_vector", + "GL_APPLE_texture_range", + "GL_APPLE_transform_hint", + "GL_APPLE_vertex_array_object", + "GL_APPLE_vertex_array_range", + "GL_APPLE_vertex_program_evaluators", + "GL_APPLE_ycbcr_422", + "GL_ARB_arrays_of_arrays", + "GL_ARB_base_instance", + "GL_ARB_bindless_texture", + "GL_ARB_blend_func_extended", + "GL_ARB_buffer_storage", + "GL_ARB_cl_event", + "GL_ARB_clear_buffer_object", + "GL_ARB_clear_texture", + "GL_ARB_color_buffer_float", + "GL_ARB_compatibility", + "GL_ARB_compressed_texture_pixel_storage", + "GL_ARB_compute_shader", + "GL_ARB_compute_variable_group_size", + "GL_ARB_conservative_depth", + "GL_ARB_copy_buffer", + "GL_ARB_copy_image", + "GL_ARB_debug_output", + "GL_ARB_depth_buffer_float", + "GL_ARB_depth_clamp", + "GL_ARB_depth_texture", + "GL_ARB_direct_state_access", + "GL_ARB_draw_buffers", + "GL_ARB_draw_buffers_blend", + "GL_ARB_draw_elements_base_vertex", + "GL_ARB_draw_indirect", + "GL_ARB_draw_instanced", + "GL_ARB_ES2_compatibility", + "GL_ARB_ES3_compatibility", + "GL_ARB_enhanced_layouts", + "GL_ARB_explicit_attrib_location", + "GL_ARB_explicit_uniform_location", + "GL_ARB_fragment_coord_conventions", + "GL_ARB_fragment_layer_viewport", + "GL_ARB_fragment_program", + "GL_ARB_fragment_program_shadow", + "GL_ARB_fragment_shader", + "GL_ARB_framebuffer_no_attachments", + "GL_ARB_framebuffer_object", + "GL_ARB_framebuffer_sRGB", + "GL_ARB_geometry_shader4", + "GL_ARB_get_program_binary", + "GL_ARB_gpu_shader5", + "GL_ARB_gpu_shader_fp64", + "GL_ARB_half_float_pixel", + "GL_ARB_half_float_vertex", + "GL_ARB_imaging", + "GL_ARB_indirect_parameters", + "GL_ARB_instanced_arrays", + "GL_ARB_internalformat_query", + "GL_ARB_internalformat_query2", + "GL_ARB_invalidate_subdata", + "GL_ARB_map_buffer_alignment", + "GL_ARB_map_buffer_range", + "GL_ARB_matrix_palette", + "GL_ARB_multi_bind", + "GL_ARB_multi_draw_indirect", + "GL_ARB_multisample", + "GL_ARB_multitexture", + "GL_ARB_occlusion_query", + "GL_ARB_occlusion_query2", + "GL_ARB_pixel_buffer_object", + "GL_ARB_point_parameters", + "GL_ARB_point_sprite", + "GL_ARB_program_interface_query", + "GL_ARB_provoking_vertex", + "GL_ARB_query_buffer_object", + "GL_ARB_robust_buffer_access_behavior", + "GL_ARB_robustness", + "GL_ARB_robustness_isolation", + "GL_ARB_sample_shading", + "GL_ARB_sampler_objects", + "GL_ARB_seamless_cube_map", + "GL_ARB_seamless_cubemap_per_texture", + "GL_ARB_separate_shader_objects", + "GL_ARB_shader_atomic_counters", + "GL_ARB_shader_bit_encoding", + "GL_ARB_shader_draw_parameters", + "GL_ARB_shader_group_vote", + "GL_ARB_shader_image_load_store", + "GL_ARB_shader_image_size", + "GL_ARB_shader_objects", + "GL_ARB_shader_precision", + "GL_ARB_shader_stencil_export", + "GL_ARB_shader_storage_buffer_object", + "GL_ARB_shader_subroutine", + "GL_ARB_shader_texture_lod", + "GL_ARB_shading_language_100", + "GL_ARB_shading_language_420pack", + "GL_ARB_shading_language_include", + "GL_ARB_shading_language_packing", + "GL_ARB_shadow", + "GL_ARB_shadow_ambient", + "GL_ARB_sparse_texture", + "GL_ARB_stencil_texturing", + "GL_ARB_sync", + "GL_ARB_tessellation_shader", + "GL_ARB_texture_border_clamp", + "GL_ARB_texture_buffer_object", + "GL_ARB_texture_buffer_object_rgb32", + "GL_ARB_texture_buffer_range", + "GL_ARB_texture_compression", + "GL_ARB_texture_compression_bptc", + "GL_ARB_texture_compression_rgtc", + "GL_ARB_texture_cube_map", + "GL_ARB_texture_cube_map_array", + "GL_ARB_texture_env_add", + "GL_ARB_texture_env_combine", + "GL_ARB_texture_env_crossbar", + "GL_ARB_texture_env_dot3", + "GL_ARB_texture_float", + "GL_ARB_texture_gather", + "GL_ARB_texture_mirror_clamp_to_edge", + "GL_ARB_texture_mirrored_repeat", + "GL_ARB_texture_multisample", + "GL_ARB_texture_non_power_of_two", + "GL_ARB_texture_query_levels", + "GL_ARB_texture_query_lod", + "GL_ARB_texture_rectangle", + "GL_ARB_texture_rg", + "GL_ARB_texture_rgb10_a2ui", + "GL_ARB_texture_stencil8", + "GL_ARB_texture_storage", + "GL_ARB_texture_storage_multisample", + "GL_ARB_texture_swizzle", + "GL_ARB_texture_view", + "GL_ARB_timer_query", + "GL_ARB_transform_feedback2", + "GL_ARB_transform_feedback3", + "GL_ARB_transform_feedback_instanced", + "GL_ARB_transpose_matrix", + "GL_ARB_uniform_buffer_object", + "GL_ARB_vertex_array_bgra", + "GL_ARB_vertex_array_object", + "GL_ARB_vertex_attrib_64bit", + "GL_ARB_vertex_attrib_binding", + "GL_ARB_vertex_blend", + "GL_ARB_vertex_buffer_object", + "GL_ARB_vertex_program", + "GL_ARB_vertex_shader", + "GL_ARB_vertex_type_10f_11f_11f_rev", + "GL_ARB_vertex_type_2_10_10_10_rev", + "GL_ARB_viewport_array", + "GL_ARB_window_pos", + "GL_ATI_draw_buffers", + "GL_ATI_element_array", + "GL_ATI_envmap_bumpmap", + "GL_ATI_fragment_shader", + "GL_ATI_map_object_buffer", + "GL_ATI_meminfo", + "GL_ATI_pixel_format_float", + "GL_ATI_pn_triangles", + "GL_ATI_separate_stencil", + "GL_ATI_text_fragment_shader", + "GL_ATI_texture_env_combine3", + "GL_ATI_texture_float", + "GL_ATI_texture_mirror_once", + "GL_ATI_vertex_array_object", + "GL_ATI_vertex_attrib_array_object", + "GL_ATI_vertex_streams", + "GL_EXT_422_pixels", + "GL_EXT_abgr", + "GL_EXT_bgra", + "GL_EXT_bindable_uniform", + "GL_EXT_blend_color", + "GL_EXT_blend_equation_separate", + "GL_EXT_blend_func_separate", + "GL_EXT_blend_logic_op", + "GL_EXT_blend_minmax", + "GL_EXT_blend_subtract", + "GL_EXT_clip_volume_hint", + "GL_EXT_cmyka", + "GL_EXT_color_subtable", + "GL_EXT_compiled_vertex_array", + "GL_EXT_convolution", + "GL_EXT_coordinate_frame", + "GL_EXT_copy_texture", + "GL_EXT_cull_vertex", + "GL_EXT_debug_label", + "GL_EXT_debug_marker", + "GL_EXT_depth_bounds_test", + "GL_EXT_direct_state_access", + "GL_EXT_draw_buffers2", + "GL_EXT_draw_instanced", + "GL_EXT_draw_range_elements", + "GL_EXT_fog_coord", + "GL_EXT_framebuffer_blit", + "GL_EXT_framebuffer_multisample", + "GL_EXT_framebuffer_multisample_blit_scaled", + "GL_EXT_framebuffer_object", + "GL_EXT_framebuffer_sRGB", + "GL_EXT_geometry_shader4", + "GL_EXT_gpu_program_parameters", + "GL_EXT_gpu_shader4", + "GL_EXT_histogram", + "GL_EXT_index_array_formats", + "GL_EXT_index_func", + "GL_EXT_index_material", + "GL_EXT_index_texture", + "GL_EXT_light_texture", + "GL_EXT_misc_attribute", + "GL_EXT_multi_draw_arrays", + "GL_EXT_multisample", + "GL_EXT_packed_depth_stencil", + "GL_EXT_packed_float", + "GL_EXT_packed_pixels", + "GL_EXT_paletted_texture", + "GL_EXT_pixel_buffer_object", + "GL_EXT_pixel_transform", + "GL_EXT_pixel_transform_color_table", + "GL_EXT_point_parameters", + "GL_EXT_polygon_offset", + "GL_EXT_provoking_vertex", + "GL_EXT_rescale_normal", + "GL_EXT_secondary_color", + "GL_EXT_separate_shader_objects", + "GL_EXT_separate_specular_color", + "GL_EXT_shader_image_load_store", + "GL_EXT_shader_integer_mix", + "GL_EXT_shadow_funcs", + "GL_EXT_shared_texture_palette", + "GL_EXT_stencil_clear_tag", + "GL_EXT_stencil_two_side", + "GL_EXT_stencil_wrap", + "GL_EXT_subtexture", + "GL_EXT_texture", + "GL_EXT_texture3D", + "GL_EXT_texture_array", + "GL_EXT_texture_buffer_object", + "GL_EXT_texture_compression_latc", + "GL_EXT_texture_compression_rgtc", + "GL_EXT_texture_compression_s3tc", + "GL_EXT_texture_cube_map", + "GL_EXT_texture_env_add", + "GL_EXT_texture_env_combine", + "GL_EXT_texture_env_dot3", + "GL_EXT_texture_filter_anisotropic", + "GL_EXT_texture_integer", + "GL_EXT_texture_lod_bias", + "GL_EXT_texture_mirror_clamp", + "GL_EXT_texture_object", + "GL_EXT_texture_perturb_normal", + "GL_EXT_texture_shared_exponent", + "GL_EXT_texture_snorm", + "GL_EXT_texture_sRGB", + "GL_EXT_texture_sRGB_decode", + "GL_EXT_texture_swizzle", + "GL_EXT_timer_query", + "GL_EXT_transform_feedback", + "GL_EXT_vertex_array", + "GL_EXT_vertex_array_bgra", + "GL_EXT_vertex_attrib_64bit", + "GL_EXT_vertex_shader", + "GL_EXT_vertex_weighting", + "GL_EXT_x11_sync_object", + "GL_GREMEDY_frame_terminator", + "GL_GREMEDY_string_marker", + "GL_HP_convolution_border_modes", + "GL_HP_image_transform", + "GL_HP_occlusion_test", + "GL_HP_texture_lighting", + "GL_IBM_cull_vertex", + "GL_IBM_multimode_draw_arrays", + "GL_IBM_rasterpos_clip", + "GL_IBM_static_data", + "GL_IBM_texture_mirrored_repeat", + "GL_IBM_vertex_array_lists", + "GL_INGR_blend_func_separate", + "GL_INGR_color_clamp", + "GL_INGR_interlace_read", + "GL_INGR_palette_buffer", + "GL_INTEL_map_texture", + "GL_INTEL_parallel_arrays", + "GL_INTEL_texture_scissor", + "GL_KHR_debug", + "GL_KHR_texture_compression_astc_hdr", + "GL_KHR_texture_compression_astc_ldr", + "GL_MESA_pack_invert", + "GL_MESA_resize_buffers", + "GL_MESA_window_pos", + "GL_MESAX_texture_stack", + "GL_MESA_ycbcr_texture", + "GL_NVX_conditional_render", + "GL_NV_bindless_multi_draw_indirect", + "GL_NV_bindless_texture", + "GL_NV_blend_equation_advanced", + "GL_NV_blend_equation_advanced_coherent", + "GL_NV_blend_square", + "GL_NV_compute_program5", + "GL_NV_conditional_render", + "GL_NV_copy_depth_to_color", + "GL_NV_copy_image", + "GL_NV_deep_texture3D", + "GL_NV_depth_buffer_float", + "GL_NV_depth_clamp", + "GL_NV_draw_texture", + "GL_NV_evaluators", + "GL_NV_explicit_multisample", + "GL_NV_fence", + "GL_NV_float_buffer", + "GL_NV_fog_distance", + "GL_NV_fragment_program", + "GL_NV_fragment_program2", + "GL_NV_fragment_program4", + "GL_NV_fragment_program_option", + "GL_NV_framebuffer_multisample_coverage", + "GL_NV_geometry_program4", + "GL_NV_geometry_shader4", + "GL_NV_gpu_program4", + "GL_NV_gpu_program5", + "GL_NV_gpu_program5_mem_extended", + "GL_NV_gpu_shader5", + "GL_NV_half_float", + "GL_NV_light_max_exponent", + "GL_NV_multisample_coverage", + "GL_NV_multisample_filter_hint", + "GL_NV_occlusion_query", + "GL_NV_packed_depth_stencil", + "GL_NV_parameter_buffer_object", + "GL_NV_parameter_buffer_object2", + "GL_NV_path_rendering", + "GL_NV_pixel_data_range", + "GL_NV_point_sprite", + "GL_NV_present_video", + "GL_NV_primitive_restart", + "GL_NV_register_combiners", + "GL_NV_register_combiners2", + "GL_NV_shader_atomic_counters", + "GL_NV_shader_atomic_float", + "GL_NV_shader_buffer_load", + "GL_NV_shader_buffer_store", + "GL_NV_shader_storage_buffer_object", + "GL_NV_tessellation_program5", + "GL_NV_texgen_emboss", + "GL_NV_texgen_reflection", + "GL_NV_texture_barrier", + "GL_NV_texture_compression_vtc", + "GL_NV_texture_env_combine4", + "GL_NV_texture_expand_normal", + "GL_NV_texture_multisample", + "GL_NV_texture_rectangle", + "GL_NV_texture_shader", + "GL_NV_texture_shader2", + "GL_NV_texture_shader3", + "GL_NV_transform_feedback", + "GL_NV_transform_feedback2", + "GL_NV_vdpau_interop", + "GL_NV_vertex_array_range", + "GL_NV_vertex_array_range2", + "GL_NV_vertex_attrib_integer_64bit", + "GL_NV_vertex_buffer_unified_memory", + "GL_NV_vertex_program", + "GL_NV_vertex_program1_1", + "GL_NV_vertex_program2", + "GL_NV_vertex_program2_option", + "GL_NV_vertex_program3", + "GL_NV_vertex_program4", + "GL_NV_video_capture", + "GL_OES_byte_coordinates", + "GL_OES_compressed_paletted_texture", + "GL_OES_fixed_point", + "GL_OES_query_matrix", + "GL_OES_read_format", + "GL_OES_single_precision", + "GL_OML_interlace", + "GL_OML_resample", + "GL_OML_subsample", + "GL_PGI_misc_hints", + "GL_PGI_vertex_hints", + "GL_REND_screen_coordinates", + "GL_S3_s3tc", + "GL_SGI_color_matrix", + "GL_SGI_color_table", + "GL_SGI_texture_color_table", + "GL_SGIS_detail_texture", + "GL_SGIS_fog_function", + "GL_SGIS_generate_mipmap", + "GL_SGIS_multisample", + "GL_SGIS_pixel_texture", + "GL_SGIS_point_line_texgen", + "GL_SGIS_point_parameters", + "GL_SGIS_sharpen_texture", + "GL_SGIS_texture4D", + "GL_SGIS_texture_border_clamp", + "GL_SGIS_texture_color_mask", + "GL_SGIS_texture_edge_clamp", + "GL_SGIS_texture_filter4", + "GL_SGIS_texture_lod", + "GL_SGIS_texture_select", + "GL_SGIX_async", + "GL_SGIX_async_histogram", + "GL_SGIX_async_pixel", + "GL_SGIX_blend_alpha_minmax", + "GL_SGIX_calligraphic_fragment", + "GL_SGIX_clipmap", + "GL_SGIX_convolution_accuracy", + "GL_SGIX_depth_pass_instrument", + "GL_SGIX_depth_texture", + "GL_SGIX_flush_raster", + "GL_SGIX_fog_offset", + "GL_SGIX_fog_scale", + "GL_SGIX_fragment_lighting", + "GL_SGIX_framezoom", + "GL_SGIX_igloo_interface", + "GL_SGIX_instruments", + "GL_SGIX_interlace", + "GL_SGIX_ir_instrument1", + "GL_SGIX_list_priority", + "GL_SGIX_pixel_texture", + "GL_SGIX_pixel_tiles", + "GL_SGIX_polynomial_ffd", + "GL_SGIX_reference_plane", + "GL_SGIX_resample", + "GL_SGIX_scalebias_hint", + "GL_SGIX_shadow", + "GL_SGIX_shadow_ambient", + "GL_SGIX_sprite", + "GL_SGIX_subsample", + "GL_SGIX_tag_sample_buffer", + "GL_SGIX_texture_add_env", + "GL_SGIX_texture_coordinate_clamp", + "GL_SGIX_texture_lod_bias", + "GL_SGIX_texture_multi_buffer", + "GL_SGIX_texture_scale_bias", + "GL_SGIX_vertex_preclip", + "GL_SGIX_ycrcb", + "GL_SGIX_ycrcba", + "GL_SGIX_ycrcb_subsample", + "GL_SUN_convolution_border_modes", + "GL_SUN_global_alpha", + "GL_SUN_mesh_array", + "GL_SUN_slice_accum", + "GL_SUN_triangle_list", + "GL_SUN_vertex", + "GL_SUNX_constant_data", + "GL_WIN_phong_shading", + "GL_WIN_specular_fog", + // unofficial stuff + "GL_NVX_gpu_memory_info"}; + +class COpenGLExtensionHandler +{ +public: + enum EOpenGLFeatures + { + IRR_3DFX_multisample = 0, + IRR_3DFX_tbuffer, + IRR_3DFX_texture_compression_FXT1, + IRR_AMD_blend_minmax_factor, + IRR_AMD_conservative_depth, + IRR_AMD_debug_output, + IRR_AMD_depth_clamp_separate, + IRR_AMD_draw_buffers_blend, + IRR_AMD_interleaved_elements, + IRR_AMD_multi_draw_indirect, + IRR_AMD_name_gen_delete, + IRR_AMD_performance_monitor, + IRR_AMD_pinned_memory, + IRR_AMD_query_buffer_object, + IRR_AMD_sample_positions, + IRR_AMD_seamless_cubemap_per_texture, + IRR_AMD_shader_atomic_counter_ops, + IRR_AMD_shader_stencil_export, + IRR_AMD_shader_trinary_minmax, + IRR_AMD_sparse_texture, + IRR_AMD_stencil_operation_extended, + IRR_AMD_texture_texture4, + IRR_AMD_transform_feedback3_lines_triangles, + IRR_AMD_vertex_shader_layer, + IRR_AMD_vertex_shader_tessellator, + IRR_AMD_vertex_shader_viewport_index, + IRR_APPLE_aux_depth_stencil, + IRR_APPLE_client_storage, + IRR_APPLE_element_array, + IRR_APPLE_fence, + IRR_APPLE_float_pixels, + IRR_APPLE_flush_buffer_range, + IRR_APPLE_object_purgeable, + IRR_APPLE_rgb_422, + IRR_APPLE_row_bytes, + IRR_APPLE_specular_vector, + IRR_APPLE_texture_range, + IRR_APPLE_transform_hint, + IRR_APPLE_vertex_array_object, + IRR_APPLE_vertex_array_range, + IRR_APPLE_vertex_program_evaluators, + IRR_APPLE_ycbcr_422, + IRR_ARB_arrays_of_arrays, + IRR_ARB_base_instance, + IRR_ARB_bindless_texture, + IRR_ARB_blend_func_extended, + IRR_ARB_buffer_storage, + IRR_ARB_cl_event, + IRR_ARB_clear_buffer_object, + IRR_ARB_clear_texture, + IRR_ARB_color_buffer_float, + IRR_ARB_compatibility, + IRR_ARB_compressed_texture_pixel_storage, + IRR_ARB_compute_shader, + IRR_ARB_compute_variable_group_size, + IRR_ARB_conservative_depth, + IRR_ARB_copy_buffer, + IRR_ARB_copy_image, + IRR_ARB_debug_output, + IRR_ARB_depth_buffer_float, + IRR_ARB_depth_clamp, + IRR_ARB_depth_texture, + IRR_ARB_direct_state_access, + IRR_ARB_draw_buffers, + IRR_ARB_draw_buffers_blend, + IRR_ARB_draw_elements_base_vertex, + IRR_ARB_draw_indirect, + IRR_ARB_draw_instanced, + IRR_ARB_ES2_compatibility, + IRR_ARB_ES3_compatibility, + IRR_ARB_enhanced_layouts, + IRR_ARB_explicit_attrib_location, + IRR_ARB_explicit_uniform_location, + IRR_ARB_fragment_coord_conventions, + IRR_ARB_fragment_layer_viewport, + IRR_ARB_fragment_program, + IRR_ARB_fragment_program_shadow, + IRR_ARB_fragment_shader, + IRR_ARB_framebuffer_no_attachments, + IRR_ARB_framebuffer_object, + IRR_ARB_framebuffer_sRGB, + IRR_ARB_geometry_shader4, + IRR_ARB_get_program_binary, + IRR_ARB_gpu_shader5, + IRR_ARB_gpu_shader_fp64, + IRR_ARB_half_float_pixel, + IRR_ARB_half_float_vertex, + IRR_ARB_imaging, + IRR_ARB_indirect_parameters, + IRR_ARB_instanced_arrays, + IRR_ARB_internalformat_query, + IRR_ARB_internalformat_query2, + IRR_ARB_invalidate_subdata, + IRR_ARB_map_buffer_alignment, + IRR_ARB_map_buffer_range, + IRR_ARB_matrix_palette, + IRR_ARB_multi_bind, + IRR_ARB_multi_draw_indirect, + IRR_ARB_multisample, + IRR_ARB_multitexture, + IRR_ARB_occlusion_query, + IRR_ARB_occlusion_query2, + IRR_ARB_pixel_buffer_object, + IRR_ARB_point_parameters, + IRR_ARB_point_sprite, + IRR_ARB_program_interface_query, + IRR_ARB_provoking_vertex, + IRR_ARB_query_buffer_object, + IRR_ARB_robust_buffer_access_behavior, + IRR_ARB_robustness, + IRR_ARB_robustness_isolation, + IRR_ARB_sample_shading, + IRR_ARB_sampler_objects, + IRR_ARB_seamless_cube_map, + IRR_ARB_seamless_cubemap_per_texture, + IRR_ARB_separate_shader_objects, + IRR_ARB_shader_atomic_counters, + IRR_ARB_shader_bit_encoding, + IRR_ARB_shader_draw_parameters, + IRR_ARB_shader_group_vote, + IRR_ARB_shader_image_load_store, + IRR_ARB_shader_image_size, + IRR_ARB_shader_objects, + IRR_ARB_shader_precision, + IRR_ARB_shader_stencil_export, + IRR_ARB_shader_storage_buffer_object, + IRR_ARB_shader_subroutine, + IRR_ARB_shader_texture_lod, + IRR_ARB_shading_language_100, + IRR_ARB_shading_language_420pack, + IRR_ARB_shading_language_include, + IRR_ARB_shading_language_packing, + IRR_ARB_shadow, + IRR_ARB_shadow_ambient, + IRR_ARB_sparse_texture, + IRR_ARB_stencil_texturing, + IRR_ARB_sync, + IRR_ARB_tessellation_shader, + IRR_ARB_texture_border_clamp, + IRR_ARB_texture_buffer_object, + IRR_ARB_texture_buffer_object_rgb32, + IRR_ARB_texture_buffer_range, + IRR_ARB_texture_compression, + IRR_ARB_texture_compression_bptc, + IRR_ARB_texture_compression_rgtc, + IRR_ARB_texture_cube_map, + IRR_ARB_texture_cube_map_array, + IRR_ARB_texture_env_add, + IRR_ARB_texture_env_combine, + IRR_ARB_texture_env_crossbar, + IRR_ARB_texture_env_dot3, + IRR_ARB_texture_float, + IRR_ARB_texture_gather, + IRR_ARB_texture_mirror_clamp_to_edge, + IRR_ARB_texture_mirrored_repeat, + IRR_ARB_texture_multisample, + IRR_ARB_texture_non_power_of_two, + IRR_ARB_texture_query_levels, + IRR_ARB_texture_query_lod, + IRR_ARB_texture_rectangle, + IRR_ARB_texture_rg, + IRR_ARB_texture_rgb10_a2ui, + IRR_ARB_texture_stencil8, + IRR_ARB_texture_storage, + IRR_ARB_texture_storage_multisample, + IRR_ARB_texture_swizzle, + IRR_ARB_texture_view, + IRR_ARB_timer_query, + IRR_ARB_transform_feedback2, + IRR_ARB_transform_feedback3, + IRR_ARB_transform_feedback_instanced, + IRR_ARB_transpose_matrix, + IRR_ARB_uniform_buffer_object, + IRR_ARB_vertex_array_bgra, + IRR_ARB_vertex_array_object, + IRR_ARB_vertex_attrib_64bit, + IRR_ARB_vertex_attrib_binding, + IRR_ARB_vertex_blend, + IRR_ARB_vertex_buffer_object, + IRR_ARB_vertex_program, + IRR_ARB_vertex_shader, + IRR_ARB_vertex_type_10f_11f_11f_rev, + IRR_ARB_vertex_type_2_10_10_10_rev, + IRR_ARB_viewport_array, + IRR_ARB_window_pos, + IRR_ATI_draw_buffers, + IRR_ATI_element_array, + IRR_ATI_envmap_bumpmap, + IRR_ATI_fragment_shader, + IRR_ATI_map_object_buffer, + IRR_ATI_meminfo, + IRR_ATI_pixel_format_float, + IRR_ATI_pn_triangles, + IRR_ATI_separate_stencil, + IRR_ATI_text_fragment_shader, + IRR_ATI_texture_env_combine3, + IRR_ATI_texture_float, + IRR_ATI_texture_mirror_once, + IRR_ATI_vertex_array_object, + IRR_ATI_vertex_attrib_array_object, + IRR_ATI_vertex_streams, + IRR_EXT_422_pixels, + IRR_EXT_abgr, + IRR_EXT_bgra, + IRR_EXT_bindable_uniform, + IRR_EXT_blend_color, + IRR_EXT_blend_equation_separate, + IRR_EXT_blend_func_separate, + IRR_EXT_blend_logic_op, + IRR_EXT_blend_minmax, + IRR_EXT_blend_subtract, + IRR_EXT_clip_volume_hint, + IRR_EXT_cmyka, + IRR_EXT_color_subtable, + IRR_EXT_compiled_vertex_array, + IRR_EXT_convolution, + IRR_EXT_coordinate_frame, + IRR_EXT_copy_texture, + IRR_EXT_cull_vertex, + IRR_EXT_debug_label, + IRR_EXT_debug_marker, + IRR_EXT_depth_bounds_test, + IRR_EXT_direct_state_access, + IRR_EXT_draw_buffers2, + IRR_EXT_draw_instanced, + IRR_EXT_draw_range_elements, + IRR_EXT_fog_coord, + IRR_EXT_framebuffer_blit, + IRR_EXT_framebuffer_multisample, + IRR_EXT_framebuffer_multisample_blit_scaled, + IRR_EXT_framebuffer_object, + IRR_EXT_framebuffer_sRGB, + IRR_EXT_geometry_shader4, + IRR_EXT_gpu_program_parameters, + IRR_EXT_gpu_shader4, + IRR_EXT_histogram, + IRR_EXT_index_array_formats, + IRR_EXT_index_func, + IRR_EXT_index_material, + IRR_EXT_index_texture, + IRR_EXT_light_texture, + IRR_EXT_misc_attribute, + IRR_EXT_multi_draw_arrays, + IRR_EXT_multisample, + IRR_EXT_packed_depth_stencil, + IRR_EXT_packed_float, + IRR_EXT_packed_pixels, + IRR_EXT_paletted_texture, + IRR_EXT_pixel_buffer_object, + IRR_EXT_pixel_transform, + IRR_EXT_pixel_transform_color_table, + IRR_EXT_point_parameters, + IRR_EXT_polygon_offset, + IRR_EXT_provoking_vertex, + IRR_EXT_rescale_normal, + IRR_EXT_secondary_color, + IRR_EXT_separate_shader_objects, + IRR_EXT_separate_specular_color, + IRR_EXT_shader_image_load_store, + IRR_EXT_shader_integer_mix, + IRR_EXT_shadow_funcs, + IRR_EXT_shared_texture_palette, + IRR_EXT_stencil_clear_tag, + IRR_EXT_stencil_two_side, + IRR_EXT_stencil_wrap, + IRR_EXT_subtexture, + IRR_EXT_texture, + IRR_EXT_texture3D, + IRR_EXT_texture_array, + IRR_EXT_texture_buffer_object, + IRR_EXT_texture_compression_latc, + IRR_EXT_texture_compression_rgtc, + IRR_EXT_texture_compression_s3tc, + IRR_EXT_texture_cube_map, + IRR_EXT_texture_env_add, + IRR_EXT_texture_env_combine, + IRR_EXT_texture_env_dot3, + IRR_EXT_texture_filter_anisotropic, + IRR_EXT_texture_integer, + IRR_EXT_texture_lod_bias, + IRR_EXT_texture_mirror_clamp, + IRR_EXT_texture_object, + IRR_EXT_texture_perturb_normal, + IRR_EXT_texture_shared_exponent, + IRR_EXT_texture_snorm, + IRR_EXT_texture_sRGB, + IRR_EXT_texture_sRGB_decode, + IRR_EXT_texture_swizzle, + IRR_EXT_timer_query, + IRR_EXT_transform_feedback, + IRR_EXT_vertex_array, + IRR_EXT_vertex_array_bgra, + IRR_EXT_vertex_attrib_64bit, + IRR_EXT_vertex_shader, + IRR_EXT_vertex_weighting, + IRR_EXT_x11_sync_object, + IRR_GREMEDY_frame_terminator, + IRR_GREMEDY_string_marker, + IRR_HP_convolution_border_modes, + IRR_HP_image_transform, + IRR_HP_occlusion_test, + IRR_HP_texture_lighting, + IRR_IBM_cull_vertex, + IRR_IBM_multimode_draw_arrays, + IRR_IBM_rasterpos_clip, + IRR_IBM_static_data, + IRR_IBM_texture_mirrored_repeat, + IRR_IBM_vertex_array_lists, + IRR_INGR_blend_func_separate, + IRR_INGR_color_clamp, + IRR_INGR_interlace_read, + IRR_INGR_palette_buffer, + IRR_INTEL_map_texture, + IRR_INTEL_parallel_arrays, + IRR_INTEL_texture_scissor, + IRR_KHR_debug, + IRR_KHR_texture_compression_astc_hdr, + IRR_KHR_texture_compression_astc_ldr, + IRR_MESA_pack_invert, + IRR_MESA_resize_buffers, + IRR_MESA_window_pos, + IRR_MESAX_texture_stack, + IRR_MESA_ycbcr_texture, + IRR_NVX_conditional_render, + IRR_NV_bindless_multi_draw_indirect, + IRR_NV_bindless_texture, + IRR_NV_blend_equation_advanced, + IRR_NV_blend_equation_advanced_coherent, + IRR_NV_blend_square, + IRR_NV_compute_program5, + IRR_NV_conditional_render, + IRR_NV_copy_depth_to_color, + IRR_NV_copy_image, + IRR_NV_deep_texture3D, + IRR_NV_depth_buffer_float, + IRR_NV_depth_clamp, + IRR_NV_draw_texture, + IRR_NV_evaluators, + IRR_NV_explicit_multisample, + IRR_NV_fence, + IRR_NV_float_buffer, + IRR_NV_fog_distance, + IRR_NV_fragment_program, + IRR_NV_fragment_program2, + IRR_NV_fragment_program4, + IRR_NV_fragment_program_option, + IRR_NV_framebuffer_multisample_coverage, + IRR_NV_geometry_program4, + IRR_NV_geometry_shader4, + IRR_NV_gpu_program4, + IRR_NV_gpu_program5, + IRR_NV_gpu_program5_mem_extended, + IRR_NV_gpu_shader5, + IRR_NV_half_float, + IRR_NV_light_max_exponent, + IRR_NV_multisample_coverage, + IRR_NV_multisample_filter_hint, + IRR_NV_occlusion_query, + IRR_NV_packed_depth_stencil, + IRR_NV_parameter_buffer_object, + IRR_NV_parameter_buffer_object2, + IRR_NV_path_rendering, + IRR_NV_pixel_data_range, + IRR_NV_point_sprite, + IRR_NV_present_video, + IRR_NV_primitive_restart, + IRR_NV_register_combiners, + IRR_NV_register_combiners2, + IRR_NV_shader_atomic_counters, + IRR_NV_shader_atomic_float, + IRR_NV_shader_buffer_load, + IRR_NV_shader_buffer_store, + IRR_NV_shader_storage_buffer_object, + IRR_NV_tessellation_program5, + IRR_NV_texgen_emboss, + IRR_NV_texgen_reflection, + IRR_NV_texture_barrier, + IRR_NV_texture_compression_vtc, + IRR_NV_texture_env_combine4, + IRR_NV_texture_expand_normal, + IRR_NV_texture_multisample, + IRR_NV_texture_rectangle, + IRR_NV_texture_shader, + IRR_NV_texture_shader2, + IRR_NV_texture_shader3, + IRR_NV_transform_feedback, + IRR_NV_transform_feedback2, + IRR_NV_vdpau_interop, + IRR_NV_vertex_array_range, + IRR_NV_vertex_array_range2, + IRR_NV_vertex_attrib_integer_64bit, + IRR_NV_vertex_buffer_unified_memory, + IRR_NV_vertex_program, + IRR_NV_vertex_program1_1, + IRR_NV_vertex_program2, + IRR_NV_vertex_program2_option, + IRR_NV_vertex_program3, + IRR_NV_vertex_program4, + IRR_NV_video_capture, + IRR_OES_byte_coordinates, + IRR_OES_compressed_paletted_texture, + IRR_OES_fixed_point, + IRR_OES_query_matrix, + IRR_OES_read_format, + IRR_OES_single_precision, + IRR_OML_interlace, + IRR_OML_resample, + IRR_OML_subsample, + IRR_PGI_misc_hints, + IRR_PGI_vertex_hints, + IRR_REND_screen_coordinates, + IRR_S3_s3tc, + IRR_SGI_color_matrix, + IRR_SGI_color_table, + IRR_SGI_texture_color_table, + IRR_SGIS_detail_texture, + IRR_SGIS_fog_function, + IRR_SGIS_generate_mipmap, + IRR_SGIS_multisample, + IRR_SGIS_pixel_texture, + IRR_SGIS_point_line_texgen, + IRR_SGIS_point_parameters, + IRR_SGIS_sharpen_texture, + IRR_SGIS_texture4D, + IRR_SGIS_texture_border_clamp, + IRR_SGIS_texture_color_mask, + IRR_SGIS_texture_edge_clamp, + IRR_SGIS_texture_filter4, + IRR_SGIS_texture_lod, + IRR_SGIS_texture_select, + IRR_SGIX_async, + IRR_SGIX_async_histogram, + IRR_SGIX_async_pixel, + IRR_SGIX_blend_alpha_minmax, + IRR_SGIX_calligraphic_fragment, + IRR_SGIX_clipmap, + IRR_SGIX_convolution_accuracy, + IRR_SGIX_depth_pass_instrument, + IRR_SGIX_depth_texture, + IRR_SGIX_flush_raster, + IRR_SGIX_fog_offset, + IRR_SGIX_fog_scale, + IRR_SGIX_fragment_lighting, + IRR_SGIX_framezoom, + IRR_SGIX_igloo_interface, + IRR_SGIX_instruments, + IRR_SGIX_interlace, + IRR_SGIX_ir_instrument1, + IRR_SGIX_list_priority, + IRR_SGIX_pixel_texture, + IRR_SGIX_pixel_tiles, + IRR_SGIX_polynomial_ffd, + IRR_SGIX_reference_plane, + IRR_SGIX_resample, + IRR_SGIX_scalebias_hint, + IRR_SGIX_shadow, + IRR_SGIX_shadow_ambient, + IRR_SGIX_sprite, + IRR_SGIX_subsample, + IRR_SGIX_tag_sample_buffer, + IRR_SGIX_texture_add_env, + IRR_SGIX_texture_coordinate_clamp, + IRR_SGIX_texture_lod_bias, + IRR_SGIX_texture_multi_buffer, + IRR_SGIX_texture_scale_bias, + IRR_SGIX_vertex_preclip, + IRR_SGIX_ycrcb, + IRR_SGIX_ycrcba, + IRR_SGIX_ycrcb_subsample, + IRR_SUN_convolution_border_modes, + IRR_SUN_global_alpha, + IRR_SUN_mesh_array, + IRR_SUN_slice_accum, + IRR_SUN_triangle_list, + IRR_SUN_vertex, + IRR_SUNX_constant_data, + IRR_WIN_phong_shading, + IRR_WIN_specular_fog, + IRR_NVX_gpu_memory_info, + IRR_OpenGL_Feature_Count + }; + + // constructor + COpenGLExtensionHandler(); + + // deferred initialization + void initExtensions(video::IContextManager *cmgr, bool stencilBuffer); + + const COpenGLCoreFeature &getFeature() const; + + //! queries the features of the driver, returns true if feature is available + bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const; + + //! queries the features of the driver, returns true if feature is available + bool queryOpenGLFeature(EOpenGLFeatures feature) const + { + return FeatureAvailable[feature]; + } + + //! show all features with availability + void dump(ELOG_LEVEL logLevel) const; + + // Some variables for properties + bool StencilBuffer; + bool TextureCompressionExtension; + + // Some non-boolean properties + //! Maximum hardware lights supported + u8 MaxLights; + //! Maximal Anisotropy + u8 MaxAnisotropy; + //! Number of user clipplanes + u8 MaxUserClipPlanes; + //! Number of auxiliary buffers + u8 MaxAuxBuffers; + //! Optimal number of indices per meshbuffer + u32 MaxIndices; + //! Maximal texture dimension + u32 MaxTextureSize; + //! Maximal vertices handled by geometry shaders + u32 MaxGeometryVerticesOut; + //! Maximal LOD Bias + f32 MaxTextureLODBias; + //! Minimal and maximal supported thickness for lines without smoothing + GLfloat DimAliasedLine[2]; + //! Minimal and maximal supported thickness for points without smoothing + GLfloat DimAliasedPoint[2]; + //! Minimal and maximal supported thickness for lines with smoothing + GLfloat DimSmoothedLine[2]; + //! Minimal and maximal supported thickness for points with smoothing + GLfloat DimSmoothedPoint[2]; + + //! OpenGL version as Integer: 100*Major+Minor, i.e. 2.1 becomes 201 + u16 Version; + //! GLSL version as Integer: 100*Major+Minor + u16 ShaderLanguageVersion; + + bool OcclusionQuerySupport; + + // Info needed for workarounds. + bool IsAtiRadeonX; + + //! Workaround until direct state access with framebuffers is stable enough in drivers + // https://devtalk.nvidia.com/default/topic/1030494/opengl/bug-amp-amp-spec-violation-checknamedframebufferstatus-returns-gl_framebuffer_incomplete_dimensions_ext-under-gl-4-5-core/ + // https://stackoverflow.com/questions/51304706/problems-with-attaching-textures-of-different-sizes-to-fbo + static bool needsDSAFramebufferHack; + + // public access to the (loaded) extensions. + // general functions + void irrGlActiveTexture(GLenum texture); + void irrGlClientActiveTexture(GLenum texture); + void extGlPointParameterf(GLint loc, GLfloat f); + void extGlPointParameterfv(GLint loc, const GLfloat *v); + void extGlStencilFuncSeparate(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); + void extGlStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass); + void irrGlCompressedTexImage2D(GLenum target, GLint level, + GLenum internalformat, GLsizei width, GLsizei height, + GLint border, GLsizei imageSize, const void *data); + void irrGlCompressedTexSubImage2D(GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + GLenum format, GLsizei imageSize, const void *data); + + // shader programming + void extGlGenPrograms(GLsizei n, GLuint *programs); + void extGlBindProgram(GLenum target, GLuint program); + void extGlProgramString(GLenum target, GLenum format, GLsizei len, const GLvoid *string); + void extGlLoadProgram(GLenum target, GLuint id, GLsizei len, const GLubyte *string); + void extGlDeletePrograms(GLsizei n, const GLuint *programs); + void extGlProgramLocalParameter4fv(GLenum, GLuint, const GLfloat *); + GLhandleARB extGlCreateShaderObject(GLenum shaderType); + GLuint extGlCreateShader(GLenum shaderType); + // note: Due to the type confusion between shader_objects and OpenGL 2.0 + // we have to add the ARB extension for proper method definitions in case + // that handleARB and uint are the same type + void extGlShaderSourceARB(GLhandleARB shader, GLsizei numOfStrings, const char **strings, const GLint *lenOfStrings); + void extGlShaderSource(GLuint shader, GLsizei numOfStrings, const char **strings, const GLint *lenOfStrings); + // note: Due to the type confusion between shader_objects and OpenGL 2.0 + // we have to add the ARB extension for proper method definitions in case + // that handleARB and uint are the same type + void extGlCompileShaderARB(GLhandleARB shader); + void extGlCompileShader(GLuint shader); + GLhandleARB extGlCreateProgramObject(void); + GLuint extGlCreateProgram(void); + void extGlAttachObject(GLhandleARB program, GLhandleARB shader); + void extGlAttachShader(GLuint program, GLuint shader); + void extGlLinkProgramARB(GLhandleARB program); + // note: Due to the type confusion between shader_objects and OpenGL 2.0 + // we have to add the ARB extension for proper method definitions in case + // that handleARB and uint are the same type + void extGlLinkProgram(GLuint program); + void extGlUseProgramObject(GLhandleARB prog); + void irrGlUseProgram(GLuint prog); + void extGlDeleteObject(GLhandleARB object); + void extGlDeleteProgram(GLuint object); + void extGlDeleteShader(GLuint shader); + void extGlGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders); + void extGlGetAttachedObjects(GLhandleARB program, GLsizei maxcount, GLsizei *count, GLhandleARB *shaders); + void extGlGetInfoLog(GLhandleARB object, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); + void extGlGetShaderInfoLog(GLuint shader, GLsizei maxLength, GLsizei *length, GLchar *infoLog); + void extGlGetProgramInfoLog(GLuint program, GLsizei maxLength, GLsizei *length, GLchar *infoLog); + void extGlGetObjectParameteriv(GLhandleARB object, GLenum type, GLint *param); + void extGlGetShaderiv(GLuint shader, GLenum type, GLint *param); + void extGlGetProgramiv(GLuint program, GLenum type, GLint *param); + GLint extGlGetUniformLocationARB(GLhandleARB program, const char *name); + GLint extGlGetUniformLocation(GLuint program, const char *name); + void extGlUniform1fv(GLint loc, GLsizei count, const GLfloat *v); + void extGlUniform2fv(GLint loc, GLsizei count, const GLfloat *v); + void extGlUniform3fv(GLint loc, GLsizei count, const GLfloat *v); + void extGlUniform4fv(GLint loc, GLsizei count, const GLfloat *v); + void extGlUniform1bv(GLint loc, GLsizei count, const bool *v); + void extGlUniform2bv(GLint loc, GLsizei count, const bool *v); + void extGlUniform3bv(GLint loc, GLsizei count, const bool *v); + void extGlUniform4bv(GLint loc, GLsizei count, const bool *v); + void extGlUniform1iv(GLint loc, GLsizei count, const GLint *v); + void extGlUniform2iv(GLint loc, GLsizei count, const GLint *v); + void extGlUniform3iv(GLint loc, GLsizei count, const GLint *v); + void extGlUniform4iv(GLint loc, GLsizei count, const GLint *v); + void extGlUniform1uiv(GLint loc, GLsizei count, const GLuint *v); + void extGlUniform2uiv(GLint loc, GLsizei count, const GLuint *v); + void extGlUniform3uiv(GLint loc, GLsizei count, const GLuint *v); + void extGlUniform4uiv(GLint loc, GLsizei count, const GLuint *v); + void extGlUniformMatrix2fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); + void extGlUniformMatrix2x3fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); + void extGlUniformMatrix2x4fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); + void extGlUniformMatrix3x2fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); + void extGlUniformMatrix3fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); + void extGlUniformMatrix3x4fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); + void extGlUniformMatrix4x2fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); + void extGlUniformMatrix4x3fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); + void extGlUniformMatrix4fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); + void extGlGetActiveUniformARB(GLhandleARB program, GLuint index, GLsizei maxlength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); + void extGlGetActiveUniform(GLuint program, GLuint index, GLsizei maxlength, GLsizei *length, GLint *size, GLenum *type, GLchar *name); + + // framebuffer objects + void irrGlBindFramebuffer(GLenum target, GLuint framebuffer); + void irrGlDeleteFramebuffers(GLsizei n, const GLuint *framebuffers); + void irrGlGenFramebuffers(GLsizei n, GLuint *framebuffers); + GLenum irrGlCheckFramebufferStatus(GLenum target); + void irrGlFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + void irrGlBindRenderbuffer(GLenum target, GLuint renderbuffer); + void irrGlDeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers); + void irrGlGenRenderbuffers(GLsizei n, GLuint *renderbuffers); + void irrGlRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + void irrGlFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + void irrGlGenerateMipmap(GLenum target); + void irrGlActiveStencilFace(GLenum face); + void irrGlDrawBuffer(GLenum mode); + void irrGlDrawBuffers(GLsizei n, const GLenum *bufs); + + // vertex buffer object + void extGlGenBuffers(GLsizei n, GLuint *buffers); + void extGlBindBuffer(GLenum target, GLuint buffer); + void extGlBufferData(GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); + void extGlDeleteBuffers(GLsizei n, const GLuint *buffers); + void extGlBufferSubData(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); + void extGlGetBufferSubData(GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); + void *extGlMapBuffer(GLenum target, GLenum access); + GLboolean extGlUnmapBuffer(GLenum target); + GLboolean extGlIsBuffer(GLuint buffer); + void extGlGetBufferParameteriv(GLenum target, GLenum pname, GLint *params); + void extGlGetBufferPointerv(GLenum target, GLenum pname, GLvoid **params); + void extGlProvokingVertex(GLenum mode); + void extGlProgramParameteri(GLuint program, GLenum pname, GLint value); + + // occlusion query + void extGlGenQueries(GLsizei n, GLuint *ids); + void extGlDeleteQueries(GLsizei n, const GLuint *ids); + GLboolean extGlIsQuery(GLuint id); + void extGlBeginQuery(GLenum target, GLuint id); + void extGlEndQuery(GLenum target); + void extGlGetQueryiv(GLenum target, GLenum pname, GLint *params); + void extGlGetQueryObjectiv(GLuint id, GLenum pname, GLint *params); + void extGlGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params); + + // blend + void irrGlBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); + void irrGlBlendEquation(GLenum mode); + + // indexed + void irrGlEnableIndexed(GLenum target, GLuint index); + void irrGlDisableIndexed(GLenum target, GLuint index); + void irrGlColorMaskIndexed(GLuint buf, GLboolean r, GLboolean g, GLboolean b, GLboolean a); + void irrGlBlendFuncIndexed(GLuint buf, GLenum src, GLenum dst); + void irrGlBlendFuncSeparateIndexed(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); + void irrGlBlendEquationIndexed(GLuint buf, GLenum mode); + void irrGlBlendEquationSeparateIndexed(GLuint buf, GLenum modeRGB, GLenum modeAlpha); + + void extGlTextureSubImage2D(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); + void extGlTextureStorage2D(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); + void extGlTextureStorage3D(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); + void extGlGetTextureImage(GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); + void extGlNamedFramebufferTexture(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); + void extGlTextureParameteri(GLuint texture, GLenum pname, GLint param); + void extGlTextureParameterf(GLuint texture, GLenum pname, GLfloat param); + void extGlTextureParameteriv(GLuint texture, GLenum pname, const GLint *params); + void extGlTextureParameterfv(GLuint texture, GLenum pname, const GLfloat *params); + void extGlCreateTextures(GLenum target, GLsizei n, GLuint *textures); + void extGlCreateFramebuffers(GLsizei n, GLuint *framebuffers); + void extGlBindTextures(GLuint first, GLsizei count, const GLuint *textures, const GLenum *targets); + void extGlGenerateTextureMipmap(GLuint texture, GLenum target); + + // generic vsync setting method for several extensions + void extGlSwapInterval(int interval); + + // the global feature array + bool FeatureAvailable[IRR_OpenGL_Feature_Count]; + +protected: + COpenGLCoreFeature Feature; + + PFNGLACTIVETEXTUREPROC pGlActiveTexture; + PFNGLACTIVETEXTUREARBPROC pGlActiveTextureARB; + PFNGLCLIENTACTIVETEXTUREARBPROC pGlClientActiveTextureARB; + PFNGLGENPROGRAMSARBPROC pGlGenProgramsARB; + PFNGLGENPROGRAMSNVPROC pGlGenProgramsNV; + PFNGLBINDPROGRAMARBPROC pGlBindProgramARB; + PFNGLBINDPROGRAMNVPROC pGlBindProgramNV; + PFNGLDELETEPROGRAMSARBPROC pGlDeleteProgramsARB; + PFNGLDELETEPROGRAMSNVPROC pGlDeleteProgramsNV; + PFNGLPROGRAMSTRINGARBPROC pGlProgramStringARB; + PFNGLLOADPROGRAMNVPROC pGlLoadProgramNV; + PFNGLPROGRAMLOCALPARAMETER4FVARBPROC pGlProgramLocalParameter4fvARB; + PFNGLCREATESHADEROBJECTARBPROC pGlCreateShaderObjectARB; + PFNGLSHADERSOURCEARBPROC pGlShaderSourceARB; + PFNGLCOMPILESHADERARBPROC pGlCompileShaderARB; + PFNGLCREATEPROGRAMOBJECTARBPROC pGlCreateProgramObjectARB; + PFNGLATTACHOBJECTARBPROC pGlAttachObjectARB; + PFNGLLINKPROGRAMARBPROC pGlLinkProgramARB; + PFNGLUSEPROGRAMOBJECTARBPROC pGlUseProgramObjectARB; + PFNGLDELETEOBJECTARBPROC pGlDeleteObjectARB; + PFNGLCREATEPROGRAMPROC pGlCreateProgram; + PFNGLUSEPROGRAMPROC pGlUseProgram; + PFNGLDELETEPROGRAMPROC pGlDeleteProgram; + PFNGLDELETESHADERPROC pGlDeleteShader; + PFNGLGETATTACHEDOBJECTSARBPROC pGlGetAttachedObjectsARB; + PFNGLGETATTACHEDSHADERSPROC pGlGetAttachedShaders; + PFNGLCREATESHADERPROC pGlCreateShader; + PFNGLSHADERSOURCEPROC pGlShaderSource; + PFNGLCOMPILESHADERPROC pGlCompileShader; + PFNGLATTACHSHADERPROC pGlAttachShader; + PFNGLLINKPROGRAMPROC pGlLinkProgram; + PFNGLGETINFOLOGARBPROC pGlGetInfoLogARB; + PFNGLGETSHADERINFOLOGPROC pGlGetShaderInfoLog; + PFNGLGETPROGRAMINFOLOGPROC pGlGetProgramInfoLog; + PFNGLGETOBJECTPARAMETERIVARBPROC pGlGetObjectParameterivARB; + PFNGLGETSHADERIVPROC pGlGetShaderiv; + PFNGLGETSHADERIVPROC pGlGetProgramiv; + PFNGLGETUNIFORMLOCATIONARBPROC pGlGetUniformLocationARB; + PFNGLGETUNIFORMLOCATIONPROC pGlGetUniformLocation; + PFNGLUNIFORM1FVARBPROC pGlUniform1fvARB; + PFNGLUNIFORM2FVARBPROC pGlUniform2fvARB; + PFNGLUNIFORM3FVARBPROC pGlUniform3fvARB; + PFNGLUNIFORM4FVARBPROC pGlUniform4fvARB; + PFNGLUNIFORM1IVARBPROC pGlUniform1ivARB; + PFNGLUNIFORM2IVARBPROC pGlUniform2ivARB; + PFNGLUNIFORM3IVARBPROC pGlUniform3ivARB; + PFNGLUNIFORM4IVARBPROC pGlUniform4ivARB; + PFNGLUNIFORM1UIVPROC pGlUniform1uiv; + PFNGLUNIFORM2UIVPROC pGlUniform2uiv; + PFNGLUNIFORM3UIVPROC pGlUniform3uiv; + PFNGLUNIFORM4UIVPROC pGlUniform4uiv; + PFNGLUNIFORMMATRIX2FVARBPROC pGlUniformMatrix2fvARB; + PFNGLUNIFORMMATRIX2X3FVPROC pGlUniformMatrix2x3fv; + PFNGLUNIFORMMATRIX2X4FVPROC pGlUniformMatrix2x4fv; + PFNGLUNIFORMMATRIX3X2FVPROC pGlUniformMatrix3x2fv; + PFNGLUNIFORMMATRIX3FVARBPROC pGlUniformMatrix3fvARB; + PFNGLUNIFORMMATRIX3X4FVPROC pGlUniformMatrix3x4fv; + PFNGLUNIFORMMATRIX4X2FVPROC pGlUniformMatrix4x2fv; + PFNGLUNIFORMMATRIX4X3FVPROC pGlUniformMatrix4x3fv; + PFNGLUNIFORMMATRIX4FVARBPROC pGlUniformMatrix4fvARB; + PFNGLGETACTIVEUNIFORMARBPROC pGlGetActiveUniformARB; + PFNGLGETACTIVEUNIFORMPROC pGlGetActiveUniform; + PFNGLPOINTPARAMETERFARBPROC pGlPointParameterfARB; + PFNGLPOINTPARAMETERFVARBPROC pGlPointParameterfvARB; + PFNGLSTENCILFUNCSEPARATEPROC pGlStencilFuncSeparate; + PFNGLSTENCILOPSEPARATEPROC pGlStencilOpSeparate; + PFNGLSTENCILFUNCSEPARATEATIPROC pGlStencilFuncSeparateATI; + PFNGLSTENCILOPSEPARATEATIPROC pGlStencilOpSeparateATI; + PFNGLCOMPRESSEDTEXIMAGE2DPROC pGlCompressedTexImage2D; + PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC pGlCompressedTexSubImage2D; + // ARB framebuffer object + PFNGLBINDFRAMEBUFFERPROC pGlBindFramebuffer; + PFNGLDELETEFRAMEBUFFERSPROC pGlDeleteFramebuffers; + PFNGLGENFRAMEBUFFERSPROC pGlGenFramebuffers; + PFNGLCHECKFRAMEBUFFERSTATUSPROC pGlCheckFramebufferStatus; + PFNGLFRAMEBUFFERTEXTURE2DPROC pGlFramebufferTexture2D; + PFNGLBINDRENDERBUFFERPROC pGlBindRenderbuffer; + PFNGLDELETERENDERBUFFERSPROC pGlDeleteRenderbuffers; + PFNGLGENRENDERBUFFERSPROC pGlGenRenderbuffers; + PFNGLRENDERBUFFERSTORAGEPROC pGlRenderbufferStorage; + PFNGLFRAMEBUFFERRENDERBUFFERPROC pGlFramebufferRenderbuffer; + PFNGLGENERATEMIPMAPPROC pGlGenerateMipmap; + // EXT framebuffer object + PFNGLBINDFRAMEBUFFEREXTPROC pGlBindFramebufferEXT; + PFNGLDELETEFRAMEBUFFERSEXTPROC pGlDeleteFramebuffersEXT; + PFNGLGENFRAMEBUFFERSEXTPROC pGlGenFramebuffersEXT; + PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC pGlCheckFramebufferStatusEXT; + PFNGLFRAMEBUFFERTEXTURE2DEXTPROC pGlFramebufferTexture2DEXT; + PFNGLBINDRENDERBUFFEREXTPROC pGlBindRenderbufferEXT; + PFNGLDELETERENDERBUFFERSEXTPROC pGlDeleteRenderbuffersEXT; + PFNGLGENRENDERBUFFERSEXTPROC pGlGenRenderbuffersEXT; + PFNGLRENDERBUFFERSTORAGEEXTPROC pGlRenderbufferStorageEXT; + PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC pGlFramebufferRenderbufferEXT; + PFNGLGENERATEMIPMAPEXTPROC pGlGenerateMipmapEXT; + PFNGLACTIVESTENCILFACEEXTPROC pGlActiveStencilFaceEXT; + PFNGLDRAWBUFFERSARBPROC pGlDrawBuffersARB; + PFNGLDRAWBUFFERSATIPROC pGlDrawBuffersATI; + PFNGLGENBUFFERSARBPROC pGlGenBuffersARB; + PFNGLBINDBUFFERARBPROC pGlBindBufferARB; + PFNGLBUFFERDATAARBPROC pGlBufferDataARB; + PFNGLDELETEBUFFERSARBPROC pGlDeleteBuffersARB; + PFNGLBUFFERSUBDATAARBPROC pGlBufferSubDataARB; + PFNGLGETBUFFERSUBDATAARBPROC pGlGetBufferSubDataARB; + PFNGLMAPBUFFERARBPROC pGlMapBufferARB; + PFNGLUNMAPBUFFERARBPROC pGlUnmapBufferARB; + PFNGLISBUFFERARBPROC pGlIsBufferARB; + PFNGLGETBUFFERPARAMETERIVARBPROC pGlGetBufferParameterivARB; + PFNGLGETBUFFERPOINTERVARBPROC pGlGetBufferPointervARB; + PFNGLPROVOKINGVERTEXPROC pGlProvokingVertexARB; + PFNGLPROVOKINGVERTEXEXTPROC pGlProvokingVertexEXT; + PFNGLPROGRAMPARAMETERIARBPROC pGlProgramParameteriARB; + PFNGLPROGRAMPARAMETERIEXTPROC pGlProgramParameteriEXT; + PFNGLGENQUERIESARBPROC pGlGenQueriesARB; + PFNGLDELETEQUERIESARBPROC pGlDeleteQueriesARB; + PFNGLISQUERYARBPROC pGlIsQueryARB; + PFNGLBEGINQUERYARBPROC pGlBeginQueryARB; + PFNGLENDQUERYARBPROC pGlEndQueryARB; + PFNGLGETQUERYIVARBPROC pGlGetQueryivARB; + PFNGLGETQUERYOBJECTIVARBPROC pGlGetQueryObjectivARB; + PFNGLGETQUERYOBJECTUIVARBPROC pGlGetQueryObjectuivARB; + PFNGLGENOCCLUSIONQUERIESNVPROC pGlGenOcclusionQueriesNV; + PFNGLDELETEOCCLUSIONQUERIESNVPROC pGlDeleteOcclusionQueriesNV; + PFNGLISOCCLUSIONQUERYNVPROC pGlIsOcclusionQueryNV; + PFNGLBEGINOCCLUSIONQUERYNVPROC pGlBeginOcclusionQueryNV; + PFNGLENDOCCLUSIONQUERYNVPROC pGlEndOcclusionQueryNV; + PFNGLGETOCCLUSIONQUERYIVNVPROC pGlGetOcclusionQueryivNV; + PFNGLGETOCCLUSIONQUERYUIVNVPROC pGlGetOcclusionQueryuivNV; + // Blend + PFNGLBLENDFUNCSEPARATEEXTPROC pGlBlendFuncSeparateEXT; + PFNGLBLENDFUNCSEPARATEPROC pGlBlendFuncSeparate; + PFNGLBLENDEQUATIONEXTPROC pGlBlendEquationEXT; + PFNGLBLENDEQUATIONPROC pGlBlendEquation; + PFNGLBLENDEQUATIONSEPARATEEXTPROC pGlBlendEquationSeparateEXT; + PFNGLBLENDEQUATIONSEPARATEPROC pGlBlendEquationSeparate; + // Indexed + PFNGLENABLEINDEXEDEXTPROC pGlEnableIndexedEXT; + PFNGLDISABLEINDEXEDEXTPROC pGlDisableIndexedEXT; + PFNGLCOLORMASKINDEXEDEXTPROC pGlColorMaskIndexedEXT; + PFNGLBLENDFUNCINDEXEDAMDPROC pGlBlendFuncIndexedAMD; + PFNGLBLENDFUNCIPROC pGlBlendFunciARB; + PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC pGlBlendFuncSeparateIndexedAMD; + PFNGLBLENDFUNCSEPARATEIPROC pGlBlendFuncSeparateiARB; + PFNGLBLENDEQUATIONINDEXEDAMDPROC pGlBlendEquationIndexedAMD; + PFNGLBLENDEQUATIONIPROC pGlBlendEquationiARB; + PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC pGlBlendEquationSeparateIndexedAMD; + PFNGLBLENDEQUATIONSEPARATEIPROC pGlBlendEquationSeparateiARB; + + // DSA + PFNGLTEXTURESTORAGE2DPROC pGlTextureStorage2D; + PFNGLTEXTURESTORAGE3DPROC pGlTextureStorage3D; + PFNGLTEXTURESUBIMAGE2DPROC pGlTextureSubImage2D; + PFNGLGETTEXTUREIMAGEPROC pGlGetTextureImage; + PFNGLNAMEDFRAMEBUFFERTEXTUREPROC pGlNamedFramebufferTexture; + PFNGLTEXTUREPARAMETERIPROC pGlTextureParameteri; + PFNGLTEXTUREPARAMETERFPROC pGlTextureParameterf; + PFNGLTEXTUREPARAMETERIVPROC pGlTextureParameteriv; + PFNGLTEXTUREPARAMETERFVPROC pGlTextureParameterfv; + + PFNGLCREATETEXTURESPROC pGlCreateTextures; + PFNGLCREATEFRAMEBUFFERSPROC pGlCreateFramebuffers; + PFNGLBINDTEXTURESPROC pGlBindTextures; + PFNGLGENERATETEXTUREMIPMAPPROC pGlGenerateTextureMipmap; + // DSA with EXT or functions to simulate it + PFNGLTEXTURESTORAGE2DEXTPROC pGlTextureStorage2DEXT; + PFNGLTEXSTORAGE2DPROC pGlTexStorage2D; + PFNGLTEXTURESTORAGE3DEXTPROC pGlTextureStorage3DEXT; + PFNGLTEXSTORAGE3DPROC pGlTexStorage3D; + PFNGLTEXTURESUBIMAGE2DEXTPROC pGlTextureSubImage2DEXT; + PFNGLGETTEXTUREIMAGEEXTPROC pGlGetTextureImageEXT; + PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC pGlNamedFramebufferTextureEXT; + PFNGLFRAMEBUFFERTEXTUREPROC pGlFramebufferTexture; + PFNGLGENERATETEXTUREMIPMAPEXTPROC pGlGenerateTextureMipmapEXT; + +#if defined(WGL_EXT_swap_control) + PFNWGLSWAPINTERVALEXTPROC pWglSwapIntervalEXT; +#endif +#if defined(GLX_SGI_swap_control) + PFNGLXSWAPINTERVALSGIPROC pGlxSwapIntervalSGI; +#endif +#if defined(GLX_EXT_swap_control) + PFNGLXSWAPINTERVALEXTPROC pGlxSwapIntervalEXT; +#endif +#if defined(GLX_MESA_swap_control) + PFNGLXSWAPINTERVALMESAPROC pGlxSwapIntervalMESA; +#endif +}; + +inline void COpenGLExtensionHandler::irrGlActiveTexture(GLenum texture) +{ + if (pGlActiveTexture) + pGlActiveTexture(texture); + else if (pGlActiveTextureARB) + pGlActiveTextureARB(texture); +} + +inline void COpenGLExtensionHandler::irrGlClientActiveTexture(GLenum texture) +{ + if (pGlClientActiveTextureARB) + pGlClientActiveTextureARB(texture); +} + +inline void COpenGLExtensionHandler::extGlGenPrograms(GLsizei n, GLuint *programs) +{ + if (programs) + memset(programs, 0, n * sizeof(GLuint)); + if (pGlGenProgramsARB) + pGlGenProgramsARB(n, programs); + else if (pGlGenProgramsNV) + pGlGenProgramsNV(n, programs); +} + +inline void COpenGLExtensionHandler::extGlBindProgram(GLenum target, GLuint program) +{ + if (pGlBindProgramARB) + pGlBindProgramARB(target, program); + else if (pGlBindProgramNV) + pGlBindProgramNV(target, program); +} + +inline void COpenGLExtensionHandler::extGlProgramString(GLenum target, GLenum format, GLsizei len, const GLvoid *string) +{ + if (pGlProgramStringARB) + pGlProgramStringARB(target, format, len, string); +} + +inline void COpenGLExtensionHandler::extGlLoadProgram(GLenum target, GLuint id, GLsizei len, const GLubyte *string) +{ + if (pGlLoadProgramNV) + pGlLoadProgramNV(target, id, len, string); +} + +inline void COpenGLExtensionHandler::extGlDeletePrograms(GLsizei n, const GLuint *programs) +{ + if (pGlDeleteProgramsARB) + pGlDeleteProgramsARB(n, programs); + else if (pGlDeleteProgramsNV) + pGlDeleteProgramsNV(n, programs); +} + +inline void COpenGLExtensionHandler::extGlProgramLocalParameter4fv(GLenum n, GLuint i, const GLfloat *f) +{ + if (pGlProgramLocalParameter4fvARB) + pGlProgramLocalParameter4fvARB(n, i, f); +} + +inline GLhandleARB COpenGLExtensionHandler::extGlCreateShaderObject(GLenum shaderType) +{ + if (pGlCreateShaderObjectARB) + return pGlCreateShaderObjectARB(shaderType); + return 0; +} + +inline GLuint COpenGLExtensionHandler::extGlCreateShader(GLenum shaderType) +{ + if (pGlCreateShader) + return pGlCreateShader(shaderType); + return 0; +} + +inline void COpenGLExtensionHandler::extGlShaderSourceARB(GLhandleARB shader, GLsizei numOfStrings, const char **strings, const GLint *lenOfStrings) +{ + if (pGlShaderSourceARB) + pGlShaderSourceARB(shader, numOfStrings, strings, lenOfStrings); +} + +inline void COpenGLExtensionHandler::extGlShaderSource(GLuint shader, GLsizei numOfStrings, const char **strings, const GLint *lenOfStrings) +{ + if (pGlShaderSource) + pGlShaderSource(shader, numOfStrings, strings, lenOfStrings); +} + +inline void COpenGLExtensionHandler::extGlCompileShaderARB(GLhandleARB shader) +{ + if (pGlCompileShaderARB) + pGlCompileShaderARB(shader); +} + +inline void COpenGLExtensionHandler::extGlCompileShader(GLuint shader) +{ + if (pGlCompileShader) + pGlCompileShader(shader); +} + +inline GLhandleARB COpenGLExtensionHandler::extGlCreateProgramObject(void) +{ + if (pGlCreateProgramObjectARB) + return pGlCreateProgramObjectARB(); + return 0; +} + +inline GLuint COpenGLExtensionHandler::extGlCreateProgram(void) +{ + if (pGlCreateProgram) + return pGlCreateProgram(); + return 0; +} + +inline void COpenGLExtensionHandler::extGlAttachObject(GLhandleARB program, GLhandleARB shader) +{ + if (pGlAttachObjectARB) + pGlAttachObjectARB(program, shader); +} + +inline void COpenGLExtensionHandler::extGlAttachShader(GLuint program, GLuint shader) +{ + if (pGlAttachShader) + pGlAttachShader(program, shader); +} + +inline void COpenGLExtensionHandler::extGlLinkProgramARB(GLhandleARB program) +{ + if (pGlLinkProgramARB) + pGlLinkProgramARB(program); +} + +inline void COpenGLExtensionHandler::extGlLinkProgram(GLuint program) +{ + if (pGlLinkProgram) + pGlLinkProgram(program); +} + +inline void COpenGLExtensionHandler::extGlUseProgramObject(GLhandleARB prog) +{ + if (pGlUseProgramObjectARB) + pGlUseProgramObjectARB(prog); +} + +inline void COpenGLExtensionHandler::irrGlUseProgram(GLuint prog) +{ + if (pGlUseProgram) + pGlUseProgram(prog); +} + +inline void COpenGLExtensionHandler::extGlDeleteObject(GLhandleARB object) +{ + if (pGlDeleteObjectARB) + pGlDeleteObjectARB(object); +} + +inline void COpenGLExtensionHandler::extGlDeleteProgram(GLuint object) +{ + if (pGlDeleteProgram) + pGlDeleteProgram(object); +} + +inline void COpenGLExtensionHandler::extGlDeleteShader(GLuint shader) +{ + if (pGlDeleteShader) + pGlDeleteShader(shader); +} + +inline void COpenGLExtensionHandler::extGlGetAttachedObjects(GLhandleARB program, GLsizei maxcount, GLsizei *count, GLhandleARB *shaders) +{ + if (count) + *count = 0; + if (pGlGetAttachedObjectsARB) + pGlGetAttachedObjectsARB(program, maxcount, count, shaders); +} + +inline void COpenGLExtensionHandler::extGlGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders) +{ + if (count) + *count = 0; + if (pGlGetAttachedShaders) + pGlGetAttachedShaders(program, maxcount, count, shaders); +} + +inline void COpenGLExtensionHandler::extGlGetInfoLog(GLhandleARB object, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog) +{ + if (length) + *length = 0; + if (pGlGetInfoLogARB) + pGlGetInfoLogARB(object, maxLength, length, infoLog); +} + +inline void COpenGLExtensionHandler::extGlGetShaderInfoLog(GLuint shader, GLsizei maxLength, GLsizei *length, GLchar *infoLog) +{ + if (length) + *length = 0; + if (pGlGetShaderInfoLog) + pGlGetShaderInfoLog(shader, maxLength, length, infoLog); +} + +inline void COpenGLExtensionHandler::extGlGetProgramInfoLog(GLuint program, GLsizei maxLength, GLsizei *length, GLchar *infoLog) +{ + if (length) + *length = 0; + if (pGlGetProgramInfoLog) + pGlGetProgramInfoLog(program, maxLength, length, infoLog); +} + +inline void COpenGLExtensionHandler::extGlGetObjectParameteriv(GLhandleARB object, GLenum type, GLint *param) +{ + if (pGlGetObjectParameterivARB) + pGlGetObjectParameterivARB(object, type, param); +} + +inline void COpenGLExtensionHandler::extGlGetShaderiv(GLuint shader, GLenum type, GLint *param) +{ + if (pGlGetShaderiv) + pGlGetShaderiv(shader, type, param); +} + +inline void COpenGLExtensionHandler::extGlGetProgramiv(GLuint program, GLenum type, GLint *param) +{ + if (pGlGetProgramiv) + pGlGetProgramiv(program, type, param); +} + +inline GLint COpenGLExtensionHandler::extGlGetUniformLocationARB(GLhandleARB program, const char *name) +{ + if (pGlGetUniformLocationARB) + return pGlGetUniformLocationARB(program, name); + return 0; +} + +inline GLint COpenGLExtensionHandler::extGlGetUniformLocation(GLuint program, const char *name) +{ + if (pGlGetUniformLocation) + return pGlGetUniformLocation(program, name); + return 0; +} + +inline void COpenGLExtensionHandler::extGlUniform1fv(GLint loc, GLsizei count, const GLfloat *v) +{ + if (pGlUniform1fvARB) + pGlUniform1fvARB(loc, count, v); +} + +inline void COpenGLExtensionHandler::extGlUniform2fv(GLint loc, GLsizei count, const GLfloat *v) +{ + if (pGlUniform2fvARB) + pGlUniform2fvARB(loc, count, v); +} + +inline void COpenGLExtensionHandler::extGlUniform3fv(GLint loc, GLsizei count, const GLfloat *v) +{ + if (pGlUniform3fvARB) + pGlUniform3fvARB(loc, count, v); +} + +inline void COpenGLExtensionHandler::extGlUniform4fv(GLint loc, GLsizei count, const GLfloat *v) +{ + if (pGlUniform4fvARB) + pGlUniform4fvARB(loc, count, v); +} + +inline void COpenGLExtensionHandler::extGlUniform1uiv(GLint loc, GLsizei count, const GLuint *v) +{ + if (pGlUniform1uiv) + pGlUniform1uiv(loc, count, v); +} + +inline void COpenGLExtensionHandler::extGlUniform2uiv(GLint loc, GLsizei count, const GLuint *v) +{ + if (pGlUniform2uiv) + pGlUniform2uiv(loc, count, v); +} + +inline void COpenGLExtensionHandler::extGlUniform3uiv(GLint loc, GLsizei count, const GLuint *v) +{ + if (pGlUniform3uiv) + pGlUniform3uiv(loc, count, v); +} + +inline void COpenGLExtensionHandler::extGlUniform4uiv(GLint loc, GLsizei count, const GLuint *v) +{ + if (pGlUniform4uiv) + pGlUniform4uiv(loc, count, v); +} + +inline void COpenGLExtensionHandler::extGlUniform1iv(GLint loc, GLsizei count, const GLint *v) +{ + if (pGlUniform1ivARB) + pGlUniform1ivARB(loc, count, v); +} + +inline void COpenGLExtensionHandler::extGlUniform2iv(GLint loc, GLsizei count, const GLint *v) +{ + if (pGlUniform2ivARB) + pGlUniform2ivARB(loc, count, v); +} + +inline void COpenGLExtensionHandler::extGlUniform3iv(GLint loc, GLsizei count, const GLint *v) +{ + if (pGlUniform3ivARB) + pGlUniform3ivARB(loc, count, v); +} + +inline void COpenGLExtensionHandler::extGlUniform4iv(GLint loc, GLsizei count, const GLint *v) +{ + if (pGlUniform4ivARB) + pGlUniform4ivARB(loc, count, v); +} + +inline void COpenGLExtensionHandler::extGlUniformMatrix2fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) +{ + if (pGlUniformMatrix2fvARB) + pGlUniformMatrix2fvARB(loc, count, transpose, v); +} + +inline void COpenGLExtensionHandler::extGlUniformMatrix2x3fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) +{ + if (pGlUniformMatrix2x3fv) + pGlUniformMatrix2x3fv(loc, count, transpose, v); + else + os::Printer::log("glUniformMatrix2x3fv not supported", ELL_ERROR); +} + +inline void COpenGLExtensionHandler::extGlUniformMatrix2x4fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) +{ + if (pGlUniformMatrix2x4fv) + pGlUniformMatrix2x4fv(loc, count, transpose, v); + else + os::Printer::log("glUniformMatrix2x4fv not supported", ELL_ERROR); +} + +inline void COpenGLExtensionHandler::extGlUniformMatrix3x2fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) +{ + if (pGlUniformMatrix3x2fv) + pGlUniformMatrix3x2fv(loc, count, transpose, v); + else + os::Printer::log("glUniformMatrix3x2fv not supported", ELL_ERROR); +} + +inline void COpenGLExtensionHandler::extGlUniformMatrix3fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) +{ + if (pGlUniformMatrix3fvARB) + pGlUniformMatrix3fvARB(loc, count, transpose, v); +} + +inline void COpenGLExtensionHandler::extGlUniformMatrix3x4fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) +{ + if (pGlUniformMatrix3x4fv) + pGlUniformMatrix3x4fv(loc, count, transpose, v); + else + os::Printer::log("glUniformMatrix3x4fv not supported", ELL_ERROR); +} + +inline void COpenGLExtensionHandler::extGlUniformMatrix4x2fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) +{ + if (pGlUniformMatrix4x2fv) + pGlUniformMatrix4x2fv(loc, count, transpose, v); + else + os::Printer::log("glUniformMatrix4x2fv not supported", ELL_ERROR); +} + +inline void COpenGLExtensionHandler::extGlUniformMatrix4x3fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) +{ + if (pGlUniformMatrix4x3fv) + pGlUniformMatrix4x3fv(loc, count, transpose, v); + else + os::Printer::log("glUniformMatrix4x3fv not supported", ELL_ERROR); +} + +inline void COpenGLExtensionHandler::extGlUniformMatrix4fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) +{ + if (pGlUniformMatrix4fvARB) + pGlUniformMatrix4fvARB(loc, count, transpose, v); +} + +inline void COpenGLExtensionHandler::extGlGetActiveUniformARB(GLhandleARB program, + GLuint index, GLsizei maxlength, GLsizei *length, + GLint *size, GLenum *type, GLcharARB *name) +{ + if (length) + *length = 0; + if (pGlGetActiveUniformARB) + pGlGetActiveUniformARB(program, index, maxlength, length, size, type, name); +} + +inline void COpenGLExtensionHandler::extGlGetActiveUniform(GLuint program, + GLuint index, GLsizei maxlength, GLsizei *length, + GLint *size, GLenum *type, GLchar *name) +{ + if (length) + *length = 0; + if (pGlGetActiveUniform) + pGlGetActiveUniform(program, index, maxlength, length, size, type, name); +} + +inline void COpenGLExtensionHandler::extGlPointParameterf(GLint loc, GLfloat f) +{ + if (pGlPointParameterfARB) + pGlPointParameterfARB(loc, f); +} + +inline void COpenGLExtensionHandler::extGlPointParameterfv(GLint loc, const GLfloat *v) +{ + if (pGlPointParameterfvARB) + pGlPointParameterfvARB(loc, v); +} + +inline void COpenGLExtensionHandler::extGlStencilFuncSeparate(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask) +{ + if (pGlStencilFuncSeparate) + pGlStencilFuncSeparate(frontfunc, backfunc, ref, mask); + else if (pGlStencilFuncSeparateATI) + pGlStencilFuncSeparateATI(frontfunc, backfunc, ref, mask); +} + +inline void COpenGLExtensionHandler::extGlStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) +{ + if (pGlStencilOpSeparate) + pGlStencilOpSeparate(face, fail, zfail, zpass); + else if (pGlStencilOpSeparateATI) + pGlStencilOpSeparateATI(face, fail, zfail, zpass); +} + +inline void COpenGLExtensionHandler::irrGlCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, + GLsizei height, GLint border, GLsizei imageSize, const void *data) +{ + if (pGlCompressedTexImage2D) + pGlCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); +} + +inline void COpenGLExtensionHandler::irrGlCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data) +{ + if (pGlCompressedTexSubImage2D) + pGlCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); +} + +inline void COpenGLExtensionHandler::irrGlBindFramebuffer(GLenum target, GLuint framebuffer) +{ + if (pGlBindFramebuffer) + pGlBindFramebuffer(target, framebuffer); + else if (pGlBindFramebufferEXT) + pGlBindFramebufferEXT(target, framebuffer); +} + +inline void COpenGLExtensionHandler::irrGlDeleteFramebuffers(GLsizei n, const GLuint *framebuffers) +{ + if (pGlDeleteFramebuffers) + pGlDeleteFramebuffers(n, framebuffers); + else if (pGlDeleteFramebuffersEXT) + pGlDeleteFramebuffersEXT(n, framebuffers); +} + +inline void COpenGLExtensionHandler::irrGlGenFramebuffers(GLsizei n, GLuint *framebuffers) +{ + if (framebuffers) + memset(framebuffers, 0, n * sizeof(GLuint)); + if (pGlGenFramebuffers) + pGlGenFramebuffers(n, framebuffers); + else if (pGlGenFramebuffersEXT) + pGlGenFramebuffersEXT(n, framebuffers); +} + +inline GLenum COpenGLExtensionHandler::irrGlCheckFramebufferStatus(GLenum target) +{ + if (pGlCheckFramebufferStatus) + return pGlCheckFramebufferStatus(target); + else if (pGlCheckFramebufferStatusEXT) + return pGlCheckFramebufferStatusEXT(target); + else + return 0; +} + +inline void COpenGLExtensionHandler::irrGlFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +{ + if (pGlFramebufferTexture2D) + pGlFramebufferTexture2D(target, attachment, textarget, texture, level); + else if (pGlFramebufferTexture2DEXT) + pGlFramebufferTexture2DEXT(target, attachment, textarget, texture, level); +} + +inline void COpenGLExtensionHandler::irrGlBindRenderbuffer(GLenum target, GLuint renderbuffer) +{ + if (pGlBindRenderbuffer) + pGlBindRenderbuffer(target, renderbuffer); + else if (pGlBindRenderbufferEXT) + pGlBindRenderbufferEXT(target, renderbuffer); +} + +inline void COpenGLExtensionHandler::irrGlDeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers) +{ + if (pGlDeleteRenderbuffers) + pGlDeleteRenderbuffers(n, renderbuffers); + else if (pGlDeleteRenderbuffersEXT) + pGlDeleteRenderbuffersEXT(n, renderbuffers); +} + +inline void COpenGLExtensionHandler::irrGlGenRenderbuffers(GLsizei n, GLuint *renderbuffers) +{ + if (renderbuffers) + memset(renderbuffers, 0, n * sizeof(GLuint)); + if (pGlGenRenderbuffers) + pGlGenRenderbuffers(n, renderbuffers); + else if (pGlGenRenderbuffersEXT) + pGlGenRenderbuffersEXT(n, renderbuffers); +} + +inline void COpenGLExtensionHandler::irrGlRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) +{ + if (pGlRenderbufferStorage) + pGlRenderbufferStorage(target, internalformat, width, height); + else if (pGlRenderbufferStorageEXT) + pGlRenderbufferStorageEXT(target, internalformat, width, height); +} + +inline void COpenGLExtensionHandler::irrGlFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +{ + if (pGlFramebufferRenderbuffer) + pGlFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer); + else if (pGlFramebufferRenderbufferEXT) + pGlFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer); +} + +inline void COpenGLExtensionHandler::irrGlGenerateMipmap(GLenum target) +{ + if (pGlGenerateMipmap) + pGlGenerateMipmap(target); + else if (pGlGenerateMipmapEXT) + pGlGenerateMipmapEXT(target); +} + +inline void COpenGLExtensionHandler::irrGlActiveStencilFace(GLenum face) +{ + if (pGlActiveStencilFaceEXT) + pGlActiveStencilFaceEXT(face); +} + +inline void COpenGLExtensionHandler::irrGlDrawBuffer(GLenum mode) +{ + glDrawBuffer(mode); +} + +inline void COpenGLExtensionHandler::irrGlDrawBuffers(GLsizei n, const GLenum *bufs) +{ + if (pGlDrawBuffersARB) + pGlDrawBuffersARB(n, bufs); + else if (pGlDrawBuffersATI) + pGlDrawBuffersATI(n, bufs); +} + +inline void COpenGLExtensionHandler::extGlGenBuffers(GLsizei n, GLuint *buffers) +{ + if (buffers) + memset(buffers, 0, n * sizeof(GLuint)); + if (pGlGenBuffersARB) + pGlGenBuffersARB(n, buffers); +} + +inline void COpenGLExtensionHandler::extGlBindBuffer(GLenum target, GLuint buffer) +{ + if (pGlBindBufferARB) + pGlBindBufferARB(target, buffer); +} + +inline void COpenGLExtensionHandler::extGlBufferData(GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage) +{ + if (pGlBufferDataARB) + pGlBufferDataARB(target, size, data, usage); +} + +inline void COpenGLExtensionHandler::extGlDeleteBuffers(GLsizei n, const GLuint *buffers) +{ + if (pGlDeleteBuffersARB) + pGlDeleteBuffersARB(n, buffers); +} + +inline void COpenGLExtensionHandler::extGlBufferSubData(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data) +{ + if (pGlBufferSubDataARB) + pGlBufferSubDataARB(target, offset, size, data); +} + +inline void COpenGLExtensionHandler::extGlGetBufferSubData(GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data) +{ + if (pGlGetBufferSubDataARB) + pGlGetBufferSubDataARB(target, offset, size, data); +} + +inline void *COpenGLExtensionHandler::extGlMapBuffer(GLenum target, GLenum access) +{ + if (pGlMapBufferARB) + return pGlMapBufferARB(target, access); + return 0; +} + +inline GLboolean COpenGLExtensionHandler::extGlUnmapBuffer(GLenum target) +{ + if (pGlUnmapBufferARB) + return pGlUnmapBufferARB(target); + return false; +} + +inline GLboolean COpenGLExtensionHandler::extGlIsBuffer(GLuint buffer) +{ + if (pGlIsBufferARB) + return pGlIsBufferARB(buffer); + return false; +} + +inline void COpenGLExtensionHandler::extGlGetBufferParameteriv(GLenum target, GLenum pname, GLint *params) +{ + if (pGlGetBufferParameterivARB) + pGlGetBufferParameterivARB(target, pname, params); +} + +inline void COpenGLExtensionHandler::extGlGetBufferPointerv(GLenum target, GLenum pname, GLvoid **params) +{ + if (pGlGetBufferPointervARB) + pGlGetBufferPointervARB(target, pname, params); +} + +inline void COpenGLExtensionHandler::extGlProvokingVertex(GLenum mode) +{ + if (FeatureAvailable[IRR_ARB_provoking_vertex] && pGlProvokingVertexARB) + pGlProvokingVertexARB(mode); + else if (FeatureAvailable[IRR_EXT_provoking_vertex] && pGlProvokingVertexEXT) + pGlProvokingVertexEXT(mode); +} + +inline void COpenGLExtensionHandler::extGlProgramParameteri(GLuint program, GLenum pname, GLint value) +{ + if (queryFeature(EVDF_GEOMETRY_SHADER)) { + if (pGlProgramParameteriARB) + pGlProgramParameteriARB(program, pname, value); + else if (pGlProgramParameteriEXT) + pGlProgramParameteriEXT(program, pname, value); + } +} + +inline void COpenGLExtensionHandler::extGlGenQueries(GLsizei n, GLuint *ids) +{ + if (pGlGenQueriesARB) + pGlGenQueriesARB(n, ids); + else if (pGlGenOcclusionQueriesNV) + pGlGenOcclusionQueriesNV(n, ids); +} + +inline void COpenGLExtensionHandler::extGlDeleteQueries(GLsizei n, const GLuint *ids) +{ + if (pGlDeleteQueriesARB) + pGlDeleteQueriesARB(n, ids); + else if (pGlDeleteOcclusionQueriesNV) + pGlDeleteOcclusionQueriesNV(n, ids); +} + +inline GLboolean COpenGLExtensionHandler::extGlIsQuery(GLuint id) +{ + if (pGlIsQueryARB) + return pGlIsQueryARB(id); + else if (pGlIsOcclusionQueryNV) + return pGlIsOcclusionQueryNV(id); + return false; +} + +inline void COpenGLExtensionHandler::extGlBeginQuery(GLenum target, GLuint id) +{ + if (pGlBeginQueryARB) + pGlBeginQueryARB(target, id); + else if (pGlBeginOcclusionQueryNV) + pGlBeginOcclusionQueryNV(id); +} + +inline void COpenGLExtensionHandler::extGlEndQuery(GLenum target) +{ + if (pGlEndQueryARB) + pGlEndQueryARB(target); + else if (pGlEndOcclusionQueryNV) + pGlEndOcclusionQueryNV(); +} + +inline void COpenGLExtensionHandler::extGlGetQueryiv(GLenum target, GLenum pname, GLint *params) +{ + if (pGlGetQueryivARB) + pGlGetQueryivARB(target, pname, params); +} + +inline void COpenGLExtensionHandler::extGlGetQueryObjectiv(GLuint id, GLenum pname, GLint *params) +{ + if (pGlGetQueryObjectivARB) + pGlGetQueryObjectivARB(id, pname, params); + else if (pGlGetOcclusionQueryivNV) + pGlGetOcclusionQueryivNV(id, pname, params); +} + +inline void COpenGLExtensionHandler::extGlGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) +{ + if (pGlGetQueryObjectuivARB) + pGlGetQueryObjectuivARB(id, pname, params); + else if (pGlGetOcclusionQueryuivNV) + pGlGetOcclusionQueryuivNV(id, pname, params); +} + +inline void COpenGLExtensionHandler::irrGlBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) +{ + if (pGlBlendFuncSeparate) + pGlBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); + else if (pGlBlendFuncSeparateEXT) + pGlBlendFuncSeparateEXT(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); +} + +inline void COpenGLExtensionHandler::irrGlBlendEquation(GLenum mode) +{ + if (pGlBlendEquation) + pGlBlendEquation(mode); + else if (pGlBlendEquationEXT) + pGlBlendEquationEXT(mode); +} + +inline void COpenGLExtensionHandler::irrGlEnableIndexed(GLenum target, GLuint index) +{ + if (FeatureAvailable[IRR_EXT_draw_buffers2] && pGlEnableIndexedEXT) + pGlEnableIndexedEXT(target, index); +} + +inline void COpenGLExtensionHandler::irrGlDisableIndexed(GLenum target, GLuint index) +{ + if (FeatureAvailable[IRR_EXT_draw_buffers2] && pGlDisableIndexedEXT) + pGlDisableIndexedEXT(target, index); +} + +inline void COpenGLExtensionHandler::irrGlColorMaskIndexed(GLuint buf, GLboolean r, GLboolean g, GLboolean b, GLboolean a) +{ + if (FeatureAvailable[IRR_EXT_draw_buffers2] && pGlColorMaskIndexedEXT) + pGlColorMaskIndexedEXT(buf, r, g, b, a); +} + +inline void COpenGLExtensionHandler::irrGlBlendFuncIndexed(GLuint buf, GLenum src, GLenum dst) +{ + if (FeatureAvailable[IRR_ARB_draw_buffers_blend] && pGlBlendFunciARB) + pGlBlendFunciARB(buf, src, dst); + else if (FeatureAvailable[IRR_AMD_draw_buffers_blend] && pGlBlendFuncIndexedAMD) + pGlBlendFuncIndexedAMD(buf, src, dst); +} + +inline void COpenGLExtensionHandler::irrGlBlendFuncSeparateIndexed(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) +{ + if (FeatureAvailable[IRR_ARB_draw_buffers_blend] && pGlBlendFuncSeparateiARB) + pGlBlendFuncSeparateiARB(buf, srcRGB, dstRGB, srcAlpha, dstAlpha); + else if (FeatureAvailable[IRR_AMD_draw_buffers_blend] && pGlBlendFuncSeparateIndexedAMD) + pGlBlendFuncSeparateIndexedAMD(buf, srcRGB, dstRGB, srcAlpha, dstAlpha); +} + +inline void COpenGLExtensionHandler::irrGlBlendEquationIndexed(GLuint buf, GLenum mode) +{ + if (FeatureAvailable[IRR_ARB_draw_buffers_blend] && pGlBlendEquationiARB) + pGlBlendEquationiARB(buf, mode); + else if (FeatureAvailable[IRR_AMD_draw_buffers_blend] && pGlBlendEquationIndexedAMD) + pGlBlendEquationIndexedAMD(buf, mode); +} + +inline void COpenGLExtensionHandler::irrGlBlendEquationSeparateIndexed(GLuint buf, GLenum modeRGB, GLenum modeAlpha) +{ + if (FeatureAvailable[IRR_ARB_draw_buffers_blend] && pGlBlendEquationSeparateiARB) + pGlBlendEquationSeparateiARB(buf, modeRGB, modeAlpha); + else if (FeatureAvailable[IRR_AMD_draw_buffers_blend] && pGlBlendEquationSeparateIndexedAMD) + pGlBlendEquationSeparateIndexedAMD(buf, modeRGB, modeAlpha); +} + +inline void COpenGLExtensionHandler::extGlTextureSubImage2D(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels) +{ + if (Version >= 405 || FeatureAvailable[IRR_ARB_direct_state_access]) { + if (pGlTextureSubImage2D) + pGlTextureSubImage2D(texture, level, xoffset, yoffset, width, height, format, type, pixels); + } else if (FeatureAvailable[IRR_EXT_direct_state_access]) { + if (pGlTextureSubImage2DEXT) + pGlTextureSubImage2DEXT(texture, target, level, xoffset, yoffset, width, height, format, type, pixels); + } else { + GLint bound; + switch (target) { +#ifdef GL_VERSION_3_0 + case GL_TEXTURE_1D_ARRAY: + glGetIntegerv(GL_TEXTURE_BINDING_1D_ARRAY, &bound); + break; +#elif GL_EXT_texture_array + case GL_TEXTURE_1D_ARRAY_EXT: + glGetIntegerv(GL_TEXTURE_BINDING_1D_ARRAY_EXT, &bound); + break; +#endif + case GL_TEXTURE_2D: + glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound); + break; +#ifdef GL_VERSION_3_2 + case GL_TEXTURE_2D_MULTISAMPLE: + glGetIntegerv(GL_TEXTURE_BINDING_2D_MULTISAMPLE, &bound); + break; +#endif + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP, &bound); + break; +#ifdef GL_VERSION_3_1 + case GL_TEXTURE_RECTANGLE: + glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE, &bound); + break; +#elif defined(GL_ARB_texture_rectangle) + case GL_TEXTURE_RECTANGLE_ARB: + glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &bound); + break; +#endif + default: + return; + } + glBindTexture(target, texture); + glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + glBindTexture(target, bound); + } +} + +inline void COpenGLExtensionHandler::extGlTextureStorage2D(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) +{ + if (Version >= 405 || FeatureAvailable[IRR_ARB_direct_state_access]) { + if (pGlTextureStorage2D) + pGlTextureStorage2D(texture, levels, internalformat, width, height); + } else if (FeatureAvailable[IRR_EXT_direct_state_access]) { + if (pGlTextureStorage2DEXT) + pGlTextureStorage2DEXT(texture, target, levels, internalformat, width, height); + } + + else if (pGlTexStorage2D) { + GLint bound; + switch (target) { +#ifdef GL_VERSION_3_0 + case GL_TEXTURE_1D_ARRAY: + glGetIntegerv(GL_TEXTURE_BINDING_1D_ARRAY, &bound); + break; +#elif GL_EXT_texture_array + case GL_TEXTURE_1D_ARRAY_EXT: + glGetIntegerv(GL_TEXTURE_BINDING_1D_ARRAY_EXT, &bound); + break; +#endif + case GL_TEXTURE_2D: + glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound); + break; + case GL_TEXTURE_CUBE_MAP: + glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP, &bound); + break; +#ifdef GL_VERSION_3_1 + case GL_TEXTURE_RECTANGLE: + glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE, &bound); + break; +#elif defined(GL_ARB_texture_rectangle) + case GL_TEXTURE_RECTANGLE_ARB: + glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &bound); + break; +#endif + default: + return; + } + glBindTexture(target, texture); + pGlTexStorage2D(target, levels, internalformat, width, height); + glBindTexture(target, bound); + } +} + +inline void COpenGLExtensionHandler::extGlTextureStorage3D(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) +{ + if (Version >= 405 || FeatureAvailable[IRR_ARB_direct_state_access]) { + if (pGlTextureStorage3D) + pGlTextureStorage3D(texture, levels, internalformat, width, height, depth); + } else if (FeatureAvailable[IRR_EXT_direct_state_access]) { + if (pGlTextureStorage3DEXT) + pGlTextureStorage3DEXT(texture, target, levels, internalformat, width, height, depth); + } else if (pGlTexStorage3D) { + GLint bound; + switch (target) { +#ifdef GL_VERSION_3_0 + case GL_TEXTURE_2D_ARRAY: + glGetIntegerv(GL_TEXTURE_BINDING_2D_ARRAY, &bound); + break; +#elif GL_EXT_texture_array + case GL_TEXTURE_2D_ARRAY_EXT: + glGetIntegerv(GL_TEXTURE_BINDING_2D_ARRAY_EXT, &bound); + break; +#endif + case GL_TEXTURE_3D: + glGetIntegerv(GL_TEXTURE_BINDING_3D, &bound); + break; +#ifdef GL_VERSION_4_0 + case GL_TEXTURE_CUBE_MAP_ARRAY: + glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY, &bound); + break; +#elif defined(GL_ARB_texture_cube_map_array) + case GL_TEXTURE_CUBE_MAP_ARRAY_ARB: + glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB, &bound); + break; +#endif + default: + return; + } + glBindTexture(target, texture); + pGlTexStorage3D(target, levels, internalformat, width, height, depth); + glBindTexture(target, bound); + } +} + +inline void COpenGLExtensionHandler::extGlGetTextureImage(GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels) +{ + if (Version >= 405 || FeatureAvailable[IRR_ARB_direct_state_access]) { + if (pGlGetTextureImage) + pGlGetTextureImage(texture, level, format, type, bufSize, pixels); + } else if (FeatureAvailable[IRR_EXT_direct_state_access]) { + if (pGlGetTextureImageEXT) + pGlGetTextureImageEXT(texture, target, level, format, type, pixels); + } else { + GLint bound; + switch (target) { +#ifdef GL_VERSION_3_0 + case GL_TEXTURE_2D_ARRAY: + glGetIntegerv(GL_TEXTURE_BINDING_2D_ARRAY, &bound); + break; +#elif GL_EXT_texture_array + case GL_TEXTURE_2D_ARRAY_EXT: + glGetIntegerv(GL_TEXTURE_BINDING_2D_ARRAY_EXT, &bound); + break; +#endif + case GL_TEXTURE_3D: + glGetIntegerv(GL_TEXTURE_BINDING_3D, &bound); + break; +#ifdef GL_VERSION_4_0 + case GL_TEXTURE_CUBE_MAP_ARRAY: + glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY, &bound); + break; +#elif defined(GL_ARB_texture_cube_map_array) + case GL_TEXTURE_CUBE_MAP_ARRAY_ARB: + glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB, &bound); + break; +#endif + default: + return; + } + glBindTexture(target, texture); + glGetTexImage(target, level, format, type, pixels); + glBindTexture(target, bound); + } +} + +inline void COpenGLExtensionHandler::extGlNamedFramebufferTexture(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level) +{ + if (!needsDSAFramebufferHack) { + if (Version >= 405 || FeatureAvailable[IRR_ARB_direct_state_access]) { + pGlNamedFramebufferTexture(framebuffer, attachment, texture, level); + return; + } else if (FeatureAvailable[IRR_EXT_direct_state_access]) { + pGlNamedFramebufferTextureEXT(framebuffer, attachment, texture, level); + return; + } + } + + GLuint bound; + glGetIntegerv(GL_FRAMEBUFFER_BINDING, reinterpret_cast(&bound)); + + if (bound != framebuffer) + pGlBindFramebuffer(GL_FRAMEBUFFER, framebuffer); + pGlFramebufferTexture(GL_FRAMEBUFFER, attachment, texture, level); + if (bound != framebuffer) + pGlBindFramebuffer(GL_FRAMEBUFFER, bound); +} + +inline void COpenGLExtensionHandler::extGlTextureParameteri(GLuint texture, GLenum pname, GLint param) +{ + if (pGlTextureParameteri) + pGlTextureParameteri(texture, pname, param); +} + +inline void COpenGLExtensionHandler::extGlTextureParameterf(GLuint texture, GLenum pname, GLfloat param) +{ + if (pGlTextureParameterf) + pGlTextureParameterf(texture, pname, param); +} + +inline void COpenGLExtensionHandler::extGlTextureParameteriv(GLuint texture, GLenum pname, const GLint *params) +{ + if (pGlTextureParameteriv) + pGlTextureParameteriv(texture, pname, params); +} + +inline void COpenGLExtensionHandler::extGlTextureParameterfv(GLuint texture, GLenum pname, const GLfloat *params) +{ + if (pGlTextureParameterfv) + pGlTextureParameterfv(texture, pname, params); +} + +inline void COpenGLExtensionHandler::extGlCreateTextures(GLenum target, GLsizei n, GLuint *textures) +{ + if (Version >= 405) { + if (pGlCreateTextures) + pGlCreateTextures(target, n, textures); + else if (textures) + memset(textures, 0, n * sizeof(GLuint)); + } else { + glGenTextures(n, textures); + } +} + +inline void COpenGLExtensionHandler::extGlCreateFramebuffers(GLsizei n, GLuint *framebuffers) +{ + if (!needsDSAFramebufferHack) { + if (Version >= 405) { + pGlCreateFramebuffers(n, framebuffers); + return; + } + } + + pGlGenFramebuffers(n, framebuffers); +} + +inline void COpenGLExtensionHandler::extGlBindTextures(GLuint first, GLsizei count, const GLuint *textures, const GLenum *targets) +{ + const GLenum supportedTargets[] = {GL_TEXTURE_1D, GL_TEXTURE_2D // GL 1.x + , + GL_TEXTURE_3D // GL 2.x +#ifdef GL_VERSION_3_1 + , + GL_TEXTURE_RECTANGLE +#elif defined(GL_ARB_texture_rectangle) + , + GL_TEXTURE_RECTANGLE_ARB +#endif + , + GL_TEXTURE_CUBE_MAP +#ifdef GL_VERSION_3_0 + , + GL_TEXTURE_1D_ARRAY, GL_TEXTURE_2D_ARRAY // GL 3.x +#elif GL_EXT_texture_array + , + GL_TEXTURE_1D_ARRAY_EXT, GL_TEXTURE_2D_ARRAY_EXT +#endif +#ifdef GL_VERSION_3_1 + , + GL_TEXTURE_BUFFER +#elif defined(GL_ARB_texture_buffer_object) + , + GL_TEXTURE_BUFFER_ARB +#elif defined(GL_EXT_texture_buffer_object) + , + GL_TEXTURE_BUFFER_EXT +#endif +#ifdef GL_VERSION_4_0 + , + GL_TEXTURE_CUBE_MAP_ARRAY // GL 4.x +#elif defined(GL_ARB_texture_cube_map_array) + , + GL_TEXTURE_CUBE_MAP_ARRAY_ARB +#endif +#ifdef GL_VERSION_3_2 + , + GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_2D_MULTISAMPLE_ARRAY +#endif + }; + + if (Version >= 404 || FeatureAvailable[IRR_ARB_multi_bind]) { + if (pGlBindTextures) + pGlBindTextures(first, count, textures); + } else { + GLint activeTex = 0; + glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex); + + for (GLsizei i = 0; i < count; i++) { + GLuint texture = textures ? textures[i] : 0; + + GLuint unit = first + i; + irrGlActiveTexture(GL_TEXTURE0 + unit); + + if (texture) + glBindTexture(targets[i], texture); + else { + for (size_t j = 0; j < sizeof(supportedTargets) / sizeof(GLenum); j++) + glBindTexture(supportedTargets[j], 0); + } + } + + irrGlActiveTexture(activeTex); + } +} + +inline void COpenGLExtensionHandler::extGlGenerateTextureMipmap(GLuint texture, GLenum target) +{ + if (Version >= 405 || FeatureAvailable[IRR_ARB_direct_state_access]) { + if (pGlGenerateTextureMipmap) + pGlGenerateTextureMipmap(texture); + } else if (FeatureAvailable[IRR_EXT_direct_state_access]) { + if (pGlGenerateTextureMipmapEXT) + pGlGenerateTextureMipmapEXT(texture, target); + } else if (pGlGenerateMipmap) { + GLint bound; + switch (target) { + case GL_TEXTURE_1D: + glGetIntegerv(GL_TEXTURE_BINDING_1D, &bound); + break; +#ifdef GL_VERSION_3_0 + case GL_TEXTURE_1D_ARRAY: + glGetIntegerv(GL_TEXTURE_BINDING_1D_ARRAY, &bound); + break; +#elif GL_EXT_texture_array + case GL_TEXTURE_1D_ARRAY_EXT: + glGetIntegerv(GL_TEXTURE_BINDING_1D_ARRAY_EXT, &bound); + break; +#endif + case GL_TEXTURE_2D: + glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound); + break; +#ifdef GL_VERSION_3_0 + case GL_TEXTURE_2D_ARRAY: + glGetIntegerv(GL_TEXTURE_BINDING_2D_ARRAY, &bound); + break; +#elif GL_EXT_texture_array + case GL_TEXTURE_2D_ARRAY_EXT: + glGetIntegerv(GL_TEXTURE_BINDING_2D_ARRAY_EXT, &bound); + break; +#endif +#ifdef GL_VERSION_3_2 + case GL_TEXTURE_2D_MULTISAMPLE: + glGetIntegerv(GL_TEXTURE_BINDING_2D_MULTISAMPLE, &bound); + break; + case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: + glGetIntegerv(GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY, &bound); + break; +#endif + case GL_TEXTURE_3D: + glGetIntegerv(GL_TEXTURE_BINDING_3D, &bound); + break; +#ifdef GL_VERSION_3_1 + case GL_TEXTURE_BUFFER: + glGetIntegerv(GL_TEXTURE_BINDING_BUFFER, &bound); + break; +#elif defined(GL_ARB_texture_buffer_object) + case GL_TEXTURE_BUFFER_ARB: + glGetIntegerv(GL_TEXTURE_BINDING_BUFFER_ARB, &bound); + break; +#elif defined(GL_EXT_texture_buffer_object) + case GL_TEXTURE_BUFFER_EXT: + glGetIntegerv(GL_TEXTURE_BINDING_BUFFER_EXT, &bound); + break; +#endif + case GL_TEXTURE_CUBE_MAP: + glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP, &bound); + break; +#ifdef GL_VERSION_4_0 + case GL_TEXTURE_CUBE_MAP_ARRAY: + glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY, &bound); + break; +#elif defined(GL_ARB_texture_cube_map_array) + case GL_TEXTURE_CUBE_MAP_ARRAY_ARB: + glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB, &bound); + break; +#endif +#ifdef GL_VERSION_3_1 + case GL_TEXTURE_RECTANGLE: + glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE, &bound); + break; +#elif defined(GL_ARB_texture_rectangle) + case GL_TEXTURE_RECTANGLE_ARB: + glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &bound); + break; +#endif + default: + os::Printer::log("DevSH would like to ask you what are you doing!!??\n", ELL_ERROR); + return; + } + glBindTexture(target, texture); + pGlGenerateMipmap(target); + glBindTexture(target, bound); + } +} + +inline void COpenGLExtensionHandler::extGlSwapInterval(int interval) +{ + // we have wglext, so try to use that +#if defined(_IRR_WINDOWS_API_) && defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) +#ifdef WGL_EXT_swap_control + if (pWglSwapIntervalEXT) + pWglSwapIntervalEXT(interval); +#endif +#endif +#ifdef _IRR_COMPILE_WITH_X11_DEVICE_ +#if defined(GLX_MESA_swap_control) + if (pGlxSwapIntervalMESA) + pGlxSwapIntervalMESA(interval); +#elif defined(GLX_EXT_swap_control) + Display *dpy = glXGetCurrentDisplay(); + GLXDrawable drawable = glXGetCurrentDrawable(); + if (pGlxSwapIntervalEXT) + pGlxSwapIntervalEXT(dpy, drawable, interval); +#elif defined(GLX_SGI_swap_control) + // does not work with interval==0 + if (interval && pGlxSwapIntervalSGI) + pGlxSwapIntervalSGI(interval); +} +#endif +#endif +} + +} +} + +#endif diff --git a/irr/src/COpenGLMaterialRenderer.h b/irr/src/COpenGLMaterialRenderer.h new file mode 100644 index 000000000..b4706f537 --- /dev/null +++ b/irr/src/COpenGLMaterialRenderer.h @@ -0,0 +1,335 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#include "IMaterialRenderer.h" + +#include "COpenGLDriver.h" +#include "COpenGLCacheHandler.h" + +namespace irr +{ +namespace video +{ + +//! Solid material renderer +class COpenGLMaterialRenderer_SOLID : public IMaterialRenderer +{ +public: + COpenGLMaterialRenderer_SOLID(video::COpenGLDriver *d) : + Driver(d) {} + + virtual void OnSetMaterial(const SMaterial &material, const SMaterial &lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices *services) override + { + if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE) + Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE); + else + Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE); + + Driver->disableTextures(1); + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + } + +protected: + video::COpenGLDriver *Driver; +}; + +//! Generic Texture Blend +class COpenGLMaterialRenderer_ONETEXTURE_BLEND : public IMaterialRenderer +{ +public: + COpenGLMaterialRenderer_ONETEXTURE_BLEND(video::COpenGLDriver *d) : + Driver(d) {} + + virtual void OnSetMaterial(const SMaterial &material, const SMaterial &lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices *services) override + { + if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE) + Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE); + else + Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE); + + Driver->disableTextures(1); + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + // if (material.MaterialType != lastMaterial.MaterialType || + // material.MaterialTypeParam != lastMaterial.MaterialTypeParam || + // resetAllRenderstates) + { + E_BLEND_FACTOR srcRGBFact, dstRGBFact, srcAlphaFact, dstAlphaFact; + E_MODULATE_FUNC modulate; + u32 alphaSource; + unpack_textureBlendFuncSeparate(srcRGBFact, dstRGBFact, srcAlphaFact, dstAlphaFact, modulate, alphaSource, material.MaterialTypeParam); + + Driver->getCacheHandler()->setBlend(true); + + if (Driver->queryFeature(EVDF_BLEND_SEPARATE)) { + Driver->getCacheHandler()->setBlendFuncSeparate(Driver->getGLBlend(srcRGBFact), Driver->getGLBlend(dstRGBFact), + Driver->getGLBlend(srcAlphaFact), Driver->getGLBlend(dstAlphaFact)); + } else { + Driver->getCacheHandler()->setBlendFunc(Driver->getGLBlend(srcRGBFact), Driver->getGLBlend(dstRGBFact)); + } + + Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0_ARB); + +#ifdef GL_ARB_texture_env_combine + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB); + glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, (f32)modulate); +#else + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); + glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, (f32)modulate); +#endif + + if (textureBlendFunc_hasAlpha(srcRGBFact) || textureBlendFunc_hasAlpha(dstRGBFact) || + textureBlendFunc_hasAlpha(srcAlphaFact) || textureBlendFunc_hasAlpha(dstAlphaFact)) { + if (alphaSource == EAS_VERTEX_COLOR) { +#ifdef GL_ARB_texture_env_combine + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PRIMARY_COLOR_ARB); +#else + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT); +#endif + } else if (alphaSource == EAS_TEXTURE) { +#ifdef GL_ARB_texture_env_combine + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE); +#else + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); +#endif + } else { +#ifdef GL_ARB_texture_env_combine + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PRIMARY_COLOR_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, GL_TEXTURE); +#else + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_TEXTURE); +#endif + } + } + } + } + + void OnUnsetMaterial() override + { + Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0_ARB); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + +#ifdef GL_ARB_texture_env_combine + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1.f); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB); +#else + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE); + glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.f); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); +#endif + + Driver->getCacheHandler()->setBlend(false); + } + + //! Returns if the material is transparent. + /** Is not always transparent, but mostly. */ + bool isTransparent() const override + { + return true; + } + +protected: + video::COpenGLDriver *Driver; +}; + +//! Transparent vertex alpha material renderer +class COpenGLMaterialRenderer_TRANSPARENT_VERTEX_ALPHA : public IMaterialRenderer +{ +public: + COpenGLMaterialRenderer_TRANSPARENT_VERTEX_ALPHA(video::COpenGLDriver *d) : + Driver(d) {} + + virtual void OnSetMaterial(const SMaterial &material, const SMaterial &lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices *services) override + { + if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE) + Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE); + else + Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE); + + Driver->disableTextures(1); + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + Driver->getCacheHandler()->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + Driver->getCacheHandler()->setBlend(true); + + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) { + Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0_ARB); + +#ifdef GL_ARB_texture_env_combine + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PRIMARY_COLOR_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB); +#else + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); +#endif + } + } + + void OnUnsetMaterial() override + { + Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0_ARB); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); +#ifdef GL_ARB_texture_env_combine + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE); +#else + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); +#endif + + Driver->getCacheHandler()->setBlend(false); + } + + //! Returns if the material is transparent. + bool isTransparent() const override + { + return true; + } + +protected: + video::COpenGLDriver *Driver; +}; + +//! Transparent alpha channel material renderer +class COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL : public IMaterialRenderer +{ +public: + COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(video::COpenGLDriver *d) : + Driver(d) {} + + virtual void OnSetMaterial(const SMaterial &material, const SMaterial &lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices *services) override + { + if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE) + Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE); + else + Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE); + + Driver->disableTextures(1); + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + Driver->getCacheHandler()->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + Driver->getCacheHandler()->setBlend(true); + Driver->getCacheHandler()->setAlphaTest(true); + Driver->getCacheHandler()->setAlphaFunc(GL_GREATER, material.MaterialTypeParam); + + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates || material.MaterialTypeParam != lastMaterial.MaterialTypeParam) { + Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0_ARB); + +#ifdef GL_ARB_texture_env_combine + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE); +#else + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); +#endif + } + } + + void OnUnsetMaterial() override + { + Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0_ARB); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); +#ifdef GL_ARB_texture_env_combine + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE); +#else + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE); +#endif + Driver->getCacheHandler()->setAlphaTest(false); + Driver->getCacheHandler()->setBlend(false); + } + + //! Returns if the material is transparent. + bool isTransparent() const override + { + return true; + } + +protected: + video::COpenGLDriver *Driver; +}; + +//! Transparent alpha channel material renderer +class COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF : public IMaterialRenderer +{ +public: + COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(video::COpenGLDriver *d) : + Driver(d) {} + + virtual void OnSetMaterial(const SMaterial &material, const SMaterial &lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices *services) override + { + if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE) + Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE); + else + Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE); + + Driver->disableTextures(1); + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) { + Driver->getCacheHandler()->setAlphaTest(true); + Driver->getCacheHandler()->setAlphaFunc(GL_GREATER, 0.5f); + } + } + + void OnUnsetMaterial() override + { + Driver->getCacheHandler()->setAlphaTest(false); + } + + //! Returns if the material is transparent. + bool isTransparent() const override + { + return false; // this material is not really transparent because it does no blending. + } + +protected: + video::COpenGLDriver *Driver; +}; + +} // end namespace video +} // end namespace irr + +#endif diff --git a/irr/src/COpenGLSLMaterialRenderer.cpp b/irr/src/COpenGLSLMaterialRenderer.cpp new file mode 100644 index 000000000..556405d7b --- /dev/null +++ b/irr/src/COpenGLSLMaterialRenderer.cpp @@ -0,0 +1,683 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +// This file was originally written by William Finlayson. I (Nikolaus +// Gebhardt) did some minor modifications and changes to it and integrated it +// into Irrlicht. Thanks a lot to William for his work on this and that he gave +// me his permission to add it into Irrlicht using the zlib license. + +// After Irrlicht 0.12, Michael Zoech did some improvements to this renderer, I +// merged this into Irrlicht 0.14, thanks to him for his work. + +#include "COpenGLSLMaterialRenderer.h" + +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#include "IGPUProgrammingServices.h" +#include "IShaderConstantSetCallBack.h" +#include "IMaterialRendererServices.h" +#include "IVideoDriver.h" +#include "os.h" + +#include "COpenGLDriver.h" +#include "COpenGLCacheHandler.h" +#include "COpenGLMaterialRenderer.h" + +#include "COpenGLCoreFeature.h" + +namespace irr +{ +namespace video +{ + +//! Constructor +COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(video::COpenGLDriver *driver, + s32 &outMaterialTypeNr, const c8 *vertexShaderProgram, + const c8 *vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, + const c8 *pixelShaderProgram, + const c8 *pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, + const c8 *geometryShaderProgram, + const c8 *geometryShaderEntryPointName, + E_GEOMETRY_SHADER_TYPE gsCompileTarget, + scene::E_PRIMITIVE_TYPE inType, scene::E_PRIMITIVE_TYPE outType, + u32 verticesOut, + IShaderConstantSetCallBack *callback, + E_MATERIAL_TYPE baseMaterial, + s32 userData) : + Driver(driver), + CallBack(callback), Alpha(false), Blending(false), AlphaTest(false), Program(0), Program2(0), UserData(userData) +{ +#ifdef _DEBUG + setDebugName("COpenGLSLMaterialRenderer"); +#endif + + switch (baseMaterial) { + case EMT_TRANSPARENT_VERTEX_ALPHA: + case EMT_TRANSPARENT_ALPHA_CHANNEL: + Alpha = true; + break; + case EMT_ONETEXTURE_BLEND: + Blending = true; + break; + case EMT_TRANSPARENT_ALPHA_CHANNEL_REF: + AlphaTest = true; + break; + default: + break; + } + + if (CallBack) + CallBack->grab(); + + if (!Driver->queryFeature(EVDF_ARB_GLSL)) + return; + + init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram, geometryShaderProgram); +} + +//! constructor only for use by derived classes who want to +//! create a fall back material for example. +COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(COpenGLDriver *driver, + IShaderConstantSetCallBack *callback, + E_MATERIAL_TYPE baseMaterial, s32 userData) : + Driver(driver), + CallBack(callback), Alpha(false), Blending(false), AlphaTest(false), Program(0), Program2(0), UserData(userData) +{ + switch (baseMaterial) { + case EMT_TRANSPARENT_VERTEX_ALPHA: + case EMT_TRANSPARENT_ALPHA_CHANNEL: + Alpha = true; + break; + case EMT_ONETEXTURE_BLEND: + Blending = true; + break; + case EMT_TRANSPARENT_ALPHA_CHANNEL_REF: + AlphaTest = true; + break; + default: + break; + } + + if (CallBack) + CallBack->grab(); +} + +//! Destructor +COpenGLSLMaterialRenderer::~COpenGLSLMaterialRenderer() +{ + if (CallBack) + CallBack->drop(); + + if (Program) { + GLhandleARB shaders[8]; + GLint count; + Driver->extGlGetAttachedObjects(Program, 8, &count, shaders); + // avoid bugs in some drivers, which return larger numbers + // use int variable to avoid compiler problems with template + int mincount = core::min_((int)count, 8); + for (int i = 0; i < mincount; ++i) + Driver->extGlDeleteObject(shaders[i]); + Driver->extGlDeleteObject(Program); + Program = 0; + } + + if (Program2) { + GLuint shaders[8]; + GLint count; + Driver->extGlGetAttachedShaders(Program2, 8, &count, shaders); + // avoid bugs in some drivers, which return larger numbers + // use int variable to avoid compiler problems with template + int mincount = core::min_((int)count, 8); + for (int i = 0; i < mincount; ++i) + Driver->extGlDeleteShader(shaders[i]); + Driver->extGlDeleteProgram(Program2); + Program2 = 0; + } + + UniformInfo.clear(); +} + +void COpenGLSLMaterialRenderer::init(s32 &outMaterialTypeNr, + const c8 *vertexShaderProgram, + const c8 *pixelShaderProgram, + const c8 *geometryShaderProgram, + scene::E_PRIMITIVE_TYPE inType, scene::E_PRIMITIVE_TYPE outType, + u32 verticesOut) +{ + outMaterialTypeNr = -1; + + if (!createProgram()) + return; + +#if defined(GL_ARB_vertex_shader) && defined(GL_ARB_fragment_shader) + if (vertexShaderProgram) + if (!createShader(GL_VERTEX_SHADER_ARB, vertexShaderProgram)) + return; + + if (pixelShaderProgram) + if (!createShader(GL_FRAGMENT_SHADER_ARB, pixelShaderProgram)) + return; +#endif + +#if defined(GL_ARB_geometry_shader4) || defined(GL_EXT_geometry_shader4) || defined(GL_NV_geometry_program4) || defined(GL_NV_geometry_shader4) + if (geometryShaderProgram && Driver->queryFeature(EVDF_GEOMETRY_SHADER)) { + if (!createShader(GL_GEOMETRY_SHADER_EXT, geometryShaderProgram)) + return; +#if defined(GL_ARB_geometry_shader4) || defined(GL_EXT_geometry_shader4) || defined(GL_NV_geometry_shader4) + if (Program2) { // Geometry shaders are supported only in OGL2.x+ drivers. + Driver->extGlProgramParameteri(Program2, GL_GEOMETRY_INPUT_TYPE_EXT, Driver->primitiveTypeToGL(inType)); + Driver->extGlProgramParameteri(Program2, GL_GEOMETRY_OUTPUT_TYPE_EXT, Driver->primitiveTypeToGL(outType)); + if (verticesOut == 0) + Driver->extGlProgramParameteri(Program2, GL_GEOMETRY_VERTICES_OUT_EXT, Driver->MaxGeometryVerticesOut); + else + Driver->extGlProgramParameteri(Program2, GL_GEOMETRY_VERTICES_OUT_EXT, core::min_(verticesOut, Driver->MaxGeometryVerticesOut)); + } +#elif defined(GL_NV_geometry_program4) + if (verticesOut == 0) + Driver->extGlProgramVertexLimit(GL_GEOMETRY_PROGRAM_NV, Driver->MaxGeometryVerticesOut); + else + Driver->extGlProgramVertexLimit(GL_GEOMETRY_PROGRAM_NV, core::min_(verticesOut, Driver->MaxGeometryVerticesOut)); +#endif + } +#endif + + if (!linkProgram()) + return; + + // register myself as new material + outMaterialTypeNr = Driver->addMaterialRenderer(this); +} + +bool COpenGLSLMaterialRenderer::OnRender(IMaterialRendererServices *service, + E_VERTEX_TYPE vtxtype) +{ + // call callback to set shader constants + if (CallBack && (Program || Program2)) + CallBack->OnSetConstants(this, UserData); + + return true; +} + +void COpenGLSLMaterialRenderer::OnSetMaterial(const video::SMaterial &material, + const video::SMaterial &lastMaterial, + bool resetAllRenderstates, + video::IMaterialRendererServices *services) +{ + if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_ENABLE) + Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE_TO_DISABLE); + else + Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE); + + COpenGLCacheHandler *cacheHandler = Driver->getCacheHandler(); + + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) { + if (Program2) + Driver->irrGlUseProgram(Program2); + else if (Program) + Driver->extGlUseProgramObject(Program); + } + + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + if (Alpha) { + cacheHandler->setBlend(true); + cacheHandler->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + cacheHandler->setAlphaTest(true); + cacheHandler->setAlphaFunc(GL_GREATER, 0.f); + } else if (Blending) { + E_BLEND_FACTOR srcRGBFact, dstRGBFact, srcAlphaFact, dstAlphaFact; + E_MODULATE_FUNC modulate; + u32 alphaSource; + unpack_textureBlendFuncSeparate(srcRGBFact, dstRGBFact, srcAlphaFact, dstAlphaFact, modulate, alphaSource, material.MaterialTypeParam); + + if (Driver->queryFeature(EVDF_BLEND_SEPARATE)) { + cacheHandler->setBlendFuncSeparate(Driver->getGLBlend(srcRGBFact), Driver->getGLBlend(dstRGBFact), + Driver->getGLBlend(srcAlphaFact), Driver->getGLBlend(dstAlphaFact)); + } else { + cacheHandler->setBlendFunc(Driver->getGLBlend(srcRGBFact), Driver->getGLBlend(dstRGBFact)); + } + + cacheHandler->setBlend(true); + } else if (AlphaTest) { + cacheHandler->setAlphaTest(true); + cacheHandler->setAlphaFunc(GL_GREATER, 0.5f); + } + + if (CallBack) + CallBack->OnSetMaterial(material); +} + +void COpenGLSLMaterialRenderer::OnUnsetMaterial() +{ + if (Program) + Driver->extGlUseProgramObject(0); + if (Program2) + Driver->irrGlUseProgram(0); + + COpenGLCacheHandler *cacheHandler = Driver->getCacheHandler(); + if (Alpha || Blending) { + cacheHandler->setBlend(false); + } + if (Alpha || AlphaTest) { + cacheHandler->setAlphaTest(false); + } +} + +//! Returns if the material is transparent. +bool COpenGLSLMaterialRenderer::isTransparent() const +{ + return (Alpha || Blending); +} + +bool COpenGLSLMaterialRenderer::createProgram() +{ + if (Driver->Version >= 200) + Program2 = Driver->extGlCreateProgram(); + else + Program = Driver->extGlCreateProgramObject(); + return true; +} + +bool COpenGLSLMaterialRenderer::createShader(GLenum shaderType, const char *shader) +{ + if (Program2) { + GLuint shaderHandle = Driver->extGlCreateShader(shaderType); + Driver->extGlShaderSource(shaderHandle, 1, &shader, NULL); + Driver->extGlCompileShader(shaderHandle); + + GLint status = 0; + +#ifdef GL_VERSION_2_0 + Driver->extGlGetShaderiv(shaderHandle, GL_COMPILE_STATUS, &status); +#endif + + if (status != GL_TRUE) { + core::stringc typeInfo("shaderType: "); + typeInfo += core::stringc((unsigned long)shaderType); + os::Printer::log("GLSL (> 2.x) shader failed to compile", typeInfo.c_str(), ELL_ERROR); + // check error message and log it + GLint maxLength = 0; + GLint length; +#ifdef GL_VERSION_2_0 + Driver->extGlGetShaderiv(shaderHandle, GL_INFO_LOG_LENGTH, + &maxLength); +#endif + if (maxLength) { + GLchar *infoLog = new GLchar[maxLength]; + Driver->extGlGetShaderInfoLog(shaderHandle, maxLength, &length, infoLog); + os::Printer::log(reinterpret_cast(infoLog), ELL_ERROR); + delete[] infoLog; + } + + return false; + } + + Driver->extGlAttachShader(Program2, shaderHandle); + } else { + GLhandleARB shaderHandle = Driver->extGlCreateShaderObject(shaderType); + + Driver->extGlShaderSourceARB(shaderHandle, 1, &shader, NULL); + Driver->extGlCompileShaderARB(shaderHandle); + + GLint status = 0; + +#ifdef GL_ARB_shader_objects + Driver->extGlGetObjectParameteriv(shaderHandle, GL_OBJECT_COMPILE_STATUS_ARB, &status); +#endif + + if (!status) { + core::stringc typeInfo("shaderType: "); + typeInfo += core::stringc((unsigned long)shaderType); + os::Printer::log("GLSL shader failed to compile", typeInfo.c_str(), ELL_ERROR); + // check error message and log it + GLint maxLength = 0; + GLsizei length; +#ifdef GL_ARB_shader_objects + Driver->extGlGetObjectParameteriv(shaderHandle, + GL_OBJECT_INFO_LOG_LENGTH_ARB, &maxLength); +#endif + if (maxLength) { + GLcharARB *infoLog = new GLcharARB[maxLength]; + Driver->extGlGetInfoLog(shaderHandle, maxLength, &length, infoLog); + os::Printer::log(reinterpret_cast(infoLog), ELL_ERROR); + delete[] infoLog; + } + + return false; + } + + Driver->extGlAttachObject(Program, shaderHandle); + } + return true; +} + +bool COpenGLSLMaterialRenderer::linkProgram() +{ + if (Program2) { + Driver->extGlLinkProgram(Program2); + + GLint status = 0; + +#ifdef GL_VERSION_2_0 + Driver->extGlGetProgramiv(Program2, GL_LINK_STATUS, &status); +#endif + + if (!status) { + os::Printer::log("GLSL (> 2.x) shader program failed to link", ELL_ERROR); + // check error message and log it + GLint maxLength = 0; + GLsizei length; +#ifdef GL_VERSION_2_0 + Driver->extGlGetProgramiv(Program2, GL_INFO_LOG_LENGTH, &maxLength); +#endif + if (maxLength) { + GLchar *infoLog = new GLchar[maxLength]; + Driver->extGlGetProgramInfoLog(Program2, maxLength, &length, infoLog); + os::Printer::log(reinterpret_cast(infoLog), ELL_ERROR); + delete[] infoLog; + } + + return false; + } + + // get uniforms information + + GLint num = 0; +#ifdef GL_VERSION_2_0 + Driver->extGlGetProgramiv(Program2, GL_ACTIVE_UNIFORMS, &num); +#endif + + if (num == 0) { + // no uniforms + return true; + } + + GLint maxlen = 0; +#ifdef GL_VERSION_2_0 + Driver->extGlGetProgramiv(Program2, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxlen); +#endif + + if (maxlen == 0) { + os::Printer::log("GLSL (> 2.x): failed to retrieve uniform information", ELL_ERROR); + return false; + } + + // seems that some implementations use an extra null terminator + ++maxlen; + c8 *buf = new c8[maxlen]; + + UniformInfo.clear(); + UniformInfo.reallocate(num); + + for (GLint i = 0; i < num; ++i) { + SUniformInfo ui; + memset(buf, 0, maxlen); + + GLint size; + Driver->extGlGetActiveUniform(Program2, i, maxlen, 0, &size, &ui.type, reinterpret_cast(buf)); + ui.name = buf; + ui.location = Driver->extGlGetUniformLocation(Program2, buf); + + UniformInfo.push_back(ui); + } + + delete[] buf; + } else { + Driver->extGlLinkProgramARB(Program); + + GLint status = 0; + +#ifdef GL_ARB_shader_objects + Driver->extGlGetObjectParameteriv(Program, GL_OBJECT_LINK_STATUS_ARB, &status); +#endif + + if (!status) { + os::Printer::log("GLSL shader program failed to link", ELL_ERROR); + // check error message and log it + GLint maxLength = 0; + GLsizei length; +#ifdef GL_ARB_shader_objects + Driver->extGlGetObjectParameteriv(Program, + GL_OBJECT_INFO_LOG_LENGTH_ARB, &maxLength); +#endif + if (maxLength) { + GLcharARB *infoLog = new GLcharARB[maxLength]; + Driver->extGlGetInfoLog(Program, maxLength, &length, infoLog); + os::Printer::log(reinterpret_cast(infoLog), ELL_ERROR); + delete[] infoLog; + } + + return false; + } + + // get uniforms information + + GLint num = 0; +#ifdef GL_ARB_shader_objects + Driver->extGlGetObjectParameteriv(Program, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &num); +#endif + + if (num == 0) { + // no uniforms + return true; + } + + GLint maxlen = 0; +#ifdef GL_ARB_shader_objects + Driver->extGlGetObjectParameteriv(Program, GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB, &maxlen); +#endif + + if (maxlen == 0) { + os::Printer::log("GLSL: failed to retrieve uniform information", ELL_ERROR); + return false; + } + + // seems that some implementations use an extra null terminator + ++maxlen; + c8 *buf = new c8[maxlen]; + + UniformInfo.clear(); + UniformInfo.reallocate(num); + + for (int i = 0; i < num; ++i) { + SUniformInfo ui; + memset(buf, 0, maxlen); + + GLint size; + Driver->extGlGetActiveUniformARB(Program, i, maxlen, 0, &size, &ui.type, reinterpret_cast(buf)); + ui.name = buf; + ui.location = Driver->extGlGetUniformLocationARB(Program, buf); + + UniformInfo.push_back(ui); + } + + delete[] buf; + } + + return true; +} + +void COpenGLSLMaterialRenderer::setBasicRenderStates(const SMaterial &material, + const SMaterial &lastMaterial, + bool resetAllRenderstates) +{ + // forward + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); +} + +s32 COpenGLSLMaterialRenderer::getVertexShaderConstantID(const c8 *name) +{ + return getPixelShaderConstantID(name); +} + +s32 COpenGLSLMaterialRenderer::getPixelShaderConstantID(const c8 *name) +{ + for (u32 i = 0; i < UniformInfo.size(); ++i) { + if (UniformInfo[i].name == name) + return i; + } + + return -1; +} + +bool COpenGLSLMaterialRenderer::setVertexShaderConstant(s32 index, const f32 *floats, int count) +{ + return setPixelShaderConstant(index, floats, count); +} + +bool COpenGLSLMaterialRenderer::setVertexShaderConstant(s32 index, const s32 *ints, int count) +{ + return setPixelShaderConstant(index, ints, count); +} + +bool COpenGLSLMaterialRenderer::setVertexShaderConstant(s32 index, const u32 *ints, int count) +{ + return setPixelShaderConstant(index, ints, count); +} + +bool COpenGLSLMaterialRenderer::setPixelShaderConstant(s32 index, const f32 *floats, int count) +{ + if (index < 0 || UniformInfo[index].location < 0) + return false; + + bool status = true; + + switch (UniformInfo[index].type) { + case GL_FLOAT: + Driver->extGlUniform1fv(UniformInfo[index].location, count, floats); + break; + case GL_FLOAT_VEC2: + Driver->extGlUniform2fv(UniformInfo[index].location, count / 2, floats); + break; + case GL_FLOAT_VEC3: + Driver->extGlUniform3fv(UniformInfo[index].location, count / 3, floats); + break; + case GL_FLOAT_VEC4: + Driver->extGlUniform4fv(UniformInfo[index].location, count / 4, floats); + break; + case GL_FLOAT_MAT2: + Driver->extGlUniformMatrix2fv(UniformInfo[index].location, count / 4, false, floats); + break; + case GL_FLOAT_MAT2x3: + Driver->extGlUniformMatrix2x3fv(UniformInfo[index].location, count / 6, false, floats); + break; + case GL_FLOAT_MAT2x4: + Driver->extGlUniformMatrix2x4fv(UniformInfo[index].location, count / 8, false, floats); + break; + case GL_FLOAT_MAT3x2: + Driver->extGlUniformMatrix3x2fv(UniformInfo[index].location, count / 6, false, floats); + break; + case GL_FLOAT_MAT3: + Driver->extGlUniformMatrix3fv(UniformInfo[index].location, count / 9, false, floats); + break; + case GL_FLOAT_MAT3x4: + Driver->extGlUniformMatrix3x4fv(UniformInfo[index].location, count / 12, false, floats); + break; + case GL_FLOAT_MAT4x2: + Driver->extGlUniformMatrix4x2fv(UniformInfo[index].location, count / 8, false, floats); + break; + case GL_FLOAT_MAT4x3: + Driver->extGlUniformMatrix4x3fv(UniformInfo[index].location, count / 12, false, floats); + break; + case GL_FLOAT_MAT4: + Driver->extGlUniformMatrix4fv(UniformInfo[index].location, count / 16, false, floats); + break; + case GL_SAMPLER_1D: + case GL_SAMPLER_2D: + case GL_SAMPLER_3D: + case GL_SAMPLER_CUBE: + case GL_SAMPLER_1D_SHADOW: + case GL_SAMPLER_2D_SHADOW: { + if (floats) { + const GLint id = static_cast(*floats); + Driver->extGlUniform1iv(UniformInfo[index].location, 1, &id); + } else + status = false; + } break; + default: + status = false; + break; + } + return status; +} + +bool COpenGLSLMaterialRenderer::setPixelShaderConstant(s32 index, const s32 *ints, int count) +{ + if (index < 0 || UniformInfo[index].location < 0) + return false; + + bool status = true; + + switch (UniformInfo[index].type) { + case GL_INT: + case GL_BOOL: + Driver->extGlUniform1iv(UniformInfo[index].location, count, reinterpret_cast(ints)); + break; + case GL_INT_VEC2: + case GL_BOOL_VEC2: + Driver->extGlUniform2iv(UniformInfo[index].location, count / 2, reinterpret_cast(ints)); + break; + case GL_INT_VEC3: + case GL_BOOL_VEC3: + Driver->extGlUniform3iv(UniformInfo[index].location, count / 3, reinterpret_cast(ints)); + break; + case GL_INT_VEC4: + case GL_BOOL_VEC4: + Driver->extGlUniform4iv(UniformInfo[index].location, count / 4, reinterpret_cast(ints)); + break; + case GL_SAMPLER_1D: + case GL_SAMPLER_2D: + case GL_SAMPLER_3D: + case GL_SAMPLER_CUBE: + case GL_SAMPLER_1D_SHADOW: + case GL_SAMPLER_2D_SHADOW: + Driver->extGlUniform1iv(UniformInfo[index].location, 1, reinterpret_cast(ints)); + break; + default: + status = false; + break; + } + return status; +} + +bool COpenGLSLMaterialRenderer::setPixelShaderConstant(s32 index, const u32 *ints, int count) +{ + if (index < 0 || UniformInfo[index].location < 0) + return false; + + bool status = true; + + switch (UniformInfo[index].type) { + case GL_UNSIGNED_INT: + Driver->extGlUniform1uiv(UniformInfo[index].location, count, reinterpret_cast(ints)); + break; +#if defined(GL_VERSION_3_0) + case GL_UNSIGNED_INT_VEC2: + Driver->extGlUniform2uiv(UniformInfo[index].location, count / 2, reinterpret_cast(ints)); + break; + case GL_UNSIGNED_INT_VEC3: + Driver->extGlUniform3uiv(UniformInfo[index].location, count / 3, reinterpret_cast(ints)); + break; + case GL_UNSIGNED_INT_VEC4: + Driver->extGlUniform4uiv(UniformInfo[index].location, count / 4, reinterpret_cast(ints)); + break; +#endif + default: + status = false; + break; + } + return status; +} + +IVideoDriver *COpenGLSLMaterialRenderer::getVideoDriver() +{ + return Driver; +} + +} // end namespace video +} // end namespace irr + +#endif diff --git a/irr/src/COpenGLSLMaterialRenderer.h b/irr/src/COpenGLSLMaterialRenderer.h new file mode 100644 index 000000000..2f4a485d2 --- /dev/null +++ b/irr/src/COpenGLSLMaterialRenderer.h @@ -0,0 +1,125 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +#include "EMaterialTypes.h" +#include "IMaterialRenderer.h" +#include "IMaterialRendererServices.h" +#include "IGPUProgrammingServices.h" +#include "irrArray.h" +#include "irrString.h" + +#include "COpenGLCommon.h" + +namespace irr +{ +namespace video +{ + +class COpenGLDriver; +class IShaderConstantSetCallBack; + +//! Class for using GLSL shaders with OpenGL +//! Please note: This renderer implements its own IMaterialRendererServices +class COpenGLSLMaterialRenderer : public IMaterialRenderer, public IMaterialRendererServices +{ +public: + //! Constructor + COpenGLSLMaterialRenderer( + COpenGLDriver *driver, + s32 &outMaterialTypeNr, + const c8 *vertexShaderProgram = 0, + const c8 *vertexShaderEntryPointName = 0, + E_VERTEX_SHADER_TYPE vsCompileTarget = video::EVST_VS_1_1, + const c8 *pixelShaderProgram = 0, + const c8 *pixelShaderEntryPointName = 0, + E_PIXEL_SHADER_TYPE psCompileTarget = video::EPST_PS_1_1, + const c8 *geometryShaderProgram = 0, + const c8 *geometryShaderEntryPointName = "main", + E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0, + scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES, + scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP, + u32 verticesOut = 0, + IShaderConstantSetCallBack *callback = 0, + E_MATERIAL_TYPE baseMaterial = EMT_SOLID, + s32 userData = 0); + + //! Destructor + virtual ~COpenGLSLMaterialRenderer(); + + virtual void OnSetMaterial(const SMaterial &material, const SMaterial &lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices *services) override; + + bool OnRender(IMaterialRendererServices *service, E_VERTEX_TYPE vtxtype) override; + + void OnUnsetMaterial() override; + + //! Returns if the material is transparent. + bool isTransparent() const override; + + //! Access the callback provided by the users when creating shader materials + IShaderConstantSetCallBack *getShaderConstantSetCallBack() const override + { + return CallBack; + } + + // implementations for the render services + void setBasicRenderStates(const SMaterial &material, const SMaterial &lastMaterial, bool resetAllRenderstates) override; + s32 getVertexShaderConstantID(const c8 *name) override; + s32 getPixelShaderConstantID(const c8 *name) override; + bool setVertexShaderConstant(s32 index, const f32 *floats, int count) override; + bool setVertexShaderConstant(s32 index, const s32 *ints, int count) override; + bool setVertexShaderConstant(s32 index, const u32 *ints, int count) override; + bool setPixelShaderConstant(s32 index, const f32 *floats, int count) override; + bool setPixelShaderConstant(s32 index, const s32 *ints, int count) override; + bool setPixelShaderConstant(s32 index, const u32 *ints, int count) override; + IVideoDriver *getVideoDriver() override; + +protected: + //! constructor only for use by derived classes who want to + //! create a fall back material for example. + COpenGLSLMaterialRenderer(COpenGLDriver *driver, + IShaderConstantSetCallBack *callback, + E_MATERIAL_TYPE baseMaterial, + s32 userData = 0); + + void init(s32 &outMaterialTypeNr, + const c8 *vertexShaderProgram, + const c8 *pixelShaderProgram, + const c8 *geometryShaderProgram, + scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES, + scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP, + u32 verticesOut = 0); + + bool createProgram(); + bool createShader(GLenum shaderType, const char *shader); + bool linkProgram(); + + COpenGLDriver *Driver; + IShaderConstantSetCallBack *CallBack; + + bool Alpha; + bool Blending; + bool AlphaTest; + + struct SUniformInfo + { + core::stringc name; + GLenum type; + GLint location; + }; + + GLhandleARB Program; + GLuint Program2; + core::array UniformInfo; + s32 UserData; +}; + +} // end namespace video +} // end namespace irr + +#endif // compile with OpenGL diff --git a/irr/src/CReadFile.cpp b/irr/src/CReadFile.cpp new file mode 100644 index 000000000..6c6e49d55 --- /dev/null +++ b/irr/src/CReadFile.cpp @@ -0,0 +1,96 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CReadFile.h" + +namespace irr +{ +namespace io +{ + +CReadFile::CReadFile(const io::path &fileName) : + File(0), FileSize(0), Filename(fileName) +{ +#ifdef _DEBUG + setDebugName("CReadFile"); +#endif + + openFile(); +} + +CReadFile::~CReadFile() +{ + if (File) + fclose(File); +} + +//! returns how much was read +size_t CReadFile::read(void *buffer, size_t sizeToRead) +{ + if (!isOpen()) + return 0; + + return fread(buffer, 1, sizeToRead, File); +} + +//! changes position in file, returns true if successful +//! if relativeMovement==true, the pos is changed relative to current pos, +//! otherwise from begin of file +bool CReadFile::seek(long finalPos, bool relativeMovement) +{ + if (!isOpen()) + return false; + + return fseek(File, finalPos, relativeMovement ? SEEK_CUR : SEEK_SET) == 0; +} + +//! returns size of file +long CReadFile::getSize() const +{ + return FileSize; +} + +//! returns where in the file we are. +long CReadFile::getPos() const +{ + return ftell(File); +} + +//! opens the file +void CReadFile::openFile() +{ + if (Filename.size() == 0) { // bugfix posted by rt + File = 0; + return; + } + + File = fopen(Filename.c_str(), "rb"); + + if (File) { + // get FileSize + + fseek(File, 0, SEEK_END); + FileSize = getPos(); + fseek(File, 0, SEEK_SET); + } +} + +//! returns name of file +const io::path &CReadFile::getFileName() const +{ + return Filename; +} + +IReadFile *CReadFile::createReadFile(const io::path &fileName) +{ + CReadFile *file = new CReadFile(fileName); + if (file->isOpen()) + return file; + + file->drop(); + return 0; +} + +} // end namespace io +} // end namespace irr diff --git a/irr/src/CReadFile.h b/irr/src/CReadFile.h new file mode 100644 index 000000000..14f674772 --- /dev/null +++ b/irr/src/CReadFile.h @@ -0,0 +1,67 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include +#include "IReadFile.h" +#include "irrString.h" + +namespace irr +{ + +namespace io +{ + +/*! + Class for reading a real file from disk. +*/ +class CReadFile : public IReadFile +{ +public: + CReadFile(const io::path &fileName); + + virtual ~CReadFile(); + + //! returns how much was read + size_t read(void *buffer, size_t sizeToRead) override; + + //! changes position in file, returns true if successful + bool seek(long finalPos, bool relativeMovement = false) override; + + //! returns size of file + long getSize() const override; + + //! returns if file is open + bool isOpen() const + { + return File != 0; + } + + //! returns where in the file we are. + long getPos() const override; + + //! returns name of file + const io::path &getFileName() const override; + + //! Get the type of the class implementing this interface + EREAD_FILE_TYPE getType() const override + { + return ERFT_READ_FILE; + } + + //! create read file on disk. + static IReadFile *createReadFile(const io::path &fileName); + +private: + //! opens the file + void openFile(); + + FILE *File; + long FileSize; + io::path Filename; +}; + +} // end namespace io +} // end namespace irr diff --git a/irr/src/CSDLManager.cpp b/irr/src/CSDLManager.cpp new file mode 100644 index 000000000..c2b38e478 --- /dev/null +++ b/irr/src/CSDLManager.cpp @@ -0,0 +1,55 @@ +// Copyright (C) 2022 sfan5 +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#include "CSDLManager.h" + +#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) + +#include "CIrrDeviceSDL.h" +#include "COpenGLCommon.h" + +namespace irr +{ +namespace video +{ + +CSDLManager::CSDLManager(CIrrDeviceSDL *device) : + IContextManager(), SDLDevice(device) +{ +#ifdef _DEBUG + setDebugName("CSDLManager"); +#endif +} + +bool CSDLManager::initialize(const SIrrlichtCreationParameters ¶ms, const SExposedVideoData &data) +{ + Data = data; + return true; +} + +const SExposedVideoData &CSDLManager::getContext() const +{ + return Data; +} + +bool CSDLManager::activateContext(const SExposedVideoData &videoData, bool restorePrimaryOnZero) +{ + return true; +} + +void *CSDLManager::getProcAddress(const std::string &procName) +{ + return SDL_GL_GetProcAddress(procName.c_str()); +} + +bool CSDLManager::swapBuffers() +{ + SDLDevice->SwapWindow(); + return true; +} + +} +} + +#endif diff --git a/irr/src/CSDLManager.h b/irr/src/CSDLManager.h new file mode 100644 index 000000000..22efeb1ee --- /dev/null +++ b/irr/src/CSDLManager.h @@ -0,0 +1,49 @@ +// Copyright (C) 2022 sfan5 +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#pragma once + +#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) + +#include "IContextManager.h" + +namespace irr +{ +class CIrrDeviceSDL; + +namespace video +{ + +// Manager for SDL with OpenGL +class CSDLManager : public IContextManager +{ +public: + CSDLManager(CIrrDeviceSDL *device); + + virtual ~CSDLManager() {} + + bool initialize(const SIrrlichtCreationParameters ¶ms, const SExposedVideoData &data) override; + + void terminate() override{}; + bool generateSurface() override { return true; }; + void destroySurface() override{}; + bool generateContext() override { return true; }; + void destroyContext() override{}; + + const SExposedVideoData &getContext() const override; + + bool activateContext(const SExposedVideoData &videoData, bool restorePrimaryOnZero = false) override; + + void *getProcAddress(const std::string &procName) override; + + bool swapBuffers() override; + +private: + SExposedVideoData Data; + CIrrDeviceSDL *SDLDevice; +}; +} +} + +#endif diff --git a/irr/src/CSceneCollisionManager.cpp b/irr/src/CSceneCollisionManager.cpp new file mode 100644 index 000000000..692f3c44f --- /dev/null +++ b/irr/src/CSceneCollisionManager.cpp @@ -0,0 +1,74 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CSceneCollisionManager.h" +#include "ICameraSceneNode.h" +#include "SViewFrustum.h" + +#include "os.h" +#include "irrMath.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CSceneCollisionManager::CSceneCollisionManager(ISceneManager *smanager, video::IVideoDriver *driver) : + SceneManager(smanager), Driver(driver) +{ +#ifdef _DEBUG + setDebugName("CSceneCollisionManager"); +#endif + + if (Driver) + Driver->grab(); +} + +//! destructor +CSceneCollisionManager::~CSceneCollisionManager() +{ + if (Driver) + Driver->drop(); +} + +//! Returns a 3d ray which would go through the 2d screen coordinates. +core::line3d CSceneCollisionManager::getRayFromScreenCoordinates( + const core::position2d &pos, const ICameraSceneNode *camera) +{ + core::line3d ln(0, 0, 0, 0, 0, 0); + + if (!SceneManager) + return ln; + + if (!camera) + camera = SceneManager->getActiveCamera(); + + if (!camera) + return ln; + + const scene::SViewFrustum *f = camera->getViewFrustum(); + + core::vector3df farLeftUp = f->getFarLeftUp(); + core::vector3df lefttoright = f->getFarRightUp() - farLeftUp; + core::vector3df uptodown = f->getFarLeftDown() - farLeftUp; + + const core::rect &viewPort = Driver->getViewPort(); + core::dimension2d screenSize(viewPort.getWidth(), viewPort.getHeight()); + + f32 dx = pos.X / (f32)screenSize.Width; + f32 dy = pos.Y / (f32)screenSize.Height; + + if (camera->isOrthogonal()) + ln.start = f->cameraPosition + (lefttoright * (dx - 0.5f)) + (uptodown * (dy - 0.5f)); + else + ln.start = f->cameraPosition; + + ln.end = farLeftUp + (lefttoright * dx) + (uptodown * dy); + + return ln; +} + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CSceneCollisionManager.h b/irr/src/CSceneCollisionManager.h new file mode 100644 index 000000000..d3dc2ef70 --- /dev/null +++ b/irr/src/CSceneCollisionManager.h @@ -0,0 +1,35 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "ISceneCollisionManager.h" +#include "ISceneManager.h" +#include "IVideoDriver.h" + +namespace irr +{ +namespace scene +{ + +class CSceneCollisionManager : public ISceneCollisionManager +{ +public: + //! constructor + CSceneCollisionManager(ISceneManager *smanager, video::IVideoDriver *driver); + + //! destructor + virtual ~CSceneCollisionManager(); + + //! Returns a 3d ray which would go through the 2d screen coordinates. + virtual core::line3d getRayFromScreenCoordinates( + const core::position2d &pos, const ICameraSceneNode *camera = 0) override; + +private: + ISceneManager *SceneManager; + video::IVideoDriver *Driver; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CSceneManager.cpp b/irr/src/CSceneManager.cpp new file mode 100644 index 000000000..b20f6010a --- /dev/null +++ b/irr/src/CSceneManager.cpp @@ -0,0 +1,809 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CSceneManager.h" +#include "IVideoDriver.h" +#include "IFileSystem.h" +#include "SAnimatedMesh.h" +#include "CMeshCache.h" +#include "IGUIEnvironment.h" +#include "IMaterialRenderer.h" +#include "IReadFile.h" +#include "IWriteFile.h" + +#include "os.h" + +#include "CSkinnedMesh.h" +#include "CXMeshFileLoader.h" +#include "COBJMeshFileLoader.h" +#include "CB3DMeshFileLoader.h" +#include "CBillboardSceneNode.h" +#include "CAnimatedMeshSceneNode.h" +#include "CCameraSceneNode.h" +#include "CMeshSceneNode.h" +#include "CDummyTransformationSceneNode.h" +#include "CEmptySceneNode.h" + +#include "CSceneCollisionManager.h" + +namespace irr +{ +namespace scene +{ + +//! constructor +CSceneManager::CSceneManager(video::IVideoDriver *driver, + gui::ICursorControl *cursorControl, IMeshCache *cache) : + ISceneNode(0, 0), + Driver(driver), + CursorControl(cursorControl), + ActiveCamera(0), ShadowColor(150, 0, 0, 0), AmbientLight(0, 0, 0, 0), Parameters(0), + MeshCache(cache), CurrentRenderPass(ESNRP_NONE) +{ +#ifdef _DEBUG + ISceneManager::setDebugName("CSceneManager ISceneManager"); + ISceneNode::setDebugName("CSceneManager ISceneNode"); +#endif + + // root node's scene manager + SceneManager = this; + + if (Driver) + Driver->grab(); + + if (CursorControl) + CursorControl->grab(); + + // create mesh cache if not there already + if (!MeshCache) + MeshCache = new CMeshCache(); + else + MeshCache->grab(); + + // set scene parameters + Parameters = new io::CAttributes(); + + // create collision manager + CollisionManager = new CSceneCollisionManager(this, Driver); + + // add file format loaders. add the least commonly used ones first, + // as these are checked last + + // TODO: now that we have multiple scene managers, these should be + // shallow copies from the previous manager if there is one. + + MeshLoaderList.push_back(new CXMeshFileLoader(this)); + MeshLoaderList.push_back(new COBJMeshFileLoader(this)); + MeshLoaderList.push_back(new CB3DMeshFileLoader(this)); +} + +//! destructor +CSceneManager::~CSceneManager() +{ + clearDeletionList(); + + //! force to remove hardwareTextures from the driver + //! because Scenes may hold internally data bounded to sceneNodes + //! which may be destroyed twice + if (Driver) + Driver->removeAllHardwareBuffers(); + + if (CursorControl) + CursorControl->drop(); + + if (CollisionManager) + CollisionManager->drop(); + + u32 i; + for (i = 0; i < MeshLoaderList.size(); ++i) + MeshLoaderList[i]->drop(); + + if (ActiveCamera) + ActiveCamera->drop(); + ActiveCamera = 0; + + if (MeshCache) + MeshCache->drop(); + + if (Parameters) + Parameters->drop(); + + // remove all nodes before dropping the driver + // as render targets may be destroyed twice + + removeAll(); + + if (Driver) + Driver->drop(); +} + +//! gets an animatable mesh. loads it if needed. returned pointer must not be dropped. +IAnimatedMesh *CSceneManager::getMesh(io::IReadFile *file) +{ + if (!file) + return 0; + + io::path name = file->getFileName(); + IAnimatedMesh *msh = MeshCache->getMeshByName(name); + if (msh) + return msh; + + msh = getUncachedMesh(file, name, name); + + return msh; +} + +// load and create a mesh which we know already isn't in the cache and put it in there +IAnimatedMesh *CSceneManager::getUncachedMesh(io::IReadFile *file, const io::path &filename, const io::path &cachename) +{ + IAnimatedMesh *msh = 0; + + // iterate the list in reverse order so user-added loaders can override the built-in ones + s32 count = MeshLoaderList.size(); + for (s32 i = count - 1; i >= 0; --i) { + if (MeshLoaderList[i]->isALoadableFileExtension(filename)) { + // reset file to avoid side effects of previous calls to createMesh + file->seek(0); + msh = MeshLoaderList[i]->createMesh(file); + if (msh) { + MeshCache->addMesh(cachename, msh); + msh->drop(); + break; + } + } + } + + if (!msh) + os::Printer::log("Could not load mesh, file format seems to be unsupported", filename, ELL_ERROR); + else + os::Printer::log("Loaded mesh", filename, ELL_DEBUG); + + return msh; +} + +//! returns the video driver +video::IVideoDriver *CSceneManager::getVideoDriver() +{ + return Driver; +} + +//! adds a scene node for rendering a static mesh +//! the returned pointer must not be dropped. +IMeshSceneNode *CSceneManager::addMeshSceneNode(IMesh *mesh, ISceneNode *parent, s32 id, + const core::vector3df &position, const core::vector3df &rotation, + const core::vector3df &scale, bool alsoAddIfMeshPointerZero) +{ + if (!alsoAddIfMeshPointerZero && !mesh) + return 0; + + if (!parent) + parent = this; + + IMeshSceneNode *node = new CMeshSceneNode(mesh, parent, this, id, position, rotation, scale); + node->drop(); + + return node; +} + +//! adds a scene node for rendering an animated mesh model +IAnimatedMeshSceneNode *CSceneManager::addAnimatedMeshSceneNode(IAnimatedMesh *mesh, ISceneNode *parent, s32 id, + const core::vector3df &position, const core::vector3df &rotation, + const core::vector3df &scale, bool alsoAddIfMeshPointerZero) +{ + if (!alsoAddIfMeshPointerZero && !mesh) + return 0; + + if (!parent) + parent = this; + + IAnimatedMeshSceneNode *node = + new CAnimatedMeshSceneNode(mesh, parent, this, id, position, rotation, scale); + node->drop(); + + return node; +} + +//! Adds a camera scene node to the tree and sets it as active camera. +//! \param position: Position of the space relative to its parent where the camera will be placed. +//! \param lookat: Position where the camera will look at. Also known as target. +//! \param parent: Parent scene node of the camera. Can be null. If the parent moves, +//! the camera will move too. +//! \return Returns pointer to interface to camera +ICameraSceneNode *CSceneManager::addCameraSceneNode(ISceneNode *parent, + const core::vector3df &position, const core::vector3df &lookat, s32 id, + bool makeActive) +{ + if (!parent) + parent = this; + + ICameraSceneNode *node = new CCameraSceneNode(parent, this, id, position, lookat); + + if (makeActive) + setActiveCamera(node); + node->drop(); + + return node; +} + +//! Adds a billboard scene node to the scene. A billboard is like a 3d sprite: A 2d element, +//! which always looks to the camera. It is usually used for things like explosions, fire, +//! lensflares and things like that. +IBillboardSceneNode *CSceneManager::addBillboardSceneNode(ISceneNode *parent, + const core::dimension2d &size, const core::vector3df &position, s32 id, + video::SColor colorTop, video::SColor colorBottom) +{ + if (!parent) + parent = this; + + IBillboardSceneNode *node = new CBillboardSceneNode(parent, this, id, position, size, + colorTop, colorBottom); + node->drop(); + + return node; +} + +//! Adds an empty scene node. +ISceneNode *CSceneManager::addEmptySceneNode(ISceneNode *parent, s32 id) +{ + if (!parent) + parent = this; + + ISceneNode *node = new CEmptySceneNode(parent, this, id); + node->drop(); + + return node; +} + +//! Adds a dummy transformation scene node to the scene graph. +IDummyTransformationSceneNode *CSceneManager::addDummyTransformationSceneNode( + ISceneNode *parent, s32 id) +{ + if (!parent) + parent = this; + + IDummyTransformationSceneNode *node = new CDummyTransformationSceneNode( + parent, this, id); + node->drop(); + + return node; +} + +//! Returns the root scene node. This is the scene node which is parent +//! of all scene nodes. The root scene node is a special scene node which +//! only exists to manage all scene nodes. It is not rendered and cannot +//! be removed from the scene. +//! \return Returns a pointer to the root scene node. +ISceneNode *CSceneManager::getRootSceneNode() +{ + return this; +} + +//! Returns the current active camera. +//! \return The active camera is returned. Note that this can be NULL, if there +//! was no camera created yet. +ICameraSceneNode *CSceneManager::getActiveCamera() const +{ + return ActiveCamera; +} + +//! Sets the active camera. The previous active camera will be deactivated. +//! \param camera: The new camera which should be active. +void CSceneManager::setActiveCamera(ICameraSceneNode *camera) +{ + if (camera) + camera->grab(); + if (ActiveCamera) + ActiveCamera->drop(); + + ActiveCamera = camera; +} + +//! renders the node. +void CSceneManager::render() +{ +} + +//! returns the axis aligned bounding box of this node +const core::aabbox3d &CSceneManager::getBoundingBox() const +{ + _IRR_DEBUG_BREAK_IF(true) // Bounding Box of Scene Manager should never be used. + + static const core::aabbox3d dummy; + return dummy; +} + +//! returns if node is culled +bool CSceneManager::isCulled(const ISceneNode *node) const +{ + const ICameraSceneNode *cam = getActiveCamera(); + if (!cam) { + return false; + } + bool result = false; + + // has occlusion query information + if (node->getAutomaticCulling() & scene::EAC_OCC_QUERY) { + result = (Driver->getOcclusionQueryResult(const_cast(node)) == 0); + } + + // can be seen by a bounding box ? + if (!result && (node->getAutomaticCulling() & scene::EAC_BOX)) { + core::aabbox3d tbox = node->getBoundingBox(); + node->getAbsoluteTransformation().transformBoxEx(tbox); + result = !(tbox.intersectsWithBox(cam->getViewFrustum()->getBoundingBox())); + } + + // can be seen by a bounding sphere + if (!result && (node->getAutomaticCulling() & scene::EAC_FRUSTUM_SPHERE)) { + const core::aabbox3df nbox = node->getTransformedBoundingBox(); + const float rad = nbox.getRadius(); + const core::vector3df center = nbox.getCenter(); + + const float camrad = cam->getViewFrustum()->getBoundingRadius(); + const core::vector3df camcenter = cam->getViewFrustum()->getBoundingCenter(); + + const float dist = (center - camcenter).getLengthSQ(); + const float maxdist = (rad + camrad) * (rad + camrad); + + result = dist > maxdist; + } + + // can be seen by cam pyramid planes ? + if (!result && (node->getAutomaticCulling() & scene::EAC_FRUSTUM_BOX)) { + SViewFrustum frust = *cam->getViewFrustum(); + + // transform the frustum to the node's current absolute transformation + core::matrix4 invTrans(node->getAbsoluteTransformation(), core::matrix4::EM4CONST_INVERSE); + // invTrans.makeInverse(); + frust.transform(invTrans); + + core::vector3df edges[8]; + node->getBoundingBox().getEdges(edges); + + for (s32 i = 0; i < scene::SViewFrustum::VF_PLANE_COUNT; ++i) { + bool boxInFrustum = false; + for (u32 j = 0; j < 8; ++j) { + if (frust.planes[i].classifyPointRelation(edges[j]) != core::ISREL3D_FRONT) { + boxInFrustum = true; + break; + } + } + + if (!boxInFrustum) { + result = true; + break; + } + } + } + + return result; +} + +//! registers a node for rendering it at a specific time. +u32 CSceneManager::registerNodeForRendering(ISceneNode *node, E_SCENE_NODE_RENDER_PASS pass) +{ + u32 taken = 0; + + switch (pass) { + // take camera if it is not already registered + case ESNRP_CAMERA: { + taken = 1; + for (u32 i = 0; i != CameraList.size(); ++i) { + if (CameraList[i] == node) { + taken = 0; + break; + } + } + if (taken) { + CameraList.push_back(node); + } + } break; + case ESNRP_SKY_BOX: + SkyBoxList.push_back(node); + taken = 1; + break; + case ESNRP_SOLID: + if (!isCulled(node)) { + SolidNodeList.push_back(node); + taken = 1; + } + break; + case ESNRP_TRANSPARENT: + if (!isCulled(node)) { + TransparentNodeList.push_back(TransparentNodeEntry(node, camWorldPos)); + taken = 1; + } + break; + case ESNRP_TRANSPARENT_EFFECT: + if (!isCulled(node)) { + TransparentEffectNodeList.push_back(TransparentNodeEntry(node, camWorldPos)); + taken = 1; + } + break; + case ESNRP_AUTOMATIC: + if (!isCulled(node)) { + const u32 count = node->getMaterialCount(); + + taken = 0; + for (u32 i = 0; i < count; ++i) { + if (Driver->needsTransparentRenderPass(node->getMaterial(i))) { + // register as transparent node + TransparentNodeEntry e(node, camWorldPos); + TransparentNodeList.push_back(e); + taken = 1; + break; + } + } + + // not transparent, register as solid + if (!taken) { + SolidNodeList.push_back(node); + taken = 1; + } + } + break; + case ESNRP_GUI: + if (!isCulled(node)) { + GuiNodeList.push_back(node); + taken = 1; + } + + // as of yet unused + case ESNRP_LIGHT: + case ESNRP_SHADOW: + case ESNRP_NONE: // ignore this one + break; + } + + return taken; +} + +void CSceneManager::clearAllRegisteredNodesForRendering() +{ + CameraList.clear(); + SkyBoxList.clear(); + SolidNodeList.clear(); + TransparentNodeList.clear(); + TransparentEffectNodeList.clear(); + GuiNodeList.clear(); +} + +//! This method is called just before the rendering process of the whole scene. +//! draws all scene nodes +void CSceneManager::drawAll() +{ + if (!Driver) + return; + + u32 i; // new ISO for scoping problem in some compilers + + // reset all transforms + Driver->setMaterial(video::SMaterial()); + Driver->setTransform(video::ETS_PROJECTION, core::IdentityMatrix); + Driver->setTransform(video::ETS_VIEW, core::IdentityMatrix); + Driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); + for (i = video::ETS_COUNT - 1; i >= video::ETS_TEXTURE_0; --i) + Driver->setTransform((video::E_TRANSFORMATION_STATE)i, core::IdentityMatrix); + // TODO: This should not use an attribute here but a real parameter when necessary (too slow!) + Driver->setAllowZWriteOnTransparent(Parameters->getAttributeAsBool(ALLOW_ZWRITE_ON_TRANSPARENT)); + + // do animations and other stuff. + OnAnimate(os::Timer::getTime()); + + /*! + First Scene Node for prerendering should be the active camera + consistent Camera is needed for culling + */ + camWorldPos.set(0, 0, 0); + if (ActiveCamera) { + ActiveCamera->render(); + camWorldPos = ActiveCamera->getAbsolutePosition(); + } + + // let all nodes register themselves + OnRegisterSceneNode(); + + // render camera scenes + { + CurrentRenderPass = ESNRP_CAMERA; + Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0); + + for (i = 0; i < CameraList.size(); ++i) + CameraList[i]->render(); + + CameraList.set_used(0); + } + + // render skyboxes + { + CurrentRenderPass = ESNRP_SKY_BOX; + Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0); + + for (i = 0; i < SkyBoxList.size(); ++i) + SkyBoxList[i]->render(); + + SkyBoxList.set_used(0); + } + + // render default objects + { + CurrentRenderPass = ESNRP_SOLID; + Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0); + + SolidNodeList.sort(); // sort by textures + + for (i = 0; i < SolidNodeList.size(); ++i) + SolidNodeList[i].Node->render(); + + SolidNodeList.set_used(0); + } + + // render transparent objects. + { + CurrentRenderPass = ESNRP_TRANSPARENT; + Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0); + + TransparentNodeList.sort(); // sort by distance from camera + for (i = 0; i < TransparentNodeList.size(); ++i) + TransparentNodeList[i].Node->render(); + + TransparentNodeList.set_used(0); + } + + // render transparent effect objects. + { + CurrentRenderPass = ESNRP_TRANSPARENT_EFFECT; + Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0); + + TransparentEffectNodeList.sort(); // sort by distance from camera + + for (i = 0; i < TransparentEffectNodeList.size(); ++i) + TransparentEffectNodeList[i].Node->render(); + + TransparentEffectNodeList.set_used(0); + } + + // render custom gui nodes + { + CurrentRenderPass = ESNRP_GUI; + Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0); + + for (i = 0; i < GuiNodeList.size(); ++i) + GuiNodeList[i]->render(); + + GuiNodeList.set_used(0); + } + clearDeletionList(); + + CurrentRenderPass = ESNRP_NONE; +} + +//! Adds an external mesh loader. +void CSceneManager::addExternalMeshLoader(IMeshLoader *externalLoader) +{ + if (!externalLoader) + return; + + externalLoader->grab(); + MeshLoaderList.push_back(externalLoader); +} + +//! Returns the number of mesh loaders supported by Irrlicht at this time +u32 CSceneManager::getMeshLoaderCount() const +{ + return MeshLoaderList.size(); +} + +//! Retrieve the given mesh loader +IMeshLoader *CSceneManager::getMeshLoader(u32 index) const +{ + if (index < MeshLoaderList.size()) + return MeshLoaderList[index]; + else + return 0; +} + +//! Returns a pointer to the scene collision manager. +ISceneCollisionManager *CSceneManager::getSceneCollisionManager() +{ + return CollisionManager; +} + +//! Returns a pointer to the mesh manipulator. +IMeshManipulator *CSceneManager::getMeshManipulator() +{ + return Driver->getMeshManipulator(); +} + +//! Adds a scene node to the deletion queue. +void CSceneManager::addToDeletionQueue(ISceneNode *node) +{ + if (!node) + return; + + node->grab(); + DeletionList.push_back(node); +} + +//! clears the deletion list +void CSceneManager::clearDeletionList() +{ + if (DeletionList.empty()) + return; + + for (u32 i = 0; i < DeletionList.size(); ++i) { + DeletionList[i]->remove(); + DeletionList[i]->drop(); + } + + DeletionList.clear(); +} + +//! Returns the first scene node with the specified name. +ISceneNode *CSceneManager::getSceneNodeFromName(const char *name, ISceneNode *start) +{ + if (start == 0) + start = getRootSceneNode(); + + auto startName = start->getName(); + if (startName.has_value() && startName == name) + return start; + + ISceneNode *node = 0; + + const ISceneNodeList &list = start->getChildren(); + ISceneNodeList::const_iterator it = list.begin(); + for (; it != list.end(); ++it) { + node = getSceneNodeFromName(name, *it); + if (node) + return node; + } + + return 0; +} + +//! Returns the first scene node with the specified id. +ISceneNode *CSceneManager::getSceneNodeFromId(s32 id, ISceneNode *start) +{ + if (start == 0) + start = getRootSceneNode(); + + if (start->getID() == id) + return start; + + ISceneNode *node = 0; + + const ISceneNodeList &list = start->getChildren(); + ISceneNodeList::const_iterator it = list.begin(); + for (; it != list.end(); ++it) { + node = getSceneNodeFromId(id, *it); + if (node) + return node; + } + + return 0; +} + +//! Returns the first scene node with the specified type. +ISceneNode *CSceneManager::getSceneNodeFromType(scene::ESCENE_NODE_TYPE type, ISceneNode *start) +{ + if (start == 0) + start = getRootSceneNode(); + + if (start->getType() == type || ESNT_ANY == type) + return start; + + ISceneNode *node = 0; + + const ISceneNodeList &list = start->getChildren(); + ISceneNodeList::const_iterator it = list.begin(); + for (; it != list.end(); ++it) { + node = getSceneNodeFromType(type, *it); + if (node) + return node; + } + + return 0; +} + +//! returns scene nodes by type. +void CSceneManager::getSceneNodesFromType(ESCENE_NODE_TYPE type, core::array &outNodes, ISceneNode *start) +{ + if (start == 0) + start = getRootSceneNode(); + + if (start->getType() == type || ESNT_ANY == type) + outNodes.push_back(start); + + const ISceneNodeList &list = start->getChildren(); + ISceneNodeList::const_iterator it = list.begin(); + + for (; it != list.end(); ++it) { + getSceneNodesFromType(type, outNodes, *it); + } +} + +//! Posts an input event to the environment. Usually you do not have to +//! use this method, it is used by the internal engine. +bool CSceneManager::postEventFromUser(const SEvent &event) +{ + bool ret = false; + ICameraSceneNode *cam = getActiveCamera(); + if (cam) + ret = cam->OnEvent(event); + + return ret; +} + +//! Removes all children of this scene node +void CSceneManager::removeAll() +{ + ISceneNode::removeAll(); + setActiveCamera(0); + // Make sure the driver is reset, might need a more complex method at some point + if (Driver) + Driver->setMaterial(video::SMaterial()); +} + +//! Clears the whole scene. All scene nodes are removed. +void CSceneManager::clear() +{ + removeAll(); +} + +//! Returns interface to the parameters set in this scene. +io::IAttributes *CSceneManager::getParameters() +{ + return Parameters; +} + +//! Returns current render pass. +E_SCENE_NODE_RENDER_PASS CSceneManager::getSceneNodeRenderPass() const +{ + return CurrentRenderPass; +} + +//! Returns an interface to the mesh cache which is shared between all existing scene managers. +IMeshCache *CSceneManager::getMeshCache() +{ + return MeshCache; +} + +//! Creates a new scene manager. +ISceneManager *CSceneManager::createNewSceneManager(bool cloneContent) +{ + CSceneManager *manager = new CSceneManager(Driver, CursorControl, MeshCache); + + if (cloneContent) + manager->cloneMembers(this, manager); + + return manager; +} + +//! Sets ambient color of the scene +void CSceneManager::setAmbientLight(const video::SColorf &ambientColor) +{ + AmbientLight = ambientColor; +} + +//! Returns ambient color of the scene +const video::SColorf &CSceneManager::getAmbientLight() const +{ + return AmbientLight; +} + +//! Get a skinned mesh, which is not available as header-only code +ISkinnedMesh *CSceneManager::createSkinnedMesh() +{ + return new CSkinnedMesh(); +} + +// creates a scenemanager +ISceneManager *createSceneManager(video::IVideoDriver *driver, gui::ICursorControl *cursorcontrol) +{ + return new CSceneManager(driver, cursorcontrol, nullptr); +} + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CSceneManager.h b/irr/src/CSceneManager.h new file mode 100644 index 000000000..0e27290a8 --- /dev/null +++ b/irr/src/CSceneManager.h @@ -0,0 +1,308 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "ISceneManager.h" +#include "ISceneNode.h" +#include "ICursorControl.h" +#include "irrString.h" +#include "irrArray.h" +#include "IMeshLoader.h" +#include "CAttributes.h" + +namespace irr +{ +namespace io +{ +class IFileSystem; +} +namespace scene +{ +class IMeshCache; + +/*! + The Scene Manager manages scene nodes, mesh resources, cameras and all the other stuff. +*/ +class CSceneManager : public ISceneManager, public ISceneNode +{ +public: + //! constructor + CSceneManager(video::IVideoDriver *driver, gui::ICursorControl *cursorControl, IMeshCache *cache = 0); + + //! destructor + virtual ~CSceneManager(); + + //! gets an animateable mesh. loads it if needed. returned pointer must not be dropped. + IAnimatedMesh *getMesh(io::IReadFile *file) override; + + //! Returns an interface to the mesh cache which is shared between all existing scene managers. + IMeshCache *getMeshCache() override; + + //! returns the video driver + video::IVideoDriver *getVideoDriver() override; + + //! adds a scene node for rendering an animated mesh model + virtual IAnimatedMeshSceneNode *addAnimatedMeshSceneNode(IAnimatedMesh *mesh, ISceneNode *parent = 0, s32 id = -1, + const core::vector3df &position = core::vector3df(0, 0, 0), + const core::vector3df &rotation = core::vector3df(0, 0, 0), + const core::vector3df &scale = core::vector3df(1.0f, 1.0f, 1.0f), + bool alsoAddIfMeshPointerZero = false) override; + + //! adds a scene node for rendering a static mesh + //! the returned pointer must not be dropped. + virtual IMeshSceneNode *addMeshSceneNode(IMesh *mesh, ISceneNode *parent = 0, s32 id = -1, + const core::vector3df &position = core::vector3df(0, 0, 0), + const core::vector3df &rotation = core::vector3df(0, 0, 0), + const core::vector3df &scale = core::vector3df(1.0f, 1.0f, 1.0f), + bool alsoAddIfMeshPointerZero = false) override; + + //! renders the node. + void render() override; + + //! returns the axis aligned bounding box of this node + const core::aabbox3d &getBoundingBox() const override; + + //! registers a node for rendering it at a specific time. + u32 registerNodeForRendering(ISceneNode *node, E_SCENE_NODE_RENDER_PASS pass = ESNRP_AUTOMATIC) override; + + //! Clear all nodes which are currently registered for rendering + void clearAllRegisteredNodesForRendering() override; + + //! draws all scene nodes + void drawAll() override; + + //! Adds a camera scene node to the tree and sets it as active camera. + //! \param position: Position of the space relative to its parent where the camera will be placed. + //! \param lookat: Position where the camera will look at. Also known as target. + //! \param parent: Parent scene node of the camera. Can be null. If the parent moves, + //! the camera will move too. + //! \return Pointer to interface to camera + virtual ICameraSceneNode *addCameraSceneNode(ISceneNode *parent = 0, + const core::vector3df &position = core::vector3df(0, 0, 0), + const core::vector3df &lookat = core::vector3df(0, 0, 100), + s32 id = -1, bool makeActive = true) override; + + //! Adds a billboard scene node to the scene. A billboard is like a 3d sprite: A 2d element, + //! which always looks to the camera. It is usually used for things like explosions, fire, + //! lensflares and things like that. + virtual IBillboardSceneNode *addBillboardSceneNode(ISceneNode *parent = 0, + const core::dimension2d &size = core::dimension2d(10.0f, 10.0f), + const core::vector3df &position = core::vector3df(0, 0, 0), s32 id = -1, + video::SColor shadeTop = 0xFFFFFFFF, video::SColor shadeBottom = 0xFFFFFFFF) override; + + //! Adds a dummy transformation scene node to the scene graph. + virtual IDummyTransformationSceneNode *addDummyTransformationSceneNode( + ISceneNode *parent = 0, s32 id = -1) override; + + //! Adds an empty scene node. + ISceneNode *addEmptySceneNode(ISceneNode *parent, s32 id = -1) override; + + //! Returns the root scene node. This is the scene node which is parent + //! of all scene nodes. The root scene node is a special scene node which + //! only exists to manage all scene nodes. It is not rendered and cannot + //! be removed from the scene. + //! \return Pointer to the root scene node. + ISceneNode *getRootSceneNode() override; + + //! Returns the current active camera. + //! \return The active camera is returned. Note that this can be NULL, if there + //! was no camera created yet. + ICameraSceneNode *getActiveCamera() const override; + + //! Sets the active camera. The previous active camera will be deactivated. + //! \param camera: The new camera which should be active. + void setActiveCamera(ICameraSceneNode *camera) override; + + //! Adds an external mesh loader. + void addExternalMeshLoader(IMeshLoader *externalLoader) override; + + //! Returns the number of mesh loaders supported by Irrlicht at this time + u32 getMeshLoaderCount() const override; + + //! Retrieve the given mesh loader + IMeshLoader *getMeshLoader(u32 index) const override; + + //! Returns a pointer to the scene collision manager. + ISceneCollisionManager *getSceneCollisionManager() override; + + //! Returns a pointer to the mesh manipulator. + IMeshManipulator *getMeshManipulator() override; + + //! Adds a scene node to the deletion queue. + void addToDeletionQueue(ISceneNode *node) override; + + //! Returns the first scene node with the specified id. + ISceneNode *getSceneNodeFromId(s32 id, ISceneNode *start = 0) override; + + //! Returns the first scene node with the specified name. + ISceneNode *getSceneNodeFromName(const c8 *name, ISceneNode *start = 0) override; + + //! Returns the first scene node with the specified type. + ISceneNode *getSceneNodeFromType(scene::ESCENE_NODE_TYPE type, ISceneNode *start = 0) override; + + //! returns scene nodes by type. + void getSceneNodesFromType(ESCENE_NODE_TYPE type, core::array &outNodes, ISceneNode *start = 0) override; + + //! Posts an input event to the environment. Usually you do not have to + //! use this method, it is used by the internal engine. + bool postEventFromUser(const SEvent &event) override; + + //! Clears the whole scene. All scene nodes are removed. + void clear() override; + + //! Removes all children of this scene node + void removeAll() override; + + //! Returns interface to the parameters set in this scene. + io::IAttributes *getParameters() override; + + //! Returns current render pass. + E_SCENE_NODE_RENDER_PASS getSceneNodeRenderPass() const override; + + //! Creates a new scene manager. + ISceneManager *createNewSceneManager(bool cloneContent) override; + + //! Returns type of the scene node + ESCENE_NODE_TYPE getType() const override { return ESNT_SCENE_MANAGER; } + + //! Get a skinned mesh, which is not available as header-only code + ISkinnedMesh *createSkinnedMesh() override; + + //! Sets ambient color of the scene + void setAmbientLight(const video::SColorf &ambientColor) override; + + //! Returns ambient color of the scene + const video::SColorf &getAmbientLight() const override; + + //! Get current render time. + E_SCENE_NODE_RENDER_PASS getCurrentRenderPass() const override { return CurrentRenderPass; } + + //! Set current render time. + void setCurrentRenderPass(E_SCENE_NODE_RENDER_PASS nextPass) override { CurrentRenderPass = nextPass; } + + //! returns if node is culled + bool isCulled(const ISceneNode *node) const override; + +private: + // load and create a mesh which we know already isn't in the cache and put it in there + IAnimatedMesh *getUncachedMesh(io::IReadFile *file, const io::path &filename, const io::path &cachename); + + //! clears the deletion list + void clearDeletionList(); + + struct DefaultNodeEntry + { + DefaultNodeEntry() + { + } + + DefaultNodeEntry(ISceneNode *n) : + Node(n), TextureValue(0) + { + if (n->getMaterialCount()) + TextureValue = (n->getMaterial(0).getTexture(0)); + } + + bool operator<(const DefaultNodeEntry &other) const + { + return (TextureValue < other.TextureValue); + } + + ISceneNode *Node; + + private: + void *TextureValue; + }; + + //! sort on distance (center) to camera + struct TransparentNodeEntry + { + TransparentNodeEntry() + { + } + + TransparentNodeEntry(ISceneNode *n, const core::vector3df &camera) : + Node(n) + { + Distance = Node->getAbsoluteTransformation().getTranslation().getDistanceFromSQ(camera); + } + + bool operator<(const TransparentNodeEntry &other) const + { + return Distance > other.Distance; + } + + ISceneNode *Node; + + private: + f64 Distance; + }; + + //! sort on distance (sphere) to camera + struct DistanceNodeEntry + { + DistanceNodeEntry(ISceneNode *n, const core::vector3df &cameraPos) : + Node(n) + { + setNodeAndDistanceFromPosition(n, cameraPos); + } + + bool operator<(const DistanceNodeEntry &other) const + { + return Distance < other.Distance; + } + + void setNodeAndDistanceFromPosition(ISceneNode *n, const core::vector3df &fromPosition) + { + Node = n; + Distance = Node->getAbsoluteTransformation().getTranslation().getDistanceFromSQ(fromPosition); + Distance -= Node->getBoundingBox().getExtent().getLengthSQ() * 0.5; + } + + ISceneNode *Node; + + private: + f64 Distance; + }; + + //! video driver + video::IVideoDriver *Driver; + + //! cursor control + gui::ICursorControl *CursorControl; + + //! collision manager + ISceneCollisionManager *CollisionManager; + + //! render pass lists + core::array CameraList; + core::array SkyBoxList; + core::array SolidNodeList; + core::array TransparentNodeList; + core::array TransparentEffectNodeList; + core::array GuiNodeList; + + core::array MeshLoaderList; + core::array DeletionList; + + //! current active camera + ICameraSceneNode *ActiveCamera; + core::vector3df camWorldPos; // Position of camera for transparent nodes. + + video::SColor ShadowColor; + video::SColorf AmbientLight; + + //! String parameters + // NOTE: Attributes are slow and should only be used for debug-info and not in release + io::CAttributes *Parameters; + + //! Mesh cache + IMeshCache *MeshCache; + + E_SCENE_NODE_RENDER_PASS CurrentRenderPass; +}; + +} // end namespace video +} // end namespace scene diff --git a/irr/src/CSkinnedMesh.cpp b/irr/src/CSkinnedMesh.cpp new file mode 100644 index 000000000..eb7317309 --- /dev/null +++ b/irr/src/CSkinnedMesh.cpp @@ -0,0 +1,1336 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CSkinnedMesh.h" +#include +#include "CBoneSceneNode.h" +#include "IAnimatedMeshSceneNode.h" +#include "os.h" + +namespace +{ +// Frames must always be increasing, so we remove objects where this isn't the case +// return number of kicked keys +template // T = objects containing a "frame" variable +irr::u32 dropBadKeys(irr::core::array &array) +{ + if (array.size() < 2) + return 0; + + irr::u32 n = 1; // new index + for (irr::u32 j = 1; j < array.size(); ++j) { + if (array[j].frame < array[n - 1].frame) + continue; // bad frame, unneeded and may cause problems + if (n != j) + array[n] = array[j]; + ++n; + } + irr::u32 d = array.size() - n; // remove already copied keys + if (d > 0) { + array.erase(n, d); + } + return d; +} + +// drop identical middle keys - we only need the first and last +// return number of kicked keys +template // Cmp = comparison for keys of type T +irr::u32 dropMiddleKeys(irr::core::array &array, Cmp &cmp) +{ + if (array.size() < 3) + return 0; + + irr::u32 s = 0; // old index for current key + irr::u32 n = 1; // new index for next key + for (irr::u32 j = 1; j < array.size(); ++j) { + if (cmp(array[j], array[s])) + continue; // same key, handle later + + if (j > s + 1) // had there been identical keys? + array[n++] = array[j - 1]; // keep the last + array[n++] = array[j]; // keep the new one + s = j; + } + if (array.size() > s + 1) // identical keys at the array end? + array[n++] = array[array.size() - 1]; // keep the last + + irr::u32 d = array.size() - n; // remove already copied keys + if (d > 0) { + array.erase(n, d); + } + return d; +} + +bool identicalPos(const irr::scene::ISkinnedMesh::SPositionKey &a, const irr::scene::ISkinnedMesh::SPositionKey &b) +{ + return a.position == b.position; +} + +bool identicalScale(const irr::scene::ISkinnedMesh::SScaleKey &a, const irr::scene::ISkinnedMesh::SScaleKey &b) +{ + return a.scale == b.scale; +} + +bool identicalRotation(const irr::scene::ISkinnedMesh::SRotationKey &a, const irr::scene::ISkinnedMesh::SRotationKey &b) +{ + return a.rotation == b.rotation; +} +} + +namespace irr +{ +namespace scene +{ + +//! constructor +CSkinnedMesh::CSkinnedMesh() : + SkinningBuffers(0), EndFrame(0.f), FramesPerSecond(25.f), + LastAnimatedFrame(-1), SkinnedLastFrame(false), + InterpolationMode(EIM_LINEAR), + HasAnimation(false), PreparedForSkinning(false), + AnimateNormals(true), HardwareSkinning(false) +{ +#ifdef _DEBUG + setDebugName("CSkinnedMesh"); +#endif + + SkinningBuffers = &LocalBuffers; +} + +//! destructor +CSkinnedMesh::~CSkinnedMesh() +{ + for (u32 i = 0; i < AllJoints.size(); ++i) + delete AllJoints[i]; + + for (u32 j = 0; j < LocalBuffers.size(); ++j) { + if (LocalBuffers[j]) + LocalBuffers[j]->drop(); + } +} + +//! returns the amount of frames in milliseconds. +//! If the amount is 1, it is a static (=non animated) mesh. +u32 CSkinnedMesh::getFrameCount() const +{ + return core::floor32(EndFrame + 1.f); +} + +//! Gets the default animation speed of the animated mesh. +/** \return Amount of frames per second. If the amount is 0, it is a static, non animated mesh. */ +f32 CSkinnedMesh::getAnimationSpeed() const +{ + return FramesPerSecond; +} + +//! Gets the frame count of the animated mesh. +/** \param fps Frames per second to play the animation with. If the amount is 0, it is not animated. +The actual speed is set in the scene node the mesh is instantiated in.*/ +void CSkinnedMesh::setAnimationSpeed(f32 fps) +{ + FramesPerSecond = fps; +} + +//! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level. +IMesh *CSkinnedMesh::getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop) +{ + // animate(frame,startFrameLoop, endFrameLoop); + if (frame == -1) + return this; + + animateMesh((f32)frame, 1.0f); + skinMesh(); + return this; +} + +//-------------------------------------------------------------------------- +// Keyframe Animation +//-------------------------------------------------------------------------- + +//! Animates this mesh's joints based on frame input +//! blend: {0-old position, 1-New position} +void CSkinnedMesh::animateMesh(f32 frame, f32 blend) +{ + if (!HasAnimation || LastAnimatedFrame == frame) + return; + + LastAnimatedFrame = frame; + SkinnedLastFrame = false; + + if (blend <= 0.f) + return; // No need to animate + + for (u32 i = 0; i < AllJoints.size(); ++i) { + // The joints can be animated here with no input from their + // parents, but for setAnimationMode extra checks are needed + // to their parents + SJoint *joint = AllJoints[i]; + + const core::vector3df oldPosition = joint->Animatedposition; + const core::vector3df oldScale = joint->Animatedscale; + const core::quaternion oldRotation = joint->Animatedrotation; + + core::vector3df position = oldPosition; + core::vector3df scale = oldScale; + core::quaternion rotation = oldRotation; + + getFrameData(frame, joint, + position, joint->positionHint, + scale, joint->scaleHint, + rotation, joint->rotationHint); + + if (blend == 1.0f) { + // No blending needed + joint->Animatedposition = position; + joint->Animatedscale = scale; + joint->Animatedrotation = rotation; + } else { + // Blend animation + joint->Animatedposition = core::lerp(oldPosition, position, blend); + joint->Animatedscale = core::lerp(oldScale, scale, blend); + joint->Animatedrotation.slerp(oldRotation, rotation, blend); + } + } + + // Note: + // LocalAnimatedMatrix needs to be built at some point, but this function may be called lots of times for + // one render (to play two animations at the same time) LocalAnimatedMatrix only needs to be built once. + // a call to buildAllLocalAnimatedMatrices is needed before skinning the mesh, and before the user gets the joints to move + + //---------------- + // Temp! + buildAllLocalAnimatedMatrices(); + //----------------- + + updateBoundingBox(); +} + +void CSkinnedMesh::buildAllLocalAnimatedMatrices() +{ + for (u32 i = 0; i < AllJoints.size(); ++i) { + SJoint *joint = AllJoints[i]; + + // Could be faster: + + if (joint->UseAnimationFrom && + (joint->UseAnimationFrom->PositionKeys.size() || + joint->UseAnimationFrom->ScaleKeys.size() || + joint->UseAnimationFrom->RotationKeys.size())) { + joint->GlobalSkinningSpace = false; + + // IRR_TEST_BROKEN_QUATERNION_USE: TODO - switched to getMatrix_transposed instead of getMatrix for downward compatibility. + // Not tested so far if this was correct or wrong before quaternion fix! + joint->Animatedrotation.getMatrix_transposed(joint->LocalAnimatedMatrix); + + // --- joint->LocalAnimatedMatrix *= joint->Animatedrotation.getMatrix() --- + f32 *m1 = joint->LocalAnimatedMatrix.pointer(); + core::vector3df &Pos = joint->Animatedposition; + m1[0] += Pos.X * m1[3]; + m1[1] += Pos.Y * m1[3]; + m1[2] += Pos.Z * m1[3]; + m1[4] += Pos.X * m1[7]; + m1[5] += Pos.Y * m1[7]; + m1[6] += Pos.Z * m1[7]; + m1[8] += Pos.X * m1[11]; + m1[9] += Pos.Y * m1[11]; + m1[10] += Pos.Z * m1[11]; + m1[12] += Pos.X * m1[15]; + m1[13] += Pos.Y * m1[15]; + m1[14] += Pos.Z * m1[15]; + // ----------------------------------- + + if (joint->ScaleKeys.size()) { + /* + core::matrix4 scaleMatrix; + scaleMatrix.setScale(joint->Animatedscale); + joint->LocalAnimatedMatrix *= scaleMatrix; + */ + + // -------- joint->LocalAnimatedMatrix *= scaleMatrix ----------------- + core::matrix4 &mat = joint->LocalAnimatedMatrix; + mat[0] *= joint->Animatedscale.X; + mat[1] *= joint->Animatedscale.X; + mat[2] *= joint->Animatedscale.X; + mat[3] *= joint->Animatedscale.X; + mat[4] *= joint->Animatedscale.Y; + mat[5] *= joint->Animatedscale.Y; + mat[6] *= joint->Animatedscale.Y; + mat[7] *= joint->Animatedscale.Y; + mat[8] *= joint->Animatedscale.Z; + mat[9] *= joint->Animatedscale.Z; + mat[10] *= joint->Animatedscale.Z; + mat[11] *= joint->Animatedscale.Z; + // ----------------------------------- + } + } else { + joint->LocalAnimatedMatrix = joint->LocalMatrix; + } + } + SkinnedLastFrame = false; +} + +void CSkinnedMesh::buildAllGlobalAnimatedMatrices(SJoint *joint, SJoint *parentJoint) +{ + if (!joint) { + for (u32 i = 0; i < RootJoints.size(); ++i) + buildAllGlobalAnimatedMatrices(RootJoints[i], 0); + return; + } else { + // Find global matrix... + if (!parentJoint || joint->GlobalSkinningSpace) + joint->GlobalAnimatedMatrix = joint->LocalAnimatedMatrix; + else + joint->GlobalAnimatedMatrix = parentJoint->GlobalAnimatedMatrix * joint->LocalAnimatedMatrix; + } + + for (u32 j = 0; j < joint->Children.size(); ++j) + buildAllGlobalAnimatedMatrices(joint->Children[j], joint); +} + +void CSkinnedMesh::getFrameData(f32 frame, SJoint *joint, + core::vector3df &position, s32 &positionHint, + core::vector3df &scale, s32 &scaleHint, + core::quaternion &rotation, s32 &rotationHint) +{ + s32 foundPositionIndex = -1; + s32 foundScaleIndex = -1; + s32 foundRotationIndex = -1; + + if (joint->UseAnimationFrom) { + const core::array &PositionKeys = joint->UseAnimationFrom->PositionKeys; + const core::array &ScaleKeys = joint->UseAnimationFrom->ScaleKeys; + const core::array &RotationKeys = joint->UseAnimationFrom->RotationKeys; + + if (PositionKeys.size()) { + foundPositionIndex = -1; + + // Test the Hints... + if (positionHint >= 0 && (u32)positionHint < PositionKeys.size()) { + // check this hint + if (positionHint > 0 && PositionKeys[positionHint].frame >= frame && PositionKeys[positionHint - 1].frame < frame) + foundPositionIndex = positionHint; + else if (positionHint + 1 < (s32)PositionKeys.size()) { + // check the next index + if (PositionKeys[positionHint + 1].frame >= frame && + PositionKeys[positionHint + 0].frame < frame) { + positionHint++; + foundPositionIndex = positionHint; + } + } + } + + // The hint test failed, do a full scan... + if (foundPositionIndex == -1) { + for (u32 i = 0; i < PositionKeys.size(); ++i) { + if (PositionKeys[i].frame >= frame) { // Keys should to be sorted by frame + foundPositionIndex = i; + positionHint = i; + break; + } + } + } + + // Do interpolation... + if (foundPositionIndex != -1) { + if (InterpolationMode == EIM_CONSTANT || foundPositionIndex == 0) { + position = PositionKeys[foundPositionIndex].position; + } else if (InterpolationMode == EIM_LINEAR) { + const SPositionKey &KeyA = PositionKeys[foundPositionIndex]; + const SPositionKey &KeyB = PositionKeys[foundPositionIndex - 1]; + + const f32 fd1 = frame - KeyA.frame; + const f32 fd2 = KeyB.frame - frame; + position = ((KeyB.position - KeyA.position) / (fd1 + fd2)) * fd1 + KeyA.position; + } + } + } + + //------------------------------------------------------------ + + if (ScaleKeys.size()) { + foundScaleIndex = -1; + + // Test the Hints... + if (scaleHint >= 0 && (u32)scaleHint < ScaleKeys.size()) { + // check this hint + if (scaleHint > 0 && ScaleKeys[scaleHint].frame >= frame && ScaleKeys[scaleHint - 1].frame < frame) + foundScaleIndex = scaleHint; + else if (scaleHint + 1 < (s32)ScaleKeys.size()) { + // check the next index + if (ScaleKeys[scaleHint + 1].frame >= frame && + ScaleKeys[scaleHint + 0].frame < frame) { + scaleHint++; + foundScaleIndex = scaleHint; + } + } + } + + // The hint test failed, do a full scan... + if (foundScaleIndex == -1) { + for (u32 i = 0; i < ScaleKeys.size(); ++i) { + if (ScaleKeys[i].frame >= frame) { // Keys should to be sorted by frame + foundScaleIndex = i; + scaleHint = i; + break; + } + } + } + + // Do interpolation... + if (foundScaleIndex != -1) { + if (InterpolationMode == EIM_CONSTANT || foundScaleIndex == 0) { + scale = ScaleKeys[foundScaleIndex].scale; + } else if (InterpolationMode == EIM_LINEAR) { + const SScaleKey &KeyA = ScaleKeys[foundScaleIndex]; + const SScaleKey &KeyB = ScaleKeys[foundScaleIndex - 1]; + + const f32 fd1 = frame - KeyA.frame; + const f32 fd2 = KeyB.frame - frame; + scale = ((KeyB.scale - KeyA.scale) / (fd1 + fd2)) * fd1 + KeyA.scale; + } + } + } + + //------------------------------------------------------------- + + if (RotationKeys.size()) { + foundRotationIndex = -1; + + // Test the Hints... + if (rotationHint >= 0 && (u32)rotationHint < RotationKeys.size()) { + // check this hint + if (rotationHint > 0 && RotationKeys[rotationHint].frame >= frame && RotationKeys[rotationHint - 1].frame < frame) + foundRotationIndex = rotationHint; + else if (rotationHint + 1 < (s32)RotationKeys.size()) { + // check the next index + if (RotationKeys[rotationHint + 1].frame >= frame && + RotationKeys[rotationHint + 0].frame < frame) { + rotationHint++; + foundRotationIndex = rotationHint; + } + } + } + + // The hint test failed, do a full scan... + if (foundRotationIndex == -1) { + for (u32 i = 0; i < RotationKeys.size(); ++i) { + if (RotationKeys[i].frame >= frame) { // Keys should be sorted by frame + foundRotationIndex = i; + rotationHint = i; + break; + } + } + } + + // Do interpolation... + if (foundRotationIndex != -1) { + if (InterpolationMode == EIM_CONSTANT || foundRotationIndex == 0) { + rotation = RotationKeys[foundRotationIndex].rotation; + } else if (InterpolationMode == EIM_LINEAR) { + const SRotationKey &KeyA = RotationKeys[foundRotationIndex]; + const SRotationKey &KeyB = RotationKeys[foundRotationIndex - 1]; + + const f32 fd1 = frame - KeyA.frame; + const f32 fd2 = KeyB.frame - frame; + const f32 t = fd1 / (fd1 + fd2); + + /* + f32 t = 0; + if (KeyA.frame!=KeyB.frame) + t = (frame-KeyA.frame) / (KeyB.frame - KeyA.frame); + */ + + rotation.slerp(KeyA.rotation, KeyB.rotation, t); + } + } + } + } +} + +//-------------------------------------------------------------------------- +// Software Skinning +//-------------------------------------------------------------------------- + +//! Preforms a software skin on this mesh based of joint positions +void CSkinnedMesh::skinMesh() +{ + if (!HasAnimation || SkinnedLastFrame) + return; + + //---------------- + // This is marked as "Temp!". A shiny dubloon to whomever can tell me why. + buildAllGlobalAnimatedMatrices(); + //----------------- + + SkinnedLastFrame = true; + if (!HardwareSkinning) { + // Software skin.... + u32 i; + + // rigid animation + for (i = 0; i < AllJoints.size(); ++i) { + for (u32 j = 0; j < AllJoints[i]->AttachedMeshes.size(); ++j) { + SSkinMeshBuffer *Buffer = (*SkinningBuffers)[AllJoints[i]->AttachedMeshes[j]]; + Buffer->Transformation = AllJoints[i]->GlobalAnimatedMatrix; + } + } + + // clear skinning helper array + for (i = 0; i < Vertices_Moved.size(); ++i) + for (u32 j = 0; j < Vertices_Moved[i].size(); ++j) + Vertices_Moved[i][j] = false; + + // skin starting with the root joints + for (i = 0; i < RootJoints.size(); ++i) + skinJoint(RootJoints[i], 0); + + for (i = 0; i < SkinningBuffers->size(); ++i) + (*SkinningBuffers)[i]->setDirty(EBT_VERTEX); + } + updateBoundingBox(); +} + +void CSkinnedMesh::skinJoint(SJoint *joint, SJoint *parentJoint) +{ + if (joint->Weights.size()) { + // Find this joints pull on vertices... + core::matrix4 jointVertexPull(core::matrix4::EM4CONST_NOTHING); + jointVertexPull.setbyproduct(joint->GlobalAnimatedMatrix, joint->GlobalInversedMatrix); + + core::vector3df thisVertexMove, thisNormalMove; + + core::array &buffersUsed = *SkinningBuffers; + + // Skin Vertices Positions and Normals... + for (u32 i = 0; i < joint->Weights.size(); ++i) { + SWeight &weight = joint->Weights[i]; + + // Pull this vertex... + jointVertexPull.transformVect(thisVertexMove, weight.StaticPos); + + if (AnimateNormals) + jointVertexPull.rotateVect(thisNormalMove, weight.StaticNormal); + + if (!(*(weight.Moved))) { + *(weight.Moved) = true; + + buffersUsed[weight.buffer_id]->getVertex(weight.vertex_id)->Pos = thisVertexMove * weight.strength; + + if (AnimateNormals) + buffersUsed[weight.buffer_id]->getVertex(weight.vertex_id)->Normal = thisNormalMove * weight.strength; + + //*(weight._Pos) = thisVertexMove * weight.strength; + } else { + buffersUsed[weight.buffer_id]->getVertex(weight.vertex_id)->Pos += thisVertexMove * weight.strength; + + if (AnimateNormals) + buffersUsed[weight.buffer_id]->getVertex(weight.vertex_id)->Normal += thisNormalMove * weight.strength; + + //*(weight._Pos) += thisVertexMove * weight.strength; + } + + buffersUsed[weight.buffer_id]->boundingBoxNeedsRecalculated(); + } + } + + // Skin all children + for (u32 j = 0; j < joint->Children.size(); ++j) + skinJoint(joint->Children[j], joint); +} + +E_ANIMATED_MESH_TYPE CSkinnedMesh::getMeshType() const +{ + return EAMT_SKINNED; +} + +//! Gets joint count. +u32 CSkinnedMesh::getJointCount() const +{ + return AllJoints.size(); +} + +//! Gets the name of a joint. +const std::optional &CSkinnedMesh::getJointName(u32 number) const +{ + if (number >= getJointCount()) { + static const std::optional nullopt; + return nullopt; + } + return AllJoints[number]->Name; +} + +//! Gets a joint number from its name +std::optional CSkinnedMesh::getJointNumber(const std::string &name) const +{ + for (u32 i = 0; i < AllJoints.size(); ++i) { + if (AllJoints[i]->Name == name) + return i; + } + + return std::nullopt; +} + +//! returns amount of mesh buffers. +u32 CSkinnedMesh::getMeshBufferCount() const +{ + return LocalBuffers.size(); +} + +//! returns pointer to a mesh buffer +IMeshBuffer *CSkinnedMesh::getMeshBuffer(u32 nr) const +{ + if (nr < LocalBuffers.size()) + return LocalBuffers[nr]; + else + return 0; +} + +//! Returns pointer to a mesh buffer which fits a material +IMeshBuffer *CSkinnedMesh::getMeshBuffer(const video::SMaterial &material) const +{ + for (u32 i = 0; i < LocalBuffers.size(); ++i) { + if (LocalBuffers[i]->getMaterial() == material) + return LocalBuffers[i]; + } + return 0; +} + +//! returns an axis aligned bounding box +const core::aabbox3d &CSkinnedMesh::getBoundingBox() const +{ + return BoundingBox; +} + +//! set user axis aligned bounding box +void CSkinnedMesh::setBoundingBox(const core::aabbox3df &box) +{ + BoundingBox = box; +} + +//! set the hardware mapping hint, for driver +void CSkinnedMesh::setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, + E_BUFFER_TYPE buffer) +{ + for (u32 i = 0; i < LocalBuffers.size(); ++i) + LocalBuffers[i]->setHardwareMappingHint(newMappingHint, buffer); +} + +//! flags the meshbuffer as changed, reloads hardware buffers +void CSkinnedMesh::setDirty(E_BUFFER_TYPE buffer) +{ + for (u32 i = 0; i < LocalBuffers.size(); ++i) + LocalBuffers[i]->setDirty(buffer); +} + +//! uses animation from another mesh +bool CSkinnedMesh::useAnimationFrom(const ISkinnedMesh *mesh) +{ + bool unmatched = false; + + for (u32 i = 0; i < AllJoints.size(); ++i) { + SJoint *joint = AllJoints[i]; + joint->UseAnimationFrom = 0; + + if (joint->Name == "") + unmatched = true; + else { + for (u32 j = 0; j < mesh->getAllJoints().size(); ++j) { + SJoint *otherJoint = mesh->getAllJoints()[j]; + if (joint->Name == otherJoint->Name) { + joint->UseAnimationFrom = otherJoint; + } + } + if (!joint->UseAnimationFrom) + unmatched = true; + } + } + + checkForAnimation(); + + return !unmatched; +} + +//! Update Normals when Animating +//! False= Don't animate them, faster +//! True= Update normals (default) +void CSkinnedMesh::updateNormalsWhenAnimating(bool on) +{ + AnimateNormals = on; +} + +//! Sets Interpolation Mode +void CSkinnedMesh::setInterpolationMode(E_INTERPOLATION_MODE mode) +{ + InterpolationMode = mode; +} + +core::array &CSkinnedMesh::getMeshBuffers() +{ + return LocalBuffers; +} + +core::array &CSkinnedMesh::getAllJoints() +{ + return AllJoints; +} + +const core::array &CSkinnedMesh::getAllJoints() const +{ + return AllJoints; +} + +//! (This feature is not implemented in irrlicht yet) +bool CSkinnedMesh::setHardwareSkinning(bool on) +{ + if (HardwareSkinning != on) { + if (on) { + + // set mesh to static pose... + for (u32 i = 0; i < AllJoints.size(); ++i) { + SJoint *joint = AllJoints[i]; + for (u32 j = 0; j < joint->Weights.size(); ++j) { + const u16 buffer_id = joint->Weights[j].buffer_id; + const u32 vertex_id = joint->Weights[j].vertex_id; + LocalBuffers[buffer_id]->getVertex(vertex_id)->Pos = joint->Weights[j].StaticPos; + LocalBuffers[buffer_id]->getVertex(vertex_id)->Normal = joint->Weights[j].StaticNormal; + LocalBuffers[buffer_id]->boundingBoxNeedsRecalculated(); + } + } + } + + HardwareSkinning = on; + } + return HardwareSkinning; +} + +void CSkinnedMesh::refreshJointCache() +{ + // copy cache from the mesh... + for (u32 i = 0; i < AllJoints.size(); ++i) { + SJoint *joint = AllJoints[i]; + for (u32 j = 0; j < joint->Weights.size(); ++j) { + const u16 buffer_id = joint->Weights[j].buffer_id; + const u32 vertex_id = joint->Weights[j].vertex_id; + joint->Weights[j].StaticPos = LocalBuffers[buffer_id]->getVertex(vertex_id)->Pos; + joint->Weights[j].StaticNormal = LocalBuffers[buffer_id]->getVertex(vertex_id)->Normal; + } + } +} + +void CSkinnedMesh::resetAnimation() +{ + // copy from the cache to the mesh... + for (u32 i = 0; i < AllJoints.size(); ++i) { + SJoint *joint = AllJoints[i]; + for (u32 j = 0; j < joint->Weights.size(); ++j) { + const u16 buffer_id = joint->Weights[j].buffer_id; + const u32 vertex_id = joint->Weights[j].vertex_id; + LocalBuffers[buffer_id]->getVertex(vertex_id)->Pos = joint->Weights[j].StaticPos; + LocalBuffers[buffer_id]->getVertex(vertex_id)->Normal = joint->Weights[j].StaticNormal; + } + } + SkinnedLastFrame = false; + LastAnimatedFrame = -1; +} + +void CSkinnedMesh::calculateGlobalMatrices(SJoint *joint, SJoint *parentJoint) +{ + if (!joint && parentJoint) // bit of protection from endless loops + return; + + // Go through the root bones + if (!joint) { + for (u32 i = 0; i < RootJoints.size(); ++i) + calculateGlobalMatrices(RootJoints[i], 0); + return; + } + + if (!parentJoint) + joint->GlobalMatrix = joint->LocalMatrix; + else + joint->GlobalMatrix = parentJoint->GlobalMatrix * joint->LocalMatrix; + + joint->LocalAnimatedMatrix = joint->LocalMatrix; + joint->GlobalAnimatedMatrix = joint->GlobalMatrix; + + if (joint->GlobalInversedMatrix.isIdentity()) { // might be pre calculated + joint->GlobalInversedMatrix = joint->GlobalMatrix; + joint->GlobalInversedMatrix.makeInverse(); // slow + } + + for (u32 j = 0; j < joint->Children.size(); ++j) + calculateGlobalMatrices(joint->Children[j], joint); + SkinnedLastFrame = false; +} + +void CSkinnedMesh::checkForAnimation() +{ + u32 i, j; + // Check for animation... + HasAnimation = false; + for (i = 0; i < AllJoints.size(); ++i) { + if (AllJoints[i]->UseAnimationFrom) { + if (AllJoints[i]->UseAnimationFrom->PositionKeys.size() || + AllJoints[i]->UseAnimationFrom->ScaleKeys.size() || + AllJoints[i]->UseAnimationFrom->RotationKeys.size()) { + HasAnimation = true; + } + } + } + + // meshes with weights, are still counted as animated for ragdolls, etc + if (!HasAnimation) { + for (i = 0; i < AllJoints.size(); ++i) { + if (AllJoints[i]->Weights.size()) + HasAnimation = true; + } + } + + if (HasAnimation) { + //--- Find the length of the animation --- + EndFrame = 0; + for (i = 0; i < AllJoints.size(); ++i) { + if (AllJoints[i]->UseAnimationFrom) { + if (AllJoints[i]->UseAnimationFrom->PositionKeys.size()) + if (AllJoints[i]->UseAnimationFrom->PositionKeys.getLast().frame > EndFrame) + EndFrame = AllJoints[i]->UseAnimationFrom->PositionKeys.getLast().frame; + + if (AllJoints[i]->UseAnimationFrom->ScaleKeys.size()) + if (AllJoints[i]->UseAnimationFrom->ScaleKeys.getLast().frame > EndFrame) + EndFrame = AllJoints[i]->UseAnimationFrom->ScaleKeys.getLast().frame; + + if (AllJoints[i]->UseAnimationFrom->RotationKeys.size()) + if (AllJoints[i]->UseAnimationFrom->RotationKeys.getLast().frame > EndFrame) + EndFrame = AllJoints[i]->UseAnimationFrom->RotationKeys.getLast().frame; + } + } + } + + if (HasAnimation && !PreparedForSkinning) { + PreparedForSkinning = true; + + // check for bugs: + for (i = 0; i < AllJoints.size(); ++i) { + SJoint *joint = AllJoints[i]; + for (j = 0; j < joint->Weights.size(); ++j) { + const u16 buffer_id = joint->Weights[j].buffer_id; + const u32 vertex_id = joint->Weights[j].vertex_id; + + // check for invalid ids + if (buffer_id >= LocalBuffers.size()) { + os::Printer::log("Skinned Mesh: Weight buffer id too large", ELL_WARNING); + joint->Weights[j].buffer_id = joint->Weights[j].vertex_id = 0; + } else if (vertex_id >= LocalBuffers[buffer_id]->getVertexCount()) { + os::Printer::log("Skinned Mesh: Weight vertex id too large", ELL_WARNING); + joint->Weights[j].buffer_id = joint->Weights[j].vertex_id = 0; + } + } + } + + // An array used in skinning + + for (i = 0; i < Vertices_Moved.size(); ++i) + for (j = 0; j < Vertices_Moved[i].size(); ++j) + Vertices_Moved[i][j] = false; + + // For skinning: cache weight values for speed + + for (i = 0; i < AllJoints.size(); ++i) { + SJoint *joint = AllJoints[i]; + for (j = 0; j < joint->Weights.size(); ++j) { + const u16 buffer_id = joint->Weights[j].buffer_id; + const u32 vertex_id = joint->Weights[j].vertex_id; + + joint->Weights[j].Moved = &Vertices_Moved[buffer_id][vertex_id]; + joint->Weights[j].StaticPos = LocalBuffers[buffer_id]->getVertex(vertex_id)->Pos; + joint->Weights[j].StaticNormal = LocalBuffers[buffer_id]->getVertex(vertex_id)->Normal; + + // joint->Weights[j]._Pos=&Buffers[buffer_id]->getVertex(vertex_id)->Pos; + } + } + + // normalize weights + normalizeWeights(); + } + SkinnedLastFrame = false; +} + +//! called by loader after populating with mesh and bone data +void CSkinnedMesh::finalize() +{ + os::Printer::log("Skinned Mesh - finalize", ELL_DEBUG); + u32 i; + + // Make sure we recalc the next frame + LastAnimatedFrame = -1; + SkinnedLastFrame = false; + + // calculate bounding box + for (i = 0; i < LocalBuffers.size(); ++i) { + LocalBuffers[i]->recalculateBoundingBox(); + } + + if (AllJoints.size() || RootJoints.size()) { + // populate AllJoints or RootJoints, depending on which is empty + if (!RootJoints.size()) { + + for (u32 CheckingIdx = 0; CheckingIdx < AllJoints.size(); ++CheckingIdx) { + + bool foundParent = false; + for (i = 0; i < AllJoints.size(); ++i) { + for (u32 n = 0; n < AllJoints[i]->Children.size(); ++n) { + if (AllJoints[i]->Children[n] == AllJoints[CheckingIdx]) + foundParent = true; + } + } + + if (!foundParent) + RootJoints.push_back(AllJoints[CheckingIdx]); + } + } else { + AllJoints = RootJoints; + } + } + + for (i = 0; i < AllJoints.size(); ++i) { + AllJoints[i]->UseAnimationFrom = AllJoints[i]; + } + + // Set array sizes... + + for (i = 0; i < LocalBuffers.size(); ++i) { + Vertices_Moved.push_back(core::array()); + Vertices_Moved[i].set_used(LocalBuffers[i]->getVertexCount()); + } + + checkForAnimation(); + + if (HasAnimation) { + irr::u32 redundantPosKeys = 0; + irr::u32 unorderedPosKeys = 0; + irr::u32 redundantScaleKeys = 0; + irr::u32 unorderedScaleKeys = 0; + irr::u32 redundantRotationKeys = 0; + irr::u32 unorderedRotationKeys = 0; + + //--- optimize and check keyframes --- + for (i = 0; i < AllJoints.size(); ++i) { + core::array &PositionKeys = AllJoints[i]->PositionKeys; + core::array &ScaleKeys = AllJoints[i]->ScaleKeys; + core::array &RotationKeys = AllJoints[i]->RotationKeys; + + // redundant = identical middle keys - we only need the first and last frame + // unordered = frames which are out of order - we can't handle those + redundantPosKeys += dropMiddleKeys(PositionKeys, identicalPos); + unorderedPosKeys += dropBadKeys(PositionKeys); + redundantScaleKeys += dropMiddleKeys(ScaleKeys, identicalScale); + unorderedScaleKeys += dropBadKeys(ScaleKeys); + redundantRotationKeys += dropMiddleKeys(RotationKeys, identicalRotation); + unorderedRotationKeys += dropBadKeys(RotationKeys); + + // Fill empty keyframe areas + if (PositionKeys.size()) { + SPositionKey *Key; + Key = &PositionKeys[0]; // getFirst + if (Key->frame != 0) { + PositionKeys.push_front(*Key); + Key = &PositionKeys[0]; // getFirst + Key->frame = 0; + } + + Key = &PositionKeys.getLast(); + if (Key->frame != EndFrame) { + PositionKeys.push_back(*Key); + Key = &PositionKeys.getLast(); + Key->frame = EndFrame; + } + } + + if (ScaleKeys.size()) { + SScaleKey *Key; + Key = &ScaleKeys[0]; // getFirst + if (Key->frame != 0) { + ScaleKeys.push_front(*Key); + Key = &ScaleKeys[0]; // getFirst + Key->frame = 0; + } + + Key = &ScaleKeys.getLast(); + if (Key->frame != EndFrame) { + ScaleKeys.push_back(*Key); + Key = &ScaleKeys.getLast(); + Key->frame = EndFrame; + } + } + + if (RotationKeys.size()) { + SRotationKey *Key; + Key = &RotationKeys[0]; // getFirst + if (Key->frame != 0) { + RotationKeys.push_front(*Key); + Key = &RotationKeys[0]; // getFirst + Key->frame = 0; + } + + Key = &RotationKeys.getLast(); + if (Key->frame != EndFrame) { + RotationKeys.push_back(*Key); + Key = &RotationKeys.getLast(); + Key->frame = EndFrame; + } + } + } + + if (redundantPosKeys > 0) { + os::Printer::log("Skinned Mesh - redundant position frames kicked", core::stringc(redundantPosKeys).c_str(), ELL_DEBUG); + } + if (unorderedPosKeys > 0) { + irr::os::Printer::log("Skinned Mesh - unsorted position frames kicked", irr::core::stringc(unorderedPosKeys).c_str(), irr::ELL_DEBUG); + } + if (redundantScaleKeys > 0) { + os::Printer::log("Skinned Mesh - redundant scale frames kicked", core::stringc(redundantScaleKeys).c_str(), ELL_DEBUG); + } + if (unorderedScaleKeys > 0) { + irr::os::Printer::log("Skinned Mesh - unsorted scale frames kicked", irr::core::stringc(unorderedScaleKeys).c_str(), irr::ELL_DEBUG); + } + if (redundantRotationKeys > 0) { + os::Printer::log("Skinned Mesh - redundant rotation frames kicked", core::stringc(redundantRotationKeys).c_str(), ELL_DEBUG); + } + if (unorderedRotationKeys > 0) { + irr::os::Printer::log("Skinned Mesh - unsorted rotation frames kicked", irr::core::stringc(unorderedRotationKeys).c_str(), irr::ELL_DEBUG); + } + } + + // Needed for animation and skinning... + + calculateGlobalMatrices(0, 0); + + // animateMesh(0, 1); + // buildAllLocalAnimatedMatrices(); + // buildAllGlobalAnimatedMatrices(); + + // rigid animation for non animated meshes + for (i = 0; i < AllJoints.size(); ++i) { + for (u32 j = 0; j < AllJoints[i]->AttachedMeshes.size(); ++j) { + SSkinMeshBuffer *Buffer = (*SkinningBuffers)[AllJoints[i]->AttachedMeshes[j]]; + Buffer->Transformation = AllJoints[i]->GlobalAnimatedMatrix; + } + } + + // calculate bounding box + if (LocalBuffers.empty()) + BoundingBox.reset(0, 0, 0); + else { + irr::core::aabbox3df bb(LocalBuffers[0]->BoundingBox); + LocalBuffers[0]->Transformation.transformBoxEx(bb); + BoundingBox.reset(bb); + + for (u32 j = 1; j < LocalBuffers.size(); ++j) { + bb = LocalBuffers[j]->BoundingBox; + LocalBuffers[j]->Transformation.transformBoxEx(bb); + + BoundingBox.addInternalBox(bb); + } + } +} + +void CSkinnedMesh::updateBoundingBox(void) +{ + if (!SkinningBuffers) + return; + + core::array &buffer = *SkinningBuffers; + BoundingBox.reset(0, 0, 0); + + if (!buffer.empty()) { + for (u32 j = 0; j < buffer.size(); ++j) { + buffer[j]->recalculateBoundingBox(); + core::aabbox3df bb = buffer[j]->BoundingBox; + buffer[j]->Transformation.transformBoxEx(bb); + + BoundingBox.addInternalBox(bb); + } + } +} + +scene::SSkinMeshBuffer *CSkinnedMesh::addMeshBuffer() +{ + scene::SSkinMeshBuffer *buffer = new scene::SSkinMeshBuffer(); + LocalBuffers.push_back(buffer); + return buffer; +} + +CSkinnedMesh::SJoint *CSkinnedMesh::addJoint(SJoint *parent) +{ + SJoint *joint = new SJoint; + + AllJoints.push_back(joint); + if (!parent) { + // Add root joints to array in finalize() + } else { + // Set parent (Be careful of the mesh loader also setting the parent) + parent->Children.push_back(joint); + } + + return joint; +} + +CSkinnedMesh::SPositionKey *CSkinnedMesh::addPositionKey(SJoint *joint) +{ + if (!joint) + return 0; + + joint->PositionKeys.push_back(SPositionKey()); + return &joint->PositionKeys.getLast(); +} + +CSkinnedMesh::SScaleKey *CSkinnedMesh::addScaleKey(SJoint *joint) +{ + if (!joint) + return 0; + + joint->ScaleKeys.push_back(SScaleKey()); + return &joint->ScaleKeys.getLast(); +} + +CSkinnedMesh::SRotationKey *CSkinnedMesh::addRotationKey(SJoint *joint) +{ + if (!joint) + return 0; + + joint->RotationKeys.push_back(SRotationKey()); + return &joint->RotationKeys.getLast(); +} + +CSkinnedMesh::SWeight *CSkinnedMesh::addWeight(SJoint *joint) +{ + if (!joint) + return 0; + + joint->Weights.push_back(SWeight()); + return &joint->Weights.getLast(); +} + +bool CSkinnedMesh::isStatic() +{ + return !HasAnimation; +} + +void CSkinnedMesh::normalizeWeights() +{ + // note: unsure if weights ids are going to be used. + + // Normalise the weights on bones.... + + u32 i, j; + core::array> verticesTotalWeight; + + verticesTotalWeight.reallocate(LocalBuffers.size()); + for (i = 0; i < LocalBuffers.size(); ++i) { + verticesTotalWeight.push_back(core::array()); + verticesTotalWeight[i].set_used(LocalBuffers[i]->getVertexCount()); + } + + for (i = 0; i < verticesTotalWeight.size(); ++i) + for (j = 0; j < verticesTotalWeight[i].size(); ++j) + verticesTotalWeight[i][j] = 0; + + for (i = 0; i < AllJoints.size(); ++i) { + SJoint *joint = AllJoints[i]; + for (j = 0; j < joint->Weights.size(); ++j) { + if (joint->Weights[j].strength <= 0) { // Check for invalid weights + joint->Weights.erase(j); + --j; + } else { + verticesTotalWeight[joint->Weights[j].buffer_id][joint->Weights[j].vertex_id] += joint->Weights[j].strength; + } + } + } + + for (i = 0; i < AllJoints.size(); ++i) { + SJoint *joint = AllJoints[i]; + for (j = 0; j < joint->Weights.size(); ++j) { + const f32 total = verticesTotalWeight[joint->Weights[j].buffer_id][joint->Weights[j].vertex_id]; + if (total != 0 && total != 1) + joint->Weights[j].strength /= total; + } + } +} + +void CSkinnedMesh::recoverJointsFromMesh(core::array &jointChildSceneNodes) +{ + for (u32 i = 0; i < AllJoints.size(); ++i) { + IBoneSceneNode *node = jointChildSceneNodes[i]; + SJoint *joint = AllJoints[i]; + node->setPosition(joint->LocalAnimatedMatrix.getTranslation()); + node->setRotation(joint->LocalAnimatedMatrix.getRotationDegrees()); + node->setScale(joint->LocalAnimatedMatrix.getScale()); + + node->positionHint = joint->positionHint; + node->scaleHint = joint->scaleHint; + node->rotationHint = joint->rotationHint; + + node->updateAbsolutePosition(); + } +} + +void CSkinnedMesh::transferJointsToMesh(const core::array &jointChildSceneNodes) +{ + for (u32 i = 0; i < AllJoints.size(); ++i) { + const IBoneSceneNode *const node = jointChildSceneNodes[i]; + SJoint *joint = AllJoints[i]; + + joint->LocalAnimatedMatrix.setRotationDegrees(node->getRotation()); + joint->LocalAnimatedMatrix.setTranslation(node->getPosition()); + joint->LocalAnimatedMatrix *= core::matrix4().setScale(node->getScale()); + + joint->positionHint = node->positionHint; + joint->scaleHint = node->scaleHint; + joint->rotationHint = node->rotationHint; + + joint->GlobalSkinningSpace = (node->getSkinningSpace() == EBSS_GLOBAL); + } + // Make sure we recalc the next frame + LastAnimatedFrame = -1; + SkinnedLastFrame = false; +} + +void CSkinnedMesh::transferOnlyJointsHintsToMesh(const core::array &jointChildSceneNodes) +{ + for (u32 i = 0; i < AllJoints.size(); ++i) { + const IBoneSceneNode *const node = jointChildSceneNodes[i]; + SJoint *joint = AllJoints[i]; + + joint->positionHint = node->positionHint; + joint->scaleHint = node->scaleHint; + joint->rotationHint = node->rotationHint; + } + SkinnedLastFrame = false; +} + +void CSkinnedMesh::addJoints(core::array &jointChildSceneNodes, + IAnimatedMeshSceneNode *node, ISceneManager *smgr) +{ + // Create new joints + for (u32 i = 0; i < AllJoints.size(); ++i) { + jointChildSceneNodes.push_back(new CBoneSceneNode(0, smgr, 0, i, AllJoints[i]->Name)); + } + + // Match up parents + for (u32 i = 0; i < jointChildSceneNodes.size(); ++i) { + const SJoint *const joint = AllJoints[i]; // should be fine + + s32 parentID = -1; + + for (u32 j = 0; (parentID == -1) && (j < AllJoints.size()); ++j) { + if (i != j) { + const SJoint *const parentTest = AllJoints[j]; + for (u32 n = 0; n < parentTest->Children.size(); ++n) { + if (parentTest->Children[n] == joint) { + parentID = j; + break; + } + } + } + } + + IBoneSceneNode *bone = jointChildSceneNodes[i]; + if (parentID != -1) + bone->setParent(jointChildSceneNodes[parentID]); + else + bone->setParent(node); + + bone->drop(); + } + SkinnedLastFrame = false; +} + +void CSkinnedMesh::convertMeshToTangents() +{ + // now calculate tangents + for (u32 b = 0; b < LocalBuffers.size(); ++b) { + if (LocalBuffers[b]) { + LocalBuffers[b]->convertToTangents(); + + const s32 idxCnt = LocalBuffers[b]->getIndexCount(); + + u16 *idx = LocalBuffers[b]->getIndices(); + video::S3DVertexTangents *v = + (video::S3DVertexTangents *)LocalBuffers[b]->getVertices(); + + for (s32 i = 0; i < idxCnt; i += 3) { + calculateTangents( + v[idx[i + 0]].Normal, + v[idx[i + 0]].Tangent, + v[idx[i + 0]].Binormal, + v[idx[i + 0]].Pos, + v[idx[i + 1]].Pos, + v[idx[i + 2]].Pos, + v[idx[i + 0]].TCoords, + v[idx[i + 1]].TCoords, + v[idx[i + 2]].TCoords); + + calculateTangents( + v[idx[i + 1]].Normal, + v[idx[i + 1]].Tangent, + v[idx[i + 1]].Binormal, + v[idx[i + 1]].Pos, + v[idx[i + 2]].Pos, + v[idx[i + 0]].Pos, + v[idx[i + 1]].TCoords, + v[idx[i + 2]].TCoords, + v[idx[i + 0]].TCoords); + + calculateTangents( + v[idx[i + 2]].Normal, + v[idx[i + 2]].Tangent, + v[idx[i + 2]].Binormal, + v[idx[i + 2]].Pos, + v[idx[i + 0]].Pos, + v[idx[i + 1]].Pos, + v[idx[i + 2]].TCoords, + v[idx[i + 0]].TCoords, + v[idx[i + 1]].TCoords); + } + } + } +} + +void CSkinnedMesh::calculateTangents( + core::vector3df &normal, + core::vector3df &tangent, + core::vector3df &binormal, + const core::vector3df &vt1, const core::vector3df &vt2, const core::vector3df &vt3, // vertices + const core::vector2df &tc1, const core::vector2df &tc2, const core::vector2df &tc3) // texture coords +{ + core::vector3df v1 = vt1 - vt2; + core::vector3df v2 = vt3 - vt1; + normal = v2.crossProduct(v1); + normal.normalize(); + + // binormal + + f32 deltaX1 = tc1.X - tc2.X; + f32 deltaX2 = tc3.X - tc1.X; + binormal = (v1 * deltaX2) - (v2 * deltaX1); + binormal.normalize(); + + // tangent + + f32 deltaY1 = tc1.Y - tc2.Y; + f32 deltaY2 = tc3.Y - tc1.Y; + tangent = (v1 * deltaY2) - (v2 * deltaY1); + tangent.normalize(); + + // adjust + + core::vector3df txb = tangent.crossProduct(binormal); + if (txb.dotProduct(normal) < 0.0f) { + tangent *= -1.0f; + binormal *= -1.0f; + } +} + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CSkinnedMesh.h b/irr/src/CSkinnedMesh.h new file mode 100644 index 000000000..b0228c93b --- /dev/null +++ b/irr/src/CSkinnedMesh.h @@ -0,0 +1,212 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +// New skinned mesh + +#pragma once + +#include "ISkinnedMesh.h" +#include "SMeshBuffer.h" +#include "quaternion.h" + +namespace irr +{ +namespace scene +{ + +class IAnimatedMeshSceneNode; +class IBoneSceneNode; + +class CSkinnedMesh : public ISkinnedMesh +{ +public: + //! constructor + CSkinnedMesh(); + + //! destructor + virtual ~CSkinnedMesh(); + + //! returns the amount of frames. If the amount is 1, it is a static (=non animated) mesh. + u32 getFrameCount() const override; + + //! Gets the default animation speed of the animated mesh. + /** \return Amount of frames per second. If the amount is 0, it is a static, non animated mesh. */ + f32 getAnimationSpeed() const override; + + //! Gets the frame count of the animated mesh. + /** \param fps Frames per second to play the animation with. If the amount is 0, it is not animated. + The actual speed is set in the scene node the mesh is instantiated in.*/ + void setAnimationSpeed(f32 fps) override; + + //! returns the animated mesh based on a detail level (which is ignored) + IMesh *getMesh(s32 frame, s32 detailLevel = 255, s32 startFrameLoop = -1, s32 endFrameLoop = -1) override; + + //! Animates this mesh's joints based on frame input + //! blend: {0-old position, 1-New position} + void animateMesh(f32 frame, f32 blend) override; + + //! Preforms a software skin on this mesh based of joint positions + void skinMesh() override; + + //! returns amount of mesh buffers. + u32 getMeshBufferCount() const override; + + //! returns pointer to a mesh buffer + IMeshBuffer *getMeshBuffer(u32 nr) const override; + + //! Returns pointer to a mesh buffer which fits a material + /** \param material: material to search for + \return Returns the pointer to the mesh buffer or + NULL if there is no such mesh buffer. */ + IMeshBuffer *getMeshBuffer(const video::SMaterial &material) const override; + + //! returns an axis aligned bounding box + const core::aabbox3d &getBoundingBox() const override; + + //! set user axis aligned bounding box + void setBoundingBox(const core::aabbox3df &box) override; + + //! set the hardware mapping hint, for driver + void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer = EBT_VERTEX_AND_INDEX) override; + + //! flags the meshbuffer as changed, reloads hardware buffers + void setDirty(E_BUFFER_TYPE buffer = EBT_VERTEX_AND_INDEX) override; + + //! Returns the type of the animated mesh. + E_ANIMATED_MESH_TYPE getMeshType() const override; + + //! Gets joint count. + u32 getJointCount() const override; + + //! Gets the name of a joint. + const std::optional &getJointName(u32 number) const override; + + //! Gets a joint number from its name + std::optional getJointNumber(const std::string &name) const override; + + //! uses animation from another mesh + bool useAnimationFrom(const ISkinnedMesh *mesh) override; + + //! Update Normals when Animating + //! False= Don't (default) + //! True = Update normals, slower + void updateNormalsWhenAnimating(bool on) override; + + //! Sets Interpolation Mode + void setInterpolationMode(E_INTERPOLATION_MODE mode) override; + + //! Convertes the mesh to contain tangent information + void convertMeshToTangents() override; + + //! Does the mesh have no animation + bool isStatic() override; + + //! (This feature is not implemented in irrlicht yet) + bool setHardwareSkinning(bool on) override; + + //! Refreshes vertex data cached in joints such as positions and normals + void refreshJointCache() override; + + //! Moves the mesh into static position. + void resetAnimation() override; + + // Interface for the mesh loaders (finalize should lock these functions, and they should have some prefix like loader_ + // these functions will use the needed arrays, set values, etc to help the loaders + + //! exposed for loaders to add mesh buffers + core::array &getMeshBuffers() override; + + //! alternative method for adding joints + core::array &getAllJoints() override; + + //! alternative method for adding joints + const core::array &getAllJoints() const override; + + //! loaders should call this after populating the mesh + void finalize() override; + + //! Adds a new meshbuffer to the mesh, access it as last one + SSkinMeshBuffer *addMeshBuffer() override; + + //! Adds a new joint to the mesh, access it as last one + SJoint *addJoint(SJoint *parent = 0) override; + + //! Adds a new position key to the mesh, access it as last one + SPositionKey *addPositionKey(SJoint *joint) override; + //! Adds a new rotation key to the mesh, access it as last one + SRotationKey *addRotationKey(SJoint *joint) override; + //! Adds a new scale key to the mesh, access it as last one + SScaleKey *addScaleKey(SJoint *joint) override; + + //! Adds a new weight to the mesh, access it as last one + SWeight *addWeight(SJoint *joint) override; + + virtual void updateBoundingBox(void); + + //! Recovers the joints from the mesh + void recoverJointsFromMesh(core::array &jointChildSceneNodes); + + //! Tranfers the joint data to the mesh + void transferJointsToMesh(const core::array &jointChildSceneNodes); + + //! Tranfers the joint hints to the mesh + void transferOnlyJointsHintsToMesh(const core::array &jointChildSceneNodes); + + //! Creates an array of joints from this mesh as children of node + void addJoints(core::array &jointChildSceneNodes, + IAnimatedMeshSceneNode *node, + ISceneManager *smgr); + +private: + void checkForAnimation(); + + void normalizeWeights(); + + void buildAllLocalAnimatedMatrices(); + + void buildAllGlobalAnimatedMatrices(SJoint *Joint = 0, SJoint *ParentJoint = 0); + + void getFrameData(f32 frame, SJoint *Node, + core::vector3df &position, s32 &positionHint, + core::vector3df &scale, s32 &scaleHint, + core::quaternion &rotation, s32 &rotationHint); + + void calculateGlobalMatrices(SJoint *Joint, SJoint *ParentJoint); + + void skinJoint(SJoint *Joint, SJoint *ParentJoint); + + void calculateTangents(core::vector3df &normal, + core::vector3df &tangent, core::vector3df &binormal, + const core::vector3df &vt1, const core::vector3df &vt2, const core::vector3df &vt3, + const core::vector2df &tc1, const core::vector2df &tc2, const core::vector2df &tc3); + + core::array *SkinningBuffers; // Meshbuffer to skin, default is to skin localBuffers + + core::array LocalBuffers; + + core::array AllJoints; + core::array RootJoints; + + // bool can't be used here because std::vector + // doesn't allow taking a reference to individual elements. + core::array> Vertices_Moved; + + core::aabbox3d BoundingBox; + + f32 EndFrame; + f32 FramesPerSecond; + + f32 LastAnimatedFrame; + bool SkinnedLastFrame; + + E_INTERPOLATION_MODE InterpolationMode : 8; + + bool HasAnimation; + bool PreparedForSkinning; + bool AnimateNormals; + bool HardwareSkinning; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CTimer.h b/irr/src/CTimer.h new file mode 100644 index 000000000..950365cd5 --- /dev/null +++ b/irr/src/CTimer.h @@ -0,0 +1,96 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "ITimer.h" +#include "os.h" + +namespace irr +{ +//! Device independent implementation of the timer +class CTimer : public ITimer +{ +public: + CTimer() + { + os::Timer::initTimer(); + } + + //! Returns current real time in milliseconds of the system. + /** This value does not start with 0 when the application starts. + For example in one implementation the value returned could be the + amount of milliseconds which have elapsed since the system was started. */ + u32 getRealTime() const override + { + return os::Timer::getRealTime(); + } + + //! Returns current virtual time in milliseconds. + /** This value starts with 0 and can be manipulated using setTime(), stopTimer(), + startTimer(), etc. This value depends on the set speed of the timer if the timer + is stopped, etc. If you need the system time, use getRealTime() */ + u32 getTime() const override + { + return os::Timer::getTime(); + } + + //! sets current virtual time + void setTime(u32 time) override + { + os::Timer::setTime(time); + } + + //! Stops the game timer. + /** The timer is reference counted, which means everything which calls + stopTimer() will also have to call startTimer(), otherwise the timer may not start/stop + corretly again. */ + void stop() override + { + os::Timer::stopTimer(); + } + + //! Starts the game timer. + /** The timer is reference counted, which means everything which calls + stopTimer() will also have to call startTimer(), otherwise the timer may not start/stop + corretly again. */ + void start() override + { + os::Timer::startTimer(); + } + + //! Sets the speed of the timer + /** The speed is the factor with which the time is running faster or slower then the + real system time. */ + void setSpeed(f32 speed = 1.0f) override + { + os::Timer::setSpeed(speed); + } + + //! Returns current speed of the timer + /** The speed is the factor with which the time is running faster or slower then the + real system time. */ + f32 getSpeed() const override + { + return os::Timer::getSpeed(); + } + + //! Returns if game timer is currently stopped + bool isStopped() const override + { + bool ret = os::Timer::isStopped(); + return ret; + } + + //! Advances the virtual time + /** Makes the virtual timer update the time value based on the real time. This is + called automatically when calling IrrlichtDevice::run(), but you can call it manually + if you don't use this method. */ + void tick() override + { + os::Timer::tick(); + } +}; + +} // end namespace diff --git a/irr/src/CWGLManager.cpp b/irr/src/CWGLManager.cpp new file mode 100644 index 000000000..9c071a9e8 --- /dev/null +++ b/irr/src/CWGLManager.cpp @@ -0,0 +1,443 @@ +// Copyright (C) 2013 Christian Stehno +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#include "CWGLManager.h" + +#ifdef _IRR_COMPILE_WITH_WGL_MANAGER_ + +#include "os.h" + +#include +#include + +namespace irr +{ +namespace video +{ + +CWGLManager::CWGLManager() : + PrimaryContext(SExposedVideoData(0)), PixelFormat(0), libHandle(NULL) +{ +#ifdef _DEBUG + setDebugName("CWGLManager"); +#endif + memset(FunctionPointers, 0, sizeof(FunctionPointers)); +} + +CWGLManager::~CWGLManager() +{ +} + +bool CWGLManager::initialize(const SIrrlichtCreationParameters ¶ms, const SExposedVideoData &videodata) +{ + // store params, videoData is set later as it would be overwritten else + Params = params; + + // Create a window to test antialiasing support + const fschar_t *ClassName = __TEXT("CWGLManager"); + HINSTANCE lhInstance = GetModuleHandle(0); + + // Register Class + WNDCLASSEX wcex; + wcex.cbSize = sizeof(WNDCLASSEX); + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = (WNDPROC)DefWindowProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = lhInstance; + wcex.hIcon = 0; + wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + wcex.lpszMenuName = 0; + wcex.lpszClassName = ClassName; + wcex.hIconSm = 0; + RegisterClassEx(&wcex); + + RECT clientSize; + clientSize.top = 0; + clientSize.left = 0; + clientSize.right = Params.WindowSize.Width; + clientSize.bottom = Params.WindowSize.Height; + + DWORD style = WS_POPUP; + if (!Params.Fullscreen) + style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; + + AdjustWindowRect(&clientSize, style, FALSE); + + const s32 realWidth = clientSize.right - clientSize.left; + const s32 realHeight = clientSize.bottom - clientSize.top; + + const s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2; + const s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2; + + HWND temporary_wnd = CreateWindow(ClassName, __TEXT(""), style, windowLeft, + windowTop, realWidth, realHeight, NULL, NULL, lhInstance, NULL); + + if (!temporary_wnd) { + os::Printer::log("Cannot create a temporary window.", ELL_ERROR); + UnregisterClass(ClassName, lhInstance); + return false; + } + + HDC HDc = GetDC(temporary_wnd); + + // Set up pixel format descriptor with desired parameters + PIXELFORMATDESCRIPTOR tmp_pfd = { + sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor + 1, // Version Number + (DWORD)(PFD_DRAW_TO_WINDOW | // Format Must Support Window + PFD_SUPPORT_OPENGL | // Format Must Support OpenGL + (Params.Doublebuffer ? PFD_DOUBLEBUFFER : 0) | // Must Support Double Buffering + (Params.Stereobuffer ? PFD_STEREO : 0)), // Must Support Stereo Buffer + PFD_TYPE_RGBA, // Request An RGBA Format + Params.Bits, // Select Our Color Depth + 0, 0, 0, 0, 0, 0, // Color Bits Ignored + 0, // No Alpha Buffer + 0, // Shift Bit Ignored + 0, // No Accumulation Buffer + 0, 0, 0, 0, // Accumulation Bits Ignored + Params.ZBufferBits, // Z-Buffer (Depth Buffer) + BYTE(Params.Stencilbuffer ? 1 : 0), // Stencil Buffer Depth + 0, // No Auxiliary Buffer + PFD_MAIN_PLANE, // Main Drawing Layer + 0, // Reserved + 0, 0, 0 // Layer Masks Ignored + }; + pfd = tmp_pfd; + + for (u32 i = 0; i < 6; ++i) { + if (i == 1) { + if (Params.Stencilbuffer) { + os::Printer::log("Cannot create a GL device with stencil buffer, disabling stencil shadows.", ELL_WARNING); + Params.Stencilbuffer = false; + pfd.cStencilBits = 0; + } else + continue; + } else if (i == 2) { + pfd.cDepthBits = 24; + } else if (i == 3) { + if (Params.Bits != 16) + pfd.cDepthBits = 16; + else + continue; + } else if (i == 4) { + // try single buffer + if (Params.Doublebuffer) + pfd.dwFlags &= ~PFD_DOUBLEBUFFER; + else + continue; + } else if (i == 5) { + os::Printer::log("Cannot create a GL device context", "No suitable format for temporary window.", ELL_ERROR); + ReleaseDC(temporary_wnd, HDc); + DestroyWindow(temporary_wnd); + UnregisterClass(ClassName, lhInstance); + return false; + } + + // choose pixelformat + PixelFormat = ChoosePixelFormat(HDc, &pfd); + if (PixelFormat) + break; + } + + SetPixelFormat(HDc, PixelFormat, &pfd); + os::Printer::log("Create temporary GL rendering context", ELL_DEBUG); + HGLRC hrc = wglCreateContext(HDc); + if (!hrc) { + os::Printer::log("Cannot create a temporary GL rendering context.", ELL_ERROR); + ReleaseDC(temporary_wnd, HDc); + DestroyWindow(temporary_wnd); + UnregisterClass(ClassName, lhInstance); + return false; + } + + CurrentContext.OpenGLWin32.HDc = HDc; + CurrentContext.OpenGLWin32.HRc = hrc; + CurrentContext.OpenGLWin32.HWnd = temporary_wnd; + + if (!activateContext(CurrentContext, false)) { + os::Printer::log("Cannot activate a temporary GL rendering context.", ELL_ERROR); + wglDeleteContext(hrc); + ReleaseDC(temporary_wnd, HDc); + DestroyWindow(temporary_wnd); + UnregisterClass(ClassName, lhInstance); + return false; + } + + 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 + + // Without a GL context we can't call wglGetProcAddress so store this for later + FunctionPointers[0] = (void *)wglGetProcAddress("wglCreateContextAttribsARB"); + +#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. + + if (Params.AntiAlias > 32) + Params.AntiAlias = 32; + + f32 fAttributes[] = {0.0, 0.0}; + s32 iAttributes[] = { + WGL_DRAW_TO_WINDOW_ARB, 1, + WGL_SUPPORT_OPENGL_ARB, 1, + WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB, + WGL_COLOR_BITS_ARB, (Params.Bits == 32) ? 24 : 15, + WGL_ALPHA_BITS_ARB, (Params.Bits == 32) ? 8 : 1, + WGL_DEPTH_BITS_ARB, Params.ZBufferBits, // 10,11 + WGL_STENCIL_BITS_ARB, Params.Stencilbuffer ? 1 : 0, + WGL_DOUBLE_BUFFER_ARB, Params.Doublebuffer ? 1 : 0, + WGL_STEREO_ARB, Params.Stereobuffer ? 1 : 0, + WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB, +#ifdef WGL_ARB_multisample + WGL_SAMPLES_ARB, Params.AntiAlias, // 20,21 + WGL_SAMPLE_BUFFERS_ARB, (Params.AntiAlias > 0) ? 1 : 0, +#elif defined(WGL_EXT_multisample) + WGL_SAMPLES_EXT, AntiAlias, // 20,21 + WGL_SAMPLE_BUFFERS_EXT, (Params.AntiAlias > 0) ? 1 : 0, +#elif defined(WGL_3DFX_multisample) + WGL_SAMPLES_3DFX, AntiAlias, // 20,21 + WGL_SAMPLE_BUFFERS_3DFX, (Params.AntiAlias > 0) ? 1 : 0, +#endif + // WGL_DEPTH_FLOAT_EXT, 1, + 0, 0, 0, 0, + }; + int iAttrSize = sizeof(iAttributes) / sizeof(int); + if (!multi_sample_supported) { + memmove(&iAttributes[20], &iAttributes[24], sizeof(int) * (iAttrSize - 24)); + iAttrSize -= 4; + } + + s32 rv = 0; + // Try to get an acceptable pixel format + do { + int pixelFormat = 0; + UINT numFormats = 0; + const BOOL valid = wglChoosePixelFormat_ARB(HDc, iAttributes, fAttributes, 1, &pixelFormat, &numFormats); + + if (valid && numFormats) + rv = pixelFormat; + else + iAttributes[21] -= 1; + } while (rv == 0 && iAttributes[21] > 1); + if (rv) { + PixelFormat = rv; + Params.AntiAlias = iAttributes[21]; + } + } else +#endif + Params.AntiAlias = 0; + + // this only terminates the temporary HRc + destroyContext(); + destroySurface(); + terminate(); + DestroyWindow(temporary_wnd); + UnregisterClass(ClassName, lhInstance); + + // now get new window + CurrentContext.OpenGLWin32.HWnd = videodata.OpenGLWin32.HWnd; + // get hdc + if (!(CurrentContext.OpenGLWin32.HDc = GetDC((HWND)videodata.OpenGLWin32.HWnd))) { + os::Printer::log("Cannot create a GL device context.", ELL_ERROR); + return false; + } + if (!PrimaryContext.OpenGLWin32.HWnd) { + PrimaryContext.OpenGLWin32.HWnd = CurrentContext.OpenGLWin32.HWnd; + PrimaryContext.OpenGLWin32.HDc = CurrentContext.OpenGLWin32.HDc; + } + + return true; +} + +void CWGLManager::terminate() +{ + if (CurrentContext.OpenGLWin32.HDc) + ReleaseDC((HWND)CurrentContext.OpenGLWin32.HWnd, (HDC)CurrentContext.OpenGLWin32.HDc); + if (PrimaryContext.OpenGLWin32.HDc && PrimaryContext.OpenGLWin32.HDc == CurrentContext.OpenGLWin32.HDc) + memset(&PrimaryContext, 0, sizeof(PrimaryContext)); + memset(&CurrentContext, 0, sizeof(CurrentContext)); + if (libHandle) + FreeLibrary(libHandle); +} + +bool CWGLManager::generateSurface() +{ + HDC HDc = (HDC)CurrentContext.OpenGLWin32.HDc; + // search for pixel format the simple way + if (PixelFormat == 0 || (!SetPixelFormat(HDc, PixelFormat, &pfd))) { + for (u32 i = 0; i < 5; ++i) { + if (i == 1) { + if (Params.Stencilbuffer) { + os::Printer::log("Cannot create a GL device with stencil buffer, disabling stencil shadows.", ELL_WARNING); + Params.Stencilbuffer = false; + pfd.cStencilBits = 0; + } else + continue; + } else if (i == 2) { + pfd.cDepthBits = 24; + } + if (i == 3) { + if (Params.Bits != 16) + pfd.cDepthBits = 16; + else + continue; + } else if (i == 4) { + os::Printer::log("Cannot create a GL device context", "No suitable format.", ELL_ERROR); + return false; + } + + // choose pixelformat + PixelFormat = ChoosePixelFormat(HDc, &pfd); + if (PixelFormat) + break; + } + + // set pixel format + if (!SetPixelFormat(HDc, PixelFormat, &pfd)) { + os::Printer::log("Cannot set the pixel format.", ELL_ERROR); + return false; + } + } + + if (pfd.cAlphaBits != 0) { + if (pfd.cRedBits == 8) + ColorFormat = ECF_A8R8G8B8; + else + ColorFormat = ECF_A1R5G5B5; + } else { + if (pfd.cRedBits == 8) + ColorFormat = ECF_R8G8B8; + else + ColorFormat = ECF_R5G6B5; + } + os::Printer::log("Pixel Format", core::stringc(PixelFormat).c_str(), ELL_DEBUG); + return true; +} + +void CWGLManager::destroySurface() +{ +} + +bool CWGLManager::generateContext() +{ + HDC HDc = (HDC)CurrentContext.OpenGLWin32.HDc; + HGLRC hrc; + // create rendering context +#ifdef WGL_ARB_create_context + PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs_ARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)FunctionPointers[0]; + if (wglCreateContextAttribs_ARB) { + // with 3.0 all available profiles should be usable, higher versions impose restrictions + // we need at least 1.1 + const int iAttribs[] = { + WGL_CONTEXT_MAJOR_VERSION_ARB, 1, + WGL_CONTEXT_MINOR_VERSION_ARB, 1, + // WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB, // enable to get a debug context (depends on driver if that does anything) + 0, + }; + hrc = wglCreateContextAttribs_ARB(HDc, 0, iAttribs); + } else +#endif + hrc = wglCreateContext(HDc); + os::Printer::log("Irrlicht context"); + + if (!hrc) { + os::Printer::log("Cannot create a GL rendering context.", ELL_ERROR); + return false; + } + + // set exposed data + CurrentContext.OpenGLWin32.HRc = hrc; + if (!PrimaryContext.OpenGLWin32.HRc) + PrimaryContext.OpenGLWin32.HRc = CurrentContext.OpenGLWin32.HRc; + + return true; +} + +const SExposedVideoData &CWGLManager::getContext() const +{ + return CurrentContext; +} + +bool CWGLManager::activateContext(const SExposedVideoData &videoData, bool restorePrimaryOnZero) +{ + if (videoData.OpenGLWin32.HWnd && videoData.OpenGLWin32.HDc && videoData.OpenGLWin32.HRc) { + if (!wglMakeCurrent((HDC)videoData.OpenGLWin32.HDc, (HGLRC)videoData.OpenGLWin32.HRc)) { + os::Printer::log("Render Context switch failed."); + return false; + } + CurrentContext = videoData; + } else if (!restorePrimaryOnZero && !videoData.OpenGLWin32.HDc && !videoData.OpenGLWin32.HRc) { + if (!wglMakeCurrent((HDC)0, (HGLRC)0)) { + os::Printer::log("Render Context reset failed."); + return false; + } + CurrentContext = videoData; + } + // set back to main context + else if (!videoData.OpenGLWin32.HWnd && CurrentContext.OpenGLWin32.HDc != PrimaryContext.OpenGLWin32.HDc) { + if (!wglMakeCurrent((HDC)PrimaryContext.OpenGLWin32.HDc, (HGLRC)PrimaryContext.OpenGLWin32.HRc)) { + os::Printer::log("Render Context switch (back to main) failed."); + return false; + } + CurrentContext = PrimaryContext; + } + return true; +} + +void CWGLManager::destroyContext() +{ + if (CurrentContext.OpenGLWin32.HRc) { + if (!wglMakeCurrent((HDC)CurrentContext.OpenGLWin32.HDc, 0)) + os::Printer::log("Release of render context failed.", ELL_WARNING); + + if (!wglDeleteContext((HGLRC)CurrentContext.OpenGLWin32.HRc)) + os::Printer::log("Deletion of render context failed.", ELL_WARNING); + if (PrimaryContext.OpenGLWin32.HRc == CurrentContext.OpenGLWin32.HRc) + PrimaryContext.OpenGLWin32.HRc = 0; + CurrentContext.OpenGLWin32.HRc = 0; + } +} + +void *CWGLManager::getProcAddress(const std::string &procName) +{ + void *proc = NULL; + proc = (void *)wglGetProcAddress(procName.c_str()); + if (!proc) { // Fallback + if (!libHandle) + libHandle = LoadLibraryA("opengl32.dll"); + if (libHandle) + proc = (void *)GetProcAddress(libHandle, procName.c_str()); + } + return proc; +} + +bool CWGLManager::swapBuffers() +{ + return SwapBuffers((HDC)CurrentContext.OpenGLWin32.HDc) == TRUE; +} + +} +} + +#endif diff --git a/irr/src/CWGLManager.h b/irr/src/CWGLManager.h new file mode 100644 index 000000000..b8276d5f8 --- /dev/null +++ b/irr/src/CWGLManager.h @@ -0,0 +1,76 @@ +// Copyright (C) 2013 Christian Stehno +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#pragma once + +#ifdef _IRR_COMPILE_WITH_WGL_MANAGER_ + +#include "SIrrCreationParameters.h" +#include "SExposedVideoData.h" +#include "IContextManager.h" +#include "SColor.h" + +#define WIN32_LEAN_AND_MEAN +#include +#include + +namespace irr +{ +namespace video +{ +// WGL manager. +class CWGLManager : public IContextManager +{ +public: + //! Constructor. + CWGLManager(); + + //! Destructor + ~CWGLManager(); + + // Initialize + bool initialize(const SIrrlichtCreationParameters ¶ms, const SExposedVideoData &data) override; + + // Terminate + void terminate() override; + + // Create surface. + bool generateSurface() override; + + // Destroy surface. + void destroySurface() override; + + // Create context. + bool generateContext() override; + + // Destroy EGL context. + void destroyContext() override; + + //! Get current context + const SExposedVideoData &getContext() const override; + + //! Change render context, disable old and activate new defined by videoData + bool activateContext(const SExposedVideoData &videoData, bool restorePrimaryOnZero) override; + + // Get procedure address. + void *getProcAddress(const std::string &procName) override; + + // Swap buffers. + bool swapBuffers() override; + +private: + SIrrlichtCreationParameters Params; + SExposedVideoData PrimaryContext; + SExposedVideoData CurrentContext; + s32 PixelFormat; + PIXELFORMATDESCRIPTOR pfd; + ECOLOR_FORMAT ColorFormat; + void *FunctionPointers[1]; + + HMODULE libHandle; +}; +} +} + +#endif diff --git a/irr/src/CWriteFile.cpp b/irr/src/CWriteFile.cpp new file mode 100644 index 000000000..362b284ee --- /dev/null +++ b/irr/src/CWriteFile.cpp @@ -0,0 +1,106 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CWriteFile.h" +#include + +namespace irr +{ +namespace io +{ + +CWriteFile::CWriteFile(const io::path &fileName, bool append) : + Filename(fileName), FileSize(0) +{ +#ifdef _DEBUG + setDebugName("CWriteFile"); +#endif + + openFile(append); +} + +CWriteFile::~CWriteFile() +{ + if (File) + fclose(File); +} + +//! returns if file is open +inline bool CWriteFile::isOpen() const +{ + return File != 0; +} + +//! returns how much was read +size_t CWriteFile::write(const void *buffer, size_t sizeToWrite) +{ + if (!isOpen()) + return 0; + + return fwrite(buffer, 1, sizeToWrite, File); +} + +//! changes position in file, returns true if successful +//! if relativeMovement==true, the pos is changed relative to current pos, +//! otherwise from begin of file +bool CWriteFile::seek(long finalPos, bool relativeMovement) +{ + if (!isOpen()) + return false; + + return fseek(File, finalPos, relativeMovement ? SEEK_CUR : SEEK_SET) == 0; +} + +//! returns where in the file we are. +long CWriteFile::getPos() const +{ + return ftell(File); +} + +//! opens the file +void CWriteFile::openFile(bool append) +{ + if (Filename.size() == 0) { + File = 0; + return; + } + + File = fopen(Filename.c_str(), append ? "ab" : "wb"); + + if (File) { + // get FileSize + + fseek(File, 0, SEEK_END); + FileSize = ftell(File); + fseek(File, 0, SEEK_SET); + } +} + +//! returns name of file +const io::path &CWriteFile::getFileName() const +{ + return Filename; +} + +//! Flush the content of the buffer in the file +bool CWriteFile::flush() +{ + if (!isOpen()) + return false; + + return fflush(File) == 0; // 0 indicates success, otherwise EOF and errno is set +} + +IWriteFile *CWriteFile::createWriteFile(const io::path &fileName, bool append) +{ + CWriteFile *file = new CWriteFile(fileName, append); + if (file->isOpen()) + return file; + + file->drop(); + return 0; +} + +} // end namespace io +} // end namespace irr diff --git a/irr/src/CWriteFile.h b/irr/src/CWriteFile.h new file mode 100644 index 000000000..20bca0894 --- /dev/null +++ b/irr/src/CWriteFile.h @@ -0,0 +1,58 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include +#include "IWriteFile.h" +#include "irrString.h" + +namespace irr +{ + +namespace io +{ + +/*! + Class for writing a real file to disk. +*/ +class CWriteFile : public IWriteFile +{ +public: + CWriteFile(const io::path &fileName, bool append); + + virtual ~CWriteFile(); + + //! Reads an amount of bytes from the file. + size_t write(const void *buffer, size_t sizeToWrite) override; + + //! Changes position in file, returns true if successful. + bool seek(long finalPos, bool relativeMovement = false) override; + + //! Returns the current position in the file. + long getPos() const override; + + //! Returns name of file. + const io::path &getFileName() const override; + + //! Flush the content of the buffer in the file + bool flush() override; + + //! returns if file is open + bool isOpen() const; + + //! creator method + static IWriteFile *createWriteFile(const io::path &fileName, bool append); + +private: + //! opens the file + void openFile(bool append); + + io::path Filename; + FILE *File; + long FileSize; +}; + +} // end namespace io +} // end namespace irr diff --git a/irr/src/CXMeshFileLoader.cpp b/irr/src/CXMeshFileLoader.cpp new file mode 100644 index 000000000..5978980f4 --- /dev/null +++ b/irr/src/CXMeshFileLoader.cpp @@ -0,0 +1,2042 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CXMeshFileLoader.h" +#include "os.h" + +#include "fast_atof.h" +#include "coreutil.h" +#include "ISceneManager.h" +#include "IVideoDriver.h" +#include "IReadFile.h" + +#ifdef _DEBUG +#define _XREADER_DEBUG +#endif +// #define BETTER_MESHBUFFER_SPLITTING_FOR_X + +#define SET_ERR_AND_RETURN() \ + do { \ + ErrorState = true; \ + return false; \ + } while (0) + +namespace irr +{ +namespace scene +{ + +//! Constructor +CXMeshFileLoader::CXMeshFileLoader(scene::ISceneManager *smgr) : + AnimatedMesh(0), Buffer(0), P(0), End(0), BinaryNumCount(0), Line(0), ErrorState(false), + CurFrame(0), MajorVersion(0), MinorVersion(0), BinaryFormat(false), FloatSize(0) +{ +#ifdef _DEBUG + setDebugName("CXMeshFileLoader"); +#endif +} + +//! returns true if the file maybe is able to be loaded by this class +//! based on the file extension (e.g. ".bsp") +bool CXMeshFileLoader::isALoadableFileExtension(const io::path &filename) const +{ + return core::hasFileExtension(filename, "x"); +} + +//! creates/loads an animated mesh from the file. +//! \return Pointer to the created mesh. Returns 0 if loading failed. +//! If you no longer need the mesh, you should call IAnimatedMesh::drop(). +//! See IReferenceCounted::drop() for more information. +IAnimatedMesh *CXMeshFileLoader::createMesh(io::IReadFile *file) +{ + if (!file) + return 0; + +#ifdef _XREADER_DEBUG + u32 time = os::Timer::getRealTime(); +#endif + + AnimatedMesh = new CSkinnedMesh(); + + if (load(file)) { + AnimatedMesh->finalize(); + } else { + AnimatedMesh->drop(); + AnimatedMesh = 0; + } +#ifdef _XREADER_DEBUG + time = os::Timer::getRealTime() - time; + core::stringc tmpString = "Time to load "; + tmpString += BinaryFormat ? "binary" : "ascii"; + tmpString += " X file: "; + tmpString += time; + tmpString += "ms"; + os::Printer::log(tmpString.c_str()); +#endif + // Clear up + + MajorVersion = 0; + MinorVersion = 0; + BinaryFormat = 0; + BinaryNumCount = 0; + FloatSize = 0; + P = 0; + End = 0; + CurFrame = 0; + + delete[] Buffer; + Buffer = 0; + + for (u32 i = 0; i < Meshes.size(); ++i) + delete Meshes[i]; + Meshes.clear(); + + return AnimatedMesh; +} + +bool CXMeshFileLoader::load(io::IReadFile *file) +{ + if (!readFileIntoMemory(file)) + return false; + + if (!parseFile()) + return false; + + for (u32 n = 0; n < Meshes.size(); ++n) { + SXMesh *mesh = Meshes[n]; + + // default material if nothing loaded + if (!mesh->Materials.size()) { + mesh->Materials.push_back(video::SMaterial()); + mesh->Materials[0].DiffuseColor.set(0xff777777); + mesh->Materials[0].Shininess = 0.f; + mesh->Materials[0].SpecularColor.set(0xff777777); + mesh->Materials[0].EmissiveColor.set(0xff000000); + } + + u32 i; + + mesh->Buffers.reallocate(mesh->Materials.size()); +#ifndef BETTER_MESHBUFFER_SPLITTING_FOR_X + const u32 bufferOffset = AnimatedMesh->getMeshBufferCount(); +#endif + for (i = 0; i < mesh->Materials.size(); ++i) { + mesh->Buffers.push_back(AnimatedMesh->addMeshBuffer()); + mesh->Buffers.getLast()->Material = mesh->Materials[i]; + + if (!mesh->HasSkinning) { + // Set up rigid animation + if (mesh->AttachedJointID != -1) { + AnimatedMesh->getAllJoints()[mesh->AttachedJointID]->AttachedMeshes.push_back(AnimatedMesh->getMeshBuffers().size() - 1); + } + } + } + + if (!mesh->FaceMaterialIndices.size()) { + mesh->FaceMaterialIndices.set_used(mesh->Indices.size() / 3); + for (i = 0; i < mesh->FaceMaterialIndices.size(); ++i) + mesh->FaceMaterialIndices[i] = 0; + } + + if (!mesh->HasVertexColors) { + for (u32 j = 0; j < mesh->FaceMaterialIndices.size(); ++j) { + for (u32 id = j * 3 + 0; id <= j * 3 + 2; ++id) { + mesh->Vertices[mesh->Indices[id]].Color = mesh->Buffers[mesh->FaceMaterialIndices[j]]->Material.DiffuseColor; + } + } + } + +#ifdef BETTER_MESHBUFFER_SPLITTING_FOR_X + { + // the same vertex can be used in many different meshbuffers, but it's slow to work out + + core::array> verticesLinkIndex; + verticesLinkIndex.reallocate(mesh->Vertices.size()); + core::array> verticesLinkBuffer; + verticesLinkBuffer.reallocate(mesh->Vertices.size()); + + for (i = 0; i < mesh->Vertices.size(); ++i) { + verticesLinkIndex.push_back(core::array()); + verticesLinkBuffer.push_back(core::array()); + } + + for (i = 0; i < mesh->FaceMaterialIndices.size(); ++i) { + for (u32 id = i * 3 + 0; id <= i * 3 + 2; ++id) { + core::array &Array = verticesLinkBuffer[mesh->Indices[id]]; + bool found = false; + + for (u32 j = 0; j < Array.size(); ++j) { + if (Array[j] == mesh->FaceMaterialIndices[i]) { + found = true; + break; + } + } + + if (!found) + Array.push_back(mesh->FaceMaterialIndices[i]); + } + } + + for (i = 0; i < verticesLinkBuffer.size(); ++i) { + if (!verticesLinkBuffer[i].size()) + verticesLinkBuffer[i].push_back(0); + } + + for (i = 0; i < mesh->Vertices.size(); ++i) { + core::array &Array = verticesLinkBuffer[i]; + verticesLinkIndex[i].reallocate(Array.size()); + for (u32 j = 0; j < Array.size(); ++j) { + scene::SSkinMeshBuffer *buffer = mesh->Buffers[Array[j]]; + verticesLinkIndex[i].push_back(buffer->Vertices_Standard.size()); + buffer->Vertices_Standard.push_back(mesh->Vertices[i]); + } + } + + for (i = 0; i < mesh->FaceMaterialIndices.size(); ++i) { + scene::SSkinMeshBuffer *buffer = mesh->Buffers[mesh->FaceMaterialIndices[i]]; + + for (u32 id = i * 3 + 0; id <= i * 3 + 2; ++id) { + core::array &Array = verticesLinkBuffer[mesh->Indices[id]]; + + for (u32 j = 0; j < Array.size(); ++j) { + if (Array[j] == mesh->FaceMaterialIndices[i]) + buffer->Indices.push_back(verticesLinkIndex[mesh->Indices[id]][j]); + } + } + } + + for (u32 j = 0; j < mesh->WeightJoint.size(); ++j) { + ISkinnedMesh::SJoint *joint = AnimatedMesh->getAllJoints()[mesh->WeightJoint[j]]; + ISkinnedMesh::SWeight &weight = joint->Weights[mesh->WeightNum[j]]; + + u32 id = weight.vertex_id; + + if (id >= verticesLinkIndex.size()) { + os::Printer::log("X loader: Weight id out of range", ELL_WARNING); + id = 0; + weight.strength = 0.f; + } + + if (verticesLinkBuffer[id].size() == 1) { + weight.vertex_id = verticesLinkIndex[id][0]; + weight.buffer_id = verticesLinkBuffer[id][0]; + } else if (verticesLinkBuffer[id].size() != 0) { + for (u32 k = 1; k < verticesLinkBuffer[id].size(); ++k) { + ISkinnedMesh::SWeight *WeightClone = AnimatedMesh->addWeight(joint); + WeightClone->strength = weight.strength; + WeightClone->vertex_id = verticesLinkIndex[id][k]; + WeightClone->buffer_id = verticesLinkBuffer[id][k]; + } + } + } + } +#else + { + core::array verticesLinkIndex; + core::array verticesLinkBuffer; + verticesLinkBuffer.set_used(mesh->Vertices.size()); + + // init with 0 + for (i = 0; i < mesh->Vertices.size(); ++i) { + // watch out for vertices which are not part of the mesh + // they will keep the -1 and can lead to out-of-bounds access + verticesLinkBuffer[i] = -1; + } + + bool warned = false; + // store meshbuffer number per vertex + for (i = 0; i < mesh->FaceMaterialIndices.size(); ++i) { + for (u32 id = i * 3 + 0; id <= i * 3 + 2; ++id) { + if ((verticesLinkBuffer[mesh->Indices[id]] != -1) && (verticesLinkBuffer[mesh->Indices[id]] != (s16)mesh->FaceMaterialIndices[i])) { + if (!warned) { + os::Printer::log("X loader", "Duplicated vertex, animation might be corrupted.", ELL_WARNING); + warned = true; + } + const u32 tmp = mesh->Vertices.size(); + mesh->Vertices.push_back(mesh->Vertices[mesh->Indices[id]]); + mesh->Indices[id] = tmp; + verticesLinkBuffer.set_used(mesh->Vertices.size()); + } + verticesLinkBuffer[mesh->Indices[id]] = mesh->FaceMaterialIndices[i]; + } + } + + if (mesh->FaceMaterialIndices.size() != 0) { + // store vertices in buffers and remember relation in verticesLinkIndex + u32 *vCountArray = new u32[mesh->Buffers.size()]; + memset(vCountArray, 0, mesh->Buffers.size() * sizeof(u32)); + // count vertices in each buffer and reallocate + for (i = 0; i < mesh->Vertices.size(); ++i) { + if (verticesLinkBuffer[i] != -1) + ++vCountArray[verticesLinkBuffer[i]]; + } + if (mesh->TCoords2.size()) { + for (i = 0; i != mesh->Buffers.size(); ++i) { + mesh->Buffers[i]->Vertices_2TCoords.reallocate(vCountArray[i]); + mesh->Buffers[i]->VertexType = video::EVT_2TCOORDS; + } + } else { + for (i = 0; i != mesh->Buffers.size(); ++i) + mesh->Buffers[i]->Vertices_Standard.reallocate(vCountArray[i]); + } + + verticesLinkIndex.set_used(mesh->Vertices.size()); + // actually store vertices + for (i = 0; i < mesh->Vertices.size(); ++i) { + // if a vertex is missing for some reason, just skip it + if (verticesLinkBuffer[i] == -1) + continue; + scene::SSkinMeshBuffer *buffer = mesh->Buffers[verticesLinkBuffer[i]]; + + if (mesh->TCoords2.size()) { + verticesLinkIndex[i] = buffer->Vertices_2TCoords.size(); + buffer->Vertices_2TCoords.push_back(mesh->Vertices[i]); + // We have a problem with correct tcoord2 handling here + // crash fixed for now by checking the values + buffer->Vertices_2TCoords.getLast().TCoords2 = (i < mesh->TCoords2.size()) ? mesh->TCoords2[i] : mesh->Vertices[i].TCoords; + } else { + verticesLinkIndex[i] = buffer->Vertices_Standard.size(); + buffer->Vertices_Standard.push_back(mesh->Vertices[i]); + } + } + + // count indices per buffer and reallocate + memset(vCountArray, 0, mesh->Buffers.size() * sizeof(u32)); + for (i = 0; i < mesh->FaceMaterialIndices.size(); ++i) + ++vCountArray[mesh->FaceMaterialIndices[i]]; + for (i = 0; i != mesh->Buffers.size(); ++i) + mesh->Buffers[i]->Indices.reallocate(vCountArray[i]); + delete[] vCountArray; + // create indices per buffer + for (i = 0; i < mesh->FaceMaterialIndices.size(); ++i) { + scene::SSkinMeshBuffer *buffer = mesh->Buffers[mesh->FaceMaterialIndices[i]]; + for (u32 id = i * 3 + 0; id != i * 3 + 3; ++id) { + buffer->Indices.push_back(verticesLinkIndex[mesh->Indices[id]]); + } + } + } + + for (u32 j = 0; j < mesh->WeightJoint.size(); ++j) { + ISkinnedMesh::SWeight &weight = (AnimatedMesh->getAllJoints()[mesh->WeightJoint[j]]->Weights[mesh->WeightNum[j]]); + + u32 id = weight.vertex_id; + + if (id >= verticesLinkIndex.size()) { + os::Printer::log("X loader: Weight id out of range", ELL_WARNING); + id = 0; + weight.strength = 0.f; + } + + weight.vertex_id = verticesLinkIndex[id]; + weight.buffer_id = verticesLinkBuffer[id] + bufferOffset; + } + } +#endif + } + + return true; +} + +//! Reads file into memory +bool CXMeshFileLoader::readFileIntoMemory(io::IReadFile *file) +{ + const long size = file->getSize(); + if (size < 12) { + os::Printer::log("X File is too small.", ELL_WARNING); + return false; + } + + Buffer = new c8[size + 1]; + Buffer[size] = 0x0; // null-terminate + + //! read all into memory + if (file->read(Buffer, size) != static_cast(size)) { + os::Printer::log("Could not read from x file.", ELL_WARNING); + return false; + } + + Line = 1; + End = Buffer + size; + + //! check header "xof " + if (strncmp(Buffer, "xof ", 4) != 0) { + os::Printer::log("Not an x file, wrong header.", ELL_WARNING); + return false; + } + + //! read minor and major version, e.g. 0302 or 0303 + c8 tmp[3]; + tmp[0] = Buffer[4]; + tmp[1] = Buffer[5]; + tmp[2] = 0x0; + MajorVersion = core::strtoul10(tmp); + + tmp[0] = Buffer[6]; + tmp[1] = Buffer[7]; + MinorVersion = core::strtoul10(tmp); + + //! read format + if (strncmp(&Buffer[8], "txt ", 4) == 0) + BinaryFormat = false; + else if (strncmp(&Buffer[8], "bin ", 4) == 0) + BinaryFormat = true; + else { + os::Printer::log("Only uncompressed x files currently supported.", ELL_WARNING); + return false; + } + BinaryNumCount = 0; + + //! read float size + if (strncmp(&Buffer[12], "0032", 4) == 0) + FloatSize = 4; + else if (strncmp(&Buffer[12], "0064", 4) == 0) + FloatSize = 8; + else { + os::Printer::log("Float size not supported.", ELL_WARNING); + return false; + } + + P = &Buffer[16]; + + readUntilEndOfLine(); + + return true; +} + +//! Parses the file +bool CXMeshFileLoader::parseFile() +{ + while (parseDataObject()) { + // loop + } + + return !ErrorState; +} + +//! Parses the next Data object in the file +bool CXMeshFileLoader::parseDataObject() +{ + core::stringc objectName = getNextToken(); + + if (objectName.size() == 0) + return false; + + // parse specific object +#ifdef _XREADER_DEBUG + os::Printer::log("debug DataObject", objectName.c_str(), ELL_DEBUG); +#endif + + if (objectName == "template") + return parseDataObjectTemplate(); + else if (objectName == "Frame") { + return parseDataObjectFrame(0); + } else if (objectName == "Mesh") { + // some meshes have no frames at all + // CurFrame = AnimatedMesh->addJoint(0); + + SXMesh *mesh = new SXMesh; + + // mesh->Buffer=AnimatedMesh->addMeshBuffer(); + Meshes.push_back(mesh); + + return parseDataObjectMesh(*mesh); + } else if (objectName == "AnimationSet") { + return parseDataObjectAnimationSet(); + } else if (objectName == "AnimTicksPerSecond") { + return parseDataObjectAnimationTicksPerSecond(); + } else if (objectName == "Material") { + return parseUnknownDataObject(); + } else if (objectName == "}") { + os::Printer::log("} found in dataObject", ELL_WARNING); + return true; + } + + os::Printer::log("Unknown data object in animation of .x file", objectName.c_str(), ELL_WARNING); + + return parseUnknownDataObject(); +} + +bool CXMeshFileLoader::parseDataObjectTemplate() +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: Reading template", ELL_DEBUG); +#endif + + // parse a template data object. Currently not stored. + core::stringc name; + + if (!readHeadOfDataObject(&name)) { + os::Printer::log("Left delimiter in template data object missing.", + name.c_str(), ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + // read GUID + getNextToken(); + + // read and ignore data members + while (true) { + core::stringc s = getNextToken(); + + if (s == "}") + break; + + if (s.size() == 0) + return false; + } + + return true; +} + +bool CXMeshFileLoader::parseDataObjectFrame(CSkinnedMesh::SJoint *Parent) +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: Reading frame", ELL_DEBUG); +#endif + + // A coordinate frame, or "frame of reference." The Frame template + // is open and can contain any object. The Direct3D extensions (D3DX) + // mesh-loading functions recognize Mesh, FrameTransformMatrix, and + // Frame template instances as child objects when loading a Frame + // instance. + + u32 JointID = 0; + + core::stringc name; + + if (!readHeadOfDataObject(&name)) { + os::Printer::log("No opening brace in Frame found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + CSkinnedMesh::SJoint *joint = 0; + + if (name.size()) { + auto n = AnimatedMesh->getJointNumber(name.c_str()); + if (n.has_value()) { + JointID = *n; + joint = AnimatedMesh->getAllJoints()[JointID]; + } + } + + if (!joint) { +#ifdef _XREADER_DEBUG + os::Printer::log("creating joint ", name.c_str(), ELL_DEBUG); +#endif + joint = AnimatedMesh->addJoint(Parent); + joint->Name = name.c_str(); + JointID = AnimatedMesh->getAllJoints().size() - 1; + } else { +#ifdef _XREADER_DEBUG + os::Printer::log("using joint ", name.c_str(), ELL_DEBUG); +#endif + if (Parent) + Parent->Children.push_back(joint); + } + + // Now inside a frame. + // read tokens until closing brace is reached. + + while (true) { + core::stringc objectName = getNextToken(); + +#ifdef _XREADER_DEBUG + os::Printer::log("debug DataObject in frame:", objectName.c_str(), ELL_DEBUG); +#endif + + if (objectName.size() == 0) { + os::Printer::log("Unexpected ending found in Frame in x file.", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } else if (objectName == "}") { + break; // frame finished + } else if (objectName == "Frame") { + + if (!parseDataObjectFrame(joint)) + return false; + } else if (objectName == "FrameTransformMatrix") { + if (!parseDataObjectTransformationMatrix(joint->LocalMatrix)) + return false; + + // joint->LocalAnimatedMatrix + // joint->LocalAnimatedMatrix.makeInverse(); + // joint->LocalMatrix=tmp*joint->LocalAnimatedMatrix; + } else if (objectName == "Mesh") { + /* + frame.Meshes.push_back(SXMesh()); + if (!parseDataObjectMesh(frame.Meshes.getLast())) + return false; + */ + SXMesh *mesh = new SXMesh; + + mesh->AttachedJointID = JointID; + + Meshes.push_back(mesh); + + if (!parseDataObjectMesh(*mesh)) + return false; + } else { + os::Printer::log("Unknown data object in frame in x file", objectName.c_str(), ELL_WARNING); + if (!parseUnknownDataObject()) + return false; + } + } + + return true; +} + +bool CXMeshFileLoader::parseDataObjectTransformationMatrix(core::matrix4 &mat) +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: Reading Transformation Matrix", ELL_DEBUG); +#endif + + if (!readHeadOfDataObject()) { + os::Printer::log("No opening brace in Transformation Matrix found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + readMatrix(mat); + + if (!checkForOneFollowingSemicolons()) { + os::Printer::log("No finishing semicolon in Transformation Matrix found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + } + + if (!checkForClosingBrace()) { + os::Printer::log("No closing brace in Transformation Matrix found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + return true; +} + +bool CXMeshFileLoader::parseDataObjectMesh(SXMesh &mesh) +{ + core::stringc name; + + if (!readHeadOfDataObject(&name)) { +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: Reading mesh", ELL_DEBUG); +#endif + os::Printer::log("No opening brace in Mesh found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: Reading mesh", name.c_str(), ELL_DEBUG); +#endif + + // read vertex count + const u32 nVertices = readInt(); + + // read vertices + mesh.Vertices.set_used(nVertices); + for (u32 n = 0; n < nVertices; ++n) { + readVector3(mesh.Vertices[n].Pos); + mesh.Vertices[n].Color = 0xFFFFFFFF; + mesh.Vertices[n].Normal = core::vector3df(0.0f); + } + + if (!checkForTwoFollowingSemicolons()) { + os::Printer::log("No finishing semicolon in Mesh Vertex Array found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + } + + // read faces + const u32 nFaces = readInt(); + + mesh.Indices.set_used(nFaces * 3); + mesh.IndexCountPerFace.set_used(nFaces); + + core::array polygonfaces; + u32 currentIndex = 0; + + for (u32 k = 0; k < nFaces; ++k) { + const u32 fcnt = readInt(); + + if (fcnt != 3) { + if (fcnt < 3) { + os::Printer::log("Invalid face count (<3) found in Mesh x file reader.", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + // read face indices + polygonfaces.set_used(fcnt); + u32 triangles = (fcnt - 2); + mesh.Indices.set_used(mesh.Indices.size() + ((triangles - 1) * 3)); + mesh.IndexCountPerFace[k] = (u16)(triangles * 3); + + for (u32 f = 0; f < fcnt; ++f) + polygonfaces[f] = readInt(); + + for (u32 jk = 0; jk < triangles; ++jk) { + mesh.Indices[currentIndex++] = polygonfaces[0]; + mesh.Indices[currentIndex++] = polygonfaces[jk + 1]; + mesh.Indices[currentIndex++] = polygonfaces[jk + 2]; + } + + // TODO: change face indices in material list + } else { + mesh.Indices[currentIndex++] = readInt(); + mesh.Indices[currentIndex++] = readInt(); + mesh.Indices[currentIndex++] = readInt(); + mesh.IndexCountPerFace[k] = 3; + } + } + + for (u32 j = 0; j < mesh.Indices.size(); j++) { + if (mesh.Indices[j] >= mesh.Vertices.size()) { + os::Printer::log("Out of range index found in Mesh x file reader.", ELL_WARNING); + SET_ERR_AND_RETURN(); + } + } + + if (!checkForTwoFollowingSemicolons()) { + os::Printer::log("No finishing semicolon in Mesh Face Array found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + } + + // here, other data objects may follow + + while (true) { + core::stringc objectName = getNextToken(); + + if (objectName.size() == 0) { + os::Printer::log("Unexpected ending found in Mesh in x file.", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } else if (objectName == "}") { + break; // mesh finished + } + +#ifdef _XREADER_DEBUG + os::Printer::log("debug DataObject in mesh", objectName.c_str(), ELL_DEBUG); +#endif + + if (objectName == "MeshNormals") { + if (!parseDataObjectMeshNormals(mesh)) + return false; + } else if (objectName == "MeshTextureCoords") { + if (!parseDataObjectMeshTextureCoords(mesh)) + return false; + } else if (objectName == "MeshVertexColors") { + if (!parseDataObjectMeshVertexColors(mesh)) + return false; + } else if (objectName == "MeshMaterialList") { + if (!parseDataObjectMeshMaterialList(mesh)) + return false; + } else if (objectName == "VertexDuplicationIndices") { + // we'll ignore vertex duplication indices + // TODO: read them + if (!parseUnknownDataObject()) + return false; + } else if (objectName == "DeclData") { + if (!readHeadOfDataObject()) { + os::Printer::log("No starting brace in DeclData found.", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + // arbitrary vertex attributes + // first comes the number of element definitions + // then the vertex element type definitions + // with format type;tesselator;semantics;usageindex + // we want to support 2;0;6;0 == tangent + // 2;0;7;0 == binormal + // 2;0;3;0 == normal + // 1/2;0;5;0 == 1st uv coord + // and 1/2;0;5;1 == 2nd uv coord + // type==2 is 3xf32, type==1 is 2xf32 + u32 j; + const u32 dcnt = readInt(); + u16 size = 0; + s16 normalpos = -1; + s16 uvpos = -1; + s16 uv2pos = -1; + s16 tangentpos = -1; + s16 binormalpos = -1; + s16 normaltype = -1; + s16 uvtype = -1; + s16 uv2type = -1; + s16 tangenttype = -1; + s16 binormaltype = -1; + + (void)tangentpos; // disable unused variable warnings + (void)binormalpos; // disable unused variable warnings + (void)tangenttype; // disable unused variable warnings + (void)binormaltype; // disable unused variable warnings + + for (j = 0; j < dcnt; ++j) { + const u32 type = readInt(); + // const u32 tesselator = readInt(); + readInt(); + const u32 semantics = readInt(); + const u32 index = readInt(); + switch (semantics) { + case 3: + normalpos = size; + normaltype = type; + break; + case 5: + if (index == 0) { + uvpos = size; + uvtype = type; + } else if (index == 1) { + uv2pos = size; + uv2type = type; + } + break; + case 6: + tangentpos = size; + tangenttype = type; + break; + case 7: + binormalpos = size; + binormaltype = type; + break; + default: + break; + } + switch (type) { + case 0: + size += 4; + break; + case 1: + size += 8; + break; + case 2: + size += 12; + break; + case 3: + size += 16; + break; + case 4: + case 5: + case 6: + size += 4; + break; + case 7: + size += 8; + break; + case 8: + case 9: + size += 4; + break; + case 10: + size += 8; + break; + case 11: + size += 4; + break; + case 12: + size += 8; + break; + case 13: + size += 4; + break; + case 14: + size += 4; + break; + case 15: + size += 4; + break; + case 16: + size += 8; + break; + } + } + const u32 datasize = readInt(); + u32 *data = new u32[datasize]; + for (j = 0; j < datasize; ++j) + data[j] = readInt(); + + if (!checkForOneFollowingSemicolons()) { + os::Printer::log("No finishing semicolon in DeclData found.", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + } + if (!checkForClosingBrace()) { + os::Printer::log("No closing brace in DeclData.", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + delete[] data; + SET_ERR_AND_RETURN(); + } + u8 *dataptr = (u8 *)data; + if ((uv2pos != -1) && (uv2type == 1)) + mesh.TCoords2.reallocate(mesh.Vertices.size()); + for (j = 0; j < mesh.Vertices.size(); ++j) { + if ((normalpos != -1) && (normaltype == 2)) + mesh.Vertices[j].Normal.set(*((core::vector3df *)(dataptr + normalpos))); + if ((uvpos != -1) && (uvtype == 1)) + mesh.Vertices[j].TCoords.set(*((core::vector2df *)(dataptr + uvpos))); + if ((uv2pos != -1) && (uv2type == 1)) + mesh.TCoords2.push_back(*((core::vector2df *)(dataptr + uv2pos))); + dataptr += size; + } + delete[] data; + } else if (objectName == "FVFData") { + if (!readHeadOfDataObject()) { + os::Printer::log("No starting brace in FVFData found.", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + const u32 dataformat = readInt(); + const u32 datasize = readInt(); + u32 *data = new u32[datasize]; + for (u32 j = 0; j < datasize; ++j) + data[j] = readInt(); + if (dataformat & 0x102) { // 2nd uv set + mesh.TCoords2.reallocate(mesh.Vertices.size()); + u8 *dataptr = (u8 *)data; + const u32 size = ((dataformat >> 8) & 0xf) * sizeof(core::vector2df); + for (u32 j = 0; j < mesh.Vertices.size(); ++j) { + mesh.TCoords2.push_back(*((core::vector2df *)(dataptr))); + dataptr += size; + } + } + delete[] data; + if (!checkForOneFollowingSemicolons()) { + os::Printer::log("No finishing semicolon in FVFData found.", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + } + if (!checkForClosingBrace()) { + os::Printer::log("No closing brace in FVFData found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + } else if (objectName == "XSkinMeshHeader") { + if (!parseDataObjectSkinMeshHeader(mesh)) + return false; + } else if (objectName == "SkinWeights") { + // mesh.SkinWeights.push_back(SXSkinWeight()); + // if (!parseDataObjectSkinWeights(mesh.SkinWeights.getLast())) + if (!parseDataObjectSkinWeights(mesh)) + return false; + } else { + os::Printer::log("Unknown data object in mesh in x file", objectName.c_str(), ELL_WARNING); + if (!parseUnknownDataObject()) + return false; + } + } + + return true; +} + +bool CXMeshFileLoader::parseDataObjectSkinWeights(SXMesh &mesh) +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: Reading mesh skin weights", ELL_DEBUG); +#endif + + if (!readHeadOfDataObject()) { + os::Printer::log("No opening brace in Skin Weights found in .x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + core::stringc TransformNodeName; + + if (!getNextTokenAsString(TransformNodeName)) { + os::Printer::log("Unknown syntax while reading transform node name string in .x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + mesh.HasSkinning = true; + + auto n = AnimatedMesh->getJointNumber(TransformNodeName.c_str()); + CSkinnedMesh::SJoint *joint = n.has_value() ? AnimatedMesh->getAllJoints()[*n] : nullptr; + + if (!joint) { +#ifdef _XREADER_DEBUG + os::Printer::log("creating joint for skinning ", TransformNodeName.c_str(), ELL_DEBUG); +#endif + n = AnimatedMesh->getAllJoints().size(); + joint = AnimatedMesh->addJoint(0); + joint->Name = TransformNodeName.c_str(); + } + + // read vertex weights + const u32 nWeights = readInt(); + + // read vertex indices + u32 i; + + const u32 jointStart = joint->Weights.size(); + joint->Weights.reallocate(jointStart + nWeights); + + mesh.WeightJoint.reallocate(mesh.WeightJoint.size() + nWeights); + mesh.WeightNum.reallocate(mesh.WeightNum.size() + nWeights); + + for (i = 0; i < nWeights; ++i) { + mesh.WeightJoint.push_back(*n); + mesh.WeightNum.push_back(joint->Weights.size()); + + CSkinnedMesh::SWeight *weight = AnimatedMesh->addWeight(joint); + + weight->buffer_id = 0; + weight->vertex_id = readInt(); + } + + // read vertex weights + + for (i = jointStart; i < jointStart + nWeights; ++i) + joint->Weights[i].strength = readFloat(); + + // read matrix offset + + // transforms the mesh vertices to the space of the bone + // When concatenated to the bone's transform, this provides the + // world space coordinates of the mesh as affected by the bone + core::matrix4 &MatrixOffset = joint->GlobalInversedMatrix; + + readMatrix(MatrixOffset); + + if (!checkForOneFollowingSemicolons()) { + os::Printer::log("No finishing semicolon in Skin Weights found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + } + + if (!checkForClosingBrace()) { + os::Printer::log("No closing brace in Skin Weights found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + return true; +} + +bool CXMeshFileLoader::parseDataObjectSkinMeshHeader(SXMesh &mesh) +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: Reading skin mesh header", ELL_DEBUG); +#endif + + if (!readHeadOfDataObject()) { + os::Printer::log("No opening brace in Skin Mesh header found in .x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + mesh.MaxSkinWeightsPerVertex = readInt(); + mesh.MaxSkinWeightsPerFace = readInt(); + mesh.BoneCount = readInt(); + + if (!BinaryFormat) + getNextToken(); // skip semicolon + + if (!checkForClosingBrace()) { + os::Printer::log("No closing brace in skin mesh header in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + return true; +} + +bool CXMeshFileLoader::parseDataObjectMeshNormals(SXMesh &mesh) +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: reading mesh normals", ELL_DEBUG); +#endif + + if (!readHeadOfDataObject()) { + os::Printer::log("No opening brace in Mesh Normals found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + // read count + const u32 nNormals = readInt(); + core::array normals; + normals.set_used(nNormals); + + // read normals + for (u32 i = 0; i < nNormals; ++i) + readVector3(normals[i]); + + if (!checkForTwoFollowingSemicolons()) { + os::Printer::log("No finishing semicolon in Mesh Normals Array found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + } + + core::array normalIndices; + normalIndices.set_used(mesh.Indices.size()); + + // read face normal indices + const u32 nFNormals = readInt(); + // if (nFNormals >= mesh.IndexCountPerFace.size()) + if (0) { // this condition doesn't work for some reason + os::Printer::log("Too many face normals found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + u32 normalidx = 0; + core::array polygonfaces; + for (u32 k = 0; k < nFNormals; ++k) { + const u32 fcnt = readInt(); + u32 triangles = fcnt - 2; + u32 indexcount = triangles * 3; + + if (indexcount != mesh.IndexCountPerFace[k]) { + os::Printer::log("Not matching normal and face index count found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + if (indexcount == 3) { + // default, only one triangle in this face + for (u32 h = 0; h < 3; ++h) { + const u32 normalnum = readInt(); + mesh.Vertices[mesh.Indices[normalidx++]].Normal.set(normals[normalnum]); + } + } else { + polygonfaces.set_used(fcnt); + // multiple triangles in this face + for (u32 h = 0; h < fcnt; ++h) + polygonfaces[h] = readInt(); + + for (u32 jk = 0; jk < triangles; ++jk) { + mesh.Vertices[mesh.Indices[normalidx++]].Normal.set(normals[polygonfaces[0]]); + mesh.Vertices[mesh.Indices[normalidx++]].Normal.set(normals[polygonfaces[jk + 1]]); + mesh.Vertices[mesh.Indices[normalidx++]].Normal.set(normals[polygonfaces[jk + 2]]); + } + } + } + + if (!checkForTwoFollowingSemicolons()) { + os::Printer::log("No finishing semicolon in Mesh Face Normals Array found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + } + + if (!checkForClosingBrace()) { + os::Printer::log("No closing brace in Mesh Normals found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + return true; +} + +bool CXMeshFileLoader::parseDataObjectMeshTextureCoords(SXMesh &mesh) +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: reading mesh texture coordinates", ELL_DEBUG); +#endif + + if (!readHeadOfDataObject()) { + os::Printer::log("No opening brace in Mesh Texture Coordinates found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + const u32 nCoords = readInt(); + // if (nCoords >= mesh.Vertices.size()) + if (0) { // this condition doesn't work for some reason + os::Printer::log("Too many texture coords found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + for (u32 i = 0; i < nCoords; ++i) + readVector2(mesh.Vertices[i].TCoords); + + if (!checkForTwoFollowingSemicolons()) { + os::Printer::log("No finishing semicolon in Mesh Texture Coordinates Array found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + } + + if (!checkForClosingBrace()) { + os::Printer::log("No closing brace in Mesh Texture Coordinates Array found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + return true; +} + +bool CXMeshFileLoader::parseDataObjectMeshVertexColors(SXMesh &mesh) +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: reading mesh vertex colors", ELL_DEBUG); +#endif + + if (!readHeadOfDataObject()) { + os::Printer::log("No opening brace for Mesh Vertex Colors found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + mesh.HasVertexColors = true; + const u32 nColors = readInt(); + for (u32 i = 0; i < nColors; ++i) { + const u32 Index = readInt(); + if (Index >= mesh.Vertices.size()) { + os::Printer::log("index value in parseDataObjectMeshVertexColors out of bounds", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + readRGBA(mesh.Vertices[Index].Color); + checkForOneFollowingSemicolons(); + } + + if (!checkForOneFollowingSemicolons()) { + os::Printer::log("No finishing semicolon in Mesh Vertex Colors Array found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + } + + if (!checkForClosingBrace()) { + os::Printer::log("No closing brace in Mesh Texture Coordinates Array found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + return false; + } + + return true; +} + +bool CXMeshFileLoader::parseDataObjectMeshMaterialList(SXMesh &mesh) +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: Reading mesh material list", ELL_DEBUG); +#endif + + if (!readHeadOfDataObject()) { + os::Printer::log("No opening brace in Mesh Material List found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + // read material count + const u32 nMaterials = readInt(); + mesh.Materials.reallocate(nMaterials); + + // read non triangulated face material index count + const u32 nFaceIndices = readInt(); + + // There seems to be a compact representation of "all faces the same material" + // being represented as 1;1;0;; which means 1 material, 1 face with first material + // all the other faces have to obey then, so check is disabled + // if (nFaceIndices != mesh.IndexCountPerFace.size()) + // os::Printer::log("Index count per face not equal to face material index count in x file.", ELL_WARNING); + + // read non triangulated face indices and create triangulated ones + mesh.FaceMaterialIndices.set_used(mesh.Indices.size() / 3); + u32 triangulatedindex = 0; + u32 ind = 0; + for (u32 tfi = 0; tfi < mesh.IndexCountPerFace.size(); ++tfi) { + if (tfi < nFaceIndices) + ind = readInt(); + if (ind >= core::max_(nMaterials, 1U)) { + os::Printer::log("Out of range index found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + const u32 fc = mesh.IndexCountPerFace[tfi] / 3; + for (u32 k = 0; k < fc; ++k) + mesh.FaceMaterialIndices[triangulatedindex++] = ind; + } + + // in version 03.02, the face indices end with two semicolons. + // commented out version check, as version 03.03 exported from blender also has 2 semicolons + if (!BinaryFormat) { // && MajorVersion == 3 && MinorVersion <= 2) + if (P[0] == ';') + ++P; + } + + // read following data objects + + while (true) { + core::stringc objectName = getNextToken(); + + if (objectName.size() == 0) { + os::Printer::log("Unexpected ending found in Mesh Material list in .x file.", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } else if (objectName == "}") { + break; // material list finished + } else if (objectName == "{") { + // template materials now available thanks to joeWright + objectName = getNextToken(); + mesh.Materials.push_back(video::SMaterial()); + getNextToken(); // skip } + } else if (objectName == "Material") { + mesh.Materials.push_back(video::SMaterial()); + if (!parseUnknownDataObject()) + return false; + } else if (objectName == ";") { + // ignore + } else { + os::Printer::log("Unknown data object in material list in x file", objectName.c_str(), ELL_WARNING); + if (!parseUnknownDataObject()) + return false; + } + } + return true; +} + +bool CXMeshFileLoader::parseDataObjectAnimationSet() +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: Reading animation set", ELL_DEBUG); +#endif + + core::stringc AnimationName; + + if (!readHeadOfDataObject(&AnimationName)) { + os::Printer::log("No opening brace in Animation Set found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + os::Printer::log("Reading animationset ", AnimationName, ELL_DEBUG); + + while (true) { + core::stringc objectName = getNextToken(); + + if (objectName.size() == 0) { + os::Printer::log("Unexpected ending found in Animation set in x file.", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } else if (objectName == "}") { + break; // animation set finished + } else if (objectName == "Animation") { + if (!parseDataObjectAnimation()) + return false; + } else { + os::Printer::log("Unknown data object in animation set in x file", objectName.c_str(), ELL_WARNING); + if (!parseUnknownDataObject()) + return false; + } + } + return true; +} + +bool CXMeshFileLoader::parseDataObjectAnimationTicksPerSecond() +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: reading AnimationTicksPerSecond", ELL_DEBUG); +#endif + + if (!readHeadOfDataObject()) { + os::Printer::log("No opening brace in Animation found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + const u32 ticks = readInt(); + + if (!checkForOneFollowingSemicolons()) { + os::Printer::log("No closing semicolon in AnimationTicksPerSecond in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + if (!checkForClosingBrace()) { + os::Printer::log("No closing brace in AnimationTicksPerSecond in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + AnimatedMesh->setAnimationSpeed(static_cast(ticks)); + + return true; +} + +bool CXMeshFileLoader::parseDataObjectAnimation() +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: reading animation", ELL_DEBUG); +#endif + + if (!readHeadOfDataObject()) { + os::Printer::log("No opening brace in Animation found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + // anim.closed = true; + // anim.linearPositionQuality = true; + CSkinnedMesh::SJoint animationDump; + + core::stringc FrameName; + + while (true) { + core::stringc objectName = getNextToken(); + + if (objectName.size() == 0) { + os::Printer::log("Unexpected ending found in Animation in x file.", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } else if (objectName == "}") { + break; // animation finished + } else if (objectName == "AnimationKey") { + if (!parseDataObjectAnimationKey(&animationDump)) + return false; + } else if (objectName == "AnimationOptions") { + // TODO: parse options. + if (!parseUnknownDataObject()) + return false; + } else if (objectName == "{") { + // read frame name + FrameName = getNextToken(); + + if (!checkForClosingBrace()) { + os::Printer::log("Unexpected ending found in Animation in x file.", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + } else { + os::Printer::log("Unknown data object in animation in x file", objectName.c_str(), ELL_WARNING); + if (!parseUnknownDataObject()) + SET_ERR_AND_RETURN(); + } + } + + if (FrameName.size() != 0) { +#ifdef _XREADER_DEBUG + os::Printer::log("frame name", FrameName.c_str(), ELL_DEBUG); +#endif + auto n = AnimatedMesh->getJointNumber(FrameName.c_str()); + + CSkinnedMesh::SJoint *joint; + if (n.has_value()) { + joint = AnimatedMesh->getAllJoints()[*n]; + } else { +#ifdef _XREADER_DEBUG + os::Printer::log("creating joint for animation ", FrameName.c_str(), ELL_DEBUG); +#endif + joint = AnimatedMesh->addJoint(0); + joint->Name = FrameName.c_str(); + } + + joint->PositionKeys.reallocate(joint->PositionKeys.size() + animationDump.PositionKeys.size()); + for (u32 n = 0; n < animationDump.PositionKeys.size(); ++n) { + joint->PositionKeys.push_back(animationDump.PositionKeys[n]); + } + + joint->ScaleKeys.reallocate(joint->ScaleKeys.size() + animationDump.ScaleKeys.size()); + for (u32 n = 0; n < animationDump.ScaleKeys.size(); ++n) { + joint->ScaleKeys.push_back(animationDump.ScaleKeys[n]); + } + + joint->RotationKeys.reallocate(joint->RotationKeys.size() + animationDump.RotationKeys.size()); + for (u32 n = 0; n < animationDump.RotationKeys.size(); ++n) { + joint->RotationKeys.push_back(animationDump.RotationKeys[n]); + } + } else + os::Printer::log("joint name was never given", ELL_WARNING); + + return true; +} + +bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint) +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: reading animation key", ELL_DEBUG); +#endif + + if (!readHeadOfDataObject()) { + os::Printer::log("No opening brace in Animation Key found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + // read key type + + const u32 keyType = readInt(); + + if (keyType > 4) { + os::Printer::log("Unknown key type found in Animation Key in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + // read number of keys + const u32 numberOfKeys = readInt(); + + // eat the semicolon after the "0". if there are keys present, readInt() + // does this for us. If there aren't, we need to do it explicitly + if (numberOfKeys == 0) + checkForOneFollowingSemicolons(); + + for (u32 i = 0; i < numberOfKeys; ++i) { + // read time + const f32 time = (f32)readInt(); + + // read keys + switch (keyType) { + case 0: // rotation + { + // read quaternions + + // read count + if (readInt() != 4) { + os::Printer::log("Expected 4 numbers in animation key in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + f32 W = -readFloat(); + f32 X = -readFloat(); + f32 Y = -readFloat(); + f32 Z = -readFloat(); + + if (!checkForTwoFollowingSemicolons()) { + os::Printer::log("No finishing semicolon after quaternion animation key in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + } + + ISkinnedMesh::SRotationKey *key = AnimatedMesh->addRotationKey(joint); + key->frame = time; + key->rotation.set(X, Y, Z, W); + key->rotation.normalize(); + } break; + case 1: // scale + case 2: // position + { + // read vectors + + // read count + if (readInt() != 3) { + os::Printer::log("Expected 3 numbers in animation key in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + core::vector3df vector; + readVector3(vector); + + if (!checkForTwoFollowingSemicolons()) { + os::Printer::log("No finishing semicolon after vector animation key in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + } + + if (keyType == 2) { + ISkinnedMesh::SPositionKey *key = AnimatedMesh->addPositionKey(joint); + key->frame = time; + key->position = vector; + } else { + ISkinnedMesh::SScaleKey *key = AnimatedMesh->addScaleKey(joint); + key->frame = time; + key->scale = vector; + } + } break; + case 3: + case 4: { + // read matrix + + // read count + if (readInt() != 16) { + os::Printer::log("Expected 16 numbers in animation key in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + // read matrix + core::matrix4 mat(core::matrix4::EM4CONST_NOTHING); + readMatrix(mat); + + // mat=joint->LocalMatrix*mat; + + if (!checkForOneFollowingSemicolons()) { + os::Printer::log("No finishing semicolon after matrix animation key in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + } + + // core::vector3df rotation = mat.getRotationDegrees(); + + ISkinnedMesh::SRotationKey *keyR = AnimatedMesh->addRotationKey(joint); + keyR->frame = time; + + // IRR_TEST_BROKEN_QUATERNION_USE: TODO - switched from mat to mat.getTransposed() for downward compatibility. + // Not tested so far if this was correct or wrong before quaternion fix! + keyR->rotation = core::quaternion(mat.getTransposed()); + + ISkinnedMesh::SPositionKey *keyP = AnimatedMesh->addPositionKey(joint); + keyP->frame = time; + keyP->position = mat.getTranslation(); + + /* + core::vector3df scale=mat.getScale(); + + if (scale.X==0) + scale.X=1; + if (scale.Y==0) + scale.Y=1; + if (scale.Z==0) + scale.Z=1; + ISkinnedMesh::SScaleKey *keyS=AnimatedMesh->addScaleKey(joint); + keyS->frame=time; + keyS->scale=scale; + */ + } break; + } // end switch + } + + if (!checkForOneFollowingSemicolons()) + --P; + + if (!checkForClosingBrace()) { + os::Printer::log("No closing brace in animation key in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + return true; +} + +bool CXMeshFileLoader::parseDataObjectTextureFilename(core::stringc &texturename) +{ +#ifdef _XREADER_DEBUG + os::Printer::log("CXFileReader: reading texture filename", ELL_DEBUG); +#endif + + if (!readHeadOfDataObject()) { + os::Printer::log("No opening brace in Texture filename found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + if (!getNextTokenAsString(texturename)) { + os::Printer::log("Unknown syntax while reading texture filename string in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + if (!checkForClosingBrace()) { + os::Printer::log("No closing brace in Texture filename found in x file", ELL_WARNING); + os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING); + SET_ERR_AND_RETURN(); + } + + return true; +} + +bool CXMeshFileLoader::parseUnknownDataObject() +{ + // find opening delimiter + while (true) { + core::stringc t = getNextToken(); + + if (t.size() == 0) + return false; + + if (t == "{") + break; + } + + u32 counter = 1; + + // parse until closing delimiter + + while (counter) { + core::stringc t = getNextToken(); + + if (t.size() == 0) + return false; + + if (t == "{") + ++counter; + else if (t == "}") + --counter; + } + + return true; +} + +//! checks for closing curly brace, returns false if not there +bool CXMeshFileLoader::checkForClosingBrace() +{ + return (getNextToken() == "}"); +} + +//! checks for one following semicolon, returns false if not there +bool CXMeshFileLoader::checkForOneFollowingSemicolons() +{ + if (BinaryFormat) + return true; + + if (getNextToken() == ";") + return true; + else { + --P; + return false; + } +} + +//! checks for two following semicolons, returns false if they are not there +bool CXMeshFileLoader::checkForTwoFollowingSemicolons() +{ + if (BinaryFormat) + return true; + + for (u32 k = 0; k < 2; ++k) { + if (getNextToken() != ";") { + --P; + return false; + } + } + + return true; +} + +//! reads header of dataobject including the opening brace. +//! returns false if error happened, and writes name of object +//! if there is one +bool CXMeshFileLoader::readHeadOfDataObject(core::stringc *outname) +{ + core::stringc nameOrBrace = getNextToken(); + if (nameOrBrace != "{") { + if (outname) + (*outname) = nameOrBrace; + + if (getNextToken() != "{") + return false; + } + + return true; +} + +//! returns next parseable token. Returns empty string if no token there +core::stringc CXMeshFileLoader::getNextToken() +{ + core::stringc s; + + // process binary-formatted file + if (BinaryFormat) { + // in binary mode it will only return NAME and STRING token + // and (correctly) skip over other tokens. + + s16 tok = readBinWord(); + u32 len; + + // standalone tokens + switch (tok) { + case 1: + // name token + len = readBinDWord(); + s = core::stringc(P, len); + P += len; + return s; + case 2: + // string token + len = readBinDWord(); + s = core::stringc(P, len); + P += (len + 2); + return s; + case 3: + // integer token + P += 4; + return ""; + case 5: + // GUID token + P += 16; + return ""; + case 6: + len = readBinDWord(); + P += (len * 4); + return ""; + case 7: + len = readBinDWord(); + P += (len * FloatSize); + return ""; + case 0x0a: + return "{"; + case 0x0b: + return "}"; + case 0x0c: + return "("; + case 0x0d: + return ")"; + case 0x0e: + return "["; + case 0x0f: + return "]"; + case 0x10: + return "<"; + case 0x11: + return ">"; + case 0x12: + return "."; + case 0x13: + return ","; + case 0x14: + return ";"; + case 0x1f: + return "template"; + case 0x28: + return "WORD"; + case 0x29: + return "DWORD"; + case 0x2a: + return "FLOAT"; + case 0x2b: + return "DOUBLE"; + case 0x2c: + return "CHAR"; + case 0x2d: + return "UCHAR"; + case 0x2e: + return "SWORD"; + case 0x2f: + return "SDWORD"; + case 0x30: + return "void"; + case 0x31: + return "string"; + case 0x32: + return "unicode"; + case 0x33: + return "cstring"; + case 0x34: + return "array"; + } + } + // process text-formatted file + else { + findNextNoneWhiteSpace(); + + if (P >= End) + return s; + + while ((P < End) && !core::isspace(P[0])) { + // either keep token delimiters when already holding a token, or return if first valid char + if (P[0] == ';' || P[0] == '}' || P[0] == '{' || P[0] == ',') { + if (!s.size()) { + s.append(P[0]); + ++P; + } + break; // stop for delimiter + } + s.append(P[0]); + ++P; + } + } + return s; +} + +//! places pointer to next begin of a token, which must be a number, +// and ignores comments +void CXMeshFileLoader::findNextNoneWhiteSpaceNumber() +{ + if (BinaryFormat) + return; + + while ((P < End) && (P[0] != '-') && (P[0] != '.') && + !(core::isdigit(P[0]))) { + // check if this is a comment + if ((P[0] == '/' && P[1] == '/') || P[0] == '#') + readUntilEndOfLine(); + else + ++P; + } +} + +// places pointer to next begin of a token, and ignores comments +void CXMeshFileLoader::findNextNoneWhiteSpace() +{ + if (BinaryFormat) + return; + + while (true) { + while ((P < End) && core::isspace(P[0])) { + if (*P == '\n') + ++Line; + ++P; + } + + if (P >= End) + return; + + // check if this is a comment + if ((P[0] == '/' && P[1] == '/') || + P[0] == '#') + readUntilEndOfLine(); + else + break; + } +} + +//! reads a x file style string +bool CXMeshFileLoader::getNextTokenAsString(core::stringc &out) +{ + if (BinaryFormat) { + out = getNextToken(); + return true; + } + findNextNoneWhiteSpace(); + + if (P >= End) + return false; + + if (P[0] != '"') + return false; + ++P; + + while (P < End && P[0] != '"') { + out.append(P[0]); + ++P; + } + + if (P[1] != ';' || P[0] != '"') + return false; + P += 2; + + return true; +} + +void CXMeshFileLoader::readUntilEndOfLine() +{ + if (BinaryFormat) + return; + + while (P < End) { + if (P[0] == '\n' || P[0] == '\r') { + ++P; + ++Line; + return; + } + + ++P; + } +} + +u16 CXMeshFileLoader::readBinWord() +{ + if (P >= End) + return 0; +#ifdef __BIG_ENDIAN__ + const u16 tmp = os::Byteswap::byteswap(*(u16 *)P); +#else + const u16 tmp = *(u16 *)P; +#endif + P += 2; + return tmp; +} + +u32 CXMeshFileLoader::readBinDWord() +{ + if (P >= End) + return 0; +#ifdef __BIG_ENDIAN__ + const u32 tmp = os::Byteswap::byteswap(*(u32 *)P); +#else + const u32 tmp = *(u32 *)P; +#endif + P += 4; + return tmp; +} + +u32 CXMeshFileLoader::readInt() +{ + if (BinaryFormat) { + if (!BinaryNumCount) { + const u16 tmp = readBinWord(); // 0x06 or 0x03 + if (tmp == 0x06) + BinaryNumCount = readBinDWord(); + else + BinaryNumCount = 1; // single int + } + --BinaryNumCount; + return readBinDWord(); + } else { + findNextNoneWhiteSpaceNumber(); + return core::strtoul10(P, &P); + } +} + +f32 CXMeshFileLoader::readFloat() +{ + if (BinaryFormat) { + if (!BinaryNumCount) { + const u16 tmp = readBinWord(); // 0x07 or 0x42 + if (tmp == 0x07) + BinaryNumCount = readBinDWord(); + else + BinaryNumCount = 1; // single int + } + --BinaryNumCount; + if (FloatSize == 8) { +#ifdef __BIG_ENDIAN__ + // TODO: Check if data is properly converted here + f32 ctmp[2]; + ctmp[1] = os::Byteswap::byteswap(*(f32 *)P); + ctmp[0] = os::Byteswap::byteswap(*(f32 *)P + 4); + const f32 tmp = (f32)(*(f64 *)(void *)ctmp); +#else + const f32 tmp = (f32)(*(f64 *)P); +#endif + P += 8; + return tmp; + } else { +#ifdef __BIG_ENDIAN__ + const f32 tmp = os::Byteswap::byteswap(*(f32 *)P); +#else + const f32 tmp = *(f32 *)P; +#endif + P += 4; + return tmp; + } + } + findNextNoneWhiteSpaceNumber(); + f32 ftmp; + P = core::fast_atof_move(P, ftmp); + return ftmp; +} + +// read 2-dimensional vector. Stops at semicolon after second value for text file format +bool CXMeshFileLoader::readVector2(core::vector2df &vec) +{ + vec.X = readFloat(); + vec.Y = readFloat(); + return true; +} + +// read 3-dimensional vector. Stops at semicolon after third value for text file format +bool CXMeshFileLoader::readVector3(core::vector3df &vec) +{ + vec.X = readFloat(); + vec.Y = readFloat(); + vec.Z = readFloat(); + return true; +} + +// read color without alpha value. Stops after second semicolon after blue value +bool CXMeshFileLoader::readRGB(video::SColor &color) +{ + video::SColorf tmpColor; + tmpColor.r = readFloat(); + tmpColor.g = readFloat(); + tmpColor.b = readFloat(); + color = tmpColor.toSColor(); + return checkForOneFollowingSemicolons(); +} + +// read color with alpha value. Stops after second semicolon after blue value +bool CXMeshFileLoader::readRGBA(video::SColor &color) +{ + video::SColorf tmpColor; + tmpColor.r = readFloat(); + tmpColor.g = readFloat(); + tmpColor.b = readFloat(); + tmpColor.a = readFloat(); + color = tmpColor.toSColor(); + return checkForOneFollowingSemicolons(); +} + +// read matrix from list of floats +bool CXMeshFileLoader::readMatrix(core::matrix4 &mat) +{ + for (u32 i = 0; i < 16; ++i) + mat[i] = readFloat(); + return checkForOneFollowingSemicolons(); +} + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CXMeshFileLoader.h b/irr/src/CXMeshFileLoader.h new file mode 100644 index 000000000..711806270 --- /dev/null +++ b/irr/src/CXMeshFileLoader.h @@ -0,0 +1,181 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IMeshLoader.h" +#include "irrString.h" +#include "CSkinnedMesh.h" + +namespace irr +{ +namespace io +{ +class IReadFile; +} // end namespace io +namespace scene +{ +class IMeshManipulator; + +//! Meshloader capable of loading x meshes. +class CXMeshFileLoader : public IMeshLoader +{ +public: + //! Constructor + CXMeshFileLoader(scene::ISceneManager *smgr); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".cob") + bool isALoadableFileExtension(const io::path &filename) const override; + + //! creates/loads an animated mesh from the file. + //! \return Pointer to the created mesh. Returns 0 if loading failed. + //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). + //! See IReferenceCounted::drop() for more information. + IAnimatedMesh *createMesh(io::IReadFile *file) override; + + struct SXMesh + { + SXMesh() : + MaxSkinWeightsPerVertex(0), MaxSkinWeightsPerFace(0), BoneCount(0), AttachedJointID(-1), HasSkinning(false), HasVertexColors(false) {} + // this mesh contains triangulated texture data. + // because in an .x file, faces can be made of more than 3 + // vertices, the indices data structure is triangulated during the + // loading process. The IndexCountPerFace array is filled during + // this triangulation process and stores how much indices belong to + // every face. This data structure can be ignored, because all data + // in this structure is triangulated. + + core::stringc Name; + + u32 MaxSkinWeightsPerVertex; + u32 MaxSkinWeightsPerFace; + u32 BoneCount; + + core::array IndexCountPerFace; // default 3, but could be more + + core::array Buffers; + + core::array Vertices; + core::array TCoords2; + + core::array Indices; + + core::array FaceMaterialIndices; // index of material for each face + + core::array Materials; // material array + + core::array WeightJoint; + core::array WeightNum; + + s32 AttachedJointID; + + bool HasSkinning; + bool HasVertexColors; + }; + +private: + bool load(io::IReadFile *file); + + bool readFileIntoMemory(io::IReadFile *file); + + bool parseFile(); + + bool parseDataObject(); + + bool parseDataObjectTemplate(); + + bool parseDataObjectFrame(CSkinnedMesh::SJoint *parent); + + bool parseDataObjectTransformationMatrix(core::matrix4 &mat); + + bool parseDataObjectMesh(SXMesh &mesh); + + bool parseDataObjectSkinWeights(SXMesh &mesh); + + bool parseDataObjectSkinMeshHeader(SXMesh &mesh); + + bool parseDataObjectMeshNormals(SXMesh &mesh); + + bool parseDataObjectMeshTextureCoords(SXMesh &mesh); + + bool parseDataObjectMeshVertexColors(SXMesh &mesh); + + bool parseDataObjectMeshMaterialList(SXMesh &mesh); + + bool parseDataObjectAnimationSet(); + + bool parseDataObjectAnimationTicksPerSecond(); + + bool parseDataObjectAnimation(); + + bool parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint); + + bool parseDataObjectTextureFilename(core::stringc &texturename); + + bool parseUnknownDataObject(); + + //! places pointer to next begin of a token, and ignores comments + void findNextNoneWhiteSpace(); + + //! places pointer to next begin of a token, which must be a number, + // and ignores comments + void findNextNoneWhiteSpaceNumber(); + + //! returns next parseable token. Returns empty string if no token there + core::stringc getNextToken(); + + //! reads header of dataobject including the opening brace. + //! returns false if error happened, and writes name of object + //! if there is one + bool readHeadOfDataObject(core::stringc *outname = 0); + + //! checks for closing curly brace, returns false if not there + bool checkForClosingBrace(); + + //! checks for one following semicolons, returns false if not there + bool checkForOneFollowingSemicolons(); + + //! checks for two following semicolons, returns false if they are not there + bool checkForTwoFollowingSemicolons(); + + //! reads a x file style string + bool getNextTokenAsString(core::stringc &out); + + void readUntilEndOfLine(); + + u16 readBinWord(); + u32 readBinDWord(); + u32 readInt(); + f32 readFloat(); + bool readVector2(core::vector2df &vec); + bool readVector3(core::vector3df &vec); + bool readMatrix(core::matrix4 &mat); + bool readRGB(video::SColor &color); + bool readRGBA(video::SColor &color); + + CSkinnedMesh *AnimatedMesh; + + c8 *Buffer; + const c8 *P; + c8 *End; + // counter for number arrays in binary format + u32 BinaryNumCount; + u32 Line; + io::path FilePath; + + bool ErrorState; + + CSkinnedMesh::SJoint *CurFrame; + + core::array Meshes; + + u32 MajorVersion; + u32 MinorVersion; + bool BinaryFormat; + c8 FloatSize; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/CZipReader.cpp b/irr/src/CZipReader.cpp new file mode 100644 index 000000000..b761c72e8 --- /dev/null +++ b/irr/src/CZipReader.cpp @@ -0,0 +1,519 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CZipReader.h" + +#include "os.h" + +#include "CFileList.h" +#include "CReadFile.h" +#include "coreutil.h" + +#include // use system lib + +namespace irr +{ +namespace io +{ + +// ----------------------------------------------------------------------------- +// zip loader +// ----------------------------------------------------------------------------- + +//! Constructor +CArchiveLoaderZIP::CArchiveLoaderZIP(io::IFileSystem *fs) : + FileSystem(fs) +{ +#ifdef _DEBUG + setDebugName("CArchiveLoaderZIP"); +#endif +} + +//! returns true if the file maybe is able to be loaded by this class +bool CArchiveLoaderZIP::isALoadableFileFormat(const io::path &filename) const +{ + return core::hasFileExtension(filename, "zip", "pk3") || + core::hasFileExtension(filename, "gz", "tgz"); +} + +//! Check to see if the loader can create archives of this type. +bool CArchiveLoaderZIP::isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const +{ + return (fileType == EFAT_ZIP || fileType == EFAT_GZIP); +} + +//! Creates an archive from the filename +/** \param file File handle to check. +\return Pointer to newly created archive, or 0 upon error. */ +IFileArchive *CArchiveLoaderZIP::createArchive(const io::path &filename, bool ignoreCase, bool ignorePaths) const +{ + IFileArchive *archive = 0; + io::IReadFile *file = FileSystem->createAndOpenFile(filename); + + if (file) { + archive = createArchive(file, ignoreCase, ignorePaths); + file->drop(); + } + + return archive; +} + +//! creates/loads an archive from the file. +//! \return Pointer to the created archive. Returns 0 if loading failed. +IFileArchive *CArchiveLoaderZIP::createArchive(io::IReadFile *file, bool ignoreCase, bool ignorePaths) const +{ + IFileArchive *archive = 0; + if (file) { + file->seek(0); + + u16 sig; + file->read(&sig, 2); + +#ifdef __BIG_ENDIAN__ + sig = os::Byteswap::byteswap(sig); +#endif + + file->seek(0); + + bool isGZip = (sig == 0x8b1f); + + archive = new CZipReader(FileSystem, file, ignoreCase, ignorePaths, isGZip); + } + return archive; +} + +//! Check if the file might be loaded by this class +/** Check might look into the file. +\param file File handle to check. +\return True if file seems to be loadable. */ +bool CArchiveLoaderZIP::isALoadableFileFormat(io::IReadFile *file) const +{ + SZIPFileHeader header; + + file->read(&header.Sig, 4); +#ifdef __BIG_ENDIAN__ + header.Sig = os::Byteswap::byteswap(header.Sig); +#endif + + return header.Sig == 0x04034b50 || // ZIP + (header.Sig & 0xffff) == 0x8b1f; // gzip +} + +// ----------------------------------------------------------------------------- +// zip archive +// ----------------------------------------------------------------------------- + +CZipReader::CZipReader(IFileSystem *fs, IReadFile *file, bool ignoreCase, bool ignorePaths, bool isGZip) : + CFileList((file ? file->getFileName() : io::path("")), ignoreCase, ignorePaths), FileSystem(fs), File(file), IsGZip(isGZip) +{ +#ifdef _DEBUG + setDebugName("CZipReader"); +#endif + + if (File) { + File->grab(); + + // load file entries + if (IsGZip) + while (scanGZipHeader()) { + } + else + while (scanZipHeader()) { + } + + sort(); + } +} + +CZipReader::~CZipReader() +{ + if (File) + File->drop(); +} + +//! get the archive type +E_FILE_ARCHIVE_TYPE CZipReader::getType() const +{ + return IsGZip ? EFAT_GZIP : EFAT_ZIP; +} + +const IFileList *CZipReader::getFileList() const +{ + return this; +} + +//! scans for a local header, returns false if there is no more local file header. +//! The gzip file format seems to think that there can be multiple files in a gzip file +//! but none +bool CZipReader::scanGZipHeader() +{ + SZipFileEntry entry; + entry.Offset = 0; + memset(&entry.header, 0, sizeof(SZIPFileHeader)); + + // read header + SGZIPMemberHeader header; + if (File->read(&header, sizeof(SGZIPMemberHeader)) == sizeof(SGZIPMemberHeader)) { + +#ifdef __BIG_ENDIAN__ + header.sig = os::Byteswap::byteswap(header.sig); + header.time = os::Byteswap::byteswap(header.time); +#endif + + // check header value + if (header.sig != 0x8b1f) + return false; + + // now get the file info + if (header.flags & EGZF_EXTRA_FIELDS) { + // read lenth of extra data + u16 dataLen; + + File->read(&dataLen, 2); + +#ifdef __BIG_ENDIAN__ + dataLen = os::Byteswap::byteswap(dataLen); +#endif + + // skip it + File->seek(dataLen, true); + } + + io::path ZipFileName = ""; + + if (header.flags & EGZF_FILE_NAME) { + c8 c; + File->read(&c, 1); + while (c) { + ZipFileName.append(c); + File->read(&c, 1); + } + } else { + // no file name? + ZipFileName = Path; + core::deletePathFromFilename(ZipFileName); + + // rename tgz to tar or remove gz extension + if (core::hasFileExtension(ZipFileName, "tgz")) { + ZipFileName[ZipFileName.size() - 2] = 'a'; + ZipFileName[ZipFileName.size() - 1] = 'r'; + } else if (core::hasFileExtension(ZipFileName, "gz")) { + ZipFileName[ZipFileName.size() - 3] = 0; + ZipFileName.validate(); + } + } + + if (header.flags & EGZF_COMMENT) { + c8 c = 'a'; + while (c) + File->read(&c, 1); + } + + if (header.flags & EGZF_CRC16) + File->seek(2, true); + + // we are now at the start of the data blocks + entry.Offset = File->getPos(); + + entry.header.FilenameLength = ZipFileName.size(); + + entry.header.CompressionMethod = header.compressionMethod; + entry.header.DataDescriptor.CompressedSize = (File->getSize() - 8) - File->getPos(); + + // seek to file end + File->seek(entry.header.DataDescriptor.CompressedSize, true); + + // read CRC + File->read(&entry.header.DataDescriptor.CRC32, 4); + // read uncompressed size + File->read(&entry.header.DataDescriptor.UncompressedSize, 4); + +#ifdef __BIG_ENDIAN__ + entry.header.DataDescriptor.CRC32 = os::Byteswap::byteswap(entry.header.DataDescriptor.CRC32); + entry.header.DataDescriptor.UncompressedSize = os::Byteswap::byteswap(entry.header.DataDescriptor.UncompressedSize); +#endif + + // now we've filled all the fields, this is just a standard deflate block + addItem(ZipFileName, entry.Offset, entry.header.DataDescriptor.UncompressedSize, false, 0); + FileInfo.push_back(entry); + } + + // there's only one block of data in a gzip file + return false; +} + +//! scans for a local header, returns false if there is no more local file header. +bool CZipReader::scanZipHeader(bool ignoreGPBits) +{ + io::path ZipFileName = ""; + SZipFileEntry entry; + entry.Offset = 0; + memset(&entry.header, 0, sizeof(SZIPFileHeader)); + + File->read(&entry.header, sizeof(SZIPFileHeader)); + +#ifdef __BIG_ENDIAN__ + entry.header.Sig = os::Byteswap::byteswap(entry.header.Sig); + entry.header.VersionToExtract = os::Byteswap::byteswap(entry.header.VersionToExtract); + entry.header.GeneralBitFlag = os::Byteswap::byteswap(entry.header.GeneralBitFlag); + entry.header.CompressionMethod = os::Byteswap::byteswap(entry.header.CompressionMethod); + entry.header.LastModFileTime = os::Byteswap::byteswap(entry.header.LastModFileTime); + entry.header.LastModFileDate = os::Byteswap::byteswap(entry.header.LastModFileDate); + entry.header.DataDescriptor.CRC32 = os::Byteswap::byteswap(entry.header.DataDescriptor.CRC32); + entry.header.DataDescriptor.CompressedSize = os::Byteswap::byteswap(entry.header.DataDescriptor.CompressedSize); + entry.header.DataDescriptor.UncompressedSize = os::Byteswap::byteswap(entry.header.DataDescriptor.UncompressedSize); + entry.header.FilenameLength = os::Byteswap::byteswap(entry.header.FilenameLength); + entry.header.ExtraFieldLength = os::Byteswap::byteswap(entry.header.ExtraFieldLength); +#endif + + if (entry.header.Sig != 0x04034b50) + return false; // local file headers end here. + + // read filename + { + c8 *tmp = new c8[entry.header.FilenameLength + 2]; + File->read(tmp, entry.header.FilenameLength); + tmp[entry.header.FilenameLength] = 0; + ZipFileName = tmp; + delete[] tmp; + } + + if (entry.header.ExtraFieldLength) + File->seek(entry.header.ExtraFieldLength, true); + + // if bit 3 was set, use CentralDirectory for setup + if (!ignoreGPBits && entry.header.GeneralBitFlag & ZIP_INFO_IN_DATA_DESCRIPTOR) { + SZIPFileCentralDirEnd dirEnd; + FileInfo.clear(); + Files.clear(); + // First place where the end record could be stored + File->seek(File->getSize() - 22); + const char endID[] = {0x50, 0x4b, 0x05, 0x06, 0x0}; + char tmp[5] = {'\0'}; + bool found = false; + // search for the end record ID + while (!found && File->getPos() > 0) { + int seek = 8; + File->read(tmp, 4); + switch (tmp[0]) { + case 0x50: + if (!strcmp(endID, tmp)) { + seek = 4; + found = true; + } + break; + case 0x4b: + seek = 5; + break; + case 0x05: + seek = 6; + break; + case 0x06: + seek = 7; + break; + } + File->seek(-seek, true); + } + File->read(&dirEnd, sizeof(dirEnd)); +#ifdef __BIG_ENDIAN__ + dirEnd.NumberDisk = os::Byteswap::byteswap(dirEnd.NumberDisk); + dirEnd.NumberStart = os::Byteswap::byteswap(dirEnd.NumberStart); + dirEnd.TotalDisk = os::Byteswap::byteswap(dirEnd.TotalDisk); + dirEnd.TotalEntries = os::Byteswap::byteswap(dirEnd.TotalEntries); + dirEnd.Size = os::Byteswap::byteswap(dirEnd.Size); + dirEnd.Offset = os::Byteswap::byteswap(dirEnd.Offset); + dirEnd.CommentLength = os::Byteswap::byteswap(dirEnd.CommentLength); +#endif + FileInfo.reallocate(dirEnd.TotalEntries); + File->seek(dirEnd.Offset); + while (scanCentralDirectoryHeader()) { + } + return false; + } + + // store position in file + entry.Offset = File->getPos(); + // move forward length of data + File->seek(entry.header.DataDescriptor.CompressedSize, true); + +#ifdef _DEBUG +// os::Debuginfo::print("added file from archive", ZipFileName.c_str()); +#endif + + addItem(ZipFileName, entry.Offset, entry.header.DataDescriptor.UncompressedSize, ZipFileName.lastChar() == '/', FileInfo.size()); + FileInfo.push_back(entry); + + return true; +} + +//! scans for a local header, returns false if there is no more local file header. +bool CZipReader::scanCentralDirectoryHeader() +{ + io::path ZipFileName = ""; + SZIPFileCentralDirFileHeader entry; + File->read(&entry, sizeof(SZIPFileCentralDirFileHeader)); + +#ifdef __BIG_ENDIAN__ + entry.Sig = os::Byteswap::byteswap(entry.Sig); + entry.VersionMadeBy = os::Byteswap::byteswap(entry.VersionMadeBy); + entry.VersionToExtract = os::Byteswap::byteswap(entry.VersionToExtract); + entry.GeneralBitFlag = os::Byteswap::byteswap(entry.GeneralBitFlag); + entry.CompressionMethod = os::Byteswap::byteswap(entry.CompressionMethod); + entry.LastModFileTime = os::Byteswap::byteswap(entry.LastModFileTime); + entry.LastModFileDate = os::Byteswap::byteswap(entry.LastModFileDate); + entry.CRC32 = os::Byteswap::byteswap(entry.CRC32); + entry.CompressedSize = os::Byteswap::byteswap(entry.CompressedSize); + entry.UncompressedSize = os::Byteswap::byteswap(entry.UncompressedSize); + entry.FilenameLength = os::Byteswap::byteswap(entry.FilenameLength); + entry.ExtraFieldLength = os::Byteswap::byteswap(entry.ExtraFieldLength); + entry.FileCommentLength = os::Byteswap::byteswap(entry.FileCommentLength); + entry.DiskNumberStart = os::Byteswap::byteswap(entry.DiskNumberStart); + entry.InternalFileAttributes = os::Byteswap::byteswap(entry.InternalFileAttributes); + entry.ExternalFileAttributes = os::Byteswap::byteswap(entry.ExternalFileAttributes); + entry.RelativeOffsetOfLocalHeader = os::Byteswap::byteswap(entry.RelativeOffsetOfLocalHeader); +#endif + + if (entry.Sig != 0x02014b50) + return false; // central dir headers end here. + + const long pos = File->getPos(); + File->seek(entry.RelativeOffsetOfLocalHeader); + scanZipHeader(true); + File->seek(pos + entry.FilenameLength + entry.ExtraFieldLength + entry.FileCommentLength); + FileInfo.getLast().header.DataDescriptor.CompressedSize = entry.CompressedSize; + FileInfo.getLast().header.DataDescriptor.UncompressedSize = entry.UncompressedSize; + FileInfo.getLast().header.DataDescriptor.CRC32 = entry.CRC32; + Files.getLast().Size = entry.UncompressedSize; + return true; +} + +//! opens a file by file name +IReadFile *CZipReader::createAndOpenFile(const io::path &filename) +{ + s32 index = findFile(filename, false); + + if (index != -1) + return createAndOpenFile(index); + + return 0; +} + +//! opens a file by index +IReadFile *CZipReader::createAndOpenFile(u32 index) +{ + // Irrlicht supports 0, 8, 12, 14, 99 + // 0 - The file is stored (no compression) + // 1 - The file is Shrunk + // 2 - The file is Reduced with compression factor 1 + // 3 - The file is Reduced with compression factor 2 + // 4 - The file is Reduced with compression factor 3 + // 5 - The file is Reduced with compression factor 4 + // 6 - The file is Imploded + // 7 - Reserved for Tokenizing compression algorithm + // 8 - The file is Deflated + // 9 - Reserved for enhanced Deflating + // 10 - PKWARE Date Compression Library Imploding + // 12 - bzip2 - Compression Method from libbz2, WinZip 10 + // 14 - LZMA - Compression Method, WinZip 12 + // 96 - Jpeg compression - Compression Method, WinZip 12 + // 97 - WavPack - Compression Method, WinZip 11 + // 98 - PPMd - Compression Method, WinZip 10 + // 99 - AES encryption, WinZip 9 + + const SZipFileEntry &e = FileInfo[Files[index].ID]; + char buf[64]; + s16 actualCompressionMethod = e.header.CompressionMethod; + IReadFile *decrypted = 0; + u8 *decryptedBuf = 0; + u32 decryptedSize = e.header.DataDescriptor.CompressedSize; + switch (actualCompressionMethod) { + case 0: // no compression + { + if (decrypted) + return decrypted; + else + return createLimitReadFile(Files[index].FullName, File, e.Offset, decryptedSize); + } + case 8: { + const u32 uncompressedSize = e.header.DataDescriptor.UncompressedSize; + c8 *pBuf = new c8[uncompressedSize]; + if (!pBuf) { + snprintf_irr(buf, 64, "Not enough memory for decompressing %s", Files[index].FullName.c_str()); + os::Printer::log(buf, ELL_ERROR); + if (decrypted) + decrypted->drop(); + return 0; + } + + u8 *pcData = decryptedBuf; + if (!pcData) { + pcData = new u8[decryptedSize]; + if (!pcData) { + snprintf_irr(buf, 64, "Not enough memory for decompressing %s", Files[index].FullName.c_str()); + os::Printer::log(buf, ELL_ERROR); + delete[] pBuf; + return 0; + } + + // memset(pcData, 0, decryptedSize); + File->seek(e.Offset); + File->read(pcData, decryptedSize); + } + + // Setup the inflate stream. + z_stream stream; + s32 err; + + stream.next_in = (Bytef *)pcData; + stream.avail_in = (uInt)decryptedSize; + stream.next_out = (Bytef *)pBuf; + stream.avail_out = uncompressedSize; + stream.zalloc = (alloc_func)0; + stream.zfree = (free_func)0; + + // Perform inflation. wbits < 0 indicates no zlib header inside the data. + err = inflateInit2(&stream, -MAX_WBITS); + if (err == Z_OK) { + err = inflate(&stream, Z_FINISH); + inflateEnd(&stream); + if (err == Z_STREAM_END) + err = Z_OK; + err = Z_OK; + inflateEnd(&stream); + } + + if (decrypted) + decrypted->drop(); + else + delete[] pcData; + + if (err != Z_OK) { + snprintf_irr(buf, 64, "Error decompressing %s", Files[index].FullName.c_str()); + os::Printer::log(buf, ELL_ERROR); + delete[] pBuf; + return 0; + } else + return FileSystem->createMemoryReadFile(pBuf, uncompressedSize, Files[index].FullName, true); + } + case 12: { + os::Printer::log("bzip2 decompression not supported. File cannot be read.", ELL_ERROR); + return 0; + } + case 14: { + os::Printer::log("lzma decompression not supported. File cannot be read.", ELL_ERROR); + return 0; + } + case 99: + // If we come here with an encrypted file, decryption support is missing + os::Printer::log("Decryption support not enabled. File cannot be read.", ELL_ERROR); + return 0; + default: + snprintf_irr(buf, 64, "file has unsupported compression method. %s", Files[index].FullName.c_str()); + os::Printer::log(buf, ELL_ERROR); + return 0; + }; +} + +} // end namespace io +} // end namespace irr diff --git a/irr/src/CZipReader.h b/irr/src/CZipReader.h new file mode 100644 index 000000000..d9afd668a --- /dev/null +++ b/irr/src/CZipReader.h @@ -0,0 +1,218 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReadFile.h" +#include "irrArray.h" +#include "irrString.h" +#include "IFileSystem.h" +#include "CFileList.h" + +namespace irr +{ +namespace io +{ +// set if the file is encrypted +const s16 ZIP_FILE_ENCRYPTED = 0x0001; +// the fields crc-32, compressed size and uncompressed size are set to +// zero in the local header +const s16 ZIP_INFO_IN_DATA_DESCRIPTOR = 0x0008; + +// byte-align structures +#include "irrpack.h" + +struct SZIPFileDataDescriptor +{ + u32 CRC32; + u32 CompressedSize; + u32 UncompressedSize; +} PACK_STRUCT; + +struct SZIPFileHeader +{ + u32 Sig; // 'PK0304' little endian (0x04034b50) + s16 VersionToExtract; + s16 GeneralBitFlag; + s16 CompressionMethod; + s16 LastModFileTime; + s16 LastModFileDate; + SZIPFileDataDescriptor DataDescriptor; + s16 FilenameLength; + s16 ExtraFieldLength; + // filename (variable size) + // extra field (variable size ) +} PACK_STRUCT; + +struct SZIPFileCentralDirFileHeader +{ + u32 Sig; // 'PK0102' (0x02014b50) + u16 VersionMadeBy; + u16 VersionToExtract; + u16 GeneralBitFlag; + u16 CompressionMethod; + u16 LastModFileTime; + u16 LastModFileDate; + u32 CRC32; + u32 CompressedSize; + u32 UncompressedSize; + u16 FilenameLength; + u16 ExtraFieldLength; + u16 FileCommentLength; + u16 DiskNumberStart; + u16 InternalFileAttributes; + u32 ExternalFileAttributes; + u32 RelativeOffsetOfLocalHeader; + + // filename (variable size) + // extra field (variable size) + // file comment (variable size) + +} PACK_STRUCT; + +struct SZIPFileCentralDirEnd +{ + u32 Sig; // 'PK0506' end_of central dir signature // (0x06054b50) + u16 NumberDisk; // number of this disk + u16 NumberStart; // number of the disk with the start of the central directory + u16 TotalDisk; // total number of entries in the central dir on this disk + u16 TotalEntries; // total number of entries in the central dir + u32 Size; // size of the central directory + u32 Offset; // offset of start of centraldirectory with respect to the starting disk number + u16 CommentLength; // zipfile comment length + // zipfile comment (variable size) +} PACK_STRUCT; + +struct SZipFileExtraHeader +{ + s16 ID; + s16 Size; +} PACK_STRUCT; + +struct SZipFileAESExtraData +{ + s16 Version; + u8 Vendor[2]; + u8 EncryptionStrength; + s16 CompressionMode; +} PACK_STRUCT; + +enum E_GZIP_FLAGS +{ + EGZF_TEXT_DAT = 1, + EGZF_CRC16 = 2, + EGZF_EXTRA_FIELDS = 4, + EGZF_FILE_NAME = 8, + EGZF_COMMENT = 16 +}; + +struct SGZIPMemberHeader +{ + u16 sig; // 0x8b1f + u8 compressionMethod; // 8 = deflate + u8 flags; + u32 time; + u8 extraFlags; // slow compress = 2, fast compress = 4 + u8 operatingSystem; +} PACK_STRUCT; + +// Default alignment +#include "irrunpack.h" + +//! Contains extended info about zip files in the archive +struct SZipFileEntry +{ + //! Position of data in the archive file + s32 Offset; + + //! The header for this file containing compression info etc + SZIPFileHeader header; +}; + +//! Archiveloader capable of loading ZIP Archives +class CArchiveLoaderZIP : public IArchiveLoader +{ +public: + //! Constructor + CArchiveLoaderZIP(io::IFileSystem *fs); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".zip") + bool isALoadableFileFormat(const io::path &filename) const override; + + //! Check if the file might be loaded by this class + /** Check might look into the file. + \param file File handle to check. + \return True if file seems to be loadable. */ + bool isALoadableFileFormat(io::IReadFile *file) const override; + + //! Check to see if the loader can create archives of this type. + /** Check based on the archive type. + \param fileType The archive type to check. + \return True if the archile loader supports this type, false if not */ + bool isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const override; + + //! Creates an archive from the filename + /** \param file File handle to check. + \return Pointer to newly created archive, or 0 upon error. */ + IFileArchive *createArchive(const io::path &filename, bool ignoreCase, bool ignorePaths) const override; + + //! creates/loads an archive from the file. + //! \return Pointer to the created archive. Returns 0 if loading failed. + io::IFileArchive *createArchive(io::IReadFile *file, bool ignoreCase, bool ignorePaths) const override; + +private: + io::IFileSystem *FileSystem; +}; + +/*! + Zip file Reader written April 2002 by N.Gebhardt. +*/ +class CZipReader : public virtual IFileArchive, virtual CFileList +{ +public: + //! constructor + CZipReader(IFileSystem *fs, IReadFile *file, bool ignoreCase, bool ignorePaths, bool isGZip = false); + + //! destructor + virtual ~CZipReader(); + + //! opens a file by file name + IReadFile *createAndOpenFile(const io::path &filename) override; + + //! opens a file by index + IReadFile *createAndOpenFile(u32 index) override; + + //! returns the list of files + const IFileList *getFileList() const override; + + //! get the archive type + E_FILE_ARCHIVE_TYPE getType() const override; + + //! return the id of the file Archive + const io::path &getArchiveName() const override { return Path; } + +protected: + //! reads the next file header from a ZIP file, returns false if there are no more headers. + /* if ignoreGPBits is set, the item will be read despite missing + file information. This is used when reading items from the central + directory. */ + bool scanZipHeader(bool ignoreGPBits = false); + + //! the same but for gzip files + bool scanGZipHeader(); + + bool scanCentralDirectoryHeader(); + + io::IFileSystem *FileSystem; + IReadFile *File; + + // holds extended info about files + core::array FileInfo; + + bool IsGZip; +}; + +} // end namespace io +} // end namespace irr diff --git a/irr/src/IAttribute.h b/irr/src/IAttribute.h new file mode 100644 index 000000000..b0dc76eee --- /dev/null +++ b/irr/src/IAttribute.h @@ -0,0 +1,51 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "IReferenceCounted.h" +#include "SColor.h" +#include "vector3d.h" +#include "vector2d.h" +#include "position2d.h" +#include "rect.h" +#include "dimension2d.h" +#include "irrString.h" +#include "irrArray.h" +#include "EAttributes.h" + +namespace irr +{ +namespace io +{ + +// All derived attribute types implement at least getter/setter for their own type (like CBoolAttribute will have setBool/getBool). +// Simple types will also implement getStringW and setString, but don't expect it to work for all types. +// String serialization makes no sense for some attribute-types (like stringw arrays or pointers), but is still useful for many types. +// (Note: I do _not_ know yet why the default string serialization is asymmetric with char* in set and wchar_t* in get). +// Additionally many attribute types will implement conversion functions like CBoolAttribute has p.E. getInt/setInt(). +// The reason for conversion functions is likely to make reading old formats easier which have changed in the meantime. For example +// an old xml can contain a bool attribute which is an int in a newer format. You can still call getInt() even thought the attribute has the wrong type. +// And please do _not_ confuse these attributes here with the ones used in the xml-reader (aka SAttribute which is just a key-value pair). + +class IAttribute : public virtual IReferenceCounted +{ +public: + virtual ~IAttribute(){}; + + virtual s32 getInt() const { return 0; } + virtual f32 getFloat() const { return 0; } + virtual bool getBool() const { return false; } + + virtual void setInt(s32 intValue){}; + virtual void setFloat(f32 floatValue){}; + virtual void setBool(bool boolValue){}; + + core::stringc Name; + + virtual E_ATTRIBUTE_TYPE getType() const = 0; +}; + +} // end namespace io +} // end namespace irr diff --git a/irr/src/Irrlicht.cpp b/irr/src/Irrlicht.cpp new file mode 100644 index 000000000..c97e5d308 --- /dev/null +++ b/irr/src/Irrlicht.cpp @@ -0,0 +1,161 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +static const char *const copyright = "Irrlicht Engine (c) 2002-2017 Nikolaus Gebhardt"; // put string in binary + +#ifdef _IRR_WINDOWS_ +#include +#if defined(_DEBUG) && !defined(__GNUWIN32__) +#include +#endif // _DEBUG +#endif + +#include "irrlicht.h" +#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ +#include "CIrrDeviceWin32.h" +#endif + +#ifdef _IRR_COMPILE_WITH_X11_DEVICE_ +#include "CIrrDeviceLinux.h" +#endif + +#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ +#include "CIrrDeviceOSX.h" +#endif + +#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ +#include "CIrrDeviceSDL.h" +#endif + +#ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_ +#include "Android/CIrrDeviceAndroid.h" +#endif + +namespace irr +{ +//! stub for calling createDeviceEx +IRRLICHT_API IrrlichtDevice *IRRCALLCONV createDevice(video::E_DRIVER_TYPE driverType, + const core::dimension2d &windowSize, + u32 bits, bool fullscreen, + bool stencilbuffer, bool vsync, IEventReceiver *res) +{ + (void)copyright; // prevent unused variable warning + + SIrrlichtCreationParameters p; + p.DriverType = driverType; + p.WindowSize = windowSize; + p.Bits = (u8)bits; + p.Fullscreen = fullscreen; + p.Stencilbuffer = stencilbuffer; + p.Vsync = vsync; + p.EventReceiver = res; + + return createDeviceEx(p); +} + +extern "C" IRRLICHT_API IrrlichtDevice *IRRCALLCONV createDeviceEx(const SIrrlichtCreationParameters ¶ms) +{ + + IrrlichtDevice *dev = 0; + +#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ + if (params.DeviceType == EIDT_WIN32 || (!dev && params.DeviceType == EIDT_BEST)) + dev = new CIrrDeviceWin32(params); +#endif + +#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ + if (params.DeviceType == EIDT_OSX || (!dev && params.DeviceType == EIDT_BEST)) + dev = new CIrrDeviceMacOSX(params); +#endif + +#ifdef _IRR_COMPILE_WITH_X11_DEVICE_ + if (params.DeviceType == EIDT_X11 || (!dev && params.DeviceType == EIDT_BEST)) + dev = new CIrrDeviceLinux(params); +#endif + +#ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_ + if (params.DeviceType == EIDT_ANDROID || (!dev && params.DeviceType == EIDT_BEST)) + dev = new CIrrDeviceAndroid(params); +#endif + +#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ + if (params.DeviceType == EIDT_SDL || (!dev && params.DeviceType == EIDT_BEST)) + dev = new CIrrDeviceSDL(params); +#endif + + if (dev && !dev->getVideoDriver() && params.DriverType != video::EDT_NULL) { + dev->closeDevice(); // destroy window + dev->run(); // consume quit message + dev->drop(); + dev = 0; + } + + return dev; +} + +namespace core +{ +const matrix4 IdentityMatrix(matrix4::EM4CONST_IDENTITY); +} + +namespace video +{ +SMaterial IdentityMaterial; + +extern "C" IRRLICHT_API bool IRRCALLCONV isDriverSupported(E_DRIVER_TYPE driver) +{ + switch (driver) { + case EDT_NULL: + return true; +#ifdef ENABLE_OPENGL3 + case EDT_OPENGL3: + return true; +#endif +#ifdef _IRR_COMPILE_WITH_OPENGL_ + case EDT_OPENGL: + return true; +#endif +#ifdef _IRR_COMPILE_WITH_OGLES1_ + case EDT_OGLES1: + return true; +#endif +#ifdef _IRR_COMPILE_WITH_OGLES2_ + case EDT_OGLES2: + return true; +#endif +#ifdef _IRR_COMPILE_WITH_WEBGL1_ + case EDT_WEBGL1: + return true; +#endif + default: + return false; + } +} +} + +} // end namespace irr + +#if defined(_IRR_WINDOWS_API_) && !defined(_IRR_STATIC_LIB_) + +BOOL APIENTRY DllMain(HANDLE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved) +{ + // _crtBreakAlloc = 139; + + switch (ul_reason_for_call) { + case DLL_PROCESS_ATTACH: +#if defined(_DEBUG) && !defined(__GNUWIN32__) + _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF); +#endif + break; + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + +#endif // defined(_IRR_WINDOWS_) diff --git a/irr/src/KHR/khrplatform.h b/irr/src/KHR/khrplatform.h new file mode 100644 index 000000000..84821e08b --- /dev/null +++ b/irr/src/KHR/khrplatform.h @@ -0,0 +1,310 @@ +#ifndef __khrplatform_h_ +#define __khrplatform_h_ + +/* +** Copyright (c) 2008-2018 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Khronos platform-specific types and definitions. + * + * The master copy of khrplatform.h is maintained in the Khronos EGL + * Registry repository at https://github.com/KhronosGroup/EGL-Registry + * The last semantic modification to khrplatform.h was at commit ID: + * 67a3e0864c2d75ea5287b9f3d2eb74a745936692 + * + * Adopters may modify this file to suit their platform. Adopters are + * encouraged to submit platform specific modifications to the Khronos + * group so that they can be included in future versions of this file. + * Please submit changes by filing pull requests or issues on + * the EGL Registry repository linked above. + * + * + * See the Implementer's Guidelines for information about where this file + * should be located on your system and for more details of its use: + * http://www.khronos.org/registry/implementers_guide.pdf + * + * This file should be included as + * #include + * by Khronos client API header files that use its types and defines. + * + * The types in khrplatform.h should only be used to define API-specific types. + * + * Types defined in khrplatform.h: + * khronos_int8_t signed 8 bit + * khronos_uint8_t unsigned 8 bit + * khronos_int16_t signed 16 bit + * khronos_uint16_t unsigned 16 bit + * khronos_int32_t signed 32 bit + * khronos_uint32_t unsigned 32 bit + * khronos_int64_t signed 64 bit + * khronos_uint64_t unsigned 64 bit + * khronos_intptr_t signed same number of bits as a pointer + * khronos_uintptr_t unsigned same number of bits as a pointer + * khronos_ssize_t signed size + * khronos_usize_t unsigned size + * khronos_float_t signed 32 bit floating point + * khronos_time_ns_t unsigned 64 bit time in nanoseconds + * khronos_utime_nanoseconds_t unsigned time interval or absolute time in + * nanoseconds + * khronos_stime_nanoseconds_t signed time interval in nanoseconds + * khronos_boolean_enum_t enumerated boolean type. This should + * only be used as a base type when a client API's boolean type is + * an enum. Client APIs which use an integer or other type for + * booleans cannot use this as the base type for their boolean. + * + * Tokens defined in khrplatform.h: + * + * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. + * + * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. + * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. + * + * Calling convention macros defined in this file: + * KHRONOS_APICALL + * KHRONOS_APIENTRY + * KHRONOS_APIATTRIBUTES + * + * These may be used in function prototypes as: + * + * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( + * int arg1, + * int arg2) KHRONOS_APIATTRIBUTES; + */ + +#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC) +#define KHRONOS_STATIC 1 +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APICALL + *------------------------------------------------------------------------- + * This precedes the return type of the function in the function prototype. + */ +#if defined(KHRONOS_STATIC) +/* If the preprocessor constant KHRONOS_STATIC is defined, make the + * header compatible with static linking. */ +#define KHRONOS_APICALL +#elif defined(_WIN32) +#define KHRONOS_APICALL __declspec(dllimport) +#elif defined(__SYMBIAN32__) +#define KHRONOS_APICALL IMPORT_C +#elif defined(__ANDROID__) +#define KHRONOS_APICALL __attribute__((visibility("default"))) +#else +#define KHRONOS_APICALL +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIENTRY + *------------------------------------------------------------------------- + * This follows the return type of the function and precedes the function + * name in the function prototype. + */ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) +/* Win32 but not WinCE */ +#define KHRONOS_APIENTRY __stdcall +#else +#define KHRONOS_APIENTRY +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIATTRIBUTES + *------------------------------------------------------------------------- + * This follows the closing parenthesis of the function prototype arguments. + */ +#if defined(__ARMCC_2__) +#define KHRONOS_APIATTRIBUTES __softfp +#else +#define KHRONOS_APIATTRIBUTES +#endif + +/*------------------------------------------------------------------------- + * basic type definitions + *-----------------------------------------------------------------------*/ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 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) + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) + +/* + * Win32 + */ +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__sun__) || defined(__digital__) + +/* + * Sun or Digital + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#if defined(__arch64__) || defined(_LP64) +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; +#else +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; +#endif /* __arch64__ */ +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif 0 + +/* + * Hypothetical platform with no float or int64 support + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 + +#else + +/* + * Generic fallback + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#endif + +/* + * Types that are (so far) the same on all platforms + */ +typedef signed char khronos_int8_t; +typedef unsigned char khronos_uint8_t; +typedef signed short int khronos_int16_t; +typedef unsigned short int khronos_uint16_t; + +/* + * Types that differ between LLP64 and LP64 architectures - in LLP64, + * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears + * to be the only LLP64 architecture in current use. + */ +#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 unsigned long long int khronos_uintptr_t; +#else +typedef signed long int khronos_intptr_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 unsigned long int khronos_usize_t; +#endif + +#if KHRONOS_SUPPORT_FLOAT +/* + * Float type + */ +typedef float khronos_float_t; +#endif + +#if KHRONOS_SUPPORT_INT64 +/* Time types + * + * These types can be used to represent a time interval in nanoseconds or + * an absolute Unadjusted System Time. Unadjusted System Time is the number + * of nanoseconds since some arbitrary system event (e.g. since the last + * time the system booted). The Unadjusted System Time is an unsigned + * 64 bit value that wraps back to 0 every 584 years. Time intervals + * may be either signed or unsigned. + */ +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; +#endif + +/* + * Dummy value used to pad enum types to 32 bits. + */ +#ifndef KHRONOS_MAX_ENUM +#define KHRONOS_MAX_ENUM 0x7FFFFFFF +#endif + +/* + * Enumerated boolean type + * + * Values other than zero should be considered to be true. Therefore + * comparisons should not be made against KHRONOS_TRUE. + */ +typedef enum +{ + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM +} khronos_boolean_enum_t; + +#endif /* __khrplatform_h_ */ diff --git a/irr/src/OpenGL/Common.h b/irr/src/OpenGL/Common.h new file mode 100644 index 000000000..92445cc34 --- /dev/null +++ b/irr/src/OpenGL/Common.h @@ -0,0 +1,57 @@ +// Copyright (C) 2023 Vitaliy Lobachevskiy +// Copyright (C) 2015 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" +// even though we have mt_opengl.h our driver code still uses GL_* constants +#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) +#include +#include +#else +#include "vendor/gl.h" +#endif + +namespace irr +{ +namespace video +{ + +// Forward declarations. + +class COpenGLCoreFeature; + +template +class COpenGLCoreTexture; + +template +class COpenGLCoreRenderTarget; + +template +class COpenGLCoreCacheHandler; + +class COpenGL3DriverBase; +typedef COpenGLCoreTexture COpenGL3Texture; +typedef COpenGLCoreRenderTarget COpenGL3RenderTarget; +typedef COpenGLCoreCacheHandler COpenGL3CacheHandler; + +enum class OpenGLSpec : u8 +{ + Core, + Compat, + ES, + // WebGL, // TODO +}; + +struct OpenGLVersion +{ + OpenGLSpec Spec; + u8 Major; + u8 Minor; + u8 Release; +}; + +} +} diff --git a/irr/src/OpenGL/Driver.cpp b/irr/src/OpenGL/Driver.cpp new file mode 100644 index 000000000..73c3451f7 --- /dev/null +++ b/irr/src/OpenGL/Driver.cpp @@ -0,0 +1,1991 @@ +// Copyright (C) 2023 Vitaliy Lobachevskiy +// Copyright (C) 2014 Patryk Nadrowski +// Copyright (C) 2009-2010 Amundis +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#include "Driver.h" +#include +#include "CNullDriver.h" +#include "IContextManager.h" + +#include "COpenGLCoreTexture.h" +#include "COpenGLCoreRenderTarget.h" +#include "COpenGLCoreCacheHandler.h" + +#include "MaterialRenderer.h" +#include "FixedPipelineRenderer.h" +#include "Renderer2D.h" + +#include "EVertexAttributes.h" +#include "CImage.h" +#include "os.h" + +#ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_ +#include "android_native_app_glue.h" +#endif + +#include "mt_opengl.h" + +namespace irr +{ +namespace video +{ +struct VertexAttribute +{ + enum class Mode + { + Regular, + Normalized, + Integral, + }; + int Index; + int ComponentCount; + GLenum ComponentType; + Mode mode; + int Offset; +}; + +struct VertexType +{ + int VertexSize; + std::vector Attributes; +}; + +static const VertexAttribute *begin(const VertexType &type) +{ + return type.Attributes.data(); +} + +static const VertexAttribute *end(const VertexType &type) +{ + return type.Attributes.data() + type.Attributes.size(); +} + +static const VertexType vtStandard = { + sizeof(S3DVertex), + { + {EVA_POSITION, 3, GL_FLOAT, VertexAttribute::Mode::Regular, offsetof(S3DVertex, Pos)}, + {EVA_NORMAL, 3, GL_FLOAT, VertexAttribute::Mode::Regular, offsetof(S3DVertex, Normal)}, + {EVA_COLOR, 4, GL_UNSIGNED_BYTE, VertexAttribute::Mode::Normalized, offsetof(S3DVertex, Color)}, + {EVA_TCOORD0, 2, GL_FLOAT, VertexAttribute::Mode::Regular, offsetof(S3DVertex, TCoords)}, + }, +}; + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winvalid-offsetof" + +static const VertexType vt2TCoords = { + sizeof(S3DVertex2TCoords), + { + {EVA_POSITION, 3, GL_FLOAT, VertexAttribute::Mode::Regular, offsetof(S3DVertex2TCoords, Pos)}, + {EVA_NORMAL, 3, GL_FLOAT, VertexAttribute::Mode::Regular, offsetof(S3DVertex2TCoords, Normal)}, + {EVA_COLOR, 4, GL_UNSIGNED_BYTE, VertexAttribute::Mode::Normalized, offsetof(S3DVertex2TCoords, Color)}, + {EVA_TCOORD0, 2, GL_FLOAT, VertexAttribute::Mode::Regular, offsetof(S3DVertex2TCoords, TCoords)}, + {EVA_TCOORD1, 2, GL_FLOAT, VertexAttribute::Mode::Regular, offsetof(S3DVertex2TCoords, TCoords2)}, + }, +}; + +static const VertexType vtTangents = { + sizeof(S3DVertexTangents), + { + {EVA_POSITION, 3, GL_FLOAT, VertexAttribute::Mode::Regular, offsetof(S3DVertexTangents, Pos)}, + {EVA_NORMAL, 3, GL_FLOAT, VertexAttribute::Mode::Regular, offsetof(S3DVertexTangents, Normal)}, + {EVA_COLOR, 4, GL_UNSIGNED_BYTE, VertexAttribute::Mode::Normalized, offsetof(S3DVertexTangents, Color)}, + {EVA_TCOORD0, 2, GL_FLOAT, VertexAttribute::Mode::Regular, offsetof(S3DVertexTangents, TCoords)}, + {EVA_TANGENT, 3, GL_FLOAT, VertexAttribute::Mode::Regular, offsetof(S3DVertexTangents, Tangent)}, + {EVA_BINORMAL, 3, GL_FLOAT, VertexAttribute::Mode::Regular, offsetof(S3DVertexTangents, Binormal)}, + }, +}; + +#pragma GCC diagnostic pop + +static const VertexType &getVertexTypeDescription(E_VERTEX_TYPE type) +{ + switch (type) { + case EVT_STANDARD: + return vtStandard; + case EVT_2TCOORDS: + return vt2TCoords; + case EVT_TANGENTS: + return vtTangents; + default: + assert(false); + } +} + +static const VertexType vt2DImage = { + sizeof(S3DVertex), + { + {EVA_POSITION, 3, GL_FLOAT, VertexAttribute::Mode::Regular, offsetof(S3DVertex, Pos)}, + {EVA_COLOR, 4, GL_UNSIGNED_BYTE, VertexAttribute::Mode::Normalized, offsetof(S3DVertex, Color)}, + {EVA_TCOORD0, 2, GL_FLOAT, VertexAttribute::Mode::Regular, offsetof(S3DVertex, TCoords)}, + }, +}; + +static const VertexType vtPrimitive = { + sizeof(S3DVertex), + { + {EVA_POSITION, 3, GL_FLOAT, VertexAttribute::Mode::Regular, offsetof(S3DVertex, Pos)}, + {EVA_COLOR, 4, GL_UNSIGNED_BYTE, VertexAttribute::Mode::Normalized, offsetof(S3DVertex, Color)}, + }, +}; + +void APIENTRY COpenGL3DriverBase::debugCb(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam) +{ + ((COpenGL3DriverBase *)userParam)->debugCb(source, type, id, severity, length, message); +} + +void COpenGL3DriverBase::debugCb(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message) +{ + printf("%04x %04x %x %x %.*s\n", source, type, id, severity, length, message); +} + +COpenGL3DriverBase::COpenGL3DriverBase(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager) : + CNullDriver(io, params.WindowSize), COpenGL3ExtensionHandler(), CacheHandler(0), + Params(params), ResetRenderStates(true), LockRenderStateMode(false), AntiAlias(params.AntiAlias), + MaterialRenderer2DActive(0), MaterialRenderer2DTexture(0), MaterialRenderer2DNoTexture(0), + CurrentRenderMode(ERM_NONE), Transformation3DChanged(true), + OGLES2ShaderPath(params.OGLES2ShaderPath), + ColorFormat(ECF_R8G8B8), ContextManager(contextManager) +{ +#ifdef _DEBUG + setDebugName("Driver"); +#endif + + if (!ContextManager) + return; + + ContextManager->grab(); + ContextManager->generateSurface(); + ContextManager->generateContext(); + ExposedData = ContextManager->getContext(); + ContextManager->activateContext(ExposedData, false); + GL.LoadAllProcedures(ContextManager); + GL.DebugMessageCallback(debugCb, this); + initQuadsIndices(); +} + +COpenGL3DriverBase::~COpenGL3DriverBase() +{ + deleteMaterialRenders(); + + CacheHandler->getTextureCache().clear(); + + removeAllRenderTargets(); + deleteAllTextures(); + removeAllOcclusionQueries(); + removeAllHardwareBuffers(); + + delete MaterialRenderer2DTexture; + delete MaterialRenderer2DNoTexture; + delete CacheHandler; + + if (ContextManager) { + ContextManager->destroyContext(); + ContextManager->destroySurface(); + ContextManager->terminate(); + ContextManager->drop(); + } +} + +void COpenGL3DriverBase::initQuadsIndices(int max_vertex_count) +{ + int max_quad_count = max_vertex_count / 4; + std::vector QuadsIndices; + QuadsIndices.reserve(6 * max_quad_count); + for (int k = 0; k < max_quad_count; k++) { + QuadsIndices.push_back(4 * k + 0); + QuadsIndices.push_back(4 * k + 1); + QuadsIndices.push_back(4 * k + 2); + QuadsIndices.push_back(4 * k + 0); + QuadsIndices.push_back(4 * k + 2); + QuadsIndices.push_back(4 * k + 3); + } + GL.GenBuffers(1, &QuadIndexBuffer); + GL.BindBuffer(GL_ARRAY_BUFFER, QuadIndexBuffer); + GL.BufferData(GL_ARRAY_BUFFER, sizeof(QuadsIndices[0]) * QuadsIndices.size(), QuadsIndices.data(), GL_STATIC_DRAW); + GL.BindBuffer(GL_ARRAY_BUFFER, 0); + QuadIndexCount = QuadsIndices.size(); +} + +void COpenGL3DriverBase::initVersion() +{ + Name = GL.GetString(GL_VERSION); + printVersion(); + + // print renderer information + VendorName = GL.GetString(GL_VENDOR); + os::Printer::log("Vendor", VendorName.c_str(), ELL_INFORMATION); + + Version = getVersionFromOpenGL(); +} + +bool COpenGL3DriverBase::isVersionAtLeast(int major, int minor) const noexcept +{ + if (Version.Major < major) + return false; + if (Version.Major > major) + return true; + return Version.Minor >= minor; +} + +bool COpenGL3DriverBase::genericDriverInit(const core::dimension2d &screenSize, bool stencilBuffer) +{ + initVersion(); + initFeatures(); + printTextureFormats(); + + // reset cache handler + delete CacheHandler; + CacheHandler = new COpenGL3CacheHandler(this); + + StencilBuffer = stencilBuffer; + + DriverAttributes->setAttribute("MaxTextures", (s32)Feature.MaxTextureUnits); + DriverAttributes->setAttribute("MaxSupportedTextures", (s32)Feature.MaxTextureUnits); + // DriverAttributes->setAttribute("MaxLights", MaxLights); + DriverAttributes->setAttribute("MaxAnisotropy", MaxAnisotropy); + // DriverAttributes->setAttribute("MaxUserClipPlanes", MaxUserClipPlanes); + // DriverAttributes->setAttribute("MaxAuxBuffers", MaxAuxBuffers); + // DriverAttributes->setAttribute("MaxMultipleRenderTargets", MaxMultipleRenderTargets); + DriverAttributes->setAttribute("MaxIndices", (s32)MaxIndices); + DriverAttributes->setAttribute("MaxTextureSize", (s32)MaxTextureSize); + DriverAttributes->setAttribute("MaxTextureLODBias", MaxTextureLODBias); + DriverAttributes->setAttribute("Version", 100 * Version.Major + Version.Minor); + DriverAttributes->setAttribute("AntiAlias", AntiAlias); + + GL.PixelStorei(GL_PACK_ALIGNMENT, 1); + + UserClipPlane.reallocate(0); + + for (s32 i = 0; i < ETS_COUNT; ++i) + setTransform(static_cast(i), core::IdentityMatrix); + + setAmbientLight(SColorf(0.0f, 0.0f, 0.0f, 0.0f)); + GL.ClearDepthf(1.0f); + + GL.Hint(GL_GENERATE_MIPMAP_HINT, GL_NICEST); + GL.FrontFace(GL_CW); + + // create material renderers + createMaterialRenderers(); + + // set the renderstates + setRenderStates3DMode(); + + // set fog mode + setFog(FogColor, FogType, FogStart, FogEnd, FogDensity, PixelFog, RangeFog); + + // create matrix for flipping textures + TextureFlipMatrix.buildTextureTransform(0.0f, core::vector2df(0, 0), core::vector2df(0, 1.0f), core::vector2df(1.0f, -1.0f)); + + // We need to reset once more at the beginning of the first rendering. + // This fixes problems with intermediate changes to the material during texture load. + ResetRenderStates = true; + + testGLError(__LINE__); + + return true; +} + +void COpenGL3DriverBase::printTextureFormats() +{ + char buf[128]; + for (u32 i = 0; i < static_cast(ECF_UNKNOWN); i++) { + auto &info = TextureFormats[i]; + if (!info.InternalFormat) { + snprintf_irr(buf, sizeof(buf), "%s -> unsupported", ColorFormatNames[i]); + } else { + snprintf_irr(buf, sizeof(buf), "%s -> %#06x %#06x %#06x%s", + ColorFormatNames[i], info.InternalFormat, info.PixelFormat, + info.PixelType, info.Converter ? " (c)" : ""); + } + os::Printer::log(buf, ELL_DEBUG); + } +} + +void COpenGL3DriverBase::loadShaderData(const io::path &vertexShaderName, const io::path &fragmentShaderName, c8 **vertexShaderData, c8 **fragmentShaderData) +{ + io::path vsPath(OGLES2ShaderPath); + vsPath += vertexShaderName; + + io::path fsPath(OGLES2ShaderPath); + fsPath += fragmentShaderName; + + *vertexShaderData = 0; + *fragmentShaderData = 0; + + io::IReadFile *vsFile = FileSystem->createAndOpenFile(vsPath); + if (!vsFile) { + std::string warning("Warning: Missing shader files needed to simulate fixed function materials:\n"); + warning.append(vsPath.c_str()).append("\n"); + warning += "Shaderpath can be changed in SIrrCreationParamters::OGLES2ShaderPath"; + os::Printer::log(warning.c_str(), ELL_WARNING); + return; + } + + io::IReadFile *fsFile = FileSystem->createAndOpenFile(fsPath); + if (!fsFile) { + std::string warning("Warning: Missing shader files needed to simulate fixed function materials:\n"); + warning.append(fsPath.c_str()).append("\n"); + warning += "Shaderpath can be changed in SIrrCreationParamters::OGLES2ShaderPath"; + os::Printer::log(warning.c_str(), ELL_WARNING); + return; + } + + long size = vsFile->getSize(); + if (size) { + *vertexShaderData = new c8[size + 1]; + vsFile->read(*vertexShaderData, size); + (*vertexShaderData)[size] = 0; + } + { + auto tmp = std::string("Loaded ") + std::to_string(size) + " bytes for vertex shader " + vertexShaderName.c_str(); + os::Printer::log(tmp.c_str(), ELL_INFORMATION); + } + + size = fsFile->getSize(); + if (size) { + // if both handles are the same we must reset the file + if (fsFile == vsFile) + fsFile->seek(0); + + *fragmentShaderData = new c8[size + 1]; + fsFile->read(*fragmentShaderData, size); + (*fragmentShaderData)[size] = 0; + } + { + auto tmp = std::string("Loaded ") + std::to_string(size) + " bytes for fragment shader " + fragmentShaderName.c_str(); + os::Printer::log(tmp.c_str(), ELL_INFORMATION); + } + + vsFile->drop(); + fsFile->drop(); +} + +void COpenGL3DriverBase::createMaterialRenderers() +{ + // Create callbacks. + + COpenGL3MaterialSolidCB *SolidCB = new COpenGL3MaterialSolidCB(); + COpenGL3MaterialSolidCB *TransparentAlphaChannelCB = new COpenGL3MaterialSolidCB(); + COpenGL3MaterialSolidCB *TransparentAlphaChannelRefCB = new COpenGL3MaterialSolidCB(); + COpenGL3MaterialSolidCB *TransparentVertexAlphaCB = new COpenGL3MaterialSolidCB(); + COpenGL3MaterialOneTextureBlendCB *OneTextureBlendCB = new COpenGL3MaterialOneTextureBlendCB(); + + // Create built-in materials. + // The addition order must be the same as in the E_MATERIAL_TYPE enumeration. Thus the + + const core::stringc VertexShader = OGLES2ShaderPath + "Solid.vsh"; + + // EMT_SOLID + core::stringc FragmentShader = OGLES2ShaderPath + "Solid.fsh"; + addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main", + EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, SolidCB, EMT_SOLID, 0); + + // EMT_TRANSPARENT_ALPHA_CHANNEL + FragmentShader = OGLES2ShaderPath + "TransparentAlphaChannel.fsh"; + addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main", + EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, TransparentAlphaChannelCB, EMT_TRANSPARENT_ALPHA_CHANNEL, 0); + + // EMT_TRANSPARENT_ALPHA_CHANNEL_REF + FragmentShader = OGLES2ShaderPath + "TransparentAlphaChannelRef.fsh"; + addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main", + EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, TransparentAlphaChannelRefCB, EMT_SOLID, 0); + + // EMT_TRANSPARENT_VERTEX_ALPHA + FragmentShader = OGLES2ShaderPath + "TransparentVertexAlpha.fsh"; + addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main", + EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, TransparentVertexAlphaCB, EMT_TRANSPARENT_ALPHA_CHANNEL, 0); + + // EMT_ONETEXTURE_BLEND + FragmentShader = OGLES2ShaderPath + "OneTextureBlend.fsh"; + addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main", + EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, OneTextureBlendCB, EMT_ONETEXTURE_BLEND, 0); + + // Drop callbacks. + + SolidCB->drop(); + TransparentAlphaChannelCB->drop(); + TransparentAlphaChannelRefCB->drop(); + TransparentVertexAlphaCB->drop(); + OneTextureBlendCB->drop(); + + // Create 2D material renderers + + c8 *vs2DData = 0; + c8 *fs2DData = 0; + loadShaderData(io::path("Renderer2D.vsh"), io::path("Renderer2D.fsh"), &vs2DData, &fs2DData); + MaterialRenderer2DTexture = new COpenGL3Renderer2D(vs2DData, fs2DData, this, true); + delete[] vs2DData; + delete[] fs2DData; + vs2DData = 0; + fs2DData = 0; + + loadShaderData(io::path("Renderer2D.vsh"), io::path("Renderer2D_noTex.fsh"), &vs2DData, &fs2DData); + MaterialRenderer2DNoTexture = new COpenGL3Renderer2D(vs2DData, fs2DData, this, false); + delete[] vs2DData; + delete[] fs2DData; +} + +bool COpenGL3DriverBase::setMaterialTexture(irr::u32 layerIdx, const irr::video::ITexture *texture) +{ + Material.TextureLayers[layerIdx].Texture = const_cast(texture); // function uses const-pointer for texture because all draw functions use const-pointers already + return CacheHandler->getTextureCache().set(0, texture); +} + +bool COpenGL3DriverBase::beginScene(u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil, const SExposedVideoData &videoData, core::rect *sourceRect) +{ + CNullDriver::beginScene(clearFlag, clearColor, clearDepth, clearStencil, videoData, sourceRect); + + if (ContextManager) + ContextManager->activateContext(videoData, true); + + clearBuffers(clearFlag, clearColor, clearDepth, clearStencil); + + return true; +} + +bool COpenGL3DriverBase::endScene() +{ + CNullDriver::endScene(); + + GL.Flush(); + + if (ContextManager) + return ContextManager->swapBuffers(); + + return false; +} + +//! Returns the transformation set by setTransform +const core::matrix4 &COpenGL3DriverBase::getTransform(E_TRANSFORMATION_STATE state) const +{ + return Matrices[state]; +} + +//! sets transformation +void COpenGL3DriverBase::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4 &mat) +{ + Matrices[state] = mat; + Transformation3DChanged = true; +} + +bool COpenGL3DriverBase::updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer) +{ + if (!HWBuffer) + return false; + + const scene::IMeshBuffer *mb = HWBuffer->MeshBuffer; + const void *vertices = mb->getVertices(); + const u32 vertexCount = mb->getVertexCount(); + const E_VERTEX_TYPE vType = mb->getVertexType(); + const u32 vertexSize = getVertexPitchFromType(vType); + + const void *buffer = vertices; + size_t bufferSize = vertexSize * vertexCount; + + // get or create buffer + bool newBuffer = false; + if (!HWBuffer->vbo_verticesID) { + GL.GenBuffers(1, &HWBuffer->vbo_verticesID); + if (!HWBuffer->vbo_verticesID) + return false; + newBuffer = true; + } else if (HWBuffer->vbo_verticesSize < bufferSize) { + newBuffer = true; + } + + GL.BindBuffer(GL_ARRAY_BUFFER, HWBuffer->vbo_verticesID); + + // copy data to graphics card + if (!newBuffer) + GL.BufferSubData(GL_ARRAY_BUFFER, 0, bufferSize, buffer); + else { + HWBuffer->vbo_verticesSize = bufferSize; + + GLenum usage = GL_STATIC_DRAW; + if (HWBuffer->Mapped_Index == scene::EHM_STREAM) + usage = GL_STREAM_DRAW; + else if (HWBuffer->Mapped_Index == scene::EHM_DYNAMIC) + usage = GL_DYNAMIC_DRAW; + GL.BufferData(GL_ARRAY_BUFFER, bufferSize, buffer, usage); + } + + GL.BindBuffer(GL_ARRAY_BUFFER, 0); + + return (!testGLError(__LINE__)); +} + +bool COpenGL3DriverBase::updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer) +{ + if (!HWBuffer) + return false; + + const scene::IMeshBuffer *mb = HWBuffer->MeshBuffer; + + const void *indices = mb->getIndices(); + u32 indexCount = mb->getIndexCount(); + + GLenum indexSize; + switch (mb->getIndexType()) { + case (EIT_16BIT): { + indexSize = sizeof(u16); + break; + } + case (EIT_32BIT): { + indexSize = sizeof(u32); + break; + } + default: { + return false; + } + } + + // get or create buffer + bool newBuffer = false; + if (!HWBuffer->vbo_indicesID) { + GL.GenBuffers(1, &HWBuffer->vbo_indicesID); + if (!HWBuffer->vbo_indicesID) + return false; + newBuffer = true; + } else if (HWBuffer->vbo_indicesSize < indexCount * indexSize) { + newBuffer = true; + } + + GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, HWBuffer->vbo_indicesID); + + // copy data to graphics card + if (!newBuffer) + GL.BufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, indexCount * indexSize, indices); + else { + HWBuffer->vbo_indicesSize = indexCount * indexSize; + + GLenum usage = GL_STATIC_DRAW; + if (HWBuffer->Mapped_Index == scene::EHM_STREAM) + usage = GL_STREAM_DRAW; + else if (HWBuffer->Mapped_Index == scene::EHM_DYNAMIC) + usage = GL_DYNAMIC_DRAW; + GL.BufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, usage); + } + + GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + + return (!testGLError(__LINE__)); +} + +//! updates hardware buffer if needed +bool COpenGL3DriverBase::updateHardwareBuffer(SHWBufferLink *HWBuffer) +{ + if (!HWBuffer) + return false; + + if (HWBuffer->Mapped_Vertex != scene::EHM_NEVER) { + if (HWBuffer->ChangedID_Vertex != HWBuffer->MeshBuffer->getChangedID_Vertex() || !static_cast(HWBuffer)->vbo_verticesID) { + + HWBuffer->ChangedID_Vertex = HWBuffer->MeshBuffer->getChangedID_Vertex(); + + if (!updateVertexHardwareBuffer(static_cast(HWBuffer))) + return false; + } + } + + if (HWBuffer->Mapped_Index != scene::EHM_NEVER) { + if (HWBuffer->ChangedID_Index != HWBuffer->MeshBuffer->getChangedID_Index() || !static_cast(HWBuffer)->vbo_indicesID) { + + HWBuffer->ChangedID_Index = HWBuffer->MeshBuffer->getChangedID_Index(); + + if (!updateIndexHardwareBuffer((SHWBufferLink_opengl *)HWBuffer)) + return false; + } + } + + return true; +} + +//! Create hardware buffer from meshbuffer +COpenGL3DriverBase::SHWBufferLink *COpenGL3DriverBase::createHardwareBuffer(const scene::IMeshBuffer *mb) +{ + if (!mb || (mb->getHardwareMappingHint_Index() == scene::EHM_NEVER && mb->getHardwareMappingHint_Vertex() == scene::EHM_NEVER)) + return 0; + + SHWBufferLink_opengl *HWBuffer = new SHWBufferLink_opengl(mb); + + // add to map + HWBuffer->listPosition = HWBufferList.insert(HWBufferList.end(), HWBuffer); + + HWBuffer->ChangedID_Vertex = HWBuffer->MeshBuffer->getChangedID_Vertex(); + HWBuffer->ChangedID_Index = HWBuffer->MeshBuffer->getChangedID_Index(); + HWBuffer->Mapped_Vertex = mb->getHardwareMappingHint_Vertex(); + HWBuffer->Mapped_Index = mb->getHardwareMappingHint_Index(); + HWBuffer->vbo_verticesID = 0; + HWBuffer->vbo_indicesID = 0; + HWBuffer->vbo_verticesSize = 0; + HWBuffer->vbo_indicesSize = 0; + + if (!updateHardwareBuffer(HWBuffer)) { + deleteHardwareBuffer(HWBuffer); + return 0; + } + + return HWBuffer; +} + +void COpenGL3DriverBase::deleteHardwareBuffer(SHWBufferLink *_HWBuffer) +{ + if (!_HWBuffer) + return; + + SHWBufferLink_opengl *HWBuffer = static_cast(_HWBuffer); + if (HWBuffer->vbo_verticesID) { + GL.DeleteBuffers(1, &HWBuffer->vbo_verticesID); + HWBuffer->vbo_verticesID = 0; + } + if (HWBuffer->vbo_indicesID) { + GL.DeleteBuffers(1, &HWBuffer->vbo_indicesID); + HWBuffer->vbo_indicesID = 0; + } + + CNullDriver::deleteHardwareBuffer(_HWBuffer); +} + +//! Draw hardware buffer +void COpenGL3DriverBase::drawHardwareBuffer(SHWBufferLink *_HWBuffer) +{ + if (!_HWBuffer) + return; + + SHWBufferLink_opengl *HWBuffer = static_cast(_HWBuffer); + + updateHardwareBuffer(HWBuffer); // check if update is needed + + const scene::IMeshBuffer *mb = HWBuffer->MeshBuffer; + const void *vertices = mb->getVertices(); + const void *indexList = mb->getIndices(); + + if (HWBuffer->Mapped_Vertex != scene::EHM_NEVER) { + GL.BindBuffer(GL_ARRAY_BUFFER, HWBuffer->vbo_verticesID); + vertices = 0; + } + + if (HWBuffer->Mapped_Index != scene::EHM_NEVER) { + GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, HWBuffer->vbo_indicesID); + indexList = 0; + } + + drawVertexPrimitiveList(vertices, mb->getVertexCount(), + indexList, mb->getPrimitiveCount(), + mb->getVertexType(), mb->getPrimitiveType(), + mb->getIndexType()); + + if (HWBuffer->Mapped_Vertex != scene::EHM_NEVER) + GL.BindBuffer(GL_ARRAY_BUFFER, 0); + + if (HWBuffer->Mapped_Index != scene::EHM_NEVER) + GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); +} + +IRenderTarget *COpenGL3DriverBase::addRenderTarget() +{ + COpenGL3RenderTarget *renderTarget = new COpenGL3RenderTarget(this); + RenderTargets.push_back(renderTarget); + + return renderTarget; +} + +// small helper function to create vertex buffer object adress offsets +static inline u8 *buffer_offset(const long offset) +{ + return ((u8 *)0 + offset); +} + +//! draws a vertex primitive list +void COpenGL3DriverBase::drawVertexPrimitiveList(const void *vertices, u32 vertexCount, + const void *indexList, u32 primitiveCount, + E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) +{ + if (!primitiveCount || !vertexCount) + return; + + if (!checkPrimitiveCount(primitiveCount)) + return; + + CNullDriver::drawVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType, iType); + + setRenderStates3DMode(); + + auto &vTypeDesc = getVertexTypeDescription(vType); + beginDraw(vTypeDesc, reinterpret_cast(vertices)); + GLenum indexSize = 0; + + switch (iType) { + case (EIT_16BIT): { + indexSize = GL_UNSIGNED_SHORT; + break; + } + case (EIT_32BIT): { +#ifdef GL_OES_element_index_uint +#ifndef GL_UNSIGNED_INT +#define GL_UNSIGNED_INT 0x1405 +#endif + if (FeatureAvailable[COGLESCoreExtensionHandler::IRR_GL_OES_element_index_uint]) + indexSize = GL_UNSIGNED_INT; + else +#endif + indexSize = GL_UNSIGNED_SHORT; + break; + } + } + + switch (pType) { + case scene::EPT_POINTS: + case scene::EPT_POINT_SPRITES: + GL.DrawArrays(GL_POINTS, 0, primitiveCount); + break; + case scene::EPT_LINE_STRIP: + GL.DrawElements(GL_LINE_STRIP, primitiveCount + 1, indexSize, indexList); + break; + case scene::EPT_LINE_LOOP: + GL.DrawElements(GL_LINE_LOOP, primitiveCount, indexSize, indexList); + break; + case scene::EPT_LINES: + GL.DrawElements(GL_LINES, primitiveCount * 2, indexSize, indexList); + break; + case scene::EPT_TRIANGLE_STRIP: + GL.DrawElements(GL_TRIANGLE_STRIP, primitiveCount + 2, indexSize, indexList); + break; + case scene::EPT_TRIANGLE_FAN: + GL.DrawElements(GL_TRIANGLE_FAN, primitiveCount + 2, indexSize, indexList); + break; + case scene::EPT_TRIANGLES: + GL.DrawElements((LastMaterial.Wireframe) ? GL_LINES : (LastMaterial.PointCloud) ? GL_POINTS + : GL_TRIANGLES, + primitiveCount * 3, indexSize, indexList); + break; + default: + break; + } + + endDraw(vTypeDesc); +} + +void COpenGL3DriverBase::draw2DImage(const video::ITexture *texture, const core::position2d &destPos, + const core::rect &sourceRect, const core::rect *clipRect, SColor color, + bool useAlphaChannelOfTexture) +{ + if (!texture) + return; + + if (!sourceRect.isValid()) + return; + + SColor colors[4] = {color, color, color, color}; + draw2DImage(texture, {destPos, sourceRect.getSize()}, sourceRect, clipRect, colors, useAlphaChannelOfTexture); +} + +void COpenGL3DriverBase::draw2DImage(const video::ITexture *texture, const core::rect &destRect, + const core::rect &sourceRect, const core::rect *clipRect, + const video::SColor *const colors, bool useAlphaChannelOfTexture) +{ + if (!texture) + return; + + // texcoords need to be flipped horizontally for RTTs + const bool isRTT = texture->isRenderTarget(); + const core::dimension2du &ss = texture->getOriginalSize(); + const f32 invW = 1.f / static_cast(ss.Width); + const f32 invH = 1.f / static_cast(ss.Height); + const core::rect tcoords( + sourceRect.UpperLeftCorner.X * invW, + (isRTT ? sourceRect.LowerRightCorner.Y : sourceRect.UpperLeftCorner.Y) * invH, + sourceRect.LowerRightCorner.X * invW, + (isRTT ? sourceRect.UpperLeftCorner.Y : sourceRect.LowerRightCorner.Y) * invH); + + const video::SColor temp[4] = { + 0xFFFFFFFF, + 0xFFFFFFFF, + 0xFFFFFFFF, + 0xFFFFFFFF, + }; + + const video::SColor *const useColor = colors ? colors : temp; + + chooseMaterial2D(); + if (!setMaterialTexture(0, texture)) + return; + + setRenderStates2DMode(useColor[0].getAlpha() < 255 || useColor[1].getAlpha() < 255 || + useColor[2].getAlpha() < 255 || useColor[3].getAlpha() < 255, + true, useAlphaChannelOfTexture); + + const core::dimension2d &renderTargetSize = getCurrentRenderTargetSize(); + + if (clipRect) { + if (!clipRect->isValid()) + return; + + GL.Enable(GL_SCISSOR_TEST); + GL.Scissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y, + clipRect->getWidth(), clipRect->getHeight()); + } + + f32 left = (f32)destRect.UpperLeftCorner.X / (f32)renderTargetSize.Width * 2.f - 1.f; + f32 right = (f32)destRect.LowerRightCorner.X / (f32)renderTargetSize.Width * 2.f - 1.f; + f32 down = 2.f - (f32)destRect.LowerRightCorner.Y / (f32)renderTargetSize.Height * 2.f - 1.f; + f32 top = 2.f - (f32)destRect.UpperLeftCorner.Y / (f32)renderTargetSize.Height * 2.f - 1.f; + + S3DVertex vertices[4]; + vertices[0] = S3DVertex(left, top, 0, 0, 0, 1, useColor[0], tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y); + vertices[1] = S3DVertex(right, top, 0, 0, 0, 1, useColor[3], tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y); + vertices[2] = S3DVertex(right, down, 0, 0, 0, 1, useColor[2], tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y); + vertices[3] = S3DVertex(left, down, 0, 0, 0, 1, useColor[1], tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y); + + drawQuad(vt2DImage, vertices); + + if (clipRect) + GL.Disable(GL_SCISSOR_TEST); + + testGLError(__LINE__); +} + +void COpenGL3DriverBase::draw2DImage(const video::ITexture *texture, u32 layer, bool flip) +{ + if (!texture) + return; + + chooseMaterial2D(); + if (!setMaterialTexture(0, texture)) + return; + + setRenderStates2DMode(false, true, true); + + S3DVertex quad2DVertices[4]; + + quad2DVertices[0].Pos = core::vector3df(-1.f, 1.f, 0.f); + quad2DVertices[1].Pos = core::vector3df(1.f, 1.f, 0.f); + quad2DVertices[2].Pos = core::vector3df(1.f, -1.f, 0.f); + quad2DVertices[3].Pos = core::vector3df(-1.f, -1.f, 0.f); + + f32 modificator = (flip) ? 1.f : 0.f; + + quad2DVertices[0].TCoords = core::vector2df(0.f, 0.f + modificator); + quad2DVertices[1].TCoords = core::vector2df(1.f, 0.f + modificator); + quad2DVertices[2].TCoords = core::vector2df(1.f, 1.f - modificator); + quad2DVertices[3].TCoords = core::vector2df(0.f, 1.f - modificator); + + quad2DVertices[0].Color = SColor(0xFFFFFFFF); + quad2DVertices[1].Color = SColor(0xFFFFFFFF); + quad2DVertices[2].Color = SColor(0xFFFFFFFF); + quad2DVertices[3].Color = SColor(0xFFFFFFFF); + + drawQuad(vt2DImage, quad2DVertices); +} + +void COpenGL3DriverBase::draw2DImageBatch(const video::ITexture *texture, + const core::array> &positions, + const core::array> &sourceRects, + const core::rect *clipRect, + SColor color, bool useAlphaChannelOfTexture) +{ + if (!texture) + return; + + chooseMaterial2D(); + if (!setMaterialTexture(0, texture)) + return; + + setRenderStates2DMode(color.getAlpha() < 255, true, useAlphaChannelOfTexture); + + const core::dimension2d &renderTargetSize = getCurrentRenderTargetSize(); + + if (clipRect) { + if (!clipRect->isValid()) + return; + + GL.Enable(GL_SCISSOR_TEST); + GL.Scissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y, + clipRect->getWidth(), clipRect->getHeight()); + } + + const irr::u32 drawCount = core::min_(positions.size(), sourceRects.size()); + assert(6 * drawCount <= QuadIndexCount); // FIXME split the batch? or let it crash? + + core::array vtx(drawCount * 4); + + for (u32 i = 0; i < drawCount; i++) { + core::position2d targetPos = positions[i]; + core::position2d sourcePos = sourceRects[i].UpperLeftCorner; + // This needs to be signed as it may go negative. + core::dimension2d sourceSize(sourceRects[i].getSize()); + + // now draw it. + + core::rect tcoords; + tcoords.UpperLeftCorner.X = (((f32)sourcePos.X)) / texture->getOriginalSize().Width; + tcoords.UpperLeftCorner.Y = (((f32)sourcePos.Y)) / texture->getOriginalSize().Height; + tcoords.LowerRightCorner.X = tcoords.UpperLeftCorner.X + ((f32)(sourceSize.Width) / texture->getOriginalSize().Width); + tcoords.LowerRightCorner.Y = tcoords.UpperLeftCorner.Y + ((f32)(sourceSize.Height) / texture->getOriginalSize().Height); + + const core::rect poss(targetPos, sourceSize); + + f32 left = (f32)poss.UpperLeftCorner.X / (f32)renderTargetSize.Width * 2.f - 1.f; + f32 right = (f32)poss.LowerRightCorner.X / (f32)renderTargetSize.Width * 2.f - 1.f; + f32 down = 2.f - (f32)poss.LowerRightCorner.Y / (f32)renderTargetSize.Height * 2.f - 1.f; + f32 top = 2.f - (f32)poss.UpperLeftCorner.Y / (f32)renderTargetSize.Height * 2.f - 1.f; + + vtx.push_back(S3DVertex(left, top, 0.0f, + 0.0f, 0.0f, 0.0f, color, + tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y)); + vtx.push_back(S3DVertex(right, top, 0.0f, + 0.0f, 0.0f, 0.0f, color, + tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y)); + vtx.push_back(S3DVertex(right, down, 0.0f, + 0.0f, 0.0f, 0.0f, color, + tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y)); + vtx.push_back(S3DVertex(left, down, 0.0f, + 0.0f, 0.0f, 0.0f, color, + tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y)); + } + + GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, QuadIndexBuffer); + drawElements(GL_TRIANGLES, vt2DImage, vtx.const_pointer(), vtx.size(), 0, 6 * drawCount); + GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + + if (clipRect) + GL.Disable(GL_SCISSOR_TEST); +} + +//! draw a 2d rectangle +void COpenGL3DriverBase::draw2DRectangle(SColor color, + const core::rect &position, + const core::rect *clip) +{ + chooseMaterial2D(); + setMaterialTexture(0, 0); + + setRenderStates2DMode(color.getAlpha() < 255, false, false); + + core::rect pos = position; + + if (clip) + pos.clipAgainst(*clip); + + if (!pos.isValid()) + return; + + const core::dimension2d &renderTargetSize = getCurrentRenderTargetSize(); + + f32 left = (f32)pos.UpperLeftCorner.X / (f32)renderTargetSize.Width * 2.f - 1.f; + f32 right = (f32)pos.LowerRightCorner.X / (f32)renderTargetSize.Width * 2.f - 1.f; + f32 down = 2.f - (f32)pos.LowerRightCorner.Y / (f32)renderTargetSize.Height * 2.f - 1.f; + f32 top = 2.f - (f32)pos.UpperLeftCorner.Y / (f32)renderTargetSize.Height * 2.f - 1.f; + + S3DVertex vertices[4]; + vertices[0] = S3DVertex(left, top, 0, 0, 0, 1, color, 0, 0); + vertices[1] = S3DVertex(right, top, 0, 0, 0, 1, color, 0, 0); + vertices[2] = S3DVertex(right, down, 0, 0, 0, 1, color, 0, 0); + vertices[3] = S3DVertex(left, down, 0, 0, 0, 1, color, 0, 0); + + drawQuad(vtPrimitive, vertices); +} + +//! draw an 2d rectangle +void COpenGL3DriverBase::draw2DRectangle(const core::rect &position, + SColor colorLeftUp, SColor colorRightUp, + SColor colorLeftDown, SColor colorRightDown, + const core::rect *clip) +{ + core::rect pos = position; + + if (clip) + pos.clipAgainst(*clip); + + if (!pos.isValid()) + return; + + chooseMaterial2D(); + setMaterialTexture(0, 0); + + setRenderStates2DMode(colorLeftUp.getAlpha() < 255 || + colorRightUp.getAlpha() < 255 || + colorLeftDown.getAlpha() < 255 || + colorRightDown.getAlpha() < 255, + false, false); + + const core::dimension2d &renderTargetSize = getCurrentRenderTargetSize(); + + f32 left = (f32)pos.UpperLeftCorner.X / (f32)renderTargetSize.Width * 2.f - 1.f; + f32 right = (f32)pos.LowerRightCorner.X / (f32)renderTargetSize.Width * 2.f - 1.f; + f32 down = 2.f - (f32)pos.LowerRightCorner.Y / (f32)renderTargetSize.Height * 2.f - 1.f; + f32 top = 2.f - (f32)pos.UpperLeftCorner.Y / (f32)renderTargetSize.Height * 2.f - 1.f; + + S3DVertex vertices[4]; + vertices[0] = S3DVertex(left, top, 0, 0, 0, 1, colorLeftUp, 0, 0); + vertices[1] = S3DVertex(right, top, 0, 0, 0, 1, colorRightUp, 0, 0); + vertices[2] = S3DVertex(right, down, 0, 0, 0, 1, colorRightDown, 0, 0); + vertices[3] = S3DVertex(left, down, 0, 0, 0, 1, colorLeftDown, 0, 0); + + drawQuad(vtPrimitive, vertices); +} + +//! Draws a 2d line. +void COpenGL3DriverBase::draw2DLine(const core::position2d &start, + const core::position2d &end, SColor color) +{ + { + chooseMaterial2D(); + setMaterialTexture(0, 0); + + setRenderStates2DMode(color.getAlpha() < 255, false, false); + + const core::dimension2d &renderTargetSize = getCurrentRenderTargetSize(); + + f32 startX = (f32)start.X / (f32)renderTargetSize.Width * 2.f - 1.f; + f32 endX = (f32)end.X / (f32)renderTargetSize.Width * 2.f - 1.f; + f32 startY = 2.f - (f32)start.Y / (f32)renderTargetSize.Height * 2.f - 1.f; + f32 endY = 2.f - (f32)end.Y / (f32)renderTargetSize.Height * 2.f - 1.f; + + S3DVertex vertices[2]; + vertices[0] = S3DVertex(startX, startY, 0, 0, 0, 1, color, 0, 0); + vertices[1] = S3DVertex(endX, endY, 0, 0, 0, 1, color, 1, 1); + + drawArrays(GL_LINES, vtPrimitive, vertices, 2); + } +} + +void COpenGL3DriverBase::drawQuad(const VertexType &vertexType, const S3DVertex (&vertices)[4]) +{ + drawArrays(GL_TRIANGLE_FAN, vertexType, vertices, 4); +} + +void COpenGL3DriverBase::drawArrays(GLenum primitiveType, const VertexType &vertexType, const void *vertices, int vertexCount) +{ + beginDraw(vertexType, reinterpret_cast(vertices)); + GL.DrawArrays(primitiveType, 0, vertexCount); + endDraw(vertexType); +} + +void COpenGL3DriverBase::drawElements(GLenum primitiveType, const VertexType &vertexType, const void *vertices, int vertexCount, const u16 *indices, int indexCount) +{ + beginDraw(vertexType, reinterpret_cast(vertices)); + GL.DrawRangeElements(primitiveType, 0, vertexCount - 1, indexCount, GL_UNSIGNED_SHORT, indices); + endDraw(vertexType); +} + +void COpenGL3DriverBase::beginDraw(const VertexType &vertexType, uintptr_t verticesBase) +{ + for (auto attr : vertexType) { + GL.EnableVertexAttribArray(attr.Index); + switch (attr.mode) { + case VertexAttribute::Mode::Regular: + GL.VertexAttribPointer(attr.Index, attr.ComponentCount, attr.ComponentType, GL_FALSE, vertexType.VertexSize, reinterpret_cast(verticesBase + attr.Offset)); + break; + case VertexAttribute::Mode::Normalized: + GL.VertexAttribPointer(attr.Index, attr.ComponentCount, attr.ComponentType, GL_TRUE, vertexType.VertexSize, reinterpret_cast(verticesBase + attr.Offset)); + break; + case VertexAttribute::Mode::Integral: + GL.VertexAttribIPointer(attr.Index, attr.ComponentCount, attr.ComponentType, vertexType.VertexSize, reinterpret_cast(verticesBase + attr.Offset)); + break; + } + } +} + +void COpenGL3DriverBase::endDraw(const VertexType &vertexType) +{ + for (auto attr : vertexType) + GL.DisableVertexAttribArray(attr.Index); +} + +ITexture *COpenGL3DriverBase::createDeviceDependentTexture(const io::path &name, IImage *image) +{ + core::array imageArray(1); + imageArray.push_back(image); + + COpenGL3Texture *texture = new COpenGL3Texture(name, imageArray, ETT_2D, this); + + return texture; +} + +ITexture *COpenGL3DriverBase::createDeviceDependentTextureCubemap(const io::path &name, const core::array &image) +{ + COpenGL3Texture *texture = new COpenGL3Texture(name, image, ETT_CUBEMAP, this); + + return texture; +} + +//! Sets a material. +void COpenGL3DriverBase::setMaterial(const SMaterial &material) +{ + Material = material; + OverrideMaterial.apply(Material); + + for (u32 i = 0; i < Feature.MaxTextureUnits; ++i) { + CacheHandler->getTextureCache().set(i, material.getTexture(i)); + setTransform((E_TRANSFORMATION_STATE)(ETS_TEXTURE_0 + i), material.getTextureMatrix(i)); + } +} + +//! prints error if an error happened. +bool COpenGL3DriverBase::testGLError(int code) +{ +#ifdef _DEBUG + GLenum g = GL.GetError(); + switch (g) { + case GL_NO_ERROR: + return false; + case GL_INVALID_ENUM: + os::Printer::log("GL_INVALID_ENUM", core::stringc(code).c_str(), ELL_ERROR); + break; + case GL_INVALID_VALUE: + os::Printer::log("GL_INVALID_VALUE", core::stringc(code).c_str(), ELL_ERROR); + break; + case GL_INVALID_OPERATION: + os::Printer::log("GL_INVALID_OPERATION", core::stringc(code).c_str(), ELL_ERROR); + break; + case GL_OUT_OF_MEMORY: + os::Printer::log("GL_OUT_OF_MEMORY", core::stringc(code).c_str(), ELL_ERROR); + break; + }; + return true; +#else + return false; +#endif +} + +//! prints error if an error happened. +bool COpenGL3DriverBase::testEGLError() +{ +#if defined(EGL_VERSION_1_0) && defined(_DEBUG) + EGLint g = eglGetError(); + switch (g) { + case EGL_SUCCESS: + return false; + case EGL_NOT_INITIALIZED: + os::Printer::log("Not Initialized", ELL_ERROR); + break; + case EGL_BAD_ACCESS: + os::Printer::log("Bad Access", ELL_ERROR); + break; + case EGL_BAD_ALLOC: + os::Printer::log("Bad Alloc", ELL_ERROR); + break; + case EGL_BAD_ATTRIBUTE: + os::Printer::log("Bad Attribute", ELL_ERROR); + break; + case EGL_BAD_CONTEXT: + os::Printer::log("Bad Context", ELL_ERROR); + break; + case EGL_BAD_CONFIG: + os::Printer::log("Bad Config", ELL_ERROR); + break; + case EGL_BAD_CURRENT_SURFACE: + os::Printer::log("Bad Current Surface", ELL_ERROR); + break; + case EGL_BAD_DISPLAY: + os::Printer::log("Bad Display", ELL_ERROR); + break; + case EGL_BAD_SURFACE: + os::Printer::log("Bad Surface", ELL_ERROR); + break; + case EGL_BAD_MATCH: + os::Printer::log("Bad Match", ELL_ERROR); + break; + case EGL_BAD_PARAMETER: + os::Printer::log("Bad Parameter", ELL_ERROR); + break; + case EGL_BAD_NATIVE_PIXMAP: + os::Printer::log("Bad Native Pixmap", ELL_ERROR); + break; + case EGL_BAD_NATIVE_WINDOW: + os::Printer::log("Bad Native Window", ELL_ERROR); + break; + case EGL_CONTEXT_LOST: + os::Printer::log("Context Lost", ELL_ERROR); + break; + }; + return true; +#else + return false; +#endif +} + +void COpenGL3DriverBase::setRenderStates3DMode() +{ + if (LockRenderStateMode) + return; + + if (CurrentRenderMode != ERM_3D) { + // Reset Texture Stages + CacheHandler->setBlend(false); + CacheHandler->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + ResetRenderStates = true; + } + + if (ResetRenderStates || LastMaterial != Material) { + // unset old material + + // unset last 3d material + if (CurrentRenderMode == ERM_2D && MaterialRenderer2DActive) { + MaterialRenderer2DActive->OnUnsetMaterial(); + MaterialRenderer2DActive = 0; + } else if (LastMaterial.MaterialType != Material.MaterialType && + static_cast(LastMaterial.MaterialType) < MaterialRenderers.size()) + MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial(); + + // set new material. + if (static_cast(Material.MaterialType) < MaterialRenderers.size()) + MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial( + Material, LastMaterial, ResetRenderStates, this); + + LastMaterial = Material; + CacheHandler->correctCacheMaterial(LastMaterial); + ResetRenderStates = false; + } + + if (static_cast(Material.MaterialType) < MaterialRenderers.size()) + MaterialRenderers[Material.MaterialType].Renderer->OnRender(this, video::EVT_STANDARD); + + CurrentRenderMode = ERM_3D; +} + +//! Can be called by an IMaterialRenderer to make its work easier. +void COpenGL3DriverBase::setBasicRenderStates(const SMaterial &material, const SMaterial &lastmaterial, bool resetAllRenderStates) +{ + // ZBuffer + switch (material.ZBuffer) { + case ECFN_DISABLED: + CacheHandler->setDepthTest(false); + break; + case ECFN_LESSEQUAL: + CacheHandler->setDepthTest(true); + CacheHandler->setDepthFunc(GL_LEQUAL); + break; + case ECFN_EQUAL: + CacheHandler->setDepthTest(true); + CacheHandler->setDepthFunc(GL_EQUAL); + break; + case ECFN_LESS: + CacheHandler->setDepthTest(true); + CacheHandler->setDepthFunc(GL_LESS); + break; + case ECFN_NOTEQUAL: + CacheHandler->setDepthTest(true); + CacheHandler->setDepthFunc(GL_NOTEQUAL); + break; + case ECFN_GREATEREQUAL: + CacheHandler->setDepthTest(true); + CacheHandler->setDepthFunc(GL_GEQUAL); + break; + case ECFN_GREATER: + CacheHandler->setDepthTest(true); + CacheHandler->setDepthFunc(GL_GREATER); + break; + case ECFN_ALWAYS: + CacheHandler->setDepthTest(true); + CacheHandler->setDepthFunc(GL_ALWAYS); + break; + case ECFN_NEVER: + CacheHandler->setDepthTest(true); + CacheHandler->setDepthFunc(GL_NEVER); + break; + default: + break; + } + + // ZWrite + if (getWriteZBuffer(material)) { + CacheHandler->setDepthMask(true); + } else { + CacheHandler->setDepthMask(false); + } + + // Back face culling + if ((material.FrontfaceCulling) && (material.BackfaceCulling)) { + CacheHandler->setCullFaceFunc(GL_FRONT_AND_BACK); + CacheHandler->setCullFace(true); + } else if (material.BackfaceCulling) { + CacheHandler->setCullFaceFunc(GL_BACK); + CacheHandler->setCullFace(true); + } else if (material.FrontfaceCulling) { + CacheHandler->setCullFaceFunc(GL_FRONT); + CacheHandler->setCullFace(true); + } else { + CacheHandler->setCullFace(false); + } + + // Color Mask + CacheHandler->setColorMask(material.ColorMask); + + // Blend Equation + if (material.BlendOperation == EBO_NONE) + CacheHandler->setBlend(false); + else { + CacheHandler->setBlend(true); + + switch (material.BlendOperation) { + case EBO_ADD: + CacheHandler->setBlendEquation(GL_FUNC_ADD); + break; + case EBO_SUBTRACT: + CacheHandler->setBlendEquation(GL_FUNC_SUBTRACT); + break; + case EBO_REVSUBTRACT: + CacheHandler->setBlendEquation(GL_FUNC_REVERSE_SUBTRACT); + break; + case EBO_MIN: + if (BlendMinMaxSupported) + CacheHandler->setBlendEquation(GL_MIN); + else + os::Printer::log("Attempt to use EBO_MIN without driver support", ELL_WARNING); + break; + case EBO_MAX: + if (BlendMinMaxSupported) + CacheHandler->setBlendEquation(GL_MAX); + else + os::Printer::log("Attempt to use EBO_MAX without driver support", ELL_WARNING); + break; + default: + break; + } + } + + // Blend Factor + if (IR(material.BlendFactor) & 0xFFFFFFFF // TODO: why the & 0xFFFFFFFF? + && material.MaterialType != EMT_ONETEXTURE_BLEND) { + E_BLEND_FACTOR srcRGBFact = EBF_ZERO; + E_BLEND_FACTOR dstRGBFact = EBF_ZERO; + E_BLEND_FACTOR srcAlphaFact = EBF_ZERO; + E_BLEND_FACTOR dstAlphaFact = EBF_ZERO; + E_MODULATE_FUNC modulo = EMFN_MODULATE_1X; + u32 alphaSource = 0; + + unpack_textureBlendFuncSeparate(srcRGBFact, dstRGBFact, srcAlphaFact, dstAlphaFact, modulo, alphaSource, material.BlendFactor); + + CacheHandler->setBlendFuncSeparate(getGLBlend(srcRGBFact), getGLBlend(dstRGBFact), + getGLBlend(srcAlphaFact), getGLBlend(dstAlphaFact)); + } + + // TODO: Polygon Offset. Not sure if it was left out deliberately or if it won't work with this driver. + + if (resetAllRenderStates || lastmaterial.Thickness != material.Thickness) + GL.LineWidth(core::clamp(static_cast(material.Thickness), DimAliasedLine[0], DimAliasedLine[1])); + + // Anti aliasing + if (resetAllRenderStates || lastmaterial.AntiAliasing != material.AntiAliasing) { + if (material.AntiAliasing & EAAM_ALPHA_TO_COVERAGE) + GL.Enable(GL_SAMPLE_ALPHA_TO_COVERAGE); + else if (lastmaterial.AntiAliasing & EAAM_ALPHA_TO_COVERAGE) + GL.Disable(GL_SAMPLE_ALPHA_TO_COVERAGE); + } + + // Texture parameters + setTextureRenderStates(material, resetAllRenderStates); +} + +//! Compare in SMaterial doesn't check texture parameters, so we should call this on each OnRender call. +void COpenGL3DriverBase::setTextureRenderStates(const SMaterial &material, bool resetAllRenderstates) +{ + // Set textures to TU/TIU and apply filters to them + + for (s32 i = Feature.MaxTextureUnits - 1; i >= 0; --i) { + const COpenGL3Texture *tmpTexture = CacheHandler->getTextureCache()[i]; + + if (!tmpTexture) + continue; + + GLenum tmpTextureType = tmpTexture->getOpenGLTextureType(); + + CacheHandler->setActiveTexture(GL_TEXTURE0 + i); + + if (resetAllRenderstates) + tmpTexture->getStatesCache().IsCached = false; + + if (!tmpTexture->getStatesCache().IsCached || material.TextureLayers[i].MagFilter != tmpTexture->getStatesCache().MagFilter) { + E_TEXTURE_MAG_FILTER magFilter = material.TextureLayers[i].MagFilter; + GL.TexParameteri(tmpTextureType, GL_TEXTURE_MAG_FILTER, + magFilter == ETMAGF_NEAREST ? GL_NEAREST : (assert(magFilter == ETMAGF_LINEAR), GL_LINEAR)); + + tmpTexture->getStatesCache().MagFilter = magFilter; + } + + if (material.UseMipMaps && tmpTexture->hasMipMaps()) { + if (!tmpTexture->getStatesCache().IsCached || material.TextureLayers[i].MinFilter != tmpTexture->getStatesCache().MinFilter || + !tmpTexture->getStatesCache().MipMapStatus) { + E_TEXTURE_MIN_FILTER minFilter = material.TextureLayers[i].MinFilter; + GL.TexParameteri(tmpTextureType, GL_TEXTURE_MIN_FILTER, + minFilter == ETMINF_NEAREST_MIPMAP_NEAREST ? GL_NEAREST_MIPMAP_NEAREST : minFilter == ETMINF_LINEAR_MIPMAP_NEAREST ? GL_LINEAR_MIPMAP_NEAREST + : minFilter == ETMINF_NEAREST_MIPMAP_LINEAR ? GL_NEAREST_MIPMAP_LINEAR + : (assert(minFilter == ETMINF_LINEAR_MIPMAP_LINEAR), GL_LINEAR_MIPMAP_LINEAR)); + + tmpTexture->getStatesCache().MinFilter = minFilter; + tmpTexture->getStatesCache().MipMapStatus = true; + } + } else { + if (!tmpTexture->getStatesCache().IsCached || material.TextureLayers[i].MinFilter != tmpTexture->getStatesCache().MinFilter || + tmpTexture->getStatesCache().MipMapStatus) { + E_TEXTURE_MIN_FILTER minFilter = material.TextureLayers[i].MinFilter; + GL.TexParameteri(tmpTextureType, GL_TEXTURE_MIN_FILTER, + (minFilter == ETMINF_NEAREST_MIPMAP_NEAREST || minFilter == ETMINF_NEAREST_MIPMAP_LINEAR) ? GL_NEAREST : (assert(minFilter == ETMINF_LINEAR_MIPMAP_NEAREST || minFilter == ETMINF_LINEAR_MIPMAP_LINEAR), GL_LINEAR)); + + tmpTexture->getStatesCache().MinFilter = minFilter; + tmpTexture->getStatesCache().MipMapStatus = false; + } + } + + if (AnisotropicFilterSupported && + (!tmpTexture->getStatesCache().IsCached || material.TextureLayers[i].AnisotropicFilter != tmpTexture->getStatesCache().AnisotropicFilter)) { + GL.TexParameteri(tmpTextureType, GL.TEXTURE_MAX_ANISOTROPY, + material.TextureLayers[i].AnisotropicFilter > 1 ? core::min_(MaxAnisotropy, material.TextureLayers[i].AnisotropicFilter) : 1); + + tmpTexture->getStatesCache().AnisotropicFilter = material.TextureLayers[i].AnisotropicFilter; + } + + if (!tmpTexture->getStatesCache().IsCached || material.TextureLayers[i].TextureWrapU != tmpTexture->getStatesCache().WrapU) { + GL.TexParameteri(tmpTextureType, GL_TEXTURE_WRAP_S, getTextureWrapMode(material.TextureLayers[i].TextureWrapU)); + tmpTexture->getStatesCache().WrapU = material.TextureLayers[i].TextureWrapU; + } + + if (!tmpTexture->getStatesCache().IsCached || material.TextureLayers[i].TextureWrapV != tmpTexture->getStatesCache().WrapV) { + GL.TexParameteri(tmpTextureType, GL_TEXTURE_WRAP_T, getTextureWrapMode(material.TextureLayers[i].TextureWrapV)); + tmpTexture->getStatesCache().WrapV = material.TextureLayers[i].TextureWrapV; + } + + tmpTexture->getStatesCache().IsCached = true; + } +} + +// Get OpenGL ES2.0 texture wrap mode from Irrlicht wrap mode. +GLint COpenGL3DriverBase::getTextureWrapMode(u8 clamp) const +{ + switch (clamp) { + case ETC_CLAMP: + case ETC_CLAMP_TO_EDGE: + case ETC_CLAMP_TO_BORDER: + return GL_CLAMP_TO_EDGE; + case ETC_MIRROR: + return GL_REPEAT; + default: + return GL_REPEAT; + } +} + +//! sets the needed renderstates +void COpenGL3DriverBase::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel) +{ + if (LockRenderStateMode) + return; + + COpenGL3Renderer2D *nextActiveRenderer = texture ? MaterialRenderer2DTexture : MaterialRenderer2DNoTexture; + + if (CurrentRenderMode != ERM_2D) { + // unset last 3d material + if (CurrentRenderMode == ERM_3D) { + if (static_cast(LastMaterial.MaterialType) < MaterialRenderers.size()) + MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial(); + } + + CurrentRenderMode = ERM_2D; + } else if (MaterialRenderer2DActive && MaterialRenderer2DActive != nextActiveRenderer) { + MaterialRenderer2DActive->OnUnsetMaterial(); + } + + MaterialRenderer2DActive = nextActiveRenderer; + + MaterialRenderer2DActive->OnSetMaterial(Material, LastMaterial, true, 0); + LastMaterial = Material; + CacheHandler->correctCacheMaterial(LastMaterial); + + // no alphaChannel without texture + alphaChannel &= texture; + + if (alphaChannel || alpha) { + CacheHandler->setBlend(true); + CacheHandler->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + CacheHandler->setBlendEquation(GL_FUNC_ADD); + } else + CacheHandler->setBlend(false); + + Material.setTexture(0, const_cast(CacheHandler->getTextureCache().get(0))); + setTransform(ETS_TEXTURE_0, core::IdentityMatrix); + + if (texture) { + if (OverrideMaterial2DEnabled) + setTextureRenderStates(OverrideMaterial2D, false); + else + setTextureRenderStates(InitMaterial2D, false); + } + + MaterialRenderer2DActive->OnRender(this, video::EVT_STANDARD); +} + +void COpenGL3DriverBase::chooseMaterial2D() +{ + if (!OverrideMaterial2DEnabled) + Material = InitMaterial2D; + + if (OverrideMaterial2DEnabled) { + OverrideMaterial2D.Lighting = false; + OverrideMaterial2D.ZWriteEnable = EZW_OFF; + OverrideMaterial2D.ZBuffer = ECFN_DISABLED; // it will be ECFN_DISABLED after merge + OverrideMaterial2D.Lighting = false; + + Material = OverrideMaterial2D; + } +} + +//! \return Returns the name of the video driver. +const char *COpenGL3DriverBase::getName() const +{ + return Name.c_str(); +} + +void COpenGL3DriverBase::setViewPort(const core::rect &area) +{ + core::rect vp = area; + core::rect rendert(0, 0, getCurrentRenderTargetSize().Width, getCurrentRenderTargetSize().Height); + vp.clipAgainst(rendert); + + if (vp.getHeight() > 0 && vp.getWidth() > 0) + CacheHandler->setViewport(vp.UpperLeftCorner.X, getCurrentRenderTargetSize().Height - vp.UpperLeftCorner.Y - vp.getHeight(), vp.getWidth(), vp.getHeight()); + + ViewPort = vp; +} + +void COpenGL3DriverBase::setViewPortRaw(u32 width, u32 height) +{ + CacheHandler->setViewport(0, 0, width, height); + ViewPort = core::recti(0, 0, width, height); +} + +//! Draws a 3d line. +void COpenGL3DriverBase::draw3DLine(const core::vector3df &start, + const core::vector3df &end, SColor color) +{ + setRenderStates3DMode(); + + S3DVertex vertices[2]; + vertices[0] = S3DVertex(start.X, start.Y, start.Z, 0, 0, 1, color, 0, 0); + vertices[1] = S3DVertex(end.X, end.Y, end.Z, 0, 0, 1, color, 0, 0); + + drawArrays(GL_LINES, vtPrimitive, vertices, 2); +} + +//! Only used by the internal engine. Used to notify the driver that +//! the window was resized. +void COpenGL3DriverBase::OnResize(const core::dimension2d &size) +{ + CNullDriver::OnResize(size); + CacheHandler->setViewport(0, 0, size.Width, size.Height); + Transformation3DChanged = true; +} + +//! Returns type of video driver +E_DRIVER_TYPE COpenGL3DriverBase::getDriverType() const +{ + return EDT_OPENGL3; +} + +//! returns color format +ECOLOR_FORMAT COpenGL3DriverBase::getColorFormat() const +{ + return ColorFormat; +} + +//! Get a vertex shader constant index. +s32 COpenGL3DriverBase::getVertexShaderConstantID(const c8 *name) +{ + return getPixelShaderConstantID(name); +} + +//! Get a pixel shader constant index. +s32 COpenGL3DriverBase::getPixelShaderConstantID(const c8 *name) +{ + os::Printer::log("Error: Please call services->getPixelShaderConstantID(), not VideoDriver->getPixelShaderConstantID()."); + return -1; +} + +//! Sets a constant for the vertex shader based on an index. +bool COpenGL3DriverBase::setVertexShaderConstant(s32 index, const f32 *floats, int count) +{ + os::Printer::log("Error: Please call services->setVertexShaderConstant(), not VideoDriver->setVertexShaderConstant()."); + return false; +} + +//! Int interface for the above. +bool COpenGL3DriverBase::setVertexShaderConstant(s32 index, const s32 *ints, int count) +{ + os::Printer::log("Error: Please call services->setVertexShaderConstant(), not VideoDriver->setVertexShaderConstant()."); + return false; +} + +bool COpenGL3DriverBase::setVertexShaderConstant(s32 index, const u32 *ints, int count) +{ + os::Printer::log("Error: Please call services->setVertexShaderConstant(), not VideoDriver->setVertexShaderConstant()."); + return false; +} + +//! Sets a constant for the pixel shader based on an index. +bool COpenGL3DriverBase::setPixelShaderConstant(s32 index, const f32 *floats, int count) +{ + os::Printer::log("Error: Please call services->setPixelShaderConstant(), not VideoDriver->setPixelShaderConstant()."); + return false; +} + +//! Int interface for the above. +bool COpenGL3DriverBase::setPixelShaderConstant(s32 index, const s32 *ints, int count) +{ + os::Printer::log("Error: Please call services->setPixelShaderConstant(), not VideoDriver->setPixelShaderConstant()."); + return false; +} + +bool COpenGL3DriverBase::setPixelShaderConstant(s32 index, const u32 *ints, int count) +{ + os::Printer::log("Error: Please call services->setPixelShaderConstant(), not VideoDriver->setPixelShaderConstant()."); + return false; +} + +//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry. +s32 COpenGL3DriverBase::addHighLevelShaderMaterial( + const c8 *vertexShaderProgram, + const c8 *vertexShaderEntryPointName, + E_VERTEX_SHADER_TYPE vsCompileTarget, + const c8 *pixelShaderProgram, + const c8 *pixelShaderEntryPointName, + E_PIXEL_SHADER_TYPE psCompileTarget, + const c8 *geometryShaderProgram, + const c8 *geometryShaderEntryPointName, + E_GEOMETRY_SHADER_TYPE gsCompileTarget, + scene::E_PRIMITIVE_TYPE inType, + scene::E_PRIMITIVE_TYPE outType, + u32 verticesOut, + IShaderConstantSetCallBack *callback, + E_MATERIAL_TYPE baseMaterial, + s32 userData) +{ + s32 nr = -1; + COpenGL3MaterialRenderer *r = new COpenGL3MaterialRenderer( + this, nr, vertexShaderProgram, + pixelShaderProgram, + callback, baseMaterial, userData); + + r->drop(); + return nr; +} + +//! Returns a pointer to the IVideoDriver interface. (Implementation for +//! IMaterialRendererServices) +IVideoDriver *COpenGL3DriverBase::getVideoDriver() +{ + return this; +} + +//! Returns pointer to the IGPUProgrammingServices interface. +IGPUProgrammingServices *COpenGL3DriverBase::getGPUProgrammingServices() +{ + return this; +} + +ITexture *COpenGL3DriverBase::addRenderTargetTexture(const core::dimension2d &size, + const io::path &name, const ECOLOR_FORMAT format) +{ + // disable mip-mapping + bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS); + setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false); + + COpenGL3Texture *renderTargetTexture = new COpenGL3Texture(name, size, ETT_2D, format, this); + addTexture(renderTargetTexture); + renderTargetTexture->drop(); + + // restore mip-mapping + setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, generateMipLevels); + + return renderTargetTexture; +} + +ITexture *COpenGL3DriverBase::addRenderTargetTextureCubemap(const irr::u32 sideLen, const io::path &name, const ECOLOR_FORMAT format) +{ + // disable mip-mapping + bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS); + setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false); + + bool supportForFBO = (Feature.ColorAttachment > 0); + + const core::dimension2d size(sideLen, sideLen); + core::dimension2du destSize(size); + + if (!supportForFBO) { + destSize = core::dimension2d(core::min_(size.Width, ScreenSize.Width), core::min_(size.Height, ScreenSize.Height)); + destSize = destSize.getOptimalSize((size == size.getOptimalSize()), false, false); + } + + COpenGL3Texture *renderTargetTexture = new COpenGL3Texture(name, destSize, ETT_CUBEMAP, format, this); + addTexture(renderTargetTexture); + renderTargetTexture->drop(); + + // restore mip-mapping + setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, generateMipLevels); + + return renderTargetTexture; +} + +//! Returns the maximum amount of primitives +u32 COpenGL3DriverBase::getMaximalPrimitiveCount() const +{ + return 65535; +} + +bool COpenGL3DriverBase::setRenderTargetEx(IRenderTarget *target, u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil) +{ + if (target && target->getDriverType() != getDriverType()) { + os::Printer::log("Fatal Error: Tried to set a render target not owned by OpenGL 3 driver.", ELL_ERROR); + return false; + } + + core::dimension2d destRenderTargetSize(0, 0); + + if (target) { + COpenGL3RenderTarget *renderTarget = static_cast(target); + + CacheHandler->setFBO(renderTarget->getBufferID()); + renderTarget->update(); + + destRenderTargetSize = renderTarget->getSize(); + + setViewPortRaw(destRenderTargetSize.Width, destRenderTargetSize.Height); + } else { + CacheHandler->setFBO(0); + + destRenderTargetSize = core::dimension2d(0, 0); + + setViewPortRaw(ScreenSize.Width, ScreenSize.Height); + } + + if (CurrentRenderTargetSize != destRenderTargetSize) { + CurrentRenderTargetSize = destRenderTargetSize; + + Transformation3DChanged = true; + } + + CurrentRenderTarget = target; + + clearBuffers(clearFlag, clearColor, clearDepth, clearStencil); + + return true; +} + +void COpenGL3DriverBase::clearBuffers(u16 flag, SColor color, f32 depth, u8 stencil) +{ + GLbitfield mask = 0; + u8 colorMask = 0; + bool depthMask = false; + + CacheHandler->getColorMask(colorMask); + CacheHandler->getDepthMask(depthMask); + + if (flag & ECBF_COLOR) { + CacheHandler->setColorMask(ECP_ALL); + + const f32 inv = 1.0f / 255.0f; + GL.ClearColor(color.getRed() * inv, color.getGreen() * inv, + color.getBlue() * inv, color.getAlpha() * inv); + + mask |= GL_COLOR_BUFFER_BIT; + } + + if (flag & ECBF_DEPTH) { + CacheHandler->setDepthMask(true); + GL.ClearDepthf(depth); + mask |= GL_DEPTH_BUFFER_BIT; + } + + if (flag & ECBF_STENCIL) { + GL.ClearStencil(stencil); + mask |= GL_STENCIL_BUFFER_BIT; + } + + if (mask) + GL.Clear(mask); + + CacheHandler->setColorMask(colorMask); + CacheHandler->setDepthMask(depthMask); +} + +//! Returns an image created from the last rendered frame. +// We want to read the front buffer to get the latest render finished. +// This is not possible under ogl-es, though, so one has to call this method +// outside of the render loop only. +IImage *COpenGL3DriverBase::createScreenShot(video::ECOLOR_FORMAT format, video::E_RENDER_TARGET target) +{ + if (target == video::ERT_MULTI_RENDER_TEXTURES || target == video::ERT_RENDER_TEXTURE || target == video::ERT_STEREO_BOTH_BUFFERS) + return 0; + + GLint internalformat = GL_RGBA; + GLint type = GL_UNSIGNED_BYTE; + { + // GL.GetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &internalformat); + // GL.GetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &type); + // there's a format we don't support ATM + if (GL_UNSIGNED_SHORT_4_4_4_4 == type) { + internalformat = GL_RGBA; + type = GL_UNSIGNED_BYTE; + } + } + + IImage *newImage = 0; + if (GL_RGBA == internalformat) { + if (GL_UNSIGNED_BYTE == type) + newImage = new CImage(ECF_A8R8G8B8, ScreenSize); + else + newImage = new CImage(ECF_A1R5G5B5, ScreenSize); + } else { + if (GL_UNSIGNED_BYTE == type) + newImage = new CImage(ECF_R8G8B8, ScreenSize); + else + newImage = new CImage(ECF_R5G6B5, ScreenSize); + } + + if (!newImage) + return 0; + + u8 *pixels = static_cast(newImage->getData()); + if (!pixels) { + newImage->drop(); + return 0; + } + + GL.ReadPixels(0, 0, ScreenSize.Width, ScreenSize.Height, internalformat, type, pixels); + testGLError(__LINE__); + + // opengl images are horizontally flipped, so we have to fix that here. + const s32 pitch = newImage->getPitch(); + u8 *p2 = pixels + (ScreenSize.Height - 1) * pitch; + u8 *tmpBuffer = new u8[pitch]; + for (u32 i = 0; i < ScreenSize.Height; i += 2) { + memcpy(tmpBuffer, pixels, pitch); + memcpy(pixels, p2, pitch); + memcpy(p2, tmpBuffer, pitch); + pixels += pitch; + p2 -= pitch; + } + delete[] tmpBuffer; + + // also GL_RGBA doesn't match the internal encoding of the image (which is BGRA) + if (GL_RGBA == internalformat && GL_UNSIGNED_BYTE == type) { + pixels = static_cast(newImage->getData()); + for (u32 i = 0; i < ScreenSize.Height; i++) { + for (u32 j = 0; j < ScreenSize.Width; j++) { + u32 c = *(u32 *)(pixels + 4 * j); + *(u32 *)(pixels + 4 * j) = (c & 0xFF00FF00) | + ((c & 0x00FF0000) >> 16) | ((c & 0x000000FF) << 16); + } + pixels += pitch; + } + } + + if (testGLError(__LINE__)) { + newImage->drop(); + return 0; + } + testGLError(__LINE__); + return newImage; +} + +void COpenGL3DriverBase::removeTexture(ITexture *texture) +{ + CacheHandler->getTextureCache().remove(texture); + CNullDriver::removeTexture(texture); +} + +//! Set/unset a clipping plane. +bool COpenGL3DriverBase::setClipPlane(u32 index, const core::plane3df &plane, bool enable) +{ + if (index >= UserClipPlane.size()) + UserClipPlane.push_back(SUserClipPlane()); + + UserClipPlane[index].Plane = plane; + UserClipPlane[index].Enabled = enable; + return true; +} + +//! Enable/disable a clipping plane. +void COpenGL3DriverBase::enableClipPlane(u32 index, bool enable) +{ + UserClipPlane[index].Enabled = enable; +} + +//! Get the ClipPlane Count +u32 COpenGL3DriverBase::getClipPlaneCount() const +{ + return UserClipPlane.size(); +} + +const core::plane3df &COpenGL3DriverBase::getClipPlane(irr::u32 index) const +{ + if (index < UserClipPlane.size()) + return UserClipPlane[index].Plane; + else { + _IRR_DEBUG_BREAK_IF(true) // invalid index + static const core::plane3df dummy; + return dummy; + } +} + +core::dimension2du COpenGL3DriverBase::getMaxTextureSize() const +{ + return core::dimension2du(MaxTextureSize, MaxTextureSize); +} + +GLenum COpenGL3DriverBase::getGLBlend(E_BLEND_FACTOR factor) const +{ + static GLenum const blendTable[] = { + GL_ZERO, + GL_ONE, + GL_DST_COLOR, + GL_ONE_MINUS_DST_COLOR, + GL_SRC_COLOR, + GL_ONE_MINUS_SRC_COLOR, + GL_SRC_ALPHA, + GL_ONE_MINUS_SRC_ALPHA, + GL_DST_ALPHA, + GL_ONE_MINUS_DST_ALPHA, + GL_SRC_ALPHA_SATURATE, + }; + + return blendTable[factor]; +} + +bool COpenGL3DriverBase::getColorFormatParameters(ECOLOR_FORMAT format, GLint &internalFormat, GLenum &pixelFormat, + GLenum &pixelType, void (**converter)(const void *, s32, void *)) const +{ + auto &info = TextureFormats[format]; + internalFormat = info.InternalFormat; + pixelFormat = info.PixelFormat; + pixelType = info.PixelType; + *converter = info.Converter; + return info.InternalFormat != 0; +} + +bool COpenGL3DriverBase::queryTextureFormat(ECOLOR_FORMAT format) const +{ + return TextureFormats[format].InternalFormat != 0; +} + +bool COpenGL3DriverBase::needsTransparentRenderPass(const irr::video::SMaterial &material) const +{ + return CNullDriver::needsTransparentRenderPass(material) || material.isAlphaBlendOperation(); +} + +const SMaterial &COpenGL3DriverBase::getCurrentMaterial() const +{ + return Material; +} + +COpenGL3CacheHandler *COpenGL3DriverBase::getCacheHandler() const +{ + return CacheHandler; +} + +} // end namespace +} // end namespace diff --git a/irr/src/OpenGL/Driver.h b/irr/src/OpenGL/Driver.h new file mode 100644 index 000000000..fefb12e2b --- /dev/null +++ b/irr/src/OpenGL/Driver.h @@ -0,0 +1,399 @@ +// Copyright (C) 2023 Vitaliy Lobachevskiy +// Copyright (C) 2014 Patryk Nadrowski +// Copyright (C) 2009-2010 Amundis +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#pragma once + +#include "SIrrCreationParameters.h" + +#include "Common.h" +#include "CNullDriver.h" +#include "IMaterialRendererServices.h" +#include "EDriverFeatures.h" +#include "fast_atof.h" +#include "ExtensionHandler.h" +#include "IContextManager.h" + +namespace irr +{ +namespace video +{ +struct VertexType; + +class COpenGL3FixedPipelineRenderer; +class COpenGL3Renderer2D; + +class COpenGL3DriverBase : public CNullDriver, public IMaterialRendererServices, public COpenGL3ExtensionHandler +{ + friend class COpenGLCoreTexture; + +protected: + //! constructor (use createOpenGL3Driver instead) + COpenGL3DriverBase(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager); + +public: + //! destructor + virtual ~COpenGL3DriverBase(); + + virtual bool beginScene(u16 clearFlag, SColor clearColor = SColor(255, 0, 0, 0), f32 clearDepth = 1.f, u8 clearStencil = 0, + const SExposedVideoData &videoData = SExposedVideoData(), core::rect *sourceRect = 0) override; + + bool endScene() override; + + //! sets transformation + void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4 &mat) override; + + struct SHWBufferLink_opengl : public SHWBufferLink + { + SHWBufferLink_opengl(const scene::IMeshBuffer *meshBuffer) : + SHWBufferLink(meshBuffer), vbo_verticesID(0), vbo_indicesID(0), vbo_verticesSize(0), vbo_indicesSize(0) + { + } + + u32 vbo_verticesID; // tmp + u32 vbo_indicesID; // tmp + + u32 vbo_verticesSize; // tmp + u32 vbo_indicesSize; // tmp + }; + + bool updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer); + bool updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer); + + //! updates hardware buffer if needed + bool updateHardwareBuffer(SHWBufferLink *HWBuffer) override; + + //! Create hardware buffer from mesh + SHWBufferLink *createHardwareBuffer(const scene::IMeshBuffer *mb) override; + + //! Delete hardware buffer (only some drivers can) + void deleteHardwareBuffer(SHWBufferLink *HWBuffer) override; + + //! Draw hardware buffer + void drawHardwareBuffer(SHWBufferLink *HWBuffer) override; + + IRenderTarget *addRenderTarget() override; + + //! draws a vertex primitive list + virtual void drawVertexPrimitiveList(const void *vertices, u32 vertexCount, + const void *indexList, u32 primitiveCount, + E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) override; + + //! queries the features of the driver, returns true if feature is available + bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const override + { + return FeatureEnabled[feature] && COpenGL3ExtensionHandler::queryFeature(feature); + } + + //! Sets a material. + void setMaterial(const SMaterial &material) override; + + virtual void draw2DImage(const video::ITexture *texture, + const core::position2d &destPos, + const core::rect &sourceRect, const core::rect *clipRect = 0, + SColor color = SColor(255, 255, 255, 255), bool useAlphaChannelOfTexture = false) override; + + virtual void draw2DImage(const video::ITexture *texture, const core::rect &destRect, + const core::rect &sourceRect, const core::rect *clipRect = 0, + const video::SColor *const colors = 0, bool useAlphaChannelOfTexture = false) override; + + // internally used + virtual void draw2DImage(const video::ITexture *texture, u32 layer, bool flip); + + void draw2DImageBatch(const video::ITexture *texture, + const core::array> &positions, + const core::array> &sourceRects, + const core::rect *clipRect, + SColor color, + bool useAlphaChannelOfTexture) override; + + //! draw an 2d rectangle + virtual void draw2DRectangle(SColor color, const core::rect &pos, + const core::rect *clip = 0) override; + + //! Draws an 2d rectangle with a gradient. + virtual void draw2DRectangle(const core::rect &pos, + SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, + const core::rect *clip = 0) override; + + //! Draws a 2d line. + virtual void draw2DLine(const core::position2d &start, + const core::position2d &end, + SColor color = SColor(255, 255, 255, 255)) override; + + //! Draws a 3d line. + virtual void draw3DLine(const core::vector3df &start, + const core::vector3df &end, + SColor color = SColor(255, 255, 255, 255)) override; + + //! Returns the name of the video driver. + const char *getName() const override; + + //! Returns the maximum texture size supported. + core::dimension2du getMaxTextureSize() const override; + + //! sets a viewport + void setViewPort(const core::rect &area) override; + + //! Only used internally by the engine + void OnResize(const core::dimension2d &size) override; + + //! Returns type of video driver + E_DRIVER_TYPE getDriverType() const override; + + //! get color format of the current color buffer + ECOLOR_FORMAT getColorFormat() const override; + + //! Returns the transformation set by setTransform + const core::matrix4 &getTransform(E_TRANSFORMATION_STATE state) const override; + + //! Can be called by an IMaterialRenderer to make its work easier. + void setBasicRenderStates(const SMaterial &material, const SMaterial &lastmaterial, bool resetAllRenderstates) override; + + //! Compare in SMaterial doesn't check texture parameters, so we should call this on each OnRender call. + void setTextureRenderStates(const SMaterial &material, bool resetAllRenderstates); + + //! Get a vertex shader constant index. + s32 getVertexShaderConstantID(const c8 *name) override; + + //! Get a pixel shader constant index. + s32 getPixelShaderConstantID(const c8 *name) override; + + //! Sets a constant for the vertex shader based on an index. + bool setVertexShaderConstant(s32 index, const f32 *floats, int count) override; + + //! Int interface for the above. + bool setVertexShaderConstant(s32 index, const s32 *ints, int count) override; + + //! Uint interface for the above. + bool setVertexShaderConstant(s32 index, const u32 *ints, int count) override; + + //! Sets a constant for the pixel shader based on an index. + bool setPixelShaderConstant(s32 index, const f32 *floats, int count) override; + + //! Int interface for the above. + bool setPixelShaderConstant(s32 index, const s32 *ints, int count) override; + + //! Uint interface for the above. + bool setPixelShaderConstant(s32 index, const u32 *ints, int count) override; + + //! Adds a new material renderer to the VideoDriver + virtual s32 addHighLevelShaderMaterial( + const c8 *vertexShaderProgram, + const c8 *vertexShaderEntryPointName = 0, + E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1, + const c8 *pixelShaderProgram = 0, + const c8 *pixelShaderEntryPointName = 0, + E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1, + const c8 *geometryShaderProgram = 0, + const c8 *geometryShaderEntryPointName = "main", + E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0, + scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES, + scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP, + u32 verticesOut = 0, + IShaderConstantSetCallBack *callback = 0, + E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, + s32 userData = 0) override; + + //! Returns pointer to the IGPUProgrammingServices interface. + IGPUProgrammingServices *getGPUProgrammingServices() override; + + //! Returns a pointer to the IVideoDriver interface. + IVideoDriver *getVideoDriver() override; + + //! Returns the maximum amount of primitives + u32 getMaximalPrimitiveCount() const override; + + virtual ITexture *addRenderTargetTexture(const core::dimension2d &size, + const io::path &name, const ECOLOR_FORMAT format = ECF_UNKNOWN) override; + + //! Creates a render target texture for a cubemap + ITexture *addRenderTargetTextureCubemap(const irr::u32 sideLen, + const io::path &name, const ECOLOR_FORMAT format) override; + + virtual bool setRenderTargetEx(IRenderTarget *target, u16 clearFlag, SColor clearColor = SColor(255, 0, 0, 0), + f32 clearDepth = 1.f, u8 clearStencil = 0) override; + + void clearBuffers(u16 flag, SColor color = SColor(255, 0, 0, 0), f32 depth = 1.f, u8 stencil = 0) override; + + //! Returns an image created from the last rendered frame. + IImage *createScreenShot(video::ECOLOR_FORMAT format = video::ECF_UNKNOWN, video::E_RENDER_TARGET target = video::ERT_FRAME_BUFFER) override; + + //! checks if an OpenGL error has happened and prints it (+ some internal code which is usually the line number) + bool testGLError(int code = 0); + + //! checks if an OGLES1 error has happened and prints it + bool testEGLError(); + + //! Set/unset a clipping plane. + bool setClipPlane(u32 index, const core::plane3df &plane, bool enable = false) override; + + //! returns the current amount of user clip planes set. + u32 getClipPlaneCount() const; + + //! returns the 0 indexed Plane + const core::plane3df &getClipPlane(u32 index) const; + + //! Enable/disable a clipping plane. + void enableClipPlane(u32 index, bool enable) override; + + //! Returns the graphics card vendor name. + core::stringc getVendorInfo() override + { + return VendorName; + }; + + void removeTexture(ITexture *texture) override; + + //! Check if the driver supports creating textures with the given color format + bool queryTextureFormat(ECOLOR_FORMAT format) const override; + + //! Used by some SceneNodes to check if a material should be rendered in the transparent render pass + bool needsTransparentRenderPass(const irr::video::SMaterial &material) const override; + + //! Convert E_BLEND_FACTOR to OpenGL equivalent + GLenum getGLBlend(E_BLEND_FACTOR factor) const; + + virtual bool getColorFormatParameters(ECOLOR_FORMAT format, GLint &internalFormat, GLenum &pixelFormat, + GLenum &pixelType, void (**converter)(const void *, s32, void *)) const; + + //! Get current material. + const SMaterial &getCurrentMaterial() const; + + COpenGL3CacheHandler *getCacheHandler() const; + +protected: + virtual bool genericDriverInit(const core::dimension2d &screenSize, bool stencilBuffer); + + void initVersion(); + virtual OpenGLVersion getVersionFromOpenGL() const = 0; + + virtual void initFeatures() = 0; + + bool isVersionAtLeast(int major, int minor = 0) const noexcept; + + void chooseMaterial2D(); + + ITexture *createDeviceDependentTexture(const io::path &name, IImage *image) override; + + ITexture *createDeviceDependentTextureCubemap(const io::path &name, const core::array &image) override; + + //! Map Irrlicht wrap mode to OpenGL enum + GLint getTextureWrapMode(u8 clamp) const; + + //! sets the needed renderstates + void setRenderStates3DMode(); + + //! sets the needed renderstates + void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel); + + //! Prevent setRenderStateMode calls to do anything. + // hack to allow drawing meshbuffers in 2D mode. + // Better solution would be passing this flag through meshbuffers, + // but the way this is currently implemented in Irrlicht makes this tricky to implement + void lockRenderStateMode() + { + LockRenderStateMode = true; + } + + //! Allow setRenderStateMode calls to work again + void unlockRenderStateMode() + { + LockRenderStateMode = false; + } + + void draw2D3DVertexPrimitiveList(const void *vertices, + u32 vertexCount, const void *indexList, u32 primitiveCount, + E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, + E_INDEX_TYPE iType, bool is3D); + + void createMaterialRenderers(); + + void loadShaderData(const io::path &vertexShaderName, const io::path &fragmentShaderName, c8 **vertexShaderData, c8 **fragmentShaderData); + + bool setMaterialTexture(irr::u32 layerIdx, const irr::video::ITexture *texture); + + //! Same as `CacheHandler->setViewport`, but also sets `ViewPort` + virtual void setViewPortRaw(u32 width, u32 height); + + void drawQuad(const VertexType &vertexType, const S3DVertex (&vertices)[4]); + void drawArrays(GLenum primitiveType, const VertexType &vertexType, const void *vertices, int vertexCount); + void drawElements(GLenum primitiveType, const VertexType &vertexType, const void *vertices, int vertexCount, const u16 *indices, int indexCount); + void drawElements(GLenum primitiveType, const VertexType &vertexType, uintptr_t vertices, uintptr_t indices, int indexCount); + + void beginDraw(const VertexType &vertexType, uintptr_t verticesBase); + void endDraw(const VertexType &vertexType); + + COpenGL3CacheHandler *CacheHandler; + core::stringc Name; + core::stringc VendorName; + SIrrlichtCreationParameters Params; + OpenGLVersion Version; + + //! bool to make all renderstates reset if set to true. + bool ResetRenderStates; + bool LockRenderStateMode; + u8 AntiAlias; + + struct SUserClipPlane + { + core::plane3df Plane; + bool Enabled; + }; + + core::array UserClipPlane; + + core::matrix4 TextureFlipMatrix; + + using FColorConverter = void (*)(const void *source, s32 count, void *dest); + struct STextureFormatInfo + { + GLenum InternalFormat; + GLenum PixelFormat; + GLenum PixelType; + FColorConverter Converter; + }; + STextureFormatInfo TextureFormats[ECF_UNKNOWN] = {}; + +private: + COpenGL3Renderer2D *MaterialRenderer2DActive; + COpenGL3Renderer2D *MaterialRenderer2DTexture; + COpenGL3Renderer2D *MaterialRenderer2DNoTexture; + + core::matrix4 Matrices[ETS_COUNT]; + + //! enumeration for rendering modes such as 2d and 3d for minimizing the switching of renderStates. + enum E_RENDER_MODE + { + ERM_NONE = 0, // no render state has been set yet. + ERM_2D, // 2d drawing rendermode + ERM_3D // 3d rendering mode + }; + + E_RENDER_MODE CurrentRenderMode; + bool Transformation3DChanged; + irr::io::path OGLES2ShaderPath; + + SMaterial Material, LastMaterial; + + //! Color buffer format + ECOLOR_FORMAT ColorFormat; + + IContextManager *ContextManager; + + void printTextureFormats(); + + void addDummyMaterial(E_MATERIAL_TYPE type); + + unsigned QuadIndexCount; + GLuint QuadIndexBuffer = 0; + void initQuadsIndices(int max_vertex_count = 65536); + + void debugCb(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message); + static void APIENTRY debugCb(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam); +}; + +} // end namespace video +} // end namespace irr diff --git a/irr/src/OpenGL/ExtensionHandler.cpp b/irr/src/OpenGL/ExtensionHandler.cpp new file mode 100644 index 000000000..3ac212987 --- /dev/null +++ b/irr/src/OpenGL/ExtensionHandler.cpp @@ -0,0 +1,61 @@ +// Copyright (C) 2015 Patryk Nadrowski +// Copyright (C) 2009-2010 Amundis +// 2017 modified by Michael Zeilfelder (unifying extension handlers) +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#include "ExtensionHandler.h" + +#include "irrString.h" +#include "SMaterial.h" +#include "fast_atof.h" +#include "os.h" +#include + +// FIXME: this basically duplicates what mt_opengl.h already does + +namespace irr +{ +namespace video +{ +void COpenGL3ExtensionHandler::initExtensionsOld() +{ + auto extensions_string = reinterpret_cast(GL.GetString(GL_EXTENSIONS)); + const char *pos = extensions_string; + while (const char *next = strchr(pos, ' ')) { + addExtension(std::string{pos, next}); + pos = next + 1; + } + addExtension(pos); + extensionsLoaded(); +} + +void COpenGL3ExtensionHandler::initExtensionsNew() +{ + int ext_count = GetInteger(GL_NUM_EXTENSIONS); + for (int k = 0; k < ext_count; k++) + addExtension(reinterpret_cast(GL.GetStringi(GL_EXTENSIONS, k))); + extensionsLoaded(); +} + +void COpenGL3ExtensionHandler::addExtension(std::string &&name) +{ + Extensions.emplace(std::move(name)); +} + +bool COpenGL3ExtensionHandler::queryExtension(const std::string &name) const noexcept +{ + return Extensions.find(name) != Extensions.end(); +} + +void COpenGL3ExtensionHandler::extensionsLoaded() +{ + os::Printer::log((std::string("Loaded ") + std::to_string(Extensions.size()) + " extensions:").c_str(), ELL_DEBUG); + for (const auto &it : Extensions) + os::Printer::log((std::string(" ") + it).c_str(), ELL_DEBUG); + for (size_t j = 0; j < IRR_OGLES_Feature_Count; ++j) + FeatureAvailable[j] = queryExtension(getFeatureString(j)); +} + +} // end namespace video +} // end namespace irr diff --git a/irr/src/OpenGL/ExtensionHandler.h b/irr/src/OpenGL/ExtensionHandler.h new file mode 100644 index 000000000..8f96f0d4a --- /dev/null +++ b/irr/src/OpenGL/ExtensionHandler.h @@ -0,0 +1,170 @@ +// Copyright (C) 2023 Vitaliy Lobachevskiy +// Copyright (C) 2015 Patryk Nadrowski +// Copyright (C) 2009-2010 Amundis +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#pragma once + +#include + +#include "EDriverFeatures.h" +#include "irrTypes.h" +#include "os.h" + +#include "Common.h" +#include // must be after Common.h + +#include "COGLESCoreExtensionHandler.h" + +namespace irr +{ +namespace video +{ + +class COpenGL3ExtensionHandler : public COGLESCoreExtensionHandler +{ +public: + COpenGL3ExtensionHandler() : + COGLESCoreExtensionHandler() {} + + void initExtensionsOld(); + void initExtensionsNew(); + + /// Checks whether a named extension is present + bool queryExtension(const std::string &name) const noexcept; + + bool queryFeature(video::E_VIDEO_DRIVER_FEATURE feature) const + { + switch (feature) { + case EVDF_RENDER_TO_TARGET: + case EVDF_HARDWARE_TL: + case EVDF_MULTITEXTURE: + case EVDF_BILINEAR_FILTER: + case EVDF_MIP_MAP: + case EVDF_MIP_MAP_AUTO_UPDATE: + case EVDF_VERTEX_SHADER_1_1: + case EVDF_PIXEL_SHADER_1_1: + case EVDF_PIXEL_SHADER_1_2: + case EVDF_PIXEL_SHADER_2_0: + case EVDF_VERTEX_SHADER_2_0: + case EVDF_ARB_GLSL: + case EVDF_TEXTURE_NSQUARE: + case EVDF_TEXTURE_NPOT: + case EVDF_FRAMEBUFFER_OBJECT: + case EVDF_VERTEX_BUFFER_OBJECT: + case EVDF_COLOR_MASK: + case EVDF_ALPHA_TO_COVERAGE: + case EVDF_POLYGON_OFFSET: + case EVDF_BLEND_OPERATIONS: + case EVDF_BLEND_SEPARATE: + case EVDF_TEXTURE_MATRIX: + case EVDF_TEXTURE_CUBEMAP: + return true; + case EVDF_ARB_VERTEX_PROGRAM_1: + case EVDF_ARB_FRAGMENT_PROGRAM_1: + case EVDF_GEOMETRY_SHADER: + case EVDF_MULTIPLE_RENDER_TARGETS: + case EVDF_MRT_BLEND: + case EVDF_MRT_COLOR_MASK: + case EVDF_MRT_BLEND_FUNC: + case EVDF_OCCLUSION_QUERY: + return false; + case EVDF_STENCIL_BUFFER: + return StencilBuffer; + default: + return false; + }; + } + + static GLint GetInteger(GLenum key) + { + GLint val = 0; + GL.GetIntegerv(key, &val); + return val; + }; + + inline void irrGlActiveTexture(GLenum texture) + { + GL.ActiveTexture(texture); + } + + inline void irrGlCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, + GLsizei imageSize, const void *data) + { + os::Printer::log("Compressed textures aren't supported", ELL_ERROR); + } + + inline void irrGlCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + GLenum format, GLsizei imageSize, const void *data) + { + os::Printer::log("Compressed textures aren't supported", ELL_ERROR); + } + + inline void irrGlUseProgram(GLuint prog) + { + GL.UseProgram(prog); + } + + inline void irrGlBindFramebuffer(GLenum target, GLuint framebuffer) + { + GL.BindFramebuffer(target, framebuffer); + } + + inline void irrGlDeleteFramebuffers(GLsizei n, const GLuint *framebuffers) + { + GL.DeleteFramebuffers(n, framebuffers); + } + + inline void irrGlGenFramebuffers(GLsizei n, GLuint *framebuffers) + { + GL.GenFramebuffers(n, framebuffers); + } + + inline GLenum irrGlCheckFramebufferStatus(GLenum target) + { + return GL.CheckFramebufferStatus(target); + } + + inline void irrGlFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) + { + GL.FramebufferTexture2D(target, attachment, textarget, texture, level); + } + + inline void irrGlGenerateMipmap(GLenum target) + { + GL.GenerateMipmap(target); + } + + inline void irrGlDrawBuffer(GLenum mode) + { + GL.DrawBuffer(mode); + } + + inline void irrGlDrawBuffers(GLsizei n, const GLenum *bufs) + { + GL.DrawBuffers(n, bufs); + } + + inline void irrGlBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) + { + GL.BlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); + } + + inline void irrGlBlendEquation(GLenum mode) + { + GL.BlendEquation(mode); + } + + bool AnisotropicFilterSupported = false; + bool BlendMinMaxSupported = false; + +private: + void addExtension(std::string &&name); + void extensionsLoaded(); + + std::unordered_set Extensions; +}; + +} +} diff --git a/irr/src/OpenGL/FixedPipelineRenderer.cpp b/irr/src/OpenGL/FixedPipelineRenderer.cpp new file mode 100644 index 000000000..7c4adf719 --- /dev/null +++ b/irr/src/OpenGL/FixedPipelineRenderer.cpp @@ -0,0 +1,186 @@ +// Copyright (C) 2023 Vitaliy Lobachevskiy +// Copyright (C) 2014 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#include "FixedPipelineRenderer.h" + +#include "IVideoDriver.h" + +namespace irr +{ +namespace video +{ + +// Base callback + +COpenGL3MaterialBaseCB::COpenGL3MaterialBaseCB() : + FirstUpdateBase(true), WVPMatrixID(-1), WVMatrixID(-1), NMatrixID(-1), + FogEnableID(-1), FogTypeID(-1), FogColorID(-1), FogStartID(-1), + FogEndID(-1), FogDensityID(-1), ThicknessID(-1), LightEnable(false), MaterialAmbient(SColorf(0.f, 0.f, 0.f)), MaterialDiffuse(SColorf(0.f, 0.f, 0.f)), MaterialEmissive(SColorf(0.f, 0.f, 0.f)), MaterialSpecular(SColorf(0.f, 0.f, 0.f)), + MaterialShininess(0.f), FogEnable(0), FogType(1), FogColor(SColorf(0.f, 0.f, 0.f, 1.f)), FogStart(0.f), FogEnd(0.f), FogDensity(0.f), Thickness(1.f) +{ +} + +void COpenGL3MaterialBaseCB::OnSetMaterial(const SMaterial &material) +{ + LightEnable = material.Lighting; + MaterialAmbient = SColorf(material.AmbientColor); + MaterialDiffuse = SColorf(material.DiffuseColor); + MaterialEmissive = SColorf(material.EmissiveColor); + MaterialSpecular = SColorf(material.SpecularColor); + MaterialShininess = material.Shininess; + + FogEnable = material.FogEnable ? 1 : 0; + + Thickness = (material.Thickness > 0.f) ? material.Thickness : 1.f; +} + +void COpenGL3MaterialBaseCB::OnSetConstants(IMaterialRendererServices *services, s32 userData) +{ + IVideoDriver *driver = services->getVideoDriver(); + + if (FirstUpdateBase) { + WVPMatrixID = services->getVertexShaderConstantID("uWVPMatrix"); + WVMatrixID = services->getVertexShaderConstantID("uWVMatrix"); + NMatrixID = services->getVertexShaderConstantID("uNMatrix"); + + FogEnableID = services->getVertexShaderConstantID("uFogEnable"); + FogTypeID = services->getVertexShaderConstantID("uFogType"); + FogColorID = services->getVertexShaderConstantID("uFogColor"); + FogStartID = services->getVertexShaderConstantID("uFogStart"); + FogEndID = services->getVertexShaderConstantID("uFogEnd"); + FogDensityID = services->getVertexShaderConstantID("uFogDensity"); + ThicknessID = services->getVertexShaderConstantID("uThickness"); + + FirstUpdateBase = false; + } + + const core::matrix4 W = driver->getTransform(ETS_WORLD); + const core::matrix4 V = driver->getTransform(ETS_VIEW); + const core::matrix4 P = driver->getTransform(ETS_PROJECTION); + + core::matrix4 Matrix = P * V * W; + services->setPixelShaderConstant(WVPMatrixID, Matrix.pointer(), 16); + + Matrix = V * W; + services->setPixelShaderConstant(WVMatrixID, Matrix.pointer(), 16); + + Matrix.makeInverse(); + services->setPixelShaderConstant(NMatrixID, Matrix.getTransposed().pointer(), 16); + + services->setPixelShaderConstant(FogEnableID, &FogEnable, 1); + + if (FogEnable) { + SColor TempColor(0); + E_FOG_TYPE TempType = EFT_FOG_LINEAR; + bool TempPerFragment = false; + bool TempRange = false; + + driver->getFog(TempColor, TempType, FogStart, FogEnd, FogDensity, TempPerFragment, TempRange); + + FogType = (s32)TempType; + FogColor = SColorf(TempColor); + + services->setPixelShaderConstant(FogTypeID, &FogType, 1); + services->setPixelShaderConstant(FogColorID, reinterpret_cast(&FogColor), 4); + services->setPixelShaderConstant(FogStartID, &FogStart, 1); + services->setPixelShaderConstant(FogEndID, &FogEnd, 1); + services->setPixelShaderConstant(FogDensityID, &FogDensity, 1); + } + + services->setPixelShaderConstant(ThicknessID, &Thickness, 1); +} + +// EMT_SOLID + EMT_TRANSPARENT_ALPHA_CHANNEL + EMT_TRANSPARENT_VERTEX_ALPHA + +COpenGL3MaterialSolidCB::COpenGL3MaterialSolidCB() : + FirstUpdate(true), TMatrix0ID(-1), AlphaRefID(-1), TextureUsage0ID(-1), TextureUnit0ID(-1), AlphaRef(0.5f), TextureUsage0(0), TextureUnit0(0) +{ +} + +void COpenGL3MaterialSolidCB::OnSetMaterial(const SMaterial &material) +{ + COpenGL3MaterialBaseCB::OnSetMaterial(material); + + AlphaRef = material.MaterialTypeParam; + TextureUsage0 = (material.TextureLayers[0].Texture) ? 1 : 0; +} + +void COpenGL3MaterialSolidCB::OnSetConstants(IMaterialRendererServices *services, s32 userData) +{ + COpenGL3MaterialBaseCB::OnSetConstants(services, userData); + + IVideoDriver *driver = services->getVideoDriver(); + + if (FirstUpdate) { + TMatrix0ID = services->getVertexShaderConstantID("uTMatrix0"); + AlphaRefID = services->getVertexShaderConstantID("uAlphaRef"); + TextureUsage0ID = services->getVertexShaderConstantID("uTextureUsage0"); + TextureUnit0ID = services->getVertexShaderConstantID("uTextureUnit0"); + + FirstUpdate = false; + } + + core::matrix4 Matrix = driver->getTransform(ETS_TEXTURE_0); + services->setPixelShaderConstant(TMatrix0ID, Matrix.pointer(), 16); + + services->setPixelShaderConstant(AlphaRefID, &AlphaRef, 1); + services->setPixelShaderConstant(TextureUsage0ID, &TextureUsage0, 1); + services->setPixelShaderConstant(TextureUnit0ID, &TextureUnit0, 1); +} + +// EMT_ONETEXTURE_BLEND + +COpenGL3MaterialOneTextureBlendCB::COpenGL3MaterialOneTextureBlendCB() : + FirstUpdate(true), TMatrix0ID(-1), BlendTypeID(-1), TextureUsage0ID(-1), TextureUnit0ID(-1), BlendType(0), TextureUsage0(0), TextureUnit0(0) +{ +} + +void COpenGL3MaterialOneTextureBlendCB::OnSetMaterial(const SMaterial &material) +{ + COpenGL3MaterialBaseCB::OnSetMaterial(material); + + BlendType = 0; + + E_BLEND_FACTOR srcRGBFact, dstRGBFact, srcAlphaFact, dstAlphaFact; + E_MODULATE_FUNC modulate; + u32 alphaSource; + unpack_textureBlendFuncSeparate(srcRGBFact, dstRGBFact, srcAlphaFact, dstAlphaFact, modulate, alphaSource, material.MaterialTypeParam); + + if (textureBlendFunc_hasAlpha(srcRGBFact) || textureBlendFunc_hasAlpha(dstRGBFact) || textureBlendFunc_hasAlpha(srcAlphaFact) || textureBlendFunc_hasAlpha(dstAlphaFact)) { + if (alphaSource == EAS_VERTEX_COLOR) { + BlendType = 1; + } else if (alphaSource == EAS_TEXTURE) { + BlendType = 2; + } + } + + TextureUsage0 = (material.TextureLayers[0].Texture) ? 1 : 0; +} + +void COpenGL3MaterialOneTextureBlendCB::OnSetConstants(IMaterialRendererServices *services, s32 userData) +{ + COpenGL3MaterialBaseCB::OnSetConstants(services, userData); + + IVideoDriver *driver = services->getVideoDriver(); + + if (FirstUpdate) { + TMatrix0ID = services->getVertexShaderConstantID("uTMatrix0"); + BlendTypeID = services->getVertexShaderConstantID("uBlendType"); + TextureUsage0ID = services->getVertexShaderConstantID("uTextureUsage0"); + TextureUnit0ID = services->getVertexShaderConstantID("uTextureUnit0"); + + FirstUpdate = false; + } + + core::matrix4 Matrix = driver->getTransform(ETS_TEXTURE_0); + services->setPixelShaderConstant(TMatrix0ID, Matrix.pointer(), 16); + + services->setPixelShaderConstant(BlendTypeID, &BlendType, 1); + services->setPixelShaderConstant(TextureUsage0ID, &TextureUsage0, 1); + services->setPixelShaderConstant(TextureUnit0ID, &TextureUnit0, 1); +} + +} +} diff --git a/irr/src/OpenGL/FixedPipelineRenderer.h b/irr/src/OpenGL/FixedPipelineRenderer.h new file mode 100644 index 000000000..a07af1df9 --- /dev/null +++ b/irr/src/OpenGL/FixedPipelineRenderer.h @@ -0,0 +1,101 @@ +// Copyright (C) 2023 Vitaliy Lobachevskiy +// Copyright (C) 2014 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#pragma once + +#include "IShaderConstantSetCallBack.h" +#include "IMaterialRendererServices.h" + +namespace irr +{ +namespace video +{ + +class COpenGL3MaterialBaseCB : public IShaderConstantSetCallBack +{ +public: + COpenGL3MaterialBaseCB(); + + virtual void OnSetMaterial(const SMaterial &material); + virtual void OnSetConstants(IMaterialRendererServices *services, s32 userData); + +protected: + bool FirstUpdateBase; + + s32 WVPMatrixID; + s32 WVMatrixID; + s32 NMatrixID; + + s32 FogEnableID; + s32 FogTypeID; + s32 FogColorID; + s32 FogStartID; + s32 FogEndID; + s32 FogDensityID; + + s32 ThicknessID; + + bool LightEnable; + SColorf GlobalAmbient; + SColorf MaterialAmbient; + SColorf MaterialDiffuse; + SColorf MaterialEmissive; + SColorf MaterialSpecular; + f32 MaterialShininess; + + s32 FogEnable; + s32 FogType; + SColorf FogColor; + f32 FogStart; + f32 FogEnd; + f32 FogDensity; + + f32 Thickness; +}; + +class COpenGL3MaterialSolidCB : public COpenGL3MaterialBaseCB +{ +public: + COpenGL3MaterialSolidCB(); + + virtual void OnSetMaterial(const SMaterial &material); + virtual void OnSetConstants(IMaterialRendererServices *services, s32 userData); + +protected: + bool FirstUpdate; + + s32 TMatrix0ID; + s32 AlphaRefID; + s32 TextureUsage0ID; + s32 TextureUnit0ID; + + f32 AlphaRef; + s32 TextureUsage0; + s32 TextureUnit0; +}; + +class COpenGL3MaterialOneTextureBlendCB : public COpenGL3MaterialBaseCB +{ +public: + COpenGL3MaterialOneTextureBlendCB(); + + virtual void OnSetMaterial(const SMaterial &material); + virtual void OnSetConstants(IMaterialRendererServices *services, s32 userData); + +protected: + bool FirstUpdate; + + s32 TMatrix0ID; + s32 BlendTypeID; + s32 TextureUsage0ID; + s32 TextureUnit0ID; + + s32 BlendType; + s32 TextureUsage0; + s32 TextureUnit0; +}; + +} +} diff --git a/irr/src/OpenGL/MaterialRenderer.cpp b/irr/src/OpenGL/MaterialRenderer.cpp new file mode 100644 index 000000000..51a796d48 --- /dev/null +++ b/irr/src/OpenGL/MaterialRenderer.cpp @@ -0,0 +1,429 @@ +// Copyright (C) 2014 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "MaterialRenderer.h" + +#include "EVertexAttributes.h" +#include "IGPUProgrammingServices.h" +#include "IShaderConstantSetCallBack.h" +#include "IVideoDriver.h" +#include "os.h" + +#include "Driver.h" + +#include "COpenGLCoreTexture.h" +#include "COpenGLCoreCacheHandler.h" + +namespace irr +{ +namespace video +{ + +COpenGL3MaterialRenderer::COpenGL3MaterialRenderer(COpenGL3DriverBase *driver, + s32 &outMaterialTypeNr, + const c8 *vertexShaderProgram, + const c8 *pixelShaderProgram, + IShaderConstantSetCallBack *callback, + E_MATERIAL_TYPE baseMaterial, + s32 userData) : + Driver(driver), + CallBack(callback), Alpha(false), Blending(false), Program(0), UserData(userData) +{ +#ifdef _DEBUG + setDebugName("MaterialRenderer"); +#endif + + switch (baseMaterial) { + case EMT_TRANSPARENT_VERTEX_ALPHA: + case EMT_TRANSPARENT_ALPHA_CHANNEL: + Alpha = true; + break; + case EMT_ONETEXTURE_BLEND: + Blending = true; + break; + default: + break; + } + + if (CallBack) + CallBack->grab(); + + init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram); +} + +COpenGL3MaterialRenderer::COpenGL3MaterialRenderer(COpenGL3DriverBase *driver, + IShaderConstantSetCallBack *callback, + E_MATERIAL_TYPE baseMaterial, s32 userData) : + Driver(driver), + CallBack(callback), Alpha(false), Blending(false), Program(0), UserData(userData) +{ + switch (baseMaterial) { + case EMT_TRANSPARENT_VERTEX_ALPHA: + case EMT_TRANSPARENT_ALPHA_CHANNEL: + Alpha = true; + break; + case EMT_ONETEXTURE_BLEND: + Blending = true; + break; + default: + break; + } + + if (CallBack) + CallBack->grab(); +} + +COpenGL3MaterialRenderer::~COpenGL3MaterialRenderer() +{ + if (CallBack) + CallBack->drop(); + + if (Program) { + GLuint shaders[8]; + GLint count; + GL.GetAttachedShaders(Program, 8, &count, shaders); + + count = core::min_(count, 8); + for (GLint i = 0; i < count; ++i) + GL.DeleteShader(shaders[i]); + GL.DeleteProgram(Program); + Program = 0; + } + + UniformInfo.clear(); +} + +GLuint COpenGL3MaterialRenderer::getProgram() const +{ + return Program; +} + +void COpenGL3MaterialRenderer::init(s32 &outMaterialTypeNr, + const c8 *vertexShaderProgram, + const c8 *pixelShaderProgram, + bool addMaterial) +{ + outMaterialTypeNr = -1; + + Program = GL.CreateProgram(); + + if (!Program) + return; + + if (vertexShaderProgram) + if (!createShader(GL_VERTEX_SHADER, vertexShaderProgram)) + return; + + if (pixelShaderProgram) + if (!createShader(GL_FRAGMENT_SHADER, pixelShaderProgram)) + return; + + for (size_t i = 0; i < EVA_COUNT; ++i) + GL.BindAttribLocation(Program, i, sBuiltInVertexAttributeNames[i]); + + if (!linkProgram()) + return; + + if (addMaterial) + outMaterialTypeNr = Driver->addMaterialRenderer(this); +} + +bool COpenGL3MaterialRenderer::OnRender(IMaterialRendererServices *service, E_VERTEX_TYPE vtxtype) +{ + if (CallBack && Program) + CallBack->OnSetConstants(this, UserData); + + return true; +} + +void COpenGL3MaterialRenderer::OnSetMaterial(const video::SMaterial &material, + const video::SMaterial &lastMaterial, + bool resetAllRenderstates, + video::IMaterialRendererServices *services) +{ + COpenGL3CacheHandler *cacheHandler = Driver->getCacheHandler(); + + cacheHandler->setProgram(Program); + + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + if (Alpha) { + cacheHandler->setBlend(true); + cacheHandler->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } else if (Blending) { + E_BLEND_FACTOR srcRGBFact, dstRGBFact, srcAlphaFact, dstAlphaFact; + E_MODULATE_FUNC modulate; + u32 alphaSource; + unpack_textureBlendFuncSeparate(srcRGBFact, dstRGBFact, srcAlphaFact, dstAlphaFact, modulate, alphaSource, material.MaterialTypeParam); + + cacheHandler->setBlendFuncSeparate(Driver->getGLBlend(srcRGBFact), Driver->getGLBlend(dstRGBFact), + Driver->getGLBlend(srcAlphaFact), Driver->getGLBlend(dstAlphaFact)); + + cacheHandler->setBlend(true); + } + + if (CallBack) + CallBack->OnSetMaterial(material); +} + +void COpenGL3MaterialRenderer::OnUnsetMaterial() +{ +} + +bool COpenGL3MaterialRenderer::isTransparent() const +{ + return (Alpha || Blending); +} + +s32 COpenGL3MaterialRenderer::getRenderCapability() const +{ + return 0; +} + +bool COpenGL3MaterialRenderer::createShader(GLenum shaderType, const char *shader) +{ + if (Program) { + GLuint shaderHandle = GL.CreateShader(shaderType); + GL.ShaderSource(shaderHandle, 1, &shader, NULL); + GL.CompileShader(shaderHandle); + + GLint status = 0; + + GL.GetShaderiv(shaderHandle, GL_COMPILE_STATUS, &status); + + if (status != GL_TRUE) { + os::Printer::log("GLSL shader failed to compile", ELL_ERROR); + + GLint maxLength = 0; + GLint length; + + GL.GetShaderiv(shaderHandle, GL_INFO_LOG_LENGTH, + &maxLength); + + if (maxLength) { + GLchar *infoLog = new GLchar[maxLength]; + GL.GetShaderInfoLog(shaderHandle, maxLength, &length, infoLog); + os::Printer::log(reinterpret_cast(infoLog), ELL_ERROR); + delete[] infoLog; + } + + return false; + } + + GL.AttachShader(Program, shaderHandle); + } + + return true; +} + +bool COpenGL3MaterialRenderer::linkProgram() +{ + if (Program) { + GL.LinkProgram(Program); + + GLint status = 0; + + GL.GetProgramiv(Program, GL_LINK_STATUS, &status); + + if (!status) { + os::Printer::log("GLSL shader program failed to link", ELL_ERROR); + + GLint maxLength = 0; + GLsizei length; + + GL.GetProgramiv(Program, GL_INFO_LOG_LENGTH, &maxLength); + + if (maxLength) { + GLchar *infoLog = new GLchar[maxLength]; + GL.GetProgramInfoLog(Program, maxLength, &length, infoLog); + os::Printer::log(reinterpret_cast(infoLog), ELL_ERROR); + delete[] infoLog; + } + + return false; + } + + GLint num = 0; + + GL.GetProgramiv(Program, GL_ACTIVE_UNIFORMS, &num); + + if (num == 0) + return true; + + GLint maxlen = 0; + + GL.GetProgramiv(Program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxlen); + + if (maxlen == 0) { + os::Printer::log("GLSL: failed to retrieve uniform information", ELL_ERROR); + return false; + } + + // seems that some implementations use an extra null terminator. + ++maxlen; + c8 *buf = new c8[maxlen]; + + UniformInfo.clear(); + UniformInfo.reallocate(num); + + for (GLint i = 0; i < num; ++i) { + SUniformInfo ui; + memset(buf, 0, maxlen); + + GLint size; + GL.GetActiveUniform(Program, i, maxlen, 0, &size, &ui.type, reinterpret_cast(buf)); + + core::stringc name = ""; + + // array support, workaround for some bugged drivers. + for (s32 i = 0; i < maxlen; ++i) { + if (buf[i] == '[' || buf[i] == '\0') + break; + + name += buf[i]; + } + + ui.name = name; + ui.location = GL.GetUniformLocation(Program, buf); + + UniformInfo.push_back(ui); + } + + delete[] buf; + } + + return true; +} + +void COpenGL3MaterialRenderer::setBasicRenderStates(const SMaterial &material, + const SMaterial &lastMaterial, + bool resetAllRenderstates) +{ + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); +} + +s32 COpenGL3MaterialRenderer::getVertexShaderConstantID(const c8 *name) +{ + return getPixelShaderConstantID(name); +} + +s32 COpenGL3MaterialRenderer::getPixelShaderConstantID(const c8 *name) +{ + for (u32 i = 0; i < UniformInfo.size(); ++i) { + if (UniformInfo[i].name == name) + return i; + } + + return -1; +} + +bool COpenGL3MaterialRenderer::setVertexShaderConstant(s32 index, const f32 *floats, int count) +{ + return setPixelShaderConstant(index, floats, count); +} + +bool COpenGL3MaterialRenderer::setVertexShaderConstant(s32 index, const s32 *ints, int count) +{ + return setPixelShaderConstant(index, ints, count); +} + +bool COpenGL3MaterialRenderer::setVertexShaderConstant(s32 index, const u32 *ints, int count) +{ + return setPixelShaderConstant(index, ints, count); +} + +bool COpenGL3MaterialRenderer::setPixelShaderConstant(s32 index, const f32 *floats, int count) +{ + if (index < 0 || UniformInfo[index].location < 0) + return false; + + bool status = true; + + switch (UniformInfo[index].type) { + case GL_FLOAT: + GL.Uniform1fv(UniformInfo[index].location, count, floats); + break; + case GL_FLOAT_VEC2: + GL.Uniform2fv(UniformInfo[index].location, count / 2, floats); + break; + case GL_FLOAT_VEC3: + GL.Uniform3fv(UniformInfo[index].location, count / 3, floats); + break; + case GL_FLOAT_VEC4: + GL.Uniform4fv(UniformInfo[index].location, count / 4, floats); + break; + case GL_FLOAT_MAT2: + GL.UniformMatrix2fv(UniformInfo[index].location, count / 4, false, floats); + break; + case GL_FLOAT_MAT3: + GL.UniformMatrix3fv(UniformInfo[index].location, count / 9, false, floats); + break; + case GL_FLOAT_MAT4: + GL.UniformMatrix4fv(UniformInfo[index].location, count / 16, false, floats); + break; + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: { + if (floats) { + const GLint id = (GLint)(*floats); + GL.Uniform1iv(UniformInfo[index].location, 1, &id); + } else + status = false; + } break; + default: + status = false; + break; + } + + return status; +} + +bool COpenGL3MaterialRenderer::setPixelShaderConstant(s32 index, const s32 *ints, int count) +{ + if (index < 0 || UniformInfo[index].location < 0) + return false; + + bool status = true; + + switch (UniformInfo[index].type) { + case GL_INT: + case GL_BOOL: + GL.Uniform1iv(UniformInfo[index].location, count, ints); + break; + case GL_INT_VEC2: + case GL_BOOL_VEC2: + GL.Uniform2iv(UniformInfo[index].location, count / 2, ints); + break; + case GL_INT_VEC3: + case GL_BOOL_VEC3: + GL.Uniform3iv(UniformInfo[index].location, count / 3, ints); + break; + case GL_INT_VEC4: + case GL_BOOL_VEC4: + GL.Uniform4iv(UniformInfo[index].location, count / 4, ints); + break; + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: + GL.Uniform1iv(UniformInfo[index].location, 1, ints); + break; + default: + status = false; + break; + } + + return status; +} + +bool COpenGL3MaterialRenderer::setPixelShaderConstant(s32 index, const u32 *ints, int count) +{ + os::Printer::log("Unsigned int support needs at least GLES 3.0", ELL_WARNING); + return false; +} + +IVideoDriver *COpenGL3MaterialRenderer::getVideoDriver() +{ + return Driver; +} + +} +} diff --git a/irr/src/OpenGL/MaterialRenderer.h b/irr/src/OpenGL/MaterialRenderer.h new file mode 100644 index 000000000..be74461e3 --- /dev/null +++ b/irr/src/OpenGL/MaterialRenderer.h @@ -0,0 +1,93 @@ +// Copyright (C) 2014 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "EMaterialTypes.h" +#include "IMaterialRenderer.h" +#include "IMaterialRendererServices.h" +#include "IGPUProgrammingServices.h" +#include "irrArray.h" +#include "irrString.h" + +#include "Common.h" + +namespace irr +{ +namespace video +{ + +class COpenGL3DriverBase; + +class COpenGL3MaterialRenderer : public IMaterialRenderer, public IMaterialRendererServices +{ +public: + COpenGL3MaterialRenderer( + COpenGL3DriverBase *driver, + s32 &outMaterialTypeNr, + const c8 *vertexShaderProgram = 0, + const c8 *pixelShaderProgram = 0, + IShaderConstantSetCallBack *callback = 0, + E_MATERIAL_TYPE baseMaterial = EMT_SOLID, + s32 userData = 0); + + virtual ~COpenGL3MaterialRenderer(); + + GLuint getProgram() const; + + virtual void OnSetMaterial(const SMaterial &material, const SMaterial &lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices *services); + + virtual bool OnRender(IMaterialRendererServices *service, E_VERTEX_TYPE vtxtype); + + virtual void OnUnsetMaterial(); + + virtual bool isTransparent() const; + + virtual s32 getRenderCapability() const; + + void setBasicRenderStates(const SMaterial &material, const SMaterial &lastMaterial, bool resetAllRenderstates) override; + + s32 getVertexShaderConstantID(const c8 *name) override; + s32 getPixelShaderConstantID(const c8 *name) override; + bool setVertexShaderConstant(s32 index, const f32 *floats, int count) override; + bool setVertexShaderConstant(s32 index, const s32 *ints, int count) override; + bool setVertexShaderConstant(s32 index, const u32 *ints, int count) override; + bool setPixelShaderConstant(s32 index, const f32 *floats, int count) override; + bool setPixelShaderConstant(s32 index, const s32 *ints, int count) override; + bool setPixelShaderConstant(s32 index, const u32 *ints, int count) override; + + IVideoDriver *getVideoDriver() override; + +protected: + COpenGL3MaterialRenderer(COpenGL3DriverBase *driver, + IShaderConstantSetCallBack *callback = 0, + E_MATERIAL_TYPE baseMaterial = EMT_SOLID, + s32 userData = 0); + + void init(s32 &outMaterialTypeNr, const c8 *vertexShaderProgram, const c8 *pixelShaderProgram, bool addMaterial = true); + + bool createShader(GLenum shaderType, const char *shader); + bool linkProgram(); + + COpenGL3DriverBase *Driver; + IShaderConstantSetCallBack *CallBack; + + bool Alpha; + bool Blending; + + struct SUniformInfo + { + core::stringc name; + GLenum type; + GLint location; + }; + + GLuint Program; + core::array UniformInfo; + s32 UserData; +}; + +} +} diff --git a/irr/src/OpenGL/Renderer2D.cpp b/irr/src/OpenGL/Renderer2D.cpp new file mode 100644 index 000000000..b625feda4 --- /dev/null +++ b/irr/src/OpenGL/Renderer2D.cpp @@ -0,0 +1,81 @@ +// Copyright (C) 2014 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#include "Renderer2D.h" + +#include "IGPUProgrammingServices.h" +#include "os.h" + +#include "Driver.h" + +#include "COpenGLCoreFeature.h" +#include "COpenGLCoreTexture.h" +#include "COpenGLCoreCacheHandler.h" + +namespace irr +{ +namespace video +{ + +COpenGL3Renderer2D::COpenGL3Renderer2D(const c8 *vertexShaderProgram, const c8 *pixelShaderProgram, COpenGL3DriverBase *driver, bool withTexture) : + COpenGL3MaterialRenderer(driver, 0, EMT_SOLID), + WithTexture(withTexture) +{ +#ifdef _DEBUG + setDebugName("Renderer2D"); +#endif + + int Temp = 0; + + init(Temp, vertexShaderProgram, pixelShaderProgram, false); + + COpenGL3CacheHandler *cacheHandler = Driver->getCacheHandler(); + + cacheHandler->setProgram(Program); + + // These states don't change later. + + ThicknessID = getPixelShaderConstantID("uThickness"); + if (WithTexture) { + TextureUsageID = getPixelShaderConstantID("uTextureUsage"); + s32 TextureUnitID = getPixelShaderConstantID("uTextureUnit"); + + s32 TextureUnit = 0; + setPixelShaderConstant(TextureUnitID, &TextureUnit, 1); + + s32 TextureUsage = 0; + setPixelShaderConstant(TextureUsageID, &TextureUsage, 1); + } + + cacheHandler->setProgram(0); +} + +COpenGL3Renderer2D::~COpenGL3Renderer2D() +{ +} + +void COpenGL3Renderer2D::OnSetMaterial(const video::SMaterial &material, + const video::SMaterial &lastMaterial, + bool resetAllRenderstates, + video::IMaterialRendererServices *services) +{ + Driver->getCacheHandler()->setProgram(Program); + Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates); + + f32 Thickness = (material.Thickness > 0.f) ? material.Thickness : 1.f; + setPixelShaderConstant(ThicknessID, &Thickness, 1); + + if (WithTexture) { + s32 TextureUsage = material.TextureLayers[0].Texture ? 1 : 0; + setPixelShaderConstant(TextureUsageID, &TextureUsage, 1); + } +} + +bool COpenGL3Renderer2D::OnRender(IMaterialRendererServices *service, E_VERTEX_TYPE vtxtype) +{ + return true; +} + +} +} diff --git a/irr/src/OpenGL/Renderer2D.h b/irr/src/OpenGL/Renderer2D.h new file mode 100644 index 000000000..6cfc7029d --- /dev/null +++ b/irr/src/OpenGL/Renderer2D.h @@ -0,0 +1,32 @@ +// Copyright (C) 2014 Patryk Nadrowski +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#pragma once + +#include "MaterialRenderer.h" + +namespace irr +{ +namespace video +{ + +class COpenGL3Renderer2D : public COpenGL3MaterialRenderer +{ +public: + COpenGL3Renderer2D(const c8 *vertexShaderProgram, const c8 *pixelShaderProgram, COpenGL3DriverBase *driver, bool withTexture); + ~COpenGL3Renderer2D(); + + virtual void OnSetMaterial(const SMaterial &material, const SMaterial &lastMaterial, + bool resetAllRenderstates, IMaterialRendererServices *services); + + virtual bool OnRender(IMaterialRendererServices *service, E_VERTEX_TYPE vtxtype); + +protected: + bool WithTexture; + s32 ThicknessID; + s32 TextureUsageID; +}; + +} +} diff --git a/irr/src/OpenGL3/Driver.cpp b/irr/src/OpenGL3/Driver.cpp new file mode 100644 index 000000000..8196a8117 --- /dev/null +++ b/irr/src/OpenGL3/Driver.cpp @@ -0,0 +1,89 @@ +// Copyright (C) 2023 Vitaliy Lobachevskiy +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#include "Driver.h" +#include +#include "mt_opengl.h" + +namespace irr +{ +namespace video +{ + +E_DRIVER_TYPE COpenGL3Driver::getDriverType() const +{ + return EDT_OPENGL3; +} + +OpenGLVersion COpenGL3Driver::getVersionFromOpenGL() const +{ + GLint major, minor, profile; + GL.GetIntegerv(GL_MAJOR_VERSION, &major); + GL.GetIntegerv(GL_MINOR_VERSION, &minor); + GL.GetIntegerv(GL_CONTEXT_PROFILE_MASK, &profile); + // The spec is clear a context can’t be both core and compatibility at the same time. + // However, the returned value is a mask. Ask Khronos why. -- numzero + if (profile & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) + return {OpenGLSpec::Compat, (u8)major, (u8)minor, 0}; + if (profile & GL_CONTEXT_CORE_PROFILE_BIT) + return {OpenGLSpec::Core, (u8)major, (u8)minor, 0}; + os::Printer::log("Got unrecognized OpenGL profile", ELL_ERROR); + return {OpenGLSpec::Core, (u8)major, (u8)minor, 0}; +} + +void COpenGL3Driver::initFeatures() +{ + assert(Version.Spec == OpenGLSpec::Compat); + assert(isVersionAtLeast(3, 2)); + initExtensionsNew(); + + TextureFormats[ECF_A1R5G5B5] = {GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV}; // WARNING: may not be renderable + TextureFormats[ECF_R5G6B5] = {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5}; // GL_RGB565 is an extension until 4.1 + TextureFormats[ECF_R8G8B8] = {GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE}; // WARNING: may not be renderable + TextureFormats[ECF_A8R8G8B8] = {GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV}; + TextureFormats[ECF_R16F] = {GL_R16F, GL_RED, GL_HALF_FLOAT}; + TextureFormats[ECF_G16R16F] = {GL_RG16F, GL_RG, GL_HALF_FLOAT}; + TextureFormats[ECF_A16B16G16R16F] = {GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT}; + TextureFormats[ECF_R32F] = {GL_R32F, GL_RED, GL_FLOAT}; + TextureFormats[ECF_G32R32F] = {GL_RG32F, GL_RG, GL_FLOAT}; + TextureFormats[ECF_A32B32G32R32F] = {GL_RGBA32F, GL_RGBA, GL_FLOAT}; + TextureFormats[ECF_R8] = {GL_R8, GL_RED, GL_UNSIGNED_BYTE}; + TextureFormats[ECF_R8G8] = {GL_RG8, GL_RG, GL_UNSIGNED_BYTE}; + TextureFormats[ECF_R16] = {GL_R16, GL_RED, GL_UNSIGNED_SHORT}; + TextureFormats[ECF_R16G16] = {GL_RG16, GL_RG, GL_UNSIGNED_SHORT}; + TextureFormats[ECF_D16] = {GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT}; + TextureFormats[ECF_D32] = {GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT}; // WARNING: may not be renderable (?!) + TextureFormats[ECF_D24S8] = {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8}; + + AnisotropicFilterSupported = isVersionAtLeast(4, 6) || queryExtension("GL_ARB_texture_filter_anisotropic") || queryExtension("GL_EXT_texture_filter_anisotropic"); + BlendMinMaxSupported = true; + + // COGLESCoreExtensionHandler::Feature + static_assert(MATERIAL_MAX_TEXTURES <= 16, "Only up to 16 textures are guaranteed"); + Feature.BlendOperation = true; + Feature.ColorAttachment = GetInteger(GL_MAX_COLOR_ATTACHMENTS); + Feature.MaxTextureUnits = MATERIAL_MAX_TEXTURES; + Feature.MultipleRenderTarget = GetInteger(GL_MAX_DRAW_BUFFERS); + + // COGLESCoreExtensionHandler + if (AnisotropicFilterSupported) + MaxAnisotropy = GetInteger(GL.MAX_TEXTURE_MAX_ANISOTROPY); + MaxIndices = GetInteger(GL_MAX_ELEMENTS_INDICES); + MaxTextureSize = GetInteger(GL_MAX_TEXTURE_SIZE); + GL.GetFloatv(GL_MAX_TEXTURE_LOD_BIAS, &MaxTextureLODBias); + GL.GetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine); + DimAliasedPoint[0] = 1.0f; + DimAliasedPoint[1] = 1.0f; +} + +IVideoDriver *createOpenGL3Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager) +{ + os::Printer::log("Using COpenGL3Driver", ELL_INFORMATION); + COpenGL3Driver *driver = new COpenGL3Driver(params, io, contextManager); + driver->genericDriverInit(params.WindowSize, params.Stencilbuffer); // don't call in constructor, it uses virtual function calls of driver + return driver; +} + +} +} diff --git a/irr/src/OpenGL3/Driver.h b/irr/src/OpenGL3/Driver.h new file mode 100644 index 000000000..f4934051e --- /dev/null +++ b/irr/src/OpenGL3/Driver.h @@ -0,0 +1,30 @@ +// Copyright (C) 2023 Vitaliy Lobachevskiy +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#pragma once +#include "OpenGL/Driver.h" + +namespace irr +{ +namespace video +{ + +/// OpenGL 3+ driver +/// +/// For OpenGL 3.2 and higher. Compatibility profile is required currently. +class COpenGL3Driver : public COpenGL3DriverBase +{ + friend IVideoDriver *createOpenGL3Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager); + +public: + using COpenGL3DriverBase::COpenGL3DriverBase; + E_DRIVER_TYPE getDriverType() const override; + +protected: + OpenGLVersion getVersionFromOpenGL() const override; + void initFeatures() override; +}; + +} +} diff --git a/irr/src/OpenGLES2/Driver.cpp b/irr/src/OpenGLES2/Driver.cpp new file mode 100644 index 000000000..6278ee9c3 --- /dev/null +++ b/irr/src/OpenGLES2/Driver.cpp @@ -0,0 +1,147 @@ +// Copyright (C) 2023 Vitaliy Lobachevskiy +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#include "Driver.h" +#include +#include + +namespace irr +{ +namespace video +{ + +E_DRIVER_TYPE COpenGLES2Driver::getDriverType() const +{ + return EDT_OGLES2; +} + +OpenGLVersion COpenGLES2Driver::getVersionFromOpenGL() const +{ + auto version_string = reinterpret_cast(GL.GetString(GL_VERSION)); + int major, minor; + if (sscanf(version_string, "OpenGL ES %d.%d", &major, &minor) != 2) { + os::Printer::log("Failed to parse OpenGL ES version string", version_string, ELL_ERROR); + return {OpenGLSpec::ES, 0, 0, 0}; + } + return {OpenGLSpec::ES, (u8)major, (u8)minor, 0}; +} + +void COpenGLES2Driver::initFeatures() +{ + assert(Version.Spec == OpenGLSpec::ES); + assert(Version.Major >= 2); + if (Version.Major >= 3) + initExtensionsNew(); + else + initExtensionsOld(); + + static const GLenum BGRA8_EXT = 0x93A1; + + if (Version.Major >= 3) { + // NOTE floating-point formats may not be suitable for render targets. + TextureFormats[ECF_A1R5G5B5] = {GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, CColorConverter::convert_A1R5G5B5toR5G5B5A1}; + TextureFormats[ECF_R5G6B5] = {GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5}; + TextureFormats[ECF_R8G8B8] = {GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE}; + TextureFormats[ECF_A8R8G8B8] = {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, CColorConverter::convert_A8R8G8B8toA8B8G8R8}; + TextureFormats[ECF_R16F] = {GL_R16F, GL_RED, GL_HALF_FLOAT}; + TextureFormats[ECF_G16R16F] = {GL_RG16F, GL_RG, GL_HALF_FLOAT}; + TextureFormats[ECF_A16B16G16R16F] = {GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT}; + TextureFormats[ECF_R32F] = {GL_R32F, GL_RED, GL_FLOAT}; + TextureFormats[ECF_G32R32F] = {GL_RG32F, GL_RG, GL_FLOAT}; + TextureFormats[ECF_A32B32G32R32F] = {GL_RGBA32F, GL_RGBA, GL_FLOAT}; + TextureFormats[ECF_R8] = {GL_R8, GL_RED, GL_UNSIGNED_BYTE}; + TextureFormats[ECF_R8G8] = {GL_RG8, GL_RG, GL_UNSIGNED_BYTE}; + TextureFormats[ECF_D16] = {GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT}; + TextureFormats[ECF_D24S8] = {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8}; + + if (FeatureAvailable[IRR_GL_EXT_texture_format_BGRA8888]) + TextureFormats[ECF_A8R8G8B8] = {GL_BGRA, GL_BGRA, GL_UNSIGNED_BYTE}; + else if (FeatureAvailable[IRR_GL_APPLE_texture_format_BGRA8888]) + TextureFormats[ECF_A8R8G8B8] = {BGRA8_EXT, GL_BGRA, GL_UNSIGNED_BYTE}; + + if (FeatureAvailable[IRR_GL_OES_depth32]) + TextureFormats[ECF_D32] = {GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT}; + } else { + // NOTE These are *texture* formats. They may or may not be suitable + // for render targets. The specs only talks on *sized* formats for the + // latter but forbids creating textures with sized internal formats, + // reserving them for renderbuffers. + + static const GLenum HALF_FLOAT_OES = 0x8D61; // not equal to GL_HALF_FLOAT + TextureFormats[ECF_A1R5G5B5] = {GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, CColorConverter::convert_A1R5G5B5toR5G5B5A1}; + TextureFormats[ECF_R5G6B5] = {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5}; + TextureFormats[ECF_R8G8B8] = {GL_RGB, GL_RGB, GL_UNSIGNED_BYTE}; + TextureFormats[ECF_A8R8G8B8] = {GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, CColorConverter::convert_A8R8G8B8toA8B8G8R8}; + + if (FeatureAvailable[IRR_GL_EXT_texture_format_BGRA8888]) + TextureFormats[ECF_A8R8G8B8] = {GL_BGRA, GL_BGRA, GL_UNSIGNED_BYTE}; + else if (FeatureAvailable[IRR_GL_APPLE_texture_format_BGRA8888]) + TextureFormats[ECF_A8R8G8B8] = {BGRA8_EXT, GL_BGRA, GL_UNSIGNED_BYTE}; + + if (FeatureAvailable[IRR_GL_OES_texture_half_float]) { + TextureFormats[ECF_A16B16G16R16F] = {GL_RGBA, GL_RGBA, HALF_FLOAT_OES}; + } + if (FeatureAvailable[IRR_GL_OES_texture_float]) { + TextureFormats[ECF_A32B32G32R32F] = {GL_RGBA, GL_RGBA, GL_FLOAT}; + } + if (FeatureAvailable[IRR_GL_EXT_texture_rg]) { + TextureFormats[ECF_R8] = {GL_RED, GL_RED, GL_UNSIGNED_BYTE}; + TextureFormats[ECF_R8G8] = {GL_RG, GL_RG, GL_UNSIGNED_BYTE}; + + if (FeatureAvailable[IRR_GL_OES_texture_half_float]) { + TextureFormats[ECF_R16F] = {GL_RED, GL_RED, HALF_FLOAT_OES}; + TextureFormats[ECF_G16R16F] = {GL_RG, GL_RG, HALF_FLOAT_OES}; + } + if (FeatureAvailable[IRR_GL_OES_texture_float]) { + TextureFormats[ECF_R32F] = {GL_RED, GL_RED, GL_FLOAT}; + TextureFormats[ECF_G32R32F] = {GL_RG, GL_RG, GL_FLOAT}; + } + } + + if (FeatureAvailable[IRR_GL_OES_depth_texture]) { + TextureFormats[ECF_D16] = {GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT}; + if (FeatureAvailable[IRR_GL_OES_depth32]) + TextureFormats[ECF_D32] = {GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT}; + if (FeatureAvailable[IRR_GL_OES_packed_depth_stencil]) + TextureFormats[ECF_D24S8] = {GL_DEPTH_STENCIL, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8}; + } + } + + const bool MRTSupported = Version.Major >= 3 || queryExtension("GL_EXT_draw_buffers"); + AnisotropicFilterSupported = queryExtension("GL_EXT_texture_filter_anisotropic"); + BlendMinMaxSupported = (Version.Major >= 3) || FeatureAvailable[IRR_GL_EXT_blend_minmax]; + const bool TextureLODBiasSupported = queryExtension("GL_EXT_texture_lod_bias"); + + // COGLESCoreExtensionHandler::Feature + static_assert(MATERIAL_MAX_TEXTURES <= 8, "Only up to 8 textures are guaranteed"); + Feature.BlendOperation = true; + Feature.ColorAttachment = 1; + if (MRTSupported) + Feature.ColorAttachment = GetInteger(GL_MAX_COLOR_ATTACHMENTS); + Feature.MaxTextureUnits = MATERIAL_MAX_TEXTURES; + if (MRTSupported) + Feature.MultipleRenderTarget = GetInteger(GL_MAX_DRAW_BUFFERS); + + // COGLESCoreExtensionHandler + if (AnisotropicFilterSupported) + MaxAnisotropy = GetInteger(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT); + if (Version.Major >= 3 || queryExtension("GL_EXT_draw_range_elements")) + MaxIndices = GetInteger(GL_MAX_ELEMENTS_INDICES); + MaxTextureSize = GetInteger(GL_MAX_TEXTURE_SIZE); + if (TextureLODBiasSupported) + GL.GetFloatv(GL_MAX_TEXTURE_LOD_BIAS, &MaxTextureLODBias); + GL.GetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine); // NOTE: this is not in the OpenGL ES 2.0 spec... + GL.GetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint); +} + +IVideoDriver *createOGLES2Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager) +{ + os::Printer::log("Using COpenGLES2Driver", ELL_INFORMATION); + COpenGLES2Driver *driver = new COpenGLES2Driver(params, io, contextManager); + driver->genericDriverInit(params.WindowSize, params.Stencilbuffer); // don't call in constructor, it uses virtual function calls of driver + return driver; +} + +} +} diff --git a/irr/src/OpenGLES2/Driver.h b/irr/src/OpenGLES2/Driver.h new file mode 100644 index 000000000..003f6d454 --- /dev/null +++ b/irr/src/OpenGLES2/Driver.h @@ -0,0 +1,30 @@ +// Copyright (C) 2023 Vitaliy Lobachevskiy +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#pragma once +#include "OpenGL/Driver.h" + +namespace irr +{ +namespace video +{ + +/// OpenGL ES 2+ driver +/// +/// For OpenGL ES 2.0 and higher. +class COpenGLES2Driver : public COpenGL3DriverBase +{ + friend IVideoDriver *createOGLES2Driver(const SIrrlichtCreationParameters ¶ms, io::IFileSystem *io, IContextManager *contextManager); + +public: + using COpenGL3DriverBase::COpenGL3DriverBase; + E_DRIVER_TYPE getDriverType() const override; + +protected: + OpenGLVersion getVersionFromOpenGL() const override; + void initFeatures() override; +}; + +} +} diff --git a/irr/src/SB3DStructs.h b/irr/src/SB3DStructs.h new file mode 100644 index 000000000..b5e61daae --- /dev/null +++ b/irr/src/SB3DStructs.h @@ -0,0 +1,71 @@ +// Copyright (C) 2006-2012 Luke Hoschke +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +// B3D Mesh loader +// File format designed by Mark Sibly for the Blitz3D engine and has been +// declared public domain + +#pragma once + +#include "SMaterial.h" +#include "irrMath.h" + +namespace irr +{ +namespace scene +{ + +struct SB3dChunkHeader +{ + c8 name[4]; + s32 size; +}; + +struct SB3dChunk +{ + SB3dChunk(const SB3dChunkHeader &header, long sp) : + length(header.size + 8), startposition(sp) + { + length = core::max_(length, 8); + name[0] = header.name[0]; + name[1] = header.name[1]; + name[2] = header.name[2]; + name[3] = header.name[3]; + } + c8 name[4]; + s32 length; + long startposition; +}; + +struct SB3dTexture +{ + std::string TextureName; + s32 Flags; + s32 Blend; + f32 Xpos; + f32 Ypos; + f32 Xscale; + f32 Yscale; + f32 Angle; +}; + +struct SB3dMaterial +{ + SB3dMaterial() : + red(1.0f), green(1.0f), + blue(1.0f), alpha(1.0f), shininess(0.0f), blend(1), + fx(0) + { + for (u32 i = 0; i < video::MATERIAL_MAX_TEXTURES; ++i) + Textures[i] = 0; + } + video::SMaterial Material; + f32 red, green, blue, alpha; + f32 shininess; + s32 blend, fx; + SB3dTexture *Textures[video::MATERIAL_MAX_TEXTURES]; +}; + +} // end namespace scene +} // end namespace irr diff --git a/irr/src/SoftwareDriver2_helper.h b/irr/src/SoftwareDriver2_helper.h new file mode 100644 index 000000000..602f9e295 --- /dev/null +++ b/irr/src/SoftwareDriver2_helper.h @@ -0,0 +1,290 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +/* + History: + - changed behavior for log2 textures ( replaced multiplies by shift ) +*/ + +#pragma once + +#include "irrMath.h" +#include "SMaterial.h" + +#ifndef REALINLINE +#ifdef _MSC_VER +#define REALINLINE __forceinline +#else +#define REALINLINE inline +#endif +#endif + +namespace irr +{ + +// ----------------------- Generic ---------------------------------- +//! align_next - align to next upper 2^n +#define align_next(num, to) (((num) + (to - 1)) & (~(to - 1))) + +//! a more useful memset for pixel. dest must be aligned at least to 4 byte +// (standard memset only works with 8-bit values) +inline void memset32(void *dest, const u32 value, size_t bytesize) +{ + u32 *d = (u32 *)dest; + + size_t i; + + // loops unrolled to reduce the number of increments by factor ~8. + i = bytesize >> (2 + 3); + while (i) { + d[0] = value; + d[1] = value; + d[2] = value; + d[3] = value; + + d[4] = value; + d[5] = value; + d[6] = value; + d[7] = value; + + d += 8; + i -= 1; + } + + i = (bytesize >> 2) & 7; + while (i) { + d[0] = value; + d += 1; + i -= 1; + } +} + +//! a more useful memset for pixel. dest must be aligned at least to 2 byte +// (standard memset only works with 8-bit values) +inline void memset16(void *dest, const u16 value, size_t bytesize) +{ + u16 *d = (u16 *)dest; + + size_t i; + + // loops unrolled to reduce the number of increments by factor ~8. + i = bytesize >> (1 + 3); + while (i) { + d[0] = value; + d[1] = value; + d[2] = value; + d[3] = value; + + d[4] = value; + d[5] = value; + d[6] = value; + d[7] = value; + + d += 8; + --i; + } + + i = (bytesize >> 1) & 7; + while (i) { + d[0] = value; + ++d; + --i; + } +} + +// integer log2 of an integer. returning 0 as denormal +static inline s32 s32_log2_s32(u32 in) +{ + s32 ret = 0; + while (in > 1) { + in >>= 1; + ret++; + } + return ret; +} + +// ------------------ Video--------------------------------------- +/*! + Pixel = dest * ( 1 - alpha ) + source * alpha + alpha [0;256] +*/ +REALINLINE u32 PixelBlend32(const u32 c2, const u32 c1, const u32 alpha) +{ + u32 srcRB = c1 & 0x00FF00FF; + u32 srcXG = c1 & 0x0000FF00; + + u32 dstRB = c2 & 0x00FF00FF; + u32 dstXG = c2 & 0x0000FF00; + + u32 rb = srcRB - dstRB; + u32 xg = srcXG - dstXG; + + rb *= alpha; + xg *= alpha; + rb >>= 8; + xg >>= 8; + + rb += dstRB; + xg += dstXG; + + rb &= 0x00FF00FF; + xg &= 0x0000FF00; + + return rb | xg; +} + +/*! + Pixel = dest * ( 1 - alpha ) + source * alpha + alpha [0;32] +*/ +inline u16 PixelBlend16(const u16 c2, const u16 c1, const u16 alpha) +{ + const u16 srcRB = c1 & 0x7C1F; + const u16 srcXG = c1 & 0x03E0; + + const u16 dstRB = c2 & 0x7C1F; + const u16 dstXG = c2 & 0x03E0; + + u32 rb = srcRB - dstRB; + u32 xg = srcXG - dstXG; + + rb *= alpha; + xg *= alpha; + rb >>= 5; + xg >>= 5; + + rb += dstRB; + xg += dstXG; + + rb &= 0x7C1F; + xg &= 0x03E0; + + return (u16)(rb | xg); +} + +/* + Pixel = c0 * (c1/31). c0 Alpha retain +*/ +inline u16 PixelMul16(const u16 c0, const u16 c1) +{ + return (u16)(((((c0 & 0x7C00) * (c1 & 0x7C00)) & 0x3E000000) >> 15) | + ((((c0 & 0x03E0) * (c1 & 0x03E0)) & 0x000F8000) >> 10) | + ((((c0 & 0x001F) * (c1 & 0x001F)) & 0x000003E0) >> 5) | + (c0 & 0x8000)); +} + +/* + Pixel = c0 * (c1/31). +*/ +inline u16 PixelMul16_2(u16 c0, u16 c1) +{ + return (u16)((((c0 & 0x7C00) * (c1 & 0x7C00)) & 0x3E000000) >> 15 | + (((c0 & 0x03E0) * (c1 & 0x03E0)) & 0x000F8000) >> 10 | + (((c0 & 0x001F) * (c1 & 0x001F)) & 0x000003E0) >> 5 | + (c0 & c1 & 0x8000)); +} + +/* + Pixel = c0 * (c1/255). c0 Alpha Retain +*/ +REALINLINE u32 PixelMul32(const u32 c0, const u32 c1) +{ + return (c0 & 0xFF000000) | + ((((c0 & 0x00FF0000) >> 12) * ((c1 & 0x00FF0000) >> 12)) & 0x00FF0000) | + ((((c0 & 0x0000FF00) * (c1 & 0x0000FF00)) >> 16) & 0x0000FF00) | + ((((c0 & 0x000000FF) * (c1 & 0x000000FF)) >> 8) & 0x000000FF); +} + +/* + Pixel = c0 * (c1/255). +*/ +REALINLINE u32 PixelMul32_2(const u32 c0, const u32 c1) +{ + return ((((c0 & 0xFF000000) >> 16) * ((c1 & 0xFF000000) >> 16)) & 0xFF000000) | + ((((c0 & 0x00FF0000) >> 12) * ((c1 & 0x00FF0000) >> 12)) & 0x00FF0000) | + ((((c0 & 0x0000FF00) * (c1 & 0x0000FF00)) >> 16) & 0x0000FF00) | + ((((c0 & 0x000000FF) * (c1 & 0x000000FF)) >> 8) & 0x000000FF); +} + +/* + Pixel = clamp ( c0 + c1, 0, 255 ) +*/ +REALINLINE u32 PixelAdd32(const u32 c2, const u32 c1) +{ + u32 sum = (c2 & 0x00FFFFFF) + (c1 & 0x00FFFFFF); + u32 low_bits = (c2 ^ c1) & 0x00010101; + s32 carries = (sum - low_bits) & 0x01010100; + u32 modulo = sum - carries; + u32 clamp = carries - (carries >> 8); + return modulo | clamp; +} + +// 1 - Bit Alpha Blending +inline u16 PixelBlend16(const u16 c2, const u16 c1) +{ + u16 mask = ((c1 & 0x8000) >> 15) + 0x7fff; + return (c2 & mask) | (c1 & ~mask); +} +/*! + Pixel = dest * ( 1 - SourceAlpha ) + source * SourceAlpha (OpenGL blending) +*/ +inline u32 PixelBlend32(const u32 c2, const u32 c1) +{ + // alpha test + u32 alpha = c1 & 0xFF000000; + + if (0 == alpha) + return c2; + if (0xFF000000 == alpha) { + return c1; + } + + alpha >>= 24; + + // add highbit alpha, if ( alpha > 127 ) alpha += 1; + alpha += (alpha >> 7); + + u32 srcRB = c1 & 0x00FF00FF; + u32 srcXG = c1 & 0x0000FF00; + + u32 dstRB = c2 & 0x00FF00FF; + u32 dstXG = c2 & 0x0000FF00; + + u32 rb = srcRB - dstRB; + u32 xg = srcXG - dstXG; + + rb *= alpha; + xg *= alpha; + rb >>= 8; + xg >>= 8; + + rb += dstRB; + xg += dstXG; + + rb &= 0x00FF00FF; + xg &= 0x0000FF00; + + return (c1 & 0xFF000000) | rb | xg; +} + +// 2D Region closed [x0;x1] +struct AbsRectangle +{ + s32 x0; + s32 y0; + s32 x1; + s32 y1; +}; + +//! 2D Intersection test +inline bool intersect(AbsRectangle &dest, const AbsRectangle &a, const AbsRectangle &b) +{ + dest.x0 = core::s32_max(a.x0, b.x0); + dest.y0 = core::s32_max(a.y0, b.y0); + dest.x1 = core::s32_min(a.x1, b.x1); + dest.y1 = core::s32_min(a.y1, b.y1); + return dest.x0 < dest.x1 && dest.y0 < dest.y1; +} + +} // end namespace irr diff --git a/irr/src/builtInFont.png b/irr/src/builtInFont.png new file mode 100644 index 000000000..feed4f6f0 Binary files /dev/null and b/irr/src/builtInFont.png differ diff --git a/irr/src/mt_opengl_loader.cpp b/irr/src/mt_opengl_loader.cpp new file mode 100755 index 000000000..084f83118 --- /dev/null +++ b/irr/src/mt_opengl_loader.cpp @@ -0,0 +1,783 @@ +// This code was generated by scripts/BindingGenerator.lua +// Do not modify it, modify and run the generator instead. + +#include "mt_opengl.h" +#include +#include + +OpenGLProcedures GL = OpenGLProcedures(); + +void OpenGLProcedures::LoadAllProcedures(irr::video::IContextManager *cmgr) +{ + + if (!CullFace) CullFace = (PFNGLCULLFACEPROC_MT)cmgr->getProcAddress("glCullFace"); + if (!FrontFace) FrontFace = (PFNGLFRONTFACEPROC_MT)cmgr->getProcAddress("glFrontFace"); + if (!Hint) Hint = (PFNGLHINTPROC_MT)cmgr->getProcAddress("glHint"); + if (!LineWidth) LineWidth = (PFNGLLINEWIDTHPROC_MT)cmgr->getProcAddress("glLineWidth"); + if (!PointSize) PointSize = (PFNGLPOINTSIZEPROC_MT)cmgr->getProcAddress("glPointSize"); + if (!PolygonMode) PolygonMode = (PFNGLPOLYGONMODEPROC_MT)cmgr->getProcAddress("glPolygonMode"); + if (!Scissor) Scissor = (PFNGLSCISSORPROC_MT)cmgr->getProcAddress("glScissor"); + if (!TexParameterf) TexParameterf = (PFNGLTEXPARAMETERFPROC_MT)cmgr->getProcAddress("glTexParameterf"); + if (!TexParameterfv) TexParameterfv = (PFNGLTEXPARAMETERFVPROC_MT)cmgr->getProcAddress("glTexParameterfv"); + if (!TexParameteri) TexParameteri = (PFNGLTEXPARAMETERIPROC_MT)cmgr->getProcAddress("glTexParameteri"); + if (!TexParameteriv) TexParameteriv = (PFNGLTEXPARAMETERIVPROC_MT)cmgr->getProcAddress("glTexParameteriv"); + if (!TexImage1D) TexImage1D = (PFNGLTEXIMAGE1DPROC_MT)cmgr->getProcAddress("glTexImage1D"); + if (!TexImage2D) TexImage2D = (PFNGLTEXIMAGE2DPROC_MT)cmgr->getProcAddress("glTexImage2D"); + if (!DrawBuffer) DrawBuffer = (PFNGLDRAWBUFFERPROC_MT)cmgr->getProcAddress("glDrawBuffer"); + if (!Clear) Clear = (PFNGLCLEARPROC_MT)cmgr->getProcAddress("glClear"); + if (!ClearColor) ClearColor = (PFNGLCLEARCOLORPROC_MT)cmgr->getProcAddress("glClearColor"); + if (!ClearStencil) ClearStencil = (PFNGLCLEARSTENCILPROC_MT)cmgr->getProcAddress("glClearStencil"); + if (!ClearDepth) ClearDepth = (PFNGLCLEARDEPTHPROC_MT)cmgr->getProcAddress("glClearDepth"); + if (!StencilMask) StencilMask = (PFNGLSTENCILMASKPROC_MT)cmgr->getProcAddress("glStencilMask"); + if (!ColorMask) ColorMask = (PFNGLCOLORMASKPROC_MT)cmgr->getProcAddress("glColorMask"); + if (!DepthMask) DepthMask = (PFNGLDEPTHMASKPROC_MT)cmgr->getProcAddress("glDepthMask"); + if (!Disable) Disable = (PFNGLDISABLEPROC_MT)cmgr->getProcAddress("glDisable"); + if (!Enable) Enable = (PFNGLENABLEPROC_MT)cmgr->getProcAddress("glEnable"); + if (!Finish) Finish = (PFNGLFINISHPROC_MT)cmgr->getProcAddress("glFinish"); + if (!Flush) Flush = (PFNGLFLUSHPROC_MT)cmgr->getProcAddress("glFlush"); + if (!BlendFunc) BlendFunc = (PFNGLBLENDFUNCPROC_MT)cmgr->getProcAddress("glBlendFunc"); + if (!LogicOp) LogicOp = (PFNGLLOGICOPPROC_MT)cmgr->getProcAddress("glLogicOp"); + if (!StencilFunc) StencilFunc = (PFNGLSTENCILFUNCPROC_MT)cmgr->getProcAddress("glStencilFunc"); + if (!StencilOp) StencilOp = (PFNGLSTENCILOPPROC_MT)cmgr->getProcAddress("glStencilOp"); + if (!DepthFunc) DepthFunc = (PFNGLDEPTHFUNCPROC_MT)cmgr->getProcAddress("glDepthFunc"); + if (!PixelStoref) PixelStoref = (PFNGLPIXELSTOREFPROC_MT)cmgr->getProcAddress("glPixelStoref"); + if (!PixelStorei) PixelStorei = (PFNGLPIXELSTOREIPROC_MT)cmgr->getProcAddress("glPixelStorei"); + if (!ReadBuffer) ReadBuffer = (PFNGLREADBUFFERPROC_MT)cmgr->getProcAddress("glReadBuffer"); + if (!ReadPixels) ReadPixels = (PFNGLREADPIXELSPROC_MT)cmgr->getProcAddress("glReadPixels"); + if (!GetBooleanv) GetBooleanv = (PFNGLGETBOOLEANVPROC_MT)cmgr->getProcAddress("glGetBooleanv"); + if (!GetDoublev) GetDoublev = (PFNGLGETDOUBLEVPROC_MT)cmgr->getProcAddress("glGetDoublev"); + if (!GetError) GetError = (PFNGLGETERRORPROC_MT)cmgr->getProcAddress("glGetError"); + if (!GetFloatv) GetFloatv = (PFNGLGETFLOATVPROC_MT)cmgr->getProcAddress("glGetFloatv"); + if (!GetIntegerv) GetIntegerv = (PFNGLGETINTEGERVPROC_MT)cmgr->getProcAddress("glGetIntegerv"); + if (!GetString) GetString = (PFNGLGETSTRINGPROC_MT)cmgr->getProcAddress("glGetString"); + if (!GetTexImage) GetTexImage = (PFNGLGETTEXIMAGEPROC_MT)cmgr->getProcAddress("glGetTexImage"); + if (!GetTexParameterfv) GetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC_MT)cmgr->getProcAddress("glGetTexParameterfv"); + if (!GetTexParameteriv) GetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC_MT)cmgr->getProcAddress("glGetTexParameteriv"); + if (!GetTexLevelParameterfv) GetTexLevelParameterfv = (PFNGLGETTEXLEVELPARAMETERFVPROC_MT)cmgr->getProcAddress("glGetTexLevelParameterfv"); + if (!GetTexLevelParameteriv) GetTexLevelParameteriv = (PFNGLGETTEXLEVELPARAMETERIVPROC_MT)cmgr->getProcAddress("glGetTexLevelParameteriv"); + if (!IsEnabled) IsEnabled = (PFNGLISENABLEDPROC_MT)cmgr->getProcAddress("glIsEnabled"); + if (!DepthRange) DepthRange = (PFNGLDEPTHRANGEPROC_MT)cmgr->getProcAddress("glDepthRange"); + if (!Viewport) Viewport = (PFNGLVIEWPORTPROC_MT)cmgr->getProcAddress("glViewport"); + if (!DrawArrays) DrawArrays = (PFNGLDRAWARRAYSPROC_MT)cmgr->getProcAddress("glDrawArrays"); + if (!DrawElements) DrawElements = (PFNGLDRAWELEMENTSPROC_MT)cmgr->getProcAddress("glDrawElements"); + if (!GetPointerv) GetPointerv = (PFNGLGETPOINTERVPROC_MT)cmgr->getProcAddress("glGetPointerv"); + if (!PolygonOffset) PolygonOffset = (PFNGLPOLYGONOFFSETPROC_MT)cmgr->getProcAddress("glPolygonOffset"); + if (!CopyTexImage1D) CopyTexImage1D = (PFNGLCOPYTEXIMAGE1DPROC_MT)cmgr->getProcAddress("glCopyTexImage1D"); + if (!CopyTexImage2D) CopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC_MT)cmgr->getProcAddress("glCopyTexImage2D"); + if (!CopyTexSubImage1D) CopyTexSubImage1D = (PFNGLCOPYTEXSUBIMAGE1DPROC_MT)cmgr->getProcAddress("glCopyTexSubImage1D"); + if (!CopyTexSubImage2D) CopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC_MT)cmgr->getProcAddress("glCopyTexSubImage2D"); + if (!TexSubImage1D) TexSubImage1D = (PFNGLTEXSUBIMAGE1DPROC_MT)cmgr->getProcAddress("glTexSubImage1D"); + if (!TexSubImage2D) TexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC_MT)cmgr->getProcAddress("glTexSubImage2D"); + if (!BindTexture) BindTexture = (PFNGLBINDTEXTUREPROC_MT)cmgr->getProcAddress("glBindTexture"); + if (!DeleteTextures) DeleteTextures = (PFNGLDELETETEXTURESPROC_MT)cmgr->getProcAddress("glDeleteTextures"); + if (!GenTextures) GenTextures = (PFNGLGENTEXTURESPROC_MT)cmgr->getProcAddress("glGenTextures"); + if (!IsTexture) IsTexture = (PFNGLISTEXTUREPROC_MT)cmgr->getProcAddress("glIsTexture"); + if (!DrawRangeElements) DrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC_MT)cmgr->getProcAddress("glDrawRangeElements"); + if (!TexImage3D) TexImage3D = (PFNGLTEXIMAGE3DPROC_MT)cmgr->getProcAddress("glTexImage3D"); + if (!TexSubImage3D) TexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC_MT)cmgr->getProcAddress("glTexSubImage3D"); + if (!CopyTexSubImage3D) CopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC_MT)cmgr->getProcAddress("glCopyTexSubImage3D"); + if (!ActiveTexture) ActiveTexture = (PFNGLACTIVETEXTUREPROC_MT)cmgr->getProcAddress("glActiveTexture"); + if (!SampleCoverage) SampleCoverage = (PFNGLSAMPLECOVERAGEPROC_MT)cmgr->getProcAddress("glSampleCoverage"); + if (!CompressedTexImage3D) CompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC_MT)cmgr->getProcAddress("glCompressedTexImage3D"); + if (!CompressedTexImage2D) CompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC_MT)cmgr->getProcAddress("glCompressedTexImage2D"); + if (!CompressedTexImage1D) CompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC_MT)cmgr->getProcAddress("glCompressedTexImage1D"); + if (!CompressedTexSubImage3D) CompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC_MT)cmgr->getProcAddress("glCompressedTexSubImage3D"); + if (!CompressedTexSubImage2D) CompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC_MT)cmgr->getProcAddress("glCompressedTexSubImage2D"); + if (!CompressedTexSubImage1D) CompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC_MT)cmgr->getProcAddress("glCompressedTexSubImage1D"); + if (!GetCompressedTexImage) GetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC_MT)cmgr->getProcAddress("glGetCompressedTexImage"); + if (!BlendFuncSeparate) BlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC_MT)cmgr->getProcAddress("glBlendFuncSeparate"); + if (!MultiDrawArrays) MultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC_MT)cmgr->getProcAddress("glMultiDrawArrays"); + if (!MultiDrawElements) MultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC_MT)cmgr->getProcAddress("glMultiDrawElements"); + if (!PointParameterf) PointParameterf = (PFNGLPOINTPARAMETERFPROC_MT)cmgr->getProcAddress("glPointParameterf"); + if (!PointParameterfv) PointParameterfv = (PFNGLPOINTPARAMETERFVPROC_MT)cmgr->getProcAddress("glPointParameterfv"); + if (!PointParameteri) PointParameteri = (PFNGLPOINTPARAMETERIPROC_MT)cmgr->getProcAddress("glPointParameteri"); + if (!PointParameteriv) PointParameteriv = (PFNGLPOINTPARAMETERIVPROC_MT)cmgr->getProcAddress("glPointParameteriv"); + if (!BlendColor) BlendColor = (PFNGLBLENDCOLORPROC_MT)cmgr->getProcAddress("glBlendColor"); + if (!BlendEquation) BlendEquation = (PFNGLBLENDEQUATIONPROC_MT)cmgr->getProcAddress("glBlendEquation"); + if (!GenQueries) GenQueries = (PFNGLGENQUERIESPROC_MT)cmgr->getProcAddress("glGenQueries"); + if (!DeleteQueries) DeleteQueries = (PFNGLDELETEQUERIESPROC_MT)cmgr->getProcAddress("glDeleteQueries"); + if (!IsQuery) IsQuery = (PFNGLISQUERYPROC_MT)cmgr->getProcAddress("glIsQuery"); + if (!BeginQuery) BeginQuery = (PFNGLBEGINQUERYPROC_MT)cmgr->getProcAddress("glBeginQuery"); + if (!EndQuery) EndQuery = (PFNGLENDQUERYPROC_MT)cmgr->getProcAddress("glEndQuery"); + if (!GetQueryiv) GetQueryiv = (PFNGLGETQUERYIVPROC_MT)cmgr->getProcAddress("glGetQueryiv"); + if (!GetQueryObjectiv) GetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC_MT)cmgr->getProcAddress("glGetQueryObjectiv"); + if (!GetQueryObjectuiv) GetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC_MT)cmgr->getProcAddress("glGetQueryObjectuiv"); + if (!BindBuffer) BindBuffer = (PFNGLBINDBUFFERPROC_MT)cmgr->getProcAddress("glBindBuffer"); + if (!DeleteBuffers) DeleteBuffers = (PFNGLDELETEBUFFERSPROC_MT)cmgr->getProcAddress("glDeleteBuffers"); + if (!GenBuffers) GenBuffers = (PFNGLGENBUFFERSPROC_MT)cmgr->getProcAddress("glGenBuffers"); + if (!IsBuffer) IsBuffer = (PFNGLISBUFFERPROC_MT)cmgr->getProcAddress("glIsBuffer"); + if (!BufferData) BufferData = (PFNGLBUFFERDATAPROC_MT)cmgr->getProcAddress("glBufferData"); + if (!BufferSubData) BufferSubData = (PFNGLBUFFERSUBDATAPROC_MT)cmgr->getProcAddress("glBufferSubData"); + if (!GetBufferSubData) GetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC_MT)cmgr->getProcAddress("glGetBufferSubData"); + if (!MapBuffer) MapBuffer = (PFNGLMAPBUFFERPROC_MT)cmgr->getProcAddress("glMapBuffer"); + if (!UnmapBuffer) UnmapBuffer = (PFNGLUNMAPBUFFERPROC_MT)cmgr->getProcAddress("glUnmapBuffer"); + if (!GetBufferParameteriv) GetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC_MT)cmgr->getProcAddress("glGetBufferParameteriv"); + if (!GetBufferPointerv) GetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC_MT)cmgr->getProcAddress("glGetBufferPointerv"); + if (!BlendEquationSeparate) BlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC_MT)cmgr->getProcAddress("glBlendEquationSeparate"); + if (!DrawBuffers) DrawBuffers = (PFNGLDRAWBUFFERSPROC_MT)cmgr->getProcAddress("glDrawBuffers"); + if (!StencilOpSeparate) StencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC_MT)cmgr->getProcAddress("glStencilOpSeparate"); + if (!StencilFuncSeparate) StencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC_MT)cmgr->getProcAddress("glStencilFuncSeparate"); + if (!StencilMaskSeparate) StencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC_MT)cmgr->getProcAddress("glStencilMaskSeparate"); + if (!AttachShader) AttachShader = (PFNGLATTACHSHADERPROC_MT)cmgr->getProcAddress("glAttachShader"); + if (!BindAttribLocation) BindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC_MT)cmgr->getProcAddress("glBindAttribLocation"); + if (!CompileShader) CompileShader = (PFNGLCOMPILESHADERPROC_MT)cmgr->getProcAddress("glCompileShader"); + if (!CreateProgram) CreateProgram = (PFNGLCREATEPROGRAMPROC_MT)cmgr->getProcAddress("glCreateProgram"); + if (!CreateShader) CreateShader = (PFNGLCREATESHADERPROC_MT)cmgr->getProcAddress("glCreateShader"); + if (!DeleteProgram) DeleteProgram = (PFNGLDELETEPROGRAMPROC_MT)cmgr->getProcAddress("glDeleteProgram"); + if (!DeleteShader) DeleteShader = (PFNGLDELETESHADERPROC_MT)cmgr->getProcAddress("glDeleteShader"); + if (!DetachShader) DetachShader = (PFNGLDETACHSHADERPROC_MT)cmgr->getProcAddress("glDetachShader"); + if (!DisableVertexAttribArray) DisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC_MT)cmgr->getProcAddress("glDisableVertexAttribArray"); + if (!EnableVertexAttribArray) EnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC_MT)cmgr->getProcAddress("glEnableVertexAttribArray"); + if (!GetActiveAttrib) GetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC_MT)cmgr->getProcAddress("glGetActiveAttrib"); + if (!GetActiveUniform) GetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC_MT)cmgr->getProcAddress("glGetActiveUniform"); + if (!GetAttachedShaders) GetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC_MT)cmgr->getProcAddress("glGetAttachedShaders"); + if (!GetAttribLocation) GetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC_MT)cmgr->getProcAddress("glGetAttribLocation"); + if (!GetProgramiv) GetProgramiv = (PFNGLGETPROGRAMIVPROC_MT)cmgr->getProcAddress("glGetProgramiv"); + if (!GetProgramInfoLog) GetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC_MT)cmgr->getProcAddress("glGetProgramInfoLog"); + if (!GetShaderiv) GetShaderiv = (PFNGLGETSHADERIVPROC_MT)cmgr->getProcAddress("glGetShaderiv"); + if (!GetShaderInfoLog) GetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC_MT)cmgr->getProcAddress("glGetShaderInfoLog"); + if (!GetShaderSource) GetShaderSource = (PFNGLGETSHADERSOURCEPROC_MT)cmgr->getProcAddress("glGetShaderSource"); + if (!GetUniformLocation) GetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC_MT)cmgr->getProcAddress("glGetUniformLocation"); + if (!GetUniformfv) GetUniformfv = (PFNGLGETUNIFORMFVPROC_MT)cmgr->getProcAddress("glGetUniformfv"); + if (!GetUniformiv) GetUniformiv = (PFNGLGETUNIFORMIVPROC_MT)cmgr->getProcAddress("glGetUniformiv"); + if (!GetVertexAttribdv) GetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC_MT)cmgr->getProcAddress("glGetVertexAttribdv"); + if (!GetVertexAttribfv) GetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC_MT)cmgr->getProcAddress("glGetVertexAttribfv"); + if (!GetVertexAttribiv) GetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC_MT)cmgr->getProcAddress("glGetVertexAttribiv"); + if (!GetVertexAttribPointerv) GetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC_MT)cmgr->getProcAddress("glGetVertexAttribPointerv"); + if (!IsProgram) IsProgram = (PFNGLISPROGRAMPROC_MT)cmgr->getProcAddress("glIsProgram"); + if (!IsShader) IsShader = (PFNGLISSHADERPROC_MT)cmgr->getProcAddress("glIsShader"); + if (!LinkProgram) LinkProgram = (PFNGLLINKPROGRAMPROC_MT)cmgr->getProcAddress("glLinkProgram"); + if (!ShaderSource) ShaderSource = (PFNGLSHADERSOURCEPROC_MT)cmgr->getProcAddress("glShaderSource"); + if (!UseProgram) UseProgram = (PFNGLUSEPROGRAMPROC_MT)cmgr->getProcAddress("glUseProgram"); + if (!Uniform1f) Uniform1f = (PFNGLUNIFORM1FPROC_MT)cmgr->getProcAddress("glUniform1f"); + if (!Uniform2f) Uniform2f = (PFNGLUNIFORM2FPROC_MT)cmgr->getProcAddress("glUniform2f"); + if (!Uniform3f) Uniform3f = (PFNGLUNIFORM3FPROC_MT)cmgr->getProcAddress("glUniform3f"); + if (!Uniform4f) Uniform4f = (PFNGLUNIFORM4FPROC_MT)cmgr->getProcAddress("glUniform4f"); + if (!Uniform1i) Uniform1i = (PFNGLUNIFORM1IPROC_MT)cmgr->getProcAddress("glUniform1i"); + if (!Uniform2i) Uniform2i = (PFNGLUNIFORM2IPROC_MT)cmgr->getProcAddress("glUniform2i"); + if (!Uniform3i) Uniform3i = (PFNGLUNIFORM3IPROC_MT)cmgr->getProcAddress("glUniform3i"); + if (!Uniform4i) Uniform4i = (PFNGLUNIFORM4IPROC_MT)cmgr->getProcAddress("glUniform4i"); + if (!Uniform1fv) Uniform1fv = (PFNGLUNIFORM1FVPROC_MT)cmgr->getProcAddress("glUniform1fv"); + if (!Uniform2fv) Uniform2fv = (PFNGLUNIFORM2FVPROC_MT)cmgr->getProcAddress("glUniform2fv"); + if (!Uniform3fv) Uniform3fv = (PFNGLUNIFORM3FVPROC_MT)cmgr->getProcAddress("glUniform3fv"); + if (!Uniform4fv) Uniform4fv = (PFNGLUNIFORM4FVPROC_MT)cmgr->getProcAddress("glUniform4fv"); + if (!Uniform1iv) Uniform1iv = (PFNGLUNIFORM1IVPROC_MT)cmgr->getProcAddress("glUniform1iv"); + if (!Uniform2iv) Uniform2iv = (PFNGLUNIFORM2IVPROC_MT)cmgr->getProcAddress("glUniform2iv"); + if (!Uniform3iv) Uniform3iv = (PFNGLUNIFORM3IVPROC_MT)cmgr->getProcAddress("glUniform3iv"); + if (!Uniform4iv) Uniform4iv = (PFNGLUNIFORM4IVPROC_MT)cmgr->getProcAddress("glUniform4iv"); + if (!UniformMatrix2fv) UniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC_MT)cmgr->getProcAddress("glUniformMatrix2fv"); + if (!UniformMatrix3fv) UniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC_MT)cmgr->getProcAddress("glUniformMatrix3fv"); + if (!UniformMatrix4fv) UniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC_MT)cmgr->getProcAddress("glUniformMatrix4fv"); + if (!ValidateProgram) ValidateProgram = (PFNGLVALIDATEPROGRAMPROC_MT)cmgr->getProcAddress("glValidateProgram"); + if (!VertexAttrib1d) VertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC_MT)cmgr->getProcAddress("glVertexAttrib1d"); + if (!VertexAttrib1dv) VertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC_MT)cmgr->getProcAddress("glVertexAttrib1dv"); + if (!VertexAttrib1f) VertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC_MT)cmgr->getProcAddress("glVertexAttrib1f"); + if (!VertexAttrib1fv) VertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC_MT)cmgr->getProcAddress("glVertexAttrib1fv"); + if (!VertexAttrib1s) VertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC_MT)cmgr->getProcAddress("glVertexAttrib1s"); + if (!VertexAttrib1sv) VertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC_MT)cmgr->getProcAddress("glVertexAttrib1sv"); + if (!VertexAttrib2d) VertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC_MT)cmgr->getProcAddress("glVertexAttrib2d"); + if (!VertexAttrib2dv) VertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC_MT)cmgr->getProcAddress("glVertexAttrib2dv"); + if (!VertexAttrib2f) VertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC_MT)cmgr->getProcAddress("glVertexAttrib2f"); + if (!VertexAttrib2fv) VertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC_MT)cmgr->getProcAddress("glVertexAttrib2fv"); + if (!VertexAttrib2s) VertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC_MT)cmgr->getProcAddress("glVertexAttrib2s"); + if (!VertexAttrib2sv) VertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC_MT)cmgr->getProcAddress("glVertexAttrib2sv"); + if (!VertexAttrib3d) VertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC_MT)cmgr->getProcAddress("glVertexAttrib3d"); + if (!VertexAttrib3dv) VertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC_MT)cmgr->getProcAddress("glVertexAttrib3dv"); + if (!VertexAttrib3f) VertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC_MT)cmgr->getProcAddress("glVertexAttrib3f"); + if (!VertexAttrib3fv) VertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC_MT)cmgr->getProcAddress("glVertexAttrib3fv"); + if (!VertexAttrib3s) VertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC_MT)cmgr->getProcAddress("glVertexAttrib3s"); + if (!VertexAttrib3sv) VertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC_MT)cmgr->getProcAddress("glVertexAttrib3sv"); + if (!VertexAttrib4Nbv) VertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC_MT)cmgr->getProcAddress("glVertexAttrib4Nbv"); + if (!VertexAttrib4Niv) VertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC_MT)cmgr->getProcAddress("glVertexAttrib4Niv"); + if (!VertexAttrib4Nsv) VertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC_MT)cmgr->getProcAddress("glVertexAttrib4Nsv"); + if (!VertexAttrib4Nub) VertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC_MT)cmgr->getProcAddress("glVertexAttrib4Nub"); + if (!VertexAttrib4Nubv) VertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC_MT)cmgr->getProcAddress("glVertexAttrib4Nubv"); + if (!VertexAttrib4Nuiv) VertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC_MT)cmgr->getProcAddress("glVertexAttrib4Nuiv"); + if (!VertexAttrib4Nusv) VertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC_MT)cmgr->getProcAddress("glVertexAttrib4Nusv"); + if (!VertexAttrib4bv) VertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC_MT)cmgr->getProcAddress("glVertexAttrib4bv"); + if (!VertexAttrib4d) VertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC_MT)cmgr->getProcAddress("glVertexAttrib4d"); + if (!VertexAttrib4dv) VertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC_MT)cmgr->getProcAddress("glVertexAttrib4dv"); + if (!VertexAttrib4f) VertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC_MT)cmgr->getProcAddress("glVertexAttrib4f"); + if (!VertexAttrib4fv) VertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC_MT)cmgr->getProcAddress("glVertexAttrib4fv"); + if (!VertexAttrib4iv) VertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC_MT)cmgr->getProcAddress("glVertexAttrib4iv"); + if (!VertexAttrib4s) VertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC_MT)cmgr->getProcAddress("glVertexAttrib4s"); + if (!VertexAttrib4sv) VertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC_MT)cmgr->getProcAddress("glVertexAttrib4sv"); + if (!VertexAttrib4ubv) VertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC_MT)cmgr->getProcAddress("glVertexAttrib4ubv"); + if (!VertexAttrib4uiv) VertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC_MT)cmgr->getProcAddress("glVertexAttrib4uiv"); + if (!VertexAttrib4usv) VertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC_MT)cmgr->getProcAddress("glVertexAttrib4usv"); + if (!VertexAttribPointer) VertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC_MT)cmgr->getProcAddress("glVertexAttribPointer"); + if (!UniformMatrix2x3fv) UniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC_MT)cmgr->getProcAddress("glUniformMatrix2x3fv"); + if (!UniformMatrix3x2fv) UniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC_MT)cmgr->getProcAddress("glUniformMatrix3x2fv"); + if (!UniformMatrix2x4fv) UniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC_MT)cmgr->getProcAddress("glUniformMatrix2x4fv"); + if (!UniformMatrix4x2fv) UniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC_MT)cmgr->getProcAddress("glUniformMatrix4x2fv"); + if (!UniformMatrix3x4fv) UniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC_MT)cmgr->getProcAddress("glUniformMatrix3x4fv"); + if (!UniformMatrix4x3fv) UniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC_MT)cmgr->getProcAddress("glUniformMatrix4x3fv"); + if (!ColorMaski) ColorMaski = (PFNGLCOLORMASKIPROC_MT)cmgr->getProcAddress("glColorMaski"); + if (!Enablei) Enablei = (PFNGLENABLEIPROC_MT)cmgr->getProcAddress("glEnablei"); + if (!Disablei) Disablei = (PFNGLDISABLEIPROC_MT)cmgr->getProcAddress("glDisablei"); + if (!IsEnabledi) IsEnabledi = (PFNGLISENABLEDIPROC_MT)cmgr->getProcAddress("glIsEnabledi"); + if (!BeginTransformFeedback) BeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC_MT)cmgr->getProcAddress("glBeginTransformFeedback"); + if (!EndTransformFeedback) EndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC_MT)cmgr->getProcAddress("glEndTransformFeedback"); + if (!BindBufferRange) BindBufferRange = (PFNGLBINDBUFFERRANGEPROC_MT)cmgr->getProcAddress("glBindBufferRange"); + if (!BindBufferBase) BindBufferBase = (PFNGLBINDBUFFERBASEPROC_MT)cmgr->getProcAddress("glBindBufferBase"); + if (!TransformFeedbackVaryings) TransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC_MT)cmgr->getProcAddress("glTransformFeedbackVaryings"); + if (!GetTransformFeedbackVarying) GetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC_MT)cmgr->getProcAddress("glGetTransformFeedbackVarying"); + if (!ClampColor) ClampColor = (PFNGLCLAMPCOLORPROC_MT)cmgr->getProcAddress("glClampColor"); + if (!BeginConditionalRender) BeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC_MT)cmgr->getProcAddress("glBeginConditionalRender"); + if (!EndConditionalRender) EndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC_MT)cmgr->getProcAddress("glEndConditionalRender"); + if (!VertexAttribIPointer) VertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC_MT)cmgr->getProcAddress("glVertexAttribIPointer"); + if (!GetVertexAttribIiv) GetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC_MT)cmgr->getProcAddress("glGetVertexAttribIiv"); + if (!GetVertexAttribIuiv) GetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC_MT)cmgr->getProcAddress("glGetVertexAttribIuiv"); + if (!VertexAttribI1i) VertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC_MT)cmgr->getProcAddress("glVertexAttribI1i"); + if (!VertexAttribI2i) VertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC_MT)cmgr->getProcAddress("glVertexAttribI2i"); + if (!VertexAttribI3i) VertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC_MT)cmgr->getProcAddress("glVertexAttribI3i"); + if (!VertexAttribI4i) VertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC_MT)cmgr->getProcAddress("glVertexAttribI4i"); + if (!VertexAttribI1ui) VertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC_MT)cmgr->getProcAddress("glVertexAttribI1ui"); + if (!VertexAttribI2ui) VertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC_MT)cmgr->getProcAddress("glVertexAttribI2ui"); + if (!VertexAttribI3ui) VertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC_MT)cmgr->getProcAddress("glVertexAttribI3ui"); + if (!VertexAttribI4ui) VertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC_MT)cmgr->getProcAddress("glVertexAttribI4ui"); + if (!VertexAttribI1iv) VertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC_MT)cmgr->getProcAddress("glVertexAttribI1iv"); + if (!VertexAttribI2iv) VertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC_MT)cmgr->getProcAddress("glVertexAttribI2iv"); + if (!VertexAttribI3iv) VertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC_MT)cmgr->getProcAddress("glVertexAttribI3iv"); + if (!VertexAttribI4iv) VertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC_MT)cmgr->getProcAddress("glVertexAttribI4iv"); + if (!VertexAttribI1uiv) VertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC_MT)cmgr->getProcAddress("glVertexAttribI1uiv"); + if (!VertexAttribI2uiv) VertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC_MT)cmgr->getProcAddress("glVertexAttribI2uiv"); + if (!VertexAttribI3uiv) VertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC_MT)cmgr->getProcAddress("glVertexAttribI3uiv"); + if (!VertexAttribI4uiv) VertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC_MT)cmgr->getProcAddress("glVertexAttribI4uiv"); + if (!VertexAttribI4bv) VertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC_MT)cmgr->getProcAddress("glVertexAttribI4bv"); + if (!VertexAttribI4sv) VertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC_MT)cmgr->getProcAddress("glVertexAttribI4sv"); + if (!VertexAttribI4ubv) VertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC_MT)cmgr->getProcAddress("glVertexAttribI4ubv"); + if (!VertexAttribI4usv) VertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC_MT)cmgr->getProcAddress("glVertexAttribI4usv"); + if (!GetUniformuiv) GetUniformuiv = (PFNGLGETUNIFORMUIVPROC_MT)cmgr->getProcAddress("glGetUniformuiv"); + if (!BindFragDataLocation) BindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC_MT)cmgr->getProcAddress("glBindFragDataLocation"); + if (!GetFragDataLocation) GetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC_MT)cmgr->getProcAddress("glGetFragDataLocation"); + if (!Uniform1ui) Uniform1ui = (PFNGLUNIFORM1UIPROC_MT)cmgr->getProcAddress("glUniform1ui"); + if (!Uniform2ui) Uniform2ui = (PFNGLUNIFORM2UIPROC_MT)cmgr->getProcAddress("glUniform2ui"); + if (!Uniform3ui) Uniform3ui = (PFNGLUNIFORM3UIPROC_MT)cmgr->getProcAddress("glUniform3ui"); + if (!Uniform4ui) Uniform4ui = (PFNGLUNIFORM4UIPROC_MT)cmgr->getProcAddress("glUniform4ui"); + if (!Uniform1uiv) Uniform1uiv = (PFNGLUNIFORM1UIVPROC_MT)cmgr->getProcAddress("glUniform1uiv"); + if (!Uniform2uiv) Uniform2uiv = (PFNGLUNIFORM2UIVPROC_MT)cmgr->getProcAddress("glUniform2uiv"); + if (!Uniform3uiv) Uniform3uiv = (PFNGLUNIFORM3UIVPROC_MT)cmgr->getProcAddress("glUniform3uiv"); + if (!Uniform4uiv) Uniform4uiv = (PFNGLUNIFORM4UIVPROC_MT)cmgr->getProcAddress("glUniform4uiv"); + if (!TexParameterIiv) TexParameterIiv = (PFNGLTEXPARAMETERIIVPROC_MT)cmgr->getProcAddress("glTexParameterIiv"); + if (!TexParameterIuiv) TexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC_MT)cmgr->getProcAddress("glTexParameterIuiv"); + if (!GetTexParameterIiv) GetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC_MT)cmgr->getProcAddress("glGetTexParameterIiv"); + if (!GetTexParameterIuiv) GetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC_MT)cmgr->getProcAddress("glGetTexParameterIuiv"); + if (!ClearBufferiv) ClearBufferiv = (PFNGLCLEARBUFFERIVPROC_MT)cmgr->getProcAddress("glClearBufferiv"); + if (!ClearBufferuiv) ClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC_MT)cmgr->getProcAddress("glClearBufferuiv"); + if (!ClearBufferfv) ClearBufferfv = (PFNGLCLEARBUFFERFVPROC_MT)cmgr->getProcAddress("glClearBufferfv"); + if (!ClearBufferfi) ClearBufferfi = (PFNGLCLEARBUFFERFIPROC_MT)cmgr->getProcAddress("glClearBufferfi"); + if (!GetStringi) GetStringi = (PFNGLGETSTRINGIPROC_MT)cmgr->getProcAddress("glGetStringi"); + if (!IsRenderbuffer) IsRenderbuffer = (PFNGLISRENDERBUFFERPROC_MT)cmgr->getProcAddress("glIsRenderbuffer"); + if (!BindRenderbuffer) BindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC_MT)cmgr->getProcAddress("glBindRenderbuffer"); + if (!DeleteRenderbuffers) DeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC_MT)cmgr->getProcAddress("glDeleteRenderbuffers"); + if (!GenRenderbuffers) GenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC_MT)cmgr->getProcAddress("glGenRenderbuffers"); + if (!RenderbufferStorage) RenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC_MT)cmgr->getProcAddress("glRenderbufferStorage"); + if (!GetRenderbufferParameteriv) GetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC_MT)cmgr->getProcAddress("glGetRenderbufferParameteriv"); + if (!IsFramebuffer) IsFramebuffer = (PFNGLISFRAMEBUFFERPROC_MT)cmgr->getProcAddress("glIsFramebuffer"); + if (!BindFramebuffer) BindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC_MT)cmgr->getProcAddress("glBindFramebuffer"); + if (!DeleteFramebuffers) DeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC_MT)cmgr->getProcAddress("glDeleteFramebuffers"); + if (!GenFramebuffers) GenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC_MT)cmgr->getProcAddress("glGenFramebuffers"); + if (!CheckFramebufferStatus) CheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC_MT)cmgr->getProcAddress("glCheckFramebufferStatus"); + if (!FramebufferTexture1D) FramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC_MT)cmgr->getProcAddress("glFramebufferTexture1D"); + if (!FramebufferTexture2D) FramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC_MT)cmgr->getProcAddress("glFramebufferTexture2D"); + if (!FramebufferTexture3D) FramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC_MT)cmgr->getProcAddress("glFramebufferTexture3D"); + if (!FramebufferRenderbuffer) FramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC_MT)cmgr->getProcAddress("glFramebufferRenderbuffer"); + if (!GetFramebufferAttachmentParameteriv) GetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC_MT)cmgr->getProcAddress("glGetFramebufferAttachmentParameteriv"); + if (!GenerateMipmap) GenerateMipmap = (PFNGLGENERATEMIPMAPPROC_MT)cmgr->getProcAddress("glGenerateMipmap"); + if (!BlitFramebuffer) BlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC_MT)cmgr->getProcAddress("glBlitFramebuffer"); + if (!RenderbufferStorageMultisample) RenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC_MT)cmgr->getProcAddress("glRenderbufferStorageMultisample"); + if (!FramebufferTextureLayer) FramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC_MT)cmgr->getProcAddress("glFramebufferTextureLayer"); + if (!FramebufferTextureLayer) FramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC_MT)cmgr->getProcAddress("glFramebufferTextureLayerARB"); + if (!MapBufferRange) MapBufferRange = (PFNGLMAPBUFFERRANGEPROC_MT)cmgr->getProcAddress("glMapBufferRange"); + if (!FlushMappedBufferRange) FlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC_MT)cmgr->getProcAddress("glFlushMappedBufferRange"); + if (!BindVertexArray) BindVertexArray = (PFNGLBINDVERTEXARRAYPROC_MT)cmgr->getProcAddress("glBindVertexArray"); + if (!DeleteVertexArrays) DeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC_MT)cmgr->getProcAddress("glDeleteVertexArrays"); + if (!GenVertexArrays) GenVertexArrays = (PFNGLGENVERTEXARRAYSPROC_MT)cmgr->getProcAddress("glGenVertexArrays"); + if (!IsVertexArray) IsVertexArray = (PFNGLISVERTEXARRAYPROC_MT)cmgr->getProcAddress("glIsVertexArray"); + if (!DrawArraysInstanced) DrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC_MT)cmgr->getProcAddress("glDrawArraysInstanced"); + if (!DrawArraysInstanced) DrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC_MT)cmgr->getProcAddress("glDrawArraysInstancedARB"); + if (!DrawElementsInstanced) DrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC_MT)cmgr->getProcAddress("glDrawElementsInstanced"); + if (!DrawElementsInstanced) DrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC_MT)cmgr->getProcAddress("glDrawElementsInstancedARB"); + if (!TexBuffer) TexBuffer = (PFNGLTEXBUFFERPROC_MT)cmgr->getProcAddress("glTexBuffer"); + if (!TexBuffer) TexBuffer = (PFNGLTEXBUFFERPROC_MT)cmgr->getProcAddress("glTexBufferARB"); + if (!PrimitiveRestartIndex) PrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC_MT)cmgr->getProcAddress("glPrimitiveRestartIndex"); + if (!CopyBufferSubData) CopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC_MT)cmgr->getProcAddress("glCopyBufferSubData"); + if (!GetUniformIndices) GetUniformIndices = (PFNGLGETUNIFORMINDICESPROC_MT)cmgr->getProcAddress("glGetUniformIndices"); + if (!GetActiveUniformsiv) GetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC_MT)cmgr->getProcAddress("glGetActiveUniformsiv"); + if (!GetActiveUniformName) GetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC_MT)cmgr->getProcAddress("glGetActiveUniformName"); + if (!GetUniformBlockIndex) GetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC_MT)cmgr->getProcAddress("glGetUniformBlockIndex"); + if (!GetActiveUniformBlockiv) GetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC_MT)cmgr->getProcAddress("glGetActiveUniformBlockiv"); + if (!GetActiveUniformBlockName) GetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC_MT)cmgr->getProcAddress("glGetActiveUniformBlockName"); + if (!UniformBlockBinding) UniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC_MT)cmgr->getProcAddress("glUniformBlockBinding"); + if (!DrawElementsBaseVertex) DrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC_MT)cmgr->getProcAddress("glDrawElementsBaseVertex"); + if (!DrawRangeElementsBaseVertex) DrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC_MT)cmgr->getProcAddress("glDrawRangeElementsBaseVertex"); + if (!DrawElementsInstancedBaseVertex) DrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC_MT)cmgr->getProcAddress("glDrawElementsInstancedBaseVertex"); + if (!MultiDrawElementsBaseVertex) MultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC_MT)cmgr->getProcAddress("glMultiDrawElementsBaseVertex"); + if (!ProvokingVertex) ProvokingVertex = (PFNGLPROVOKINGVERTEXPROC_MT)cmgr->getProcAddress("glProvokingVertex"); + if (!FenceSync) FenceSync = (PFNGLFENCESYNCPROC_MT)cmgr->getProcAddress("glFenceSync"); + if (!IsSync) IsSync = (PFNGLISSYNCPROC_MT)cmgr->getProcAddress("glIsSync"); + if (!DeleteSync) DeleteSync = (PFNGLDELETESYNCPROC_MT)cmgr->getProcAddress("glDeleteSync"); + if (!ClientWaitSync) ClientWaitSync = (PFNGLCLIENTWAITSYNCPROC_MT)cmgr->getProcAddress("glClientWaitSync"); + if (!WaitSync) WaitSync = (PFNGLWAITSYNCPROC_MT)cmgr->getProcAddress("glWaitSync"); + if (!GetInteger64v) GetInteger64v = (PFNGLGETINTEGER64VPROC_MT)cmgr->getProcAddress("glGetInteger64v"); + if (!GetSynciv) GetSynciv = (PFNGLGETSYNCIVPROC_MT)cmgr->getProcAddress("glGetSynciv"); + if (!GetBufferParameteri64v) GetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC_MT)cmgr->getProcAddress("glGetBufferParameteri64v"); + if (!FramebufferTexture) FramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC_MT)cmgr->getProcAddress("glFramebufferTexture"); + if (!FramebufferTexture) FramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC_MT)cmgr->getProcAddress("glFramebufferTextureARB"); + if (!TexImage2DMultisample) TexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC_MT)cmgr->getProcAddress("glTexImage2DMultisample"); + if (!TexImage3DMultisample) TexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC_MT)cmgr->getProcAddress("glTexImage3DMultisample"); + if (!GetMultisamplefv) GetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC_MT)cmgr->getProcAddress("glGetMultisamplefv"); + if (!SampleMaski) SampleMaski = (PFNGLSAMPLEMASKIPROC_MT)cmgr->getProcAddress("glSampleMaski"); + if (!BindFragDataLocationIndexed) BindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC_MT)cmgr->getProcAddress("glBindFragDataLocationIndexed"); + if (!GetFragDataIndex) GetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC_MT)cmgr->getProcAddress("glGetFragDataIndex"); + if (!GenSamplers) GenSamplers = (PFNGLGENSAMPLERSPROC_MT)cmgr->getProcAddress("glGenSamplers"); + if (!DeleteSamplers) DeleteSamplers = (PFNGLDELETESAMPLERSPROC_MT)cmgr->getProcAddress("glDeleteSamplers"); + if (!IsSampler) IsSampler = (PFNGLISSAMPLERPROC_MT)cmgr->getProcAddress("glIsSampler"); + if (!BindSampler) BindSampler = (PFNGLBINDSAMPLERPROC_MT)cmgr->getProcAddress("glBindSampler"); + if (!SamplerParameteri) SamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC_MT)cmgr->getProcAddress("glSamplerParameteri"); + if (!SamplerParameteriv) SamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC_MT)cmgr->getProcAddress("glSamplerParameteriv"); + if (!SamplerParameterf) SamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC_MT)cmgr->getProcAddress("glSamplerParameterf"); + if (!SamplerParameterfv) SamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC_MT)cmgr->getProcAddress("glSamplerParameterfv"); + if (!SamplerParameterIiv) SamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIVPROC_MT)cmgr->getProcAddress("glSamplerParameterIiv"); + if (!SamplerParameterIuiv) SamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIVPROC_MT)cmgr->getProcAddress("glSamplerParameterIuiv"); + if (!GetSamplerParameteriv) GetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIVPROC_MT)cmgr->getProcAddress("glGetSamplerParameteriv"); + if (!GetSamplerParameterIiv) GetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIVPROC_MT)cmgr->getProcAddress("glGetSamplerParameterIiv"); + if (!GetSamplerParameterfv) GetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFVPROC_MT)cmgr->getProcAddress("glGetSamplerParameterfv"); + if (!GetSamplerParameterIuiv) GetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIVPROC_MT)cmgr->getProcAddress("glGetSamplerParameterIuiv"); + if (!QueryCounter) QueryCounter = (PFNGLQUERYCOUNTERPROC_MT)cmgr->getProcAddress("glQueryCounter"); + if (!GetQueryObjecti64v) GetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC_MT)cmgr->getProcAddress("glGetQueryObjecti64v"); + if (!GetQueryObjectui64v) GetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC_MT)cmgr->getProcAddress("glGetQueryObjectui64v"); + if (!VertexAttribDivisor) VertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC_MT)cmgr->getProcAddress("glVertexAttribDivisor"); + if (!VertexAttribDivisor) VertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC_MT)cmgr->getProcAddress("glVertexAttribDivisorARB"); + if (!VertexAttribP1ui) VertexAttribP1ui = (PFNGLVERTEXATTRIBP1UIPROC_MT)cmgr->getProcAddress("glVertexAttribP1ui"); + if (!VertexAttribP1uiv) VertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIVPROC_MT)cmgr->getProcAddress("glVertexAttribP1uiv"); + if (!VertexAttribP2ui) VertexAttribP2ui = (PFNGLVERTEXATTRIBP2UIPROC_MT)cmgr->getProcAddress("glVertexAttribP2ui"); + if (!VertexAttribP2uiv) VertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIVPROC_MT)cmgr->getProcAddress("glVertexAttribP2uiv"); + if (!VertexAttribP3ui) VertexAttribP3ui = (PFNGLVERTEXATTRIBP3UIPROC_MT)cmgr->getProcAddress("glVertexAttribP3ui"); + if (!VertexAttribP3uiv) VertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIVPROC_MT)cmgr->getProcAddress("glVertexAttribP3uiv"); + if (!VertexAttribP4ui) VertexAttribP4ui = (PFNGLVERTEXATTRIBP4UIPROC_MT)cmgr->getProcAddress("glVertexAttribP4ui"); + if (!VertexAttribP4uiv) VertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIVPROC_MT)cmgr->getProcAddress("glVertexAttribP4uiv"); + if (!MinSampleShading) MinSampleShading = (PFNGLMINSAMPLESHADINGPROC_MT)cmgr->getProcAddress("glMinSampleShading"); + if (!MinSampleShading) MinSampleShading = (PFNGLMINSAMPLESHADINGPROC_MT)cmgr->getProcAddress("glMinSampleShadingARB"); + if (!BlendEquationi) BlendEquationi = (PFNGLBLENDEQUATIONIPROC_MT)cmgr->getProcAddress("glBlendEquationi"); + if (!BlendEquationi) BlendEquationi = (PFNGLBLENDEQUATIONIPROC_MT)cmgr->getProcAddress("glBlendEquationiARB"); + if (!BlendEquationSeparatei) BlendEquationSeparatei = (PFNGLBLENDEQUATIONSEPARATEIPROC_MT)cmgr->getProcAddress("glBlendEquationSeparatei"); + if (!BlendEquationSeparatei) BlendEquationSeparatei = (PFNGLBLENDEQUATIONSEPARATEIPROC_MT)cmgr->getProcAddress("glBlendEquationSeparateiARB"); + if (!BlendFunci) BlendFunci = (PFNGLBLENDFUNCIPROC_MT)cmgr->getProcAddress("glBlendFunci"); + if (!BlendFunci) BlendFunci = (PFNGLBLENDFUNCIPROC_MT)cmgr->getProcAddress("glBlendFunciARB"); + if (!BlendFuncSeparatei) BlendFuncSeparatei = (PFNGLBLENDFUNCSEPARATEIPROC_MT)cmgr->getProcAddress("glBlendFuncSeparatei"); + if (!BlendFuncSeparatei) BlendFuncSeparatei = (PFNGLBLENDFUNCSEPARATEIPROC_MT)cmgr->getProcAddress("glBlendFuncSeparateiARB"); + if (!DrawArraysIndirect) DrawArraysIndirect = (PFNGLDRAWARRAYSINDIRECTPROC_MT)cmgr->getProcAddress("glDrawArraysIndirect"); + if (!DrawElementsIndirect) DrawElementsIndirect = (PFNGLDRAWELEMENTSINDIRECTPROC_MT)cmgr->getProcAddress("glDrawElementsIndirect"); + if (!Uniform1d) Uniform1d = (PFNGLUNIFORM1DPROC_MT)cmgr->getProcAddress("glUniform1d"); + if (!Uniform2d) Uniform2d = (PFNGLUNIFORM2DPROC_MT)cmgr->getProcAddress("glUniform2d"); + if (!Uniform3d) Uniform3d = (PFNGLUNIFORM3DPROC_MT)cmgr->getProcAddress("glUniform3d"); + if (!Uniform4d) Uniform4d = (PFNGLUNIFORM4DPROC_MT)cmgr->getProcAddress("glUniform4d"); + if (!Uniform1dv) Uniform1dv = (PFNGLUNIFORM1DVPROC_MT)cmgr->getProcAddress("glUniform1dv"); + if (!Uniform2dv) Uniform2dv = (PFNGLUNIFORM2DVPROC_MT)cmgr->getProcAddress("glUniform2dv"); + if (!Uniform3dv) Uniform3dv = (PFNGLUNIFORM3DVPROC_MT)cmgr->getProcAddress("glUniform3dv"); + if (!Uniform4dv) Uniform4dv = (PFNGLUNIFORM4DVPROC_MT)cmgr->getProcAddress("glUniform4dv"); + if (!UniformMatrix2dv) UniformMatrix2dv = (PFNGLUNIFORMMATRIX2DVPROC_MT)cmgr->getProcAddress("glUniformMatrix2dv"); + if (!UniformMatrix3dv) UniformMatrix3dv = (PFNGLUNIFORMMATRIX3DVPROC_MT)cmgr->getProcAddress("glUniformMatrix3dv"); + if (!UniformMatrix4dv) UniformMatrix4dv = (PFNGLUNIFORMMATRIX4DVPROC_MT)cmgr->getProcAddress("glUniformMatrix4dv"); + if (!UniformMatrix2x3dv) UniformMatrix2x3dv = (PFNGLUNIFORMMATRIX2X3DVPROC_MT)cmgr->getProcAddress("glUniformMatrix2x3dv"); + if (!UniformMatrix2x4dv) UniformMatrix2x4dv = (PFNGLUNIFORMMATRIX2X4DVPROC_MT)cmgr->getProcAddress("glUniformMatrix2x4dv"); + if (!UniformMatrix3x2dv) UniformMatrix3x2dv = (PFNGLUNIFORMMATRIX3X2DVPROC_MT)cmgr->getProcAddress("glUniformMatrix3x2dv"); + if (!UniformMatrix3x4dv) UniformMatrix3x4dv = (PFNGLUNIFORMMATRIX3X4DVPROC_MT)cmgr->getProcAddress("glUniformMatrix3x4dv"); + if (!UniformMatrix4x2dv) UniformMatrix4x2dv = (PFNGLUNIFORMMATRIX4X2DVPROC_MT)cmgr->getProcAddress("glUniformMatrix4x2dv"); + if (!UniformMatrix4x3dv) UniformMatrix4x3dv = (PFNGLUNIFORMMATRIX4X3DVPROC_MT)cmgr->getProcAddress("glUniformMatrix4x3dv"); + if (!GetUniformdv) GetUniformdv = (PFNGLGETUNIFORMDVPROC_MT)cmgr->getProcAddress("glGetUniformdv"); + if (!GetSubroutineUniformLocation) GetSubroutineUniformLocation = (PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC_MT)cmgr->getProcAddress("glGetSubroutineUniformLocation"); + if (!GetSubroutineIndex) GetSubroutineIndex = (PFNGLGETSUBROUTINEINDEXPROC_MT)cmgr->getProcAddress("glGetSubroutineIndex"); + if (!GetActiveSubroutineUniformiv) GetActiveSubroutineUniformiv = (PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC_MT)cmgr->getProcAddress("glGetActiveSubroutineUniformiv"); + if (!GetActiveSubroutineUniformName) GetActiveSubroutineUniformName = (PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC_MT)cmgr->getProcAddress("glGetActiveSubroutineUniformName"); + if (!GetActiveSubroutineName) GetActiveSubroutineName = (PFNGLGETACTIVESUBROUTINENAMEPROC_MT)cmgr->getProcAddress("glGetActiveSubroutineName"); + if (!UniformSubroutinesuiv) UniformSubroutinesuiv = (PFNGLUNIFORMSUBROUTINESUIVPROC_MT)cmgr->getProcAddress("glUniformSubroutinesuiv"); + if (!GetUniformSubroutineuiv) GetUniformSubroutineuiv = (PFNGLGETUNIFORMSUBROUTINEUIVPROC_MT)cmgr->getProcAddress("glGetUniformSubroutineuiv"); + if (!GetProgramStageiv) GetProgramStageiv = (PFNGLGETPROGRAMSTAGEIVPROC_MT)cmgr->getProcAddress("glGetProgramStageiv"); + if (!PatchParameteri) PatchParameteri = (PFNGLPATCHPARAMETERIPROC_MT)cmgr->getProcAddress("glPatchParameteri"); + if (!PatchParameterfv) PatchParameterfv = (PFNGLPATCHPARAMETERFVPROC_MT)cmgr->getProcAddress("glPatchParameterfv"); + if (!BindTransformFeedback) BindTransformFeedback = (PFNGLBINDTRANSFORMFEEDBACKPROC_MT)cmgr->getProcAddress("glBindTransformFeedback"); + if (!DeleteTransformFeedbacks) DeleteTransformFeedbacks = (PFNGLDELETETRANSFORMFEEDBACKSPROC_MT)cmgr->getProcAddress("glDeleteTransformFeedbacks"); + if (!GenTransformFeedbacks) GenTransformFeedbacks = (PFNGLGENTRANSFORMFEEDBACKSPROC_MT)cmgr->getProcAddress("glGenTransformFeedbacks"); + if (!IsTransformFeedback) IsTransformFeedback = (PFNGLISTRANSFORMFEEDBACKPROC_MT)cmgr->getProcAddress("glIsTransformFeedback"); + if (!PauseTransformFeedback) PauseTransformFeedback = (PFNGLPAUSETRANSFORMFEEDBACKPROC_MT)cmgr->getProcAddress("glPauseTransformFeedback"); + if (!ResumeTransformFeedback) ResumeTransformFeedback = (PFNGLRESUMETRANSFORMFEEDBACKPROC_MT)cmgr->getProcAddress("glResumeTransformFeedback"); + if (!DrawTransformFeedback) DrawTransformFeedback = (PFNGLDRAWTRANSFORMFEEDBACKPROC_MT)cmgr->getProcAddress("glDrawTransformFeedback"); + if (!DrawTransformFeedbackStream) DrawTransformFeedbackStream = (PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC_MT)cmgr->getProcAddress("glDrawTransformFeedbackStream"); + if (!BeginQueryIndexed) BeginQueryIndexed = (PFNGLBEGINQUERYINDEXEDPROC_MT)cmgr->getProcAddress("glBeginQueryIndexed"); + if (!EndQueryIndexed) EndQueryIndexed = (PFNGLENDQUERYINDEXEDPROC_MT)cmgr->getProcAddress("glEndQueryIndexed"); + if (!GetQueryIndexediv) GetQueryIndexediv = (PFNGLGETQUERYINDEXEDIVPROC_MT)cmgr->getProcAddress("glGetQueryIndexediv"); + if (!ReleaseShaderCompiler) ReleaseShaderCompiler = (PFNGLRELEASESHADERCOMPILERPROC_MT)cmgr->getProcAddress("glReleaseShaderCompiler"); + if (!ShaderBinary) ShaderBinary = (PFNGLSHADERBINARYPROC_MT)cmgr->getProcAddress("glShaderBinary"); + if (!GetShaderPrecisionFormat) GetShaderPrecisionFormat = (PFNGLGETSHADERPRECISIONFORMATPROC_MT)cmgr->getProcAddress("glGetShaderPrecisionFormat"); + if (!DepthRangef) DepthRangef = (PFNGLDEPTHRANGEFPROC_MT)cmgr->getProcAddress("glDepthRangef"); + if (!ClearDepthf) ClearDepthf = (PFNGLCLEARDEPTHFPROC_MT)cmgr->getProcAddress("glClearDepthf"); + if (!GetProgramBinary) GetProgramBinary = (PFNGLGETPROGRAMBINARYPROC_MT)cmgr->getProcAddress("glGetProgramBinary"); + if (!ProgramBinary) ProgramBinary = (PFNGLPROGRAMBINARYPROC_MT)cmgr->getProcAddress("glProgramBinary"); + if (!ProgramParameteri) ProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC_MT)cmgr->getProcAddress("glProgramParameteri"); + if (!ProgramParameteri) ProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC_MT)cmgr->getProcAddress("glProgramParameteriARB"); + if (!UseProgramStages) UseProgramStages = (PFNGLUSEPROGRAMSTAGESPROC_MT)cmgr->getProcAddress("glUseProgramStages"); + if (!ActiveShaderProgram) ActiveShaderProgram = (PFNGLACTIVESHADERPROGRAMPROC_MT)cmgr->getProcAddress("glActiveShaderProgram"); + if (!CreateShaderProgramv) CreateShaderProgramv = (PFNGLCREATESHADERPROGRAMVPROC_MT)cmgr->getProcAddress("glCreateShaderProgramv"); + if (!BindProgramPipeline) BindProgramPipeline = (PFNGLBINDPROGRAMPIPELINEPROC_MT)cmgr->getProcAddress("glBindProgramPipeline"); + if (!DeleteProgramPipelines) DeleteProgramPipelines = (PFNGLDELETEPROGRAMPIPELINESPROC_MT)cmgr->getProcAddress("glDeleteProgramPipelines"); + if (!GenProgramPipelines) GenProgramPipelines = (PFNGLGENPROGRAMPIPELINESPROC_MT)cmgr->getProcAddress("glGenProgramPipelines"); + if (!IsProgramPipeline) IsProgramPipeline = (PFNGLISPROGRAMPIPELINEPROC_MT)cmgr->getProcAddress("glIsProgramPipeline"); + if (!GetProgramPipelineiv) GetProgramPipelineiv = (PFNGLGETPROGRAMPIPELINEIVPROC_MT)cmgr->getProcAddress("glGetProgramPipelineiv"); + if (!ProgramUniform1i) ProgramUniform1i = (PFNGLPROGRAMUNIFORM1IPROC_MT)cmgr->getProcAddress("glProgramUniform1i"); + if (!ProgramUniform1iv) ProgramUniform1iv = (PFNGLPROGRAMUNIFORM1IVPROC_MT)cmgr->getProcAddress("glProgramUniform1iv"); + if (!ProgramUniform1f) ProgramUniform1f = (PFNGLPROGRAMUNIFORM1FPROC_MT)cmgr->getProcAddress("glProgramUniform1f"); + if (!ProgramUniform1fv) ProgramUniform1fv = (PFNGLPROGRAMUNIFORM1FVPROC_MT)cmgr->getProcAddress("glProgramUniform1fv"); + if (!ProgramUniform1d) ProgramUniform1d = (PFNGLPROGRAMUNIFORM1DPROC_MT)cmgr->getProcAddress("glProgramUniform1d"); + if (!ProgramUniform1dv) ProgramUniform1dv = (PFNGLPROGRAMUNIFORM1DVPROC_MT)cmgr->getProcAddress("glProgramUniform1dv"); + if (!ProgramUniform1ui) ProgramUniform1ui = (PFNGLPROGRAMUNIFORM1UIPROC_MT)cmgr->getProcAddress("glProgramUniform1ui"); + if (!ProgramUniform1uiv) ProgramUniform1uiv = (PFNGLPROGRAMUNIFORM1UIVPROC_MT)cmgr->getProcAddress("glProgramUniform1uiv"); + if (!ProgramUniform2i) ProgramUniform2i = (PFNGLPROGRAMUNIFORM2IPROC_MT)cmgr->getProcAddress("glProgramUniform2i"); + if (!ProgramUniform2iv) ProgramUniform2iv = (PFNGLPROGRAMUNIFORM2IVPROC_MT)cmgr->getProcAddress("glProgramUniform2iv"); + if (!ProgramUniform2f) ProgramUniform2f = (PFNGLPROGRAMUNIFORM2FPROC_MT)cmgr->getProcAddress("glProgramUniform2f"); + if (!ProgramUniform2fv) ProgramUniform2fv = (PFNGLPROGRAMUNIFORM2FVPROC_MT)cmgr->getProcAddress("glProgramUniform2fv"); + if (!ProgramUniform2d) ProgramUniform2d = (PFNGLPROGRAMUNIFORM2DPROC_MT)cmgr->getProcAddress("glProgramUniform2d"); + if (!ProgramUniform2dv) ProgramUniform2dv = (PFNGLPROGRAMUNIFORM2DVPROC_MT)cmgr->getProcAddress("glProgramUniform2dv"); + if (!ProgramUniform2ui) ProgramUniform2ui = (PFNGLPROGRAMUNIFORM2UIPROC_MT)cmgr->getProcAddress("glProgramUniform2ui"); + if (!ProgramUniform2uiv) ProgramUniform2uiv = (PFNGLPROGRAMUNIFORM2UIVPROC_MT)cmgr->getProcAddress("glProgramUniform2uiv"); + if (!ProgramUniform3i) ProgramUniform3i = (PFNGLPROGRAMUNIFORM3IPROC_MT)cmgr->getProcAddress("glProgramUniform3i"); + if (!ProgramUniform3iv) ProgramUniform3iv = (PFNGLPROGRAMUNIFORM3IVPROC_MT)cmgr->getProcAddress("glProgramUniform3iv"); + if (!ProgramUniform3f) ProgramUniform3f = (PFNGLPROGRAMUNIFORM3FPROC_MT)cmgr->getProcAddress("glProgramUniform3f"); + if (!ProgramUniform3fv) ProgramUniform3fv = (PFNGLPROGRAMUNIFORM3FVPROC_MT)cmgr->getProcAddress("glProgramUniform3fv"); + if (!ProgramUniform3d) ProgramUniform3d = (PFNGLPROGRAMUNIFORM3DPROC_MT)cmgr->getProcAddress("glProgramUniform3d"); + if (!ProgramUniform3dv) ProgramUniform3dv = (PFNGLPROGRAMUNIFORM3DVPROC_MT)cmgr->getProcAddress("glProgramUniform3dv"); + if (!ProgramUniform3ui) ProgramUniform3ui = (PFNGLPROGRAMUNIFORM3UIPROC_MT)cmgr->getProcAddress("glProgramUniform3ui"); + if (!ProgramUniform3uiv) ProgramUniform3uiv = (PFNGLPROGRAMUNIFORM3UIVPROC_MT)cmgr->getProcAddress("glProgramUniform3uiv"); + if (!ProgramUniform4i) ProgramUniform4i = (PFNGLPROGRAMUNIFORM4IPROC_MT)cmgr->getProcAddress("glProgramUniform4i"); + if (!ProgramUniform4iv) ProgramUniform4iv = (PFNGLPROGRAMUNIFORM4IVPROC_MT)cmgr->getProcAddress("glProgramUniform4iv"); + if (!ProgramUniform4f) ProgramUniform4f = (PFNGLPROGRAMUNIFORM4FPROC_MT)cmgr->getProcAddress("glProgramUniform4f"); + if (!ProgramUniform4fv) ProgramUniform4fv = (PFNGLPROGRAMUNIFORM4FVPROC_MT)cmgr->getProcAddress("glProgramUniform4fv"); + if (!ProgramUniform4d) ProgramUniform4d = (PFNGLPROGRAMUNIFORM4DPROC_MT)cmgr->getProcAddress("glProgramUniform4d"); + if (!ProgramUniform4dv) ProgramUniform4dv = (PFNGLPROGRAMUNIFORM4DVPROC_MT)cmgr->getProcAddress("glProgramUniform4dv"); + if (!ProgramUniform4ui) ProgramUniform4ui = (PFNGLPROGRAMUNIFORM4UIPROC_MT)cmgr->getProcAddress("glProgramUniform4ui"); + if (!ProgramUniform4uiv) ProgramUniform4uiv = (PFNGLPROGRAMUNIFORM4UIVPROC_MT)cmgr->getProcAddress("glProgramUniform4uiv"); + if (!ProgramUniformMatrix2fv) ProgramUniformMatrix2fv = (PFNGLPROGRAMUNIFORMMATRIX2FVPROC_MT)cmgr->getProcAddress("glProgramUniformMatrix2fv"); + if (!ProgramUniformMatrix3fv) ProgramUniformMatrix3fv = (PFNGLPROGRAMUNIFORMMATRIX3FVPROC_MT)cmgr->getProcAddress("glProgramUniformMatrix3fv"); + if (!ProgramUniformMatrix4fv) ProgramUniformMatrix4fv = (PFNGLPROGRAMUNIFORMMATRIX4FVPROC_MT)cmgr->getProcAddress("glProgramUniformMatrix4fv"); + if (!ProgramUniformMatrix2dv) ProgramUniformMatrix2dv = (PFNGLPROGRAMUNIFORMMATRIX2DVPROC_MT)cmgr->getProcAddress("glProgramUniformMatrix2dv"); + if (!ProgramUniformMatrix3dv) ProgramUniformMatrix3dv = (PFNGLPROGRAMUNIFORMMATRIX3DVPROC_MT)cmgr->getProcAddress("glProgramUniformMatrix3dv"); + if (!ProgramUniformMatrix4dv) ProgramUniformMatrix4dv = (PFNGLPROGRAMUNIFORMMATRIX4DVPROC_MT)cmgr->getProcAddress("glProgramUniformMatrix4dv"); + if (!ProgramUniformMatrix2x3fv) ProgramUniformMatrix2x3fv = (PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC_MT)cmgr->getProcAddress("glProgramUniformMatrix2x3fv"); + if (!ProgramUniformMatrix3x2fv) ProgramUniformMatrix3x2fv = (PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC_MT)cmgr->getProcAddress("glProgramUniformMatrix3x2fv"); + if (!ProgramUniformMatrix2x4fv) ProgramUniformMatrix2x4fv = (PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC_MT)cmgr->getProcAddress("glProgramUniformMatrix2x4fv"); + if (!ProgramUniformMatrix4x2fv) ProgramUniformMatrix4x2fv = (PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC_MT)cmgr->getProcAddress("glProgramUniformMatrix4x2fv"); + if (!ProgramUniformMatrix3x4fv) ProgramUniformMatrix3x4fv = (PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC_MT)cmgr->getProcAddress("glProgramUniformMatrix3x4fv"); + if (!ProgramUniformMatrix4x3fv) ProgramUniformMatrix4x3fv = (PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC_MT)cmgr->getProcAddress("glProgramUniformMatrix4x3fv"); + if (!ProgramUniformMatrix2x3dv) ProgramUniformMatrix2x3dv = (PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC_MT)cmgr->getProcAddress("glProgramUniformMatrix2x3dv"); + if (!ProgramUniformMatrix3x2dv) ProgramUniformMatrix3x2dv = (PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC_MT)cmgr->getProcAddress("glProgramUniformMatrix3x2dv"); + if (!ProgramUniformMatrix2x4dv) ProgramUniformMatrix2x4dv = (PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC_MT)cmgr->getProcAddress("glProgramUniformMatrix2x4dv"); + if (!ProgramUniformMatrix4x2dv) ProgramUniformMatrix4x2dv = (PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC_MT)cmgr->getProcAddress("glProgramUniformMatrix4x2dv"); + if (!ProgramUniformMatrix3x4dv) ProgramUniformMatrix3x4dv = (PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC_MT)cmgr->getProcAddress("glProgramUniformMatrix3x4dv"); + if (!ProgramUniformMatrix4x3dv) ProgramUniformMatrix4x3dv = (PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC_MT)cmgr->getProcAddress("glProgramUniformMatrix4x3dv"); + if (!ValidateProgramPipeline) ValidateProgramPipeline = (PFNGLVALIDATEPROGRAMPIPELINEPROC_MT)cmgr->getProcAddress("glValidateProgramPipeline"); + if (!GetProgramPipelineInfoLog) GetProgramPipelineInfoLog = (PFNGLGETPROGRAMPIPELINEINFOLOGPROC_MT)cmgr->getProcAddress("glGetProgramPipelineInfoLog"); + if (!VertexAttribL1d) VertexAttribL1d = (PFNGLVERTEXATTRIBL1DPROC_MT)cmgr->getProcAddress("glVertexAttribL1d"); + if (!VertexAttribL2d) VertexAttribL2d = (PFNGLVERTEXATTRIBL2DPROC_MT)cmgr->getProcAddress("glVertexAttribL2d"); + if (!VertexAttribL3d) VertexAttribL3d = (PFNGLVERTEXATTRIBL3DPROC_MT)cmgr->getProcAddress("glVertexAttribL3d"); + if (!VertexAttribL4d) VertexAttribL4d = (PFNGLVERTEXATTRIBL4DPROC_MT)cmgr->getProcAddress("glVertexAttribL4d"); + if (!VertexAttribL1dv) VertexAttribL1dv = (PFNGLVERTEXATTRIBL1DVPROC_MT)cmgr->getProcAddress("glVertexAttribL1dv"); + if (!VertexAttribL2dv) VertexAttribL2dv = (PFNGLVERTEXATTRIBL2DVPROC_MT)cmgr->getProcAddress("glVertexAttribL2dv"); + if (!VertexAttribL3dv) VertexAttribL3dv = (PFNGLVERTEXATTRIBL3DVPROC_MT)cmgr->getProcAddress("glVertexAttribL3dv"); + if (!VertexAttribL4dv) VertexAttribL4dv = (PFNGLVERTEXATTRIBL4DVPROC_MT)cmgr->getProcAddress("glVertexAttribL4dv"); + if (!VertexAttribLPointer) VertexAttribLPointer = (PFNGLVERTEXATTRIBLPOINTERPROC_MT)cmgr->getProcAddress("glVertexAttribLPointer"); + if (!GetVertexAttribLdv) GetVertexAttribLdv = (PFNGLGETVERTEXATTRIBLDVPROC_MT)cmgr->getProcAddress("glGetVertexAttribLdv"); + if (!ViewportArrayv) ViewportArrayv = (PFNGLVIEWPORTARRAYVPROC_MT)cmgr->getProcAddress("glViewportArrayv"); + if (!ViewportIndexedf) ViewportIndexedf = (PFNGLVIEWPORTINDEXEDFPROC_MT)cmgr->getProcAddress("glViewportIndexedf"); + if (!ViewportIndexedfv) ViewportIndexedfv = (PFNGLVIEWPORTINDEXEDFVPROC_MT)cmgr->getProcAddress("glViewportIndexedfv"); + if (!ScissorArrayv) ScissorArrayv = (PFNGLSCISSORARRAYVPROC_MT)cmgr->getProcAddress("glScissorArrayv"); + if (!ScissorIndexed) ScissorIndexed = (PFNGLSCISSORINDEXEDPROC_MT)cmgr->getProcAddress("glScissorIndexed"); + if (!ScissorIndexedv) ScissorIndexedv = (PFNGLSCISSORINDEXEDVPROC_MT)cmgr->getProcAddress("glScissorIndexedv"); + if (!DepthRangeArrayv) DepthRangeArrayv = (PFNGLDEPTHRANGEARRAYVPROC_MT)cmgr->getProcAddress("glDepthRangeArrayv"); + if (!DepthRangeIndexed) DepthRangeIndexed = (PFNGLDEPTHRANGEINDEXEDPROC_MT)cmgr->getProcAddress("glDepthRangeIndexed"); + if (!DrawArraysInstancedBaseInstance) DrawArraysInstancedBaseInstance = (PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC_MT)cmgr->getProcAddress("glDrawArraysInstancedBaseInstance"); + if (!DrawElementsInstancedBaseInstance) DrawElementsInstancedBaseInstance = (PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC_MT)cmgr->getProcAddress("glDrawElementsInstancedBaseInstance"); + if (!DrawElementsInstancedBaseVertexBaseInstance) DrawElementsInstancedBaseVertexBaseInstance = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC_MT)cmgr->getProcAddress("glDrawElementsInstancedBaseVertexBaseInstance"); + if (!GetInternalformativ) GetInternalformativ = (PFNGLGETINTERNALFORMATIVPROC_MT)cmgr->getProcAddress("glGetInternalformativ"); + if (!GetActiveAtomicCounterBufferiv) GetActiveAtomicCounterBufferiv = (PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC_MT)cmgr->getProcAddress("glGetActiveAtomicCounterBufferiv"); + if (!BindImageTexture) BindImageTexture = (PFNGLBINDIMAGETEXTUREPROC_MT)cmgr->getProcAddress("glBindImageTexture"); + if (!MemoryBarrier) MemoryBarrier = (PFNGLMEMORYBARRIERPROC_MT)cmgr->getProcAddress("glMemoryBarrier"); + if (!TexStorage1D) TexStorage1D = (PFNGLTEXSTORAGE1DPROC_MT)cmgr->getProcAddress("glTexStorage1D"); + if (!TexStorage2D) TexStorage2D = (PFNGLTEXSTORAGE2DPROC_MT)cmgr->getProcAddress("glTexStorage2D"); + if (!TexStorage3D) TexStorage3D = (PFNGLTEXSTORAGE3DPROC_MT)cmgr->getProcAddress("glTexStorage3D"); + if (!DrawTransformFeedbackInstanced) DrawTransformFeedbackInstanced = (PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC_MT)cmgr->getProcAddress("glDrawTransformFeedbackInstanced"); + if (!DrawTransformFeedbackStreamInstanced) DrawTransformFeedbackStreamInstanced = (PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC_MT)cmgr->getProcAddress("glDrawTransformFeedbackStreamInstanced"); + if (!ClearBufferData) ClearBufferData = (PFNGLCLEARBUFFERDATAPROC_MT)cmgr->getProcAddress("glClearBufferData"); + if (!ClearBufferSubData) ClearBufferSubData = (PFNGLCLEARBUFFERSUBDATAPROC_MT)cmgr->getProcAddress("glClearBufferSubData"); + if (!DispatchCompute) DispatchCompute = (PFNGLDISPATCHCOMPUTEPROC_MT)cmgr->getProcAddress("glDispatchCompute"); + if (!DispatchComputeIndirect) DispatchComputeIndirect = (PFNGLDISPATCHCOMPUTEINDIRECTPROC_MT)cmgr->getProcAddress("glDispatchComputeIndirect"); + if (!CopyImageSubData) CopyImageSubData = (PFNGLCOPYIMAGESUBDATAPROC_MT)cmgr->getProcAddress("glCopyImageSubData"); + if (!FramebufferParameteri) FramebufferParameteri = (PFNGLFRAMEBUFFERPARAMETERIPROC_MT)cmgr->getProcAddress("glFramebufferParameteri"); + if (!GetFramebufferParameteriv) GetFramebufferParameteriv = (PFNGLGETFRAMEBUFFERPARAMETERIVPROC_MT)cmgr->getProcAddress("glGetFramebufferParameteriv"); + if (!GetInternalformati64v) GetInternalformati64v = (PFNGLGETINTERNALFORMATI64VPROC_MT)cmgr->getProcAddress("glGetInternalformati64v"); + if (!InvalidateTexSubImage) InvalidateTexSubImage = (PFNGLINVALIDATETEXSUBIMAGEPROC_MT)cmgr->getProcAddress("glInvalidateTexSubImage"); + if (!InvalidateTexImage) InvalidateTexImage = (PFNGLINVALIDATETEXIMAGEPROC_MT)cmgr->getProcAddress("glInvalidateTexImage"); + if (!InvalidateBufferSubData) InvalidateBufferSubData = (PFNGLINVALIDATEBUFFERSUBDATAPROC_MT)cmgr->getProcAddress("glInvalidateBufferSubData"); + if (!InvalidateBufferData) InvalidateBufferData = (PFNGLINVALIDATEBUFFERDATAPROC_MT)cmgr->getProcAddress("glInvalidateBufferData"); + if (!InvalidateFramebuffer) InvalidateFramebuffer = (PFNGLINVALIDATEFRAMEBUFFERPROC_MT)cmgr->getProcAddress("glInvalidateFramebuffer"); + if (!InvalidateSubFramebuffer) InvalidateSubFramebuffer = (PFNGLINVALIDATESUBFRAMEBUFFERPROC_MT)cmgr->getProcAddress("glInvalidateSubFramebuffer"); + if (!MultiDrawArraysIndirect) MultiDrawArraysIndirect = (PFNGLMULTIDRAWARRAYSINDIRECTPROC_MT)cmgr->getProcAddress("glMultiDrawArraysIndirect"); + if (!MultiDrawElementsIndirect) MultiDrawElementsIndirect = (PFNGLMULTIDRAWELEMENTSINDIRECTPROC_MT)cmgr->getProcAddress("glMultiDrawElementsIndirect"); + if (!GetProgramInterfaceiv) GetProgramInterfaceiv = (PFNGLGETPROGRAMINTERFACEIVPROC_MT)cmgr->getProcAddress("glGetProgramInterfaceiv"); + if (!GetProgramResourceIndex) GetProgramResourceIndex = (PFNGLGETPROGRAMRESOURCEINDEXPROC_MT)cmgr->getProcAddress("glGetProgramResourceIndex"); + if (!GetProgramResourceName) GetProgramResourceName = (PFNGLGETPROGRAMRESOURCENAMEPROC_MT)cmgr->getProcAddress("glGetProgramResourceName"); + if (!GetProgramResourceiv) GetProgramResourceiv = (PFNGLGETPROGRAMRESOURCEIVPROC_MT)cmgr->getProcAddress("glGetProgramResourceiv"); + if (!GetProgramResourceLocation) GetProgramResourceLocation = (PFNGLGETPROGRAMRESOURCELOCATIONPROC_MT)cmgr->getProcAddress("glGetProgramResourceLocation"); + if (!GetProgramResourceLocationIndex) GetProgramResourceLocationIndex = (PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC_MT)cmgr->getProcAddress("glGetProgramResourceLocationIndex"); + if (!ShaderStorageBlockBinding) ShaderStorageBlockBinding = (PFNGLSHADERSTORAGEBLOCKBINDINGPROC_MT)cmgr->getProcAddress("glShaderStorageBlockBinding"); + if (!TexBufferRange) TexBufferRange = (PFNGLTEXBUFFERRANGEPROC_MT)cmgr->getProcAddress("glTexBufferRange"); + if (!TexStorage2DMultisample) TexStorage2DMultisample = (PFNGLTEXSTORAGE2DMULTISAMPLEPROC_MT)cmgr->getProcAddress("glTexStorage2DMultisample"); + if (!TexStorage3DMultisample) TexStorage3DMultisample = (PFNGLTEXSTORAGE3DMULTISAMPLEPROC_MT)cmgr->getProcAddress("glTexStorage3DMultisample"); + if (!TextureView) TextureView = (PFNGLTEXTUREVIEWPROC_MT)cmgr->getProcAddress("glTextureView"); + if (!BindVertexBuffer) BindVertexBuffer = (PFNGLBINDVERTEXBUFFERPROC_MT)cmgr->getProcAddress("glBindVertexBuffer"); + if (!VertexAttribFormat) VertexAttribFormat = (PFNGLVERTEXATTRIBFORMATPROC_MT)cmgr->getProcAddress("glVertexAttribFormat"); + if (!VertexAttribIFormat) VertexAttribIFormat = (PFNGLVERTEXATTRIBIFORMATPROC_MT)cmgr->getProcAddress("glVertexAttribIFormat"); + if (!VertexAttribLFormat) VertexAttribLFormat = (PFNGLVERTEXATTRIBLFORMATPROC_MT)cmgr->getProcAddress("glVertexAttribLFormat"); + if (!VertexAttribBinding) VertexAttribBinding = (PFNGLVERTEXATTRIBBINDINGPROC_MT)cmgr->getProcAddress("glVertexAttribBinding"); + if (!VertexBindingDivisor) VertexBindingDivisor = (PFNGLVERTEXBINDINGDIVISORPROC_MT)cmgr->getProcAddress("glVertexBindingDivisor"); + if (!DebugMessageControl) DebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC_MT)cmgr->getProcAddress("glDebugMessageControl"); + if (!DebugMessageControl) DebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC_MT)cmgr->getProcAddress("glDebugMessageControlARB"); + if (!DebugMessageInsert) DebugMessageInsert = (PFNGLDEBUGMESSAGEINSERTPROC_MT)cmgr->getProcAddress("glDebugMessageInsert"); + if (!DebugMessageInsert) DebugMessageInsert = (PFNGLDEBUGMESSAGEINSERTPROC_MT)cmgr->getProcAddress("glDebugMessageInsertARB"); + if (!DebugMessageCallback) DebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC_MT)cmgr->getProcAddress("glDebugMessageCallback"); + if (!DebugMessageCallback) DebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC_MT)cmgr->getProcAddress("glDebugMessageCallbackARB"); + if (!GetDebugMessageLog) GetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGPROC_MT)cmgr->getProcAddress("glGetDebugMessageLog"); + if (!GetDebugMessageLog) GetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGPROC_MT)cmgr->getProcAddress("glGetDebugMessageLogARB"); + if (!PushDebugGroup) PushDebugGroup = (PFNGLPUSHDEBUGGROUPPROC_MT)cmgr->getProcAddress("glPushDebugGroup"); + if (!PopDebugGroup) PopDebugGroup = (PFNGLPOPDEBUGGROUPPROC_MT)cmgr->getProcAddress("glPopDebugGroup"); + if (!ObjectLabel) ObjectLabel = (PFNGLOBJECTLABELPROC_MT)cmgr->getProcAddress("glObjectLabel"); + if (!GetObjectLabel) GetObjectLabel = (PFNGLGETOBJECTLABELPROC_MT)cmgr->getProcAddress("glGetObjectLabel"); + if (!ObjectPtrLabel) ObjectPtrLabel = (PFNGLOBJECTPTRLABELPROC_MT)cmgr->getProcAddress("glObjectPtrLabel"); + if (!GetObjectPtrLabel) GetObjectPtrLabel = (PFNGLGETOBJECTPTRLABELPROC_MT)cmgr->getProcAddress("glGetObjectPtrLabel"); + if (!BufferStorage) BufferStorage = (PFNGLBUFFERSTORAGEPROC_MT)cmgr->getProcAddress("glBufferStorage"); + if (!ClearTexImage) ClearTexImage = (PFNGLCLEARTEXIMAGEPROC_MT)cmgr->getProcAddress("glClearTexImage"); + if (!ClearTexSubImage) ClearTexSubImage = (PFNGLCLEARTEXSUBIMAGEPROC_MT)cmgr->getProcAddress("glClearTexSubImage"); + if (!BindBuffersBase) BindBuffersBase = (PFNGLBINDBUFFERSBASEPROC_MT)cmgr->getProcAddress("glBindBuffersBase"); + if (!BindBuffersRange) BindBuffersRange = (PFNGLBINDBUFFERSRANGEPROC_MT)cmgr->getProcAddress("glBindBuffersRange"); + if (!BindTextures) BindTextures = (PFNGLBINDTEXTURESPROC_MT)cmgr->getProcAddress("glBindTextures"); + if (!BindSamplers) BindSamplers = (PFNGLBINDSAMPLERSPROC_MT)cmgr->getProcAddress("glBindSamplers"); + if (!BindImageTextures) BindImageTextures = (PFNGLBINDIMAGETEXTURESPROC_MT)cmgr->getProcAddress("glBindImageTextures"); + if (!BindVertexBuffers) BindVertexBuffers = (PFNGLBINDVERTEXBUFFERSPROC_MT)cmgr->getProcAddress("glBindVertexBuffers"); + if (!ClipControl) ClipControl = (PFNGLCLIPCONTROLPROC_MT)cmgr->getProcAddress("glClipControl"); + if (!CreateTransformFeedbacks) CreateTransformFeedbacks = (PFNGLCREATETRANSFORMFEEDBACKSPROC_MT)cmgr->getProcAddress("glCreateTransformFeedbacks"); + if (!TransformFeedbackBufferBase) TransformFeedbackBufferBase = (PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC_MT)cmgr->getProcAddress("glTransformFeedbackBufferBase"); + if (!TransformFeedbackBufferRange) TransformFeedbackBufferRange = (PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC_MT)cmgr->getProcAddress("glTransformFeedbackBufferRange"); + if (!GetTransformFeedbackiv) GetTransformFeedbackiv = (PFNGLGETTRANSFORMFEEDBACKIVPROC_MT)cmgr->getProcAddress("glGetTransformFeedbackiv"); + if (!CreateBuffers) CreateBuffers = (PFNGLCREATEBUFFERSPROC_MT)cmgr->getProcAddress("glCreateBuffers"); + if (!NamedBufferStorage) NamedBufferStorage = (PFNGLNAMEDBUFFERSTORAGEPROC_MT)cmgr->getProcAddress("glNamedBufferStorage"); + if (!NamedBufferData) NamedBufferData = (PFNGLNAMEDBUFFERDATAPROC_MT)cmgr->getProcAddress("glNamedBufferData"); + if (!NamedBufferSubData) NamedBufferSubData = (PFNGLNAMEDBUFFERSUBDATAPROC_MT)cmgr->getProcAddress("glNamedBufferSubData"); + if (!CopyNamedBufferSubData) CopyNamedBufferSubData = (PFNGLCOPYNAMEDBUFFERSUBDATAPROC_MT)cmgr->getProcAddress("glCopyNamedBufferSubData"); + if (!ClearNamedBufferData) ClearNamedBufferData = (PFNGLCLEARNAMEDBUFFERDATAPROC_MT)cmgr->getProcAddress("glClearNamedBufferData"); + if (!ClearNamedBufferSubData) ClearNamedBufferSubData = (PFNGLCLEARNAMEDBUFFERSUBDATAPROC_MT)cmgr->getProcAddress("glClearNamedBufferSubData"); + if (!MapNamedBuffer) MapNamedBuffer = (PFNGLMAPNAMEDBUFFERPROC_MT)cmgr->getProcAddress("glMapNamedBuffer"); + if (!MapNamedBufferRange) MapNamedBufferRange = (PFNGLMAPNAMEDBUFFERRANGEPROC_MT)cmgr->getProcAddress("glMapNamedBufferRange"); + if (!UnmapNamedBuffer) UnmapNamedBuffer = (PFNGLUNMAPNAMEDBUFFERPROC_MT)cmgr->getProcAddress("glUnmapNamedBuffer"); + if (!FlushMappedNamedBufferRange) FlushMappedNamedBufferRange = (PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC_MT)cmgr->getProcAddress("glFlushMappedNamedBufferRange"); + if (!GetNamedBufferParameteriv) GetNamedBufferParameteriv = (PFNGLGETNAMEDBUFFERPARAMETERIVPROC_MT)cmgr->getProcAddress("glGetNamedBufferParameteriv"); + if (!GetNamedBufferParameteri64v) GetNamedBufferParameteri64v = (PFNGLGETNAMEDBUFFERPARAMETERI64VPROC_MT)cmgr->getProcAddress("glGetNamedBufferParameteri64v"); + if (!GetNamedBufferPointerv) GetNamedBufferPointerv = (PFNGLGETNAMEDBUFFERPOINTERVPROC_MT)cmgr->getProcAddress("glGetNamedBufferPointerv"); + if (!GetNamedBufferSubData) GetNamedBufferSubData = (PFNGLGETNAMEDBUFFERSUBDATAPROC_MT)cmgr->getProcAddress("glGetNamedBufferSubData"); + if (!CreateFramebuffers) CreateFramebuffers = (PFNGLCREATEFRAMEBUFFERSPROC_MT)cmgr->getProcAddress("glCreateFramebuffers"); + if (!NamedFramebufferRenderbuffer) NamedFramebufferRenderbuffer = (PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC_MT)cmgr->getProcAddress("glNamedFramebufferRenderbuffer"); + if (!NamedFramebufferParameteri) NamedFramebufferParameteri = (PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC_MT)cmgr->getProcAddress("glNamedFramebufferParameteri"); + if (!NamedFramebufferTexture) NamedFramebufferTexture = (PFNGLNAMEDFRAMEBUFFERTEXTUREPROC_MT)cmgr->getProcAddress("glNamedFramebufferTexture"); + if (!NamedFramebufferTextureLayer) NamedFramebufferTextureLayer = (PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC_MT)cmgr->getProcAddress("glNamedFramebufferTextureLayer"); + if (!NamedFramebufferDrawBuffer) NamedFramebufferDrawBuffer = (PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC_MT)cmgr->getProcAddress("glNamedFramebufferDrawBuffer"); + if (!NamedFramebufferDrawBuffers) NamedFramebufferDrawBuffers = (PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC_MT)cmgr->getProcAddress("glNamedFramebufferDrawBuffers"); + if (!NamedFramebufferReadBuffer) NamedFramebufferReadBuffer = (PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC_MT)cmgr->getProcAddress("glNamedFramebufferReadBuffer"); + if (!InvalidateNamedFramebufferData) InvalidateNamedFramebufferData = (PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC_MT)cmgr->getProcAddress("glInvalidateNamedFramebufferData"); + if (!InvalidateNamedFramebufferSubData) InvalidateNamedFramebufferSubData = (PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC_MT)cmgr->getProcAddress("glInvalidateNamedFramebufferSubData"); + if (!ClearNamedFramebufferiv) ClearNamedFramebufferiv = (PFNGLCLEARNAMEDFRAMEBUFFERIVPROC_MT)cmgr->getProcAddress("glClearNamedFramebufferiv"); + if (!ClearNamedFramebufferuiv) ClearNamedFramebufferuiv = (PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC_MT)cmgr->getProcAddress("glClearNamedFramebufferuiv"); + if (!ClearNamedFramebufferfv) ClearNamedFramebufferfv = (PFNGLCLEARNAMEDFRAMEBUFFERFVPROC_MT)cmgr->getProcAddress("glClearNamedFramebufferfv"); + if (!ClearNamedFramebufferfi) ClearNamedFramebufferfi = (PFNGLCLEARNAMEDFRAMEBUFFERFIPROC_MT)cmgr->getProcAddress("glClearNamedFramebufferfi"); + if (!BlitNamedFramebuffer) BlitNamedFramebuffer = (PFNGLBLITNAMEDFRAMEBUFFERPROC_MT)cmgr->getProcAddress("glBlitNamedFramebuffer"); + if (!CheckNamedFramebufferStatus) CheckNamedFramebufferStatus = (PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC_MT)cmgr->getProcAddress("glCheckNamedFramebufferStatus"); + if (!GetNamedFramebufferParameteriv) GetNamedFramebufferParameteriv = (PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC_MT)cmgr->getProcAddress("glGetNamedFramebufferParameteriv"); + if (!GetNamedFramebufferAttachmentParameteriv) GetNamedFramebufferAttachmentParameteriv = (PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC_MT)cmgr->getProcAddress("glGetNamedFramebufferAttachmentParameteriv"); + if (!CreateRenderbuffers) CreateRenderbuffers = (PFNGLCREATERENDERBUFFERSPROC_MT)cmgr->getProcAddress("glCreateRenderbuffers"); + if (!NamedRenderbufferStorage) NamedRenderbufferStorage = (PFNGLNAMEDRENDERBUFFERSTORAGEPROC_MT)cmgr->getProcAddress("glNamedRenderbufferStorage"); + if (!NamedRenderbufferStorageMultisample) NamedRenderbufferStorageMultisample = (PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC_MT)cmgr->getProcAddress("glNamedRenderbufferStorageMultisample"); + if (!GetNamedRenderbufferParameteriv) GetNamedRenderbufferParameteriv = (PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC_MT)cmgr->getProcAddress("glGetNamedRenderbufferParameteriv"); + if (!CreateTextures) CreateTextures = (PFNGLCREATETEXTURESPROC_MT)cmgr->getProcAddress("glCreateTextures"); + if (!TextureBuffer) TextureBuffer = (PFNGLTEXTUREBUFFERPROC_MT)cmgr->getProcAddress("glTextureBuffer"); + if (!TextureBufferRange) TextureBufferRange = (PFNGLTEXTUREBUFFERRANGEPROC_MT)cmgr->getProcAddress("glTextureBufferRange"); + if (!TextureStorage1D) TextureStorage1D = (PFNGLTEXTURESTORAGE1DPROC_MT)cmgr->getProcAddress("glTextureStorage1D"); + if (!TextureStorage2D) TextureStorage2D = (PFNGLTEXTURESTORAGE2DPROC_MT)cmgr->getProcAddress("glTextureStorage2D"); + if (!TextureStorage3D) TextureStorage3D = (PFNGLTEXTURESTORAGE3DPROC_MT)cmgr->getProcAddress("glTextureStorage3D"); + if (!TextureStorage2DMultisample) TextureStorage2DMultisample = (PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC_MT)cmgr->getProcAddress("glTextureStorage2DMultisample"); + if (!TextureStorage3DMultisample) TextureStorage3DMultisample = (PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC_MT)cmgr->getProcAddress("glTextureStorage3DMultisample"); + if (!TextureSubImage1D) TextureSubImage1D = (PFNGLTEXTURESUBIMAGE1DPROC_MT)cmgr->getProcAddress("glTextureSubImage1D"); + if (!TextureSubImage2D) TextureSubImage2D = (PFNGLTEXTURESUBIMAGE2DPROC_MT)cmgr->getProcAddress("glTextureSubImage2D"); + if (!TextureSubImage3D) TextureSubImage3D = (PFNGLTEXTURESUBIMAGE3DPROC_MT)cmgr->getProcAddress("glTextureSubImage3D"); + if (!CompressedTextureSubImage1D) CompressedTextureSubImage1D = (PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC_MT)cmgr->getProcAddress("glCompressedTextureSubImage1D"); + if (!CompressedTextureSubImage2D) CompressedTextureSubImage2D = (PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC_MT)cmgr->getProcAddress("glCompressedTextureSubImage2D"); + if (!CompressedTextureSubImage3D) CompressedTextureSubImage3D = (PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC_MT)cmgr->getProcAddress("glCompressedTextureSubImage3D"); + if (!CopyTextureSubImage1D) CopyTextureSubImage1D = (PFNGLCOPYTEXTURESUBIMAGE1DPROC_MT)cmgr->getProcAddress("glCopyTextureSubImage1D"); + if (!CopyTextureSubImage2D) CopyTextureSubImage2D = (PFNGLCOPYTEXTURESUBIMAGE2DPROC_MT)cmgr->getProcAddress("glCopyTextureSubImage2D"); + if (!CopyTextureSubImage3D) CopyTextureSubImage3D = (PFNGLCOPYTEXTURESUBIMAGE3DPROC_MT)cmgr->getProcAddress("glCopyTextureSubImage3D"); + if (!TextureParameterf) TextureParameterf = (PFNGLTEXTUREPARAMETERFPROC_MT)cmgr->getProcAddress("glTextureParameterf"); + if (!TextureParameterfv) TextureParameterfv = (PFNGLTEXTUREPARAMETERFVPROC_MT)cmgr->getProcAddress("glTextureParameterfv"); + if (!TextureParameteri) TextureParameteri = (PFNGLTEXTUREPARAMETERIPROC_MT)cmgr->getProcAddress("glTextureParameteri"); + if (!TextureParameterIiv) TextureParameterIiv = (PFNGLTEXTUREPARAMETERIIVPROC_MT)cmgr->getProcAddress("glTextureParameterIiv"); + if (!TextureParameterIuiv) TextureParameterIuiv = (PFNGLTEXTUREPARAMETERIUIVPROC_MT)cmgr->getProcAddress("glTextureParameterIuiv"); + if (!TextureParameteriv) TextureParameteriv = (PFNGLTEXTUREPARAMETERIVPROC_MT)cmgr->getProcAddress("glTextureParameteriv"); + if (!GenerateTextureMipmap) GenerateTextureMipmap = (PFNGLGENERATETEXTUREMIPMAPPROC_MT)cmgr->getProcAddress("glGenerateTextureMipmap"); + if (!BindTextureUnit) BindTextureUnit = (PFNGLBINDTEXTUREUNITPROC_MT)cmgr->getProcAddress("glBindTextureUnit"); + if (!GetTextureImage) GetTextureImage = (PFNGLGETTEXTUREIMAGEPROC_MT)cmgr->getProcAddress("glGetTextureImage"); + if (!GetCompressedTextureImage) GetCompressedTextureImage = (PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC_MT)cmgr->getProcAddress("glGetCompressedTextureImage"); + if (!GetTextureLevelParameterfv) GetTextureLevelParameterfv = (PFNGLGETTEXTURELEVELPARAMETERFVPROC_MT)cmgr->getProcAddress("glGetTextureLevelParameterfv"); + if (!GetTextureLevelParameteriv) GetTextureLevelParameteriv = (PFNGLGETTEXTURELEVELPARAMETERIVPROC_MT)cmgr->getProcAddress("glGetTextureLevelParameteriv"); + if (!GetTextureParameterfv) GetTextureParameterfv = (PFNGLGETTEXTUREPARAMETERFVPROC_MT)cmgr->getProcAddress("glGetTextureParameterfv"); + if (!GetTextureParameterIiv) GetTextureParameterIiv = (PFNGLGETTEXTUREPARAMETERIIVPROC_MT)cmgr->getProcAddress("glGetTextureParameterIiv"); + if (!GetTextureParameterIuiv) GetTextureParameterIuiv = (PFNGLGETTEXTUREPARAMETERIUIVPROC_MT)cmgr->getProcAddress("glGetTextureParameterIuiv"); + if (!GetTextureParameteriv) GetTextureParameteriv = (PFNGLGETTEXTUREPARAMETERIVPROC_MT)cmgr->getProcAddress("glGetTextureParameteriv"); + if (!CreateVertexArrays) CreateVertexArrays = (PFNGLCREATEVERTEXARRAYSPROC_MT)cmgr->getProcAddress("glCreateVertexArrays"); + if (!DisableVertexArrayAttrib) DisableVertexArrayAttrib = (PFNGLDISABLEVERTEXARRAYATTRIBPROC_MT)cmgr->getProcAddress("glDisableVertexArrayAttrib"); + if (!EnableVertexArrayAttrib) EnableVertexArrayAttrib = (PFNGLENABLEVERTEXARRAYATTRIBPROC_MT)cmgr->getProcAddress("glEnableVertexArrayAttrib"); + if (!VertexArrayElementBuffer) VertexArrayElementBuffer = (PFNGLVERTEXARRAYELEMENTBUFFERPROC_MT)cmgr->getProcAddress("glVertexArrayElementBuffer"); + if (!VertexArrayVertexBuffer) VertexArrayVertexBuffer = (PFNGLVERTEXARRAYVERTEXBUFFERPROC_MT)cmgr->getProcAddress("glVertexArrayVertexBuffer"); + if (!VertexArrayVertexBuffers) VertexArrayVertexBuffers = (PFNGLVERTEXARRAYVERTEXBUFFERSPROC_MT)cmgr->getProcAddress("glVertexArrayVertexBuffers"); + if (!VertexArrayAttribBinding) VertexArrayAttribBinding = (PFNGLVERTEXARRAYATTRIBBINDINGPROC_MT)cmgr->getProcAddress("glVertexArrayAttribBinding"); + if (!VertexArrayAttribFormat) VertexArrayAttribFormat = (PFNGLVERTEXARRAYATTRIBFORMATPROC_MT)cmgr->getProcAddress("glVertexArrayAttribFormat"); + if (!VertexArrayAttribIFormat) VertexArrayAttribIFormat = (PFNGLVERTEXARRAYATTRIBIFORMATPROC_MT)cmgr->getProcAddress("glVertexArrayAttribIFormat"); + if (!VertexArrayAttribLFormat) VertexArrayAttribLFormat = (PFNGLVERTEXARRAYATTRIBLFORMATPROC_MT)cmgr->getProcAddress("glVertexArrayAttribLFormat"); + if (!VertexArrayBindingDivisor) VertexArrayBindingDivisor = (PFNGLVERTEXARRAYBINDINGDIVISORPROC_MT)cmgr->getProcAddress("glVertexArrayBindingDivisor"); + if (!GetVertexArrayiv) GetVertexArrayiv = (PFNGLGETVERTEXARRAYIVPROC_MT)cmgr->getProcAddress("glGetVertexArrayiv"); + if (!GetVertexArrayIndexediv) GetVertexArrayIndexediv = (PFNGLGETVERTEXARRAYINDEXEDIVPROC_MT)cmgr->getProcAddress("glGetVertexArrayIndexediv"); + if (!GetVertexArrayIndexed64iv) GetVertexArrayIndexed64iv = (PFNGLGETVERTEXARRAYINDEXED64IVPROC_MT)cmgr->getProcAddress("glGetVertexArrayIndexed64iv"); + if (!CreateSamplers) CreateSamplers = (PFNGLCREATESAMPLERSPROC_MT)cmgr->getProcAddress("glCreateSamplers"); + if (!CreateProgramPipelines) CreateProgramPipelines = (PFNGLCREATEPROGRAMPIPELINESPROC_MT)cmgr->getProcAddress("glCreateProgramPipelines"); + if (!CreateQueries) CreateQueries = (PFNGLCREATEQUERIESPROC_MT)cmgr->getProcAddress("glCreateQueries"); + if (!GetQueryBufferObjecti64v) GetQueryBufferObjecti64v = (PFNGLGETQUERYBUFFEROBJECTI64VPROC_MT)cmgr->getProcAddress("glGetQueryBufferObjecti64v"); + if (!GetQueryBufferObjectiv) GetQueryBufferObjectiv = (PFNGLGETQUERYBUFFEROBJECTIVPROC_MT)cmgr->getProcAddress("glGetQueryBufferObjectiv"); + if (!GetQueryBufferObjectui64v) GetQueryBufferObjectui64v = (PFNGLGETQUERYBUFFEROBJECTUI64VPROC_MT)cmgr->getProcAddress("glGetQueryBufferObjectui64v"); + if (!GetQueryBufferObjectuiv) GetQueryBufferObjectuiv = (PFNGLGETQUERYBUFFEROBJECTUIVPROC_MT)cmgr->getProcAddress("glGetQueryBufferObjectuiv"); + if (!MemoryBarrierByRegion) MemoryBarrierByRegion = (PFNGLMEMORYBARRIERBYREGIONPROC_MT)cmgr->getProcAddress("glMemoryBarrierByRegion"); + if (!GetTextureSubImage) GetTextureSubImage = (PFNGLGETTEXTURESUBIMAGEPROC_MT)cmgr->getProcAddress("glGetTextureSubImage"); + if (!GetCompressedTextureSubImage) GetCompressedTextureSubImage = (PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC_MT)cmgr->getProcAddress("glGetCompressedTextureSubImage"); + if (!GetGraphicsResetStatus) GetGraphicsResetStatus = (PFNGLGETGRAPHICSRESETSTATUSPROC_MT)cmgr->getProcAddress("glGetGraphicsResetStatus"); + if (!GetGraphicsResetStatus) GetGraphicsResetStatus = (PFNGLGETGRAPHICSRESETSTATUSPROC_MT)cmgr->getProcAddress("glGetGraphicsResetStatusARB"); + if (!GetnCompressedTexImage) GetnCompressedTexImage = (PFNGLGETNCOMPRESSEDTEXIMAGEPROC_MT)cmgr->getProcAddress("glGetnCompressedTexImage"); + if (!GetnCompressedTexImage) GetnCompressedTexImage = (PFNGLGETNCOMPRESSEDTEXIMAGEPROC_MT)cmgr->getProcAddress("glGetnCompressedTexImageARB"); + if (!GetnTexImage) GetnTexImage = (PFNGLGETNTEXIMAGEPROC_MT)cmgr->getProcAddress("glGetnTexImage"); + if (!GetnTexImage) GetnTexImage = (PFNGLGETNTEXIMAGEPROC_MT)cmgr->getProcAddress("glGetnTexImageARB"); + if (!GetnUniformdv) GetnUniformdv = (PFNGLGETNUNIFORMDVPROC_MT)cmgr->getProcAddress("glGetnUniformdv"); + if (!GetnUniformdv) GetnUniformdv = (PFNGLGETNUNIFORMDVPROC_MT)cmgr->getProcAddress("glGetnUniformdvARB"); + if (!GetnUniformfv) GetnUniformfv = (PFNGLGETNUNIFORMFVPROC_MT)cmgr->getProcAddress("glGetnUniformfv"); + if (!GetnUniformfv) GetnUniformfv = (PFNGLGETNUNIFORMFVPROC_MT)cmgr->getProcAddress("glGetnUniformfvARB"); + if (!GetnUniformiv) GetnUniformiv = (PFNGLGETNUNIFORMIVPROC_MT)cmgr->getProcAddress("glGetnUniformiv"); + if (!GetnUniformiv) GetnUniformiv = (PFNGLGETNUNIFORMIVPROC_MT)cmgr->getProcAddress("glGetnUniformivARB"); + if (!GetnUniformuiv) GetnUniformuiv = (PFNGLGETNUNIFORMUIVPROC_MT)cmgr->getProcAddress("glGetnUniformuiv"); + if (!GetnUniformuiv) GetnUniformuiv = (PFNGLGETNUNIFORMUIVPROC_MT)cmgr->getProcAddress("glGetnUniformuivARB"); + if (!ReadnPixels) ReadnPixels = (PFNGLREADNPIXELSPROC_MT)cmgr->getProcAddress("glReadnPixels"); + if (!ReadnPixels) ReadnPixels = (PFNGLREADNPIXELSPROC_MT)cmgr->getProcAddress("glReadnPixelsARB"); + if (!TextureBarrier) TextureBarrier = (PFNGLTEXTUREBARRIERPROC_MT)cmgr->getProcAddress("glTextureBarrier"); + if (!SpecializeShader) SpecializeShader = (PFNGLSPECIALIZESHADERPROC_MT)cmgr->getProcAddress("glSpecializeShader"); + if (!SpecializeShader) SpecializeShader = (PFNGLSPECIALIZESHADERPROC_MT)cmgr->getProcAddress("glSpecializeShaderARB"); + if (!MultiDrawArraysIndirectCount) MultiDrawArraysIndirectCount = (PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC_MT)cmgr->getProcAddress("glMultiDrawArraysIndirectCount"); + if (!MultiDrawArraysIndirectCount) MultiDrawArraysIndirectCount = (PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC_MT)cmgr->getProcAddress("glMultiDrawArraysIndirectCountARB"); + if (!MultiDrawElementsIndirectCount) MultiDrawElementsIndirectCount = (PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC_MT)cmgr->getProcAddress("glMultiDrawElementsIndirectCount"); + if (!MultiDrawElementsIndirectCount) MultiDrawElementsIndirectCount = (PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC_MT)cmgr->getProcAddress("glMultiDrawElementsIndirectCountARB"); + if (!PolygonOffsetClamp) PolygonOffsetClamp = (PFNGLPOLYGONOFFSETCLAMPPROC_MT)cmgr->getProcAddress("glPolygonOffsetClamp"); + if (!PrimitiveBoundingBox) PrimitiveBoundingBox = (PFNGLPRIMITIVEBOUNDINGBOXPROC_MT)cmgr->getProcAddress("glPrimitiveBoundingBoxARB"); + if (!GetTextureHandle) GetTextureHandle = (PFNGLGETTEXTUREHANDLEPROC_MT)cmgr->getProcAddress("glGetTextureHandleARB"); + if (!GetTextureSamplerHandle) GetTextureSamplerHandle = (PFNGLGETTEXTURESAMPLERHANDLEPROC_MT)cmgr->getProcAddress("glGetTextureSamplerHandleARB"); + if (!MakeTextureHandleResident) MakeTextureHandleResident = (PFNGLMAKETEXTUREHANDLERESIDENTPROC_MT)cmgr->getProcAddress("glMakeTextureHandleResidentARB"); + if (!MakeTextureHandleNonResident) MakeTextureHandleNonResident = (PFNGLMAKETEXTUREHANDLENONRESIDENTPROC_MT)cmgr->getProcAddress("glMakeTextureHandleNonResidentARB"); + if (!GetImageHandle) GetImageHandle = (PFNGLGETIMAGEHANDLEPROC_MT)cmgr->getProcAddress("glGetImageHandleARB"); + if (!MakeImageHandleResident) MakeImageHandleResident = (PFNGLMAKEIMAGEHANDLERESIDENTPROC_MT)cmgr->getProcAddress("glMakeImageHandleResidentARB"); + if (!MakeImageHandleNonResident) MakeImageHandleNonResident = (PFNGLMAKEIMAGEHANDLENONRESIDENTPROC_MT)cmgr->getProcAddress("glMakeImageHandleNonResidentARB"); + if (!UniformHandleui64) UniformHandleui64 = (PFNGLUNIFORMHANDLEUI64PROC_MT)cmgr->getProcAddress("glUniformHandleui64ARB"); + if (!UniformHandleui64v) UniformHandleui64v = (PFNGLUNIFORMHANDLEUI64VPROC_MT)cmgr->getProcAddress("glUniformHandleui64vARB"); + if (!ProgramUniformHandleui64) ProgramUniformHandleui64 = (PFNGLPROGRAMUNIFORMHANDLEUI64PROC_MT)cmgr->getProcAddress("glProgramUniformHandleui64ARB"); + if (!ProgramUniformHandleui64v) ProgramUniformHandleui64v = (PFNGLPROGRAMUNIFORMHANDLEUI64VPROC_MT)cmgr->getProcAddress("glProgramUniformHandleui64vARB"); + if (!IsTextureHandleResident) IsTextureHandleResident = (PFNGLISTEXTUREHANDLERESIDENTPROC_MT)cmgr->getProcAddress("glIsTextureHandleResidentARB"); + if (!IsImageHandleResident) IsImageHandleResident = (PFNGLISIMAGEHANDLERESIDENTPROC_MT)cmgr->getProcAddress("glIsImageHandleResidentARB"); + if (!VertexAttribL1ui64) VertexAttribL1ui64 = (PFNGLVERTEXATTRIBL1UI64PROC_MT)cmgr->getProcAddress("glVertexAttribL1ui64ARB"); + if (!VertexAttribL1ui64v) VertexAttribL1ui64v = (PFNGLVERTEXATTRIBL1UI64VPROC_MT)cmgr->getProcAddress("glVertexAttribL1ui64vARB"); + if (!GetVertexAttribLui64v) GetVertexAttribLui64v = (PFNGLGETVERTEXATTRIBLUI64VPROC_MT)cmgr->getProcAddress("glGetVertexAttribLui64vARB"); + if (!CreateSyncFromCLevent) CreateSyncFromCLevent = (PFNGLCREATESYNCFROMCLEVENTPROC_MT)cmgr->getProcAddress("glCreateSyncFromCLeventARB"); + if (!DispatchComputeGroupSize) DispatchComputeGroupSize = (PFNGLDISPATCHCOMPUTEGROUPSIZEPROC_MT)cmgr->getProcAddress("glDispatchComputeGroupSizeARB"); + if (!FramebufferTextureFace) FramebufferTextureFace = (PFNGLFRAMEBUFFERTEXTUREFACEPROC_MT)cmgr->getProcAddress("glFramebufferTextureFaceARB"); + if (!Uniform1i64) Uniform1i64 = (PFNGLUNIFORM1I64PROC_MT)cmgr->getProcAddress("glUniform1i64ARB"); + if (!Uniform2i64) Uniform2i64 = (PFNGLUNIFORM2I64PROC_MT)cmgr->getProcAddress("glUniform2i64ARB"); + if (!Uniform3i64) Uniform3i64 = (PFNGLUNIFORM3I64PROC_MT)cmgr->getProcAddress("glUniform3i64ARB"); + if (!Uniform4i64) Uniform4i64 = (PFNGLUNIFORM4I64PROC_MT)cmgr->getProcAddress("glUniform4i64ARB"); + if (!Uniform1i64v) Uniform1i64v = (PFNGLUNIFORM1I64VPROC_MT)cmgr->getProcAddress("glUniform1i64vARB"); + if (!Uniform2i64v) Uniform2i64v = (PFNGLUNIFORM2I64VPROC_MT)cmgr->getProcAddress("glUniform2i64vARB"); + if (!Uniform3i64v) Uniform3i64v = (PFNGLUNIFORM3I64VPROC_MT)cmgr->getProcAddress("glUniform3i64vARB"); + if (!Uniform4i64v) Uniform4i64v = (PFNGLUNIFORM4I64VPROC_MT)cmgr->getProcAddress("glUniform4i64vARB"); + if (!Uniform1ui64) Uniform1ui64 = (PFNGLUNIFORM1UI64PROC_MT)cmgr->getProcAddress("glUniform1ui64ARB"); + if (!Uniform2ui64) Uniform2ui64 = (PFNGLUNIFORM2UI64PROC_MT)cmgr->getProcAddress("glUniform2ui64ARB"); + if (!Uniform3ui64) Uniform3ui64 = (PFNGLUNIFORM3UI64PROC_MT)cmgr->getProcAddress("glUniform3ui64ARB"); + if (!Uniform4ui64) Uniform4ui64 = (PFNGLUNIFORM4UI64PROC_MT)cmgr->getProcAddress("glUniform4ui64ARB"); + if (!Uniform1ui64v) Uniform1ui64v = (PFNGLUNIFORM1UI64VPROC_MT)cmgr->getProcAddress("glUniform1ui64vARB"); + if (!Uniform2ui64v) Uniform2ui64v = (PFNGLUNIFORM2UI64VPROC_MT)cmgr->getProcAddress("glUniform2ui64vARB"); + if (!Uniform3ui64v) Uniform3ui64v = (PFNGLUNIFORM3UI64VPROC_MT)cmgr->getProcAddress("glUniform3ui64vARB"); + if (!Uniform4ui64v) Uniform4ui64v = (PFNGLUNIFORM4UI64VPROC_MT)cmgr->getProcAddress("glUniform4ui64vARB"); + if (!GetUniformi64v) GetUniformi64v = (PFNGLGETUNIFORMI64VPROC_MT)cmgr->getProcAddress("glGetUniformi64vARB"); + if (!GetUniformui64v) GetUniformui64v = (PFNGLGETUNIFORMUI64VPROC_MT)cmgr->getProcAddress("glGetUniformui64vARB"); + if (!GetnUniformi64v) GetnUniformi64v = (PFNGLGETNUNIFORMI64VPROC_MT)cmgr->getProcAddress("glGetnUniformi64vARB"); + if (!GetnUniformui64v) GetnUniformui64v = (PFNGLGETNUNIFORMUI64VPROC_MT)cmgr->getProcAddress("glGetnUniformui64vARB"); + if (!ProgramUniform1i64) ProgramUniform1i64 = (PFNGLPROGRAMUNIFORM1I64PROC_MT)cmgr->getProcAddress("glProgramUniform1i64ARB"); + if (!ProgramUniform2i64) ProgramUniform2i64 = (PFNGLPROGRAMUNIFORM2I64PROC_MT)cmgr->getProcAddress("glProgramUniform2i64ARB"); + if (!ProgramUniform3i64) ProgramUniform3i64 = (PFNGLPROGRAMUNIFORM3I64PROC_MT)cmgr->getProcAddress("glProgramUniform3i64ARB"); + if (!ProgramUniform4i64) ProgramUniform4i64 = (PFNGLPROGRAMUNIFORM4I64PROC_MT)cmgr->getProcAddress("glProgramUniform4i64ARB"); + if (!ProgramUniform1i64v) ProgramUniform1i64v = (PFNGLPROGRAMUNIFORM1I64VPROC_MT)cmgr->getProcAddress("glProgramUniform1i64vARB"); + if (!ProgramUniform2i64v) ProgramUniform2i64v = (PFNGLPROGRAMUNIFORM2I64VPROC_MT)cmgr->getProcAddress("glProgramUniform2i64vARB"); + if (!ProgramUniform3i64v) ProgramUniform3i64v = (PFNGLPROGRAMUNIFORM3I64VPROC_MT)cmgr->getProcAddress("glProgramUniform3i64vARB"); + if (!ProgramUniform4i64v) ProgramUniform4i64v = (PFNGLPROGRAMUNIFORM4I64VPROC_MT)cmgr->getProcAddress("glProgramUniform4i64vARB"); + if (!ProgramUniform1ui64) ProgramUniform1ui64 = (PFNGLPROGRAMUNIFORM1UI64PROC_MT)cmgr->getProcAddress("glProgramUniform1ui64ARB"); + if (!ProgramUniform2ui64) ProgramUniform2ui64 = (PFNGLPROGRAMUNIFORM2UI64PROC_MT)cmgr->getProcAddress("glProgramUniform2ui64ARB"); + if (!ProgramUniform3ui64) ProgramUniform3ui64 = (PFNGLPROGRAMUNIFORM3UI64PROC_MT)cmgr->getProcAddress("glProgramUniform3ui64ARB"); + if (!ProgramUniform4ui64) ProgramUniform4ui64 = (PFNGLPROGRAMUNIFORM4UI64PROC_MT)cmgr->getProcAddress("glProgramUniform4ui64ARB"); + if (!ProgramUniform1ui64v) ProgramUniform1ui64v = (PFNGLPROGRAMUNIFORM1UI64VPROC_MT)cmgr->getProcAddress("glProgramUniform1ui64vARB"); + if (!ProgramUniform2ui64v) ProgramUniform2ui64v = (PFNGLPROGRAMUNIFORM2UI64VPROC_MT)cmgr->getProcAddress("glProgramUniform2ui64vARB"); + if (!ProgramUniform3ui64v) ProgramUniform3ui64v = (PFNGLPROGRAMUNIFORM3UI64VPROC_MT)cmgr->getProcAddress("glProgramUniform3ui64vARB"); + if (!ProgramUniform4ui64v) ProgramUniform4ui64v = (PFNGLPROGRAMUNIFORM4UI64VPROC_MT)cmgr->getProcAddress("glProgramUniform4ui64vARB"); + if (!MaxShaderCompilerThreads) MaxShaderCompilerThreads = (PFNGLMAXSHADERCOMPILERTHREADSPROC_MT)cmgr->getProcAddress("glMaxShaderCompilerThreadsARB"); + if (!MaxShaderCompilerThreads) MaxShaderCompilerThreads = (PFNGLMAXSHADERCOMPILERTHREADSPROC_MT)cmgr->getProcAddress("glMaxShaderCompilerThreadsKHR"); + if (!FramebufferSampleLocationsfv) FramebufferSampleLocationsfv = (PFNGLFRAMEBUFFERSAMPLELOCATIONSFVPROC_MT)cmgr->getProcAddress("glFramebufferSampleLocationsfvARB"); + if (!NamedFramebufferSampleLocationsfv) NamedFramebufferSampleLocationsfv = (PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVPROC_MT)cmgr->getProcAddress("glNamedFramebufferSampleLocationsfvARB"); + if (!EvaluateDepthValues) EvaluateDepthValues = (PFNGLEVALUATEDEPTHVALUESPROC_MT)cmgr->getProcAddress("glEvaluateDepthValuesARB"); + if (!NamedString) NamedString = (PFNGLNAMEDSTRINGPROC_MT)cmgr->getProcAddress("glNamedStringARB"); + if (!DeleteNamedString) DeleteNamedString = (PFNGLDELETENAMEDSTRINGPROC_MT)cmgr->getProcAddress("glDeleteNamedStringARB"); + if (!CompileShaderInclude) CompileShaderInclude = (PFNGLCOMPILESHADERINCLUDEPROC_MT)cmgr->getProcAddress("glCompileShaderIncludeARB"); + if (!IsNamedString) IsNamedString = (PFNGLISNAMEDSTRINGPROC_MT)cmgr->getProcAddress("glIsNamedStringARB"); + if (!GetNamedString) GetNamedString = (PFNGLGETNAMEDSTRINGPROC_MT)cmgr->getProcAddress("glGetNamedStringARB"); + if (!GetNamedStringiv) GetNamedStringiv = (PFNGLGETNAMEDSTRINGIVPROC_MT)cmgr->getProcAddress("glGetNamedStringivARB"); + if (!BufferPageCommitment) BufferPageCommitment = (PFNGLBUFFERPAGECOMMITMENTPROC_MT)cmgr->getProcAddress("glBufferPageCommitmentARB"); + if (!NamedBufferPageCommitment) NamedBufferPageCommitment = (PFNGLNAMEDBUFFERPAGECOMMITMENTPROC_MT)cmgr->getProcAddress("glNamedBufferPageCommitmentARB"); + if (!TexPageCommitment) TexPageCommitment = (PFNGLTEXPAGECOMMITMENTPROC_MT)cmgr->getProcAddress("glTexPageCommitmentARB"); + + // 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 + std::stringstream ext_ss((char*)ext_str); + std::string tmp; + while (std::getline(ext_ss, tmp, ' ')) + extensions.emplace(tmp); + +} diff --git a/irr/src/os.cpp b/irr/src/os.cpp new file mode 100644 index 000000000..96be8dd63 --- /dev/null +++ b/irr/src/os.cpp @@ -0,0 +1,379 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "os.h" +#include "irrString.h" +#include "irrMath.h" + +#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) +#include +#define bswap_16(X) SDL_Swap16(X) +#define bswap_32(X) SDL_Swap32(X) +#define bswap_64(X) SDL_Swap64(X) +#elif defined(_IRR_WINDOWS_API_) && defined(_MSC_VER) +#include +#define bswap_16(X) _byteswap_ushort(X) +#define bswap_32(X) _byteswap_ulong(X) +#define bswap_64(X) _byteswap_uint64(X) +#elif defined(_IRR_OSX_PLATFORM_) +#include +#define bswap_16(X) OSReadSwapInt16(&X, 0) +#define bswap_32(X) OSReadSwapInt32(&X, 0) +#define bswap_64(X) OSReadSwapInt64(&X, 0) +#elif defined(__FreeBSD__) +#include +#define bswap_16(X) bswap16(X) +#define bswap_32(X) bswap32(X) +#define bswap_64(X) bswap64(X) +#elif defined(__OpenBSD__) +#include +#define bswap_16(X) letoh16(X) +#define bswap_32(X) letoh32(X) +#define bswap_64(X) letoh64(X) +#elif !defined(_IRR_SOLARIS_PLATFORM_) && !defined(__PPC__) && !defined(_IRR_WINDOWS_API_) +#include +#else +#define bswap_16(X) ((((X) & 0xFF) << 8) | (((X) & 0xFF00) >> 8)) +#define bswap_32(X) ((((X) & 0x000000FF) << 24) | (((X) & 0xFF000000) >> 24) | (((X) & 0x0000FF00) << 8) | (((X) & 0x00FF0000) >> 8)) +#define bswap_64(X) ((((X) & 0x00000000000000FF) << 56) | (((X) & 0xFF00000000000000) >> 56) | (((X) & 0x000000000000FF00) << 40) | (((X) & 0x00FF000000000000) >> 40) | (((X) & 0x0000000000FF0000) << 24) | (((X) & 0x0000FF0000000000) >> 24) | (((X) & 0x00000000FF000000) << 8) | (((X) & 0x000000FF00000000) >> 8)) +#endif + +namespace irr +{ +namespace os +{ +u16 Byteswap::byteswap(u16 num) +{ + return bswap_16(num); +} +s16 Byteswap::byteswap(s16 num) +{ + return bswap_16(num); +} +u32 Byteswap::byteswap(u32 num) +{ + return bswap_32(num); +} +s32 Byteswap::byteswap(s32 num) +{ + return bswap_32(num); +} +u64 Byteswap::byteswap(u64 num) +{ + return bswap_64(num); +} +s64 Byteswap::byteswap(s64 num) +{ + return bswap_64(num); +} +f32 Byteswap::byteswap(f32 num) +{ + u32 tmp = IR(num); + tmp = bswap_32(tmp); + return (FR(tmp)); +} +} +} + +#if defined(_IRR_WINDOWS_API_) +// ---------------------------------------------------------------- +// Windows specific functions +// ---------------------------------------------------------------- + +#define WIN32_LEAN_AND_MEAN +#include +#include + +namespace irr +{ +namespace os +{ +//! prints a debuginfo string +void Printer::print(const c8 *message, ELOG_LEVEL ll) +{ + core::stringc tmp(message); + tmp += "\n"; + OutputDebugStringA(tmp.c_str()); + printf("%s", tmp.c_str()); +} + +static LARGE_INTEGER HighPerformanceFreq; +static BOOL HighPerformanceTimerSupport = FALSE; + +void Timer::initTimer() +{ + HighPerformanceTimerSupport = QueryPerformanceFrequency(&HighPerformanceFreq); + initVirtualTimer(); +} + +u32 Timer::getRealTime() +{ + if (HighPerformanceTimerSupport) { + LARGE_INTEGER nTime; + BOOL queriedOK = QueryPerformanceCounter(&nTime); + + if (queriedOK) + return u32((nTime.QuadPart) * 1000 / HighPerformanceFreq.QuadPart); + } + + return GetTickCount(); +} + +} // end namespace os + +#elif defined(_IRR_ANDROID_PLATFORM_) + +// ---------------------------------------------------------------- +// Android version +// ---------------------------------------------------------------- + +#include + +namespace irr +{ +namespace os +{ + +//! prints a debuginfo string +void Printer::print(const c8 *message, ELOG_LEVEL ll) +{ + android_LogPriority LogLevel = ANDROID_LOG_UNKNOWN; + + switch (ll) { + case ELL_DEBUG: + LogLevel = ANDROID_LOG_DEBUG; + break; + case ELL_INFORMATION: + LogLevel = ANDROID_LOG_INFO; + break; + case ELL_WARNING: + LogLevel = ANDROID_LOG_WARN; + break; + case ELL_ERROR: + LogLevel = ANDROID_LOG_ERROR; + break; + default: // ELL_NONE + LogLevel = ANDROID_LOG_VERBOSE; + break; + } + + // Android logcat restricts log-output and cuts the rest of the message away. But we want it all. + // On my device max-len is 1023 (+ 0 byte). Some websites claim a limit of 4096 so maybe different numbers on different devices. + const size_t maxLogLen = 1023; + size_t msgLen = strlen(message); + size_t start = 0; + while (msgLen - start > maxLogLen) { + __android_log_print(LogLevel, "Irrlicht", "%.*s\n", maxLogLen, &message[start]); + start += maxLogLen; + } + __android_log_print(LogLevel, "Irrlicht", "%s\n", &message[start]); +} + +void Timer::initTimer() +{ + initVirtualTimer(); +} + +u32 Timer::getRealTime() +{ + timeval tv; + gettimeofday(&tv, 0); + return (u32)(tv.tv_sec * 1000) + (tv.tv_usec / 1000); +} +} // end namespace os + +#elif defined(_IRR_EMSCRIPTEN_PLATFORM_) + +// ---------------------------------------------------------------- +// emscripten version +// ---------------------------------------------------------------- + +#include +#include +#include + +namespace irr +{ +namespace os +{ + +//! prints a debuginfo string +void Printer::print(const c8 *message, ELOG_LEVEL ll) +{ + int log_level; + switch (ll) { + case ELL_DEBUG: + log_level = 0; + break; + case ELL_INFORMATION: + log_level = 0; + break; + case ELL_WARNING: + log_level = EM_LOG_WARN; + break; + case ELL_ERROR: + log_level = EM_LOG_ERROR; + break; + default: // ELL_NONE + log_level = 0; + break; + } + emscripten_log(log_level, "%s", message); // Note: not adding \n as emscripten_log seems to do that already. +} + +void Timer::initTimer() +{ + initVirtualTimer(); +} + +u32 Timer::getRealTime() +{ + double time = emscripten_get_now(); + return (u32)(time); +} +} // end namespace os + +#else + +// ---------------------------------------------------------------- +// linux/ansi version +// ---------------------------------------------------------------- + +#include +#include +#include + +namespace irr +{ +namespace os +{ + +//! prints a debuginfo string +void Printer::print(const c8 *message, ELOG_LEVEL ll) +{ + printf("%s\n", message); +} + +void Timer::initTimer() +{ + initVirtualTimer(); +} + +u32 Timer::getRealTime() +{ + timeval tv; + gettimeofday(&tv, 0); + return (u32)(tv.tv_sec * 1000) + (tv.tv_usec / 1000); +} +} // end namespace os + +#endif // end linux / emscripten / android / windows + +namespace os +{ +// The platform independent implementation of the printer +ILogger *Printer::Logger = 0; + +void Printer::log(const c8 *message, ELOG_LEVEL ll) +{ + if (Logger) + Logger->log(message, ll); +} + +void Printer::log(const c8 *message, const c8 *hint, ELOG_LEVEL ll) +{ + if (Logger) + Logger->log(message, hint, ll); +} + +void Printer::log(const c8 *message, const io::path &hint, ELOG_LEVEL ll) +{ + if (Logger) + Logger->log(message, hint.c_str(), ll); +} + +// ------------------------------------------------------ +// virtual timer implementation + +f32 Timer::VirtualTimerSpeed = 1.0f; +s32 Timer::VirtualTimerStopCounter = 0; +u32 Timer::LastVirtualTime = 0; +u32 Timer::StartRealTime = 0; +u32 Timer::StaticTime = 0; + +//! returns current virtual time +u32 Timer::getTime() +{ + if (isStopped()) + return LastVirtualTime; + + return LastVirtualTime + (u32)((StaticTime - StartRealTime) * VirtualTimerSpeed); +} + +//! ticks, advances the virtual timer +void Timer::tick() +{ + StaticTime = getRealTime(); +} + +//! sets the current virtual time +void Timer::setTime(u32 time) +{ + StaticTime = getRealTime(); + LastVirtualTime = time; + StartRealTime = StaticTime; +} + +//! stops the virtual timer +void Timer::stopTimer() +{ + if (!isStopped()) { + // stop the virtual timer + LastVirtualTime = getTime(); + } + + --VirtualTimerStopCounter; +} + +//! starts the virtual timer +void Timer::startTimer() +{ + ++VirtualTimerStopCounter; + + if (!isStopped()) { + // restart virtual timer + setTime(LastVirtualTime); + } +} + +//! sets the speed of the virtual timer +void Timer::setSpeed(f32 speed) +{ + setTime(getTime()); + + VirtualTimerSpeed = speed; + if (VirtualTimerSpeed < 0.0f) + VirtualTimerSpeed = 0.0f; +} + +//! gets the speed of the virtual timer +f32 Timer::getSpeed() +{ + return VirtualTimerSpeed; +} + +//! returns if the timer currently is stopped +bool Timer::isStopped() +{ + return VirtualTimerStopCounter < 0; +} + +void Timer::initVirtualTimer() +{ + StaticTime = getRealTime(); + StartRealTime = StaticTime; +} + +} // end namespace os +} // end namespace irr diff --git a/irr/src/os.h b/irr/src/os.h new file mode 100644 index 000000000..fcbaeddd5 --- /dev/null +++ b/irr/src/os.h @@ -0,0 +1,91 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#pragma once + +#include "irrTypes.h" +#include "irrString.h" +#include "path.h" +#include "ILogger.h" +#include "ITimer.h" + +namespace irr +{ + +namespace os +{ +class Byteswap +{ +public: + static u16 byteswap(u16 num); + static s16 byteswap(s16 num); + static u32 byteswap(u32 num); + static s32 byteswap(s32 num); + static u64 byteswap(u64 num); + static s64 byteswap(s64 num); + static f32 byteswap(f32 num); + // prevent accidental swapping of chars + static inline u8 byteswap(u8 num) { return num; } + static inline c8 byteswap(c8 num) { return num; } +}; + +class Printer +{ +public: + // prints out a string to the console out stdout or debug log or whatever + static void print(const c8 *message, ELOG_LEVEL ll = ELL_INFORMATION); + static void log(const c8 *message, ELOG_LEVEL ll = ELL_INFORMATION); + static void log(const wchar_t *message, ELOG_LEVEL ll = ELL_INFORMATION); + + // The string ": " is added between message and hint + static void log(const c8 *message, const c8 *hint, ELOG_LEVEL ll = ELL_INFORMATION); + static void log(const c8 *message, const io::path &hint, ELOG_LEVEL ll = ELL_INFORMATION); + static ILogger *Logger; +}; + +class Timer +{ +public: + //! returns the current time in milliseconds + static u32 getTime(); + + //! initializes the real timer + static void initTimer(); + + //! sets the current virtual (game) time + static void setTime(u32 time); + + //! stops the virtual (game) timer + static void stopTimer(); + + //! starts the game timer + static void startTimer(); + + //! sets the speed of the virtual timer + static void setSpeed(f32 speed); + + //! gets the speed of the virtual timer + static f32 getSpeed(); + + //! returns if the timer currently is stopped + static bool isStopped(); + + //! makes the virtual timer update the time value based on the real time + static void tick(); + + //! returns the current real time in milliseconds + static u32 getRealTime(); + +private: + static void initVirtualTimer(); + + static f32 VirtualTimerSpeed; + static s32 VirtualTimerStopCounter; + static u32 StartRealTime; + static u32 LastVirtualTime; + static u32 StaticTime; +}; + +} // end namespace os +} // end namespace irr diff --git a/irr/src/vendor/gl.h b/irr/src/vendor/gl.h new file mode 100644 index 000000000..d1aae08ea --- /dev/null +++ b/irr/src/vendor/gl.h @@ -0,0 +1,2098 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef __gl_h_ +#define __gl_h_ + +/********************************************************************** + * Begin system-specific stuff. + */ + +#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) +#define __WIN32__ +#endif + +#if defined(__WIN32__) && !defined(__CYGWIN__) +# define GLAPI extern +# if !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) + /* Win32 but not WinCE */ +# define GLAPIENTRY __stdcall +# else +# define GLAPIENTRY +# endif +#elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native windows opengl32 */ +# define GLAPI extern +# define GLAPIENTRY __stdcall +#elif (defined(__GNUC__) && __GNUC__ >= 4) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define GLAPI __attribute__((visibility("default"))) +# define GLAPIENTRY +#endif /* WIN32 && !CYGWIN */ + +/* + * WINDOWS: Include windows.h here to define APIENTRY. + * It is also useful when applications include this file by + * including only glut.h, since glut.h depends on windows.h. + * Applications needing to include windows.h with parms other + * than "WIN32_LEAN_AND_MEAN" may include windows.h before + * glut.h or gl.h. + */ +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#include +#endif + +#ifndef GLAPI +#define GLAPI extern +#endif + +#ifndef GLAPIENTRY +#define GLAPIENTRY +#endif + +#ifndef APIENTRY +#define APIENTRY GLAPIENTRY +#endif + +/* "P" suffix to be used for a pointer to a function */ +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif + +#ifndef GLAPIENTRYP +#define GLAPIENTRYP GLAPIENTRY * +#endif + +/* + * End system-specific stuff. + **********************************************************************/ + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define GL_VERSION_1_1 1 +#define GL_VERSION_1_2 1 +#define GL_VERSION_1_3 1 +#define GL_ARB_imaging 1 + + +/* + * Datatypes + */ +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef unsigned int GLbitfield; +typedef void GLvoid; +typedef signed char GLbyte; /* 1-byte signed */ +typedef short GLshort; /* 2-byte signed */ +typedef int GLint; /* 4-byte signed */ +typedef unsigned char GLubyte; /* 1-byte unsigned */ +typedef unsigned short GLushort; /* 2-byte unsigned */ +typedef unsigned int GLuint; /* 4-byte unsigned */ +typedef int GLsizei; /* 4-byte signed */ +typedef float GLfloat; /* single precision float */ +typedef float GLclampf; /* single precision float in [0,1] */ +typedef double GLdouble; /* double precision float */ +typedef double GLclampd; /* double precision float in [0,1] */ + + + +/* + * Constants + */ + +/* Boolean values */ +#define GL_FALSE 0 +#define GL_TRUE 1 + +/* Data types */ +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_2_BYTES 0x1407 +#define GL_3_BYTES 0x1408 +#define GL_4_BYTES 0x1409 +#define GL_DOUBLE 0x140A + +/* Primitives */ +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_QUADS 0x0007 +#define GL_QUAD_STRIP 0x0008 +#define GL_POLYGON 0x0009 + +/* Vertex Arrays */ +#define GL_VERTEX_ARRAY 0x8074 +#define GL_NORMAL_ARRAY 0x8075 +#define GL_COLOR_ARRAY 0x8076 +#define GL_INDEX_ARRAY 0x8077 +#define GL_TEXTURE_COORD_ARRAY 0x8078 +#define GL_EDGE_FLAG_ARRAY 0x8079 +#define GL_VERTEX_ARRAY_SIZE 0x807A +#define GL_VERTEX_ARRAY_TYPE 0x807B +#define GL_VERTEX_ARRAY_STRIDE 0x807C +#define GL_NORMAL_ARRAY_TYPE 0x807E +#define GL_NORMAL_ARRAY_STRIDE 0x807F +#define GL_COLOR_ARRAY_SIZE 0x8081 +#define GL_COLOR_ARRAY_TYPE 0x8082 +#define GL_COLOR_ARRAY_STRIDE 0x8083 +#define GL_INDEX_ARRAY_TYPE 0x8085 +#define GL_INDEX_ARRAY_STRIDE 0x8086 +#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A +#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C +#define GL_VERTEX_ARRAY_POINTER 0x808E +#define GL_NORMAL_ARRAY_POINTER 0x808F +#define GL_COLOR_ARRAY_POINTER 0x8090 +#define GL_INDEX_ARRAY_POINTER 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 +#define GL_V2F 0x2A20 +#define GL_V3F 0x2A21 +#define GL_C4UB_V2F 0x2A22 +#define GL_C4UB_V3F 0x2A23 +#define GL_C3F_V3F 0x2A24 +#define GL_N3F_V3F 0x2A25 +#define GL_C4F_N3F_V3F 0x2A26 +#define GL_T2F_V3F 0x2A27 +#define GL_T4F_V4F 0x2A28 +#define GL_T2F_C4UB_V3F 0x2A29 +#define GL_T2F_C3F_V3F 0x2A2A +#define GL_T2F_N3F_V3F 0x2A2B +#define GL_T2F_C4F_N3F_V3F 0x2A2C +#define GL_T4F_C4F_N3F_V4F 0x2A2D + +/* Matrix Mode */ +#define GL_MATRIX_MODE 0x0BA0 +#define GL_MODELVIEW 0x1700 +#define GL_PROJECTION 0x1701 +#define GL_TEXTURE 0x1702 + +/* Points */ +#define GL_POINT_SMOOTH 0x0B10 +#define GL_POINT_SIZE 0x0B11 +#define GL_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_POINT_SIZE_RANGE 0x0B12 + +/* Lines */ +#define GL_LINE_SMOOTH 0x0B20 +#define GL_LINE_STIPPLE 0x0B24 +#define GL_LINE_STIPPLE_PATTERN 0x0B25 +#define GL_LINE_STIPPLE_REPEAT 0x0B26 +#define GL_LINE_WIDTH 0x0B21 +#define GL_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_LINE_WIDTH_RANGE 0x0B22 + +/* Polygons */ +#define GL_POINT 0x1B00 +#define GL_LINE 0x1B01 +#define GL_FILL 0x1B02 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_POLYGON_MODE 0x0B40 +#define GL_POLYGON_SMOOTH 0x0B41 +#define GL_POLYGON_STIPPLE 0x0B42 +#define GL_EDGE_FLAG 0x0B43 +#define GL_CULL_FACE 0x0B44 +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_POINT 0x2A01 +#define GL_POLYGON_OFFSET_LINE 0x2A02 +#define GL_POLYGON_OFFSET_FILL 0x8037 + +/* Display Lists */ +#define GL_COMPILE 0x1300 +#define GL_COMPILE_AND_EXECUTE 0x1301 +#define GL_LIST_BASE 0x0B32 +#define GL_LIST_INDEX 0x0B33 +#define GL_LIST_MODE 0x0B30 + +/* Depth buffer */ +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_DEPTH_TEST 0x0B71 +#define GL_DEPTH_BITS 0x0D56 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_COMPONENT 0x1902 + +/* Lighting */ +#define GL_LIGHTING 0x0B50 +#define GL_LIGHT0 0x4000 +#define GL_LIGHT1 0x4001 +#define GL_LIGHT2 0x4002 +#define GL_LIGHT3 0x4003 +#define GL_LIGHT4 0x4004 +#define GL_LIGHT5 0x4005 +#define GL_LIGHT6 0x4006 +#define GL_LIGHT7 0x4007 +#define GL_SPOT_EXPONENT 0x1205 +#define GL_SPOT_CUTOFF 0x1206 +#define GL_CONSTANT_ATTENUATION 0x1207 +#define GL_LINEAR_ATTENUATION 0x1208 +#define GL_QUADRATIC_ATTENUATION 0x1209 +#define GL_AMBIENT 0x1200 +#define GL_DIFFUSE 0x1201 +#define GL_SPECULAR 0x1202 +#define GL_SHININESS 0x1601 +#define GL_EMISSION 0x1600 +#define GL_POSITION 0x1203 +#define GL_SPOT_DIRECTION 0x1204 +#define GL_AMBIENT_AND_DIFFUSE 0x1602 +#define GL_COLOR_INDEXES 0x1603 +#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 +#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 +#define GL_LIGHT_MODEL_AMBIENT 0x0B53 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_SHADE_MODEL 0x0B54 +#define GL_FLAT 0x1D00 +#define GL_SMOOTH 0x1D01 +#define GL_COLOR_MATERIAL 0x0B57 +#define GL_COLOR_MATERIAL_FACE 0x0B55 +#define GL_COLOR_MATERIAL_PARAMETER 0x0B56 +#define GL_NORMALIZE 0x0BA1 + +/* User clipping planes */ +#define GL_CLIP_PLANE0 0x3000 +#define GL_CLIP_PLANE1 0x3001 +#define GL_CLIP_PLANE2 0x3002 +#define GL_CLIP_PLANE3 0x3003 +#define GL_CLIP_PLANE4 0x3004 +#define GL_CLIP_PLANE5 0x3005 + +/* Accumulation buffer */ +#define GL_ACCUM_RED_BITS 0x0D58 +#define GL_ACCUM_GREEN_BITS 0x0D59 +#define GL_ACCUM_BLUE_BITS 0x0D5A +#define GL_ACCUM_ALPHA_BITS 0x0D5B +#define GL_ACCUM_CLEAR_VALUE 0x0B80 +#define GL_ACCUM 0x0100 +#define GL_ADD 0x0104 +#define GL_LOAD 0x0101 +#define GL_MULT 0x0103 +#define GL_RETURN 0x0102 + +/* Alpha testing */ +#define GL_ALPHA_TEST 0x0BC0 +#define GL_ALPHA_TEST_REF 0x0BC2 +#define GL_ALPHA_TEST_FUNC 0x0BC1 + +/* Blending */ +#define GL_BLEND 0x0BE2 +#define GL_BLEND_SRC 0x0BE1 +#define GL_BLEND_DST 0x0BE0 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 + +/* Render Mode */ +#define GL_FEEDBACK 0x1C01 +#define GL_RENDER 0x1C00 +#define GL_SELECT 0x1C02 + +/* Feedback */ +#define GL_2D 0x0600 +#define GL_3D 0x0601 +#define GL_3D_COLOR 0x0602 +#define GL_3D_COLOR_TEXTURE 0x0603 +#define GL_4D_COLOR_TEXTURE 0x0604 +#define GL_POINT_TOKEN 0x0701 +#define GL_LINE_TOKEN 0x0702 +#define GL_LINE_RESET_TOKEN 0x0707 +#define GL_POLYGON_TOKEN 0x0703 +#define GL_BITMAP_TOKEN 0x0704 +#define GL_DRAW_PIXEL_TOKEN 0x0705 +#define GL_COPY_PIXEL_TOKEN 0x0706 +#define GL_PASS_THROUGH_TOKEN 0x0700 +#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 +#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 +#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 + +/* Selection */ +#define GL_SELECTION_BUFFER_POINTER 0x0DF3 +#define GL_SELECTION_BUFFER_SIZE 0x0DF4 + +/* Fog */ +#define GL_FOG 0x0B60 +#define GL_FOG_MODE 0x0B65 +#define GL_FOG_DENSITY 0x0B62 +#define GL_FOG_COLOR 0x0B66 +#define GL_FOG_INDEX 0x0B61 +#define GL_FOG_START 0x0B63 +#define GL_FOG_END 0x0B64 +#define GL_LINEAR 0x2601 +#define GL_EXP 0x0800 +#define GL_EXP2 0x0801 + +/* Logic Ops */ +#define GL_LOGIC_OP 0x0BF1 +#define GL_INDEX_LOGIC_OP 0x0BF1 +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_CLEAR 0x1500 +#define GL_SET 0x150F +#define GL_COPY 0x1503 +#define GL_COPY_INVERTED 0x150C +#define GL_NOOP 0x1505 +#define GL_INVERT 0x150A +#define GL_AND 0x1501 +#define GL_NAND 0x150E +#define GL_OR 0x1507 +#define GL_NOR 0x1508 +#define GL_XOR 0x1506 +#define GL_EQUIV 0x1509 +#define GL_AND_REVERSE 0x1502 +#define GL_AND_INVERTED 0x1504 +#define GL_OR_REVERSE 0x150B +#define GL_OR_INVERTED 0x150D + +/* Stencil */ +#define GL_STENCIL_BITS 0x0D57 +#define GL_STENCIL_TEST 0x0B90 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_INDEX 0x1901 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 + +/* Buffers, Pixel Drawing/Reading */ +#define GL_NONE 0 +#define GL_LEFT 0x0406 +#define GL_RIGHT 0x0407 +/*GL_FRONT 0x0404 */ +/*GL_BACK 0x0405 */ +/*GL_FRONT_AND_BACK 0x0408 */ +#define GL_FRONT_LEFT 0x0400 +#define GL_FRONT_RIGHT 0x0401 +#define GL_BACK_LEFT 0x0402 +#define GL_BACK_RIGHT 0x0403 +#define GL_AUX0 0x0409 +#define GL_AUX1 0x040A +#define GL_AUX2 0x040B +#define GL_AUX3 0x040C +#define GL_COLOR_INDEX 0x1900 +#define GL_RED 0x1903 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_ALPHA 0x1906 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_ALPHA_BITS 0x0D55 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_INDEX_BITS 0x0D51 +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_AUX_BUFFERS 0x0C00 +#define GL_READ_BUFFER 0x0C02 +#define GL_DRAW_BUFFER 0x0C01 +#define GL_DOUBLEBUFFER 0x0C32 +#define GL_STEREO 0x0C33 +#define GL_BITMAP 0x1A00 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_DITHER 0x0BD0 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 + +/* Implementation limits */ +#define GL_MAX_LIST_NESTING 0x0B31 +#define GL_MAX_EVAL_ORDER 0x0D30 +#define GL_MAX_LIGHTS 0x0D31 +#define GL_MAX_CLIP_PLANES 0x0D32 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_PIXEL_MAP_TABLE 0x0D34 +#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 +#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 +#define GL_MAX_NAME_STACK_DEPTH 0x0D37 +#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 +#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B + +/* Gets */ +#define GL_ATTRIB_STACK_DEPTH 0x0BB0 +#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_CURRENT_INDEX 0x0B01 +#define GL_CURRENT_COLOR 0x0B00 +#define GL_CURRENT_NORMAL 0x0B02 +#define GL_CURRENT_RASTER_COLOR 0x0B04 +#define GL_CURRENT_RASTER_DISTANCE 0x0B09 +#define GL_CURRENT_RASTER_INDEX 0x0B05 +#define GL_CURRENT_RASTER_POSITION 0x0B07 +#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 +#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 +#define GL_CURRENT_TEXTURE_COORDS 0x0B03 +#define GL_INDEX_CLEAR_VALUE 0x0C20 +#define GL_INDEX_MODE 0x0C30 +#define GL_INDEX_WRITEMASK 0x0C21 +#define GL_MODELVIEW_MATRIX 0x0BA6 +#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 +#define GL_NAME_STACK_DEPTH 0x0D70 +#define GL_PROJECTION_MATRIX 0x0BA7 +#define GL_PROJECTION_STACK_DEPTH 0x0BA4 +#define GL_RENDER_MODE 0x0C40 +#define GL_RGBA_MODE 0x0C31 +#define GL_TEXTURE_MATRIX 0x0BA8 +#define GL_TEXTURE_STACK_DEPTH 0x0BA5 +#define GL_VIEWPORT 0x0BA2 + +/* Evaluators */ +#define GL_AUTO_NORMAL 0x0D80 +#define GL_MAP1_COLOR_4 0x0D90 +#define GL_MAP1_INDEX 0x0D91 +#define GL_MAP1_NORMAL 0x0D92 +#define GL_MAP1_TEXTURE_COORD_1 0x0D93 +#define GL_MAP1_TEXTURE_COORD_2 0x0D94 +#define GL_MAP1_TEXTURE_COORD_3 0x0D95 +#define GL_MAP1_TEXTURE_COORD_4 0x0D96 +#define GL_MAP1_VERTEX_3 0x0D97 +#define GL_MAP1_VERTEX_4 0x0D98 +#define GL_MAP2_COLOR_4 0x0DB0 +#define GL_MAP2_INDEX 0x0DB1 +#define GL_MAP2_NORMAL 0x0DB2 +#define GL_MAP2_TEXTURE_COORD_1 0x0DB3 +#define GL_MAP2_TEXTURE_COORD_2 0x0DB4 +#define GL_MAP2_TEXTURE_COORD_3 0x0DB5 +#define GL_MAP2_TEXTURE_COORD_4 0x0DB6 +#define GL_MAP2_VERTEX_3 0x0DB7 +#define GL_MAP2_VERTEX_4 0x0DB8 +#define GL_MAP1_GRID_DOMAIN 0x0DD0 +#define GL_MAP1_GRID_SEGMENTS 0x0DD1 +#define GL_MAP2_GRID_DOMAIN 0x0DD2 +#define GL_MAP2_GRID_SEGMENTS 0x0DD3 +#define GL_COEFF 0x0A00 +#define GL_ORDER 0x0A01 +#define GL_DOMAIN 0x0A02 + +/* Hints */ +#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 +#define GL_POINT_SMOOTH_HINT 0x0C51 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_POLYGON_SMOOTH_HINT 0x0C53 +#define GL_FOG_HINT 0x0C54 +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 + +/* Scissor box */ +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 + +/* Pixel Mode / Transfer */ +#define GL_MAP_COLOR 0x0D10 +#define GL_MAP_STENCIL 0x0D11 +#define GL_INDEX_SHIFT 0x0D12 +#define GL_INDEX_OFFSET 0x0D13 +#define GL_RED_SCALE 0x0D14 +#define GL_RED_BIAS 0x0D15 +#define GL_GREEN_SCALE 0x0D18 +#define GL_GREEN_BIAS 0x0D19 +#define GL_BLUE_SCALE 0x0D1A +#define GL_BLUE_BIAS 0x0D1B +#define GL_ALPHA_SCALE 0x0D1C +#define GL_ALPHA_BIAS 0x0D1D +#define GL_DEPTH_SCALE 0x0D1E +#define GL_DEPTH_BIAS 0x0D1F +#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 +#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 +#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 +#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 +#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 +#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 +#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 +#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 +#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 +#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 +#define GL_PIXEL_MAP_S_TO_S 0x0C71 +#define GL_PIXEL_MAP_I_TO_I 0x0C70 +#define GL_PIXEL_MAP_I_TO_R 0x0C72 +#define GL_PIXEL_MAP_I_TO_G 0x0C73 +#define GL_PIXEL_MAP_I_TO_B 0x0C74 +#define GL_PIXEL_MAP_I_TO_A 0x0C75 +#define GL_PIXEL_MAP_R_TO_R 0x0C76 +#define GL_PIXEL_MAP_G_TO_G 0x0C77 +#define GL_PIXEL_MAP_B_TO_B 0x0C78 +#define GL_PIXEL_MAP_A_TO_A 0x0C79 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_PACK_LSB_FIRST 0x0D01 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SWAP_BYTES 0x0D00 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_UNPACK_LSB_FIRST 0x0CF1 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SWAP_BYTES 0x0CF0 +#define GL_ZOOM_X 0x0D16 +#define GL_ZOOM_Y 0x0D17 + +/* Texture mapping */ +#define GL_TEXTURE_ENV 0x2300 +#define GL_TEXTURE_ENV_MODE 0x2200 +#define GL_TEXTURE_1D 0x0DE0 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_ENV_COLOR 0x2201 +#define GL_TEXTURE_GEN_S 0x0C60 +#define GL_TEXTURE_GEN_T 0x0C61 +#define GL_TEXTURE_GEN_R 0x0C62 +#define GL_TEXTURE_GEN_Q 0x0C63 +#define GL_TEXTURE_GEN_MODE 0x2500 +#define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_BORDER 0x1005 +#define GL_TEXTURE_COMPONENTS 0x1003 +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE 0x8061 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_OBJECT_LINEAR 0x2401 +#define GL_OBJECT_PLANE 0x2501 +#define GL_EYE_LINEAR 0x2400 +#define GL_EYE_PLANE 0x2502 +#define GL_SPHERE_MAP 0x2402 +#define GL_DECAL 0x2101 +#define GL_MODULATE 0x2100 +#define GL_NEAREST 0x2600 +#define GL_REPEAT 0x2901 +#define GL_CLAMP 0x2900 +#define GL_S 0x2000 +#define GL_T 0x2001 +#define GL_R 0x2002 +#define GL_Q 0x2003 + +/* Utility */ +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 + +/* Errors */ +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_OUT_OF_MEMORY 0x0505 + +/* glPush/PopAttrib bits */ +#define GL_CURRENT_BIT 0x00000001 +#define GL_POINT_BIT 0x00000002 +#define GL_LINE_BIT 0x00000004 +#define GL_POLYGON_BIT 0x00000008 +#define GL_POLYGON_STIPPLE_BIT 0x00000010 +#define GL_PIXEL_MODE_BIT 0x00000020 +#define GL_LIGHTING_BIT 0x00000040 +#define GL_FOG_BIT 0x00000080 +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_ACCUM_BUFFER_BIT 0x00000200 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_VIEWPORT_BIT 0x00000800 +#define GL_TRANSFORM_BIT 0x00001000 +#define GL_ENABLE_BIT 0x00002000 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_HINT_BIT 0x00008000 +#define GL_EVAL_BIT 0x00010000 +#define GL_LIST_BIT 0x00020000 +#define GL_TEXTURE_BIT 0x00040000 +#define GL_SCISSOR_BIT 0x00080000 +#define GL_ALL_ATTRIB_BITS 0xFFFFFFFF + + +/* OpenGL 1.1 */ +#define GL_PROXY_TEXTURE_1D 0x8063 +#define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_TEXTURE_PRIORITY 0x8066 +#define GL_TEXTURE_RESIDENT 0x8067 +#define GL_TEXTURE_BINDING_1D 0x8068 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_ALPHA4 0x803B +#define GL_ALPHA8 0x803C +#define GL_ALPHA12 0x803D +#define GL_ALPHA16 0x803E +#define GL_LUMINANCE4 0x803F +#define GL_LUMINANCE8 0x8040 +#define GL_LUMINANCE12 0x8041 +#define GL_LUMINANCE16 0x8042 +#define GL_LUMINANCE4_ALPHA4 0x8043 +#define GL_LUMINANCE6_ALPHA2 0x8044 +#define GL_LUMINANCE8_ALPHA8 0x8045 +#define GL_LUMINANCE12_ALPHA4 0x8046 +#define GL_LUMINANCE12_ALPHA12 0x8047 +#define GL_LUMINANCE16_ALPHA16 0x8048 +#define GL_INTENSITY 0x8049 +#define GL_INTENSITY4 0x804A +#define GL_INTENSITY8 0x804B +#define GL_INTENSITY12 0x804C +#define GL_INTENSITY16 0x804D +#define GL_R3_G3_B2 0x2A10 +#define GL_RGB4 0x804F +#define GL_RGB5 0x8050 +#define GL_RGB8 0x8051 +#define GL_RGB10 0x8052 +#define GL_RGB12 0x8053 +#define GL_RGB16 0x8054 +#define GL_RGBA2 0x8055 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_RGBA12 0x805A +#define GL_RGBA16 0x805B +#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 +#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 +#define GL_ALL_CLIENT_ATTRIB_BITS 0xFFFFFFFF +#define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF + + + +/* + * Miscellaneous + */ + +GLAPI void GLAPIENTRY glClearIndex( GLfloat c ); + +GLAPI void GLAPIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); + +GLAPI void GLAPIENTRY glClear( GLbitfield mask ); + +GLAPI void GLAPIENTRY glIndexMask( GLuint mask ); + +GLAPI void GLAPIENTRY glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ); + +GLAPI void GLAPIENTRY glAlphaFunc( GLenum func, GLclampf ref ); + +GLAPI void GLAPIENTRY glBlendFunc( GLenum sfactor, GLenum dfactor ); + +GLAPI void GLAPIENTRY glLogicOp( GLenum opcode ); + +GLAPI void GLAPIENTRY glCullFace( GLenum mode ); + +GLAPI void GLAPIENTRY glFrontFace( GLenum mode ); + +GLAPI void GLAPIENTRY glPointSize( GLfloat size ); + +GLAPI void GLAPIENTRY glLineWidth( GLfloat width ); + +GLAPI void GLAPIENTRY glLineStipple( GLint factor, GLushort pattern ); + +GLAPI void GLAPIENTRY glPolygonMode( GLenum face, GLenum mode ); + +GLAPI void GLAPIENTRY glPolygonOffset( GLfloat factor, GLfloat units ); + +GLAPI void GLAPIENTRY glPolygonStipple( const GLubyte *mask ); + +GLAPI void GLAPIENTRY glGetPolygonStipple( GLubyte *mask ); + +GLAPI void GLAPIENTRY glEdgeFlag( GLboolean flag ); + +GLAPI void GLAPIENTRY glEdgeFlagv( const GLboolean *flag ); + +GLAPI void GLAPIENTRY glScissor( GLint x, GLint y, GLsizei width, GLsizei height); + +GLAPI void GLAPIENTRY glClipPlane( GLenum plane, const GLdouble *equation ); + +GLAPI void GLAPIENTRY glGetClipPlane( GLenum plane, GLdouble *equation ); + +GLAPI void GLAPIENTRY glDrawBuffer( GLenum mode ); + +GLAPI void GLAPIENTRY glReadBuffer( GLenum mode ); + +GLAPI void GLAPIENTRY glEnable( GLenum cap ); + +GLAPI void GLAPIENTRY glDisable( GLenum cap ); + +GLAPI GLboolean GLAPIENTRY glIsEnabled( GLenum cap ); + + +GLAPI void GLAPIENTRY glEnableClientState( GLenum cap ); /* 1.1 */ + +GLAPI void GLAPIENTRY glDisableClientState( GLenum cap ); /* 1.1 */ + + +GLAPI void GLAPIENTRY glGetBooleanv( GLenum pname, GLboolean *params ); + +GLAPI void GLAPIENTRY glGetDoublev( GLenum pname, GLdouble *params ); + +GLAPI void GLAPIENTRY glGetFloatv( GLenum pname, GLfloat *params ); + +GLAPI void GLAPIENTRY glGetIntegerv( GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glPushAttrib( GLbitfield mask ); + +GLAPI void GLAPIENTRY glPopAttrib( void ); + + +GLAPI void GLAPIENTRY glPushClientAttrib( GLbitfield mask ); /* 1.1 */ + +GLAPI void GLAPIENTRY glPopClientAttrib( void ); /* 1.1 */ + + +GLAPI GLint GLAPIENTRY glRenderMode( GLenum mode ); + +GLAPI GLenum GLAPIENTRY glGetError( void ); + +GLAPI const GLubyte * GLAPIENTRY glGetString( GLenum name ); + +GLAPI void GLAPIENTRY glFinish( void ); + +GLAPI void GLAPIENTRY glFlush( void ); + +GLAPI void GLAPIENTRY glHint( GLenum target, GLenum mode ); + + +/* + * Depth Buffer + */ + +GLAPI void GLAPIENTRY glClearDepth( GLclampd depth ); + +GLAPI void GLAPIENTRY glDepthFunc( GLenum func ); + +GLAPI void GLAPIENTRY glDepthMask( GLboolean flag ); + +GLAPI void GLAPIENTRY glDepthRange( GLclampd near_val, GLclampd far_val ); + + +/* + * Accumulation Buffer + */ + +GLAPI void GLAPIENTRY glClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); + +GLAPI void GLAPIENTRY glAccum( GLenum op, GLfloat value ); + + +/* + * Transformation + */ + +GLAPI void GLAPIENTRY glMatrixMode( GLenum mode ); + +GLAPI void GLAPIENTRY glOrtho( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble near_val, GLdouble far_val ); + +GLAPI void GLAPIENTRY glFrustum( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble near_val, GLdouble far_val ); + +GLAPI void GLAPIENTRY glViewport( GLint x, GLint y, + GLsizei width, GLsizei height ); + +GLAPI void GLAPIENTRY glPushMatrix( void ); + +GLAPI void GLAPIENTRY glPopMatrix( void ); + +GLAPI void GLAPIENTRY glLoadIdentity( void ); + +GLAPI void GLAPIENTRY glLoadMatrixd( const GLdouble *m ); +GLAPI void GLAPIENTRY glLoadMatrixf( const GLfloat *m ); + +GLAPI void GLAPIENTRY glMultMatrixd( const GLdouble *m ); +GLAPI void GLAPIENTRY glMultMatrixf( const GLfloat *m ); + +GLAPI void GLAPIENTRY glRotated( GLdouble angle, + GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glRotatef( GLfloat angle, + GLfloat x, GLfloat y, GLfloat z ); + +GLAPI void GLAPIENTRY glScaled( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glScalef( GLfloat x, GLfloat y, GLfloat z ); + +GLAPI void GLAPIENTRY glTranslated( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glTranslatef( GLfloat x, GLfloat y, GLfloat z ); + + +/* + * Display Lists + */ + +GLAPI GLboolean GLAPIENTRY glIsList( GLuint list ); + +GLAPI void GLAPIENTRY glDeleteLists( GLuint list, GLsizei range ); + +GLAPI GLuint GLAPIENTRY glGenLists( GLsizei range ); + +GLAPI void GLAPIENTRY glNewList( GLuint list, GLenum mode ); + +GLAPI void GLAPIENTRY glEndList( void ); + +GLAPI void GLAPIENTRY glCallList( GLuint list ); + +GLAPI void GLAPIENTRY glCallLists( GLsizei n, GLenum type, + const GLvoid *lists ); + +GLAPI void GLAPIENTRY glListBase( GLuint base ); + + +/* + * Drawing Functions + */ + +GLAPI void GLAPIENTRY glBegin( GLenum mode ); + +GLAPI void GLAPIENTRY glEnd( void ); + + +GLAPI void GLAPIENTRY glVertex2d( GLdouble x, GLdouble y ); +GLAPI void GLAPIENTRY glVertex2f( GLfloat x, GLfloat y ); +GLAPI void GLAPIENTRY glVertex2i( GLint x, GLint y ); +GLAPI void GLAPIENTRY glVertex2s( GLshort x, GLshort y ); + +GLAPI void GLAPIENTRY glVertex3d( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glVertex3f( GLfloat x, GLfloat y, GLfloat z ); +GLAPI void GLAPIENTRY glVertex3i( GLint x, GLint y, GLint z ); +GLAPI void GLAPIENTRY glVertex3s( GLshort x, GLshort y, GLshort z ); + +GLAPI void GLAPIENTRY glVertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); +GLAPI void GLAPIENTRY glVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); +GLAPI void GLAPIENTRY glVertex4i( GLint x, GLint y, GLint z, GLint w ); +GLAPI void GLAPIENTRY glVertex4s( GLshort x, GLshort y, GLshort z, GLshort w ); + +GLAPI void GLAPIENTRY glVertex2dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glVertex2fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glVertex2iv( const GLint *v ); +GLAPI void GLAPIENTRY glVertex2sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glVertex3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glVertex3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glVertex3iv( const GLint *v ); +GLAPI void GLAPIENTRY glVertex3sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glVertex4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glVertex4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glVertex4iv( const GLint *v ); +GLAPI void GLAPIENTRY glVertex4sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glNormal3b( GLbyte nx, GLbyte ny, GLbyte nz ); +GLAPI void GLAPIENTRY glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz ); +GLAPI void GLAPIENTRY glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz ); +GLAPI void GLAPIENTRY glNormal3i( GLint nx, GLint ny, GLint nz ); +GLAPI void GLAPIENTRY glNormal3s( GLshort nx, GLshort ny, GLshort nz ); + +GLAPI void GLAPIENTRY glNormal3bv( const GLbyte *v ); +GLAPI void GLAPIENTRY glNormal3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glNormal3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glNormal3iv( const GLint *v ); +GLAPI void GLAPIENTRY glNormal3sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glIndexd( GLdouble c ); +GLAPI void GLAPIENTRY glIndexf( GLfloat c ); +GLAPI void GLAPIENTRY glIndexi( GLint c ); +GLAPI void GLAPIENTRY glIndexs( GLshort c ); +GLAPI void GLAPIENTRY glIndexub( GLubyte c ); /* 1.1 */ + +GLAPI void GLAPIENTRY glIndexdv( const GLdouble *c ); +GLAPI void GLAPIENTRY glIndexfv( const GLfloat *c ); +GLAPI void GLAPIENTRY glIndexiv( const GLint *c ); +GLAPI void GLAPIENTRY glIndexsv( const GLshort *c ); +GLAPI void GLAPIENTRY glIndexubv( const GLubyte *c ); /* 1.1 */ + +GLAPI void GLAPIENTRY glColor3b( GLbyte red, GLbyte green, GLbyte blue ); +GLAPI void GLAPIENTRY glColor3d( GLdouble red, GLdouble green, GLdouble blue ); +GLAPI void GLAPIENTRY glColor3f( GLfloat red, GLfloat green, GLfloat blue ); +GLAPI void GLAPIENTRY glColor3i( GLint red, GLint green, GLint blue ); +GLAPI void GLAPIENTRY glColor3s( GLshort red, GLshort green, GLshort blue ); +GLAPI void GLAPIENTRY glColor3ub( GLubyte red, GLubyte green, GLubyte blue ); +GLAPI void GLAPIENTRY glColor3ui( GLuint red, GLuint green, GLuint blue ); +GLAPI void GLAPIENTRY glColor3us( GLushort red, GLushort green, GLushort blue ); + +GLAPI void GLAPIENTRY glColor4b( GLbyte red, GLbyte green, + GLbyte blue, GLbyte alpha ); +GLAPI void GLAPIENTRY glColor4d( GLdouble red, GLdouble green, + GLdouble blue, GLdouble alpha ); +GLAPI void GLAPIENTRY glColor4f( GLfloat red, GLfloat green, + GLfloat blue, GLfloat alpha ); +GLAPI void GLAPIENTRY glColor4i( GLint red, GLint green, + GLint blue, GLint alpha ); +GLAPI void GLAPIENTRY glColor4s( GLshort red, GLshort green, + GLshort blue, GLshort alpha ); +GLAPI void GLAPIENTRY glColor4ub( GLubyte red, GLubyte green, + GLubyte blue, GLubyte alpha ); +GLAPI void GLAPIENTRY glColor4ui( GLuint red, GLuint green, + GLuint blue, GLuint alpha ); +GLAPI void GLAPIENTRY glColor4us( GLushort red, GLushort green, + GLushort blue, GLushort alpha ); + + +GLAPI void GLAPIENTRY glColor3bv( const GLbyte *v ); +GLAPI void GLAPIENTRY glColor3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glColor3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glColor3iv( const GLint *v ); +GLAPI void GLAPIENTRY glColor3sv( const GLshort *v ); +GLAPI void GLAPIENTRY glColor3ubv( const GLubyte *v ); +GLAPI void GLAPIENTRY glColor3uiv( const GLuint *v ); +GLAPI void GLAPIENTRY glColor3usv( const GLushort *v ); + +GLAPI void GLAPIENTRY glColor4bv( const GLbyte *v ); +GLAPI void GLAPIENTRY glColor4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glColor4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glColor4iv( const GLint *v ); +GLAPI void GLAPIENTRY glColor4sv( const GLshort *v ); +GLAPI void GLAPIENTRY glColor4ubv( const GLubyte *v ); +GLAPI void GLAPIENTRY glColor4uiv( const GLuint *v ); +GLAPI void GLAPIENTRY glColor4usv( const GLushort *v ); + + +GLAPI void GLAPIENTRY glTexCoord1d( GLdouble s ); +GLAPI void GLAPIENTRY glTexCoord1f( GLfloat s ); +GLAPI void GLAPIENTRY glTexCoord1i( GLint s ); +GLAPI void GLAPIENTRY glTexCoord1s( GLshort s ); + +GLAPI void GLAPIENTRY glTexCoord2d( GLdouble s, GLdouble t ); +GLAPI void GLAPIENTRY glTexCoord2f( GLfloat s, GLfloat t ); +GLAPI void GLAPIENTRY glTexCoord2i( GLint s, GLint t ); +GLAPI void GLAPIENTRY glTexCoord2s( GLshort s, GLshort t ); + +GLAPI void GLAPIENTRY glTexCoord3d( GLdouble s, GLdouble t, GLdouble r ); +GLAPI void GLAPIENTRY glTexCoord3f( GLfloat s, GLfloat t, GLfloat r ); +GLAPI void GLAPIENTRY glTexCoord3i( GLint s, GLint t, GLint r ); +GLAPI void GLAPIENTRY glTexCoord3s( GLshort s, GLshort t, GLshort r ); + +GLAPI void GLAPIENTRY glTexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q ); +GLAPI void GLAPIENTRY glTexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q ); +GLAPI void GLAPIENTRY glTexCoord4i( GLint s, GLint t, GLint r, GLint q ); +GLAPI void GLAPIENTRY glTexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q ); + +GLAPI void GLAPIENTRY glTexCoord1dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord1fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord1iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord1sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glTexCoord2dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord2fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord2iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord2sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glTexCoord3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord3iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord3sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glTexCoord4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord4iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord4sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glRasterPos2d( GLdouble x, GLdouble y ); +GLAPI void GLAPIENTRY glRasterPos2f( GLfloat x, GLfloat y ); +GLAPI void GLAPIENTRY glRasterPos2i( GLint x, GLint y ); +GLAPI void GLAPIENTRY glRasterPos2s( GLshort x, GLshort y ); + +GLAPI void GLAPIENTRY glRasterPos3d( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glRasterPos3f( GLfloat x, GLfloat y, GLfloat z ); +GLAPI void GLAPIENTRY glRasterPos3i( GLint x, GLint y, GLint z ); +GLAPI void GLAPIENTRY glRasterPos3s( GLshort x, GLshort y, GLshort z ); + +GLAPI void GLAPIENTRY glRasterPos4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); +GLAPI void GLAPIENTRY glRasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); +GLAPI void GLAPIENTRY glRasterPos4i( GLint x, GLint y, GLint z, GLint w ); +GLAPI void GLAPIENTRY glRasterPos4s( GLshort x, GLshort y, GLshort z, GLshort w ); + +GLAPI void GLAPIENTRY glRasterPos2dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glRasterPos2fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glRasterPos2iv( const GLint *v ); +GLAPI void GLAPIENTRY glRasterPos2sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glRasterPos3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glRasterPos3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glRasterPos3iv( const GLint *v ); +GLAPI void GLAPIENTRY glRasterPos3sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glRasterPos4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glRasterPos4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glRasterPos4iv( const GLint *v ); +GLAPI void GLAPIENTRY glRasterPos4sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glRectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 ); +GLAPI void GLAPIENTRY glRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ); +GLAPI void GLAPIENTRY glRecti( GLint x1, GLint y1, GLint x2, GLint y2 ); +GLAPI void GLAPIENTRY glRects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 ); + + +GLAPI void GLAPIENTRY glRectdv( const GLdouble *v1, const GLdouble *v2 ); +GLAPI void GLAPIENTRY glRectfv( const GLfloat *v1, const GLfloat *v2 ); +GLAPI void GLAPIENTRY glRectiv( const GLint *v1, const GLint *v2 ); +GLAPI void GLAPIENTRY glRectsv( const GLshort *v1, const GLshort *v2 ); + + +/* + * Vertex Arrays (1.1) + */ + +GLAPI void GLAPIENTRY glVertexPointer( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glNormalPointer( GLenum type, GLsizei stride, + const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glColorPointer( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glIndexPointer( GLenum type, GLsizei stride, + const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glTexCoordPointer( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glEdgeFlagPointer( GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glGetPointerv( GLenum pname, GLvoid **params ); + +GLAPI void GLAPIENTRY glArrayElement( GLint i ); + +GLAPI void GLAPIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count ); + +GLAPI void GLAPIENTRY glDrawElements( GLenum mode, GLsizei count, + GLenum type, const GLvoid *indices ); + +GLAPI void GLAPIENTRY glInterleavedArrays( GLenum format, GLsizei stride, + const GLvoid *pointer ); + +/* + * Lighting + */ + +GLAPI void GLAPIENTRY glShadeModel( GLenum mode ); + +GLAPI void GLAPIENTRY glLightf( GLenum light, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glLighti( GLenum light, GLenum pname, GLint param ); +GLAPI void GLAPIENTRY glLightfv( GLenum light, GLenum pname, + const GLfloat *params ); +GLAPI void GLAPIENTRY glLightiv( GLenum light, GLenum pname, + const GLint *params ); + +GLAPI void GLAPIENTRY glGetLightfv( GLenum light, GLenum pname, + GLfloat *params ); +GLAPI void GLAPIENTRY glGetLightiv( GLenum light, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glLightModelf( GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glLightModeli( GLenum pname, GLint param ); +GLAPI void GLAPIENTRY glLightModelfv( GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glLightModeliv( GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glMaterialf( GLenum face, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glMateriali( GLenum face, GLenum pname, GLint param ); +GLAPI void GLAPIENTRY glMaterialfv( GLenum face, GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glMaterialiv( GLenum face, GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetMaterialiv( GLenum face, GLenum pname, GLint *params ); + +GLAPI void GLAPIENTRY glColorMaterial( GLenum face, GLenum mode ); + + +/* + * Raster functions + */ + +GLAPI void GLAPIENTRY glPixelZoom( GLfloat xfactor, GLfloat yfactor ); + +GLAPI void GLAPIENTRY glPixelStoref( GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glPixelStorei( GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glPixelTransferf( GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glPixelTransferi( GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glPixelMapfv( GLenum map, GLsizei mapsize, + const GLfloat *values ); +GLAPI void GLAPIENTRY glPixelMapuiv( GLenum map, GLsizei mapsize, + const GLuint *values ); +GLAPI void GLAPIENTRY glPixelMapusv( GLenum map, GLsizei mapsize, + const GLushort *values ); + +GLAPI void GLAPIENTRY glGetPixelMapfv( GLenum map, GLfloat *values ); +GLAPI void GLAPIENTRY glGetPixelMapuiv( GLenum map, GLuint *values ); +GLAPI void GLAPIENTRY glGetPixelMapusv( GLenum map, GLushort *values ); + +GLAPI void GLAPIENTRY glBitmap( GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, + const GLubyte *bitmap ); + +GLAPI void GLAPIENTRY glReadPixels( GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLvoid *pixels ); + +GLAPI void GLAPIENTRY glDrawPixels( GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glCopyPixels( GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum type ); + +/* + * Stenciling + */ + +GLAPI void GLAPIENTRY glStencilFunc( GLenum func, GLint ref, GLuint mask ); + +GLAPI void GLAPIENTRY glStencilMask( GLuint mask ); + +GLAPI void GLAPIENTRY glStencilOp( GLenum fail, GLenum zfail, GLenum zpass ); + +GLAPI void GLAPIENTRY glClearStencil( GLint s ); + + + +/* + * Texture mapping + */ + +GLAPI void GLAPIENTRY glTexGend( GLenum coord, GLenum pname, GLdouble param ); +GLAPI void GLAPIENTRY glTexGenf( GLenum coord, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glTexGeni( GLenum coord, GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glTexGendv( GLenum coord, GLenum pname, const GLdouble *params ); +GLAPI void GLAPIENTRY glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glTexGeniv( GLenum coord, GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glGetTexGendv( GLenum coord, GLenum pname, GLdouble *params ); +GLAPI void GLAPIENTRY glGetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetTexGeniv( GLenum coord, GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glTexEnvf( GLenum target, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glTexEnvi( GLenum target, GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glTexEnviv( GLenum target, GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glGetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetTexEnviv( GLenum target, GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glTexParameterfv( GLenum target, GLenum pname, + const GLfloat *params ); +GLAPI void GLAPIENTRY glTexParameteriv( GLenum target, GLenum pname, + const GLint *params ); + +GLAPI void GLAPIENTRY glGetTexParameterfv( GLenum target, + GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetTexParameteriv( GLenum target, + GLenum pname, GLint *params ); + +GLAPI void GLAPIENTRY glGetTexLevelParameterfv( GLenum target, GLint level, + GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetTexLevelParameteriv( GLenum target, GLint level, + GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glTexImage1D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glTexImage2D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLsizei height, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glGetTexImage( GLenum target, GLint level, + GLenum format, GLenum type, + GLvoid *pixels ); + + +/* 1.1 functions */ + +GLAPI void GLAPIENTRY glGenTextures( GLsizei n, GLuint *textures ); + +GLAPI void GLAPIENTRY glDeleteTextures( GLsizei n, const GLuint *textures); + +GLAPI void GLAPIENTRY glBindTexture( GLenum target, GLuint texture ); + +GLAPI void GLAPIENTRY glPrioritizeTextures( GLsizei n, + const GLuint *textures, + const GLclampf *priorities ); + +GLAPI GLboolean GLAPIENTRY glAreTexturesResident( GLsizei n, + const GLuint *textures, + GLboolean *residences ); + +GLAPI GLboolean GLAPIENTRY glIsTexture( GLuint texture ); + + +GLAPI void GLAPIENTRY glTexSubImage1D( GLenum target, GLint level, + GLint xoffset, + GLsizei width, GLenum format, + GLenum type, const GLvoid *pixels ); + + +GLAPI void GLAPIENTRY glTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ); + + +GLAPI void GLAPIENTRY glCopyTexImage1D( GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLint border ); + + +GLAPI void GLAPIENTRY glCopyTexImage2D( GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLsizei height, + GLint border ); + + +GLAPI void GLAPIENTRY glCopyTexSubImage1D( GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, + GLsizei width ); + + +GLAPI void GLAPIENTRY glCopyTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height ); + + +/* + * Evaluators + */ + +GLAPI void GLAPIENTRY glMap1d( GLenum target, GLdouble u1, GLdouble u2, + GLint stride, + GLint order, const GLdouble *points ); +GLAPI void GLAPIENTRY glMap1f( GLenum target, GLfloat u1, GLfloat u2, + GLint stride, + GLint order, const GLfloat *points ); + +GLAPI void GLAPIENTRY glMap2d( GLenum target, + GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, + GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, + const GLdouble *points ); +GLAPI void GLAPIENTRY glMap2f( GLenum target, + GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLfloat *points ); + +GLAPI void GLAPIENTRY glGetMapdv( GLenum target, GLenum query, GLdouble *v ); +GLAPI void GLAPIENTRY glGetMapfv( GLenum target, GLenum query, GLfloat *v ); +GLAPI void GLAPIENTRY glGetMapiv( GLenum target, GLenum query, GLint *v ); + +GLAPI void GLAPIENTRY glEvalCoord1d( GLdouble u ); +GLAPI void GLAPIENTRY glEvalCoord1f( GLfloat u ); + +GLAPI void GLAPIENTRY glEvalCoord1dv( const GLdouble *u ); +GLAPI void GLAPIENTRY glEvalCoord1fv( const GLfloat *u ); + +GLAPI void GLAPIENTRY glEvalCoord2d( GLdouble u, GLdouble v ); +GLAPI void GLAPIENTRY glEvalCoord2f( GLfloat u, GLfloat v ); + +GLAPI void GLAPIENTRY glEvalCoord2dv( const GLdouble *u ); +GLAPI void GLAPIENTRY glEvalCoord2fv( const GLfloat *u ); + +GLAPI void GLAPIENTRY glMapGrid1d( GLint un, GLdouble u1, GLdouble u2 ); +GLAPI void GLAPIENTRY glMapGrid1f( GLint un, GLfloat u1, GLfloat u2 ); + +GLAPI void GLAPIENTRY glMapGrid2d( GLint un, GLdouble u1, GLdouble u2, + GLint vn, GLdouble v1, GLdouble v2 ); +GLAPI void GLAPIENTRY glMapGrid2f( GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2 ); + +GLAPI void GLAPIENTRY glEvalPoint1( GLint i ); + +GLAPI void GLAPIENTRY glEvalPoint2( GLint i, GLint j ); + +GLAPI void GLAPIENTRY glEvalMesh1( GLenum mode, GLint i1, GLint i2 ); + +GLAPI void GLAPIENTRY glEvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); + + +/* + * Fog + */ + +GLAPI void GLAPIENTRY glFogf( GLenum pname, GLfloat param ); + +GLAPI void GLAPIENTRY glFogi( GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glFogfv( GLenum pname, const GLfloat *params ); + +GLAPI void GLAPIENTRY glFogiv( GLenum pname, const GLint *params ); + + +/* + * Selection and Feedback + */ + +GLAPI void GLAPIENTRY glFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ); + +GLAPI void GLAPIENTRY glPassThrough( GLfloat token ); + +GLAPI void GLAPIENTRY glSelectBuffer( GLsizei size, GLuint *buffer ); + +GLAPI void GLAPIENTRY glInitNames( void ); + +GLAPI void GLAPIENTRY glLoadName( GLuint name ); + +GLAPI void GLAPIENTRY glPushName( GLuint name ); + +GLAPI void GLAPIENTRY glPopName( void ); + + + +/* + * OpenGL 1.2 + */ + +#define GL_RESCALE_NORMAL 0x803A +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_TEXTURE_BINDING_3D 0x806A + +GLAPI void GLAPIENTRY glDrawRangeElements( GLenum mode, GLuint start, + GLuint end, GLsizei count, GLenum type, const GLvoid *indices ); + +GLAPI void GLAPIENTRY glTexImage3D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLsizei height, + GLsizei depth, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, + GLenum format, + GLenum type, const GLvoid *pixels); + +GLAPI void GLAPIENTRY glCopyTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLint x, + GLint y, GLsizei width, + GLsizei height ); + +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + + +/* + * GL_ARB_imaging + */ + +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_BLEND_EQUATION 0x8009 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_BLEND_COLOR 0x8005 + + +GLAPI void GLAPIENTRY glColorTable( GLenum target, GLenum internalformat, + GLsizei width, GLenum format, + GLenum type, const GLvoid *table ); + +GLAPI void GLAPIENTRY glColorSubTable( GLenum target, + GLsizei start, GLsizei count, + GLenum format, GLenum type, + const GLvoid *data ); + +GLAPI void GLAPIENTRY glColorTableParameteriv(GLenum target, GLenum pname, + const GLint *params); + +GLAPI void GLAPIENTRY glColorTableParameterfv(GLenum target, GLenum pname, + const GLfloat *params); + +GLAPI void GLAPIENTRY glCopyColorSubTable( GLenum target, GLsizei start, + GLint x, GLint y, GLsizei width ); + +GLAPI void GLAPIENTRY glCopyColorTable( GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width ); + +GLAPI void GLAPIENTRY glGetColorTable( GLenum target, GLenum format, + GLenum type, GLvoid *table ); + +GLAPI void GLAPIENTRY glGetColorTableParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetColorTableParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glBlendEquation( GLenum mode ); + +GLAPI void GLAPIENTRY glBlendColor( GLclampf red, GLclampf green, + GLclampf blue, GLclampf alpha ); + +GLAPI void GLAPIENTRY glHistogram( GLenum target, GLsizei width, + GLenum internalformat, GLboolean sink ); + +GLAPI void GLAPIENTRY glResetHistogram( GLenum target ); + +GLAPI void GLAPIENTRY glGetHistogram( GLenum target, GLboolean reset, + GLenum format, GLenum type, + GLvoid *values ); + +GLAPI void GLAPIENTRY glGetHistogramParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetHistogramParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glMinmax( GLenum target, GLenum internalformat, + GLboolean sink ); + +GLAPI void GLAPIENTRY glResetMinmax( GLenum target ); + +GLAPI void GLAPIENTRY glGetMinmax( GLenum target, GLboolean reset, + GLenum format, GLenum types, + GLvoid *values ); + +GLAPI void GLAPIENTRY glGetMinmaxParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetMinmaxParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glConvolutionFilter1D( GLenum target, + GLenum internalformat, GLsizei width, GLenum format, GLenum type, + const GLvoid *image ); + +GLAPI void GLAPIENTRY glConvolutionFilter2D( GLenum target, + GLenum internalformat, GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *image ); + +GLAPI void GLAPIENTRY glConvolutionParameterf( GLenum target, GLenum pname, + GLfloat params ); + +GLAPI void GLAPIENTRY glConvolutionParameterfv( GLenum target, GLenum pname, + const GLfloat *params ); + +GLAPI void GLAPIENTRY glConvolutionParameteri( GLenum target, GLenum pname, + GLint params ); + +GLAPI void GLAPIENTRY glConvolutionParameteriv( GLenum target, GLenum pname, + const GLint *params ); + +GLAPI void GLAPIENTRY glCopyConvolutionFilter1D( GLenum target, + GLenum internalformat, GLint x, GLint y, GLsizei width ); + +GLAPI void GLAPIENTRY glCopyConvolutionFilter2D( GLenum target, + GLenum internalformat, GLint x, GLint y, GLsizei width, + GLsizei height); + +GLAPI void GLAPIENTRY glGetConvolutionFilter( GLenum target, GLenum format, + GLenum type, GLvoid *image ); + +GLAPI void GLAPIENTRY glGetConvolutionParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetConvolutionParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glSeparableFilter2D( GLenum target, + GLenum internalformat, GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *row, const GLvoid *column ); + +GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format, + GLenum type, GLvoid *row, GLvoid *column, GLvoid *span ); + + + + +/* + * OpenGL 1.3 + */ + +/* multitexture */ +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +/* texture_cube_map */ +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +/* texture_compression */ +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +/* multisample */ +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_MULTISAMPLE_BIT 0x20000000 +/* transpose_matrix */ +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +/* texture_env_combine */ +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +/* texture_env_dot3 */ +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +/* texture_border_clamp */ +#define GL_CLAMP_TO_BORDER 0x812D + +GLAPI void GLAPIENTRY glActiveTexture( GLenum texture ); + +GLAPI void GLAPIENTRY glClientActiveTexture( GLenum texture ); + +GLAPI void GLAPIENTRY glCompressedTexImage1D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glGetCompressedTexImage( GLenum target, GLint lod, GLvoid *img ); + +GLAPI void GLAPIENTRY glMultiTexCoord1d( GLenum target, GLdouble s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord1f( GLenum target, GLfloat s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord1i( GLenum target, GLint s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord1s( GLenum target, GLshort s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1sv( GLenum target, const GLshort *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2d( GLenum target, GLdouble s, GLdouble t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2f( GLenum target, GLfloat s, GLfloat t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2i( GLenum target, GLint s, GLint t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2s( GLenum target, GLshort s, GLshort t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2sv( GLenum target, const GLshort *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3d( GLenum target, GLdouble s, GLdouble t, GLdouble r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3f( GLenum target, GLfloat s, GLfloat t, GLfloat r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3i( GLenum target, GLint s, GLint t, GLint r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3s( GLenum target, GLshort s, GLshort t, GLshort r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3sv( GLenum target, const GLshort *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4d( GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4i( GLenum target, GLint s, GLint t, GLint r, GLint q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4s( GLenum target, GLshort s, GLshort t, GLshort r, GLshort q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4sv( GLenum target, const GLshort *v ); + + +GLAPI void GLAPIENTRY glLoadTransposeMatrixd( const GLdouble * m ); + +GLAPI void GLAPIENTRY glLoadTransposeMatrixf( const GLfloat * m ); + +GLAPI void GLAPIENTRY glMultTransposeMatrixd( const GLdouble * m ); + +GLAPI void GLAPIENTRY glMultTransposeMatrixf( const GLfloat * m ); + +GLAPI void GLAPIENTRY glSampleCoverage( GLclampf value, GLboolean invert ); + + +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); + + + +/* + * GL_ARB_multitexture (ARB extension 1 and OpenGL 1.2.1) + */ +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 + +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 + +GLAPI void GLAPIENTRY glActiveTextureARB(GLenum texture); +GLAPI void GLAPIENTRY glClientActiveTextureARB(GLenum texture); +GLAPI void GLAPIENTRY glMultiTexCoord1dARB(GLenum target, GLdouble s); +GLAPI void GLAPIENTRY glMultiTexCoord1dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord1fARB(GLenum target, GLfloat s); +GLAPI void GLAPIENTRY glMultiTexCoord1fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord1iARB(GLenum target, GLint s); +GLAPI void GLAPIENTRY glMultiTexCoord1ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord1sARB(GLenum target, GLshort s); +GLAPI void GLAPIENTRY glMultiTexCoord1svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t); +GLAPI void GLAPIENTRY glMultiTexCoord2dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t); +GLAPI void GLAPIENTRY glMultiTexCoord2fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord2iARB(GLenum target, GLint s, GLint t); +GLAPI void GLAPIENTRY glMultiTexCoord2ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord2sARB(GLenum target, GLshort s, GLshort t); +GLAPI void GLAPIENTRY glMultiTexCoord2svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void GLAPIENTRY glMultiTexCoord3dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void GLAPIENTRY glMultiTexCoord3fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r); +GLAPI void GLAPIENTRY glMultiTexCoord3ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void GLAPIENTRY glMultiTexCoord3svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void GLAPIENTRY glMultiTexCoord4dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void GLAPIENTRY glMultiTexCoord4fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void GLAPIENTRY glMultiTexCoord4ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void GLAPIENTRY glMultiTexCoord4svARB(GLenum target, const GLshort *v); + +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); + +#endif /* GL_ARB_multitexture */ + + + +/* + * Define this token if you want "old-style" header file behaviour (extensions + * defined in gl.h). Otherwise, extensions will be included from glext.h. + */ +#if defined(GL_GLEXT_LEGACY) + +/* All extensions that used to be here are now found in glext.h */ + +#else /* GL_GLEXT_LEGACY */ + +#include "vendor/glext.h" + +#endif /* GL_GLEXT_LEGACY */ + + + +/* + * ???. GL_MESA_packed_depth_stencil + * XXX obsolete + */ +#ifndef GL_MESA_packed_depth_stencil +#define GL_MESA_packed_depth_stencil 1 + +#define GL_DEPTH_STENCIL_MESA 0x8750 +#define GL_UNSIGNED_INT_24_8_MESA 0x8751 +#define GL_UNSIGNED_INT_8_24_REV_MESA 0x8752 +#define GL_UNSIGNED_SHORT_15_1_MESA 0x8753 +#define GL_UNSIGNED_SHORT_1_15_REV_MESA 0x8754 + +#endif /* GL_MESA_packed_depth_stencil */ + + +#ifndef GL_ATI_blend_equation_separate +#define GL_ATI_blend_equation_separate 1 + +#define GL_ALPHA_BLEND_EQUATION_ATI 0x883D + +GLAPI void GLAPIENTRY glBlendEquationSeparateATI( GLenum modeRGB, GLenum modeA ); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEATIPROC) (GLenum modeRGB, GLenum modeA); + +#endif /* GL_ATI_blend_equation_separate */ + + +/* GL_OES_EGL_image */ +#if !defined(GL_OES_EGL_image) && !defined(GL_EXT_EGL_image_storage) +typedef void* GLeglImageOES; +#endif + +#ifndef GL_OES_EGL_image +#define GL_OES_EGL_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); +GLAPI void APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image); +#endif +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); +typedef void (APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* __gl_h_ */ diff --git a/irr/src/vendor/glext.h b/irr/src/vendor/glext.h new file mode 100644 index 000000000..480d4dada --- /dev/null +++ b/irr/src/vendor/glext.h @@ -0,0 +1,12912 @@ +#ifndef __gl_glext_h_ +#define __gl_glext_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright 2013-2020 The Khronos Group Inc. +** SPDX-License-Identifier: MIT +** +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** https://github.com/KhronosGroup/OpenGL-Registry +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +#define GL_GLEXT_VERSION 20231129 + +#include + +/* Generated C header for: + * API: gl + * Profile: compatibility + * Versions considered: .* + * Versions emitted: 1\.[2-9]|[234]\.[0-9] + * Default extensions included: gl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_RESCALE_NORMAL 0x803A +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_VERSION_1_2 */ + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum texture); +GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, void *img); +GLAPI void APIENTRY glClientActiveTexture (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); +#endif +#endif /* GL_VERSION_1_3 */ + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#define GL_BLEND_COLOR 0x8005 +#define GL_BLEND_EQUATION 0x8009 +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_FUNC_SUBTRACT 0x800A +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); +GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFogCoordf (GLfloat coord); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); +GLAPI void APIENTRY glFogCoordd (GLdouble coord); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2iv (const GLint *v); +GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); +GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3iv (const GLint *v); +GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); +GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void APIENTRY glBlendEquation (GLenum mode); +#endif +#endif /* GL_VERSION_1_4 */ + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +typedef khronos_ssize_t GLsizeiptr; +typedef khronos_intptr_t GLintptr; +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_SRC1_ALPHA 0x8589 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_FOG_COORD_SRC 0x8450 +#define GL_FOG_COORD 0x8451 +#define GL_CURRENT_FOG_COORD 0x8453 +#define GL_FOG_COORD_ARRAY_TYPE 0x8454 +#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORD_ARRAY_POINTER 0x8456 +#define GL_FOG_COORD_ARRAY 0x8457 +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D +#define GL_SRC0_RGB 0x8580 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_RGB 0x8582 +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC2_ALPHA 0x858A +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQuery (GLuint id); +GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQuery (GLenum target); +GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); +GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void *APIENTRY glMapBuffer (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_VERSION_1_5 */ + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +typedef char GLchar; +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_TEXTURE_COORDS 0x8871 +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GLAPI void APIENTRY glCompileShader (GLuint shader); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum type); +GLAPI void APIENTRY glDeleteProgram (GLuint program); +GLAPI void APIENTRY glDeleteShader (GLuint shader); +GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); +GLAPI GLboolean APIENTRY glIsProgram (GLuint program); +GLAPI GLboolean APIENTRY glIsShader (GLuint shader); +GLAPI void APIENTRY glLinkProgram (GLuint program); +GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GLAPI void APIENTRY glUseProgram (GLuint program); +GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glValidateProgram (GLuint program); +GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +#endif +#endif /* GL_VERSION_2_0 */ + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif +#endif /* GL_VERSION_2_1 */ + +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +typedef khronos_uint16_t GLhalf; +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_CLIP_DISTANCE6 0x3006 +#define GL_CLIP_DISTANCE7 0x3007 +#define GL_MAX_CLIP_DISTANCES 0x0D32 +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_COLOR_ATTACHMENT16 0x8CF0 +#define GL_COLOR_ATTACHMENT17 0x8CF1 +#define GL_COLOR_ATTACHMENT18 0x8CF2 +#define GL_COLOR_ATTACHMENT19 0x8CF3 +#define GL_COLOR_ATTACHMENT20 0x8CF4 +#define GL_COLOR_ATTACHMENT21 0x8CF5 +#define GL_COLOR_ATTACHMENT22 0x8CF6 +#define GL_COLOR_ATTACHMENT23 0x8CF7 +#define GL_COLOR_ATTACHMENT24 0x8CF8 +#define GL_COLOR_ATTACHMENT25 0x8CF9 +#define GL_COLOR_ATTACHMENT26 0x8CFA +#define GL_COLOR_ATTACHMENT27 0x8CFB +#define GL_COLOR_ATTACHMENT28 0x8CFC +#define GL_COLOR_ATTACHMENT29 0x8CFD +#define GL_COLOR_ATTACHMENT30 0x8CFE +#define GL_COLOR_ATTACHMENT31 0x8CFF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_INDEX 0x8222 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_ALPHA_INTEGER 0x8D97 +typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void *(APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); +GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); +GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedback (void); +GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); +GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRender (void); +GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); +GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmap (GLenum target); +GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void *APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glBindVertexArray (GLuint array); +GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); +#endif +#endif /* GL_VERSION_3_0 */ + +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); +typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); +GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif +#endif /* GL_VERSION_3_1 */ + +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 +typedef struct __GLsync *GLsync; +typedef khronos_uint64_t GLuint64; +typedef khronos_int64_t GLint64; +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +#define GL_DEPTH_CLAMP 0x864F +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); +typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); +typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +GLAPI void APIENTRY glProvokingVertex (GLenum mode); +GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GLAPI GLboolean APIENTRY glIsSync (GLsync sync); +GLAPI void APIENTRY glDeleteSync (GLsync sync); +GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); +GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaski (GLuint maskNumber, GLbitfield mask); +#endif +#endif /* GL_VERSION_3_2 */ + +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_SRC1_COLOR 0x88F9 +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#define GL_INT_2_10_10_10_REV 0x8D9F +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); +GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); +GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); +GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); +GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); +GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); +#endif +#endif /* GL_VERSION_3_3 */ + +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +#define GL_MAX_VERTEX_STREAMS 0x8E71 +#define GL_DOUBLE_VEC2 0x8FFC +#define GL_DOUBLE_VEC3 0x8FFD +#define GL_DOUBLE_VEC4 0x8FFE +#define GL_DOUBLE_MAT2 0x8F46 +#define GL_DOUBLE_MAT3 0x8F47 +#define GL_DOUBLE_MAT4 0x8F48 +#define GL_DOUBLE_MAT2x3 0x8F49 +#define GL_DOUBLE_MAT2x4 0x8F4A +#define GL_DOUBLE_MAT3x2 0x8F4B +#define GL_DOUBLE_MAT3x4 0x8F4C +#define GL_DOUBLE_MAT4x2 0x8F4D +#define GL_DOUBLE_MAT4x3 0x8F4E +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +#define GL_ISOLINES 0x8E7A +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); +typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect); +typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); +typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); +typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); +typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShading (GLfloat value); +GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const void *indirect); +GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect); +GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); +GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); +GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); +GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); +GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); +GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); +GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedback (void); +GLAPI void APIENTRY glResumeTransformFeedback (void); +GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); +GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); +GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); +GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); +GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif +#endif /* GL_VERSION_4_0 */ + +#ifndef GL_VERSION_4_1 +#define GL_VERSION_4_1 1 +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#define GL_MAX_VIEWPORTS 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE 0x825D +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F +#define GL_UNDEFINED_VERTEX 0x8260 +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); +typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); +typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); +GLAPI void APIENTRY glClearDepthf (GLfloat d); +GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); +GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); +GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); +GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); +GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); +GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); +GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); +#endif +#endif /* GL_VERSION_4_1 */ + +#ifndef GL_VERSION_4_2 +#define GL_VERSION_4_2 1 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 +#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 +#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 +#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A +#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B +#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C +#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D +#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_1D 0x904C +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_2D_RECT 0x904F +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_BUFFER 0x9051 +#define GL_IMAGE_1D_ARRAY 0x9052 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 +#define GL_INT_IMAGE_1D 0x9057 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_2D_RECT 0x905A +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_BUFFER 0x905C +#define GL_INT_IMAGE_1D_ARRAY 0x905D +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C +#define GL_MAX_IMAGE_SAMPLES 0x906D +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params); +GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); +GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); +GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#endif +#endif /* GL_VERSION_4_2 */ + +#ifndef GL_VERSION_4_3 +#define GL_VERSION_4_3 1 +typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 +#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#define GL_INTERNALFORMAT_SUPPORTED 0x826F +#define GL_INTERNALFORMAT_PREFERRED 0x8270 +#define GL_INTERNALFORMAT_RED_SIZE 0x8271 +#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 +#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 +#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 +#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 +#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 +#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 +#define GL_INTERNALFORMAT_RED_TYPE 0x8278 +#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 +#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A +#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B +#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C +#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D +#define GL_MAX_WIDTH 0x827E +#define GL_MAX_HEIGHT 0x827F +#define GL_MAX_DEPTH 0x8280 +#define GL_MAX_LAYERS 0x8281 +#define GL_MAX_COMBINED_DIMENSIONS 0x8282 +#define GL_COLOR_COMPONENTS 0x8283 +#define GL_DEPTH_COMPONENTS 0x8284 +#define GL_STENCIL_COMPONENTS 0x8285 +#define GL_COLOR_RENDERABLE 0x8286 +#define GL_DEPTH_RENDERABLE 0x8287 +#define GL_STENCIL_RENDERABLE 0x8288 +#define GL_FRAMEBUFFER_RENDERABLE 0x8289 +#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A +#define GL_FRAMEBUFFER_BLEND 0x828B +#define GL_READ_PIXELS 0x828C +#define GL_READ_PIXELS_FORMAT 0x828D +#define GL_READ_PIXELS_TYPE 0x828E +#define GL_TEXTURE_IMAGE_FORMAT 0x828F +#define GL_TEXTURE_IMAGE_TYPE 0x8290 +#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 +#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 +#define GL_MIPMAP 0x8293 +#define GL_MANUAL_GENERATE_MIPMAP 0x8294 +#define GL_AUTO_GENERATE_MIPMAP 0x8295 +#define GL_COLOR_ENCODING 0x8296 +#define GL_SRGB_READ 0x8297 +#define GL_SRGB_WRITE 0x8298 +#define GL_FILTER 0x829A +#define GL_VERTEX_TEXTURE 0x829B +#define GL_TESS_CONTROL_TEXTURE 0x829C +#define GL_TESS_EVALUATION_TEXTURE 0x829D +#define GL_GEOMETRY_TEXTURE 0x829E +#define GL_FRAGMENT_TEXTURE 0x829F +#define GL_COMPUTE_TEXTURE 0x82A0 +#define GL_TEXTURE_SHADOW 0x82A1 +#define GL_TEXTURE_GATHER 0x82A2 +#define GL_TEXTURE_GATHER_SHADOW 0x82A3 +#define GL_SHADER_IMAGE_LOAD 0x82A4 +#define GL_SHADER_IMAGE_STORE 0x82A5 +#define GL_SHADER_IMAGE_ATOMIC 0x82A6 +#define GL_IMAGE_TEXEL_SIZE 0x82A7 +#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 +#define GL_IMAGE_PIXEL_FORMAT 0x82A9 +#define GL_IMAGE_PIXEL_TYPE 0x82AA +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF +#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 +#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 +#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 +#define GL_CLEAR_BUFFER 0x82B4 +#define GL_TEXTURE_VIEW 0x82B5 +#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 +#define GL_FULL_SUPPORT 0x82B7 +#define GL_CAVEAT_SUPPORT 0x82B8 +#define GL_IMAGE_CLASS_4_X_32 0x82B9 +#define GL_IMAGE_CLASS_2_X_32 0x82BA +#define GL_IMAGE_CLASS_1_X_32 0x82BB +#define GL_IMAGE_CLASS_4_X_16 0x82BC +#define GL_IMAGE_CLASS_2_X_16 0x82BD +#define GL_IMAGE_CLASS_1_X_16 0x82BE +#define GL_IMAGE_CLASS_4_X_8 0x82BF +#define GL_IMAGE_CLASS_2_X_8 0x82C0 +#define GL_IMAGE_CLASS_1_X_8 0x82C1 +#define GL_IMAGE_CLASS_11_11_10 0x82C2 +#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 +#define GL_VIEW_CLASS_128_BITS 0x82C4 +#define GL_VIEW_CLASS_96_BITS 0x82C5 +#define GL_VIEW_CLASS_64_BITS 0x82C6 +#define GL_VIEW_CLASS_48_BITS 0x82C7 +#define GL_VIEW_CLASS_32_BITS 0x82C8 +#define GL_VIEW_CLASS_24_BITS 0x82C9 +#define GL_VIEW_CLASS_16_BITS 0x82CA +#define GL_VIEW_CLASS_8_BITS 0x82CB +#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC +#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD +#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE +#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF +#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 +#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 +#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 +#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +#define GL_VERTEX_SUBROUTINE 0x92E8 +#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 +#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA +#define GL_GEOMETRY_SUBROUTINE 0x92EB +#define GL_FRAGMENT_SUBROUTINE 0x92EC +#define GL_COMPUTE_SUBROUTINE 0x92ED +#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE +#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF +#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 +#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 +#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 +#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_LOCATION_INDEX 0x930F +#define GL_IS_PER_PATCH 0x92E7 +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#define GL_VERTEX_BINDING_BUFFER 0x8F4F +#define GL_DISPLAY_LIST 0x82E7 +typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 *params); +typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLint *params); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); +GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 *params); +GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); +GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); +GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLint *params); +GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GLAPI void APIENTRY glPopDebugGroup (void); +GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_VERSION_4_3 */ + +#ifndef GL_VERSION_4_4 +#define GL_VERSION_4_4 1 +#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 +#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 +#define GL_TEXTURE_BUFFER_BINDING 0x8C2A +#define GL_MAP_PERSISTENT_BIT 0x0040 +#define GL_MAP_COHERENT_BIT 0x0080 +#define GL_DYNAMIC_STORAGE_BIT 0x0100 +#define GL_CLIENT_STORAGE_BIT 0x0200 +#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 +#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F +#define GL_BUFFER_STORAGE_FLAGS 0x8220 +#define GL_CLEAR_TEXTURE 0x9365 +#define GL_LOCATION_COMPONENT 0x934A +#define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B +#define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C +#define GL_QUERY_BUFFER 0x9192 +#define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000 +#define GL_QUERY_BUFFER_BINDING 0x9193 +#define GL_QUERY_RESULT_NO_WAIT 0x9194 +#define GL_MIRROR_CLAMP_TO_EDGE 0x8743 +typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLBINDBUFFERSBASEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); +typedef void (APIENTRYP PFNGLBINDBUFFERSRANGEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); +typedef void (APIENTRYP PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); +typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint *samplers); +typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERSPROC) (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferStorage (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glClearTexImage (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glBindBuffersBase (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); +GLAPI void APIENTRY glBindBuffersRange (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); +GLAPI void APIENTRY glBindTextures (GLuint first, GLsizei count, const GLuint *textures); +GLAPI void APIENTRY glBindSamplers (GLuint first, GLsizei count, const GLuint *samplers); +GLAPI void APIENTRY glBindImageTextures (GLuint first, GLsizei count, const GLuint *textures); +GLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +#endif +#endif /* GL_VERSION_4_4 */ + +#ifndef GL_VERSION_4_5 +#define GL_VERSION_4_5 1 +#define GL_CONTEXT_LOST 0x0507 +#define GL_NEGATIVE_ONE_TO_ONE 0x935E +#define GL_ZERO_TO_ONE 0x935F +#define GL_CLIP_ORIGIN 0x935C +#define GL_CLIP_DEPTH_MODE 0x935D +#define GL_QUERY_WAIT_INVERTED 0x8E17 +#define GL_QUERY_NO_WAIT_INVERTED 0x8E18 +#define GL_QUERY_BY_REGION_WAIT_INVERTED 0x8E19 +#define GL_QUERY_BY_REGION_NO_WAIT_INVERTED 0x8E1A +#define GL_MAX_CULL_DISTANCES 0x82F9 +#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA +#define GL_TEXTURE_TARGET 0x1006 +#define GL_QUERY_TARGET 0x82EA +#define GL_GUILTY_CONTEXT_RESET 0x8253 +#define GL_INNOCENT_CONTEXT_RESET 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY 0x8256 +#define GL_LOSE_CONTEXT_ON_RESET 0x8252 +#define GL_NO_RESET_NOTIFICATION 0x8261 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004 +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_MINMAX 0x802E +#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB +#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC +typedef void (APIENTRYP PFNGLCLIPCONTROLPROC) (GLenum origin, GLenum depth); +typedef void (APIENTRYP PFNGLCREATETRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC) (GLuint xfb, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC) (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKIVPROC) (GLuint xfb, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint *param); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); +typedef void (APIENTRYP PFNGLCREATEBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLCOPYNAMEDBUFFERSUBDATAPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERPROC) (GLuint buffer, GLenum access); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERI64VPROC) (GLuint buffer, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVPROC) (GLuint buffer, GLenum pname, void **params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +typedef void (APIENTRYP PFNGLCREATEFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC) (GLuint framebuffer, GLenum buf); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC) (GLuint framebuffer, GLenum src); +typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef void (APIENTRYP PFNGLBLITNAMEDFRAMEBUFFERPROC) (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC) (GLuint framebuffer, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATERENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATETEXTURESPROC) (GLenum target, GLsizei n, GLuint *textures); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERPROC) (GLuint texture, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEPROC) (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFPROC) (GLuint texture, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIPROC) (GLuint texture, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLBINDTEXTUREUNITPROC) (GLuint unit, GLuint texture); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVPROC) (GLuint texture, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVPROC) (GLuint texture, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATEVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLVERTEXARRAYELEMENTBUFFERPROC) (GLuint vaobj, GLuint buffer); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERSPROC) (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBBINDINGPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBIFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBLFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDINGDIVISORPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYIVPROC) (GLuint vaobj, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXEDIVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXED64IVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); +typedef void (APIENTRYP PFNGLCREATESAMPLERSPROC) (GLsizei n, GLuint *samplers); +typedef void (APIENTRYP PFNGLCREATEPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef void (APIENTRYP PFNGLCREATEQUERIESPROC) (GLenum target, GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC) (GLbitfield barriers); +typedef void (APIENTRYP PFNGLGETTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSPROC) (void); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLREADNPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (APIENTRYP PFNGLGETNMAPDVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void (APIENTRYP PFNGLGETNMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void (APIENTRYP PFNGLTEXTUREBARRIERPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClipControl (GLenum origin, GLenum depth); +GLAPI void APIENTRY glCreateTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glTransformFeedbackBufferBase (GLuint xfb, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackBufferRange (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glGetTransformFeedbackiv (GLuint xfb, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTransformFeedbacki_v (GLuint xfb, GLenum pname, GLuint index, GLint *param); +GLAPI void APIENTRY glGetTransformFeedbacki64_v (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); +GLAPI void APIENTRY glCreateBuffers (GLsizei n, GLuint *buffers); +GLAPI void APIENTRY glNamedBufferStorage (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glNamedBufferData (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glClearNamedBufferData (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubData (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void *APIENTRY glMapNamedBuffer (GLuint buffer, GLenum access); +GLAPI void *APIENTRY glMapNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI GLboolean APIENTRY glUnmapNamedBuffer (GLuint buffer); +GLAPI void APIENTRY glFlushMappedNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glGetNamedBufferParameteriv (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferParameteri64v (GLuint buffer, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetNamedBufferPointerv (GLuint buffer, GLenum pname, void **params); +GLAPI void APIENTRY glGetNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void APIENTRY glCreateFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI void APIENTRY glNamedFramebufferRenderbuffer (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glNamedFramebufferParameteri (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glNamedFramebufferTexture (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayer (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferDrawBuffer (GLuint framebuffer, GLenum buf); +GLAPI void APIENTRY glNamedFramebufferDrawBuffers (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glNamedFramebufferReadBuffer (GLuint framebuffer, GLenum src); +GLAPI void APIENTRY glInvalidateNamedFramebufferData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateNamedFramebufferSubData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glClearNamedFramebufferiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearNamedFramebufferuiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearNamedFramebufferfv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearNamedFramebufferfi (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI void APIENTRY glBlitNamedFramebuffer (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatus (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glGetNamedFramebufferParameteriv (GLuint framebuffer, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameteriv (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glNamedRenderbufferStorage (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisample (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameteriv (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateTextures (GLenum target, GLsizei n, GLuint *textures); +GLAPI void APIENTRY glTextureBuffer (GLuint texture, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glTextureBufferRange (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTextureStorage1D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glTextureStorage2DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCompressedTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCopyTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureParameterf (GLuint texture, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfv (GLuint texture, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glTextureParameteri (GLuint texture, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterIiv (GLuint texture, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuiv (GLuint texture, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glTextureParameteriv (GLuint texture, GLenum pname, const GLint *param); +GLAPI void APIENTRY glGenerateTextureMipmap (GLuint texture); +GLAPI void APIENTRY glBindTextureUnit (GLuint unit, GLuint texture); +GLAPI void APIENTRY glGetTextureImage (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetCompressedTextureImage (GLuint texture, GLint level, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetTextureLevelParameterfv (GLuint texture, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameteriv (GLuint texture, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterfv (GLuint texture, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterIiv (GLuint texture, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuiv (GLuint texture, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetTextureParameteriv (GLuint texture, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateVertexArrays (GLsizei n, GLuint *arrays); +GLAPI void APIENTRY glDisableVertexArrayAttrib (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glEnableVertexArrayAttrib (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glVertexArrayElementBuffer (GLuint vaobj, GLuint buffer); +GLAPI void APIENTRY glVertexArrayVertexBuffer (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexBuffers (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +GLAPI void APIENTRY glVertexArrayAttribBinding (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayAttribFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayAttribIFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayAttribLFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayBindingDivisor (GLuint vaobj, GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glGetVertexArrayiv (GLuint vaobj, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayIndexediv (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayIndexed64iv (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); +GLAPI void APIENTRY glCreateSamplers (GLsizei n, GLuint *samplers); +GLAPI void APIENTRY glCreateProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI void APIENTRY glCreateQueries (GLenum target, GLsizei n, GLuint *ids); +GLAPI void APIENTRY glGetQueryBufferObjecti64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectui64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectuiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glMemoryBarrierByRegion (GLbitfield barriers); +GLAPI void APIENTRY glGetTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetCompressedTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); +GLAPI GLenum APIENTRY glGetGraphicsResetStatus (void); +GLAPI void APIENTRY glGetnCompressedTexImage (GLenum target, GLint lod, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetnTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetnUniformdv (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +GLAPI void APIENTRY glGetnUniformfv (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformiv (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuiv (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glReadnPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GLAPI void APIENTRY glGetnMapdv (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfv (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapiv (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfv (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuiv (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusv (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStipple (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTable (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +GLAPI void APIENTRY glGetnConvolutionFilter (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +GLAPI void APIENTRY glGetnSeparableFilter (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +GLAPI void APIENTRY glGetnHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +GLAPI void APIENTRY glGetnMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +GLAPI void APIENTRY glTextureBarrier (void); +#endif +#endif /* GL_VERSION_4_5 */ + +#ifndef GL_VERSION_4_6 +#define GL_VERSION_4_6 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V 0x9551 +#define GL_SPIR_V_BINARY 0x9552 +#define GL_PARAMETER_BUFFER 0x80EE +#define GL_PARAMETER_BUFFER_BINDING 0x80EF +#define GL_CONTEXT_FLAG_NO_ERROR_BIT 0x00000008 +#define GL_VERTICES_SUBMITTED 0x82EE +#define GL_PRIMITIVES_SUBMITTED 0x82EF +#define GL_VERTEX_SHADER_INVOCATIONS 0x82F0 +#define GL_TESS_CONTROL_SHADER_PATCHES 0x82F1 +#define GL_TESS_EVALUATION_SHADER_INVOCATIONS 0x82F2 +#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED 0x82F3 +#define GL_FRAGMENT_SHADER_INVOCATIONS 0x82F4 +#define GL_COMPUTE_SHADER_INVOCATIONS 0x82F5 +#define GL_CLIPPING_INPUT_PRIMITIVES 0x82F6 +#define GL_CLIPPING_OUTPUT_PRIMITIVES 0x82F7 +#define GL_POLYGON_OFFSET_CLAMP 0x8E1B +#define GL_SPIR_V_EXTENSIONS 0x9553 +#define GL_NUM_SPIR_V_EXTENSIONS 0x9554 +#define GL_TEXTURE_MAX_ANISOTROPY 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY 0x84FF +#define GL_TRANSFORM_FEEDBACK_OVERFLOW 0x82EC +#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW 0x82ED +typedef void (APIENTRYP PFNGLSPECIALIZESHADERPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpecializeShader (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +GLAPI void APIENTRY glMultiDrawArraysIndirectCount (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCount (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glPolygonOffsetClamp (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_VERSION_4_6 */ + +#ifndef GL_ARB_ES2_compatibility +#define GL_ARB_ES2_compatibility 1 +#endif /* GL_ARB_ES2_compatibility */ + +#ifndef GL_ARB_ES3_1_compatibility +#define GL_ARB_ES3_1_compatibility 1 +#endif /* GL_ARB_ES3_1_compatibility */ + +#ifndef GL_ARB_ES3_2_compatibility +#define GL_ARB_ES3_2_compatibility 1 +#define GL_PRIMITIVE_BOUNDING_BOX_ARB 0x92BE +#define GL_MULTISAMPLE_LINE_WIDTH_RANGE_ARB 0x9381 +#define GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY_ARB 0x9382 +typedef void (APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXARBPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveBoundingBoxARB (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#endif +#endif /* GL_ARB_ES3_2_compatibility */ + +#ifndef GL_ARB_ES3_compatibility +#define GL_ARB_ES3_compatibility 1 +#endif /* GL_ARB_ES3_compatibility */ + +#ifndef GL_ARB_arrays_of_arrays +#define GL_ARB_arrays_of_arrays 1 +#endif /* GL_ARB_arrays_of_arrays */ + +#ifndef GL_ARB_base_instance +#define GL_ARB_base_instance 1 +#endif /* GL_ARB_base_instance */ + +#ifndef GL_ARB_bindless_texture +#define GL_ARB_bindless_texture 1 +typedef khronos_uint64_t GLuint64EXT; +#define GL_UNSIGNED_INT64_ARB 0x140F +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLEARBPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64ARBPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64ARBPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VARBPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VARBPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleARB (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleARB (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentARB (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentARB (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleARB (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentARB (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentARB (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64ARB (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64ARB (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentARB (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentARB (GLuint64 handle); +GLAPI void APIENTRY glVertexAttribL1ui64ARB (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL1ui64vARB (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLui64vARB (GLuint index, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_ARB_bindless_texture */ + +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 +#endif /* GL_ARB_blend_func_extended */ + +#ifndef GL_ARB_buffer_storage +#define GL_ARB_buffer_storage 1 +#endif /* GL_ARB_buffer_storage */ + +#ifndef GL_ARB_cl_event +#define GL_ARB_cl_event 1 +struct _cl_context; +struct _cl_event; +#define GL_SYNC_CL_EVENT_ARB 0x8240 +#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 +typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); +#endif +#endif /* GL_ARB_cl_event */ + +#ifndef GL_ARB_clear_buffer_object +#define GL_ARB_clear_buffer_object 1 +#endif /* GL_ARB_clear_buffer_object */ + +#ifndef GL_ARB_clear_texture +#define GL_ARB_clear_texture 1 +#endif /* GL_ARB_clear_texture */ + +#ifndef GL_ARB_clip_control +#define GL_ARB_clip_control 1 +#endif /* GL_ARB_clip_control */ + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); +#endif +#endif /* GL_ARB_color_buffer_float */ + +#ifndef GL_ARB_compatibility +#define GL_ARB_compatibility 1 +#endif /* GL_ARB_compatibility */ + +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_ARB_compressed_texture_pixel_storage 1 +#endif /* GL_ARB_compressed_texture_pixel_storage */ + +#ifndef GL_ARB_compute_shader +#define GL_ARB_compute_shader 1 +#endif /* GL_ARB_compute_shader */ + +#ifndef GL_ARB_compute_variable_group_size +#define GL_ARB_compute_variable_group_size 1 +#define GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB 0x9344 +#define GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB 0x90EB +#define GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB 0x9345 +#define GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB 0x91BF +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDispatchComputeGroupSizeARB (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); +#endif +#endif /* GL_ARB_compute_variable_group_size */ + +#ifndef GL_ARB_conditional_render_inverted +#define GL_ARB_conditional_render_inverted 1 +#endif /* GL_ARB_conditional_render_inverted */ + +#ifndef GL_ARB_conservative_depth +#define GL_ARB_conservative_depth 1 +#endif /* GL_ARB_conservative_depth */ + +#ifndef GL_ARB_copy_buffer +#define GL_ARB_copy_buffer 1 +#endif /* GL_ARB_copy_buffer */ + +#ifndef GL_ARB_copy_image +#define GL_ARB_copy_image 1 +#endif /* GL_ARB_copy_image */ + +#ifndef GL_ARB_cull_distance +#define GL_ARB_cull_distance 1 +#endif /* GL_ARB_cull_distance */ + +#ifndef GL_ARB_debug_output +#define GL_ARB_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define GL_DEBUG_SOURCE_API_ARB 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B +#define GL_DEBUG_TYPE_ERROR_ARB 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif +#endif /* GL_ARB_debug_output */ + +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif /* GL_ARB_depth_buffer_float */ + +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +#endif /* GL_ARB_depth_clamp */ + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif /* GL_ARB_depth_texture */ + +#ifndef GL_ARB_derivative_control +#define GL_ARB_derivative_control 1 +#endif /* GL_ARB_derivative_control */ + +#ifndef GL_ARB_direct_state_access +#define GL_ARB_direct_state_access 1 +#endif /* GL_ARB_direct_state_access */ + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_ARB_draw_buffers */ + +#ifndef GL_ARB_draw_buffers_blend +#define GL_ARB_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif +#endif /* GL_ARB_draw_buffers_blend */ + +#ifndef GL_ARB_draw_elements_base_vertex +#define GL_ARB_draw_elements_base_vertex 1 +#endif /* GL_ARB_draw_elements_base_vertex */ + +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 +#endif /* GL_ARB_draw_indirect */ + +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_ARB_draw_instanced */ + +#ifndef GL_ARB_enhanced_layouts +#define GL_ARB_enhanced_layouts 1 +#endif /* GL_ARB_enhanced_layouts */ + +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 +#endif /* GL_ARB_explicit_attrib_location */ + +#ifndef GL_ARB_explicit_uniform_location +#define GL_ARB_explicit_uniform_location 1 +#endif /* GL_ARB_explicit_uniform_location */ + +#ifndef GL_ARB_fragment_coord_conventions +#define GL_ARB_fragment_coord_conventions 1 +#endif /* GL_ARB_fragment_coord_conventions */ + +#ifndef GL_ARB_fragment_layer_viewport +#define GL_ARB_fragment_layer_viewport 1 +#endif /* GL_ARB_fragment_layer_viewport */ + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void *string); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const void *string); +GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, void *string); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); +#endif +#endif /* GL_ARB_fragment_program */ + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif /* GL_ARB_fragment_program_shadow */ + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif /* GL_ARB_fragment_shader */ + +#ifndef GL_ARB_fragment_shader_interlock +#define GL_ARB_fragment_shader_interlock 1 +#endif /* GL_ARB_fragment_shader_interlock */ + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_ARB_framebuffer_no_attachments 1 +#endif /* GL_ARB_framebuffer_no_attachments */ + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#endif /* GL_ARB_framebuffer_object */ + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif /* GL_ARB_framebuffer_sRGB */ + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_ARB_geometry_shader4 */ + +#ifndef GL_ARB_get_program_binary +#define GL_ARB_get_program_binary 1 +#endif /* GL_ARB_get_program_binary */ + +#ifndef GL_ARB_get_texture_sub_image +#define GL_ARB_get_texture_sub_image 1 +#endif /* GL_ARB_get_texture_sub_image */ + +#ifndef GL_ARB_gl_spirv +#define GL_ARB_gl_spirv 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V_ARB 0x9551 +#define GL_SPIR_V_BINARY_ARB 0x9552 +typedef void (APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpecializeShaderARB (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +#endif +#endif /* GL_ARB_gl_spirv */ + +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 +#endif /* GL_ARB_gpu_shader5 */ + +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 +#endif /* GL_ARB_gpu_shader_fp64 */ + +#ifndef GL_ARB_gpu_shader_int64 +#define GL_ARB_gpu_shader_int64 1 +#define GL_INT64_ARB 0x140E +#define GL_INT64_VEC2_ARB 0x8FE9 +#define GL_INT64_VEC3_ARB 0x8FEA +#define GL_INT64_VEC4_ARB 0x8FEB +#define GL_UNSIGNED_INT64_VEC2_ARB 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_ARB 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_ARB 0x8FF7 +typedef void (APIENTRYP PFNGLUNIFORM1I64ARBPROC) (GLint location, GLint64 x); +typedef void (APIENTRYP PFNGLUNIFORM2I64ARBPROC) (GLint location, GLint64 x, GLint64 y); +typedef void (APIENTRYP PFNGLUNIFORM3I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z); +typedef void (APIENTRYP PFNGLUNIFORM4I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64ARBPROC) (GLint location, GLuint64 x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VARBPROC) (GLuint program, GLint location, GLint64 *params); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLuint64 *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64ARBPROC) (GLuint program, GLint location, GLint64 x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64ARBPROC) (GLuint program, GLint location, GLuint64 x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64ARB (GLint location, GLint64 x); +GLAPI void APIENTRY glUniform2i64ARB (GLint location, GLint64 x, GLint64 y); +GLAPI void APIENTRY glUniform3i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z); +GLAPI void APIENTRY glUniform4i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +GLAPI void APIENTRY glUniform1i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform2i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform3i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform4i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform1ui64ARB (GLint location, GLuint64 x); +GLAPI void APIENTRY glUniform2ui64ARB (GLint location, GLuint64 x, GLuint64 y); +GLAPI void APIENTRY glUniform3ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +GLAPI void APIENTRY glUniform4ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +GLAPI void APIENTRY glUniform1ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform2ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform3ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform4ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glGetUniformi64vARB (GLuint program, GLint location, GLint64 *params); +GLAPI void APIENTRY glGetUniformui64vARB (GLuint program, GLint location, GLuint64 *params); +GLAPI void APIENTRY glGetnUniformi64vARB (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); +GLAPI void APIENTRY glGetnUniformui64vARB (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); +GLAPI void APIENTRY glProgramUniform1i64ARB (GLuint program, GLint location, GLint64 x); +GLAPI void APIENTRY glProgramUniform2i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y); +GLAPI void APIENTRY glProgramUniform3i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); +GLAPI void APIENTRY glProgramUniform4i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +GLAPI void APIENTRY glProgramUniform1i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform2i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform3i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform4i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform1ui64ARB (GLuint program, GLint location, GLuint64 x); +GLAPI void APIENTRY glProgramUniform2ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y); +GLAPI void APIENTRY glProgramUniform3ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +GLAPI void APIENTRY glProgramUniform4ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +GLAPI void APIENTRY glProgramUniform1ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform2ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform3ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform4ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +#endif +#endif /* GL_ARB_gpu_shader_int64 */ + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +typedef khronos_uint16_t GLhalfARB; +#define GL_HALF_FLOAT_ARB 0x140B +#endif /* GL_ARB_half_float_pixel */ + +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif /* GL_ARB_half_float_vertex */ + +#ifndef GL_ARB_imaging +#define GL_ARB_imaging 1 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, void *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, void *table); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, void *image); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogram (GLenum target); +GLAPI void APIENTRY glResetMinmax (GLenum target); +#endif +#endif /* GL_ARB_imaging */ + +#ifndef GL_ARB_indirect_parameters +#define GL_ARB_indirect_parameters 1 +#define GL_PARAMETER_BUFFER_ARB 0x80EE +#define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#endif +#endif /* GL_ARB_indirect_parameters */ + +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); +#endif +#endif /* GL_ARB_instanced_arrays */ + +#ifndef GL_ARB_internalformat_query +#define GL_ARB_internalformat_query 1 +#endif /* GL_ARB_internalformat_query */ + +#ifndef GL_ARB_internalformat_query2 +#define GL_ARB_internalformat_query2 1 +#define GL_SRGB_DECODE_ARB 0x8299 +#define GL_VIEW_CLASS_EAC_R11 0x9383 +#define GL_VIEW_CLASS_EAC_RG11 0x9384 +#define GL_VIEW_CLASS_ETC2_RGB 0x9385 +#define GL_VIEW_CLASS_ETC2_RGBA 0x9386 +#define GL_VIEW_CLASS_ETC2_EAC_RGBA 0x9387 +#define GL_VIEW_CLASS_ASTC_4x4_RGBA 0x9388 +#define GL_VIEW_CLASS_ASTC_5x4_RGBA 0x9389 +#define GL_VIEW_CLASS_ASTC_5x5_RGBA 0x938A +#define GL_VIEW_CLASS_ASTC_6x5_RGBA 0x938B +#define GL_VIEW_CLASS_ASTC_6x6_RGBA 0x938C +#define GL_VIEW_CLASS_ASTC_8x5_RGBA 0x938D +#define GL_VIEW_CLASS_ASTC_8x6_RGBA 0x938E +#define GL_VIEW_CLASS_ASTC_8x8_RGBA 0x938F +#define GL_VIEW_CLASS_ASTC_10x5_RGBA 0x9390 +#define GL_VIEW_CLASS_ASTC_10x6_RGBA 0x9391 +#define GL_VIEW_CLASS_ASTC_10x8_RGBA 0x9392 +#define GL_VIEW_CLASS_ASTC_10x10_RGBA 0x9393 +#define GL_VIEW_CLASS_ASTC_12x10_RGBA 0x9394 +#define GL_VIEW_CLASS_ASTC_12x12_RGBA 0x9395 +#endif /* GL_ARB_internalformat_query2 */ + +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +#endif /* GL_ARB_invalidate_subdata */ + +#ifndef GL_ARB_map_buffer_alignment +#define GL_ARB_map_buffer_alignment 1 +#endif /* GL_ARB_map_buffer_alignment */ + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#endif /* GL_ARB_map_buffer_range */ + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_ARB_matrix_palette */ + +#ifndef GL_ARB_multi_bind +#define GL_ARB_multi_bind 1 +#endif /* GL_ARB_multi_bind */ + +#ifndef GL_ARB_multi_draw_indirect +#define GL_ARB_multi_draw_indirect 1 +#endif /* GL_ARB_multi_draw_indirect */ + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); +#endif +#endif /* GL_ARB_multisample */ + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); +#endif +#endif /* GL_ARB_multitexture */ + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); +GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQueryARB (GLenum target); +GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); +#endif +#endif /* GL_ARB_occlusion_query */ + +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 +#endif /* GL_ARB_occlusion_query2 */ + +#ifndef GL_ARB_parallel_shader_compile +#define GL_ARB_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_ARB 0x91B0 +#define GL_COMPLETION_STATUS_ARB 0x91B1 +typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSARBPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMaxShaderCompilerThreadsARB (GLuint count); +#endif +#endif /* GL_ARB_parallel_shader_compile */ + +#ifndef GL_ARB_pipeline_statistics_query +#define GL_ARB_pipeline_statistics_query 1 +#define GL_VERTICES_SUBMITTED_ARB 0x82EE +#define GL_PRIMITIVES_SUBMITTED_ARB 0x82EF +#define GL_VERTEX_SHADER_INVOCATIONS_ARB 0x82F0 +#define GL_TESS_CONTROL_SHADER_PATCHES_ARB 0x82F1 +#define GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB 0x82F2 +#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB 0x82F3 +#define GL_FRAGMENT_SHADER_INVOCATIONS_ARB 0x82F4 +#define GL_COMPUTE_SHADER_INVOCATIONS_ARB 0x82F5 +#define GL_CLIPPING_INPUT_PRIMITIVES_ARB 0x82F6 +#define GL_CLIPPING_OUTPUT_PRIMITIVES_ARB 0x82F7 +#endif /* GL_ARB_pipeline_statistics_query */ + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif /* GL_ARB_pixel_buffer_object */ + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_ARB_point_parameters */ + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif /* GL_ARB_point_sprite */ + +#ifndef GL_ARB_polygon_offset_clamp +#define GL_ARB_polygon_offset_clamp 1 +#endif /* GL_ARB_polygon_offset_clamp */ + +#ifndef GL_ARB_post_depth_coverage +#define GL_ARB_post_depth_coverage 1 +#endif /* GL_ARB_post_depth_coverage */ + +#ifndef GL_ARB_program_interface_query +#define GL_ARB_program_interface_query 1 +#endif /* GL_ARB_program_interface_query */ + +#ifndef GL_ARB_provoking_vertex +#define GL_ARB_provoking_vertex 1 +#endif /* GL_ARB_provoking_vertex */ + +#ifndef GL_ARB_query_buffer_object +#define GL_ARB_query_buffer_object 1 +#endif /* GL_ARB_query_buffer_object */ + +#ifndef GL_ARB_robust_buffer_access_behavior +#define GL_ARB_robust_buffer_access_behavior 1 +#endif /* GL_ARB_robust_buffer_access_behavior */ + +#ifndef GL_ARB_robustness +#define GL_ARB_robustness 1 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); +typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, void *img); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); +GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); +GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, void *img); +GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +#endif +#endif /* GL_ARB_robustness */ + +#ifndef GL_ARB_robustness_isolation +#define GL_ARB_robustness_isolation 1 +#endif /* GL_ARB_robustness_isolation */ + +#ifndef GL_ARB_sample_locations +#define GL_ARB_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB 0x9340 +#define GL_SAMPLE_LOCATION_ARB 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_ARB 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_ARB 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_ARB 0x9343 +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLEVALUATEDEPTHVALUESARBPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSampleLocationsfvARB (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvARB (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glEvaluateDepthValuesARB (void); +#endif +#endif /* GL_ARB_sample_locations */ + +#ifndef GL_ARB_sample_shading +#define GL_ARB_sample_shading 1 +#define GL_SAMPLE_SHADING_ARB 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); +#endif +#endif /* GL_ARB_sample_shading */ + +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 +#endif /* GL_ARB_sampler_objects */ + +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map 1 +#endif /* GL_ARB_seamless_cube_map */ + +#ifndef GL_ARB_seamless_cubemap_per_texture +#define GL_ARB_seamless_cubemap_per_texture 1 +#endif /* GL_ARB_seamless_cubemap_per_texture */ + +#ifndef GL_ARB_separate_shader_objects +#define GL_ARB_separate_shader_objects 1 +#endif /* GL_ARB_separate_shader_objects */ + +#ifndef GL_ARB_shader_atomic_counter_ops +#define GL_ARB_shader_atomic_counter_ops 1 +#endif /* GL_ARB_shader_atomic_counter_ops */ + +#ifndef GL_ARB_shader_atomic_counters +#define GL_ARB_shader_atomic_counters 1 +#endif /* GL_ARB_shader_atomic_counters */ + +#ifndef GL_ARB_shader_ballot +#define GL_ARB_shader_ballot 1 +#endif /* GL_ARB_shader_ballot */ + +#ifndef GL_ARB_shader_bit_encoding +#define GL_ARB_shader_bit_encoding 1 +#endif /* GL_ARB_shader_bit_encoding */ + +#ifndef GL_ARB_shader_clock +#define GL_ARB_shader_clock 1 +#endif /* GL_ARB_shader_clock */ + +#ifndef GL_ARB_shader_draw_parameters +#define GL_ARB_shader_draw_parameters 1 +#endif /* GL_ARB_shader_draw_parameters */ + +#ifndef GL_ARB_shader_group_vote +#define GL_ARB_shader_group_vote 1 +#endif /* GL_ARB_shader_group_vote */ + +#ifndef GL_ARB_shader_image_load_store +#define GL_ARB_shader_image_load_store 1 +#endif /* GL_ARB_shader_image_load_store */ + +#ifndef GL_ARB_shader_image_size +#define GL_ARB_shader_image_size 1 +#endif /* GL_ARB_shader_image_size */ + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef __APPLE__ +typedef void *GLhandleARB; +#else +typedef unsigned int GLhandleARB; +#endif +typedef char GLcharARB; +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif +#endif /* GL_ARB_shader_objects */ + +#ifndef GL_ARB_shader_precision +#define GL_ARB_shader_precision 1 +#endif /* GL_ARB_shader_precision */ + +#ifndef GL_ARB_shader_stencil_export +#define GL_ARB_shader_stencil_export 1 +#endif /* GL_ARB_shader_stencil_export */ + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +#endif /* GL_ARB_shader_storage_buffer_object */ + +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 +#endif /* GL_ARB_shader_subroutine */ + +#ifndef GL_ARB_shader_texture_image_samples +#define GL_ARB_shader_texture_image_samples 1 +#endif /* GL_ARB_shader_texture_image_samples */ + +#ifndef GL_ARB_shader_texture_lod +#define GL_ARB_shader_texture_lod 1 +#endif /* GL_ARB_shader_texture_lod */ + +#ifndef GL_ARB_shader_viewport_layer_array +#define GL_ARB_shader_viewport_layer_array 1 +#endif /* GL_ARB_shader_viewport_layer_array */ + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif /* GL_ARB_shading_language_100 */ + +#ifndef GL_ARB_shading_language_420pack +#define GL_ARB_shading_language_420pack 1 +#endif /* GL_ARB_shading_language_420pack */ + +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA +typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); +typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); +GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif +#endif /* GL_ARB_shading_language_include */ + +#ifndef GL_ARB_shading_language_packing +#define GL_ARB_shading_language_packing 1 +#endif /* GL_ARB_shading_language_packing */ + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif /* GL_ARB_shadow */ + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif /* GL_ARB_shadow_ambient */ + +#ifndef GL_ARB_sparse_buffer +#define GL_ARB_sparse_buffer 1 +#define GL_SPARSE_STORAGE_BIT_ARB 0x0400 +#define GL_SPARSE_BUFFER_PAGE_SIZE_ARB 0x82F8 +typedef void (APIENTRYP PFNGLBUFFERPAGECOMMITMENTARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); +typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTARBPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferPageCommitmentARB (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); +GLAPI void APIENTRY glNamedBufferPageCommitmentEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +GLAPI void APIENTRY glNamedBufferPageCommitmentARB (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +#endif +#endif /* GL_ARB_sparse_buffer */ + +#ifndef GL_ARB_sparse_texture +#define GL_ARB_sparse_texture 1 +#define GL_TEXTURE_SPARSE_ARB 0x91A6 +#define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7 +#define GL_NUM_SPARSE_LEVELS_ARB 0x91AA +#define GL_NUM_VIRTUAL_PAGE_SIZES_ARB 0x91A8 +#define GL_VIRTUAL_PAGE_SIZE_X_ARB 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_ARB 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_ARB 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_ARB 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A +#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9 +typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +#endif +#endif /* GL_ARB_sparse_texture */ + +#ifndef GL_ARB_sparse_texture2 +#define GL_ARB_sparse_texture2 1 +#endif /* GL_ARB_sparse_texture2 */ + +#ifndef GL_ARB_sparse_texture_clamp +#define GL_ARB_sparse_texture_clamp 1 +#endif /* GL_ARB_sparse_texture_clamp */ + +#ifndef GL_ARB_spirv_extensions +#define GL_ARB_spirv_extensions 1 +#endif /* GL_ARB_spirv_extensions */ + +#ifndef GL_ARB_stencil_texturing +#define GL_ARB_stencil_texturing 1 +#endif /* GL_ARB_stencil_texturing */ + +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#endif /* GL_ARB_sync */ + +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 +#endif /* GL_ARB_tessellation_shader */ + +#ifndef GL_ARB_texture_barrier +#define GL_ARB_texture_barrier 1 +#endif /* GL_ARB_texture_barrier */ + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif /* GL_ARB_texture_border_clamp */ + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); +#endif +#endif /* GL_ARB_texture_buffer_object */ + +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 +#endif /* GL_ARB_texture_buffer_object_rgb32 */ + +#ifndef GL_ARB_texture_buffer_range +#define GL_ARB_texture_buffer_range 1 +#endif /* GL_ARB_texture_buffer_range */ + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, void *img); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, void *img); +#endif +#endif /* GL_ARB_texture_compression */ + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif /* GL_ARB_texture_compression_bptc */ + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif /* GL_ARB_texture_compression_rgtc */ + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif /* GL_ARB_texture_cube_map */ + +#ifndef GL_ARB_texture_cube_map_array +#define GL_ARB_texture_cube_map_array 1 +#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F +#endif /* GL_ARB_texture_cube_map_array */ + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif /* GL_ARB_texture_env_add */ + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif /* GL_ARB_texture_env_combine */ + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif /* GL_ARB_texture_env_crossbar */ + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif /* GL_ARB_texture_env_dot3 */ + +#ifndef GL_ARB_texture_filter_anisotropic +#define GL_ARB_texture_filter_anisotropic 1 +#endif /* GL_ARB_texture_filter_anisotropic */ + +#ifndef GL_ARB_texture_filter_minmax +#define GL_ARB_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_ARB 0x9366 +#define GL_WEIGHTED_AVERAGE_ARB 0x9367 +#endif /* GL_ARB_texture_filter_minmax */ + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif /* GL_ARB_texture_float */ + +#ifndef GL_ARB_texture_gather +#define GL_ARB_texture_gather 1 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F +#endif /* GL_ARB_texture_gather */ + +#ifndef GL_ARB_texture_mirror_clamp_to_edge +#define GL_ARB_texture_mirror_clamp_to_edge 1 +#endif /* GL_ARB_texture_mirror_clamp_to_edge */ + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif /* GL_ARB_texture_mirrored_repeat */ + +#ifndef GL_ARB_texture_multisample +#define GL_ARB_texture_multisample 1 +#endif /* GL_ARB_texture_multisample */ + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif /* GL_ARB_texture_non_power_of_two */ + +#ifndef GL_ARB_texture_query_levels +#define GL_ARB_texture_query_levels 1 +#endif /* GL_ARB_texture_query_levels */ + +#ifndef GL_ARB_texture_query_lod +#define GL_ARB_texture_query_lod 1 +#endif /* GL_ARB_texture_query_lod */ + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif /* GL_ARB_texture_rectangle */ + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif /* GL_ARB_texture_rg */ + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 +#endif /* GL_ARB_texture_rgb10_a2ui */ + +#ifndef GL_ARB_texture_stencil8 +#define GL_ARB_texture_stencil8 1 +#endif /* GL_ARB_texture_stencil8 */ + +#ifndef GL_ARB_texture_storage +#define GL_ARB_texture_storage 1 +#endif /* GL_ARB_texture_storage */ + +#ifndef GL_ARB_texture_storage_multisample +#define GL_ARB_texture_storage_multisample 1 +#endif /* GL_ARB_texture_storage_multisample */ + +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 +#endif /* GL_ARB_texture_swizzle */ + +#ifndef GL_ARB_texture_view +#define GL_ARB_texture_view 1 +#endif /* GL_ARB_texture_view */ + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 +#endif /* GL_ARB_timer_query */ + +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 +#endif /* GL_ARB_transform_feedback2 */ + +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 +#endif /* GL_ARB_transform_feedback3 */ + +#ifndef GL_ARB_transform_feedback_instanced +#define GL_ARB_transform_feedback_instanced 1 +#endif /* GL_ARB_transform_feedback_instanced */ + +#ifndef GL_ARB_transform_feedback_overflow_query +#define GL_ARB_transform_feedback_overflow_query 1 +#define GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB 0x82EC +#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB 0x82ED +#endif /* GL_ARB_transform_feedback_overflow_query */ + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); +#endif +#endif /* GL_ARB_transpose_matrix */ + +#ifndef GL_ARB_uniform_buffer_object +#define GL_ARB_uniform_buffer_object 1 +#endif /* GL_ARB_uniform_buffer_object */ + +#ifndef GL_ARB_vertex_array_bgra +#define GL_ARB_vertex_array_bgra 1 +#endif /* GL_ARB_vertex_array_bgra */ + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#endif /* GL_ARB_vertex_array_object */ + +#ifndef GL_ARB_vertex_attrib_64bit +#define GL_ARB_vertex_attrib_64bit 1 +#endif /* GL_ARB_vertex_attrib_64bit */ + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_ARB_vertex_attrib_binding 1 +#endif /* GL_ARB_vertex_attrib_binding */ + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); +GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); +GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); +GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); +GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); +GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); +GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); +GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); +GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glVertexBlendARB (GLint count); +#endif +#endif /* GL_ARB_vertex_blend */ + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +typedef khronos_ssize_t GLsizeiptrARB; +typedef khronos_intptr_t GLintptrARB; +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); +GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); +GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); +GLAPI void *APIENTRY glMapBufferARB (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_ARB_vertex_buffer_object */ + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, void **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, void **pointer); +#endif +#endif /* GL_ARB_vertex_program */ + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); +#endif +#endif /* GL_ARB_vertex_shader */ + +#ifndef GL_ARB_vertex_type_10f_11f_11f_rev +#define GL_ARB_vertex_type_10f_11f_11f_rev 1 +#endif /* GL_ARB_vertex_type_10f_11f_11f_rev */ + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 +#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ + +#ifndef GL_ARB_viewport_array +#define GL_ARB_viewport_array 1 +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYDVNVPROC) (GLuint first, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDDNVPROC) (GLuint index, GLdouble n, GLdouble f); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangeArraydvNV (GLuint first, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glDepthRangeIndexeddNV (GLuint index, GLdouble n, GLdouble f); +#endif +#endif /* GL_ARB_viewport_array */ + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); +#endif +#endif /* GL_ARB_window_pos */ + +#ifndef GL_KHR_blend_equation_advanced +#define GL_KHR_blend_equation_advanced 1 +#define GL_MULTIPLY_KHR 0x9294 +#define GL_SCREEN_KHR 0x9295 +#define GL_OVERLAY_KHR 0x9296 +#define GL_DARKEN_KHR 0x9297 +#define GL_LIGHTEN_KHR 0x9298 +#define GL_COLORDODGE_KHR 0x9299 +#define GL_COLORBURN_KHR 0x929A +#define GL_HARDLIGHT_KHR 0x929B +#define GL_SOFTLIGHT_KHR 0x929C +#define GL_DIFFERENCE_KHR 0x929E +#define GL_EXCLUSION_KHR 0x92A0 +#define GL_HSL_HUE_KHR 0x92AD +#define GL_HSL_SATURATION_KHR 0x92AE +#define GL_HSL_COLOR_KHR 0x92AF +#define GL_HSL_LUMINOSITY_KHR 0x92B0 +typedef void (APIENTRYP PFNGLBLENDBARRIERKHRPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendBarrierKHR (void); +#endif +#endif /* GL_KHR_blend_equation_advanced */ + +#ifndef GL_KHR_blend_equation_advanced_coherent +#define GL_KHR_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 +#endif /* GL_KHR_blend_equation_advanced_coherent */ + +#ifndef GL_KHR_context_flush_control +#define GL_KHR_context_flush_control 1 +#endif /* GL_KHR_context_flush_control */ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#endif /* GL_KHR_debug */ + +#ifndef GL_KHR_no_error +#define GL_KHR_no_error 1 +#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 +#endif /* GL_KHR_no_error */ + +#ifndef GL_KHR_parallel_shader_compile +#define GL_KHR_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 +typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSKHRPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMaxShaderCompilerThreadsKHR (GLuint count); +#endif +#endif /* GL_KHR_parallel_shader_compile */ + +#ifndef GL_KHR_robust_buffer_access_behavior +#define GL_KHR_robust_buffer_access_behavior 1 +#endif /* GL_KHR_robust_buffer_access_behavior */ + +#ifndef GL_KHR_robustness +#define GL_KHR_robustness 1 +#define GL_CONTEXT_ROBUST_ACCESS 0x90F3 +#endif /* GL_KHR_robustness */ + +#ifndef GL_KHR_shader_subgroup +#define GL_KHR_shader_subgroup 1 +#define GL_SUBGROUP_SIZE_KHR 0x9532 +#define GL_SUBGROUP_SUPPORTED_STAGES_KHR 0x9533 +#define GL_SUBGROUP_SUPPORTED_FEATURES_KHR 0x9534 +#define GL_SUBGROUP_QUAD_ALL_STAGES_KHR 0x9535 +#define GL_SUBGROUP_FEATURE_BASIC_BIT_KHR 0x00000001 +#define GL_SUBGROUP_FEATURE_VOTE_BIT_KHR 0x00000002 +#define GL_SUBGROUP_FEATURE_ARITHMETIC_BIT_KHR 0x00000004 +#define GL_SUBGROUP_FEATURE_BALLOT_BIT_KHR 0x00000008 +#define GL_SUBGROUP_FEATURE_SHUFFLE_BIT_KHR 0x00000010 +#define GL_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT_KHR 0x00000020 +#define GL_SUBGROUP_FEATURE_CLUSTERED_BIT_KHR 0x00000040 +#define GL_SUBGROUP_FEATURE_QUAD_BIT_KHR 0x00000080 +#endif /* GL_KHR_shader_subgroup */ + +#ifndef GL_KHR_texture_compression_astc_hdr +#define GL_KHR_texture_compression_astc_hdr 1 +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif /* GL_KHR_texture_compression_astc_hdr */ + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif /* GL_KHR_texture_compression_astc_ldr */ + +#ifndef GL_KHR_texture_compression_astc_sliced_3d +#define GL_KHR_texture_compression_astc_sliced_3d 1 +#endif /* GL_KHR_texture_compression_astc_sliced_3d */ + +#ifndef GL_OES_byte_coordinates +#define GL_OES_byte_coordinates 1 +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BOESPROC) (GLenum texture, GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD1BOESPROC) (GLbyte s); +typedef void (APIENTRYP PFNGLTEXCOORD1BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2BOESPROC) (GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLTEXCOORD2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x, GLbyte y); +typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y, GLbyte z); +typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z, GLbyte w); +typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s); +GLAPI void APIENTRY glMultiTexCoord1bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord2bOES (GLenum texture, GLbyte s, GLbyte t); +GLAPI void APIENTRY glMultiTexCoord2bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord3bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glMultiTexCoord3bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord4bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glMultiTexCoord4bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glTexCoord1bOES (GLbyte s); +GLAPI void APIENTRY glTexCoord1bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord2bOES (GLbyte s, GLbyte t); +GLAPI void APIENTRY glTexCoord2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex2bOES (GLbyte x, GLbyte y); +GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y, GLbyte z); +GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z, GLbyte w); +GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords); +#endif +#endif /* GL_OES_byte_coordinates */ + +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif /* GL_OES_compressed_paletted_texture */ + +#ifndef GL_OES_fixed_point +#define GL_OES_fixed_point 1 +typedef khronos_int32_t GLfixed; +#define GL_FIXED_OES 0x140C +typedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref); +typedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLfixed depth); +typedef void (APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation); +typedef void (APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum plane, GLfixed *equation); +typedef void (APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width); +typedef void (APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz); +typedef void (APIENTRYP PFNGLORTHOXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); +typedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLACCUMXOESPROC) (GLenum op, GLfixed value); +typedef void (APIENTRYP PFNGLBITMAPXOESPROC) (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +typedef void (APIENTRYP PFNGLBLENDCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARACCUMXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCOLOR3XOESPROC) (GLfixed red, GLfixed green, GLfixed blue); +typedef void (APIENTRYP PFNGLCOLOR3XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCOLOR4XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLEVALCOORD1XOESPROC) (GLfixed u); +typedef void (APIENTRYP PFNGLEVALCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLEVALCOORD2XOESPROC) (GLfixed u, GLfixed v); +typedef void (APIENTRYP PFNGLEVALCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLFEEDBACKBUFFERXOESPROC) (GLsizei n, GLenum type, const GLfixed *buffer); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETMAPXVOESPROC) (GLenum target, GLenum query, GLfixed *v); +typedef void (APIENTRYP PFNGLGETMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLGETPIXELMAPXVPROC) (GLenum map, GLint size, GLfixed *values); +typedef void (APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERXVOESPROC) (GLenum target, GLint level, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLINDEXXOESPROC) (GLfixed component); +typedef void (APIENTRYP PFNGLINDEXXVOESPROC) (const GLfixed *component); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMAP1XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +typedef void (APIENTRYP PFNGLMAP2XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +typedef void (APIENTRYP PFNGLMAPGRID1XOESPROC) (GLint n, GLfixed u1, GLfixed u2); +typedef void (APIENTRYP PFNGLMAPGRID2XOESPROC) (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XOESPROC) (GLenum texture, GLfixed s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XOESPROC) (GLenum texture, GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLNORMAL3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLPASSTHROUGHXOESPROC) (GLfixed token); +typedef void (APIENTRYP PFNGLPIXELMAPXPROC) (GLenum map, GLint size, const GLfixed *values); +typedef void (APIENTRYP PFNGLPIXELSTOREXPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELTRANSFERXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELZOOMXOESPROC) (GLfixed xfactor, GLfixed yfactor); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESXOESPROC) (GLsizei n, const GLuint *textures, const GLfixed *priorities); +typedef void (APIENTRYP PFNGLRASTERPOS2XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLRASTERPOS2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS3XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLRASTERPOS3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS4XOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +typedef void (APIENTRYP PFNGLRASTERPOS4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRECTXOESPROC) (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +typedef void (APIENTRYP PFNGLRECTXVOESPROC) (const GLfixed *v1, const GLfixed *v2); +typedef void (APIENTRYP PFNGLTEXCOORD1XOESPROC) (GLfixed s); +typedef void (APIENTRYP PFNGLTEXCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2XOESPROC) (GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLTEXCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3XOESPROC) (GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLTEXCOORD3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4XOESPROC) (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLTEXCOORD4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLVERTEX2XOESPROC) (GLfixed x); +typedef void (APIENTRYP PFNGLVERTEX2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX3XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLVERTEX3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX4XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLVERTEX4XVOESPROC) (const GLfixed *coords); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAlphaFuncxOES (GLenum func, GLfixed ref); +GLAPI void APIENTRY glClearColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearDepthxOES (GLfixed depth); +GLAPI void APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation); +GLAPI void APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glDepthRangexOES (GLfixed n, GLfixed f); +GLAPI void APIENTRY glFogxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glFogxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glFrustumxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glGetClipPlanexOES (GLenum plane, GLfixed *equation); +GLAPI void APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexEnvxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glLightModelxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glLineWidthxOES (GLfixed width); +GLAPI void APIENTRY glLoadMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glMultMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord4xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz); +GLAPI void APIENTRY glOrthoxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glPointSizexOES (GLfixed size); +GLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); +GLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glAccumxOES (GLenum op, GLfixed value); +GLAPI void APIENTRY glBitmapxOES (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +GLAPI void APIENTRY glBlendColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearAccumxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glColor3xOES (GLfixed red, GLfixed green, GLfixed blue); +GLAPI void APIENTRY glColor3xvOES (const GLfixed *components); +GLAPI void APIENTRY glColor4xvOES (const GLfixed *components); +GLAPI void APIENTRY glConvolutionParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glConvolutionParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glEvalCoord1xOES (GLfixed u); +GLAPI void APIENTRY glEvalCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glEvalCoord2xOES (GLfixed u, GLfixed v); +GLAPI void APIENTRY glEvalCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glFeedbackBufferxOES (GLsizei n, GLenum type, const GLfixed *buffer); +GLAPI void APIENTRY glGetConvolutionParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetHistogramParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetLightxOES (GLenum light, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetMapxvOES (GLenum target, GLenum query, GLfixed *v); +GLAPI void APIENTRY glGetMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glGetPixelMapxv (GLenum map, GLint size, GLfixed *values); +GLAPI void APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexLevelParameterxvOES (GLenum target, GLint level, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glIndexxOES (GLfixed component); +GLAPI void APIENTRY glIndexxvOES (const GLfixed *component); +GLAPI void APIENTRY glLoadTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMap1xOES (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +GLAPI void APIENTRY glMap2xOES (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +GLAPI void APIENTRY glMapGrid1xOES (GLint n, GLfixed u1, GLfixed u2); +GLAPI void APIENTRY glMapGrid2xOES (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +GLAPI void APIENTRY glMultTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord1xOES (GLenum texture, GLfixed s); +GLAPI void APIENTRY glMultiTexCoord1xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord2xOES (GLenum texture, GLfixed s, GLfixed t); +GLAPI void APIENTRY glMultiTexCoord2xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord3xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glMultiTexCoord3xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord4xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glNormal3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glPassThroughxOES (GLfixed token); +GLAPI void APIENTRY glPixelMapx (GLenum map, GLint size, const GLfixed *values); +GLAPI void APIENTRY glPixelStorex (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelTransferxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelZoomxOES (GLfixed xfactor, GLfixed yfactor); +GLAPI void APIENTRY glPrioritizeTexturesxOES (GLsizei n, const GLuint *textures, const GLfixed *priorities); +GLAPI void APIENTRY glRasterPos2xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glRasterPos2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos3xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glRasterPos3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos4xOES (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +GLAPI void APIENTRY glRasterPos4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRectxOES (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +GLAPI void APIENTRY glRectxvOES (const GLfixed *v1, const GLfixed *v2); +GLAPI void APIENTRY glTexCoord1xOES (GLfixed s); +GLAPI void APIENTRY glTexCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord2xOES (GLfixed s, GLfixed t); +GLAPI void APIENTRY glTexCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord3xOES (GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glTexCoord3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord4xOES (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glTexCoord4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glVertex2xOES (GLfixed x); +GLAPI void APIENTRY glVertex2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex3xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glVertex3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex4xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glVertex4xvOES (const GLfixed *coords); +#endif +#endif /* GL_OES_fixed_point */ + +#ifndef GL_OES_query_matrix +#define GL_OES_query_matrix 1 +typedef GLbitfield (APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed *mantissa, GLint *exponent); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLbitfield APIENTRY glQueryMatrixxOES (GLfixed *mantissa, GLint *exponent); +#endif +#endif /* GL_OES_query_matrix */ + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif /* GL_OES_read_format */ + +#ifndef GL_OES_single_precision +#define GL_OES_single_precision 1 +typedef void (APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); +typedef void (APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation); +typedef void (APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); +typedef void (APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat *equation); +typedef void (APIENTRYP PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearDepthfOES (GLclampf depth); +GLAPI void APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); +GLAPI void APIENTRY glDepthRangefOES (GLclampf n, GLclampf f); +GLAPI void APIENTRY glFrustumfOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +GLAPI void APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation); +GLAPI void APIENTRY glOrthofOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +#endif +#endif /* GL_OES_single_precision */ + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif /* GL_3DFX_multisample */ + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); +#endif +#endif /* GL_3DFX_tbuffer */ + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif /* GL_3DFX_texture_compression_FXT1 */ + +#ifndef GL_AMD_blend_minmax_factor +#define GL_AMD_blend_minmax_factor 1 +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif /* GL_AMD_blend_minmax_factor */ + +#ifndef GL_AMD_conservative_depth +#define GL_AMD_conservative_depth 1 +#endif /* GL_AMD_conservative_depth */ + +#ifndef GL_AMD_debug_output +#define GL_AMD_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); +#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 +#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 +#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 +#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A +#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B +#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C +#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D +#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E +#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F +#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 +typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufSize, GLenum *categories, GLenum *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufSize, GLenum *categories, GLenum *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif +#endif /* GL_AMD_debug_output */ + +#ifndef GL_AMD_depth_clamp_separate +#define GL_AMD_depth_clamp_separate 1 +#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E +#define GL_DEPTH_CLAMP_FAR_AMD 0x901F +#endif /* GL_AMD_depth_clamp_separate */ + +#ifndef GL_AMD_draw_buffers_blend +#define GL_AMD_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif +#endif /* GL_AMD_draw_buffers_blend */ + +#ifndef GL_AMD_framebuffer_multisample_advanced +#define GL_AMD_framebuffer_multisample_advanced 1 +#define GL_RENDERBUFFER_STORAGE_SAMPLES_AMD 0x91B2 +#define GL_MAX_COLOR_FRAMEBUFFER_SAMPLES_AMD 0x91B3 +#define GL_MAX_COLOR_FRAMEBUFFER_STORAGE_SAMPLES_AMD 0x91B4 +#define GL_MAX_DEPTH_STENCIL_FRAMEBUFFER_SAMPLES_AMD 0x91B5 +#define GL_NUM_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B6 +#define GL_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B7 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleAdvancedAMD (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleAdvancedAMD (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_AMD_framebuffer_multisample_advanced */ + +#ifndef GL_AMD_framebuffer_sample_positions +#define GL_AMD_framebuffer_sample_positions 1 +#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F +#define GL_PIXELS_PER_SAMPLE_PATTERN_X_AMD 0x91AE +#define GL_PIXELS_PER_SAMPLE_PATTERN_Y_AMD 0x91AF +#define GL_ALL_PIXELS_AMD 0xFFFFFFFF +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLEPOSITIONSFVAMDPROC) (GLenum target, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLEPOSITIONSFVAMDPROC) (GLuint framebuffer, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERFVAMDPROC) (GLenum target, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERFVAMDPROC) (GLuint framebuffer, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSamplePositionsfvAMD (GLenum target, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +GLAPI void APIENTRY glNamedFramebufferSamplePositionsfvAMD (GLuint framebuffer, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +GLAPI void APIENTRY glGetFramebufferParameterfvAMD (GLenum target, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +GLAPI void APIENTRY glGetNamedFramebufferParameterfvAMD (GLuint framebuffer, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +#endif +#endif /* GL_AMD_framebuffer_sample_positions */ + +#ifndef GL_AMD_gcn_shader +#define GL_AMD_gcn_shader 1 +#endif /* GL_AMD_gcn_shader */ + +#ifndef GL_AMD_gpu_shader_half_float +#define GL_AMD_gpu_shader_half_float 1 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +#define GL_FLOAT16_MAT2_AMD 0x91C5 +#define GL_FLOAT16_MAT3_AMD 0x91C6 +#define GL_FLOAT16_MAT4_AMD 0x91C7 +#define GL_FLOAT16_MAT2x3_AMD 0x91C8 +#define GL_FLOAT16_MAT2x4_AMD 0x91C9 +#define GL_FLOAT16_MAT3x2_AMD 0x91CA +#define GL_FLOAT16_MAT3x4_AMD 0x91CB +#define GL_FLOAT16_MAT4x2_AMD 0x91CC +#define GL_FLOAT16_MAT4x3_AMD 0x91CD +#endif /* GL_AMD_gpu_shader_half_float */ + +#ifndef GL_AMD_gpu_shader_int16 +#define GL_AMD_gpu_shader_int16 1 +#endif /* GL_AMD_gpu_shader_int16 */ + +#ifndef GL_AMD_gpu_shader_int64 +#define GL_AMD_gpu_shader_int64 1 +typedef khronos_int64_t GLint64EXT; +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); +GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); +GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); +GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); +GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); +GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); +GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_AMD_gpu_shader_int64 */ + +#ifndef GL_AMD_interleaved_elements +#define GL_AMD_interleaved_elements 1 +#define GL_VERTEX_ELEMENT_SWIZZLE_AMD 0x91A4 +#define GL_VERTEX_ID_SWIZZLE_AMD 0x91A5 +typedef void (APIENTRYP PFNGLVERTEXATTRIBPARAMETERIAMDPROC) (GLuint index, GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribParameteriAMD (GLuint index, GLenum pname, GLint param); +#endif +#endif /* GL_AMD_interleaved_elements */ + +#ifndef GL_AMD_multi_draw_indirect +#define GL_AMD_multi_draw_indirect 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); +#endif +#endif /* GL_AMD_multi_draw_indirect */ + +#ifndef GL_AMD_name_gen_delete +#define GL_AMD_name_gen_delete 1 +#define GL_DATA_BUFFER_AMD 0x9151 +#define GL_PERFORMANCE_MONITOR_AMD 0x9152 +#define GL_QUERY_OBJECT_AMD 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 +#define GL_SAMPLER_OBJECT_AMD 0x9155 +typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); +typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); +typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); +GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); +GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); +#endif +#endif /* GL_AMD_name_gen_delete */ + +#ifndef GL_AMD_occlusion_query_event +#define GL_AMD_occlusion_query_event 1 +#define GL_OCCLUSION_QUERY_EVENT_MASK_AMD 0x874F +#define GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD 0x00000001 +#define GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD 0x00000002 +#define GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD 0x00000004 +#define GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD 0x00000008 +#define GL_QUERY_ALL_EVENT_BITS_AMD 0xFFFFFFFF +typedef void (APIENTRYP PFNGLQUERYOBJECTPARAMETERUIAMDPROC) (GLenum target, GLuint id, GLenum pname, GLuint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glQueryObjectParameteruiAMD (GLenum target, GLuint id, GLenum pname, GLuint param); +#endif +#endif /* GL_AMD_occlusion_query_event */ + +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); +typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data); +GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif +#endif /* GL_AMD_performance_monitor */ + +#ifndef GL_AMD_pinned_memory +#define GL_AMD_pinned_memory 1 +#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 +#endif /* GL_AMD_pinned_memory */ + +#ifndef GL_AMD_query_buffer_object +#define GL_AMD_query_buffer_object 1 +#define GL_QUERY_BUFFER_AMD 0x9192 +#define GL_QUERY_BUFFER_BINDING_AMD 0x9193 +#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 +#endif /* GL_AMD_query_buffer_object */ + +#ifndef GL_AMD_sample_positions +#define GL_AMD_sample_positions 1 +typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); +#endif +#endif /* GL_AMD_sample_positions */ + +#ifndef GL_AMD_seamless_cubemap_per_texture +#define GL_AMD_seamless_cubemap_per_texture 1 +#endif /* GL_AMD_seamless_cubemap_per_texture */ + +#ifndef GL_AMD_shader_atomic_counter_ops +#define GL_AMD_shader_atomic_counter_ops 1 +#endif /* GL_AMD_shader_atomic_counter_ops */ + +#ifndef GL_AMD_shader_ballot +#define GL_AMD_shader_ballot 1 +#endif /* GL_AMD_shader_ballot */ + +#ifndef GL_AMD_shader_explicit_vertex_parameter +#define GL_AMD_shader_explicit_vertex_parameter 1 +#endif /* GL_AMD_shader_explicit_vertex_parameter */ + +#ifndef GL_AMD_shader_gpu_shader_half_float_fetch +#define GL_AMD_shader_gpu_shader_half_float_fetch 1 +#endif /* GL_AMD_shader_gpu_shader_half_float_fetch */ + +#ifndef GL_AMD_shader_image_load_store_lod +#define GL_AMD_shader_image_load_store_lod 1 +#endif /* GL_AMD_shader_image_load_store_lod */ + +#ifndef GL_AMD_shader_stencil_export +#define GL_AMD_shader_stencil_export 1 +#endif /* GL_AMD_shader_stencil_export */ + +#ifndef GL_AMD_shader_trinary_minmax +#define GL_AMD_shader_trinary_minmax 1 +#endif /* GL_AMD_shader_trinary_minmax */ + +#ifndef GL_AMD_sparse_texture +#define GL_AMD_sparse_texture 1 +#define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A +#define GL_MIN_SPARSE_LEVEL_AMD 0x919B +#define GL_MIN_LOD_WARNING_AMD 0x919C +#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 +typedef void (APIENTRYP PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +typedef void (APIENTRYP PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorageSparseAMD (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +GLAPI void APIENTRY glTextureStorageSparseAMD (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#endif +#endif /* GL_AMD_sparse_texture */ + +#ifndef GL_AMD_stencil_operation_extended +#define GL_AMD_stencil_operation_extended 1 +#define GL_SET_AMD 0x874A +#define GL_REPLACE_VALUE_AMD 0x874B +#define GL_STENCIL_OP_VALUE_AMD 0x874C +#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D +typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); +#endif +#endif /* GL_AMD_stencil_operation_extended */ + +#ifndef GL_AMD_texture_gather_bias_lod +#define GL_AMD_texture_gather_bias_lod 1 +#endif /* GL_AMD_texture_gather_bias_lod */ + +#ifndef GL_AMD_texture_texture4 +#define GL_AMD_texture_texture4 1 +#endif /* GL_AMD_texture_texture4 */ + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#define GL_AMD_transform_feedback3_lines_triangles 1 +#endif /* GL_AMD_transform_feedback3_lines_triangles */ + +#ifndef GL_AMD_transform_feedback4 +#define GL_AMD_transform_feedback4 1 +#define GL_STREAM_RASTERIZATION_AMD 0x91A0 +#endif /* GL_AMD_transform_feedback4 */ + +#ifndef GL_AMD_vertex_shader_layer +#define GL_AMD_vertex_shader_layer 1 +#endif /* GL_AMD_vertex_shader_layer */ + +#ifndef GL_AMD_vertex_shader_tessellator +#define GL_AMD_vertex_shader_tessellator 1 +#define GL_SAMPLER_BUFFER_AMD 0x9001 +#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 +#define GL_TESSELLATION_MODE_AMD 0x9004 +#define GL_TESSELLATION_FACTOR_AMD 0x9005 +#define GL_DISCRETE_AMD 0x9006 +#define GL_CONTINUOUS_AMD 0x9007 +typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); +GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); +#endif +#endif /* GL_AMD_vertex_shader_tessellator */ + +#ifndef GL_AMD_vertex_shader_viewport_index +#define GL_AMD_vertex_shader_viewport_index 1 +#endif /* GL_AMD_vertex_shader_viewport_index */ + +#ifndef GL_APPLE_aux_depth_stencil +#define GL_APPLE_aux_depth_stencil 1 +#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 +#endif /* GL_APPLE_aux_depth_stencil */ + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif /* GL_APPLE_client_storage */ + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#define GL_ELEMENT_ARRAY_APPLE 0x8A0C +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const void *pointer); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif +#endif /* GL_APPLE_element_array */ + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); +#endif +#endif /* GL_APPLE_fence */ + +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 +#define GL_HALF_APPLE 0x140B +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881A +#define GL_RGB_FLOAT16_APPLE 0x881B +#define GL_ALPHA_FLOAT16_APPLE 0x881C +#define GL_INTENSITY_FLOAT16_APPLE 0x881D +#define GL_LUMINANCE_FLOAT16_APPLE 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F +#define GL_COLOR_FLOAT_APPLE 0x8A0F +#endif /* GL_APPLE_float_pixels */ + +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 +typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); +#endif +#endif /* GL_APPLE_flush_buffer_range */ + +#ifndef GL_APPLE_object_purgeable +#define GL_APPLE_object_purgeable 1 +#define GL_BUFFER_OBJECT_APPLE 0x85B3 +#define GL_RELEASED_APPLE 0x8A19 +#define GL_VOLATILE_APPLE 0x8A1A +#define GL_RETAINED_APPLE 0x8A1B +#define GL_UNDEFINED_APPLE 0x8A1C +#define GL_PURGEABLE_APPLE 0x8A1D +typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#endif +#endif /* GL_APPLE_object_purgeable */ + +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#define GL_RGB_RAW_422_APPLE 0x8A51 +#endif /* GL_APPLE_rgb_422 */ + +#ifndef GL_APPLE_row_bytes +#define GL_APPLE_row_bytes 1 +#define GL_PACK_ROW_BYTES_APPLE 0x8A15 +#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 +#endif /* GL_APPLE_row_bytes */ + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif /* GL_APPLE_specular_vector */ + +#ifndef GL_APPLE_texture_range +#define GL_APPLE_texture_range 1 +#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 +#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_STORAGE_PRIVATE_APPLE 0x85BD +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const void *pointer); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const void *pointer); +GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_APPLE_texture_range */ + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif /* GL_APPLE_transform_hint */ + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); +#endif +#endif /* GL_APPLE_vertex_array_object */ + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CLIENT_APPLE 0x85B4 +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, void *pointer); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, void *pointer); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); +#endif +#endif /* GL_APPLE_vertex_array_range */ + +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_APPLE_vertex_program_evaluators 1 +#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 +#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 +#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 +#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 +#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 +#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 +#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 +#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 +#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 +#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#endif +#endif /* GL_APPLE_vertex_program_evaluators */ + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#define GL_YCBCR_422_APPLE 0x85B9 +#endif /* GL_APPLE_ycbcr_422 */ + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_ATI_draw_buffers */ + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum type, const void *pointer); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif +#endif /* GL_ATI_element_array */ + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); +#endif +#endif /* GL_ATI_envmap_bumpmap */ + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); +GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); +#endif +#endif /* GL_ATI_fragment_shader */ + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +typedef void *(APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void *APIENTRY glMapObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); +#endif +#endif /* GL_ATI_map_object_buffer */ + +#ifndef GL_ATI_meminfo +#define GL_ATI_meminfo 1 +#define GL_VBO_FREE_MEMORY_ATI 0x87FB +#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC +#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD +#endif /* GL_ATI_meminfo */ + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +#define GL_RGBA_FLOAT_MODE_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif /* GL_ATI_pixel_format_float */ + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); +#endif +#endif /* GL_ATI_pn_triangles */ + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif +#endif /* GL_ATI_separate_stencil */ + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif /* GL_ATI_text_fragment_shader */ + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif /* GL_ATI_texture_env_combine3 */ + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif /* GL_ATI_texture_float */ + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif /* GL_ATI_texture_mirror_once */ + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const void *pointer, GLenum usage); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); +#endif +#endif /* GL_ATI_vertex_array_object */ + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); +#endif +#endif /* GL_ATI_vertex_attrib_array_object */ + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); +GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); +GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); +#endif +#endif /* GL_ATI_vertex_streams */ + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif /* GL_EXT_422_pixels */ + +#ifndef GL_EXT_EGL_image_storage +#define GL_EXT_EGL_image_storage 1 +typedef void *GLeglImageOES; +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC) (GLenum target, GLeglImageOES image, const GLint* attrib_list); +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC) (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEGLImageTargetTexStorageEXT (GLenum target, GLeglImageOES image, const GLint* attrib_list); +GLAPI void APIENTRY glEGLImageTargetTextureStorageEXT (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#endif +#endif /* GL_EXT_EGL_image_storage */ + +#ifndef GL_EXT_EGL_sync +#define GL_EXT_EGL_sync 1 +#endif /* GL_EXT_EGL_sync */ + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#define GL_ABGR_EXT 0x8000 +#endif /* GL_EXT_abgr */ + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif /* GL_EXT_bgra */ + +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF +typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); +typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); +GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); +GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); +#endif +#endif /* GL_EXT_bindable_uniform */ + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#endif +#endif /* GL_EXT_blend_color */ + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); +#endif +#endif /* GL_EXT_blend_equation_separate */ + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif +#endif /* GL_EXT_blend_func_separate */ + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif /* GL_EXT_blend_logic_op */ + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_BLEND_EQUATION_EXT 0x8009 +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); +#endif +#endif /* GL_EXT_blend_minmax */ + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif /* GL_EXT_blend_subtract */ + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif /* GL_EXT_clip_volume_hint */ + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif /* GL_EXT_cmyka */ + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif +#endif /* GL_EXT_color_subtable */ + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif +#endif /* GL_EXT_compiled_vertex_array */ + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, void *image); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +#endif +#endif /* GL_EXT_convolution */ + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); +GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); +GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); +GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_coordinate_frame */ + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_EXT_copy_texture */ + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_cull_vertex */ + +#ifndef GL_EXT_debug_label +#define GL_EXT_debug_label 1 +#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F +#define GL_PROGRAM_OBJECT_EXT 0x8B40 +#define GL_SHADER_OBJECT_EXT 0x8B48 +#define GL_BUFFER_OBJECT_EXT 0x9151 +#define GL_QUERY_OBJECT_EXT 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 +typedef void (APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_EXT_debug_label */ + +#ifndef GL_EXT_debug_marker +#define GL_EXT_debug_marker 1 +typedef void (APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); +GLAPI void APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); +GLAPI void APIENTRY glPopGroupMarkerEXT (void); +#endif +#endif /* GL_EXT_debug_marker */ + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); +#endif +#endif /* GL_EXT_depth_bounds_test */ + +#ifndef GL_EXT_direct_state_access +#define GL_EXT_direct_state_access 1 +#define GL_PROGRAM_MATRIX_EXT 0x8E2D +#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E +#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F +typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); +typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, void **data); +typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, void *img); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, void *img); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void **params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void *string); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); +typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, void **param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC) (GLuint vaobj, GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); +GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); +GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); +GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); +GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, void **data); +GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, void *img); +GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, void *img); +GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void *APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); +GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); +GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, void **params); +GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glEnableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloati_vEXT (GLenum pname, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetDoublei_vEXT (GLenum pname, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetPointeri_vEXT (GLenum pname, GLuint index, void **params); +GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); +GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, void *string); +GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); +GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); +GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glVertexArrayVertexOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayEdgeFlagOffsetEXT (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayIndexOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayNormalOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayMultiTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayFogCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArraySecondaryColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribIOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glEnableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glDisableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glEnableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glDisableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glGetVertexArrayIntegervEXT (GLuint vaobj, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointervEXT (GLuint vaobj, GLenum pname, void **param); +GLAPI void APIENTRY glGetVertexArrayIntegeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, void **param); +GLAPI void *APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glNamedBufferStorageEXT (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); +GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glTexturePageCommitmentEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +GLAPI void APIENTRY glVertexArrayVertexAttribDivisorEXT (GLuint vaobj, GLuint index, GLuint divisor); +#endif +#endif /* GL_EXT_direct_state_access */ + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 +typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#endif +#endif /* GL_EXT_draw_buffers2 */ + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_EXT_draw_instanced */ + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +#endif +#endif /* GL_EXT_draw_range_elements */ + +#ifndef GL_EXT_external_buffer +#define GL_EXT_external_buffer 1 +typedef void *GLeglClientBufferEXT; +typedef void (APIENTRYP PFNGLBUFFERSTORAGEEXTERNALEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferStorageExternalEXT (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +GLAPI void APIENTRY glNamedBufferStorageExternalEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#endif +#endif /* GL_EXT_external_buffer */ + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_fog_coord */ + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* GL_EXT_framebuffer_blit */ + +#ifndef GL_EXT_framebuffer_blit_layers +#define GL_EXT_framebuffer_blit_layers 1 +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERLAYERSEXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERLAYEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint srcLayer, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLint dstLayer, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlitFramebufferLayersEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glBlitFramebufferLayerEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint srcLayer, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLint dstLayer, GLbitfield mask, GLenum filter); +#endif +#endif /* GL_EXT_framebuffer_blit_layers */ + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_EXT_framebuffer_multisample */ + +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_EXT_framebuffer_multisample_blit_scaled 1 +#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA +#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB +#endif /* GL_EXT_framebuffer_multisample_blit_scaled */ + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); +#endif +#endif /* GL_EXT_framebuffer_object */ + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif /* GL_EXT_framebuffer_sRGB */ + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +#endif +#endif /* GL_EXT_geometry_shader4 */ + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif +#endif /* GL_EXT_gpu_program_parameters */ + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_EXT 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_EXT 0x8905 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD +typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); +#endif +#endif /* GL_EXT_gpu_shader4 */ + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogramEXT (GLenum target); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); +#endif +#endif /* GL_EXT_histogram */ + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif /* GL_EXT_index_array_formats */ + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); +#endif +#endif /* GL_EXT_index_func */ + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_index_material */ + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif /* GL_EXT_index_texture */ + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); +GLAPI void APIENTRY glTextureLightEXT (GLenum pname); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_light_texture */ + +#ifndef GL_EXT_memory_object +#define GL_EXT_memory_object 1 +#define GL_TEXTURE_TILING_EXT 0x9580 +#define GL_DEDICATED_MEMORY_OBJECT_EXT 0x9581 +#define GL_PROTECTED_MEMORY_OBJECT_EXT 0x959B +#define GL_NUM_TILING_TYPES_EXT 0x9582 +#define GL_TILING_TYPES_EXT 0x9583 +#define GL_OPTIMAL_TILING_EXT 0x9584 +#define GL_LINEAR_TILING_EXT 0x9585 +#define GL_NUM_DEVICE_UUIDS_EXT 0x9596 +#define GL_DEVICE_UUID_EXT 0x9597 +#define GL_DRIVER_UUID_EXT 0x9598 +#define GL_UUID_SIZE_EXT 16 +typedef void (APIENTRYP PFNGLGETUNSIGNEDBYTEVEXTPROC) (GLenum pname, GLubyte *data); +typedef void (APIENTRYP PFNGLGETUNSIGNEDBYTEI_VEXTPROC) (GLenum target, GLuint index, GLubyte *data); +typedef void (APIENTRYP PFNGLDELETEMEMORYOBJECTSEXTPROC) (GLsizei n, const GLuint *memoryObjects); +typedef GLboolean (APIENTRYP PFNGLISMEMORYOBJECTEXTPROC) (GLuint memoryObject); +typedef void (APIENTRYP PFNGLCREATEMEMORYOBJECTSEXTPROC) (GLsizei n, GLuint *memoryObjects); +typedef void (APIENTRYP PFNGLMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLBUFFERSTORAGEMEMEXTPROC) (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM2DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM3DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC) (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM1DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUnsignedBytevEXT (GLenum pname, GLubyte *data); +GLAPI void APIENTRY glGetUnsignedBytei_vEXT (GLenum target, GLuint index, GLubyte *data); +GLAPI void APIENTRY glDeleteMemoryObjectsEXT (GLsizei n, const GLuint *memoryObjects); +GLAPI GLboolean APIENTRY glIsMemoryObjectEXT (GLuint memoryObject); +GLAPI void APIENTRY glCreateMemoryObjectsEXT (GLsizei n, GLuint *memoryObjects); +GLAPI void APIENTRY glMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, GLint *params); +GLAPI void APIENTRY glTexStorageMem2DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem2DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem3DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem3DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glBufferStorageMemEXT (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem2DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem2DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem3DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem3DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glNamedBufferStorageMemEXT (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem1DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem1DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_EXT_memory_object */ + +#ifndef GL_EXT_memory_object_fd +#define GL_EXT_memory_object_fd 1 +#define GL_HANDLE_TYPE_OPAQUE_FD_EXT 0x9586 +typedef void (APIENTRYP PFNGLIMPORTMEMORYFDEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportMemoryFdEXT (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_memory_object_fd */ + +#ifndef GL_EXT_memory_object_win32 +#define GL_EXT_memory_object_win32 1 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_EXT 0x9587 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_KMT_EXT 0x9588 +#define GL_DEVICE_LUID_EXT 0x9599 +#define GL_DEVICE_NODE_MASK_EXT 0x959A +#define GL_LUID_SIZE_EXT 8 +#define GL_HANDLE_TYPE_D3D12_TILEPOOL_EXT 0x9589 +#define GL_HANDLE_TYPE_D3D12_RESOURCE_EXT 0x958A +#define GL_HANDLE_TYPE_D3D11_IMAGE_EXT 0x958B +#define GL_HANDLE_TYPE_D3D11_IMAGE_KMT_EXT 0x958C +typedef void (APIENTRYP PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +typedef void (APIENTRYP PFNGLIMPORTMEMORYWIN32NAMEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportMemoryWin32HandleEXT (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +GLAPI void APIENTRY glImportMemoryWin32NameEXT (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_memory_object_win32 */ + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif /* GL_EXT_misc_attribute */ + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#endif +#endif /* GL_EXT_multi_draw_arrays */ + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); +#endif +#endif /* GL_EXT_multisample */ + +#ifndef GL_EXT_multiview_tessellation_geometry_shader +#define GL_EXT_multiview_tessellation_geometry_shader 1 +#endif /* GL_EXT_multiview_tessellation_geometry_shader */ + +#ifndef GL_EXT_multiview_texture_multisample +#define GL_EXT_multiview_texture_multisample 1 +#endif /* GL_EXT_multiview_texture_multisample */ + +#ifndef GL_EXT_multiview_timer_query +#define GL_EXT_multiview_timer_query 1 +#endif /* GL_EXT_multiview_timer_query */ + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif /* GL_EXT_packed_depth_stencil */ + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C +#endif /* GL_EXT_packed_float */ + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif /* GL_EXT_packed_pixels */ + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, void *data); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_paletted_texture */ + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif /* GL_EXT_pixel_buffer_object */ + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTransformParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTransformParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_pixel_transform */ + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif /* GL_EXT_pixel_transform_color_table */ + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_EXT_point_parameters */ + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); +#endif +#endif /* GL_EXT_polygon_offset */ + +#ifndef GL_EXT_polygon_offset_clamp +#define GL_EXT_polygon_offset_clamp 1 +#define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B +typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPEXTPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetClampEXT (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_EXT_polygon_offset_clamp */ + +#ifndef GL_EXT_post_depth_coverage +#define GL_EXT_post_depth_coverage 1 +#endif /* GL_EXT_post_depth_coverage */ + +#ifndef GL_EXT_provoking_vertex +#define GL_EXT_provoking_vertex 1 +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E +#define GL_PROVOKING_VERTEX_EXT 0x8E4F +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); +#endif +#endif /* GL_EXT_provoking_vertex */ + +#ifndef GL_EXT_raster_multisample +#define GL_EXT_raster_multisample 1 +#define GL_RASTER_MULTISAMPLE_EXT 0x9327 +#define GL_RASTER_SAMPLES_EXT 0x9328 +#define GL_MAX_RASTER_SAMPLES_EXT 0x9329 +#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A +#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B +#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C +typedef void (APIENTRYP PFNGLRASTERSAMPLESEXTPROC) (GLuint samples, GLboolean fixedsamplelocations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRasterSamplesEXT (GLuint samples, GLboolean fixedsamplelocations); +#endif +#endif /* GL_EXT_raster_multisample */ + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif /* GL_EXT_rescale_normal */ + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_secondary_color */ + +#ifndef GL_EXT_semaphore +#define GL_EXT_semaphore 1 +#define GL_LAYOUT_GENERAL_EXT 0x958D +#define GL_LAYOUT_COLOR_ATTACHMENT_EXT 0x958E +#define GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT 0x958F +#define GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT 0x9590 +#define GL_LAYOUT_SHADER_READ_ONLY_EXT 0x9591 +#define GL_LAYOUT_TRANSFER_SRC_EXT 0x9592 +#define GL_LAYOUT_TRANSFER_DST_EXT 0x9593 +#define GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT 0x9530 +#define GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT 0x9531 +typedef void (APIENTRYP PFNGLGENSEMAPHORESEXTPROC) (GLsizei n, GLuint *semaphores); +typedef void (APIENTRYP PFNGLDELETESEMAPHORESEXTPROC) (GLsizei n, const GLuint *semaphores); +typedef GLboolean (APIENTRYP PFNGLISSEMAPHOREEXTPROC) (GLuint semaphore); +typedef void (APIENTRYP PFNGLSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, const GLuint64 *params); +typedef void (APIENTRYP PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLWAITSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +typedef void (APIENTRYP PFNGLSIGNALSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenSemaphoresEXT (GLsizei n, GLuint *semaphores); +GLAPI void APIENTRY glDeleteSemaphoresEXT (GLsizei n, const GLuint *semaphores); +GLAPI GLboolean APIENTRY glIsSemaphoreEXT (GLuint semaphore); +GLAPI void APIENTRY glSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, const GLuint64 *params); +GLAPI void APIENTRY glGetSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, GLuint64 *params); +GLAPI void APIENTRY glWaitSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +GLAPI void APIENTRY glSignalSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#endif +#endif /* GL_EXT_semaphore */ + +#ifndef GL_EXT_semaphore_fd +#define GL_EXT_semaphore_fd 1 +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREFDEXTPROC) (GLuint semaphore, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportSemaphoreFdEXT (GLuint semaphore, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_semaphore_fd */ + +#ifndef GL_EXT_semaphore_win32 +#define GL_EXT_semaphore_win32 1 +#define GL_HANDLE_TYPE_D3D12_FENCE_EXT 0x9594 +#define GL_D3D12_FENCE_VALUE_EXT 0x9595 +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC) (GLuint semaphore, GLenum handleType, void *handle); +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC) (GLuint semaphore, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportSemaphoreWin32HandleEXT (GLuint semaphore, GLenum handleType, void *handle); +GLAPI void APIENTRY glImportSemaphoreWin32NameEXT (GLuint semaphore, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_semaphore_win32 */ + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#define GL_ACTIVE_PROGRAM_EXT 0x8B8D +typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); +typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); +GLAPI void APIENTRY glActiveProgramEXT (GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); +#endif +#endif /* GL_EXT_separate_shader_objects */ + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif /* GL_EXT_separate_specular_color */ + +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_EXT_shader_framebuffer_fetch 1 +#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 +#endif /* GL_EXT_shader_framebuffer_fetch */ + +#ifndef GL_EXT_shader_framebuffer_fetch_non_coherent +#define GL_EXT_shader_framebuffer_fetch_non_coherent 1 +typedef void (APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferFetchBarrierEXT (void); +#endif +#endif /* GL_EXT_shader_framebuffer_fetch_non_coherent */ + +#ifndef GL_EXT_shader_image_load_formatted +#define GL_EXT_shader_image_load_formatted 1 +#endif /* GL_EXT_shader_image_load_formatted */ + +#ifndef GL_EXT_shader_image_load_store +#define GL_EXT_shader_image_load_store 1 +#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 +#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A +#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B +#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C +#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D +#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E +#define GL_IMAGE_1D_EXT 0x904C +#define GL_IMAGE_2D_EXT 0x904D +#define GL_IMAGE_3D_EXT 0x904E +#define GL_IMAGE_2D_RECT_EXT 0x904F +#define GL_IMAGE_CUBE_EXT 0x9050 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_IMAGE_1D_ARRAY_EXT 0x9052 +#define GL_IMAGE_2D_ARRAY_EXT 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 +#define GL_INT_IMAGE_1D_EXT 0x9057 +#define GL_INT_IMAGE_2D_EXT 0x9058 +#define GL_INT_IMAGE_3D_EXT 0x9059 +#define GL_INT_IMAGE_2D_RECT_EXT 0x905A +#define GL_INT_IMAGE_CUBE_EXT 0x905B +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D +#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C +#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D +#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 +#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 +#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); +#endif +#endif /* GL_EXT_shader_image_load_store */ + +#ifndef GL_EXT_shader_integer_mix +#define GL_EXT_shader_integer_mix 1 +#endif /* GL_EXT_shader_integer_mix */ + +#ifndef GL_EXT_shader_samples_identical +#define GL_EXT_shader_samples_identical 1 +#endif /* GL_EXT_shader_samples_identical */ + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif /* GL_EXT_shadow_funcs */ + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif /* GL_EXT_shared_texture_palette */ + +#ifndef GL_EXT_sparse_texture2 +#define GL_EXT_sparse_texture2 1 +#endif /* GL_EXT_sparse_texture2 */ + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 +typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif +#endif /* GL_EXT_stencil_clear_tag */ + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); +#endif +#endif /* GL_EXT_stencil_two_side */ + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif /* GL_EXT_stencil_wrap */ + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_EXT_subtexture */ + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif /* GL_EXT_texture */ + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_EXT_texture3D */ + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif +#endif /* GL_EXT_texture_array */ + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); +#endif +#endif /* GL_EXT_texture_buffer_object */ + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#endif /* GL_EXT_texture_compression_latc */ + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif /* GL_EXT_texture_compression_rgtc */ + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif /* GL_EXT_texture_compression_s3tc */ + +#ifndef GL_EXT_texture_cube_map +#define GL_EXT_texture_cube_map 1 +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif /* GL_EXT_texture_cube_map */ + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif /* GL_EXT_texture_env_add */ + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif /* GL_EXT_texture_env_combine */ + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif /* GL_EXT_texture_env_dot3 */ + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif /* GL_EXT_texture_filter_anisotropic */ + +#ifndef GL_EXT_texture_filter_minmax +#define GL_EXT_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366 +#define GL_WEIGHTED_AVERAGE_EXT 0x9367 +#endif /* GL_EXT_texture_filter_minmax */ + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); +GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif +#endif /* GL_EXT_texture_integer */ + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif /* GL_EXT_texture_lod_bias */ + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif /* GL_EXT_texture_mirror_clamp */ + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); +GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif +#endif /* GL_EXT_texture_object */ + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); +#endif +#endif /* GL_EXT_texture_perturb_normal */ + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif /* GL_EXT_texture_sRGB */ + +#ifndef GL_EXT_texture_sRGB_R8 +#define GL_EXT_texture_sRGB_R8 1 +#define GL_SR8_EXT 0x8FBD +#endif /* GL_EXT_texture_sRGB_R8 */ + +#ifndef GL_EXT_texture_sRGB_RG8 +#define GL_EXT_texture_sRGB_RG8 1 +#define GL_SRG8_EXT 0x8FBE +#endif /* GL_EXT_texture_sRGB_RG8 */ + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif /* GL_EXT_texture_sRGB_decode */ + +#ifndef GL_EXT_texture_shadow_lod +#define GL_EXT_texture_shadow_lod 1 +#endif /* GL_EXT_texture_shadow_lod */ + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F +#endif /* GL_EXT_texture_shared_exponent */ + +#ifndef GL_EXT_texture_snorm +#define GL_EXT_texture_snorm 1 +#define GL_ALPHA_SNORM 0x9010 +#define GL_LUMINANCE_SNORM 0x9011 +#define GL_LUMINANCE_ALPHA_SNORM 0x9012 +#define GL_INTENSITY_SNORM 0x9013 +#define GL_ALPHA8_SNORM 0x9014 +#define GL_LUMINANCE8_SNORM 0x9015 +#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 +#define GL_INTENSITY8_SNORM 0x9017 +#define GL_ALPHA16_SNORM 0x9018 +#define GL_LUMINANCE16_SNORM 0x9019 +#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A +#define GL_INTENSITY16_SNORM 0x901B +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 +#endif /* GL_EXT_texture_snorm */ + +#ifndef GL_EXT_texture_storage +#define GL_EXT_texture_storage 1 +#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F +#define GL_RGBA32F_EXT 0x8814 +#define GL_RGB32F_EXT 0x8815 +#define GL_ALPHA32F_EXT 0x8816 +#define GL_LUMINANCE32F_EXT 0x8818 +#define GL_LUMINANCE_ALPHA32F_EXT 0x8819 +#define GL_RGBA16F_EXT 0x881A +#define GL_RGB16F_EXT 0x881B +#define GL_ALPHA16F_EXT 0x881C +#define GL_LUMINANCE16F_EXT 0x881E +#define GL_LUMINANCE_ALPHA16F_EXT 0x881F +#define GL_BGRA8_EXT 0x93A1 +#define GL_R8_EXT 0x8229 +#define GL_RG8_EXT 0x822B +#define GL_R32F_EXT 0x822E +#define GL_RG32F_EXT 0x8230 +#define GL_R16F_EXT 0x822D +#define GL_RG16F_EXT 0x822F +typedef void (APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorage1DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTexStorage2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexStorage3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* GL_EXT_texture_storage */ + +#ifndef GL_EXT_texture_swizzle +#define GL_EXT_texture_swizzle 1 +#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 +#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 +#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 +#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 +#endif /* GL_EXT_texture_swizzle */ + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 +#define GL_TIME_ELAPSED_EXT 0x88BF +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); +#endif +#endif /* GL_EXT_timer_query */ + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackEXT (void); +GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif +#endif /* GL_EXT_transform_feedback */ + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, void **params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint i); +GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); +GLAPI void APIENTRY glGetPointervEXT (GLenum pname, void **params); +GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +#endif +#endif /* GL_EXT_vertex_array */ + +#ifndef GL_EXT_vertex_array_bgra +#define GL_EXT_vertex_array_bgra 1 +#endif /* GL_EXT_vertex_array_bgra */ + +#ifndef GL_EXT_vertex_attrib_64bit +#define GL_EXT_vertex_attrib_64bit 1 +#define GL_DOUBLE_VEC2_EXT 0x8FFC +#define GL_DOUBLE_VEC3_EXT 0x8FFD +#define GL_DOUBLE_VEC4_EXT 0x8FFE +#define GL_DOUBLE_MAT2_EXT 0x8F46 +#define GL_DOUBLE_MAT3_EXT 0x8F47 +#define GL_DOUBLE_MAT4_EXT 0x8F48 +#define GL_DOUBLE_MAT2x3_EXT 0x8F49 +#define GL_DOUBLE_MAT2x4_EXT 0x8F4A +#define GL_DOUBLE_MAT3x2_EXT 0x8F4B +#define GL_DOUBLE_MAT3x4_EXT 0x8F4C +#define GL_DOUBLE_MAT4x2_EXT 0x8F4D +#define GL_DOUBLE_MAT4x3_EXT 0x8F4E +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); +#endif +#endif /* GL_EXT_vertex_attrib_64bit */ + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const void *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const void *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const void *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, void **data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); +GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); +GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const void *addr); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const void *addr); +GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); +GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); +GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); +GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); +GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); +GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); +GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); +GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); +GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const void *addr); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, void **data); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +#endif +#endif /* GL_EXT_vertex_shader */ + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT 0x1700 +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_vertex_weighting */ + +#ifndef GL_EXT_win32_keyed_mutex +#define GL_EXT_win32_keyed_mutex 1 +typedef GLboolean (APIENTRYP PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key, GLuint timeout); +typedef GLboolean (APIENTRYP PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAcquireKeyedMutexWin32EXT (GLuint memory, GLuint64 key, GLuint timeout); +GLAPI GLboolean APIENTRY glReleaseKeyedMutexWin32EXT (GLuint memory, GLuint64 key); +#endif +#endif /* GL_EXT_win32_keyed_mutex */ + +#ifndef GL_EXT_window_rectangles +#define GL_EXT_window_rectangles 1 +#define GL_INCLUSIVE_EXT 0x8F10 +#define GL_EXCLUSIVE_EXT 0x8F11 +#define GL_WINDOW_RECTANGLE_EXT 0x8F12 +#define GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13 +#define GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14 +#define GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15 +typedef void (APIENTRYP PFNGLWINDOWRECTANGLESEXTPROC) (GLenum mode, GLsizei count, const GLint *box); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowRectanglesEXT (GLenum mode, GLsizei count, const GLint *box); +#endif +#endif /* GL_EXT_window_rectangles */ + +#ifndef GL_EXT_x11_sync_object +#define GL_EXT_x11_sync_object 1 +#define GL_SYNC_X11_FENCE_EXT 0x90E1 +typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#endif +#endif /* GL_EXT_x11_sync_object */ + +#ifndef GL_GREMEDY_frame_terminator +#define GL_GREMEDY_frame_terminator 1 +typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); +#endif +#endif /* GL_GREMEDY_frame_terminator */ + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void *string); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const void *string); +#endif +#endif /* GL_GREMEDY_string_marker */ + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif /* GL_HP_convolution_border_modes */ + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_HP_image_transform */ + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif /* GL_HP_occlusion_test */ + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif /* GL_HP_texture_lighting */ + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#define GL_CULL_VERTEX_IBM 103050 +#endif /* GL_IBM_cull_vertex */ + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); +#endif +#endif /* GL_IBM_multimode_draw_arrays */ + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif /* GL_IBM_rasterpos_clip */ + +#ifndef GL_IBM_static_data +#define GL_IBM_static_data 1 +#define GL_ALL_STATIC_DATA_IBM 103060 +#define GL_STATIC_VERTEX_ARRAY_IBM 103061 +typedef void (APIENTRYP PFNGLFLUSHSTATICDATAIBMPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushStaticDataIBM (GLenum target); +#endif +#endif /* GL_IBM_static_data */ + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_IBM_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif /* GL_IBM_texture_mirrored_repeat */ + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean **pointer, GLint ptrstride); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +#endif +#endif /* GL_IBM_vertex_array_lists */ + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif +#endif /* GL_INGR_blend_func_separate */ + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif /* GL_INGR_color_clamp */ + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#define GL_INTERLACE_READ_INGR 0x8568 +#endif /* GL_INGR_interlace_read */ + +#ifndef GL_INTEL_blackhole_render +#define GL_INTEL_blackhole_render 1 +#define GL_BLACKHOLE_RENDER_INTEL 0x83FC +#endif /* GL_INTEL_blackhole_render */ + +#ifndef GL_INTEL_conservative_rasterization +#define GL_INTEL_conservative_rasterization 1 +#define GL_CONSERVATIVE_RASTERIZATION_INTEL 0x83FE +#endif /* GL_INTEL_conservative_rasterization */ + +#ifndef GL_INTEL_fragment_shader_ordering +#define GL_INTEL_fragment_shader_ordering 1 +#endif /* GL_INTEL_fragment_shader_ordering */ + +#ifndef GL_INTEL_framebuffer_CMAA +#define GL_INTEL_framebuffer_CMAA 1 +typedef void (APIENTRYP PFNGLAPPLYFRAMEBUFFERATTACHMENTCMAAINTELPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyFramebufferAttachmentCMAAINTEL (void); +#endif +#endif /* GL_INTEL_framebuffer_CMAA */ + +#ifndef GL_INTEL_map_texture +#define GL_INTEL_map_texture 1 +#define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF +#define GL_LAYOUT_DEFAULT_INTEL 0 +#define GL_LAYOUT_LINEAR_INTEL 1 +#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 +typedef void (APIENTRYP PFNGLSYNCTEXTUREINTELPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level); +typedef void *(APIENTRYP PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSyncTextureINTEL (GLuint texture); +GLAPI void APIENTRY glUnmapTexture2DINTEL (GLuint texture, GLint level); +GLAPI void *APIENTRY glMapTexture2DINTEL (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); +#endif +#endif /* GL_INTEL_map_texture */ + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const void **pointer); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const void **pointer); +GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const void **pointer); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const void **pointer); +#endif +#endif /* GL_INTEL_parallel_arrays */ + +#ifndef GL_INTEL_performance_query +#define GL_INTEL_performance_query 1 +#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000 +#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001 +#define GL_PERFQUERY_WAIT_INTEL 0x83FB +#define GL_PERFQUERY_FLUSH_INTEL 0x83FA +#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 +#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 +#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 +#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 +#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 +#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 +#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 +#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 +#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 +#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA +#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB +#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC +#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD +#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE +#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF +#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 +typedef void (APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle); +typedef void (APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); +typedef void (APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); +typedef void (APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); +typedef void (APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); +typedef void (APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle); +GLAPI void APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); +GLAPI void APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); +GLAPI void APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); +GLAPI void APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); +GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#endif +#endif /* GL_INTEL_performance_query */ + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E +#endif /* GL_MESAX_texture_stack */ + +#ifndef GL_MESA_framebuffer_flip_x +#define GL_MESA_framebuffer_flip_x 1 +#define GL_FRAMEBUFFER_FLIP_X_MESA 0x8BBC +#endif /* GL_MESA_framebuffer_flip_x */ + +#ifndef GL_MESA_framebuffer_flip_y +#define GL_MESA_framebuffer_flip_y 1 +#define GL_FRAMEBUFFER_FLIP_Y_MESA 0x8BBB +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIMESAPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVMESAPROC) (GLenum target, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferParameteriMESA (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameterivMESA (GLenum target, GLenum pname, GLint *params); +#endif +#endif /* GL_MESA_framebuffer_flip_y */ + +#ifndef GL_MESA_framebuffer_swap_xy +#define GL_MESA_framebuffer_swap_xy 1 +#define GL_FRAMEBUFFER_SWAP_XY_MESA 0x8BBD +#endif /* GL_MESA_framebuffer_swap_xy */ + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#define GL_PACK_INVERT_MESA 0x8758 +#endif /* GL_MESA_pack_invert */ + +#ifndef GL_MESA_program_binary_formats +#define GL_MESA_program_binary_formats 1 +#define GL_PROGRAM_BINARY_FORMAT_MESA 0x875F +#endif /* GL_MESA_program_binary_formats */ + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif +#endif /* GL_MESA_resize_buffers */ + +#ifndef GL_MESA_shader_integer_functions +#define GL_MESA_shader_integer_functions 1 +#endif /* GL_MESA_shader_integer_functions */ + +#ifndef GL_MESA_tile_raster_order +#define GL_MESA_tile_raster_order 1 +#define GL_TILE_RASTER_ORDER_FIXED_MESA 0x8BB8 +#define GL_TILE_RASTER_ORDER_INCREASING_X_MESA 0x8BB9 +#define GL_TILE_RASTER_ORDER_INCREASING_Y_MESA 0x8BBA +#endif /* GL_MESA_tile_raster_order */ + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); +#endif +#endif /* GL_MESA_window_pos */ + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif /* GL_MESA_ycbcr_texture */ + +#ifndef GL_NVX_blend_equation_advanced_multi_draw_buffers +#define GL_NVX_blend_equation_advanced_multi_draw_buffers 1 +#endif /* GL_NVX_blend_equation_advanced_multi_draw_buffers */ + +#ifndef GL_NVX_conditional_render +#define GL_NVX_conditional_render 1 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNVX (GLuint id); +GLAPI void APIENTRY glEndConditionalRenderNVX (void); +#endif +#endif /* GL_NVX_conditional_render */ + +#ifndef GL_NVX_gpu_memory_info +#define GL_NVX_gpu_memory_info 1 +#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047 +#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048 +#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049 +#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A +#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B +#endif /* GL_NVX_gpu_memory_info */ + +#ifndef GL_NVX_gpu_multicast2 +#define GL_NVX_gpu_multicast2 1 +#define GL_UPLOAD_GPU_MASK_NVX 0x954A +typedef void (APIENTRYP PFNGLUPLOADGPUMASKNVXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLMULTICASTVIEWPORTARRAYVNVXPROC) (GLuint gpu, GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTICASTVIEWPORTPOSITIONWSCALENVXPROC) (GLuint gpu, GLuint index, GLfloat xcoeff, GLfloat ycoeff); +typedef void (APIENTRYP PFNGLMULTICASTSCISSORARRAYVNVXPROC) (GLuint gpu, GLuint first, GLsizei count, const GLint *v); +typedef GLuint (APIENTRYP PFNGLASYNCCOPYBUFFERSUBDATANVXPROC) (GLsizei waitSemaphoreCount, const GLuint *waitSemaphoreArray, const GLuint64 *fenceValueArray, GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size, GLsizei signalSemaphoreCount, const GLuint *signalSemaphoreArray, const GLuint64 *signalValueArray); +typedef GLuint (APIENTRYP PFNGLASYNCCOPYIMAGESUBDATANVXPROC) (GLsizei waitSemaphoreCount, const GLuint *waitSemaphoreArray, const GLuint64 *waitValueArray, GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth, GLsizei signalSemaphoreCount, const GLuint *signalSemaphoreArray, const GLuint64 *signalValueArray); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUploadGpuMaskNVX (GLbitfield mask); +GLAPI void APIENTRY glMulticastViewportArrayvNVX (GLuint gpu, GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glMulticastViewportPositionWScaleNVX (GLuint gpu, GLuint index, GLfloat xcoeff, GLfloat ycoeff); +GLAPI void APIENTRY glMulticastScissorArrayvNVX (GLuint gpu, GLuint first, GLsizei count, const GLint *v); +GLAPI GLuint APIENTRY glAsyncCopyBufferSubDataNVX (GLsizei waitSemaphoreCount, const GLuint *waitSemaphoreArray, const GLuint64 *fenceValueArray, GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size, GLsizei signalSemaphoreCount, const GLuint *signalSemaphoreArray, const GLuint64 *signalValueArray); +GLAPI GLuint APIENTRY glAsyncCopyImageSubDataNVX (GLsizei waitSemaphoreCount, const GLuint *waitSemaphoreArray, const GLuint64 *waitValueArray, GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth, GLsizei signalSemaphoreCount, const GLuint *signalSemaphoreArray, const GLuint64 *signalValueArray); +#endif +#endif /* GL_NVX_gpu_multicast2 */ + +#ifndef GL_NVX_linked_gpu_multicast +#define GL_NVX_linked_gpu_multicast 1 +#define GL_LGPU_SEPARATE_STORAGE_BIT_NVX 0x0800 +#define GL_MAX_LGPU_GPUS_NVX 0x92BA +typedef void (APIENTRYP PFNGLLGPUNAMEDBUFFERSUBDATANVXPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLLGPUCOPYIMAGESUBDATANVXPROC) (GLuint sourceGpu, GLbitfield destinationGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLLGPUINTERLOCKNVXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLGPUNamedBufferSubDataNVX (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glLGPUCopyImageSubDataNVX (GLuint sourceGpu, GLbitfield destinationGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glLGPUInterlockNVX (void); +#endif +#endif /* GL_NVX_linked_gpu_multicast */ + +#ifndef GL_NVX_progress_fence +#define GL_NVX_progress_fence 1 +typedef GLuint (APIENTRYP PFNGLCREATEPROGRESSFENCENVXPROC) (void); +typedef void (APIENTRYP PFNGLSIGNALSEMAPHOREUI64NVXPROC) (GLuint signalGpu, GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); +typedef void (APIENTRYP PFNGLWAITSEMAPHOREUI64NVXPROC) (GLuint waitGpu, GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); +typedef void (APIENTRYP PFNGLCLIENTWAITSEMAPHOREUI64NVXPROC) (GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glCreateProgressFenceNVX (void); +GLAPI void APIENTRY glSignalSemaphoreui64NVX (GLuint signalGpu, GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); +GLAPI void APIENTRY glWaitSemaphoreui64NVX (GLuint waitGpu, GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); +GLAPI void APIENTRY glClientWaitSemaphoreui64NVX (GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); +#endif +#endif /* GL_NVX_progress_fence */ + +#ifndef GL_NV_alpha_to_coverage_dither_control +#define GL_NV_alpha_to_coverage_dither_control 1 +#define GL_ALPHA_TO_COVERAGE_DITHER_DEFAULT_NV 0x934D +#define GL_ALPHA_TO_COVERAGE_DITHER_ENABLE_NV 0x934E +#define GL_ALPHA_TO_COVERAGE_DITHER_DISABLE_NV 0x934F +#define GL_ALPHA_TO_COVERAGE_DITHER_MODE_NV 0x92BF +typedef void (APIENTRYP PFNGLALPHATOCOVERAGEDITHERCONTROLNVPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAlphaToCoverageDitherControlNV (GLenum mode); +#endif +#endif /* GL_NV_alpha_to_coverage_dither_control */ + +#ifndef GL_NV_bindless_multi_draw_indirect +#define GL_NV_bindless_multi_draw_indirect 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#endif +#endif /* GL_NV_bindless_multi_draw_indirect */ + +#ifndef GL_NV_bindless_multi_draw_indirect_count +#define GL_NV_bindless_multi_draw_indirect_count 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessCountNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessCountNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +#endif +#endif /* GL_NV_bindless_multi_draw_indirect_count */ + +#ifndef GL_NV_bindless_texture +#define GL_NV_bindless_texture 1 +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); +#endif +#endif /* GL_NV_bindless_texture */ + +#ifndef GL_NV_blend_equation_advanced +#define GL_NV_blend_equation_advanced 1 +#define GL_BLEND_OVERLAP_NV 0x9281 +#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 +#define GL_BLUE_NV 0x1905 +#define GL_COLORBURN_NV 0x929A +#define GL_COLORDODGE_NV 0x9299 +#define GL_CONJOINT_NV 0x9284 +#define GL_CONTRAST_NV 0x92A1 +#define GL_DARKEN_NV 0x9297 +#define GL_DIFFERENCE_NV 0x929E +#define GL_DISJOINT_NV 0x9283 +#define GL_DST_ATOP_NV 0x928F +#define GL_DST_IN_NV 0x928B +#define GL_DST_NV 0x9287 +#define GL_DST_OUT_NV 0x928D +#define GL_DST_OVER_NV 0x9289 +#define GL_EXCLUSION_NV 0x92A0 +#define GL_GREEN_NV 0x1904 +#define GL_HARDLIGHT_NV 0x929B +#define GL_HARDMIX_NV 0x92A9 +#define GL_HSL_COLOR_NV 0x92AF +#define GL_HSL_HUE_NV 0x92AD +#define GL_HSL_LUMINOSITY_NV 0x92B0 +#define GL_HSL_SATURATION_NV 0x92AE +#define GL_INVERT_OVG_NV 0x92B4 +#define GL_INVERT_RGB_NV 0x92A3 +#define GL_LIGHTEN_NV 0x9298 +#define GL_LINEARBURN_NV 0x92A5 +#define GL_LINEARDODGE_NV 0x92A4 +#define GL_LINEARLIGHT_NV 0x92A7 +#define GL_MINUS_CLAMPED_NV 0x92B3 +#define GL_MINUS_NV 0x929F +#define GL_MULTIPLY_NV 0x9294 +#define GL_OVERLAY_NV 0x9296 +#define GL_PINLIGHT_NV 0x92A8 +#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 +#define GL_PLUS_CLAMPED_NV 0x92B1 +#define GL_PLUS_DARKER_NV 0x9292 +#define GL_PLUS_NV 0x9291 +#define GL_RED_NV 0x1903 +#define GL_SCREEN_NV 0x9295 +#define GL_SOFTLIGHT_NV 0x929C +#define GL_SRC_ATOP_NV 0x928E +#define GL_SRC_IN_NV 0x928A +#define GL_SRC_NV 0x9286 +#define GL_SRC_OUT_NV 0x928C +#define GL_SRC_OVER_NV 0x9288 +#define GL_UNCORRELATED_NV 0x9282 +#define GL_VIVIDLIGHT_NV 0x92A6 +#define GL_XOR_NV 0x1506 +typedef void (APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLBLENDBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendParameteriNV (GLenum pname, GLint value); +GLAPI void APIENTRY glBlendBarrierNV (void); +#endif +#endif /* GL_NV_blend_equation_advanced */ + +#ifndef GL_NV_blend_equation_advanced_coherent +#define GL_NV_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 +#endif /* GL_NV_blend_equation_advanced_coherent */ + +#ifndef GL_NV_blend_minmax_factor +#define GL_NV_blend_minmax_factor 1 +#endif /* GL_NV_blend_minmax_factor */ + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif /* GL_NV_blend_square */ + +#ifndef GL_NV_clip_space_w_scaling +#define GL_NV_clip_space_w_scaling 1 +#define GL_VIEWPORT_POSITION_W_SCALE_NV 0x937C +#define GL_VIEWPORT_POSITION_W_SCALE_X_COEFF_NV 0x937D +#define GL_VIEWPORT_POSITION_W_SCALE_Y_COEFF_NV 0x937E +typedef void (APIENTRYP PFNGLVIEWPORTPOSITIONWSCALENVPROC) (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportPositionWScaleNV (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#endif +#endif /* GL_NV_clip_space_w_scaling */ + +#ifndef GL_NV_command_list +#define GL_NV_command_list 1 +#define GL_TERMINATE_SEQUENCE_COMMAND_NV 0x0000 +#define GL_NOP_COMMAND_NV 0x0001 +#define GL_DRAW_ELEMENTS_COMMAND_NV 0x0002 +#define GL_DRAW_ARRAYS_COMMAND_NV 0x0003 +#define GL_DRAW_ELEMENTS_STRIP_COMMAND_NV 0x0004 +#define GL_DRAW_ARRAYS_STRIP_COMMAND_NV 0x0005 +#define GL_DRAW_ELEMENTS_INSTANCED_COMMAND_NV 0x0006 +#define GL_DRAW_ARRAYS_INSTANCED_COMMAND_NV 0x0007 +#define GL_ELEMENT_ADDRESS_COMMAND_NV 0x0008 +#define GL_ATTRIBUTE_ADDRESS_COMMAND_NV 0x0009 +#define GL_UNIFORM_ADDRESS_COMMAND_NV 0x000A +#define GL_BLEND_COLOR_COMMAND_NV 0x000B +#define GL_STENCIL_REF_COMMAND_NV 0x000C +#define GL_LINE_WIDTH_COMMAND_NV 0x000D +#define GL_POLYGON_OFFSET_COMMAND_NV 0x000E +#define GL_ALPHA_REF_COMMAND_NV 0x000F +#define GL_VIEWPORT_COMMAND_NV 0x0010 +#define GL_SCISSOR_COMMAND_NV 0x0011 +#define GL_FRONT_FACE_COMMAND_NV 0x0012 +typedef void (APIENTRYP PFNGLCREATESTATESNVPROC) (GLsizei n, GLuint *states); +typedef void (APIENTRYP PFNGLDELETESTATESNVPROC) (GLsizei n, const GLuint *states); +typedef GLboolean (APIENTRYP PFNGLISSTATENVPROC) (GLuint state); +typedef void (APIENTRYP PFNGLSTATECAPTURENVPROC) (GLuint state, GLenum mode); +typedef GLuint (APIENTRYP PFNGLGETCOMMANDHEADERNVPROC) (GLenum tokenID, GLuint size); +typedef GLushort (APIENTRYP PFNGLGETSTAGEINDEXNVPROC) (GLenum shadertype); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSNVPROC) (GLenum primitiveMode, GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, GLuint count); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSADDRESSNVPROC) (GLenum primitiveMode, const GLuint64 *indirects, const GLsizei *sizes, GLuint count); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSSTATESNVPROC) (GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSSTATESADDRESSNVPROC) (const GLuint64 *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +typedef void (APIENTRYP PFNGLCREATECOMMANDLISTSNVPROC) (GLsizei n, GLuint *lists); +typedef void (APIENTRYP PFNGLDELETECOMMANDLISTSNVPROC) (GLsizei n, const GLuint *lists); +typedef GLboolean (APIENTRYP PFNGLISCOMMANDLISTNVPROC) (GLuint list); +typedef void (APIENTRYP PFNGLLISTDRAWCOMMANDSSTATESCLIENTNVPROC) (GLuint list, GLuint segment, const void **indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +typedef void (APIENTRYP PFNGLCOMMANDLISTSEGMENTSNVPROC) (GLuint list, GLuint segments); +typedef void (APIENTRYP PFNGLCOMPILECOMMANDLISTNVPROC) (GLuint list); +typedef void (APIENTRYP PFNGLCALLCOMMANDLISTNVPROC) (GLuint list); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCreateStatesNV (GLsizei n, GLuint *states); +GLAPI void APIENTRY glDeleteStatesNV (GLsizei n, const GLuint *states); +GLAPI GLboolean APIENTRY glIsStateNV (GLuint state); +GLAPI void APIENTRY glStateCaptureNV (GLuint state, GLenum mode); +GLAPI GLuint APIENTRY glGetCommandHeaderNV (GLenum tokenID, GLuint size); +GLAPI GLushort APIENTRY glGetStageIndexNV (GLenum shadertype); +GLAPI void APIENTRY glDrawCommandsNV (GLenum primitiveMode, GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, GLuint count); +GLAPI void APIENTRY glDrawCommandsAddressNV (GLenum primitiveMode, const GLuint64 *indirects, const GLsizei *sizes, GLuint count); +GLAPI void APIENTRY glDrawCommandsStatesNV (GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +GLAPI void APIENTRY glDrawCommandsStatesAddressNV (const GLuint64 *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +GLAPI void APIENTRY glCreateCommandListsNV (GLsizei n, GLuint *lists); +GLAPI void APIENTRY glDeleteCommandListsNV (GLsizei n, const GLuint *lists); +GLAPI GLboolean APIENTRY glIsCommandListNV (GLuint list); +GLAPI void APIENTRY glListDrawCommandsStatesClientNV (GLuint list, GLuint segment, const void **indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +GLAPI void APIENTRY glCommandListSegmentsNV (GLuint list, GLuint segments); +GLAPI void APIENTRY glCompileCommandListNV (GLuint list); +GLAPI void APIENTRY glCallCommandListNV (GLuint list); +#endif +#endif /* GL_NV_command_list */ + +#ifndef GL_NV_compute_program5 +#define GL_NV_compute_program5 1 +#define GL_COMPUTE_PROGRAM_NV 0x90FB +#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC +#endif /* GL_NV_compute_program5 */ + +#ifndef GL_NV_compute_shader_derivatives +#define GL_NV_compute_shader_derivatives 1 +#endif /* GL_NV_compute_shader_derivatives */ + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRenderNV (void); +#endif +#endif /* GL_NV_conditional_render */ + +#ifndef GL_NV_conservative_raster +#define GL_NV_conservative_raster 1 +#define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346 +#define GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347 +#define GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348 +#define GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349 +typedef void (APIENTRYP PFNGLSUBPIXELPRECISIONBIASNVPROC) (GLuint xbits, GLuint ybits); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSubpixelPrecisionBiasNV (GLuint xbits, GLuint ybits); +#endif +#endif /* GL_NV_conservative_raster */ + +#ifndef GL_NV_conservative_raster_dilate +#define GL_NV_conservative_raster_dilate 1 +#define GL_CONSERVATIVE_RASTER_DILATE_NV 0x9379 +#define GL_CONSERVATIVE_RASTER_DILATE_RANGE_NV 0x937A +#define GL_CONSERVATIVE_RASTER_DILATE_GRANULARITY_NV 0x937B +typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERFNVPROC) (GLenum pname, GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConservativeRasterParameterfNV (GLenum pname, GLfloat value); +#endif +#endif /* GL_NV_conservative_raster_dilate */ + +#ifndef GL_NV_conservative_raster_pre_snap +#define GL_NV_conservative_raster_pre_snap 1 +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_NV 0x9550 +#endif /* GL_NV_conservative_raster_pre_snap */ + +#ifndef GL_NV_conservative_raster_pre_snap_triangles +#define GL_NV_conservative_raster_pre_snap_triangles 1 +#define GL_CONSERVATIVE_RASTER_MODE_NV 0x954D +#define GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV 0x954E +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV 0x954F +typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERINVPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConservativeRasterParameteriNV (GLenum pname, GLint param); +#endif +#endif /* GL_NV_conservative_raster_pre_snap_triangles */ + +#ifndef GL_NV_conservative_raster_underestimation +#define GL_NV_conservative_raster_underestimation 1 +#endif /* GL_NV_conservative_raster_underestimation */ + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif /* GL_NV_copy_depth_to_color */ + +#ifndef GL_NV_copy_image +#define GL_NV_copy_image 1 +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* GL_NV_copy_image */ + +#ifndef GL_NV_deep_texture3D +#define GL_NV_deep_texture3D 1 +#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 +#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 +#endif /* GL_NV_deep_texture3D */ + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF +typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); +GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); +#endif +#endif /* GL_NV_depth_buffer_float */ + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#define GL_DEPTH_CLAMP_NV 0x864F +#endif /* GL_NV_depth_clamp */ + +#ifndef GL_NV_draw_texture +#define GL_NV_draw_texture 1 +typedef void (APIENTRYP PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#endif +#endif /* GL_NV_draw_texture */ + +#ifndef GL_NV_draw_vulkan_image +#define GL_NV_draw_vulkan_image 1 +typedef void (APIENTRY *GLVULKANPROCNV)(void); +typedef void (APIENTRYP PFNGLDRAWVKIMAGENVPROC) (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +typedef GLVULKANPROCNV (APIENTRYP PFNGLGETVKPROCADDRNVPROC) (const GLchar *name); +typedef void (APIENTRYP PFNGLWAITVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (APIENTRYP PFNGLSIGNALVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (APIENTRYP PFNGLSIGNALVKFENCENVPROC) (GLuint64 vkFence); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawVkImageNV (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +GLAPI GLVULKANPROCNV APIENTRY glGetVkProcAddrNV (const GLchar *name); +GLAPI void APIENTRY glWaitVkSemaphoreNV (GLuint64 vkSemaphore); +GLAPI void APIENTRY glSignalVkSemaphoreNV (GLuint64 vkSemaphore); +GLAPI void APIENTRY glSignalVkFenceNV (GLuint64 vkFence); +#endif +#endif /* GL_NV_draw_vulkan_image */ + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); +GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); +#endif +#endif /* GL_NV_evaluators */ + +#ifndef GL_NV_explicit_multisample +#define GL_NV_explicit_multisample 1 +#define GL_SAMPLE_POSITION_NV 0x8E50 +#define GL_SAMPLE_MASK_NV 0x8E51 +#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 +#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 +#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 +#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 +#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 +#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 +#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 +#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); +GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); +#endif +#endif /* GL_NV_explicit_multisample */ + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); +GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GLAPI void APIENTRY glFinishFenceNV (GLuint fence); +GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif +#endif /* GL_NV_fence */ + +#ifndef GL_NV_fill_rectangle +#define GL_NV_fill_rectangle 1 +#define GL_FILL_RECTANGLE_NV 0x933C +#endif /* GL_NV_fill_rectangle */ + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif /* GL_NV_float_buffer */ + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +#endif /* GL_NV_fog_distance */ + +#ifndef GL_NV_fragment_coverage_to_color +#define GL_NV_fragment_coverage_to_color 1 +#define GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD +#define GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE +typedef void (APIENTRYP PFNGLFRAGMENTCOVERAGECOLORNVPROC) (GLuint color); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentCoverageColorNV (GLuint color); +#endif +#endif /* GL_NV_fragment_coverage_to_color */ + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif +#endif /* GL_NV_fragment_program */ + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif /* GL_NV_fragment_program2 */ + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 +#endif /* GL_NV_fragment_program4 */ + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif /* GL_NV_fragment_program_option */ + +#ifndef GL_NV_fragment_shader_barycentric +#define GL_NV_fragment_shader_barycentric 1 +#endif /* GL_NV_fragment_shader_barycentric */ + +#ifndef GL_NV_fragment_shader_interlock +#define GL_NV_fragment_shader_interlock 1 +#endif /* GL_NV_fragment_shader_interlock */ + +#ifndef GL_NV_framebuffer_mixed_samples +#define GL_NV_framebuffer_mixed_samples 1 +#define GL_COVERAGE_MODULATION_TABLE_NV 0x9331 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#define GL_DEPTH_SAMPLES_NV 0x932D +#define GL_STENCIL_SAMPLES_NV 0x932E +#define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F +#define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 +#define GL_COVERAGE_MODULATION_NV 0x9332 +#define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 +typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONTABLENVPROC) (GLsizei n, const GLfloat *v); +typedef void (APIENTRYP PFNGLGETCOVERAGEMODULATIONTABLENVPROC) (GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONNVPROC) (GLenum components); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCoverageModulationTableNV (GLsizei n, const GLfloat *v); +GLAPI void APIENTRY glGetCoverageModulationTableNV (GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glCoverageModulationNV (GLenum components); +#endif +#endif /* GL_NV_framebuffer_mixed_samples */ + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_NV_framebuffer_multisample_coverage */ + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 +typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); +GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_NV_geometry_program4 */ + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 +#endif /* GL_NV_geometry_shader4 */ + +#ifndef GL_NV_geometry_shader_passthrough +#define GL_NV_geometry_shader_passthrough 1 +#endif /* GL_NV_geometry_shader_passthrough */ + +#ifndef GL_NV_gpu_multicast +#define GL_NV_gpu_multicast 1 +#define GL_PER_GPU_STORAGE_BIT_NV 0x0800 +#define GL_MULTICAST_GPUS_NV 0x92BA +#define GL_RENDER_GPU_MASK_NV 0x9558 +#define GL_PER_GPU_STORAGE_NV 0x9548 +#define GL_MULTICAST_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9549 +typedef void (APIENTRYP PFNGLRENDERGPUMASKNVPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLMULTICASTBUFFERSUBDATANVPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLMULTICASTCOPYBUFFERSUBDATANVPROC) (GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLMULTICASTCOPYIMAGESUBDATANVPROC) (GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (APIENTRYP PFNGLMULTICASTBLITFRAMEBUFFERNVPROC) (GLuint srcGpu, GLuint dstGpu, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLMULTICASTFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint gpu, GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTICASTBARRIERNVPROC) (void); +typedef void (APIENTRYP PFNGLMULTICASTWAITSYNCNVPROC) (GLuint signalGpu, GLbitfield waitGpuMask); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTIVNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTUIVNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTUI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint64 *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderGpuMaskNV (GLbitfield mask); +GLAPI void APIENTRY glMulticastBufferSubDataNV (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glMulticastCopyBufferSubDataNV (GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glMulticastCopyImageSubDataNV (GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GLAPI void APIENTRY glMulticastBlitFramebufferNV (GLuint srcGpu, GLuint dstGpu, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glMulticastFramebufferSampleLocationsfvNV (GLuint gpu, GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glMulticastBarrierNV (void); +GLAPI void APIENTRY glMulticastWaitSyncNV (GLuint signalGpu, GLbitfield waitGpuMask); +GLAPI void APIENTRY glMulticastGetQueryObjectivNV (GLuint gpu, GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glMulticastGetQueryObjectuivNV (GLuint gpu, GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMulticastGetQueryObjecti64vNV (GLuint gpu, GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glMulticastGetQueryObjectui64vNV (GLuint gpu, GLuint id, GLenum pname, GLuint64 *params); +#endif +#endif /* GL_NV_gpu_multicast */ + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); +#endif +#endif /* GL_NV_gpu_program4 */ + +#ifndef GL_NV_gpu_program5 +#define GL_NV_gpu_program5 1 +#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C +#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F +#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 +#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 +typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); +#endif +#endif /* GL_NV_gpu_program5 */ + +#ifndef GL_NV_gpu_program5_mem_extended +#define GL_NV_gpu_program5_mem_extended 1 +#endif /* GL_NV_gpu_program5_mem_extended */ + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +#endif /* GL_NV_gpu_shader5 */ + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +typedef unsigned short GLhalfNV; +#define GL_HALF_FLOAT_NV 0x140B +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); +#endif +#endif /* GL_NV_half_float */ + +#ifndef GL_NV_internalformat_sample_query +#define GL_NV_internalformat_sample_query 1 +#define GL_MULTISAMPLES_NV 0x9371 +#define GL_SUPERSAMPLE_SCALE_X_NV 0x9372 +#define GL_SUPERSAMPLE_SCALE_Y_NV 0x9373 +#define GL_CONFORMANT_NV 0x9374 +typedef void (APIENTRYP PFNGLGETINTERNALFORMATSAMPLEIVNVPROC) (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInternalformatSampleivNV (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); +#endif +#endif /* GL_NV_internalformat_sample_query */ + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif /* GL_NV_light_max_exponent */ + +#ifndef GL_NV_memory_attachment +#define GL_NV_memory_attachment 1 +#define GL_ATTACHED_MEMORY_OBJECT_NV 0x95A4 +#define GL_ATTACHED_MEMORY_OFFSET_NV 0x95A5 +#define GL_MEMORY_ATTACHABLE_ALIGNMENT_NV 0x95A6 +#define GL_MEMORY_ATTACHABLE_SIZE_NV 0x95A7 +#define GL_MEMORY_ATTACHABLE_NV 0x95A8 +#define GL_DETACHED_MEMORY_INCARNATION_NV 0x95A9 +#define GL_DETACHED_TEXTURES_NV 0x95AA +#define GL_DETACHED_BUFFERS_NV 0x95AB +#define GL_MAX_DETACHED_TEXTURES_NV 0x95AC +#define GL_MAX_DETACHED_BUFFERS_NV 0x95AD +typedef void (APIENTRYP PFNGLGETMEMORYOBJECTDETACHEDRESOURCESUIVNVPROC) (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); +typedef void (APIENTRYP PFNGLRESETMEMORYOBJECTPARAMETERNVPROC) (GLuint memory, GLenum pname); +typedef void (APIENTRYP PFNGLTEXATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLBUFFERATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTUREATTACHMEMORYNVPROC) (GLuint texture, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLNAMEDBUFFERATTACHMEMORYNVPROC) (GLuint buffer, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMemoryObjectDetachedResourcesuivNV (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); +GLAPI void APIENTRY glResetMemoryObjectParameterNV (GLuint memory, GLenum pname); +GLAPI void APIENTRY glTexAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glBufferAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureAttachMemoryNV (GLuint texture, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glNamedBufferAttachMemoryNV (GLuint buffer, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_NV_memory_attachment */ + +#ifndef GL_NV_memory_object_sparse +#define GL_NV_memory_object_sparse 1 +typedef void (APIENTRYP PFNGLBUFFERPAGECOMMITMENTMEMNVPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); +typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTMEMNVPROC) (GLenum target, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); +typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTMEMNVPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); +typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTMEMNVPROC) (GLuint texture, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferPageCommitmentMemNV (GLenum target, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); +GLAPI void APIENTRY glTexPageCommitmentMemNV (GLenum target, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); +GLAPI void APIENTRY glNamedBufferPageCommitmentMemNV (GLuint buffer, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); +GLAPI void APIENTRY glTexturePageCommitmentMemNV (GLuint texture, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); +#endif +#endif /* GL_NV_memory_object_sparse */ + +#ifndef GL_NV_mesh_shader +#define GL_NV_mesh_shader 1 +#define GL_MESH_SHADER_NV 0x9559 +#define GL_TASK_SHADER_NV 0x955A +#define GL_MAX_MESH_UNIFORM_BLOCKS_NV 0x8E60 +#define GL_MAX_MESH_TEXTURE_IMAGE_UNITS_NV 0x8E61 +#define GL_MAX_MESH_IMAGE_UNIFORMS_NV 0x8E62 +#define GL_MAX_MESH_UNIFORM_COMPONENTS_NV 0x8E63 +#define GL_MAX_MESH_ATOMIC_COUNTER_BUFFERS_NV 0x8E64 +#define GL_MAX_MESH_ATOMIC_COUNTERS_NV 0x8E65 +#define GL_MAX_MESH_SHADER_STORAGE_BLOCKS_NV 0x8E66 +#define GL_MAX_COMBINED_MESH_UNIFORM_COMPONENTS_NV 0x8E67 +#define GL_MAX_TASK_UNIFORM_BLOCKS_NV 0x8E68 +#define GL_MAX_TASK_TEXTURE_IMAGE_UNITS_NV 0x8E69 +#define GL_MAX_TASK_IMAGE_UNIFORMS_NV 0x8E6A +#define GL_MAX_TASK_UNIFORM_COMPONENTS_NV 0x8E6B +#define GL_MAX_TASK_ATOMIC_COUNTER_BUFFERS_NV 0x8E6C +#define GL_MAX_TASK_ATOMIC_COUNTERS_NV 0x8E6D +#define GL_MAX_TASK_SHADER_STORAGE_BLOCKS_NV 0x8E6E +#define GL_MAX_COMBINED_TASK_UNIFORM_COMPONENTS_NV 0x8E6F +#define GL_MAX_MESH_WORK_GROUP_INVOCATIONS_NV 0x95A2 +#define GL_MAX_TASK_WORK_GROUP_INVOCATIONS_NV 0x95A3 +#define GL_MAX_MESH_TOTAL_MEMORY_SIZE_NV 0x9536 +#define GL_MAX_TASK_TOTAL_MEMORY_SIZE_NV 0x9537 +#define GL_MAX_MESH_OUTPUT_VERTICES_NV 0x9538 +#define GL_MAX_MESH_OUTPUT_PRIMITIVES_NV 0x9539 +#define GL_MAX_TASK_OUTPUT_COUNT_NV 0x953A +#define GL_MAX_DRAW_MESH_TASKS_COUNT_NV 0x953D +#define GL_MAX_MESH_VIEWS_NV 0x9557 +#define GL_MESH_OUTPUT_PER_VERTEX_GRANULARITY_NV 0x92DF +#define GL_MESH_OUTPUT_PER_PRIMITIVE_GRANULARITY_NV 0x9543 +#define GL_MAX_MESH_WORK_GROUP_SIZE_NV 0x953B +#define GL_MAX_TASK_WORK_GROUP_SIZE_NV 0x953C +#define GL_MESH_WORK_GROUP_SIZE_NV 0x953E +#define GL_TASK_WORK_GROUP_SIZE_NV 0x953F +#define GL_MESH_VERTICES_OUT_NV 0x9579 +#define GL_MESH_PRIMITIVES_OUT_NV 0x957A +#define GL_MESH_OUTPUT_TYPE_NV 0x957B +#define GL_UNIFORM_BLOCK_REFERENCED_BY_MESH_SHADER_NV 0x959C +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TASK_SHADER_NV 0x959D +#define GL_REFERENCED_BY_MESH_SHADER_NV 0x95A0 +#define GL_REFERENCED_BY_TASK_SHADER_NV 0x95A1 +#define GL_MESH_SHADER_BIT_NV 0x00000040 +#define GL_TASK_SHADER_BIT_NV 0x00000080 +#define GL_MESH_SUBROUTINE_NV 0x957C +#define GL_TASK_SUBROUTINE_NV 0x957D +#define GL_MESH_SUBROUTINE_UNIFORM_NV 0x957E +#define GL_TASK_SUBROUTINE_UNIFORM_NV 0x957F +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_MESH_SHADER_NV 0x959E +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TASK_SHADER_NV 0x959F +typedef void (APIENTRYP PFNGLDRAWMESHTASKSNVPROC) (GLuint first, GLuint count); +typedef void (APIENTRYP PFNGLDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect); +typedef void (APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTCOUNTNVPROC) (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshTasksNV (GLuint first, GLuint count); +GLAPI void APIENTRY glDrawMeshTasksIndirectNV (GLintptr indirect); +GLAPI void APIENTRY glMultiDrawMeshTasksIndirectNV (GLintptr indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawMeshTasksIndirectCountNV (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#endif +#endif /* GL_NV_mesh_shader */ + +#ifndef GL_NV_multisample_coverage +#define GL_NV_multisample_coverage 1 +#endif /* GL_NV_multisample_coverage */ + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif /* GL_NV_multisample_filter_hint */ + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); +#endif +#endif /* GL_NV_occlusion_query */ + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif /* GL_NV_packed_depth_stencil */ + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#endif +#endif /* GL_NV_parameter_buffer_object */ + +#ifndef GL_NV_parameter_buffer_object2 +#define GL_NV_parameter_buffer_object2 1 +#endif /* GL_NV_parameter_buffer_object2 */ + +#ifndef GL_NV_path_rendering +#define GL_NV_path_rendering 1 +#define GL_PATH_FORMAT_SVG_NV 0x9070 +#define GL_PATH_FORMAT_PS_NV 0x9071 +#define GL_STANDARD_FONT_NAME_NV 0x9072 +#define GL_SYSTEM_FONT_NAME_NV 0x9073 +#define GL_FILE_NAME_NV 0x9074 +#define GL_PATH_STROKE_WIDTH_NV 0x9075 +#define GL_PATH_END_CAPS_NV 0x9076 +#define GL_PATH_INITIAL_END_CAP_NV 0x9077 +#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 +#define GL_PATH_JOIN_STYLE_NV 0x9079 +#define GL_PATH_MITER_LIMIT_NV 0x907A +#define GL_PATH_DASH_CAPS_NV 0x907B +#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C +#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D +#define GL_PATH_DASH_OFFSET_NV 0x907E +#define GL_PATH_CLIENT_LENGTH_NV 0x907F +#define GL_PATH_FILL_MODE_NV 0x9080 +#define GL_PATH_FILL_MASK_NV 0x9081 +#define GL_PATH_FILL_COVER_MODE_NV 0x9082 +#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 +#define GL_PATH_STROKE_MASK_NV 0x9084 +#define GL_COUNT_UP_NV 0x9088 +#define GL_COUNT_DOWN_NV 0x9089 +#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A +#define GL_CONVEX_HULL_NV 0x908B +#define GL_BOUNDING_BOX_NV 0x908D +#define GL_TRANSLATE_X_NV 0x908E +#define GL_TRANSLATE_Y_NV 0x908F +#define GL_TRANSLATE_2D_NV 0x9090 +#define GL_TRANSLATE_3D_NV 0x9091 +#define GL_AFFINE_2D_NV 0x9092 +#define GL_AFFINE_3D_NV 0x9094 +#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 +#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 +#define GL_UTF8_NV 0x909A +#define GL_UTF16_NV 0x909B +#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C +#define GL_PATH_COMMAND_COUNT_NV 0x909D +#define GL_PATH_COORD_COUNT_NV 0x909E +#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F +#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 +#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 +#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 +#define GL_SQUARE_NV 0x90A3 +#define GL_ROUND_NV 0x90A4 +#define GL_TRIANGULAR_NV 0x90A5 +#define GL_BEVEL_NV 0x90A6 +#define GL_MITER_REVERT_NV 0x90A7 +#define GL_MITER_TRUNCATE_NV 0x90A8 +#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 +#define GL_USE_MISSING_GLYPH_NV 0x90AA +#define GL_PATH_ERROR_POSITION_NV 0x90AB +#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD +#define GL_ADJACENT_PAIRS_NV 0x90AE +#define GL_FIRST_TO_REST_NV 0x90AF +#define GL_PATH_GEN_MODE_NV 0x90B0 +#define GL_PATH_GEN_COEFF_NV 0x90B1 +#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 +#define GL_PATH_STENCIL_FUNC_NV 0x90B7 +#define GL_PATH_STENCIL_REF_NV 0x90B8 +#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 +#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD +#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE +#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF +#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 +#define GL_MOVE_TO_RESETS_NV 0x90B5 +#define GL_MOVE_TO_CONTINUES_NV 0x90B6 +#define GL_CLOSE_PATH_NV 0x00 +#define GL_MOVE_TO_NV 0x02 +#define GL_RELATIVE_MOVE_TO_NV 0x03 +#define GL_LINE_TO_NV 0x04 +#define GL_RELATIVE_LINE_TO_NV 0x05 +#define GL_HORIZONTAL_LINE_TO_NV 0x06 +#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 +#define GL_VERTICAL_LINE_TO_NV 0x08 +#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 +#define GL_QUADRATIC_CURVE_TO_NV 0x0A +#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B +#define GL_CUBIC_CURVE_TO_NV 0x0C +#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D +#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E +#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F +#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 +#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 +#define GL_SMALL_CCW_ARC_TO_NV 0x12 +#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 +#define GL_SMALL_CW_ARC_TO_NV 0x14 +#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 +#define GL_LARGE_CCW_ARC_TO_NV 0x16 +#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 +#define GL_LARGE_CW_ARC_TO_NV 0x18 +#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 +#define GL_RESTART_PATH_NV 0xF0 +#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 +#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 +#define GL_RECT_NV 0xF6 +#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 +#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA +#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC +#define GL_ARC_TO_NV 0xFE +#define GL_RELATIVE_ARC_TO_NV 0xFF +#define GL_BOLD_BIT_NV 0x01 +#define GL_ITALIC_BIT_NV 0x02 +#define GL_GLYPH_WIDTH_BIT_NV 0x01 +#define GL_GLYPH_HEIGHT_BIT_NV 0x02 +#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 +#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 +#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 +#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 +#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 +#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 +#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 +#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 +#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 +#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 +#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 +#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 +#define GL_FONT_ASCENDER_BIT_NV 0x00200000 +#define GL_FONT_DESCENDER_BIT_NV 0x00400000 +#define GL_FONT_HEIGHT_BIT_NV 0x00800000 +#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 +#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 +#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 +#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 +#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 +#define GL_ROUNDED_RECT_NV 0xE8 +#define GL_RELATIVE_ROUNDED_RECT_NV 0xE9 +#define GL_ROUNDED_RECT2_NV 0xEA +#define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB +#define GL_ROUNDED_RECT4_NV 0xEC +#define GL_RELATIVE_ROUNDED_RECT4_NV 0xED +#define GL_ROUNDED_RECT8_NV 0xEE +#define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF +#define GL_RELATIVE_RECT_NV 0xF7 +#define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368 +#define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369 +#define GL_FONT_UNAVAILABLE_NV 0x936A +#define GL_FONT_UNINTELLIGIBLE_NV 0x936B +#define GL_CONIC_CURVE_TO_NV 0x1A +#define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B +#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000 +#define GL_STANDARD_FONT_FORMAT_NV 0x936C +#define GL_2_BYTES_NV 0x1407 +#define GL_3_BYTES_NV 0x1408 +#define GL_4_BYTES_NV 0x1409 +#define GL_EYE_LINEAR_NV 0x2400 +#define GL_OBJECT_LINEAR_NV 0x2401 +#define GL_CONSTANT_NV 0x8576 +#define GL_PATH_FOG_GEN_MODE_NV 0x90AC +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 +#define GL_PATH_PROJECTION_NV 0x1701 +#define GL_PATH_MODELVIEW_NV 0x1700 +#define GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3 +#define GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6 +#define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36 +#define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3 +#define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4 +#define GL_PATH_PROJECTION_MATRIX_NV 0x0BA7 +#define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38 +#define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4 +#define GL_FRAGMENT_INPUT_NV 0x936D +typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); +typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); +typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); +typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); +typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); +typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); +typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); +typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); +typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); +typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); +typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); +typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +typedef void (APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint *baseAndCount); +typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef GLenum (APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); +typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); +GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); +GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); +GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString); +GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); +GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); +GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); +GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); +GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); +GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); +GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); +GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); +GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); +GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); +GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); +GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); +GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); +GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); +GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); +GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +GLAPI void APIENTRY glMatrixLoad3x2fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoad3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMult3x2fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMult3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glStencilThenCoverFillPathNV (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); +GLAPI void APIENTRY glStencilThenCoverStrokePathNV (GLuint path, GLint reference, GLuint mask, GLenum coverMode); +GLAPI void APIENTRY glStencilThenCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilThenCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI GLenum APIENTRY glPathGlyphIndexRangeNV (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint *baseAndCount); +GLAPI GLenum APIENTRY glPathGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI GLenum APIENTRY glPathMemoryGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glProgramPathFragmentInputGenNV (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glGetProgramResourcefvNV (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); +GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); +GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); +#endif +#endif /* GL_NV_path_rendering */ + +#ifndef GL_NV_path_rendering_shared_edge +#define GL_NV_path_rendering_shared_edge 1 +#define GL_SHARED_EDGE_NV 0xC0 +#endif /* GL_NV_path_rendering_shared_edge */ + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const void *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const void *pointer); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); +#endif +#endif /* GL_NV_pixel_data_range */ + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); +#endif +#endif /* GL_NV_point_sprite */ + +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B +typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_NV_present_video */ + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); +#endif +#endif /* GL_NV_primitive_restart */ + +#ifndef GL_NV_primitive_shading_rate +#define GL_NV_primitive_shading_rate 1 +#define GL_SHADING_RATE_IMAGE_PER_PRIMITIVE_NV 0x95B1 +#define GL_SHADING_RATE_IMAGE_PALETTE_COUNT_NV 0x95B2 +#endif /* GL_NV_primitive_shading_rate */ + +#ifndef GL_NV_query_resource +#define GL_NV_query_resource 1 +#define GL_QUERY_RESOURCE_TYPE_VIDMEM_ALLOC_NV 0x9540 +#define GL_QUERY_RESOURCE_MEMTYPE_VIDMEM_NV 0x9542 +#define GL_QUERY_RESOURCE_SYS_RESERVED_NV 0x9544 +#define GL_QUERY_RESOURCE_TEXTURE_NV 0x9545 +#define GL_QUERY_RESOURCE_RENDERBUFFER_NV 0x9546 +#define GL_QUERY_RESOURCE_BUFFEROBJECT_NV 0x9547 +typedef GLint (APIENTRYP PFNGLQUERYRESOURCENVPROC) (GLenum queryType, GLint tagId, GLuint count, GLint *buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glQueryResourceNV (GLenum queryType, GLint tagId, GLuint count, GLint *buffer); +#endif +#endif /* GL_NV_query_resource */ + +#ifndef GL_NV_query_resource_tag +#define GL_NV_query_resource_tag 1 +typedef void (APIENTRYP PFNGLGENQUERYRESOURCETAGNVPROC) (GLsizei n, GLint *tagIds); +typedef void (APIENTRYP PFNGLDELETEQUERYRESOURCETAGNVPROC) (GLsizei n, const GLint *tagIds); +typedef void (APIENTRYP PFNGLQUERYRESOURCETAGNVPROC) (GLint tagId, const GLchar *tagString); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueryResourceTagNV (GLsizei n, GLint *tagIds); +GLAPI void APIENTRY glDeleteQueryResourceTagNV (GLsizei n, const GLint *tagIds); +GLAPI void APIENTRY glQueryResourceTagNV (GLint tagId, const GLchar *tagString); +#endif +#endif /* GL_NV_query_resource_tag */ + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); +#endif +#endif /* GL_NV_register_combiners */ + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); +#endif +#endif /* GL_NV_register_combiners2 */ + +#ifndef GL_NV_representative_fragment_test +#define GL_NV_representative_fragment_test 1 +#define GL_REPRESENTATIVE_FRAGMENT_TEST_NV 0x937F +#endif /* GL_NV_representative_fragment_test */ + +#ifndef GL_NV_robustness_video_memory_purge +#define GL_NV_robustness_video_memory_purge 1 +#define GL_PURGED_CONTEXT_RESET_NV 0x92BB +#endif /* GL_NV_robustness_video_memory_purge */ + +#ifndef GL_NV_sample_locations +#define GL_NV_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340 +#define GL_SAMPLE_LOCATION_NV 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343 +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLRESOLVEDEPTHVALUESNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSampleLocationsfvNV (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvNV (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glResolveDepthValuesNV (void); +#endif +#endif /* GL_NV_sample_locations */ + +#ifndef GL_NV_sample_mask_override_coverage +#define GL_NV_sample_mask_override_coverage 1 +#endif /* GL_NV_sample_mask_override_coverage */ + +#ifndef GL_NV_scissor_exclusive +#define GL_NV_scissor_exclusive 1 +#define GL_SCISSOR_TEST_EXCLUSIVE_NV 0x9555 +#define GL_SCISSOR_BOX_EXCLUSIVE_NV 0x9556 +typedef void (APIENTRYP PFNGLSCISSOREXCLUSIVENVPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSOREXCLUSIVEARRAYVNVPROC) (GLuint first, GLsizei count, const GLint *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glScissorExclusiveNV (GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorExclusiveArrayvNV (GLuint first, GLsizei count, const GLint *v); +#endif +#endif /* GL_NV_scissor_exclusive */ + +#ifndef GL_NV_shader_atomic_counters +#define GL_NV_shader_atomic_counters 1 +#endif /* GL_NV_shader_atomic_counters */ + +#ifndef GL_NV_shader_atomic_float +#define GL_NV_shader_atomic_float 1 +#endif /* GL_NV_shader_atomic_float */ + +#ifndef GL_NV_shader_atomic_float64 +#define GL_NV_shader_atomic_float64 1 +#endif /* GL_NV_shader_atomic_float64 */ + +#ifndef GL_NV_shader_atomic_fp16_vector +#define GL_NV_shader_atomic_fp16_vector 1 +#endif /* GL_NV_shader_atomic_fp16_vector */ + +#ifndef GL_NV_shader_atomic_int64 +#define GL_NV_shader_atomic_int64 1 +#endif /* GL_NV_shader_atomic_int64 */ + +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 +typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); +typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); +typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); +typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); +typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); +GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); +GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); +GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); +GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); +GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); +GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); +GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); +GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); +GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_NV_shader_buffer_load */ + +#ifndef GL_NV_shader_buffer_store +#define GL_NV_shader_buffer_store 1 +#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 +#endif /* GL_NV_shader_buffer_store */ + +#ifndef GL_NV_shader_storage_buffer_object +#define GL_NV_shader_storage_buffer_object 1 +#endif /* GL_NV_shader_storage_buffer_object */ + +#ifndef GL_NV_shader_subgroup_partitioned +#define GL_NV_shader_subgroup_partitioned 1 +#define GL_SUBGROUP_FEATURE_PARTITIONED_BIT_NV 0x00000100 +#endif /* GL_NV_shader_subgroup_partitioned */ + +#ifndef GL_NV_shader_texture_footprint +#define GL_NV_shader_texture_footprint 1 +#endif /* GL_NV_shader_texture_footprint */ + +#ifndef GL_NV_shader_thread_group +#define GL_NV_shader_thread_group 1 +#define GL_WARP_SIZE_NV 0x9339 +#define GL_WARPS_PER_SM_NV 0x933A +#define GL_SM_COUNT_NV 0x933B +#endif /* GL_NV_shader_thread_group */ + +#ifndef GL_NV_shader_thread_shuffle +#define GL_NV_shader_thread_shuffle 1 +#endif /* GL_NV_shader_thread_shuffle */ + +#ifndef GL_NV_shading_rate_image +#define GL_NV_shading_rate_image 1 +#define GL_SHADING_RATE_IMAGE_NV 0x9563 +#define GL_SHADING_RATE_NO_INVOCATIONS_NV 0x9564 +#define GL_SHADING_RATE_1_INVOCATION_PER_PIXEL_NV 0x9565 +#define GL_SHADING_RATE_1_INVOCATION_PER_1X2_PIXELS_NV 0x9566 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X1_PIXELS_NV 0x9567 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X2_PIXELS_NV 0x9568 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X4_PIXELS_NV 0x9569 +#define GL_SHADING_RATE_1_INVOCATION_PER_4X2_PIXELS_NV 0x956A +#define GL_SHADING_RATE_1_INVOCATION_PER_4X4_PIXELS_NV 0x956B +#define GL_SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV 0x956C +#define GL_SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV 0x956D +#define GL_SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV 0x956E +#define GL_SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV 0x956F +#define GL_SHADING_RATE_IMAGE_BINDING_NV 0x955B +#define GL_SHADING_RATE_IMAGE_TEXEL_WIDTH_NV 0x955C +#define GL_SHADING_RATE_IMAGE_TEXEL_HEIGHT_NV 0x955D +#define GL_SHADING_RATE_IMAGE_PALETTE_SIZE_NV 0x955E +#define GL_MAX_COARSE_FRAGMENT_SAMPLES_NV 0x955F +#define GL_SHADING_RATE_SAMPLE_ORDER_DEFAULT_NV 0x95AE +#define GL_SHADING_RATE_SAMPLE_ORDER_PIXEL_MAJOR_NV 0x95AF +#define GL_SHADING_RATE_SAMPLE_ORDER_SAMPLE_MAJOR_NV 0x95B0 +typedef void (APIENTRYP PFNGLBINDSHADINGRATEIMAGENVPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLGETSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint entry, GLenum *rate); +typedef void (APIENTRYP PFNGLGETSHADINGRATESAMPLELOCATIONIVNVPROC) (GLenum rate, GLuint samples, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLSHADINGRATEIMAGEBARRIERNVPROC) (GLboolean synchronize); +typedef void (APIENTRYP PFNGLSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); +typedef void (APIENTRYP PFNGLSHADINGRATESAMPLEORDERNVPROC) (GLenum order); +typedef void (APIENTRYP PFNGLSHADINGRATESAMPLEORDERCUSTOMNVPROC) (GLenum rate, GLuint samples, const GLint *locations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindShadingRateImageNV (GLuint texture); +GLAPI void APIENTRY glGetShadingRateImagePaletteNV (GLuint viewport, GLuint entry, GLenum *rate); +GLAPI void APIENTRY glGetShadingRateSampleLocationivNV (GLenum rate, GLuint samples, GLuint index, GLint *location); +GLAPI void APIENTRY glShadingRateImageBarrierNV (GLboolean synchronize); +GLAPI void APIENTRY glShadingRateImagePaletteNV (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); +GLAPI void APIENTRY glShadingRateSampleOrderNV (GLenum order); +GLAPI void APIENTRY glShadingRateSampleOrderCustomNV (GLenum rate, GLuint samples, const GLint *locations); +#endif +#endif /* GL_NV_shading_rate_image */ + +#ifndef GL_NV_stereo_view_rendering +#define GL_NV_stereo_view_rendering 1 +#endif /* GL_NV_stereo_view_rendering */ + +#ifndef GL_NV_tessellation_program5 +#define GL_NV_tessellation_program5 1 +#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 +#define GL_TESS_CONTROL_PROGRAM_NV 0x891E +#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F +#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 +#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 +#endif /* GL_NV_tessellation_program5 */ + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif /* GL_NV_texgen_emboss */ + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif /* GL_NV_texgen_reflection */ + +#ifndef GL_NV_texture_barrier +#define GL_NV_texture_barrier 1 +typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureBarrierNV (void); +#endif +#endif /* GL_NV_texture_barrier */ + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif /* GL_NV_texture_compression_vtc */ + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif /* GL_NV_texture_env_combine4 */ + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif /* GL_NV_texture_expand_normal */ + +#ifndef GL_NV_texture_multisample +#define GL_NV_texture_multisample 1 +#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 +#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#endif +#endif /* GL_NV_texture_multisample */ + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif /* GL_NV_texture_rectangle */ + +#ifndef GL_NV_texture_rectangle_compressed +#define GL_NV_texture_rectangle_compressed 1 +#endif /* GL_NV_texture_rectangle_compressed */ + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif /* GL_NV_texture_shader */ + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif /* GL_NV_texture_shader2 */ + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif /* GL_NV_texture_shader3 */ + +#ifndef GL_NV_timeline_semaphore +#define GL_NV_timeline_semaphore 1 +#define GL_TIMELINE_SEMAPHORE_VALUE_NV 0x9595 +#define GL_SEMAPHORE_TYPE_NV 0x95B3 +#define GL_SEMAPHORE_TYPE_BINARY_NV 0x95B4 +#define GL_SEMAPHORE_TYPE_TIMELINE_NV 0x95B5 +#define GL_MAX_TIMELINE_SEMAPHORE_VALUE_DIFFERENCE_NV 0x95B6 +typedef void (APIENTRYP PFNGLCREATESEMAPHORESNVPROC) (GLsizei n, GLuint *semaphores); +typedef void (APIENTRYP PFNGLSEMAPHOREPARAMETERIVNVPROC) (GLuint semaphore, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETSEMAPHOREPARAMETERIVNVPROC) (GLuint semaphore, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCreateSemaphoresNV (GLsizei n, GLuint *semaphores); +GLAPI void APIENTRY glSemaphoreParameterivNV (GLuint semaphore, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetSemaphoreParameterivNV (GLuint semaphore, GLenum pname, GLint *params); +#endif +#endif /* GL_NV_timeline_semaphore */ + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F +#define GL_LAYER_NV 0x8DAA +#define GL_NEXT_BUFFER_NV -2 +#define GL_SKIP_COMPONENTS4_NV -3 +#define GL_SKIP_COMPONENTS3_NV -4 +#define GL_SKIP_COMPONENTS2_NV -5 +#define GL_SKIP_COMPONENTS1_NV -6 +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLenum bufferMode); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackNV (void); +GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLsizei count, const GLint *attribs, GLenum bufferMode); +GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); +GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); +GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif +#endif /* GL_NV_transform_feedback */ + +#ifndef GL_NV_transform_feedback2 +#define GL_NV_transform_feedback2 1 +#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedbackNV (void); +GLAPI void APIENTRY glResumeTransformFeedbackNV (void); +GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); +#endif +#endif /* GL_NV_transform_feedback2 */ + +#ifndef GL_NV_uniform_buffer_std430_layout +#define GL_NV_uniform_buffer_std430_layout 1 +#endif /* GL_NV_uniform_buffer_std430_layout */ + +#ifndef GL_NV_uniform_buffer_unified_memory +#define GL_NV_uniform_buffer_unified_memory 1 +#define GL_UNIFORM_BUFFER_UNIFIED_NV 0x936E +#define GL_UNIFORM_BUFFER_ADDRESS_NV 0x936F +#define GL_UNIFORM_BUFFER_LENGTH_NV 0x9370 +#endif /* GL_NV_uniform_buffer_unified_memory */ + +#ifndef GL_NV_vdpau_interop +#define GL_NV_vdpau_interop 1 +typedef GLintptr GLvdpauSurfaceNV; +#define GL_SURFACE_STATE_NV 0x86EB +#define GL_SURFACE_REGISTERED_NV 0x86FD +#define GL_SURFACE_MAPPED_NV 0x8700 +#define GL_WRITE_DISCARD_NV 0x88BE +typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const void *vdpDevice, const void *getProcAddress); +typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLboolean (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); +typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVDPAUInitNV (const void *vdpDevice, const void *getProcAddress); +GLAPI void APIENTRY glVDPAUFiniNV (void); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLboolean APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); +GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif +#endif /* GL_NV_vdpau_interop */ + +#ifndef GL_NV_vdpau_interop2 +#define GL_NV_vdpau_interop2 1 +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACEWITHPICTURESTRUCTURENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames, GLboolean isFrameStructure); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceWithPictureStructureNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames, GLboolean isFrameStructure); +#endif +#endif /* GL_NV_vdpau_interop2 */ + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const void *pointer); +#endif +#endif /* GL_NV_vertex_array_range */ + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif /* GL_NV_vertex_array_range2 */ + +#ifndef GL_NV_vertex_attrib_integer_64bit +#define GL_NV_vertex_attrib_integer_64bit 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); +GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif +#endif /* GL_NV_vertex_attrib_integer_64bit */ + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 +typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); +GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); +#endif +#endif /* GL_NV_vertex_buffer_unified_memory */ + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, void **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); +GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); +GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, void **pointer); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); +GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); +#endif +#endif /* GL_NV_vertex_program */ + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif /* GL_NV_vertex_program1_1 */ + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif /* GL_NV_vertex_program2 */ + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif /* GL_NV_vertex_program2_option */ + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif /* GL_NV_vertex_program3 */ + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD +#endif /* GL_NV_vertex_program4 */ + +#ifndef GL_NV_video_capture +#define GL_NV_video_capture 1 +#define GL_VIDEO_BUFFER_NV 0x9020 +#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 +#define GL_FIELD_UPPER_NV 0x9022 +#define GL_FIELD_LOWER_NV 0x9023 +#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 +#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 +#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 +#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 +#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 +#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 +#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A +#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B +#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C +#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D +#define GL_PARTIAL_SUCCESS_NV 0x902E +#define GL_SUCCESS_NV 0x902F +#define GL_FAILURE_NV 0x9030 +#define GL_YCBYCR8_422_NV 0x9031 +#define GL_YCBAYCR8A_4224_NV 0x9032 +#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 +#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 +#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 +#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 +#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 +#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 +#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 +#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A +#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B +#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C +typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#endif +#endif /* GL_NV_video_capture */ + +#ifndef GL_NV_viewport_array2 +#define GL_NV_viewport_array2 1 +#endif /* GL_NV_viewport_array2 */ + +#ifndef GL_NV_viewport_swizzle +#define GL_NV_viewport_swizzle 1 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV 0x9350 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_X_NV 0x9351 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Y_NV 0x9352 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Y_NV 0x9353 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Z_NV 0x9354 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Z_NV 0x9355 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_W_NV 0x9356 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_W_NV 0x9357 +#define GL_VIEWPORT_SWIZZLE_X_NV 0x9358 +#define GL_VIEWPORT_SWIZZLE_Y_NV 0x9359 +#define GL_VIEWPORT_SWIZZLE_Z_NV 0x935A +#define GL_VIEWPORT_SWIZZLE_W_NV 0x935B +typedef void (APIENTRYP PFNGLVIEWPORTSWIZZLENVPROC) (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportSwizzleNV (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#endif +#endif /* GL_NV_viewport_swizzle */ + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif /* GL_OML_interlace */ + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif /* GL_OML_resample */ + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif /* GL_OML_subsample */ + +#ifndef GL_OVR_multiview +#define GL_OVR_multiview 1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 +#define GL_MAX_VIEWS_OVR 0x9631 +#define GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR 0x9633 +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferTextureMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#endif +#endif /* GL_OVR_multiview */ + +#ifndef GL_OVR_multiview2 +#define GL_OVR_multiview2 1 +#endif /* GL_OVR_multiview2 */ + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); +#endif +#endif /* GL_PGI_misc_hints */ + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif /* GL_PGI_vertex_hints */ + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif /* GL_REND_screen_coordinates */ + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#define GL_RGBA_DXT5_S3TC 0x83A4 +#define GL_RGBA4_DXT5_S3TC 0x83A5 +#endif /* GL_S3_s3tc */ + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); +#endif +#endif /* GL_SGIS_detail_texture */ + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); +#endif +#endif /* GL_SGIS_fog_function */ + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif /* GL_SGIS_generate_mipmap */ + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); +#endif +#endif /* GL_SGIS_multisample */ + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); +#endif +#endif /* GL_SGIS_pixel_texture */ + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif /* GL_SGIS_point_line_texgen */ + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_SGIS_point_parameters */ + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); +#endif +#endif /* GL_SGIS_sharpen_texture */ + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_SGIS_texture4D */ + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif /* GL_SGIS_texture_border_clamp */ + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif +#endif /* GL_SGIS_texture_color_mask */ + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif /* GL_SGIS_texture_edge_clamp */ + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif +#endif /* GL_SGIS_texture_filter4 */ + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif /* GL_SGIS_texture_lod */ + +#ifndef GL_SGIS_texture_select +#define GL_SGIS_texture_select 1 +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif /* GL_SGIS_texture_select */ + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#define GL_ASYNC_MARKER_SGIX 0x8329 +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); +#endif +#endif /* GL_SGIX_async */ + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif /* GL_SGIX_async_histogram */ + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif /* GL_SGIX_async_pixel */ + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif /* GL_SGIX_blend_alpha_minmax */ + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif /* GL_SGIX_calligraphic_fragment */ + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif /* GL_SGIX_clipmap */ + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif /* GL_SGIX_convolution_accuracy */ + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif /* GL_SGIX_depth_pass_instrument */ + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif /* GL_SGIX_depth_texture */ + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif +#endif /* GL_SGIX_flush_raster */ + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif /* GL_SGIX_fog_offset */ + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); +GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); +#endif +#endif /* GL_SGIX_fragment_lighting */ + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); +#endif +#endif /* GL_SGIX_framezoom */ + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const void *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const void *params); +#endif +#endif /* GL_SGIX_igloo_interface */ + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); +#endif +#endif /* GL_SGIX_instruments */ + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#define GL_INTERLACE_SGIX 0x8094 +#endif /* GL_SGIX_interlace */ + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif /* GL_SGIX_ir_instrument1 */ + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#define GL_LIST_PRIORITY_SGIX 0x8182 +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); +GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); +GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); +#endif +#endif /* GL_SGIX_list_priority */ + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); +#endif +#endif /* GL_SGIX_pixel_texture */ + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif /* GL_SGIX_pixel_tiles */ + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); +#endif +#endif /* GL_SGIX_polynomial_ffd */ + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); +#endif +#endif /* GL_SGIX_reference_plane */ + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#define GL_PACK_RESAMPLE_SGIX 0x842E +#define GL_UNPACK_RESAMPLE_SGIX 0x842F +#define GL_RESAMPLE_REPLICATE_SGIX 0x8433 +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x8434 +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif /* GL_SGIX_resample */ + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif /* GL_SGIX_scalebias_hint */ + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif /* GL_SGIX_shadow */ + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif /* GL_SGIX_shadow_ambient */ + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); +#endif +#endif /* GL_SGIX_sprite */ + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif /* GL_SGIX_subsample */ + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif +#endif /* GL_SGIX_tag_sample_buffer */ + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif /* GL_SGIX_texture_add_env */ + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif /* GL_SGIX_texture_coordinate_clamp */ + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif /* GL_SGIX_texture_lod_bias */ + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif /* GL_SGIX_texture_multi_buffer */ + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif /* GL_SGIX_texture_scale_bias */ + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif /* GL_SGIX_vertex_preclip */ + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif /* GL_SGIX_ycrcb */ + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif /* GL_SGIX_ycrcb_subsample */ + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif /* GL_SGIX_ycrcba */ + +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif /* GL_SGI_color_matrix */ + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, void *table); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); +#endif +#endif /* GL_SGI_color_table */ + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif /* GL_SGI_texture_color_table */ + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif +#endif /* GL_SUNX_constant_data */ + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif /* GL_SUN_convolution_border_modes */ + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); +#endif +#endif /* GL_SUN_global_alpha */ + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif +#endif /* GL_SUN_mesh_array */ + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif /* GL_SUN_slice_accum */ + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const void **pointer); +#endif +#endif /* GL_SUN_triangle_list */ + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif +#endif /* GL_SUN_vertex */ + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif /* GL_WIN_phong_shading */ + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif /* GL_WIN_specular_fog */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/irr/test/CMakeLists.txt b/irr/test/CMakeLists.txt new file mode 100644 index 000000000..6518f69c1 --- /dev/null +++ b/irr/test/CMakeLists.txt @@ -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) diff --git a/irr/test/data/sample_16bpp_v3.bmp b/irr/test/data/sample_16bpp_v3.bmp new file mode 100644 index 000000000..4b6fbcf50 Binary files /dev/null and b/irr/test/data/sample_16bpp_v3.bmp differ diff --git a/irr/test/data/sample_16bpp_v7.bmp b/irr/test/data/sample_16bpp_v7.bmp new file mode 100644 index 000000000..7a0b8a6ed Binary files /dev/null and b/irr/test/data/sample_16bpp_v7.bmp differ diff --git a/irr/test/data/sample_24bpp.png b/irr/test/data/sample_24bpp.png new file mode 100644 index 000000000..d38f5989c Binary files /dev/null and b/irr/test/data/sample_24bpp.png differ diff --git a/irr/test/data/sample_24bpp_down.tga b/irr/test/data/sample_24bpp_down.tga new file mode 100644 index 000000000..031f88282 Binary files /dev/null and b/irr/test/data/sample_24bpp_down.tga differ diff --git a/irr/test/data/sample_24bpp_rle_down.tga b/irr/test/data/sample_24bpp_rle_down.tga new file mode 100644 index 000000000..24e765e19 Binary files /dev/null and b/irr/test/data/sample_24bpp_rle_down.tga differ diff --git a/irr/test/data/sample_24bpp_rle_up.tga b/irr/test/data/sample_24bpp_rle_up.tga new file mode 100644 index 000000000..4a5f9604d Binary files /dev/null and b/irr/test/data/sample_24bpp_rle_up.tga differ diff --git a/irr/test/data/sample_24bpp_up.tga b/irr/test/data/sample_24bpp_up.tga new file mode 100644 index 000000000..1f1edc6e9 Binary files /dev/null and b/irr/test/data/sample_24bpp_up.tga differ diff --git a/irr/test/data/sample_24bpp_v3.bmp b/irr/test/data/sample_24bpp_v3.bmp new file mode 100644 index 000000000..4684f1466 Binary files /dev/null and b/irr/test/data/sample_24bpp_v3.bmp differ diff --git a/irr/test/data/sample_24bpp_v7.bmp b/irr/test/data/sample_24bpp_v7.bmp new file mode 100644 index 000000000..1fa343188 Binary files /dev/null and b/irr/test/data/sample_24bpp_v7.bmp differ diff --git a/irr/test/data/sample_4bpp_v3.bmp b/irr/test/data/sample_4bpp_v3.bmp new file mode 100644 index 000000000..0cc06f316 Binary files /dev/null and b/irr/test/data/sample_4bpp_v3.bmp differ diff --git a/irr/test/data/sample_8bpp.png b/irr/test/data/sample_8bpp.png new file mode 100644 index 000000000..c81f816f4 Binary files /dev/null and b/irr/test/data/sample_8bpp.png differ diff --git a/irr/test/data/sample_8bpp_down.tga b/irr/test/data/sample_8bpp_down.tga new file mode 100644 index 000000000..e46cad554 Binary files /dev/null and b/irr/test/data/sample_8bpp_down.tga differ diff --git a/irr/test/data/sample_8bpp_rle_down.tga b/irr/test/data/sample_8bpp_rle_down.tga new file mode 100644 index 000000000..3d34bff4c Binary files /dev/null and b/irr/test/data/sample_8bpp_rle_down.tga differ diff --git a/irr/test/data/sample_8bpp_rle_up.tga b/irr/test/data/sample_8bpp_rle_up.tga new file mode 100644 index 000000000..0372bc34c Binary files /dev/null and b/irr/test/data/sample_8bpp_rle_up.tga differ diff --git a/irr/test/data/sample_8bpp_up.tga b/irr/test/data/sample_8bpp_up.tga new file mode 100644 index 000000000..a314e8689 Binary files /dev/null and b/irr/test/data/sample_8bpp_up.tga differ diff --git a/irr/test/data/sample_8bpp_v3.bmp b/irr/test/data/sample_8bpp_v3.bmp new file mode 100644 index 000000000..a890e6465 Binary files /dev/null and b/irr/test/data/sample_8bpp_v3.bmp differ diff --git a/irr/test/data/sample_8bpp_v3_rle.bmp b/irr/test/data/sample_8bpp_v3_rle.bmp new file mode 100644 index 000000000..d460d0fd6 Binary files /dev/null and b/irr/test/data/sample_8bpp_v3_rle.bmp differ diff --git a/irr/test/data/sample_8bpp_v7.bmp b/irr/test/data/sample_8bpp_v7.bmp new file mode 100644 index 000000000..a31a342c2 Binary files /dev/null and b/irr/test/data/sample_8bpp_v7.bmp differ diff --git a/irr/test/data/sample_8bpp_v7_rle.bmp b/irr/test/data/sample_8bpp_v7_rle.bmp new file mode 100644 index 000000000..d197b09a6 Binary files /dev/null and b/irr/test/data/sample_8bpp_v7_rle.bmp differ diff --git a/irr/test/image_loader_test.cpp b/irr/test/image_loader_test.cpp new file mode 100644 index 000000000..1dd4888f2 --- /dev/null +++ b/irr/test/image_loader_test.cpp @@ -0,0 +1,162 @@ +#include +#include +#include +#include +#include + +using namespace irr; + +struct ImageDesc +{ + const char *name; + video::ECOLOR_FORMAT format; + std::vector data; +}; + +template +std::vector to_byte_array(std::initializer_list in_data) +{ + std::vector 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({ + 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({ + 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({ + 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 = ℑ + } + 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; +}