mirror of
https://github.com/minetest/irrlicht.git
synced 2025-07-03 08:40:26 +02:00
Compare commits
47 Commits
Author | SHA1 | Date | |
---|---|---|---|
2bbfa178ea | |||
61682104df | |||
46542793d6 | |||
9f2d13a2b6 | |||
602a4050b5 | |||
54de743641 | |||
3e8d8440e3 | |||
8189b2338a | |||
0a77ef5dc2 | |||
19f0f707a6 | |||
83998f7471 | |||
b7bb4b5958 | |||
f28e442bfa | |||
4cd5c3489e | |||
52e4d72ae2 | |||
7241a49566 | |||
2db8c8728e | |||
270b2bec6e | |||
c83f28431b | |||
e60921f0cb | |||
92252f70d2 | |||
4e9d0db4be | |||
2bb2d3fe01 | |||
45ace61007 | |||
89d0717779 | |||
19819bd23a | |||
2894d9ab03 | |||
e56605d7ce | |||
f91be59811 | |||
0069837920 | |||
ad96fabe4a | |||
6ba6118b8c | |||
7f11d2f950 | |||
fe3e41e7ea | |||
4478b1f1ec | |||
3992129735 | |||
0dab737d60 | |||
330150854b | |||
6779ac83f9 | |||
f1504093d1 | |||
8482cc3db8 | |||
a4f94b7656 | |||
4299ee21d8 | |||
5b81694b1d | |||
66786d0059 | |||
9df2f0b944 | |||
c3571261ca |
86
.github/workflows/build.yml
vendored
86
.github/workflows/build.yml
vendored
@ -10,7 +10,7 @@ jobs:
|
||||
linux-gl:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get update
|
||||
@ -30,7 +30,7 @@ jobs:
|
||||
make DESTDIR=$PWD/_install install
|
||||
tar -c -I "gzip -9" -f irrlicht-linux.tar.gz -C ./_install/usr/local .
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: irrlicht-linux
|
||||
path: ./irrlicht-linux.tar.gz
|
||||
@ -39,7 +39,7 @@ jobs:
|
||||
# Xvfb test is broken on 20.04 for unknown reasons (not our bug)
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get update
|
||||
@ -61,9 +61,10 @@ jobs:
|
||||
LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest ogles2
|
||||
|
||||
linux-sdl:
|
||||
runs-on: ubuntu-20.04
|
||||
# something is wrong with the SDL cmake files on 20.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get update
|
||||
@ -71,7 +72,7 @@ jobs:
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cmake . -DBUILD_EXAMPLES=1 -DUSE_SDL2=ON
|
||||
cmake . -DBUILD_EXAMPLES=1 -DUSE_SDL2=ON -DCMAKE_BUILD_TYPE=Debug
|
||||
make -j2
|
||||
|
||||
- name: Test (headless)
|
||||
@ -83,7 +84,7 @@ jobs:
|
||||
# Xvfb test is broken on 20.04 for unknown reasons (not our bug)
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get update
|
||||
@ -105,9 +106,10 @@ jobs:
|
||||
LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest opengl3
|
||||
|
||||
linux-sdl-gles2:
|
||||
runs-on: ubuntu-20.04
|
||||
# something is wrong with the SDL cmake files on 20.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get update
|
||||
@ -140,21 +142,21 @@ jobs:
|
||||
- {variant: win32, arch: i686, extras: "-sdl"}
|
||||
- {variant: win64, arch: x86_64, extras: "-sdl"}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install compiler
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install cmake -qyy
|
||||
./scripts/ci-get-mingw.sh ${{matrix.config.arch}}
|
||||
./scripts/ci-get-mingw.sh
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
./scripts/ci-build-mingw.sh package
|
||||
env:
|
||||
CC: ${{matrix.config.arch}}-w64-mingw32-gcc
|
||||
CXX: ${{matrix.config.arch}}-w64-mingw32-g++
|
||||
CC: ${{matrix.config.arch}}-w64-mingw32-clang
|
||||
CXX: ${{matrix.config.arch}}-w64-mingw32-clang++
|
||||
extras: ${{matrix.config.extras}}
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: irrlicht-${{matrix.config.variant}}${{matrix.config.extras}}
|
||||
path: ./irrlicht-${{matrix.config.variant}}${{matrix.config.extras}}.zip
|
||||
@ -162,7 +164,7 @@ jobs:
|
||||
macos:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install deps
|
||||
run: |
|
||||
brew update
|
||||
@ -180,7 +182,7 @@ jobs:
|
||||
macos-sdl:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install deps
|
||||
run: |
|
||||
brew update
|
||||
@ -197,7 +199,7 @@ jobs:
|
||||
env:
|
||||
VCPKG_VERSION: 8eb57355a4ffb410a2e94c07b4dca2dffbee8e50
|
||||
# 2023.10.19
|
||||
vcpkg_packages: zlib libpng libjpeg-turbo opengl-registry
|
||||
vcpkg_packages: zlib libpng libjpeg-turbo
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@ -214,6 +216,7 @@ jobs:
|
||||
-
|
||||
use: FALSE
|
||||
label: '(no SDL)'
|
||||
vcpkg_packages: opengl-registry
|
||||
-
|
||||
use: TRUE
|
||||
label: '(with SDL)'
|
||||
@ -221,7 +224,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Restore from cache and run vcpkg
|
||||
uses: lukka/run-vcpkg@v7
|
||||
@ -254,7 +257,50 @@ jobs:
|
||||
run: move include artifact/
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: msvc-${{ matrix.config.arch }}
|
||||
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 }}
|
||||
|
@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
set(IRRLICHTMT_REVISION 14)
|
||||
set(IRRLICHTMT_REVISION 15)
|
||||
|
||||
project(Irrlicht
|
||||
VERSION 1.9.0.${IRRLICHTMT_REVISION}
|
||||
|
@ -1,5 +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()
|
||||
|
@ -15,6 +15,7 @@ The following libraries are required to be installed:
|
||||
* 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
|
||||
@ -23,7 +24,7 @@ Aside from standard search options (`ZLIB_INCLUDE_DIR`, `ZLIB_LIBRARY`, ...) the
|
||||
* `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: `OFF`) - Use SDL2 instead of native platform device
|
||||
* `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:
|
||||
|
||||
@ -40,7 +41,7 @@ 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 opengl-registry --triplet x64-windows
|
||||
vcpkg install zlib libjpeg-turbo libpng sdl2 --triplet x64-windows
|
||||
|
||||
Run the following script in PowerShell:
|
||||
|
||||
|
@ -206,37 +206,6 @@ namespace scene
|
||||
}
|
||||
|
||||
|
||||
//! Append the meshbuffer 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.
|
||||
\param other Meshbuffer to be appended to this one.
|
||||
*/
|
||||
void append(const IMeshBuffer* const other) override
|
||||
{
|
||||
/*
|
||||
if (this==other)
|
||||
return;
|
||||
|
||||
const u32 vertexCount = getVertexCount();
|
||||
u32 i;
|
||||
|
||||
Vertices.reallocate(vertexCount+other->getVertexCount());
|
||||
for (i=0; i<other->getVertexCount(); ++i)
|
||||
{
|
||||
Vertices.push_back(reinterpret_cast<const T*>(other->getVertices())[i]);
|
||||
}
|
||||
|
||||
Indices.reallocate(getIndexCount()+other->getIndexCount());
|
||||
for (i=0; i<other->getIndexCount(); ++i)
|
||||
{
|
||||
Indices.push_back(other->getIndices()[i]+vertexCount);
|
||||
}
|
||||
BoundingBox.addInternalBox(other->getBoundingBox());
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
//! get the current hardware mapping hint
|
||||
E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const override
|
||||
{
|
||||
|
@ -19,75 +19,9 @@ enum E_ATTRIBUTE_TYPE
|
||||
// float attribute
|
||||
EAT_FLOAT,
|
||||
|
||||
// string attribute
|
||||
EAT_STRING,
|
||||
|
||||
// boolean attribute
|
||||
EAT_BOOL,
|
||||
|
||||
// enumeration attribute
|
||||
EAT_ENUM,
|
||||
|
||||
// color attribute
|
||||
EAT_COLOR,
|
||||
|
||||
// floating point color attribute
|
||||
EAT_COLORF,
|
||||
|
||||
// 3d vector attribute
|
||||
EAT_VECTOR3D,
|
||||
|
||||
// 2d position attribute
|
||||
EAT_POSITION2D,
|
||||
|
||||
// vector 2d attribute
|
||||
EAT_VECTOR2D,
|
||||
|
||||
// rectangle attribute
|
||||
EAT_RECT,
|
||||
|
||||
// matrix attribute
|
||||
EAT_MATRIX,
|
||||
|
||||
// quaternion attribute
|
||||
EAT_QUATERNION,
|
||||
|
||||
// 3d bounding box
|
||||
EAT_BBOX,
|
||||
|
||||
// plane
|
||||
EAT_PLANE,
|
||||
|
||||
// 3d triangle
|
||||
EAT_TRIANGLE3D,
|
||||
|
||||
// line 2d
|
||||
EAT_LINE2D,
|
||||
|
||||
// line 3d
|
||||
EAT_LINE3D,
|
||||
|
||||
// array of stringws attribute
|
||||
EAT_STRINGWARRAY,
|
||||
|
||||
// array of float
|
||||
EAT_FLOATARRAY,
|
||||
|
||||
// array of int
|
||||
EAT_INTARRAY,
|
||||
|
||||
// binary data attribute
|
||||
EAT_BINARY,
|
||||
|
||||
// texture reference attribute
|
||||
EAT_TEXTURE,
|
||||
|
||||
// user pointer void*
|
||||
EAT_USER_POINTER,
|
||||
|
||||
// dimension attribute
|
||||
EAT_DIMENSION2D,
|
||||
|
||||
// known attribute type count
|
||||
EAT_COUNT,
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef __E_MATERIAL_TYPES_H_INCLUDED__
|
||||
#define __E_MATERIAL_TYPES_H_INCLUDED__
|
||||
|
||||
#include "irrTypes.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
@ -67,6 +69,9 @@ namespace video
|
||||
0
|
||||
};
|
||||
|
||||
constexpr u32 numBuiltInMaterials =
|
||||
sizeof(sBuiltInMaterialTypeNames) / sizeof(char*) - 1;
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
|
@ -6,25 +6,10 @@
|
||||
#define __I_ATTRIBUTES_H_INCLUDED__
|
||||
|
||||
#include "IReferenceCounted.h"
|
||||
#include "SColor.h"
|
||||
#include "vector3d.h"
|
||||
#include "vector2d.h"
|
||||
#include "line2d.h"
|
||||
#include "line3d.h"
|
||||
#include "triangle3d.h"
|
||||
#include "position2d.h"
|
||||
#include "rect.h"
|
||||
#include "dimension2d.h"
|
||||
#include "matrix4.h"
|
||||
#include "quaternion.h"
|
||||
#include "plane3d.h"
|
||||
#include "triangle3d.h"
|
||||
#include "line2d.h"
|
||||
#include "line3d.h"
|
||||
#include "irrString.h"
|
||||
#include "irrArray.h"
|
||||
#include "EAttributes.h"
|
||||
#include "path.h"
|
||||
|
||||
// not needed here but I can't be bothered to clean the transitive includes up.
|
||||
#include "quaternion.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
@ -55,16 +40,6 @@ public:
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
virtual E_ATTRIBUTE_TYPE getAttributeType(s32 index) const = 0;
|
||||
|
||||
//! Returns the type string of the attribute
|
||||
//! \param attributeName: String for the attribute type
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
virtual const wchar_t* getAttributeTypeString(const c8* attributeName, const wchar_t* defaultNotFound = L"unknown") const = 0;
|
||||
|
||||
//! Returns the type string of the attribute by index.
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
//! \param defaultNotFound Value returned for an invalid index
|
||||
virtual const wchar_t* getAttributeTypeString(s32 index, const wchar_t* defaultNotFound = L"unknown") const = 0;
|
||||
|
||||
//! Returns if an attribute with a name exists
|
||||
virtual bool existsAttribute(const c8* attributeName) const = 0;
|
||||
|
||||
|
@ -155,7 +155,7 @@ public:
|
||||
callback, baseMaterial, userData);
|
||||
}
|
||||
|
||||
//! Like IGPUProgrammingServices::addShaderMaterial(), but loads from files.
|
||||
//! 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.
|
||||
@ -279,7 +279,7 @@ public:
|
||||
callback, baseMaterial, userData);
|
||||
}
|
||||
|
||||
//! Like IGPUProgrammingServices::addShaderMaterial(), but loads from files.
|
||||
//! 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.
|
||||
@ -357,94 +357,14 @@ public:
|
||||
callback, baseMaterial, userData);
|
||||
}
|
||||
|
||||
//! Adds a new ASM shader material renderer to the VideoDriver
|
||||
/** Note that it is a good idea to call IVideoDriver::queryFeature() in
|
||||
advance to check if the IVideoDriver supports the vertex and/or pixel
|
||||
shader version your are using.
|
||||
|
||||
The material is added to the VideoDriver like with
|
||||
IVideoDriver::addMaterialRenderer() and can be used like it had been
|
||||
added with that method.
|
||||
\param vertexShaderProgram String containing the source of the vertex
|
||||
shader program. This can be 0 if no vertex program shall be used.
|
||||
|
||||
For DX8 programs, the will always input registers look like this: v0:
|
||||
position, v1: normal, v2: color, v3: texture coordinates, v4: texture
|
||||
coordinates 2 if available.
|
||||
|
||||
For DX9 programs, you can manually set the registers using the dcl_
|
||||
statements.
|
||||
\param pixelShaderProgram String containing the source of the pixel
|
||||
shader program. This can be 0 if you don't want to use a pixel shader.
|
||||
\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 Returns the number of the material type which can be set in
|
||||
SMaterial::MaterialType to use the renderer. -1 is returned if an
|
||||
error occurred. -1 is returned for example if a vertex or pixel shader
|
||||
program could not be compiled, the error strings are then printed out
|
||||
into the error log, and can be caught with a custom event receiver. */
|
||||
virtual s32 addShaderMaterial(const c8* vertexShaderProgram = 0,
|
||||
const c8* pixelShaderProgram = 0,
|
||||
IShaderConstantSetCallBack* callback = 0,
|
||||
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
|
||||
s32 userData = 0) = 0;
|
||||
|
||||
//! Like IGPUProgrammingServices::addShaderMaterial(), but loads from files.
|
||||
/** \param vertexShaderProgram Text file containing the source of the
|
||||
vertex shader program. Set to 0 if no shader shall be created.
|
||||
\param pixelShaderProgram Text file containing the source of the pixel
|
||||
shader program. Set to 0 if no shader shall be created.
|
||||
\param callback Pointer to an IShaderConstantSetCallback object to
|
||||
which the OnSetConstants function is called.
|
||||
\param baseMaterial baseMaterial
|
||||
\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 Returns the number of the material type which can be set in
|
||||
SMaterial::MaterialType to use the renderer. -1 is returned if an
|
||||
error occurred. -1 is returned for example if a vertex or pixel shader
|
||||
program could not be compiled, the error strings are then printed out
|
||||
into the error log, and can be caught with a custom event receiver. */
|
||||
virtual s32 addShaderMaterialFromFiles(io::IReadFile* vertexShaderProgram,
|
||||
io::IReadFile* pixelShaderProgram,
|
||||
IShaderConstantSetCallBack* callback = 0,
|
||||
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
|
||||
s32 userData = 0) = 0;
|
||||
|
||||
//! Like IGPUProgrammingServices::addShaderMaterial(), but loads from files.
|
||||
/** \param vertexShaderProgramFileName Text file name containing the
|
||||
source of the vertex shader program. Set to 0 if no shader shall be
|
||||
created.
|
||||
\param pixelShaderProgramFileName Text file name containing the source
|
||||
of the pixel shader program. Set to 0 if no shader shall be created.
|
||||
\param callback Pointer to an IShaderConstantSetCallback object on
|
||||
which the OnSetConstants function is called.
|
||||
\param baseMaterial baseMaterial
|
||||
\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 Returns the number of the material type which can be set in
|
||||
SMaterial::MaterialType to use the renderer. -1 is returned if an
|
||||
error occurred. -1 is returned for example if a vertex or pixel shader
|
||||
program could not be compiled, the error strings are then printed out
|
||||
into the error log, and can be caught with a custom event receiver. */
|
||||
virtual s32 addShaderMaterialFromFiles(const io::path& vertexShaderProgramFileName,
|
||||
const io::path& pixelShaderProgramFileName,
|
||||
IShaderConstantSetCallBack* callback = 0,
|
||||
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
|
||||
s32 userData = 0) = 0;
|
||||
//! 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;
|
||||
};
|
||||
|
||||
|
||||
|
@ -73,27 +73,6 @@ public:
|
||||
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;
|
||||
virtual void log(const c8* text, const wchar_t* hint, 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 wchar_t* text, const wchar_t* hint, ELOG_LEVEL ll=ELL_INFORMATION) = 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 wchar_t* text, ELOG_LEVEL ll=ELL_INFORMATION) = 0;
|
||||
};
|
||||
|
||||
} // end namespace
|
||||
|
@ -53,19 +53,8 @@ public:
|
||||
virtual bool setVertexShaderConstant(s32 index, const s32* ints, int count) = 0;
|
||||
|
||||
//! Uint interface for the above.
|
||||
/* NOTE: UINT only works with GLSL, not supported for other shaders.
|
||||
Also GLES drivers in Irrlicht do not support it as this needs at least GLES 3.0.
|
||||
*/
|
||||
virtual bool setVertexShaderConstant(s32 index, const u32* ints, int count) = 0;
|
||||
|
||||
//! Sets a vertex shader constant.
|
||||
/** Can be used if you created a shader using pixel/vertex shader
|
||||
assembler or ARB_fragment_program or ARB_vertex_program.
|
||||
\param data: Data to be set in the constants
|
||||
\param startRegister: First register to be set
|
||||
\param constantAmount: Amount of registers to be set. One register consists of 4 floats. */
|
||||
virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) = 0;
|
||||
|
||||
//! Return an index constant for the pixel shader for the given uniform variable name
|
||||
virtual s32 getPixelShaderConstantID(const c8* name) = 0;
|
||||
|
||||
@ -83,19 +72,8 @@ public:
|
||||
virtual bool setPixelShaderConstant(s32 index, const s32* ints, int count) = 0;
|
||||
|
||||
//! Uint interface for the above.
|
||||
/* NOTE: UINT only works with GLSL, not supported for other shaders.
|
||||
Also GLES drivers in Irrlicht do not support it as this needs at least GLES 3.0.
|
||||
*/
|
||||
virtual bool setPixelShaderConstant(s32 index, const u32* ints, int count) = 0;
|
||||
|
||||
//! Sets a pixel shader constant.
|
||||
/** Can be used if you created a shader using pixel/vertex shader
|
||||
assembler or ARB_fragment_program or ARB_vertex_program.
|
||||
\param data Data to be set in the constants
|
||||
\param startRegister First register to be set.
|
||||
\param constantAmount Amount of registers to be set. One register consists of 4 floats. */
|
||||
virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) = 0;
|
||||
|
||||
//! Get pointer to the IVideoDriver interface
|
||||
/** \return Pointer to the IVideoDriver interface */
|
||||
virtual IVideoDriver* getVideoDriver() = 0;
|
||||
|
@ -120,11 +120,6 @@ namespace scene
|
||||
\param numIndices Number of indices in array. */
|
||||
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) = 0;
|
||||
|
||||
//! Append the meshbuffer to the current buffer
|
||||
/** Only works for compatible vertex types
|
||||
\param other Buffer to append to this one. */
|
||||
virtual void append(const IMeshBuffer* const other) = 0;
|
||||
|
||||
//! get the current hardware mapping hint
|
||||
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const = 0;
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "aabbox3d.h"
|
||||
#include "matrix4.h"
|
||||
#include "IAttributes.h"
|
||||
|
||||
#include <list>
|
||||
#include <optional>
|
||||
|
||||
@ -117,23 +118,14 @@ namespace scene
|
||||
|
||||
//! Returns the name of the node.
|
||||
/** \return Name as character string. */
|
||||
virtual const c8* getName() const
|
||||
virtual const std::optional<std::string> &getName() const
|
||||
{
|
||||
return Name.c_str();
|
||||
return Name;
|
||||
}
|
||||
|
||||
|
||||
//! Sets the name of the node.
|
||||
/** \param name New name of the scene node. */
|
||||
virtual void setName(const c8* name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
|
||||
//! Sets the name of the node.
|
||||
/** \param name New name of the scene node. */
|
||||
virtual void setName(const core::stringc& name)
|
||||
virtual void setName(const std::optional<std::string> &name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
@ -601,7 +593,7 @@ namespace scene
|
||||
}
|
||||
|
||||
//! Name of the scene node.
|
||||
core::stringc Name;
|
||||
std::optional<std::string> Name;
|
||||
|
||||
//! Absolute transformation of the node.
|
||||
core::matrix4 AbsoluteTransformation;
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "IAnimatedMesh.h"
|
||||
#include "SSkinMeshBuffer.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
@ -41,12 +43,12 @@ namespace scene
|
||||
/** \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 c8* getJointName(u32 number) const = 0;
|
||||
virtual const std::optional<std::string> &getJointName(u32 number) const = 0;
|
||||
|
||||
//! Gets a joint number from its name
|
||||
/** \param name: Name of the joint.
|
||||
\return Number of the joint or -1 if not found. */
|
||||
virtual s32 getJointNumber(const c8* name) const = 0;
|
||||
\return Number of the joint or std::nullopt if not found. */
|
||||
virtual std::optional<u32> getJointNumber(const std::string &name) const = 0;
|
||||
|
||||
//! Use animation from another mesh
|
||||
/** The animation is linked (not copied) based on joint names
|
||||
@ -136,7 +138,7 @@ namespace scene
|
||||
}
|
||||
|
||||
//! The name of this joint
|
||||
core::stringc Name;
|
||||
std::optional<std::string> Name;
|
||||
|
||||
//! Local matrix of this joint
|
||||
core::matrix4 LocalMatrix;
|
||||
|
@ -869,7 +869,7 @@ namespace video
|
||||
//! 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 wchar_t* getName() const =0;
|
||||
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
|
||||
|
@ -5,8 +5,8 @@
|
||||
#pragma once
|
||||
|
||||
//! Identifies the IrrlichtMt fork customized for the Minetest engine
|
||||
#define IRRLICHT_VERSION_MT_REVISION 14
|
||||
#define IRRLICHT_VERSION_MT "mt14"
|
||||
#define IRRLICHT_VERSION_MT_REVISION 15
|
||||
#define IRRLICHT_VERSION_MT "mt15"
|
||||
|
||||
//! Irrlicht SDK Version
|
||||
#define IRRLICHT_VERSION_MAJOR 1
|
||||
|
@ -178,7 +178,10 @@ namespace irr
|
||||
virtual bool isFullscreen() const = 0;
|
||||
|
||||
//! Checks if the window could possibly be visible.
|
||||
//! Currently, this only returns false when the app is paused on Android.
|
||||
//! Currently, this only returns false when the activity is stopped on
|
||||
//! Android. Note that for Android activities, "stopped" means something
|
||||
//! different than you might expect (and also something different than
|
||||
//! "paused"). Read the Android lifecycle documentation.
|
||||
virtual bool isWindowVisible() const { return true; };
|
||||
|
||||
//! Get the current color format of the window
|
||||
|
@ -193,16 +193,9 @@ namespace video
|
||||
EAAM_SIMPLE=1,
|
||||
//! High-quality anti-aliasing, not always supported, automatically enables SIMPLE mode
|
||||
EAAM_QUALITY=3,
|
||||
//! Line smoothing
|
||||
//! Careful, enabling this can lead to software emulation under OpenGL
|
||||
EAAM_LINE_SMOOTH=4,
|
||||
//! point smoothing, often in software and slow, only with OpenGL
|
||||
EAAM_POINT_SMOOTH=8,
|
||||
//! All typical anti-alias and smooth modes
|
||||
EAAM_FULL_BASIC=15,
|
||||
//! Enhanced anti-aliasing for transparent materials
|
||||
/** Usually used with EMT_TRANSPARENT_ALPHA_CHANNEL_REF and multisampling. */
|
||||
EAAM_ALPHA_TO_COVERAGE=16
|
||||
EAAM_ALPHA_TO_COVERAGE=4
|
||||
};
|
||||
|
||||
//! These flags allow to define the interpretation of vertex color when lighting is enabled
|
||||
|
@ -330,9 +330,6 @@ struct SSkinMeshBuffer : public IMeshBuffer
|
||||
//! append the vertices and indices to the current buffer
|
||||
void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) override {}
|
||||
|
||||
//! append the meshbuffer to the current buffer
|
||||
void append(const IMeshBuffer* const other) override {}
|
||||
|
||||
//! get the current hardware mapping hint for vertex buffers
|
||||
E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const override
|
||||
{
|
||||
|
@ -5,9 +5,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "irrTypes.h"
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <float.h>
|
||||
#include <stdlib.h> // for abs() etc.
|
||||
#include <cstdlib> // for abs() etc.
|
||||
#include <limits.h> // For INT_MAX / UINT_MAX
|
||||
#include <type_traits>
|
||||
|
||||
@ -197,7 +197,7 @@ namespace core
|
||||
template <class T, std::enable_if_t<std::is_floating_point<T>::value, bool> = true>
|
||||
inline bool equals(const T a, const T b, const T tolerance = roundingError<T>())
|
||||
{
|
||||
return abs(a - b) <= tolerance;
|
||||
return std::abs(a - b) <= tolerance;
|
||||
}
|
||||
|
||||
//! returns if a equals b, taking relative error in form of factor
|
||||
|
@ -17,6 +17,9 @@ namespace io
|
||||
*/
|
||||
typedef core::string<fschar_t> 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.
|
||||
@ -62,11 +65,6 @@ struct SNamedPath
|
||||
{
|
||||
return core::stringc(getPath());
|
||||
}
|
||||
//! Implicit cast to io::path
|
||||
operator core::stringw() const
|
||||
{
|
||||
return core::stringw(getPath());
|
||||
}
|
||||
|
||||
protected:
|
||||
// convert the given path string to a name string.
|
||||
|
@ -1,75 +0,0 @@
|
||||
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 vec4 vSpecularColor;
|
||||
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;
|
||||
FinalColor += vSpecularColor;
|
||||
|
||||
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;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
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;
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
/* 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;
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
precision mediump float;
|
||||
|
||||
/* Varyings */
|
||||
varying vec4 vVertexColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vVertexColor;
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
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 vec4 vSpecularColor;
|
||||
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);
|
||||
Color += vSpecularColor;
|
||||
|
||||
if (bool(uFogEnable))
|
||||
{
|
||||
float FogFactor = computeFog();
|
||||
vec4 FogColor = uFogColor;
|
||||
FogColor.a = 1.0;
|
||||
Color = mix(FogColor, Color, FogFactor);
|
||||
}
|
||||
|
||||
gl_FragColor = Color;
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
/* 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 vec4 uGlobalAmbient;
|
||||
uniform vec4 uMaterialAmbient;
|
||||
uniform vec4 uMaterialDiffuse;
|
||||
uniform vec4 uMaterialEmissive;
|
||||
uniform vec4 uMaterialSpecular;
|
||||
uniform float uMaterialShininess;
|
||||
|
||||
uniform float uThickness;
|
||||
|
||||
/* Varyings */
|
||||
|
||||
varying vec2 vTextureCoord0;
|
||||
varying vec4 vVertexColor;
|
||||
varying vec4 vSpecularColor;
|
||||
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;
|
||||
vSpecularColor = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
vec3 Position = (uWVMatrix * vec4(inVertexPosition, 1.0)).xyz;
|
||||
|
||||
vFogCoord = length(Position);
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
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 vec4 vSpecularColor;
|
||||
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;
|
||||
}
|
||||
Color += vSpecularColor;
|
||||
|
||||
if (bool(uFogEnable))
|
||||
{
|
||||
float FogFactor = computeFog();
|
||||
vec4 FogColor = uFogColor;
|
||||
FogColor.a = 1.0;
|
||||
Color = mix(FogColor, Color, FogFactor);
|
||||
}
|
||||
|
||||
gl_FragColor = Color;
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
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 vec4 vSpecularColor;
|
||||
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;
|
||||
|
||||
Color += vSpecularColor;
|
||||
|
||||
if (bool(uFogEnable))
|
||||
{
|
||||
float FogFactor = computeFog();
|
||||
vec4 FogColor = uFogColor;
|
||||
FogColor.a = 1.0;
|
||||
Color = mix(FogColor, Color, FogFactor);
|
||||
}
|
||||
|
||||
gl_FragColor = Color;
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
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 vec4 vSpecularColor;
|
||||
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);
|
||||
Color += vSpecularColor;
|
||||
|
||||
if (bool(uFogEnable))
|
||||
{
|
||||
float FogFactor = computeFog();
|
||||
vec4 FogColor = uFogColor;
|
||||
FogColor.a = 1.0;
|
||||
Color = mix(FogColor, Color, FogFactor);
|
||||
}
|
||||
|
||||
gl_FragColor = Color;
|
||||
}
|
123
scripts/ci-build-android.sh
Executable file
123
scripts/ci-build-android.sh
Executable file
@ -0,0 +1,123 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
# NOTE: this code is mostly copied from minetest_android_deps
|
||||
# <https://github.com/minetest/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 <ABI>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
_setup_toolchain $1
|
||||
_run_build $1
|
@ -12,7 +12,7 @@ with_sdl=0
|
||||
libjpeg_version=3.0.1
|
||||
libpng_version=1.6.40
|
||||
sdl2_version=2.28.5
|
||||
zlib_version=1.3
|
||||
zlib_version=1.3.1
|
||||
|
||||
download () {
|
||||
local url=$1
|
||||
@ -25,13 +25,14 @@ download () {
|
||||
unzip -o "$filename" -d "$foldername"
|
||||
}
|
||||
|
||||
libs=$PWD/libs
|
||||
mkdir -p libs
|
||||
pushd libs
|
||||
libs=$PWD
|
||||
download "http://minetest.kitsunemimi.pw/libjpeg-$libjpeg_version-$variant.zip"
|
||||
download "http://minetest.kitsunemimi.pw/libpng-$libpng_version-$variant.zip"
|
||||
[ $with_sdl -eq 1 ] && download "http://minetest.kitsunemimi.pw/sdl2-$sdl2_version-$variant.zip"
|
||||
download "http://minetest.kitsunemimi.pw/zlib-$zlib_version-$variant.zip"
|
||||
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=(
|
||||
|
@ -1,12 +1,9 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
topdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
[ -z "$1" ] && exit 255
|
||||
|
||||
ver=13.2.0
|
||||
os=ubuntu22.04
|
||||
name="mingw-w64-${1}_${ver}_${os}.tar.xz"
|
||||
wget "http://minetest.kitsunemimi.pw/$name" -O "$name"
|
||||
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
|
||||
sudo tar -xaf "$name" -C /usr --strip-components=1
|
||||
rm -f "$name"
|
||||
|
@ -1,10 +1,9 @@
|
||||
a7dc54d5fb9f841eae26ee17f6146c0b7a0e5d99a914866a394b723dffc83316 libjpeg-3.0.1-win32.zip
|
||||
cd1f667ed2d24d96e1d61fcf91ba6d7b11270a4903e36f08e640971884caaccd libjpeg-3.0.1-win64.zip
|
||||
72a624fbaef15909f80976c9c569717e9438bd34c3209071378f05487e859f8a libpng-1.6.40-win32.zip
|
||||
8e2552f6965c385f7e2467018d583fd206744db18e36656ddf1c07c8663ea23f libpng-1.6.40-win64.zip
|
||||
9f0cfab8ca089d48be7a59f85d5fd5648f18f54c91d7ac6c31b281ba5e90852a mingw-w64-i686_13.2.0_ubuntu22.04.tar.xz
|
||||
93bc9f04d43a023358d1ae2b76dec42d3d79baecd452402ee9fb3ee21945fdfe mingw-w64-x86_64_13.2.0_ubuntu22.04.tar.xz
|
||||
2abdc82b4cac710bab0b3e9f9a9c38cc242abcca443c1e1f7af51d29a5eb5457 sdl2-2.28.5-win32.zip
|
||||
949a3de77d1c97240ee4b35e15495962b5effb816f7f03efe5c6edd8975a8b19 sdl2-2.28.5-win64.zip
|
||||
3c5abd40e9492c834651d995db6bbf0f57a7579d091d2d03110293b95e9b039a zlib-1.3-win32.zip
|
||||
f63d9a38c2ee56fa1e95a486224c274412cb5b3275734c1da53b0a68a7e8c654 zlib-1.3-win64.zip
|
||||
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
|
||||
|
@ -31,7 +31,8 @@ namespace irr
|
||||
{
|
||||
|
||||
CIrrDeviceAndroid::CIrrDeviceAndroid(const SIrrlichtCreationParameters& param)
|
||||
: CIrrDeviceStub(param), Accelerometer(0), Gyroscope(0), Focused(false), Initialized(false), Paused(true), JNIEnvAttachedToVM(0)
|
||||
: CIrrDeviceStub(param), Accelerometer(0), Gyroscope(0), Initialized(false),
|
||||
Stopped(true), Paused(true), Focused(false), JNIEnvAttachedToVM(0)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CIrrDeviceAndroid");
|
||||
@ -64,7 +65,7 @@ CIrrDeviceAndroid::CIrrDeviceAndroid(const SIrrlichtCreationParameters& param)
|
||||
s32 Events = 0;
|
||||
android_poll_source* Source = 0;
|
||||
|
||||
while ((ALooper_pollAll(((Focused && !Paused) || !Initialized) ? 0 : -1, 0, &Events, (void**)&Source)) >= 0)
|
||||
while ((ALooper_pollAll((!Initialized || isWindowActive()) ? 0 : -1, 0, &Events, (void**)&Source)) >= 0)
|
||||
{
|
||||
if(Source)
|
||||
Source->process(Android, Source);
|
||||
@ -180,7 +181,7 @@ void CIrrDeviceAndroid::setWindowCaption(const wchar_t* text)
|
||||
|
||||
bool CIrrDeviceAndroid::isWindowActive() const
|
||||
{
|
||||
return (Focused && !Paused);
|
||||
return (Focused && !Paused && !Stopped);
|
||||
}
|
||||
|
||||
bool CIrrDeviceAndroid::isWindowFocused() const
|
||||
@ -195,7 +196,7 @@ bool CIrrDeviceAndroid::isWindowMinimized() const
|
||||
|
||||
bool CIrrDeviceAndroid::isWindowVisible() const
|
||||
{
|
||||
return !Paused;
|
||||
return !Stopped;
|
||||
}
|
||||
|
||||
void CIrrDeviceAndroid::closeDevice()
|
||||
@ -265,6 +266,7 @@ void CIrrDeviceAndroid::handleAndroidCommand(android_app* app, int32_t cmd)
|
||||
break;
|
||||
case APP_CMD_START:
|
||||
os::Printer::log("Android command APP_CMD_START", ELL_DEBUG);
|
||||
device->Stopped = false;
|
||||
break;
|
||||
case APP_CMD_INIT_WINDOW:
|
||||
os::Printer::log("Android command APP_CMD_INIT_WINDOW", ELL_DEBUG);
|
||||
@ -322,6 +324,7 @@ void CIrrDeviceAndroid::handleAndroidCommand(android_app* app, int32_t cmd)
|
||||
break;
|
||||
case APP_CMD_STOP:
|
||||
os::Printer::log("Android command APP_CMD_STOP", ELL_DEBUG);
|
||||
device->Stopped = true;
|
||||
break;
|
||||
case APP_CMD_RESUME:
|
||||
os::Printer::log("Android command APP_CMD_RESUME", ELL_DEBUG);
|
||||
|
@ -86,9 +86,10 @@ namespace irr
|
||||
const ASensor* Accelerometer;
|
||||
const ASensor* Gyroscope;
|
||||
|
||||
bool Focused;
|
||||
bool Initialized;
|
||||
bool Stopped;
|
||||
bool Paused;
|
||||
bool Focused;
|
||||
|
||||
JNIEnv* JNIEnvAttachedToVM;
|
||||
|
||||
|
@ -471,21 +471,21 @@ IBoneSceneNode* CAnimatedMeshSceneNode::getJointNode(const c8* jointName)
|
||||
|
||||
ISkinnedMesh *skinnedMesh=(ISkinnedMesh*)Mesh;
|
||||
|
||||
const s32 number = skinnedMesh->getJointNumber(jointName);
|
||||
const std::optional<u32> number = skinnedMesh->getJointNumber(jointName);
|
||||
|
||||
if (number == -1)
|
||||
if (!number.has_value())
|
||||
{
|
||||
os::Printer::log("Joint with specified name not found in skinned mesh", jointName, ELL_DEBUG);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((s32)JointChildSceneNodes.size() <= number)
|
||||
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];
|
||||
return JointChildSceneNodes[*number];
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,11 +62,6 @@ public:
|
||||
return EAT_BOOL;
|
||||
}
|
||||
|
||||
const wchar_t* getTypeString() const override
|
||||
{
|
||||
return L"bool";
|
||||
}
|
||||
|
||||
bool BoolValue;
|
||||
};
|
||||
|
||||
@ -106,11 +101,6 @@ public:
|
||||
return EAT_INT;
|
||||
}
|
||||
|
||||
const wchar_t* getTypeString() const override
|
||||
{
|
||||
return L"int";
|
||||
}
|
||||
|
||||
s32 Value;
|
||||
};
|
||||
|
||||
@ -150,11 +140,6 @@ public:
|
||||
return EAT_FLOAT;
|
||||
}
|
||||
|
||||
const wchar_t* getTypeString() const override
|
||||
{
|
||||
return L"float";
|
||||
}
|
||||
|
||||
f32 Value;
|
||||
};
|
||||
|
||||
|
@ -172,26 +172,6 @@ E_ATTRIBUTE_TYPE CAttributes::getAttributeType(s32 index) const
|
||||
return Attributes[index]->getType();
|
||||
}
|
||||
|
||||
//! Returns the type of an attribute
|
||||
const wchar_t* CAttributes::getAttributeTypeString(const c8* attributeName, const wchar_t* defaultNotFound) const
|
||||
{
|
||||
const IAttribute* att = getAttributeP(attributeName);
|
||||
if (att)
|
||||
return att->getTypeString();
|
||||
else
|
||||
return defaultNotFound;
|
||||
}
|
||||
|
||||
//! Returns attribute type string by index.
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
const wchar_t* CAttributes::getAttributeTypeString(s32 index, const wchar_t* defaultNotFound) const
|
||||
{
|
||||
if ((u32)index >= Attributes.size())
|
||||
return defaultNotFound;
|
||||
|
||||
return Attributes[index]->getTypeString();
|
||||
}
|
||||
|
||||
//! Gets an attribute as integer value
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
s32 CAttributes::getAttributeAsInt(s32 index) const
|
||||
|
@ -41,15 +41,6 @@ public:
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
E_ATTRIBUTE_TYPE getAttributeType(s32 index) const override;
|
||||
|
||||
//! Returns the type string of the attribute
|
||||
//! \param attributeName: String for the attribute type
|
||||
//! \param defaultNotFound Value returned when attributeName was not found
|
||||
const wchar_t* getAttributeTypeString(const c8* attributeName, const wchar_t* defaultNotFound = L"unknown") const override;
|
||||
|
||||
//! Returns the type string of the attribute by index.
|
||||
//! \param index: Index value, must be between 0 and getAttributeCount()-1.
|
||||
const wchar_t* getAttributeTypeString(s32 index, const wchar_t* defaultNotFound = L"unknown") const override;
|
||||
|
||||
//! Returns if an attribute with a name exists
|
||||
bool existsAttribute(const c8* attributeName) const override;
|
||||
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include "IFileSystem.h"
|
||||
#include "os.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define _B3D_READER_DEBUG
|
||||
#endif
|
||||
@ -149,14 +151,14 @@ bool CB3DMeshFileLoader::load()
|
||||
bool CB3DMeshFileLoader::readChunkNODE(CSkinnedMesh::SJoint *inJoint)
|
||||
{
|
||||
CSkinnedMesh::SJoint *joint = AnimatedMesh->addJoint(inJoint);
|
||||
readString(joint->Name);
|
||||
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.c_str(), ELL_DEBUG);
|
||||
os::Printer::log(logStr.c_str(), joint->Name.value_or("").c_str(), ELL_DEBUG);
|
||||
#endif
|
||||
|
||||
f32 position[3], scale[3], rotation[4];
|
||||
@ -818,8 +820,8 @@ bool CB3DMeshFileLoader::readChunkTEXS()
|
||||
Textures.push_back(SB3dTexture());
|
||||
SB3dTexture& B3dTexture = Textures.getLast();
|
||||
|
||||
readString(B3dTexture.TextureName);
|
||||
B3dTexture.TextureName.replace('\\','/');
|
||||
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
|
||||
@ -872,10 +874,9 @@ bool CB3DMeshFileLoader::readChunkBRUS()
|
||||
{
|
||||
// This is what blitz basic calls a brush, like a Irrlicht Material
|
||||
|
||||
core::stringc name;
|
||||
readString(name);
|
||||
auto name = readString();
|
||||
#ifdef _B3D_READER_DEBUG
|
||||
os::Printer::log("read Material", name, ELL_DEBUG);
|
||||
os::Printer::log("read Material", name.c_str(), ELL_DEBUG);
|
||||
#endif
|
||||
Materials.push_back(SB3dMaterial());
|
||||
SB3dMaterial& B3dMaterial=Materials.getLast();
|
||||
@ -1031,18 +1032,19 @@ bool CB3DMeshFileLoader::readChunkBRUS()
|
||||
}
|
||||
|
||||
|
||||
void CB3DMeshFileLoader::readString(core::stringc& newstring)
|
||||
std::string CB3DMeshFileLoader::readString()
|
||||
{
|
||||
newstring="";
|
||||
std::string newstring = "";
|
||||
while (true)
|
||||
{
|
||||
c8 character;
|
||||
if (B3DFile->read(&character, sizeof(character)) == 0)
|
||||
return; // eof
|
||||
break; // eof
|
||||
if (character==0)
|
||||
return;
|
||||
newstring.append(character);
|
||||
break;
|
||||
newstring.push_back(character);
|
||||
}
|
||||
return newstring;
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,7 +52,7 @@ private:
|
||||
bool readChunkTEXS();
|
||||
bool readChunkBRUS();
|
||||
|
||||
void readString(core::stringc& newstring);
|
||||
std::string readString();
|
||||
void readFloats(f32* vec, u32 count);
|
||||
|
||||
core::array<SB3dChunk> B3dStack;
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "CBoneSceneNode.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
@ -11,7 +13,7 @@ namespace scene
|
||||
|
||||
//! constructor
|
||||
CBoneSceneNode::CBoneSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
|
||||
u32 boneIndex, const c8* boneName)
|
||||
u32 boneIndex, const std::optional<std::string> &boneName)
|
||||
: IBoneSceneNode(parent, mgr, id), BoneIndex(boneIndex),
|
||||
AnimationMode(EBAM_AUTOMATIC), SkinningSpace(EBSS_LOCAL)
|
||||
{
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
#include "IBoneSceneNode.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
@ -19,7 +21,8 @@ namespace scene
|
||||
|
||||
//! constructor
|
||||
CBoneSceneNode(ISceneNode* parent, ISceneManager* mgr,
|
||||
s32 id=-1, u32 boneIndex=0, const c8* boneName=0);
|
||||
s32 id=-1, u32 boneIndex=0,
|
||||
const std::optional<std::string> &boneName = std::nullopt);
|
||||
|
||||
//! Returns the index of the bone
|
||||
u32 getBoneIndex() const override;
|
||||
|
@ -745,15 +745,10 @@ IFileList* CFileSystem::createFileList()
|
||||
|
||||
r = new CFileList(Path, true, false);
|
||||
|
||||
// TODO: Should be unified once mingw adapts the proper types
|
||||
#if defined(__GNUC__)
|
||||
long hFile; //mingw return type declaration
|
||||
#else
|
||||
// intptr_t is optional but supported by MinGW since 2007 or earlier.
|
||||
intptr_t hFile;
|
||||
#endif
|
||||
|
||||
struct _tfinddata_t c_file;
|
||||
if( (hFile = _tfindfirst( _T("*"), &c_file )) != -1L )
|
||||
if( (hFile = _tfindfirst( _T("*"), &c_file )) != (intptr_t)(-1L) )
|
||||
{
|
||||
do
|
||||
{
|
||||
|
@ -8,19 +8,12 @@
|
||||
|
||||
#include "os.h"
|
||||
|
||||
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
#define GL_GLEXT_LEGACY 1
|
||||
#define GLX_GLXEXT_LEGACY 1
|
||||
#else
|
||||
#define GL_GLEXT_PROTOTYPES 1
|
||||
#define GLX_GLXEXT_PROTOTYPES 1
|
||||
#endif
|
||||
#define GL_GLEXT_LEGACY 1
|
||||
#define GLX_GLXEXT_LEGACY 1
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glx.h>
|
||||
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
#include <GL/glext.h>
|
||||
#include <GL/glxext.h>
|
||||
#endif
|
||||
|
||||
namespace irr
|
||||
{
|
||||
@ -45,11 +38,7 @@ CGLXManager::CGLXManager(const SIrrlichtCreationParameters& params, const SExpos
|
||||
#if defined(GLX_VERSION_1_3)
|
||||
typedef GLXFBConfig * ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);
|
||||
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
PFNGLXCHOOSEFBCONFIGPROC glxChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)glXGetProcAddress(reinterpret_cast<const GLubyte*>("glXChooseFBConfig"));
|
||||
#else
|
||||
PFNGLXCHOOSEFBCONFIGPROC glxChooseFBConfig=glXChooseFBConfig;
|
||||
#endif
|
||||
if (major==1 && minor>2 && glxChooseFBConfig)
|
||||
{
|
||||
os::Printer::log("GLX >= 1.3", ELL_DEBUG);
|
||||
@ -196,14 +185,10 @@ os::Printer::log("GLX >= 1.3", ELL_DEBUG);
|
||||
{
|
||||
glxFBConfig=configList[0];
|
||||
XFree(configList);
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config);
|
||||
PFNGLXGETVISUALFROMFBCONFIGPROC glxGetVisualFromFBConfig= (PFNGLXGETVISUALFROMFBCONFIGPROC)glXGetProcAddress(reinterpret_cast<const GLubyte*>("glXGetVisualFromFBConfig"));
|
||||
if (glxGetVisualFromFBConfig)
|
||||
VisualInfo = glxGetVisualFromFBConfig(display,(GLXFBConfig)glxFBConfig);
|
||||
#else
|
||||
VisualInfo = glXGetVisualFromFBConfig(display,(GLXFBConfig)glxFBConfig);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -328,11 +313,7 @@ bool CGLXManager::generateContext()
|
||||
{
|
||||
#if defined(GLX_ARB_create_context)
|
||||
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
PFNGLXCREATECONTEXTATTRIBSARBPROC glxCreateContextAttribsARB=(PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress(reinterpret_cast<const GLubyte*>("glXCreateContextAttribsARB"));
|
||||
#else
|
||||
PFNGLXCREATECONTEXTATTRIBSARBPROC glxCreateContextAttribsARB=glXCreateContextAttribsARB;
|
||||
#endif
|
||||
|
||||
if (glxCreateContextAttribsARB)
|
||||
{
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "CImage.h"
|
||||
#include "irrString.h"
|
||||
|
||||
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
|
||||
|
||||
namespace irr
|
||||
{
|
||||
@ -138,7 +139,8 @@ IImage* CImageLoaderTGA::loadImage(io::IReadFile* file) const
|
||||
if (header.ColorMapType)
|
||||
{
|
||||
// Create 32 bit palette
|
||||
const irr::u16 paletteSize = core::max_((u16)256, header.ColorMapLength); // ColorMapLength can lie, but so far we only use palette for 8-bit, so ensure it has 256 entries
|
||||
// `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 )
|
||||
|
@ -193,7 +193,18 @@ bool CIrrDeviceSDL::keyIsKnownSpecial(EKEY_CODE key)
|
||||
}
|
||||
}
|
||||
|
||||
int CIrrDeviceSDL::findCharToPassToIrrlicht(int assumedChar, EKEY_CODE key) {
|
||||
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))
|
||||
@ -218,9 +229,28 @@ int CIrrDeviceSDL::findCharToPassToIrrlicht(int assumedChar, EKEY_CODE key) {
|
||||
void CIrrDeviceSDL::resetReceiveTextInputEvents() {
|
||||
gui::IGUIElement *elem = GUIEnvironment->getFocus();
|
||||
if (elem && elem->acceptsIME())
|
||||
SDL_StartTextInput();
|
||||
{
|
||||
// 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<s32> 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
|
||||
@ -704,18 +734,13 @@ bool CIrrDeviceSDL::run()
|
||||
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;
|
||||
|
||||
#ifdef _IRR_WINDOWS_API_
|
||||
// handle alt+f4 in Windows, because SDL seems not to
|
||||
if ( (SDL_event.key.keysym.mod & KMOD_LALT) && key == KEY_F4)
|
||||
{
|
||||
Close = true;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
irrevent.EventType = irr::EET_KEY_INPUT_EVENT;
|
||||
irrevent.KeyInput.Key = key;
|
||||
irrevent.KeyInput.PressedDown = (SDL_event.type == SDL_KEYDOWN);
|
||||
@ -1250,7 +1275,7 @@ void CIrrDeviceSDL::createKeyMap()
|
||||
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_, KEY_SEPARATOR));
|
||||
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));
|
||||
|
@ -17,6 +17,10 @@
|
||||
#endif
|
||||
|
||||
#include <SDL.h>
|
||||
// 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 <SDL_syswm.h>
|
||||
|
||||
#include <memory>
|
||||
@ -256,7 +260,7 @@ namespace irr
|
||||
}
|
||||
};
|
||||
std::vector<std::unique_ptr<SDL_Cursor, CursorDeleter>> Cursors;
|
||||
gui::ECURSOR_ICON ActiveIcon;
|
||||
gui::ECURSOR_ICON ActiveIcon = gui::ECURSOR_ICON::ECI_NORMAL;
|
||||
};
|
||||
|
||||
private:
|
||||
@ -299,6 +303,8 @@ namespace irr
|
||||
|
||||
bool Resizable;
|
||||
|
||||
core::rect<s32> lastElemPos;
|
||||
|
||||
struct SKeyMap
|
||||
{
|
||||
SKeyMap() {}
|
||||
|
@ -59,38 +59,6 @@ namespace irr
|
||||
log (s.c_str(), ll);
|
||||
}
|
||||
|
||||
//! Prints out a text into the log
|
||||
void CLogger::log(const wchar_t* text, ELOG_LEVEL ll)
|
||||
{
|
||||
if (ll < LogLevel)
|
||||
return;
|
||||
|
||||
core::stringc s = text;
|
||||
log(s.c_str(), ll);
|
||||
}
|
||||
|
||||
|
||||
//! Prints out a text into the log
|
||||
void CLogger::log(const wchar_t* text, const wchar_t* hint, ELOG_LEVEL ll)
|
||||
{
|
||||
if (ll < LogLevel)
|
||||
return;
|
||||
|
||||
core::stringc s1 = text;
|
||||
core::stringc s2 = hint;
|
||||
log(s1.c_str(), s2.c_str(), ll);
|
||||
}
|
||||
|
||||
//! Prints out a text into the log
|
||||
void CLogger::log(const c8* text, const wchar_t* hint, ELOG_LEVEL ll)
|
||||
{
|
||||
if (ll < LogLevel)
|
||||
return;
|
||||
|
||||
core::stringc s2 = hint;
|
||||
log( text, s2.c_str(), ll);
|
||||
}
|
||||
|
||||
//! Sets a new event receiver
|
||||
void CLogger::setReceiver(IEventReceiver* r)
|
||||
{
|
||||
|
@ -28,18 +28,9 @@ public:
|
||||
//! 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 wchar_t* 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;
|
||||
|
||||
//! Prints out a text into the log
|
||||
void log(const c8* text, const wchar_t* hint, ELOG_LEVEL ll=ELL_INFORMATION) override;
|
||||
|
||||
//! Prints out a text into the log
|
||||
void log(const wchar_t* text, const wchar_t* hint, ELOG_LEVEL ll=ELL_INFORMATION) override;
|
||||
|
||||
//! Sets a new event receiver
|
||||
void setReceiver(IEventReceiver* r);
|
||||
|
||||
|
@ -176,7 +176,8 @@ else()
|
||||
set(DEFAULT_WEBGL1 TRUE)
|
||||
endif()
|
||||
option(ENABLE_GLES2 "Enable OpenGL ES 2+" ${DEFAULT_GLES2})
|
||||
option(ENABLE_WEBGL1 "Enable WebGL (requires GLES2)" ${DEFAULT_WEBGL1})
|
||||
#option(ENABLE_WEBGL1 "Enable WebGL (requires GLES2)" ${DEFAULT_WEBGL1})
|
||||
set(ENABLE_WEBGL1 FALSE) # not working currently
|
||||
if(ENABLE_WEBGL1)
|
||||
set(ENABLE_GLES2 TRUE)
|
||||
endif()
|
||||
@ -184,15 +185,13 @@ endif()
|
||||
|
||||
if(ENABLE_OPENGL)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_OPENGL_)
|
||||
set(OPENGL_DIRECT_LINK TRUE) # not yet possible to remove this
|
||||
set(OPENGL_DIRECT_LINK TRUE) # driver relies on this
|
||||
if(DEVICE STREQUAL "WINDOWS")
|
||||
add_definitions(-D_IRR_COMPILE_WITH_WGL_MANAGER_ -D_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_WGL_MANAGER_)
|
||||
elseif(DEVICE STREQUAL "X11")
|
||||
add_definitions(-D_IRR_COMPILE_WITH_GLX_MANAGER_ -D_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_GLX_MANAGER_)
|
||||
elseif(DEVICE STREQUAL "OSX")
|
||||
add_definitions(-D_IRR_COMPILE_WITH_NSOGL_MANAGER_)
|
||||
elseif(DEVICE STREQUAL "SDL")
|
||||
add_definitions(-D_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -200,9 +199,6 @@ if(ENABLE_OPENGL3)
|
||||
if (NOT USE_SDL2)
|
||||
message(FATAL_ERROR "OpenGL 3 driver requires SDL2")
|
||||
endif()
|
||||
set(OPENGL_DIRECT_LINK TRUE) # TODO
|
||||
set(USE_SDLGL ON)
|
||||
set(USE_SDLGL3 ON)
|
||||
endif()
|
||||
|
||||
if(ENABLE_GLES1)
|
||||
@ -212,19 +208,14 @@ if(ENABLE_GLES1)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_OGLES1_)
|
||||
set(OPENGLES_DIRECT_LINK TRUE)
|
||||
if(DEVICE MATCHES "^(WINDOWS|X11|ANDROID)$")
|
||||
add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_ -D_IRR_OGLES1_USE_EXTPOINTER_)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_GLES2)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_OGLES2_)
|
||||
set(OPENGLES2_DIRECT_LINK TRUE) # not yet possible to remove this
|
||||
if(DEVICE MATCHES "^(WINDOWS|X11|ANDROID)$" OR EMSCRIPTEN)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_ -D_IRR_OGLES2_USE_EXTPOINTER_)
|
||||
elseif(DEVICE STREQUAL "SDL")
|
||||
add_definitions(-D_IRR_OGLES2_USE_EXTPOINTER_)
|
||||
set(USE_SDLGL ON)
|
||||
set(USE_SDLGLES2 ON)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_EGL_MANAGER_)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -246,14 +237,12 @@ message(STATUS "Device: ${DEVICE}")
|
||||
message(STATUS "OpenGL: ${ENABLE_OPENGL}")
|
||||
message(STATUS "OpenGL 3: ${ENABLE_OPENGL3}")
|
||||
message(STATUS "OpenGL ES: ${ENABLE_GLES1}")
|
||||
if (USE_SDLGLES2)
|
||||
if (ENABLE_GLES2)
|
||||
message(STATUS "OpenGL ES 2: ON (unified)")
|
||||
elseif (ENABLE_GLES2)
|
||||
message(STATUS "OpenGL ES 2: ON (legacy)")
|
||||
else()
|
||||
message(STATUS "OpenGL ES 2: OFF")
|
||||
endif()
|
||||
message(STATUS "WebGL: ${ENABLE_WEBGL1}")
|
||||
#message(STATUS "WebGL: ${ENABLE_WEBGL1}")
|
||||
|
||||
# Required libs
|
||||
|
||||
@ -276,10 +265,28 @@ if(ENABLE_OPENGL OR ENABLE_OPENGL3)
|
||||
find_package(OpenGL REQUIRED)
|
||||
endif()
|
||||
if(USE_SDL2)
|
||||
find_package(SDL2 CONFIG REQUIRED)
|
||||
find_package(SDL2 2.0.10 CONFIG REQUIRED)
|
||||
message(STATUS "Found SDL2: ${SDL2_LIBRARIES}")
|
||||
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 <SDL_opengl.h>\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)
|
||||
@ -314,26 +321,6 @@ set(link_includes
|
||||
"$<$<BOOL:${USE_X11}>:${X11_INCLUDE_DIR}>"
|
||||
)
|
||||
|
||||
set(link_libs
|
||||
"${ZLIB_LIBRARY}"
|
||||
"${JPEG_LIBRARY}"
|
||||
"${PNG_LIBRARY}"
|
||||
"$<$<BOOL:${USE_SDL2}>:${SDL2_LIBRARIES}>"
|
||||
|
||||
"$<$<BOOL:${OPENGL_DIRECT_LINK}>:${OPENGL_LIBRARIES}>"
|
||||
"$<$<BOOL:${OPENGLES_DIRECT_LINK}>:${OPENGLES_LIBRARIES}>"
|
||||
"$<$<BOOL:${OPENGLES2_DIRECT_LINK}>:${OPENGLES2_LIBRARIES}>"
|
||||
${EGL_LIBRARY}
|
||||
|
||||
"$<$<PLATFORM_ID:Android>:-landroid -llog>"
|
||||
${COCOA_LIB}
|
||||
${IOKIT_LIB}
|
||||
"$<$<PLATFORM_ID:Windows>:gdi32>"
|
||||
"$<$<PLATFORM_ID:Windows>:winmm>"
|
||||
"$<$<BOOL:${USE_X11}>:${X11_X11_LIB}>"
|
||||
"$<$<BOOL:${USE_X11}>:${X11_Xi_LIB}>"
|
||||
)
|
||||
|
||||
# Source files
|
||||
|
||||
set(IRRMESHLOADER
|
||||
@ -370,12 +357,13 @@ set(IRRDRVROBJ
|
||||
mt_opengl_loader.cpp
|
||||
)
|
||||
|
||||
# the two legacy drivers
|
||||
|
||||
if(ENABLE_OPENGL)
|
||||
set(IRRDRVROBJ
|
||||
${IRRDRVROBJ}
|
||||
COpenGLCacheHandler.cpp
|
||||
COpenGLDriver.cpp
|
||||
COpenGLShaderMaterialRenderer.cpp
|
||||
COpenGLSLMaterialRenderer.cpp
|
||||
COpenGLExtensionHandler.cpp
|
||||
)
|
||||
@ -389,6 +377,33 @@ if(ENABLE_GLES1)
|
||||
)
|
||||
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
|
||||
@ -406,37 +421,6 @@ add_library(IRRVIDEOOBJ OBJECT
|
||||
${IRRIMAGEOBJ}
|
||||
)
|
||||
|
||||
if(USE_SDLGL)
|
||||
target_sources(IRRVIDEOOBJ PRIVATE
|
||||
OpenGL/Driver.cpp
|
||||
OpenGL/ExtensionHandler.cpp
|
||||
OpenGL/FixedPipelineRenderer.cpp
|
||||
OpenGL/MaterialRenderer.cpp
|
||||
OpenGL/Renderer2D.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(USE_SDLGL3)
|
||||
target_sources(IRRVIDEOOBJ PRIVATE
|
||||
OpenGL3/Driver.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(USE_SDLGLES2)
|
||||
target_sources(IRRVIDEOOBJ PRIVATE
|
||||
OpenGLES2/Driver.cpp
|
||||
)
|
||||
elseif(ENABLE_GLES2)
|
||||
target_sources(IRRVIDEOOBJ PRIVATE
|
||||
COGLES2Driver.cpp
|
||||
COGLES2ExtensionHandler.cpp
|
||||
COGLES2FixedPipelineRenderer.cpp
|
||||
COGLES2MaterialRenderer.cpp
|
||||
COGLES2Renderer2D.cpp
|
||||
CWebGL1Driver.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(IRRIOOBJ OBJECT
|
||||
CFileList.cpp
|
||||
CFileSystem.cpp
|
||||
@ -533,7 +517,26 @@ target_include_directories(IrrlichtMt
|
||||
${link_includes}
|
||||
)
|
||||
|
||||
target_link_libraries(IrrlichtMt PRIVATE ${link_libs})
|
||||
# this needs to be here and not in a variable (like link_includes) due to issues
|
||||
# with the generator expressions on at least CMake 3.22, but not 3.28 or later
|
||||
target_link_libraries(IrrlichtMt PRIVATE
|
||||
${ZLIB_LIBRARY}
|
||||
${JPEG_LIBRARY}
|
||||
${PNG_LIBRARY}
|
||||
"$<$<BOOL:${USE_SDL2}>:SDL2::SDL2>"
|
||||
|
||||
"$<$<BOOL:${OPENGL_DIRECT_LINK}>:${OPENGL_LIBRARIES}>"
|
||||
"$<$<BOOL:${OPENGLES_DIRECT_LINK}>:${OPENGLES_LIBRARY}>"
|
||||
${EGL_LIBRARY}
|
||||
|
||||
"$<$<PLATFORM_ID:Android>:-landroid -llog>"
|
||||
${COCOA_LIB}
|
||||
${IOKIT_LIB}
|
||||
"$<$<PLATFORM_ID:Windows>:gdi32>"
|
||||
"$<$<PLATFORM_ID:Windows>:winmm>"
|
||||
"$<$<BOOL:${USE_X11}>:${X11_X11_LIB}>"
|
||||
"$<$<BOOL:${USE_X11}>:${X11_Xi_LIB}>"
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
target_compile_definitions(IrrlichtMt INTERFACE _IRR_WINDOWS_API_) # used in _IRR_DEBUG_BREAK_IF definition in a public header
|
||||
|
@ -41,6 +41,14 @@ 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<u32>& screenSize)
|
||||
@ -839,9 +847,9 @@ const SColorf& CNullDriver::getAmbientLight() const
|
||||
//! \return Returns the name of the video driver. Example: In case of the DIRECT3D8
|
||||
//! driver, it would return "Direct3D8".
|
||||
|
||||
const wchar_t* CNullDriver::getName() const
|
||||
const char* CNullDriver::getName() const
|
||||
{
|
||||
return L"Irrlicht NullDevice";
|
||||
return "Irrlicht NullDevice";
|
||||
}
|
||||
|
||||
|
||||
@ -1525,7 +1533,7 @@ s32 CNullDriver::addMaterialRenderer(IMaterialRenderer* renderer, const char* na
|
||||
r.Renderer = renderer;
|
||||
r.Name = name;
|
||||
|
||||
if (name == 0 && (MaterialRenderers.size() < (sizeof(sBuiltInMaterialTypeNames) / sizeof(char*))-1 ))
|
||||
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.
|
||||
@ -1542,8 +1550,7 @@ s32 CNullDriver::addMaterialRenderer(IMaterialRenderer* renderer, const char* na
|
||||
//! Sets the name of a material renderer.
|
||||
void CNullDriver::setMaterialRendererName(u32 idx, const char* name)
|
||||
{
|
||||
if (idx < (sizeof(sBuiltInMaterialTypeNames) / sizeof(char*))-1 ||
|
||||
idx >= MaterialRenderers.size())
|
||||
if (idx < numBuiltInMaterials || idx >= MaterialRenderers.size())
|
||||
return;
|
||||
|
||||
MaterialRenderers[idx].Name = name;
|
||||
@ -1642,8 +1649,6 @@ s32 CNullDriver::addHighLevelShaderMaterial(
|
||||
}
|
||||
|
||||
|
||||
//! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description),
|
||||
//! but tries to load the programs from files.
|
||||
s32 CNullDriver::addHighLevelShaderMaterialFromFiles(
|
||||
const io::path& vertexShaderProgramFileName,
|
||||
const c8* vertexShaderEntryPointName,
|
||||
@ -1714,8 +1719,6 @@ s32 CNullDriver::addHighLevelShaderMaterialFromFiles(
|
||||
}
|
||||
|
||||
|
||||
//! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description),
|
||||
//! but tries to load the programs from files.
|
||||
s32 CNullDriver::addHighLevelShaderMaterialFromFiles(
|
||||
io::IReadFile* vertexShaderProgram,
|
||||
const c8* vertexShaderEntryPointName,
|
||||
@ -1790,107 +1793,25 @@ s32 CNullDriver::addHighLevelShaderMaterialFromFiles(
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//! Adds a new material renderer to the VideoDriver, using pixel and/or
|
||||
//! vertex shaders to render geometry.
|
||||
s32 CNullDriver::addShaderMaterial(const c8* vertexShaderProgram,
|
||||
const c8* pixelShaderProgram,
|
||||
IShaderConstantSetCallBack* callback,
|
||||
E_MATERIAL_TYPE baseMaterial,
|
||||
s32 userData)
|
||||
void CNullDriver::deleteShaderMaterial(s32 material)
|
||||
{
|
||||
os::Printer::log("Shader materials not implemented yet in this driver, sorry.");
|
||||
return -1;
|
||||
}
|
||||
const u32 idx = (u32)material;
|
||||
if (idx < numBuiltInMaterials || idx >= MaterialRenderers.size())
|
||||
return;
|
||||
|
||||
|
||||
//! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the
|
||||
//! programs from files.
|
||||
s32 CNullDriver::addShaderMaterialFromFiles(io::IReadFile* vertexShaderProgram,
|
||||
io::IReadFile* pixelShaderProgram,
|
||||
IShaderConstantSetCallBack* callback,
|
||||
E_MATERIAL_TYPE baseMaterial,
|
||||
s32 userData)
|
||||
{
|
||||
c8* vs = 0;
|
||||
c8* ps = 0;
|
||||
|
||||
if (vertexShaderProgram)
|
||||
{
|
||||
const long size = vertexShaderProgram->getSize();
|
||||
if (size)
|
||||
{
|
||||
vs = new c8[size+1];
|
||||
vertexShaderProgram->read(vs, size);
|
||||
vs[size] = 0;
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
||||
if (pixelShaderProgram)
|
||||
{
|
||||
const long size = pixelShaderProgram->getSize();
|
||||
if (size)
|
||||
{
|
||||
ps = new c8[size+1];
|
||||
pixelShaderProgram->read(ps, size);
|
||||
ps[size] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
s32 result = addShaderMaterial(vs, ps, callback, baseMaterial, userData);
|
||||
|
||||
delete [] vs;
|
||||
delete [] ps;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the
|
||||
//! programs from files.
|
||||
s32 CNullDriver::addShaderMaterialFromFiles(const io::path& vertexShaderProgramFileName,
|
||||
const io::path& pixelShaderProgramFileName,
|
||||
IShaderConstantSetCallBack* callback,
|
||||
E_MATERIAL_TYPE baseMaterial,
|
||||
s32 userData)
|
||||
{
|
||||
io::IReadFile* vsfile = 0;
|
||||
io::IReadFile* psfile = 0;
|
||||
|
||||
if (vertexShaderProgramFileName.size())
|
||||
{
|
||||
vsfile = FileSystem->createAndOpenFile(vertexShaderProgramFileName);
|
||||
if (!vsfile)
|
||||
{
|
||||
os::Printer::log("Could not open vertex shader program file",
|
||||
vertexShaderProgramFileName, ELL_WARNING);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (pixelShaderProgramFileName.size())
|
||||
{
|
||||
psfile = FileSystem->createAndOpenFile(pixelShaderProgramFileName);
|
||||
if (!psfile)
|
||||
{
|
||||
os::Printer::log("Could not open pixel shader program file",
|
||||
pixelShaderProgramFileName, ELL_WARNING);
|
||||
if (vsfile)
|
||||
vsfile->drop();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
s32 result = addShaderMaterialFromFiles(vsfile, psfile, callback,
|
||||
baseMaterial, userData);
|
||||
|
||||
if (psfile)
|
||||
psfile->drop();
|
||||
|
||||
if (vsfile)
|
||||
vsfile->drop();
|
||||
|
||||
return result;
|
||||
// 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();
|
||||
}
|
||||
|
||||
|
||||
@ -1929,7 +1850,7 @@ IImage* CNullDriver::createScreenShot(video::ECOLOR_FORMAT format, video::E_REND
|
||||
// prints renderer version
|
||||
void CNullDriver::printVersion()
|
||||
{
|
||||
core::stringw namePrint = L"Using renderer: ";
|
||||
core::stringc namePrint = "Using renderer: ";
|
||||
namePrint += getName();
|
||||
os::Printer::log(namePrint.c_str(), ELL_INFORMATION);
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ namespace video
|
||||
|
||||
//! \return Returns the name of the video driver. Example: In case of the DIRECT3D8
|
||||
//! driver, it would return "Direct3D8.1".
|
||||
const wchar_t* getName() const override;
|
||||
const char* getName() const override;
|
||||
|
||||
//! Sets the dynamic ambient light color. The default color is
|
||||
//! (0,0,0,0) which means it is dark.
|
||||
@ -464,30 +464,6 @@ namespace video
|
||||
//! Returns pointer to the IGPUProgrammingServices interface.
|
||||
IGPUProgrammingServices* getGPUProgrammingServices() override;
|
||||
|
||||
//! Adds a new material renderer to the VideoDriver, using pixel and/or
|
||||
//! vertex shaders to render geometry.
|
||||
virtual s32 addShaderMaterial(const c8* vertexShaderProgram = 0,
|
||||
const c8* pixelShaderProgram = 0,
|
||||
IShaderConstantSetCallBack* callback = 0,
|
||||
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
|
||||
s32 userData=0) override;
|
||||
|
||||
//! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the
|
||||
//! programs from files.
|
||||
virtual s32 addShaderMaterialFromFiles(io::IReadFile* vertexShaderProgram = 0,
|
||||
io::IReadFile* pixelShaderProgram = 0,
|
||||
IShaderConstantSetCallBack* callback = 0,
|
||||
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
|
||||
s32 userData=0) override;
|
||||
|
||||
//! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the
|
||||
//! programs from files.
|
||||
virtual s32 addShaderMaterialFromFiles(const io::path& vertexShaderProgramFileName,
|
||||
const io::path& pixelShaderProgramFileName,
|
||||
IShaderConstantSetCallBack* callback = 0,
|
||||
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
|
||||
s32 userData=0) override;
|
||||
|
||||
//! Returns pointer to material renderer or null
|
||||
IMaterialRenderer* getMaterialRenderer(u32 idx) const override;
|
||||
|
||||
@ -497,8 +473,7 @@ namespace video
|
||||
//! 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. Currently only HLSL in D3D9 is supported.
|
||||
//! 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,
|
||||
@ -516,8 +491,6 @@ namespace video
|
||||
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
|
||||
s32 userData = 0) override;
|
||||
|
||||
//! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description),
|
||||
//! but tries to load the programs from files.
|
||||
virtual s32 addHighLevelShaderMaterialFromFiles(
|
||||
const io::path& vertexShaderProgramFile,
|
||||
const c8* vertexShaderEntryPointName = "main",
|
||||
@ -535,8 +508,6 @@ namespace video
|
||||
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
|
||||
s32 userData = 0) override;
|
||||
|
||||
//! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description),
|
||||
//! but tries to load the programs from files.
|
||||
virtual s32 addHighLevelShaderMaterialFromFiles(
|
||||
io::IReadFile* vertexShaderProgram,
|
||||
const c8* vertexShaderEntryPointName = "main",
|
||||
@ -554,6 +525,8 @@ namespace video
|
||||
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;
|
||||
|
||||
|
@ -1,72 +0,0 @@
|
||||
// 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_OGLES2_
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_IOS_DEVICE_)
|
||||
#include <OpenGLES/ES2/gl.h>
|
||||
#include <OpenGLES/ES2/glext.h>
|
||||
#elif defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#include <EGL/eglplatform.h>
|
||||
#elif defined(_IRR_EMSCRIPTEN_PLATFORM_)
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#include <EGL/eglplatform.h>
|
||||
#else
|
||||
#if defined(_IRR_OGLES2_USE_EXTPOINTER_)
|
||||
#define GL_GLEXT_PROTOTYPES 1
|
||||
#define GLX_GLXEXT_PROTOTYPES 1
|
||||
#endif
|
||||
#include <GLES2/gl2.h>
|
||||
#include <EGL/eglplatform.h>
|
||||
typedef char GLchar;
|
||||
#if defined(_IRR_OGLES2_USE_EXTPOINTER_)
|
||||
#include <GLES2/gl2ext.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GL_BGRA
|
||||
#define GL_BGRA 0x80E1;
|
||||
#endif
|
||||
|
||||
// FBO definitions.
|
||||
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 1
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 2
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS 3
|
||||
|
||||
// to check if this header is in the current compile unit (different GL implementation used different "GLCommon" headers in Irrlicht
|
||||
#define IRR_COMPILE_GLES2_COMMON
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
// Forward declarations.
|
||||
|
||||
class COpenGLCoreFeature;
|
||||
|
||||
template <class TOpenGLDriver>
|
||||
class COpenGLCoreTexture;
|
||||
|
||||
template <class TOpenGLDriver, class TOpenGLTexture>
|
||||
class COpenGLCoreRenderTarget;
|
||||
|
||||
template <class TOpenGLDriver, class TOpenGLTexture>
|
||||
class COpenGLCoreCacheHandler;
|
||||
|
||||
class COGLES2Driver;
|
||||
typedef COpenGLCoreTexture<COGLES2Driver> COGLES2Texture;
|
||||
typedef COpenGLCoreRenderTarget<COGLES2Driver, COGLES2Texture> COGLES2RenderTarget;
|
||||
typedef COpenGLCoreCacheHandler<COGLES2Driver, COGLES2Texture> COGLES2CacheHandler;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -1,405 +0,0 @@
|
||||
// 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"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
|
||||
#include "CNullDriver.h"
|
||||
#include "IMaterialRendererServices.h"
|
||||
#include "EDriverFeatures.h"
|
||||
#include "fast_atof.h"
|
||||
#include "COGLES2ExtensionHandler.h"
|
||||
#include "IContextManager.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
class COGLES2FixedPipelineRenderer;
|
||||
class COGLES2Renderer2D;
|
||||
|
||||
class COGLES2Driver : public CNullDriver, public IMaterialRendererServices, public COGLES2ExtensionHandler
|
||||
{
|
||||
friend class COpenGLCoreTexture<COGLES2Driver>;
|
||||
friend IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager);
|
||||
|
||||
protected:
|
||||
//! constructor (use createOGLES2Driver instead)
|
||||
COGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager);
|
||||
|
||||
public:
|
||||
|
||||
//! destructor
|
||||
virtual ~COGLES2Driver();
|
||||
|
||||
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<s32>* 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] && COGLES2ExtensionHandler::queryFeature(feature);
|
||||
}
|
||||
|
||||
//! Sets a material.
|
||||
void setMaterial(const SMaterial& material) override;
|
||||
|
||||
virtual void draw2DImage(const video::ITexture* texture,
|
||||
const core::position2d<s32>& destPos,
|
||||
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
|
||||
SColor color = SColor(255, 255, 255, 255), bool useAlphaChannelOfTexture = false) override;
|
||||
|
||||
virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
|
||||
const core::rect<s32>& sourceRect, const core::rect<s32>* 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);
|
||||
|
||||
//! draws a set of 2d images
|
||||
virtual void draw2DImageBatch(const video::ITexture* texture,
|
||||
const core::position2d<s32>& pos,
|
||||
const core::array<core::rect<s32> >& sourceRects,
|
||||
const core::array<s32>& indices, s32 kerningWidth = 0,
|
||||
const core::rect<s32>* clipRect = 0,
|
||||
SColor color = SColor(255, 255, 255, 255),
|
||||
bool useAlphaChannelOfTexture = false) override;
|
||||
|
||||
void draw2DImageBatch(const video::ITexture* texture,
|
||||
const core::array<core::position2d<s32> >& positions,
|
||||
const core::array<core::rect<s32> >& sourceRects,
|
||||
const core::rect<s32>* clipRect,
|
||||
SColor color,
|
||||
bool useAlphaChannelOfTexture) override;
|
||||
|
||||
//! draw an 2d rectangle
|
||||
virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos,
|
||||
const core::rect<s32>* clip = 0) override;
|
||||
|
||||
//!Draws an 2d rectangle with a gradient.
|
||||
virtual void draw2DRectangle(const core::rect<s32>& pos,
|
||||
SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown,
|
||||
const core::rect<s32>* clip = 0) override;
|
||||
|
||||
//! Draws a 2d line.
|
||||
virtual void draw2DLine(const core::position2d<s32>& start,
|
||||
const core::position2d<s32>& end,
|
||||
SColor color = SColor(255, 255, 255, 255)) override;
|
||||
|
||||
//! Draws a single pixel
|
||||
void drawPixel(u32 x, u32 y, const SColor & color) 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 pixel
|
||||
// virtual void drawPixel(u32 x, u32 y, const SColor & color);
|
||||
|
||||
//! Returns the name of the video driver.
|
||||
const wchar_t* getName() const override;
|
||||
|
||||
//! Returns the maximum texture size supported.
|
||||
core::dimension2du getMaxTextureSize() const override;
|
||||
|
||||
//! Draws a shadow volume into the stencil buffer.
|
||||
void drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail, u32 debugDataVisible=0) override;
|
||||
|
||||
//! Fills the stencil shadow with color.
|
||||
virtual void drawStencilShadow(bool clearStencilBuffer=false,
|
||||
video::SColor leftUpEdge = video::SColor(0,0,0,0),
|
||||
video::SColor rightUpEdge = video::SColor(0,0,0,0),
|
||||
video::SColor leftDownEdge = video::SColor(0,0,0,0),
|
||||
video::SColor rightDownEdge = video::SColor(0,0,0,0)) override;
|
||||
|
||||
//! sets a viewport
|
||||
void setViewPort(const core::rect<s32>& area) override;
|
||||
|
||||
//! Only used internally by the engine
|
||||
void OnResize(const core::dimension2d<u32>& 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 vertex shader constant.
|
||||
void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount = 1) override;
|
||||
|
||||
//! Sets a pixel shader constant.
|
||||
void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount = 1) 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 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram,
|
||||
IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData) 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<u32>& 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;
|
||||
|
||||
//! Get ZBuffer bits.
|
||||
virtual GLenum getZBufferBits() 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;
|
||||
|
||||
COGLES2CacheHandler* getCacheHandler() const;
|
||||
|
||||
protected:
|
||||
//! inits the opengl-es driver
|
||||
virtual bool genericDriverInit(const core::dimension2d<u32>& screenSize, bool stencilBuffer);
|
||||
|
||||
void chooseMaterial2D();
|
||||
|
||||
ITexture* createDeviceDependentTexture(const io::path& name, IImage* image) override;
|
||||
|
||||
ITexture* createDeviceDependentTextureCubemap(const io::path& name, const core::array<IImage*>& 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);
|
||||
|
||||
COGLES2CacheHandler* CacheHandler;
|
||||
core::stringw Name;
|
||||
core::stringc VendorName;
|
||||
SIrrlichtCreationParameters Params;
|
||||
|
||||
//! 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<SUserClipPlane> UserClipPlane;
|
||||
|
||||
core::matrix4 TextureFlipMatrix;
|
||||
|
||||
private:
|
||||
|
||||
COGLES2Renderer2D* MaterialRenderer2DActive;
|
||||
COGLES2Renderer2D* MaterialRenderer2DTexture;
|
||||
COGLES2Renderer2D* 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;
|
||||
};
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_OGLES2_
|
@ -1,57 +0,0 @@
|
||||
// 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 "COGLES2ExtensionHandler.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
|
||||
#include "irrString.h"
|
||||
#include "SMaterial.h"
|
||||
#include "fast_atof.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
void COGLES2ExtensionHandler::initExtensions()
|
||||
{
|
||||
getGLVersion();
|
||||
|
||||
getGLExtensions();
|
||||
|
||||
GLint val=0;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &val);
|
||||
Feature.MaxTextureUnits = static_cast<u8>(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<u8>(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<u32>(val);
|
||||
#ifdef GL_EXT_texture_lod_bias
|
||||
if (FeatureAvailable[IRR_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<u8>(MATERIAL_MAX_TEXTURES));
|
||||
Feature.ColorAttachment = 1;
|
||||
}
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_OGLES2_
|
@ -1,180 +0,0 @@
|
||||
// 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
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
|
||||
#include "EDriverFeatures.h"
|
||||
#include "irrTypes.h"
|
||||
#include "os.h"
|
||||
|
||||
#include "COGLES2Common.h"
|
||||
|
||||
#include "COGLESCoreExtensionHandler.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
class COGLES2ExtensionHandler : public COGLESCoreExtensionHandler
|
||||
{
|
||||
public:
|
||||
COGLES2ExtensionHandler() : COGLESCoreExtensionHandler() {}
|
||||
|
||||
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_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;
|
||||
};
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
glUseProgram(prog);
|
||||
}
|
||||
|
||||
inline void irrGlBindFramebuffer(GLenum target, GLuint framebuffer)
|
||||
{
|
||||
glBindFramebuffer(target, framebuffer);
|
||||
}
|
||||
|
||||
inline void irrGlDeleteFramebuffers(GLsizei n, const GLuint *framebuffers)
|
||||
{
|
||||
glDeleteFramebuffers(n, framebuffers);
|
||||
}
|
||||
|
||||
inline void irrGlGenFramebuffers(GLsizei n, GLuint *framebuffers)
|
||||
{
|
||||
glGenFramebuffers(n, framebuffers);
|
||||
}
|
||||
|
||||
inline GLenum irrGlCheckFramebufferStatus(GLenum target)
|
||||
{
|
||||
return glCheckFramebufferStatus(target);
|
||||
}
|
||||
|
||||
inline void irrGlFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
|
||||
{
|
||||
glFramebufferTexture2D(target, attachment, textarget, texture, level);
|
||||
}
|
||||
|
||||
inline void irrGlGenerateMipmap(GLenum target)
|
||||
{
|
||||
glGenerateMipmap(target);
|
||||
}
|
||||
|
||||
inline void irrGlActiveStencilFace(GLenum face)
|
||||
{
|
||||
}
|
||||
|
||||
inline void irrGlDrawBuffer(GLenum mode)
|
||||
{
|
||||
}
|
||||
|
||||
inline void irrGlDrawBuffers(GLsizei n, const GLenum *bufs)
|
||||
{
|
||||
}
|
||||
|
||||
inline void irrGlBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha)
|
||||
{
|
||||
glBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
|
||||
}
|
||||
|
||||
inline void irrGlBlendEquation(GLenum mode)
|
||||
{
|
||||
glBlendEquation(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)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -1,203 +0,0 @@
|
||||
// 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 "COGLES2FixedPipelineRenderer.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
|
||||
#include "IVideoDriver.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
// Base callback
|
||||
|
||||
COGLES2MaterialBaseCB::COGLES2MaterialBaseCB() :
|
||||
FirstUpdateBase(true), WVPMatrixID(-1), WVMatrixID(-1), NMatrixID(-1), GlobalAmbientID(-1), MaterialAmbientID(-1), MaterialDiffuseID(-1), MaterialEmissiveID(-1), MaterialSpecularID(-1), MaterialShininessID(-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 COGLES2MaterialBaseCB::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 COGLES2MaterialBaseCB::OnSetConstants(IMaterialRendererServices* services, s32 userData)
|
||||
{
|
||||
IVideoDriver* driver = services->getVideoDriver();
|
||||
|
||||
if (FirstUpdateBase)
|
||||
{
|
||||
WVPMatrixID = services->getVertexShaderConstantID("uWVPMatrix");
|
||||
WVMatrixID = services->getVertexShaderConstantID("uWVMatrix");
|
||||
NMatrixID = services->getVertexShaderConstantID("uNMatrix");
|
||||
GlobalAmbientID = services->getVertexShaderConstantID("uGlobalAmbient");
|
||||
MaterialAmbientID = services->getVertexShaderConstantID("uMaterialAmbient");
|
||||
MaterialDiffuseID = services->getVertexShaderConstantID("uMaterialDiffuse");
|
||||
MaterialEmissiveID = services->getVertexShaderConstantID("uMaterialEmissive");
|
||||
MaterialSpecularID = services->getVertexShaderConstantID("uMaterialSpecular");
|
||||
MaterialShininessID = services->getVertexShaderConstantID("uMaterialShininess");
|
||||
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<f32*>(&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
|
||||
|
||||
COGLES2MaterialSolidCB::COGLES2MaterialSolidCB() :
|
||||
FirstUpdate(true), TMatrix0ID(-1), AlphaRefID(-1), TextureUsage0ID(-1), TextureUnit0ID(-1), AlphaRef(0.5f), TextureUsage0(0), TextureUnit0(0)
|
||||
{
|
||||
}
|
||||
|
||||
void COGLES2MaterialSolidCB::OnSetMaterial(const SMaterial& material)
|
||||
{
|
||||
COGLES2MaterialBaseCB::OnSetMaterial(material);
|
||||
|
||||
AlphaRef = material.MaterialTypeParam;
|
||||
TextureUsage0 = (material.TextureLayers[0].Texture) ? 1 : 0;
|
||||
}
|
||||
|
||||
void COGLES2MaterialSolidCB::OnSetConstants(IMaterialRendererServices* services, s32 userData)
|
||||
{
|
||||
COGLES2MaterialBaseCB::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
|
||||
|
||||
COGLES2MaterialOneTextureBlendCB::COGLES2MaterialOneTextureBlendCB() :
|
||||
FirstUpdate(true), TMatrix0ID(-1), BlendTypeID(-1), TextureUsage0ID(-1), TextureUnit0ID(-1), BlendType(0), TextureUsage0(0), TextureUnit0(0)
|
||||
{
|
||||
}
|
||||
|
||||
void COGLES2MaterialOneTextureBlendCB::OnSetMaterial(const SMaterial& material)
|
||||
{
|
||||
COGLES2MaterialBaseCB::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 COGLES2MaterialOneTextureBlendCB::OnSetConstants(IMaterialRendererServices* services, s32 userData)
|
||||
{
|
||||
COGLES2MaterialBaseCB::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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,111 +0,0 @@
|
||||
// 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_OGLES2_
|
||||
|
||||
#include "IShaderConstantSetCallBack.h"
|
||||
#include "IMaterialRendererServices.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
class COGLES2MaterialBaseCB : public IShaderConstantSetCallBack
|
||||
{
|
||||
public:
|
||||
COGLES2MaterialBaseCB();
|
||||
|
||||
virtual void OnSetMaterial(const SMaterial& material);
|
||||
virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData);
|
||||
|
||||
protected:
|
||||
bool FirstUpdateBase;
|
||||
|
||||
s32 WVPMatrixID;
|
||||
s32 WVMatrixID;
|
||||
s32 NMatrixID;
|
||||
|
||||
s32 GlobalAmbientID;
|
||||
s32 MaterialAmbientID;
|
||||
s32 MaterialDiffuseID;
|
||||
s32 MaterialEmissiveID;
|
||||
s32 MaterialSpecularID;
|
||||
s32 MaterialShininessID;
|
||||
|
||||
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 COGLES2MaterialSolidCB : public COGLES2MaterialBaseCB
|
||||
{
|
||||
public:
|
||||
COGLES2MaterialSolidCB();
|
||||
|
||||
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 COGLES2MaterialOneTextureBlendCB : public COGLES2MaterialBaseCB
|
||||
{
|
||||
public:
|
||||
COGLES2MaterialOneTextureBlendCB();
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -1,476 +0,0 @@
|
||||
// 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 "COGLES2MaterialRenderer.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
|
||||
#include "EVertexAttributes.h"
|
||||
#include "IGPUProgrammingServices.h"
|
||||
#include "IShaderConstantSetCallBack.h"
|
||||
#include "IVideoDriver.h"
|
||||
#include "os.h"
|
||||
|
||||
#include "COGLES2Driver.h"
|
||||
|
||||
#include "COpenGLCoreTexture.h"
|
||||
#include "COpenGLCoreCacheHandler.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
|
||||
COGLES2MaterialRenderer::COGLES2MaterialRenderer(COGLES2Driver* 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("COGLES2MaterialRenderer");
|
||||
#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);
|
||||
}
|
||||
|
||||
|
||||
COGLES2MaterialRenderer::COGLES2MaterialRenderer(COGLES2Driver* 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();
|
||||
}
|
||||
|
||||
|
||||
COGLES2MaterialRenderer::~COGLES2MaterialRenderer()
|
||||
{
|
||||
if (CallBack)
|
||||
CallBack->drop();
|
||||
|
||||
if (Program)
|
||||
{
|
||||
GLuint shaders[8];
|
||||
GLint count;
|
||||
glGetAttachedShaders(Program, 8, &count, shaders);
|
||||
|
||||
count=core::min_(count,8);
|
||||
for (GLint i=0; i<count; ++i)
|
||||
glDeleteShader(shaders[i]);
|
||||
glDeleteProgram(Program);
|
||||
Program = 0;
|
||||
}
|
||||
|
||||
UniformInfo.clear();
|
||||
}
|
||||
|
||||
GLuint COGLES2MaterialRenderer::getProgram() const
|
||||
{
|
||||
return Program;
|
||||
}
|
||||
|
||||
void COGLES2MaterialRenderer::init(s32& outMaterialTypeNr,
|
||||
const c8* vertexShaderProgram,
|
||||
const c8* pixelShaderProgram,
|
||||
bool addMaterial)
|
||||
{
|
||||
outMaterialTypeNr = -1;
|
||||
|
||||
Program = glCreateProgram();
|
||||
|
||||
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 )
|
||||
glBindAttribLocation( Program, i, sBuiltInVertexAttributeNames[i]);
|
||||
|
||||
if (!linkProgram())
|
||||
return;
|
||||
|
||||
if (addMaterial)
|
||||
outMaterialTypeNr = Driver->addMaterialRenderer(this);
|
||||
}
|
||||
|
||||
|
||||
bool COGLES2MaterialRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype)
|
||||
{
|
||||
if (CallBack && Program)
|
||||
CallBack->OnSetConstants(this, UserData);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void COGLES2MaterialRenderer::OnSetMaterial(const video::SMaterial& material,
|
||||
const video::SMaterial& lastMaterial,
|
||||
bool resetAllRenderstates,
|
||||
video::IMaterialRendererServices* services)
|
||||
{
|
||||
COGLES2CacheHandler* 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 COGLES2MaterialRenderer::OnUnsetMaterial()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool COGLES2MaterialRenderer::isTransparent() const
|
||||
{
|
||||
return (Alpha || Blending);
|
||||
}
|
||||
|
||||
|
||||
s32 COGLES2MaterialRenderer::getRenderCapability() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool COGLES2MaterialRenderer::createShader(GLenum shaderType, const char* shader)
|
||||
{
|
||||
if (Program)
|
||||
{
|
||||
GLuint shaderHandle = glCreateShader(shaderType);
|
||||
glShaderSource(shaderHandle, 1, &shader, NULL);
|
||||
glCompileShader(shaderHandle);
|
||||
|
||||
GLint status = 0;
|
||||
|
||||
glGetShaderiv(shaderHandle, GL_COMPILE_STATUS, &status);
|
||||
|
||||
if (status != GL_TRUE)
|
||||
{
|
||||
os::Printer::log("GLSL shader failed to compile", ELL_ERROR);
|
||||
|
||||
GLint maxLength=0;
|
||||
GLint length;
|
||||
|
||||
glGetShaderiv(shaderHandle, GL_INFO_LOG_LENGTH,
|
||||
&maxLength);
|
||||
|
||||
if (maxLength)
|
||||
{
|
||||
GLchar *infoLog = new GLchar[maxLength];
|
||||
glGetShaderInfoLog(shaderHandle, maxLength, &length, infoLog);
|
||||
os::Printer::log(reinterpret_cast<const c8*>(infoLog), ELL_ERROR);
|
||||
delete [] infoLog;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
glAttachShader(Program, shaderHandle);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool COGLES2MaterialRenderer::linkProgram()
|
||||
{
|
||||
if (Program)
|
||||
{
|
||||
glLinkProgram(Program);
|
||||
|
||||
GLint status = 0;
|
||||
|
||||
glGetProgramiv(Program, GL_LINK_STATUS, &status);
|
||||
|
||||
if (!status)
|
||||
{
|
||||
os::Printer::log("GLSL shader program failed to link", ELL_ERROR);
|
||||
|
||||
GLint maxLength=0;
|
||||
GLsizei length;
|
||||
|
||||
glGetProgramiv(Program, GL_INFO_LOG_LENGTH, &maxLength);
|
||||
|
||||
if (maxLength)
|
||||
{
|
||||
GLchar *infoLog = new GLchar[maxLength];
|
||||
glGetProgramInfoLog(Program, maxLength, &length, infoLog);
|
||||
os::Printer::log(reinterpret_cast<const c8*>(infoLog), ELL_ERROR);
|
||||
delete [] infoLog;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
GLint num = 0;
|
||||
|
||||
glGetProgramiv(Program, GL_ACTIVE_UNIFORMS, &num);
|
||||
|
||||
if (num == 0)
|
||||
return true;
|
||||
|
||||
GLint maxlen = 0;
|
||||
|
||||
glGetProgramiv(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;
|
||||
glGetActiveUniform(Program, i, maxlen, 0, &size, &ui.type, reinterpret_cast<GLchar*>(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 = glGetUniformLocation(Program, buf);
|
||||
|
||||
UniformInfo.push_back(ui);
|
||||
}
|
||||
|
||||
delete [] buf;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void COGLES2MaterialRenderer::setBasicRenderStates(const SMaterial& material,
|
||||
const SMaterial& lastMaterial,
|
||||
bool resetAllRenderstates)
|
||||
{
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
}
|
||||
|
||||
s32 COGLES2MaterialRenderer::getVertexShaderConstantID(const c8* name)
|
||||
{
|
||||
return getPixelShaderConstantID(name);
|
||||
}
|
||||
|
||||
s32 COGLES2MaterialRenderer::getPixelShaderConstantID(const c8* name)
|
||||
{
|
||||
for (u32 i = 0; i < UniformInfo.size(); ++i)
|
||||
{
|
||||
if (UniformInfo[i].name == name)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void COGLES2MaterialRenderer::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
|
||||
{
|
||||
os::Printer::log("Cannot set constant, please use high level shader call instead.", ELL_WARNING);
|
||||
}
|
||||
|
||||
void COGLES2MaterialRenderer::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
|
||||
{
|
||||
os::Printer::log("Cannot set constant, use high level shader call.", ELL_WARNING);
|
||||
}
|
||||
|
||||
bool COGLES2MaterialRenderer::setVertexShaderConstant(s32 index, const f32* floats, int count)
|
||||
{
|
||||
return setPixelShaderConstant(index, floats, count);
|
||||
}
|
||||
|
||||
bool COGLES2MaterialRenderer::setVertexShaderConstant(s32 index, const s32* ints, int count)
|
||||
{
|
||||
return setPixelShaderConstant(index, ints, count);
|
||||
}
|
||||
|
||||
bool COGLES2MaterialRenderer::setVertexShaderConstant(s32 index, const u32* ints, int count)
|
||||
{
|
||||
return setPixelShaderConstant(index, ints, count);
|
||||
}
|
||||
|
||||
bool COGLES2MaterialRenderer::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:
|
||||
glUniform1fv(UniformInfo[index].location, count, floats);
|
||||
break;
|
||||
case GL_FLOAT_VEC2:
|
||||
glUniform2fv(UniformInfo[index].location, count/2, floats);
|
||||
break;
|
||||
case GL_FLOAT_VEC3:
|
||||
glUniform3fv(UniformInfo[index].location, count/3, floats);
|
||||
break;
|
||||
case GL_FLOAT_VEC4:
|
||||
glUniform4fv(UniformInfo[index].location, count/4, floats);
|
||||
break;
|
||||
case GL_FLOAT_MAT2:
|
||||
glUniformMatrix2fv(UniformInfo[index].location, count/4, false, floats);
|
||||
break;
|
||||
case GL_FLOAT_MAT3:
|
||||
glUniformMatrix3fv(UniformInfo[index].location, count/9, false, floats);
|
||||
break;
|
||||
case GL_FLOAT_MAT4:
|
||||
glUniformMatrix4fv(UniformInfo[index].location, count/16, false, floats);
|
||||
break;
|
||||
case GL_SAMPLER_2D:
|
||||
case GL_SAMPLER_CUBE:
|
||||
{
|
||||
if(floats)
|
||||
{
|
||||
const GLint id = (GLint)(*floats);
|
||||
glUniform1iv(UniformInfo[index].location, 1, &id);
|
||||
}
|
||||
else
|
||||
status = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
status = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
bool COGLES2MaterialRenderer::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:
|
||||
glUniform1iv(UniformInfo[index].location, count, ints);
|
||||
break;
|
||||
case GL_INT_VEC2:
|
||||
case GL_BOOL_VEC2:
|
||||
glUniform2iv(UniformInfo[index].location, count/2, ints);
|
||||
break;
|
||||
case GL_INT_VEC3:
|
||||
case GL_BOOL_VEC3:
|
||||
glUniform3iv(UniformInfo[index].location, count/3, ints);
|
||||
break;
|
||||
case GL_INT_VEC4:
|
||||
case GL_BOOL_VEC4:
|
||||
glUniform4iv(UniformInfo[index].location, count/4, ints);
|
||||
break;
|
||||
case GL_SAMPLER_2D:
|
||||
case GL_SAMPLER_CUBE:
|
||||
glUniform1iv(UniformInfo[index].location, 1, ints);
|
||||
break;
|
||||
default:
|
||||
status = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
bool COGLES2MaterialRenderer::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* COGLES2MaterialRenderer::getVideoDriver()
|
||||
{
|
||||
return Driver;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,102 +0,0 @@
|
||||
// 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_OGLES2_
|
||||
|
||||
#include "EMaterialTypes.h"
|
||||
#include "IMaterialRenderer.h"
|
||||
#include "IMaterialRendererServices.h"
|
||||
#include "IGPUProgrammingServices.h"
|
||||
#include "irrArray.h"
|
||||
#include "irrString.h"
|
||||
|
||||
#include "COGLES2Common.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
class COGLES2Driver;
|
||||
|
||||
class COGLES2MaterialRenderer : public IMaterialRenderer, public IMaterialRendererServices
|
||||
{
|
||||
public:
|
||||
|
||||
COGLES2MaterialRenderer(
|
||||
COGLES2Driver* driver,
|
||||
s32& outMaterialTypeNr,
|
||||
const c8* vertexShaderProgram = 0,
|
||||
const c8* pixelShaderProgram = 0,
|
||||
IShaderConstantSetCallBack* callback = 0,
|
||||
E_MATERIAL_TYPE baseMaterial = EMT_SOLID,
|
||||
s32 userData = 0);
|
||||
|
||||
virtual ~COGLES2MaterialRenderer();
|
||||
|
||||
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;
|
||||
void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) override;
|
||||
void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) 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:
|
||||
|
||||
COGLES2MaterialRenderer(COGLES2Driver* 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();
|
||||
|
||||
COGLES2Driver* Driver;
|
||||
IShaderConstantSetCallBack* CallBack;
|
||||
|
||||
bool Alpha;
|
||||
bool Blending;
|
||||
|
||||
struct SUniformInfo
|
||||
{
|
||||
core::stringc name;
|
||||
GLenum type;
|
||||
GLint location;
|
||||
};
|
||||
|
||||
GLuint Program;
|
||||
core::array<SUniformInfo> UniformInfo;
|
||||
s32 UserData;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -1,87 +0,0 @@
|
||||
// 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 "COGLES2Renderer2D.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
|
||||
#include "IGPUProgrammingServices.h"
|
||||
#include "os.h"
|
||||
|
||||
#include "COGLES2Driver.h"
|
||||
|
||||
#include "COpenGLCoreFeature.h"
|
||||
#include "COpenGLCoreTexture.h"
|
||||
#include "COpenGLCoreCacheHandler.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
COGLES2Renderer2D::COGLES2Renderer2D(const c8* vertexShaderProgram, const c8* pixelShaderProgram, COGLES2Driver* driver, bool withTexture) :
|
||||
COGLES2MaterialRenderer(driver, 0, EMT_SOLID),
|
||||
WithTexture(withTexture)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("COGLES2Renderer2D");
|
||||
#endif
|
||||
|
||||
int Temp = 0;
|
||||
|
||||
init(Temp, vertexShaderProgram, pixelShaderProgram, false);
|
||||
|
||||
COGLES2CacheHandler* 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);
|
||||
}
|
||||
|
||||
COGLES2Renderer2D::~COGLES2Renderer2D()
|
||||
{
|
||||
}
|
||||
|
||||
void COGLES2Renderer2D::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 COGLES2Renderer2D::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -1,37 +0,0 @@
|
||||
// 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_OGLES2_
|
||||
|
||||
#include "COGLES2MaterialRenderer.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
class COGLES2Renderer2D : public COGLES2MaterialRenderer
|
||||
{
|
||||
public:
|
||||
COGLES2Renderer2D(const c8* vertexShaderProgram, const c8* pixelShaderProgram, COGLES2Driver* driver, bool withTexture);
|
||||
~COGLES2Renderer2D();
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -24,316 +24,33 @@ namespace video
|
||||
enum EOGLESFeatures
|
||||
{
|
||||
// If you update this enum also update the corresponding OGLESFeatureStrings string-array
|
||||
// Last updated was up to (including) extension number 290 (GL_EXT_clip_control)
|
||||
IRR_GLX_ARB_context_flush_control, // 191
|
||||
IRR_GL_AMD_compressed_3DC_texture, // 39
|
||||
IRR_GL_AMD_compressed_ATC_texture, // 40
|
||||
IRR_GL_AMD_performance_monitor, // 50
|
||||
IRR_GL_AMD_program_binary_Z400, // 48
|
||||
IRR_GL_ANDROID_extension_pack_es31a, // 187
|
||||
IRR_GL_ANGLE_depth_texture, // 138
|
||||
IRR_GL_ANGLE_framebuffer_blit, // 83
|
||||
IRR_GL_ANGLE_framebuffer_multisample, // 84
|
||||
IRR_GL_ANGLE_instanced_arrays, // 109
|
||||
IRR_GL_ANGLE_pack_reverse_row_order, // 110
|
||||
IRR_GL_ANGLE_program_binary, //139
|
||||
IRR_GL_ANGLE_texture_compression_dxt1, // 111
|
||||
IRR_GL_ANGLE_texture_compression_dxt3, // 111
|
||||
IRR_GL_ANGLE_texture_compression_dxt5, // 111
|
||||
IRR_GL_ANGLE_texture_usage, // 112
|
||||
IRR_GL_ANGLE_translated_shader_source, // 113
|
||||
IRR_GL_APPLE_clip_distance, // 193
|
||||
IRR_GL_APPLE_color_buffer_packed_float, // 194
|
||||
IRR_GL_APPLE_copy_texture_levels, // 123
|
||||
IRR_GL_APPLE_framebuffer_multisample, // 78
|
||||
IRR_GL_APPLE_rgb_422, // 76
|
||||
IRR_GL_APPLE_sync, // 124
|
||||
IRR_GL_APPLE_texture_2D_limited_npot, // 59
|
||||
IRR_GL_APPLE_texture_format_BGRA8888, // 79
|
||||
IRR_GL_APPLE_texture_max_level, // 80
|
||||
IRR_GL_APPLE_texture_packed_float, // 195
|
||||
IRR_ARB_texture_env_combine, //ogl, IMG simulator
|
||||
IRR_ARB_texture_env_dot3, //ogl, IMG simulator
|
||||
IRR_GL_ARM_mali_program_binary, // 120
|
||||
IRR_GL_ARM_mali_shader_binary, // 81
|
||||
IRR_GL_ARM_rgba8, // 82
|
||||
IRR_GL_ARM_shader_framebuffer_fetch, // 165
|
||||
IRR_GL_ARM_shader_framebuffer_fetch_depth_stencil, // 166
|
||||
IRR_GL_DMP_program_binary, // 192
|
||||
IRR_GL_DMP_shader_binary, // 88
|
||||
IRR_GL_EXT_EGL_image_array, // 278
|
||||
IRR_GL_EXT_YUV_target, // 222
|
||||
IRR_GL_EXT_base_instance, // 203
|
||||
IRR_GL_EXT_blend_func_extended, // 247
|
||||
IRR_GL_EXT_blend_minmax, // 65
|
||||
IRR_GL_EXT_buffer_storage, // 239
|
||||
IRR_GL_EXT_clear_texture, // 269
|
||||
IRR_GL_EXT_clip_control, // 290
|
||||
IRR_GL_EXT_clip_cull_distance, // 257
|
||||
IRR_GL_EXT_color_buffer_float, // 137
|
||||
IRR_GL_EXT_color_buffer_half_float, // 97
|
||||
IRR_GL_EXT_compressed_ETC1_RGB8_sub_texture, // 188
|
||||
IRR_GL_EXT_conservative_depth, // 268
|
||||
IRR_GL_EXT_copy_image, // 175
|
||||
IRR_GL_EXT_debug_label, // 98
|
||||
IRR_GL_EXT_debug_marker, // 99
|
||||
IRR_GL_EXT_discard_framebuffer, // 64
|
||||
IRR_GL_EXT_disjoint_timer_query, // 150
|
||||
IRR_GL_EXT_draw_buffers, // 151
|
||||
IRR_GL_EXT_draw_buffers_indexed, // 176
|
||||
IRR_GL_EXT_draw_elements_base_vertex, // 204
|
||||
IRR_GL_EXT_draw_instanced, // 157
|
||||
IRR_GL_EXT_draw_transform_feedback, // 272
|
||||
IRR_GL_EXT_external_buffer, // 284
|
||||
IRR_GL_EXT_float_blend, // 225
|
||||
IRR_GL_EXT_frag_depth, // 86
|
||||
IRR_GL_EXT_geometry_point_size, // 177
|
||||
IRR_GL_EXT_geometry_shader, // 177
|
||||
IRR_GL_EXT_gpu_shader5, // 178
|
||||
IRR_GL_EXT_instanced_arrays, // 156
|
||||
IRR_GL_EXT_map_buffer_range, // 121
|
||||
IRR_GL_EXT_memory_object, // 280
|
||||
IRR_GL_EXT_memory_object_fd, // 281
|
||||
IRR_GL_EXT_memory_object_win32, // 282
|
||||
IRR_GL_EXT_multi_draw_arrays, // 69
|
||||
IRR_GL_EXT_multi_draw_indirect, // 205
|
||||
IRR_GL_EXT_multisample_compatibility, // 248
|
||||
IRR_GL_EXT_multisampled_render_to_texture, // 106
|
||||
IRR_GL_EXT_multisampled_render_to_texture2, // 275
|
||||
IRR_GL_EXT_multiview_draw_buffers, // 125
|
||||
IRR_GL_EXT_occlusion_query_boolean, // 100
|
||||
IRR_GL_EXT_polygon_offset_clamp, // 252
|
||||
IRR_GL_EXT_post_depth_coverage, // 225
|
||||
IRR_GL_EXT_primitive_bounding_box, // 186
|
||||
IRR_GL_EXT_protected_textures, // 256
|
||||
IRR_GL_EXT_pvrtc_sRGB, // 155
|
||||
IRR_GL_EXT_raster_multisample, // 226
|
||||
IRR_GL_EXT_read_format_bgra, // 66
|
||||
IRR_GL_EXT_render_snorm, // 206
|
||||
IRR_GL_EXT_robustness, // 107
|
||||
IRR_GL_EXT_sRGB, // 105
|
||||
IRR_GL_EXT_sRGB_write_control, // 153
|
||||
IRR_GL_EXT_semaphore, // 280
|
||||
IRR_GL_EXT_semaphore_fd, // 281
|
||||
IRR_GL_EXT_semaphore_win32, // 282
|
||||
IRR_GL_EXT_separate_shader_objects, // 101
|
||||
IRR_GL_EXT_shader_framebuffer_fetch, // 122
|
||||
IRR_GL_EXT_shader_group_vote, // 254
|
||||
IRR_GL_EXT_shader_implicit_conversions, // 179
|
||||
IRR_GL_EXT_shader_integer_mix, // 161
|
||||
IRR_GL_EXT_shader_io_blocks, // 180
|
||||
IRR_GL_EXT_shader_non_constant_global_initializers, // 264
|
||||
IRR_GL_EXT_shader_pixel_local_storage, // 167
|
||||
IRR_GL_EXT_shader_pixel_local_storage2, // 253
|
||||
IRR_GL_EXT_shader_texture_lod, // 77
|
||||
IRR_GL_EXT_shadow_samplers, // 102
|
||||
IRR_GL_EXT_sparse_texture, // 240
|
||||
IRR_GL_EXT_sparse_texture2, // 259
|
||||
IRR_GL_EXT_tessellation_point_size, // 181
|
||||
IRR_GL_EXT_tessellation_shader, // 181
|
||||
IRR_GL_EXT_texture_border_clamp, // 182
|
||||
IRR_GL_EXT_texture_buffer, // 183
|
||||
IRR_GL_EXT_texture_compression_astc_decode_mode, // 276
|
||||
IRR_GL_EXT_texture_compression_astc_decode_mode_rgb9e5, // 276
|
||||
IRR_GL_EXT_texture_compression_bptc, // 287
|
||||
IRR_GL_EXT_texture_compression_dxt1, // 49
|
||||
IRR_GL_EXT_texture_compression_rgtc, // 286
|
||||
IRR_GL_EXT_texture_compression_s3tc, // 154
|
||||
IRR_GL_EXT_texture_compression_s3tc_srgb, // 289
|
||||
IRR_GL_EXT_texture_cube_map_array, // 184
|
||||
IRR_GL_EXT_texture_filter_anisotropic, // 41
|
||||
IRR_GL_EXT_texture_filter_minmax, // 227
|
||||
IRR_GL_EXT_texture_format_BGRA8888, // 51
|
||||
IRR_GL_EXT_texture_lod_bias, // 60
|
||||
IRR_GL_EXT_texture_norm16, // 207
|
||||
IRR_GL_EXT_texture_rg, // 103
|
||||
IRR_GL_EXT_texture_sRGB_R8, // 221
|
||||
IRR_GL_EXT_texture_sRGB_RG8, // 223
|
||||
IRR_GL_EXT_texture_sRGB_decode, // 152
|
||||
IRR_GL_EXT_texture_storage, // 108
|
||||
IRR_GL_EXT_texture_type_2_10_10_10_REV, // 42
|
||||
IRR_GL_EXT_texture_view, // 185
|
||||
IRR_GL_EXT_unpack_subimage, // 90
|
||||
IRR_GL_EXT_win32_keyed_mutex, // 283
|
||||
IRR_GL_EXT_window_rectangles, // 263
|
||||
IRR_GL_FJ_shader_binary_GCCSO, // 114
|
||||
IRR_GL_IMG_bindless_texture, // 270
|
||||
IRR_GL_IMG_framebuffer_downsample, // 255
|
||||
IRR_GL_IMG_multisampled_render_to_texture, // 74
|
||||
IRR_GL_IMG_program_binary, // 67
|
||||
IRR_GL_IMG_read_format, // 53
|
||||
IRR_GL_IMG_shader_binary, // 68
|
||||
IRR_GL_IMG_texture_compression_pvrtc, // 54
|
||||
IRR_GL_IMG_texture_compression_pvrtc2, // 140
|
||||
IRR_GL_IMG_texture_env_enhanced_fixed_function, // 58
|
||||
IRR_GL_IMG_texture_format_BGRA8888, // replaced by EXT version
|
||||
IRR_GL_IMG_texture_filter_cubic, // 251
|
||||
IRR_GL_IMG_user_clip_plane, // 57, was clip_planes
|
||||
IRR_GL_IMG_vertex_program, // non-standard
|
||||
IRR_GL_INTEL_conservative_rasterization, // 265
|
||||
IRR_GL_INTEL_framebuffer_CMAA, // 246
|
||||
IRR_GL_INTEL_performance_query, // 164
|
||||
IRR_GL_KHR_blend_equation_advanced, // 168
|
||||
IRR_GL_KHR_blend_equation_advanced_coherent, // 168
|
||||
IRR_GL_KHR_context_flush_control, // 191
|
||||
IRR_GL_KHR_debug, // 118
|
||||
IRR_GL_KHR_no_error, // 243
|
||||
IRR_GL_KHR_parallel_shader_compile, // 288
|
||||
IRR_GL_KHR_robust_buffer_access_behavior, // 189
|
||||
IRR_GL_KHR_robustness, // 190
|
||||
IRR_GL_KHR_texture_compression_astc_hdr, // 117
|
||||
IRR_GL_KHR_texture_compression_astc_ldr, // 117
|
||||
IRR_GL_KHR_texture_compression_astc_sliced_3d, // 249
|
||||
IRR_GL_NVX_blend_equation_advanced_multi_draw_buffers, // 266
|
||||
IRR_GL_NV_3dvision_settings, // 129
|
||||
IRR_GL_NV_EGL_stream_consumer_external, // 104
|
||||
IRR_GL_NV_bgr, // 135
|
||||
IRR_GL_NV_bindless_texture, // 197
|
||||
IRR_GL_NV_blend_equation_advanced, // 163
|
||||
IRR_GL_NV_blend_equation_advanced_coherent, // 163
|
||||
IRR_GL_NV_blend_minmax_factor, // 285
|
||||
IRR_GL_NV_conditional_render, // 198
|
||||
IRR_GL_NV_conservative_raster, // 228
|
||||
IRR_GL_NV_conservative_raster_pre_snap_triangles, // 262
|
||||
IRR_GL_NV_copy_buffer, // 158
|
||||
IRR_GL_NV_coverage_sample, // 72
|
||||
IRR_GL_NV_depth_nonlinear, // 73
|
||||
IRR_GL_NV_draw_buffers, // 91
|
||||
IRR_GL_NV_draw_instanced, // 141
|
||||
IRR_GL_NV_draw_texture, // 126
|
||||
IRR_GL_NV_draw_vulkan_image, // 274
|
||||
IRR_GL_NV_explicit_attrib_location, // 159
|
||||
IRR_GL_NV_fbo_color_attachments, // 92
|
||||
IRR_GL_NV_fence, // 52
|
||||
IRR_GL_NV_fill_rectangle, // 232
|
||||
IRR_GL_NV_fragment_coverage_to_color, // 229
|
||||
IRR_GL_NV_fragment_shader_interlock, // 230
|
||||
IRR_GL_NV_framebuffer_blit, // 142
|
||||
IRR_GL_NV_framebuffer_mixed_samples, // 231
|
||||
IRR_GL_NV_framebuffer_multisample, // 143
|
||||
IRR_GL_NV_generate_mipmap_sRGB, // 144
|
||||
IRR_GL_NV_geometry_shader_passthrough, // 233
|
||||
IRR_GL_NV_gpu_shader5, // 260
|
||||
IRR_GL_NV_image_formats, // 200
|
||||
IRR_GL_NV_instanced_arrays, // 145
|
||||
IRR_GL_NV_internalformat_sample_query, // 196
|
||||
IRR_GL_NV_non_square_matrices, // 160
|
||||
IRR_GL_NV_pack_subimage, // 132
|
||||
IRR_GL_NV_packed_float, // 127
|
||||
IRR_GL_NV_path_rendering, // 199
|
||||
IRR_GL_NV_path_rendering_shared_edge, // 234
|
||||
IRR_GL_NV_pixel_buffer_object, // 134
|
||||
IRR_GL_NV_platform_binary, // 131
|
||||
IRR_GL_NV_polygon_mode, // 238
|
||||
IRR_GL_NV_read_buffer, // 93
|
||||
IRR_GL_NV_read_buffer_front, // part of 93 (non standard)
|
||||
IRR_GL_NV_read_depth, // part of 94 (non standard)
|
||||
IRR_GL_NV_read_depth_stencil, // 94
|
||||
IRR_GL_NV_read_stencil, // part of 94 (non standard)
|
||||
IRR_GL_NV_sRGB_formats, // 148
|
||||
IRR_GL_NV_sample_locations, // 235
|
||||
IRR_GL_NV_sample_mask_override_coverage, // 236
|
||||
IRR_GL_NV_shader_atomic_fp16_vector, // 261
|
||||
IRR_GL_NV_shader_noperspective_interpolation, // 201
|
||||
IRR_GL_NV_shadow_samplers_array, // 146
|
||||
IRR_GL_NV_shadow_samplers_cube, // 147
|
||||
IRR_GL_NV_texture_array, // 133
|
||||
IRR_GL_NV_texture_barrier, // 271
|
||||
IRR_GL_NV_texture_border_clamp, // 149
|
||||
IRR_GL_NV_texture_compression_latc, // 130
|
||||
IRR_GL_NV_texture_compression_s3tc, // 128
|
||||
IRR_GL_NV_texture_compression_s3tc_update, // 95
|
||||
IRR_GL_NV_texture_npot_2D_mipmap, // 96
|
||||
IRR_GL_NV_viewport_array, // 202
|
||||
IRR_GL_NV_viewport_array2, // 237
|
||||
IRR_GL_NV_viewport_swizzle, // 258
|
||||
IRR_GL_OES_EGL_image, // 23
|
||||
IRR_GL_OES_EGL_image_external, // 87
|
||||
IRR_GL_OES_EGL_image_external_essl3, // 220
|
||||
IRR_GL_OES_EGL_sync, // 75
|
||||
IRR_GL_OES_blend_equation_separate, // 1
|
||||
IRR_GL_OES_blend_func_separate, // 2
|
||||
IRR_GL_OES_blend_subtract, // 3
|
||||
IRR_GL_OES_byte_coordinates, // 4
|
||||
IRR_GL_OES_compressed_ETC1_RGB8_texture, // 5
|
||||
IRR_GL_OES_compressed_paletted_texture, // 6
|
||||
IRR_GL_OES_copy_image, // 208
|
||||
IRR_GL_OES_depth24, // 24
|
||||
IRR_GL_OES_depth32, // 25
|
||||
IRR_GL_OES_depth_texture, // 43
|
||||
IRR_GL_OES_depth_texture_cube_map, // 136
|
||||
IRR_GL_OES_draw_buffers_indexed, // 209
|
||||
IRR_GL_OES_draw_elements_base_vertex, // 219
|
||||
IRR_GL_OES_draw_texture, // 7
|
||||
IRR_GL_OES_element_index_uint, // 26
|
||||
IRR_GL_OES_extended_matrix_palette, // 8
|
||||
IRR_GL_OES_fbo_render_mipmap, // 27
|
||||
IRR_GL_OES_fixed_point, // 9
|
||||
IRR_GL_OES_fragment_precision_high, // 28
|
||||
IRR_GL_OES_framebuffer_object, // 10
|
||||
IRR_GL_OES_geometry_shader, // 210
|
||||
IRR_GL_OES_get_program_binary, // 47
|
||||
IRR_GL_OES_gpu_shader5, // 211
|
||||
IRR_GL_OES_mapbuffer, // 29
|
||||
IRR_GL_OES_matrix_get, // 11
|
||||
IRR_GL_OES_matrix_palette, // 12
|
||||
IRR_GL_OES_packed_depth_stencil, // 44
|
||||
IRR_GL_OES_point_size_array, // 14
|
||||
IRR_GL_OES_point_sprite, // 15
|
||||
IRR_GL_OES_primitive_bounding_box, // 212
|
||||
IRR_GL_OES_query_matrix, // 16
|
||||
IRR_GL_OES_read_format, // 17
|
||||
IRR_GL_OES_required_internalformat, // 115
|
||||
IRR_GL_OES_rgb8_rgba8, // 30
|
||||
IRR_GL_OES_sample_shading, // 169
|
||||
IRR_GL_OES_sample_variables, // 170
|
||||
IRR_GL_OES_shader_image_atomic, // 171
|
||||
IRR_GL_OES_shader_io_blocks, // 213
|
||||
IRR_GL_OES_shader_multisample_interpolation, // 172
|
||||
IRR_GL_OES_single_precision, // 18
|
||||
IRR_GL_OES_standard_derivatives, // 45
|
||||
IRR_GL_OES_stencil1, // 31
|
||||
IRR_GL_OES_stencil4, // 32
|
||||
IRR_GL_OES_stencil8, // 33
|
||||
IRR_GL_OES_stencil_wrap, // 19
|
||||
IRR_GL_OES_surfaceless_context, // 116
|
||||
IRR_GL_OES_tessellation_shader, // 214
|
||||
IRR_GL_OES_texture_3D, // 34
|
||||
IRR_GL_OES_texture_border_clamp, // 215
|
||||
IRR_GL_OES_texture_buffer, // 216
|
||||
IRR_GL_OES_texture_compression_astc, // 162
|
||||
IRR_GL_OES_texture_cube_map, // 20
|
||||
IRR_GL_OES_texture_cube_map_array, // 217
|
||||
IRR_GL_OES_texture_env_crossbar, // 21
|
||||
IRR_GL_OES_texture_float, // 36
|
||||
IRR_GL_OES_texture_float_linear, // 35
|
||||
IRR_GL_OES_texture_half_float, // 36
|
||||
IRR_GL_OES_texture_half_float_linear, // 35
|
||||
IRR_GL_OES_texture_mirrored_repeat, // 22
|
||||
IRR_GL_OES_texture_npot, // 37
|
||||
IRR_GL_OES_texture_stencil8, // 173
|
||||
IRR_GL_OES_texture_storage_multisample_2d_array, // 174
|
||||
IRR_GL_OES_texture_view, // 218
|
||||
IRR_GL_OES_vertex_array_object, // 71
|
||||
IRR_GL_OES_vertex_half_float, // 38
|
||||
IRR_GL_OES_vertex_type_10_10_10_2, // 46
|
||||
IRR_GL_OES_viewport_array, // 267
|
||||
IRR_GL_OVR_multiview, // 241
|
||||
IRR_GL_OVR_multiview2, // 242
|
||||
IRR_GL_OVR_multiview_multisampled_render_to_texture, // 250
|
||||
IRR_GL_QCOM_alpha_test, // 89
|
||||
IRR_GL_QCOM_binning_control, // 119
|
||||
IRR_GL_QCOM_driver_control, // 55
|
||||
IRR_GL_QCOM_extended_get, // 62
|
||||
IRR_GL_QCOM_extended_get2, // 63
|
||||
IRR_GL_QCOM_framebuffer_foveated, // 273
|
||||
IRR_GL_QCOM_performance_monitor_global_mode, // 56
|
||||
IRR_GL_QCOM_shader_framebuffer_fetch_noncoherent, // 277
|
||||
IRR_GL_QCOM_tiled_rendering, // 70
|
||||
IRR_GL_QCOM_writeonly_rendering, // 61
|
||||
IRR_GL_SUN_multi_draw_arrays, // 69
|
||||
IRR_GL_VIV_shader_binary, // 85
|
||||
WGL_ARB_context_flush_control, // 191
|
||||
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
|
||||
};
|
||||
@ -373,319 +90,36 @@ namespace video
|
||||
|
||||
const char* getFeatureString(size_t index) const
|
||||
{
|
||||
// Extension names from https://www.khronos.org/registry/OpenGL/index_es.php
|
||||
// One for each EOGLESFeatures
|
||||
static const char* const OGLESFeatureStrings[IRR_OGLES_Feature_Count] =
|
||||
{
|
||||
"GLX_ARB_context_flush_control",
|
||||
"GL_AMD_compressed_3DC_texture",
|
||||
"GL_AMD_compressed_ATC_texture",
|
||||
"GL_AMD_performance_monitor",
|
||||
"GL_AMD_program_binary_Z400",
|
||||
"GL_ANDROID_extension_pack_es31a",
|
||||
"GL_ANGLE_depth_texture",
|
||||
"GL_ANGLE_framebuffer_blit",
|
||||
"GL_ANGLE_framebuffer_multisample",
|
||||
"GL_ANGLE_instanced_arrays",
|
||||
"GL_ANGLE_pack_reverse_row_order",
|
||||
"GL_ANGLE_program_binary",
|
||||
"GL_ANGLE_texture_compression_dxt1",
|
||||
"GL_ANGLE_texture_compression_dxt3",
|
||||
"GL_ANGLE_texture_compression_dxt5",
|
||||
"GL_ANGLE_texture_usage",
|
||||
"GL_ANGLE_translated_shader_source",
|
||||
"GL_APPLE_clip_distance",
|
||||
"GL_APPLE_color_buffer_packed_float",
|
||||
"GL_APPLE_copy_texture_levels",
|
||||
"GL_APPLE_framebuffer_multisample",
|
||||
"GL_APPLE_rgb_422",
|
||||
"GL_APPLE_sync",
|
||||
"GL_APPLE_texture_2D_limited_npot",
|
||||
"GL_APPLE_texture_format_BGRA8888",
|
||||
"GL_APPLE_texture_max_level",
|
||||
"GL_APPLE_texture_packed_float",
|
||||
"GL_ARB_texture_env_combine",
|
||||
"GL_ARB_texture_env_dot3",
|
||||
"GL_ARM_mali_program_binary",
|
||||
"GL_ARM_mali_shader_binary",
|
||||
"GL_ARM_rgba8",
|
||||
"GL_ARM_shader_framebuffer_fetch",
|
||||
"GL_ARM_shader_framebuffer_fetch_depth_stencil",
|
||||
"GL_DMP_program_binary",
|
||||
"GL_DMP_shader_binary",
|
||||
"GL_EXT_EGL_image_array",
|
||||
"GL_EXT_YUV_target",
|
||||
"GL_EXT_base_instance",
|
||||
"GL_EXT_blend_func_extended",
|
||||
"GL_EXT_blend_minmax",
|
||||
"GL_EXT_buffer_storage",
|
||||
"GL_EXT_clear_texture",
|
||||
"GL_EXT_clip_control",
|
||||
"GL_EXT_clip_cull_distance",
|
||||
"GL_EXT_color_buffer_float",
|
||||
"GL_EXT_color_buffer_half_float",
|
||||
"GL_EXT_compressed_ETC1_RGB8_sub_texture",
|
||||
"GL_EXT_conservative_depth",
|
||||
"GL_EXT_copy_image",
|
||||
"GL_EXT_debug_label",
|
||||
"GL_EXT_debug_marker",
|
||||
"GL_EXT_discard_framebuffer",
|
||||
"GL_EXT_disjoint_timer_query",
|
||||
"GL_EXT_draw_buffers",
|
||||
"GL_EXT_draw_buffers_indexed",
|
||||
"GL_EXT_draw_elements_base_vertex",
|
||||
"GL_EXT_draw_instanced",
|
||||
"GL_EXT_draw_transform_feedback",
|
||||
"GL_EXT_external_buffer",
|
||||
"GL_EXT_float_blend",
|
||||
"GL_EXT_frag_depth",
|
||||
"GL_EXT_geometry_point_size",
|
||||
"GL_EXT_geometry_shader",
|
||||
"GL_EXT_gpu_shader5",
|
||||
"GL_EXT_instanced_arrays",
|
||||
"GL_EXT_map_buffer_range",
|
||||
"GL_EXT_memory_object",
|
||||
"GL_EXT_memory_object_fd",
|
||||
"GL_EXT_memory_object_win32",
|
||||
"GL_EXT_multi_draw_arrays",
|
||||
"GL_EXT_multi_draw_indirect",
|
||||
"GL_EXT_multisample_compatibility",
|
||||
"GL_EXT_multisampled_render_to_texture",
|
||||
"GL_EXT_multisampled_render_to_texture2",
|
||||
"GL_EXT_multiview_draw_buffers",
|
||||
"GL_EXT_occlusion_query_boolean",
|
||||
"GL_EXT_polygon_offset_clamp",
|
||||
"GL_EXT_post_depth_coverage",
|
||||
"GL_EXT_primitive_bounding_box",
|
||||
"GL_EXT_protected_textures",
|
||||
"GL_EXT_pvrtc_sRGB",
|
||||
"GL_EXT_raster_multisample",
|
||||
"GL_EXT_read_format_bgra",
|
||||
"GL_EXT_render_snorm",
|
||||
"GL_EXT_robustness",
|
||||
"GL_EXT_sRGB",
|
||||
"GL_EXT_sRGB_write_control",
|
||||
"GL_EXT_semaphore",
|
||||
"GL_EXT_semaphore_fd",
|
||||
"GL_EXT_semaphore_win32",
|
||||
"GL_EXT_separate_shader_objects",
|
||||
"GL_EXT_shader_framebuffer_fetch",
|
||||
"GL_EXT_shader_group_vote",
|
||||
"GL_EXT_shader_implicit_conversions",
|
||||
"GL_EXT_shader_integer_mix",
|
||||
"GL_EXT_shader_io_blocks",
|
||||
"GL_EXT_shader_non_constant_global_initializers",
|
||||
"GL_EXT_shader_pixel_local_storage",
|
||||
"GL_EXT_shader_pixel_local_storage2",
|
||||
"GL_EXT_shader_texture_lod",
|
||||
"GL_EXT_shadow_samplers",
|
||||
"GL_EXT_sparse_texture",
|
||||
"GL_EXT_sparse_texture2",
|
||||
"GL_EXT_tessellation_point_size",
|
||||
"GL_EXT_tessellation_shader",
|
||||
"GL_EXT_texture_border_clamp",
|
||||
"GL_EXT_texture_buffer",
|
||||
"GL_EXT_texture_compression_astc_decode_mode",
|
||||
"GL_EXT_texture_compression_astc_decode_mode_rgb9e5",
|
||||
"GL_EXT_texture_compression_bptc",
|
||||
"GL_EXT_texture_compression_dxt1",
|
||||
"GL_EXT_texture_compression_rgtc",
|
||||
"GL_EXT_texture_compression_s3tc",
|
||||
"GL_EXT_texture_compression_s3tc_srgb",
|
||||
"GL_EXT_texture_cube_map_array",
|
||||
"GL_EXT_texture_filter_anisotropic",
|
||||
"GL_EXT_texture_filter_minmax",
|
||||
"GL_EXT_texture_format_BGRA8888",
|
||||
"GL_EXT_texture_lod_bias",
|
||||
"GL_EXT_texture_norm16",
|
||||
"GL_EXT_texture_rg",
|
||||
"GL_EXT_texture_sRGB_R8",
|
||||
"GL_EXT_texture_sRGB_RG8",
|
||||
"GL_EXT_texture_sRGB_decode",
|
||||
"GL_EXT_texture_storage",
|
||||
"GL_EXT_texture_type_2_10_10_10_REV",
|
||||
"GL_EXT_texture_view",
|
||||
"GL_EXT_unpack_subimage",
|
||||
"GL_EXT_win32_keyed_mutex",
|
||||
"GL_EXT_window_rectangles",
|
||||
"GL_FJ_shader_binary_GCCSO",
|
||||
"GL_IMG_bindless_texture",
|
||||
"GL_IMG_framebuffer_downsample",
|
||||
"GL_IMG_multisampled_render_to_texture",
|
||||
"GL_IMG_program_binary",
|
||||
"GL_IMG_read_format",
|
||||
"GL_IMG_shader_binary",
|
||||
"GL_IMG_texture_compression_pvrtc",
|
||||
"GL_IMG_texture_compression_pvrtc2",
|
||||
"GL_IMG_texture_env_enhanced_fixed_function",
|
||||
"GL_IMG_texture_format_BGRA8888",
|
||||
"GL_IMG_texture_filter_cubic",
|
||||
"GL_IMG_user_clip_plane",
|
||||
"GL_IMG_vertex_program",
|
||||
"GL_INTEL_conservative_rasterization",
|
||||
"GL_INTEL_framebuffer_CMAA",
|
||||
"GL_INTEL_performance_query",
|
||||
"GL_KHR_blend_equation_advanced",
|
||||
"GL_KHR_blend_equation_advanced_coherent",
|
||||
"GL_KHR_context_flush_control",
|
||||
"GL_KHR_debug",
|
||||
"GL_KHR_no_error",
|
||||
"GL_KHR_parallel_shader_compile",
|
||||
"GL_KHR_robust_buffer_access_behavior",
|
||||
"GL_KHR_robustness",
|
||||
"GL_KHR_texture_compression_astc_hdr",
|
||||
"GL_KHR_texture_compression_astc_ldr",
|
||||
"GL_KHR_texture_compression_astc_sliced_3d",
|
||||
"GL_NVX_blend_equation_advanced_multi_draw_buffers",
|
||||
"GL_NV_3dvision_settings",
|
||||
"GL_NV_EGL_stream_consumer_external",
|
||||
"GL_NV_bgr",
|
||||
"GL_NV_bindless_texture",
|
||||
"GL_NV_blend_equation_advanced",
|
||||
"GL_NV_blend_equation_advanced_coherent",
|
||||
"GL_NV_blend_minmax_factor",
|
||||
"GL_NV_conditional_render",
|
||||
"GL_NV_conservative_raster",
|
||||
"GL_NV_conservative_raster_pre_snap_triangles",
|
||||
"GL_NV_copy_buffer",
|
||||
"GL_NV_coverage_sample",
|
||||
"GL_NV_depth_nonlinear",
|
||||
"GL_NV_draw_buffers",
|
||||
"GL_NV_draw_instanced",
|
||||
"GL_NV_draw_texture",
|
||||
"GL_NV_draw_vulkan_image",
|
||||
"GL_NV_explicit_attrib_location",
|
||||
"GL_NV_fbo_color_attachments",
|
||||
"GL_NV_fence",
|
||||
"GL_NV_fill_rectangle",
|
||||
"GL_NV_fragment_coverage_to_color",
|
||||
"GL_NV_fragment_shader_interlock",
|
||||
"GL_NV_framebuffer_blit",
|
||||
"GL_NV_framebuffer_mixed_samples",
|
||||
"GL_NV_framebuffer_multisample",
|
||||
"GL_NV_generate_mipmap_sRGB",
|
||||
"GL_NV_geometry_shader_passthrough",
|
||||
"GL_NV_gpu_shader5",
|
||||
"GL_NV_image_formats",
|
||||
"GL_NV_instanced_arrays",
|
||||
"GL_NV_internalformat_sample_query",
|
||||
"GL_NV_non_square_matrices",
|
||||
"GL_NV_pack_subimage",
|
||||
"GL_NV_packed_float",
|
||||
"GL_NV_path_rendering",
|
||||
"GL_NV_path_rendering_shared_edge",
|
||||
"GL_NV_pixel_buffer_object",
|
||||
"GL_NV_platform_binary",
|
||||
"GL_NV_polygon_mode",
|
||||
"GL_NV_read_buffer",
|
||||
"GL_NV_read_buffer_front",
|
||||
"GL_NV_read_depth",
|
||||
"GL_NV_read_depth_stencil",
|
||||
"GL_NV_read_stencil",
|
||||
"GL_NV_sRGB_formats",
|
||||
"GL_NV_sample_locations",
|
||||
"GL_NV_sample_mask_override_coverage",
|
||||
"GL_NV_shader_atomic_fp16_vector",
|
||||
"GL_NV_shader_noperspective_interpolation",
|
||||
"GL_NV_shadow_samplers_array",
|
||||
"GL_NV_shadow_samplers_cube",
|
||||
"GL_NV_texture_array",
|
||||
"GL_NV_texture_barrier",
|
||||
"GL_NV_texture_border_clamp",
|
||||
"GL_NV_texture_compression_latc",
|
||||
"GL_NV_texture_compression_s3tc",
|
||||
"GL_NV_texture_compression_s3tc_update",
|
||||
"GL_NV_texture_npot_2D_mipmap",
|
||||
"GL_NV_viewport_array",
|
||||
"GL_NV_viewport_array2",
|
||||
"GL_NV_viewport_swizzle",
|
||||
"GL_OES_EGL_image",
|
||||
"GL_OES_EGL_image_external",
|
||||
"GL_OES_EGL_image_external_essl3",
|
||||
"GL_OES_EGL_sync",
|
||||
"GL_OES_blend_equation_separate",
|
||||
"GL_OES_blend_func_separate",
|
||||
"GL_OES_blend_subtract",
|
||||
"GL_OES_byte_coordinates",
|
||||
"GL_OES_compressed_ETC1_RGB8_texture",
|
||||
"GL_OES_compressed_paletted_texture",
|
||||
"GL_OES_copy_image",
|
||||
"GL_OES_depth_texture",
|
||||
"GL_OES_depth24",
|
||||
"GL_OES_depth32",
|
||||
"GL_OES_depth_texture",
|
||||
"GL_OES_depth_texture_cube_map",
|
||||
"GL_OES_draw_buffers_indexed",
|
||||
"GL_OES_draw_elements_base_vertex",
|
||||
"GL_OES_draw_texture",
|
||||
"GL_OES_element_index_uint",
|
||||
"GL_OES_extended_matrix_palette",
|
||||
"GL_OES_fbo_render_mipmap",
|
||||
"GL_OES_fixed_point",
|
||||
"GL_OES_fragment_precision_high",
|
||||
"GL_OES_framebuffer_object",
|
||||
"GL_OES_geometry_shader",
|
||||
"GL_OES_get_program_binary",
|
||||
"GL_OES_gpu_shader5",
|
||||
"GL_OES_mapbuffer",
|
||||
"GL_OES_matrix_get",
|
||||
"GL_OES_matrix_palette",
|
||||
"GL_OES_packed_depth_stencil",
|
||||
"GL_OES_point_size_array",
|
||||
"GL_OES_point_sprite",
|
||||
"GL_OES_primitive_bounding_box",
|
||||
"GL_OES_query_matrix",
|
||||
"GL_OES_read_format",
|
||||
"GL_OES_required_internalformat",
|
||||
"GL_OES_rgb8_rgba8",
|
||||
"GL_OES_sample_shading",
|
||||
"GL_OES_sample_variables",
|
||||
"GL_OES_shader_image_atomic",
|
||||
"GL_OES_shader_io_blocks",
|
||||
"GL_OES_shader_multisample_interpolation",
|
||||
"GL_OES_single_precision",
|
||||
"GL_OES_standard_derivatives",
|
||||
"GL_OES_stencil1",
|
||||
"GL_OES_stencil4",
|
||||
"GL_OES_stencil8",
|
||||
"GL_OES_stencil_wrap",
|
||||
"GL_OES_surfaceless_context",
|
||||
"GL_OES_tessellation_shader",
|
||||
"GL_OES_texture_3D",
|
||||
"GL_OES_texture_border_clamp",
|
||||
"GL_OES_texture_buffer",
|
||||
"GL_OES_texture_compression_astc",
|
||||
"GL_OES_texture_cube_map",
|
||||
"GL_OES_texture_cube_map_array",
|
||||
"GL_OES_texture_env_crossbar",
|
||||
"GL_OES_texture_float",
|
||||
"GL_OES_texture_float_linear",
|
||||
"GL_OES_texture_half_float",
|
||||
"GL_OES_texture_half_float_linear",
|
||||
"GL_OES_texture_mirrored_repeat",
|
||||
"GL_OES_texture_npot",
|
||||
"GL_OES_texture_stencil8",
|
||||
"GL_OES_texture_storage_multisample_2d_array",
|
||||
"GL_OES_texture_view",
|
||||
"GL_OES_vertex_array_object",
|
||||
"GL_OES_vertex_half_float",
|
||||
"GL_OES_vertex_type_10_10_10_2",
|
||||
"GL_OES_viewport_array",
|
||||
"GL_OVR_multiview",
|
||||
"GL_OVR_multiview2",
|
||||
"GL_OVR_multiview_multisampled_render_to_texture",
|
||||
"GL_QCOM_alpha_test",
|
||||
"GL_QCOM_binning_control",
|
||||
"GL_QCOM_driver_control",
|
||||
"GL_QCOM_extended_get",
|
||||
"GL_QCOM_extended_get2",
|
||||
"GL_QCOM_framebuffer_foveated",
|
||||
"GL_QCOM_performance_monitor_global_mode",
|
||||
"GL_QCOM_shader_framebuffer_fetch_noncoherent",
|
||||
"GL_QCOM_tiled_rendering",
|
||||
"GL_QCOM_writeonly_rendering",
|
||||
"GL_SUN_multi_draw_arrays",
|
||||
"GL_VIV_shader_binary",
|
||||
"WGL_ARB_context_flush_control"
|
||||
};
|
||||
|
||||
return OGLESFeatureStrings[index];
|
||||
@ -721,10 +155,6 @@ namespace video
|
||||
core::stringc extensions = glGetString(GL_EXTENSIONS);
|
||||
os::Printer::log(extensions.c_str());
|
||||
|
||||
// typo in the simulator (note the postfixed s)
|
||||
if (extensions.find("GL_IMG_user_clip_planes"))
|
||||
FeatureAvailable[IRR_GL_IMG_user_clip_plane] = true;
|
||||
|
||||
const u32 size = extensions.size() + 1;
|
||||
c8* str = new c8[size];
|
||||
strncpy(str, extensions.c_str(), extensions.size());
|
||||
|
@ -125,8 +125,6 @@ bool COGLES1Driver::genericDriverInit(const core::dimension2d<u32>& screenSize,
|
||||
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
||||
glHint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
|
||||
glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
|
||||
glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glFrontFace(GL_CW);
|
||||
glAlphaFunc(GL_GREATER, 0.f);
|
||||
@ -1798,33 +1796,15 @@ void COGLES1Driver::setBasicRenderStates(const SMaterial& material, const SMater
|
||||
// Anti aliasing
|
||||
if (resetAllRenderStates || lastmaterial.AntiAliasing != material.AntiAliasing)
|
||||
{
|
||||
// if (FeatureAvailable[IRR_ARB_multisample])
|
||||
{
|
||||
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 (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);
|
||||
}
|
||||
if ((material.AntiAliasing & EAAM_LINE_SMOOTH) != (lastmaterial.AntiAliasing & EAAM_LINE_SMOOTH))
|
||||
{
|
||||
if (material.AntiAliasing & EAAM_LINE_SMOOTH)
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
else if (lastmaterial.AntiAliasing & EAAM_LINE_SMOOTH)
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
}
|
||||
if ((material.AntiAliasing & EAAM_POINT_SMOOTH) != (lastmaterial.AntiAliasing & EAAM_POINT_SMOOTH))
|
||||
{
|
||||
if (material.AntiAliasing & EAAM_POINT_SMOOTH)
|
||||
// often in software, and thus very slow
|
||||
glEnable(GL_POINT_SMOOTH);
|
||||
else if (lastmaterial.AntiAliasing & EAAM_POINT_SMOOTH)
|
||||
glDisable(GL_POINT_SMOOTH);
|
||||
}
|
||||
if ((AntiAlias >= 2) && (material.AntiAliasing & (EAAM_SIMPLE|EAAM_QUALITY)))
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
else
|
||||
glDisable(GL_MULTISAMPLE);
|
||||
}
|
||||
|
||||
// Texture parameters
|
||||
@ -1872,33 +1852,7 @@ void COGLES1Driver::setTextureRenderStates(const SMaterial& material, bool reset
|
||||
if (resetAllRenderstates)
|
||||
statesCache.IsCached = false;
|
||||
|
||||
#ifdef GL_VERSION_2_1
|
||||
if (Version >= 210)
|
||||
{
|
||||
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(tmpTextureType, GL_TEXTURE_LOD_BIAS, tmp);
|
||||
}
|
||||
else
|
||||
glTexParameterf(tmpTextureType, 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 defined(GL_EXT_texture_lod_bias)
|
||||
if (FeatureAvailable[COGLESCoreExtensionHandler::IRR_GL_EXT_texture_lod_bias])
|
||||
{
|
||||
if (material.TextureLayers[i].LODBias)
|
||||
@ -2087,7 +2041,7 @@ void COGLES1Driver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh
|
||||
|
||||
|
||||
//! \return Returns the name of the video driver.
|
||||
const wchar_t* COGLES1Driver::getName() const
|
||||
const char* COGLES1Driver::getName() const
|
||||
{
|
||||
return Name.c_str();
|
||||
}
|
||||
@ -2420,36 +2374,6 @@ bool COGLES1Driver::setPixelShaderConstant(s32 index, const u32* ints, int count
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Sets a vertex shader constant.
|
||||
void COGLES1Driver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
|
||||
{
|
||||
#ifdef GL_vertex_program
|
||||
for (s32 i=0; i<constantAmount; ++i)
|
||||
extGlProgramLocalParameter4fv(GL_VERTEX_PROGRAM, startRegister+i, &data[i*4]);
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Sets a pixel shader constant.
|
||||
void COGLES1Driver::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
|
||||
{
|
||||
#ifdef GL_fragment_program
|
||||
for (s32 i=0; i<constantAmount; ++i)
|
||||
extGlProgramLocalParameter4fv(GL_FRAGMENT_PROGRAM, startRegister+i, &data[i*4]);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//! Adds a new material renderer to the VideoDriver, using pixel and/or
|
||||
//! vertex shaders to render geometry.
|
||||
s32 COGLES1Driver::addShaderMaterial(const c8* vertexShaderProgram,
|
||||
const c8* pixelShaderProgram,
|
||||
IShaderConstantSetCallBack* callback,
|
||||
E_MATERIAL_TYPE baseMaterial, s32 userData)
|
||||
{
|
||||
os::Printer::log("No shader support.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry.
|
||||
s32 COGLES1Driver::addHighLevelShaderMaterial(
|
||||
|
@ -136,7 +136,7 @@ namespace video
|
||||
SColor color = SColor(255,255,255,255)) override;
|
||||
|
||||
//! Returns the name of the video driver.
|
||||
const wchar_t* getName() const override;
|
||||
const char* getName() const override;
|
||||
|
||||
//! Sets the dynamic ambient light color.
|
||||
void setAmbientLight(const SColorf& color) override;
|
||||
@ -201,16 +201,6 @@ namespace video
|
||||
//! Uint interface for the above.
|
||||
bool setPixelShaderConstant(s32 index, const u32* ints, int count) override;
|
||||
|
||||
//! Sets a vertex shader constant.
|
||||
void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) override;
|
||||
|
||||
//! Sets a pixel shader constant.
|
||||
void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) override;
|
||||
|
||||
//! Adds a new material renderer to the VideoDriver
|
||||
virtual s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram,
|
||||
IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData) 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,
|
||||
@ -318,7 +308,7 @@ namespace video
|
||||
|
||||
COGLES1CacheHandler* CacheHandler;
|
||||
|
||||
core::stringw Name;
|
||||
core::stringc Name;
|
||||
core::matrix4 Matrices[ETS_COUNT];
|
||||
core::array<u8> ColorBuffer;
|
||||
|
||||
|
@ -12,13 +12,11 @@
|
||||
#include "SMaterial.h"
|
||||
#include "fast_atof.h"
|
||||
|
||||
#if defined(_IRR_OGLES1_USE_EXTPOINTER_)
|
||||
#if defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_) || defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
|
||||
#include <EGL/egl.h>
|
||||
#else
|
||||
#include <GLES/egl.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace irr
|
||||
{
|
||||
@ -27,12 +25,10 @@ namespace video
|
||||
|
||||
COGLES1ExtensionHandler::COGLES1ExtensionHandler() : COGLESCoreExtensionHandler(),
|
||||
MaxUserClipPlanes(0), MaxLights(0)
|
||||
#if defined(_IRR_OGLES1_USE_EXTPOINTER_)
|
||||
, pGlBlendEquationOES(0), pGlBlendFuncSeparateOES(0),
|
||||
pGlBindFramebufferOES(0), pGlDeleteFramebuffersOES(0),
|
||||
pGlGenFramebuffersOES(0), pGlCheckFramebufferStatusOES(0),
|
||||
pGlFramebufferTexture2DOES(0), pGlGenerateMipmapOES(0)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
@ -84,7 +80,6 @@ namespace video
|
||||
Feature.MaxTextureUnits = core::min_(Feature.MaxTextureUnits, static_cast<u8>(MATERIAL_MAX_TEXTURES));
|
||||
Feature.ColorAttachment = 1;
|
||||
|
||||
#if defined(_IRR_OGLES1_USE_EXTPOINTER_)
|
||||
pGlBlendEquationOES = (PFNGLBLENDEQUATIONOESPROC)eglGetProcAddress("glBlendEquationOES");
|
||||
pGlBlendFuncSeparateOES = (PFNGLBLENDFUNCSEPARATEOESPROC)eglGetProcAddress("glBlendFuncSeparateOES");
|
||||
pGlBindFramebufferOES = (PFNGLBINDFRAMEBUFFEROESPROC)eglGetProcAddress("glBindFramebufferOES");
|
||||
@ -93,7 +88,6 @@ namespace video
|
||||
pGlCheckFramebufferStatusOES = (PFNGLCHECKFRAMEBUFFERSTATUSOESPROC)eglGetProcAddress("glCheckFramebufferStatusOES");
|
||||
pGlFramebufferTexture2DOES = (PFNGLFRAMEBUFFERTEXTURE2DOESPROC)eglGetProcAddress("glFramebufferTexture2DOES");
|
||||
pGlGenerateMipmapOES = (PFNGLGENERATEMIPMAPOESPROC)eglGetProcAddress("glGenerateMipmapOES");
|
||||
#endif
|
||||
}
|
||||
|
||||
} // end namespace video
|
||||
|
@ -83,66 +83,40 @@ namespace video
|
||||
|
||||
inline void irrGlBindFramebuffer(GLenum target, GLuint framebuffer)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlBindFramebufferOES)
|
||||
pGlBindFramebufferOES(target, framebuffer);
|
||||
#elif defined(GL_OES_framebuffer_object)
|
||||
glBindFramebufferOES(target, framebuffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void irrGlDeleteFramebuffers(GLsizei n, const GLuint *framebuffers)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlDeleteFramebuffersOES)
|
||||
pGlDeleteFramebuffersOES(n, framebuffers);
|
||||
#elif defined(GL_OES_framebuffer_object)
|
||||
glDeleteFramebuffersOES(n, framebuffers);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void irrGlGenFramebuffers(GLsizei n, GLuint *framebuffers)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlGenFramebuffersOES)
|
||||
pGlGenFramebuffersOES(n, framebuffers);
|
||||
#elif defined(GL_OES_framebuffer_object)
|
||||
glGenFramebuffersOES(n, framebuffers);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline GLenum irrGlCheckFramebufferStatus(GLenum target)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlCheckFramebufferStatusOES)
|
||||
return pGlCheckFramebufferStatusOES(target);
|
||||
else
|
||||
return 0;
|
||||
#elif defined(GL_OES_framebuffer_object)
|
||||
return glCheckFramebufferStatusOES(target);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void irrGlFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlFramebufferTexture2DOES)
|
||||
pGlFramebufferTexture2DOES(target, attachment, textarget, texture, level);
|
||||
#elif defined(GL_OES_framebuffer_object)
|
||||
glFramebufferTexture2DOES(target, attachment, textarget, texture, level);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void irrGlGenerateMipmap(GLenum target)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlGenerateMipmapOES)
|
||||
pGlGenerateMipmapOES(target);
|
||||
#elif defined(GL_OES_framebuffer_object)
|
||||
glGenerateMipmapOES(target);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void irrGlActiveStencilFace(GLenum face)
|
||||
@ -159,22 +133,14 @@ namespace video
|
||||
|
||||
inline void irrGlBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlBlendFuncSeparateOES)
|
||||
pGlBlendFuncSeparateOES(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||
#elif defined(GL_OES_blend_func_separate)
|
||||
glBlendFuncSeparateOES(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void irrGlBlendEquation(GLenum mode)
|
||||
{
|
||||
#ifdef _IRR_OGLES1_USE_EXTPOINTER_
|
||||
if (pGlBlendEquationOES)
|
||||
pGlBlendEquationOES(mode);
|
||||
#elif defined(GL_OES_blend_subtract)
|
||||
glBlendEquationOES(mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void irrGlEnableIndexed(GLenum target, GLuint index)
|
||||
@ -210,7 +176,6 @@ namespace video
|
||||
u8 MaxUserClipPlanes;
|
||||
u8 MaxLights;
|
||||
|
||||
#if defined(_IRR_OGLES1_USE_EXTPOINTER_)
|
||||
PFNGLBLENDEQUATIONOESPROC pGlBlendEquationOES;
|
||||
PFNGLBLENDFUNCSEPARATEOESPROC pGlBlendFuncSeparateOES;
|
||||
PFNGLBINDFRAMEBUFFEROESPROC pGlBindFramebufferOES;
|
||||
@ -219,7 +184,6 @@ namespace video
|
||||
PFNGLCHECKFRAMEBUFFERSTATUSOESPROC pGlCheckFramebufferStatusOES;
|
||||
PFNGLFRAMEBUFFERTEXTURE2DOESPROC pGlFramebufferTexture2DOES;
|
||||
PFNGLGENERATEMIPMAPOESPROC pGlGenerateMipmapOES;
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -6,162 +6,15 @@
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||
|
||||
#if defined(_IRR_WINDOWS_API_)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
#define GL_GLEXT_LEGACY 1
|
||||
#endif
|
||||
#include <GL/gl.h>
|
||||
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
#include <GL/glext.h>
|
||||
#endif
|
||||
#include <GL/wglext.h>
|
||||
#elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
|
||||
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
#define GL_GLEXT_LEGACY 1
|
||||
#endif
|
||||
#include <OpenGL/gl.h>
|
||||
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
#error glext.h missing on OSX
|
||||
#endif
|
||||
#elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_) && !defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
#define GL_GLEXT_LEGACY 1
|
||||
#else
|
||||
#define GL_GLEXT_PROTOTYPES 1
|
||||
#endif
|
||||
#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) && defined(IRR_PREFER_SDL_GL_HEADER)
|
||||
#include <SDL_video.h>
|
||||
#include <SDL_opengl.h>
|
||||
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
#ifdef __APPLE__
|
||||
#include <SDL_opengl_glext.h>
|
||||
#else
|
||||
#include <GL/glext.h>
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
#define GL_GLEXT_LEGACY 1
|
||||
#define GLX_GLXEXT_LEGACY 1
|
||||
#else
|
||||
#define GL_GLEXT_PROTOTYPES 1
|
||||
#define GLX_GLXEXT_PROTOTYPES 1
|
||||
#endif
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glx.h>
|
||||
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
|
||||
#include <GL/glext.h>
|
||||
#include <GL/glxext.h>
|
||||
#endif
|
||||
#include "vendor/gl.h"
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_shader_objects
|
||||
typedef char GLcharARB;
|
||||
typedef unsigned int GLhandleARB;
|
||||
#endif
|
||||
|
||||
#ifndef GL_VERSION_2_0
|
||||
typedef char GLchar;
|
||||
#endif
|
||||
|
||||
// Blending definitions.
|
||||
|
||||
#if !defined(GL_VERSION_1_4)
|
||||
#if defined(GL_EXT_blend_subtract) || defined(GL_EXT_blend_minmax) || defined(GL_EXT_blend_logic_op)
|
||||
#define GL_FUNC_ADD GL_FUNC_ADD_EXT
|
||||
#else
|
||||
#define GL_FUNC_ADD 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// FBO definitions.
|
||||
|
||||
#if !defined(GL_VERSION_3_0) && !defined(GL_ARB_framebuffer_object)
|
||||
#ifdef GL_EXT_framebuffer_object
|
||||
#define GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT
|
||||
#define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
|
||||
#define GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT
|
||||
#define GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_EXT
|
||||
#define GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT
|
||||
#define GL_FRAMEBUFFER_UNSUPPORTED GL_FRAMEBUFFER_UNSUPPORTED_EXT
|
||||
#else
|
||||
#define GL_FRAMEBUFFER 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_MISSING_ATTACHMENT 4
|
||||
#define GL_FRAMEBUFFER_UNSUPPORTED 5
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GL_EXT_framebuffer_object
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT
|
||||
#else
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS 6
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 7
|
||||
#endif
|
||||
|
||||
// MipMaps definitions.
|
||||
|
||||
#if !defined(GL_VERSION_1_4)
|
||||
#ifdef GL_SGIS_generate_mipmap
|
||||
#define GL_GENERATE_MIPMAP GL_GENERATE_MIPMAP_SGIS
|
||||
#define GL_GENERATE_MIPMAP_HINT GL_GENERATE_MIPMAP_HINT_SGIS
|
||||
#else
|
||||
#define GL_GENERATE_MIPMAP 0
|
||||
#define GL_GENERATE_MIPMAP_HINT 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Texture definitions.
|
||||
|
||||
#if !defined(GL_VERSION_1_3)
|
||||
#ifdef GL_ARB_multitexture
|
||||
#define GL_TEXTURE0 GL_TEXTURE0_ARB
|
||||
#else
|
||||
#define GL_TEXTURE0 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(GL_VERSION_1_3)
|
||||
#ifdef GL_ARB_texture_cube_map
|
||||
#define GL_TEXTURE_CUBE_MAP GL_TEXTURE_CUBE_MAP_ARB
|
||||
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
|
||||
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
|
||||
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
|
||||
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
|
||||
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
|
||||
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
|
||||
#elif defined(GL_EXT_texture_cube_map)
|
||||
#define GL_TEXTURE_CUBE_MAP GL_TEXTURE_CUBE_MAP_EXT
|
||||
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT
|
||||
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT
|
||||
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT
|
||||
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT
|
||||
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT
|
||||
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT
|
||||
#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
|
||||
#endif
|
||||
|
||||
// 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
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "SMaterial.h"
|
||||
#include "ITexture.h"
|
||||
|
||||
#include "mt_opengl.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
@ -87,19 +89,19 @@ class COpenGLCoreCacheHandler
|
||||
|
||||
if (curTextureType != prevTextureType)
|
||||
{
|
||||
glBindTexture(prevTextureType, 0);
|
||||
GL.BindTexture(prevTextureType, 0);
|
||||
|
||||
#if ( defined(IRR_COMPILE_GL_COMMON) || defined(IRR_COMPILE_GLES_COMMON) )
|
||||
glDisable(prevTextureType);
|
||||
glEnable(curTextureType);
|
||||
GL.Disable(prevTextureType);
|
||||
GL.Enable(curTextureType);
|
||||
#endif
|
||||
}
|
||||
#if ( defined(IRR_COMPILE_GL_COMMON) || defined(IRR_COMPILE_GLES_COMMON) )
|
||||
else if (!prevTexture)
|
||||
glEnable(curTextureType);
|
||||
GL.Enable(curTextureType);
|
||||
#endif
|
||||
|
||||
glBindTexture(curTextureType, static_cast<const TOpenGLTexture*>(texture)->getOpenGLTextureName());
|
||||
GL.BindTexture(curTextureType, static_cast<const TOpenGLTexture*>(texture)->getOpenGLTextureName());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -115,10 +117,10 @@ class COpenGLCoreCacheHandler
|
||||
{
|
||||
const GLenum prevTextureType = prevTexture->getOpenGLTextureType();
|
||||
|
||||
glBindTexture(prevTextureType, 0);
|
||||
GL.BindTexture(prevTextureType, 0);
|
||||
|
||||
#if ( defined(IRR_COMPILE_GL_COMMON) || defined(IRR_COMPILE_GLES_COMMON) )
|
||||
glDisable(prevTextureType);
|
||||
GL.Disable(prevTextureType);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -222,28 +224,28 @@ public:
|
||||
ColorMask[i] = ECP_ALL;
|
||||
}
|
||||
|
||||
glBlendFunc(GL_ONE, GL_ZERO);
|
||||
glDisable(GL_BLEND);
|
||||
GL.BlendFunc(GL_ONE, GL_ZERO);
|
||||
GL.Disable(GL_BLEND);
|
||||
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
GL.ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
|
||||
glCullFace(CullFaceMode);
|
||||
glDisable(GL_CULL_FACE);
|
||||
GL.CullFace(CullFaceMode);
|
||||
GL.Disable(GL_CULL_FACE);
|
||||
|
||||
glDepthFunc(DepthFunc);
|
||||
glDepthMask(GL_TRUE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
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) )
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
GL.Disable(GL_TEXTURE_2D);
|
||||
#endif
|
||||
|
||||
const core::dimension2d<u32> ScreenSize = Driver->getScreenSize();
|
||||
ViewportWidth = ScreenSize.Width;
|
||||
ViewportHeight = ScreenSize.Height;
|
||||
glViewport(ViewportX, ViewportY, ViewportWidth, ViewportHeight);
|
||||
GL.Viewport(ViewportX, ViewportY, ViewportWidth, ViewportHeight);
|
||||
}
|
||||
|
||||
virtual ~COpenGLCoreCacheHandler()
|
||||
@ -300,7 +302,7 @@ public:
|
||||
BlendSourceAlpha[0] != source || BlendDestinationAlpha[0] != destination ||
|
||||
BlendFuncInvalid)
|
||||
{
|
||||
glBlendFunc(source, destination);
|
||||
GL.BlendFunc(source, destination);
|
||||
|
||||
for (GLuint i = 0; i < FrameBufferCount; ++i)
|
||||
{
|
||||
@ -383,9 +385,9 @@ public:
|
||||
if (Blend[0] != enable || BlendInvalid)
|
||||
{
|
||||
if (enable)
|
||||
glEnable(GL_BLEND);
|
||||
GL.Enable(GL_BLEND);
|
||||
else
|
||||
glDisable(GL_BLEND);
|
||||
GL.Disable(GL_BLEND);
|
||||
|
||||
for (GLuint i = 0; i < FrameBufferCount; ++i)
|
||||
Blend[i] = enable;
|
||||
@ -419,7 +421,7 @@ public:
|
||||
{
|
||||
if (ColorMask[0] != mask || ColorMaskInvalid)
|
||||
{
|
||||
glColorMask((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);
|
||||
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;
|
||||
@ -445,7 +447,7 @@ public:
|
||||
{
|
||||
if (CullFaceMode != mode)
|
||||
{
|
||||
glCullFace(mode);
|
||||
GL.CullFace(mode);
|
||||
CullFaceMode = mode;
|
||||
}
|
||||
}
|
||||
@ -455,9 +457,9 @@ public:
|
||||
if (CullFace != enable)
|
||||
{
|
||||
if (enable)
|
||||
glEnable(GL_CULL_FACE);
|
||||
GL.Enable(GL_CULL_FACE);
|
||||
else
|
||||
glDisable(GL_CULL_FACE);
|
||||
GL.Disable(GL_CULL_FACE);
|
||||
|
||||
CullFace = enable;
|
||||
}
|
||||
@ -469,7 +471,7 @@ public:
|
||||
{
|
||||
if (DepthFunc != mode)
|
||||
{
|
||||
glDepthFunc(mode);
|
||||
GL.DepthFunc(mode);
|
||||
DepthFunc = mode;
|
||||
}
|
||||
}
|
||||
@ -484,9 +486,9 @@ public:
|
||||
if (DepthMask != enable)
|
||||
{
|
||||
if (enable)
|
||||
glDepthMask(GL_TRUE);
|
||||
GL.DepthMask(GL_TRUE);
|
||||
else
|
||||
glDepthMask(GL_FALSE);
|
||||
GL.DepthMask(GL_FALSE);
|
||||
|
||||
DepthMask = enable;
|
||||
}
|
||||
@ -502,9 +504,9 @@ public:
|
||||
if (DepthTest != enable)
|
||||
{
|
||||
if (enable)
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
GL.Enable(GL_DEPTH_TEST);
|
||||
else
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
GL.Disable(GL_DEPTH_TEST);
|
||||
|
||||
DepthTest = enable;
|
||||
}
|
||||
@ -572,7 +574,7 @@ public:
|
||||
{
|
||||
if (ViewportX != viewportX || ViewportY != viewportY || ViewportWidth != viewportWidth || ViewportHeight != viewportHeight)
|
||||
{
|
||||
glViewport(viewportX, viewportY, viewportWidth, viewportHeight);
|
||||
GL.Viewport(viewportX, viewportY, viewportWidth, viewportHeight);
|
||||
ViewportX = viewportX;
|
||||
ViewportY = viewportY;
|
||||
ViewportWidth = viewportWidth;
|
||||
|
@ -12,10 +12,7 @@
|
||||
#include "CImage.h"
|
||||
#include "CColorConverter.h"
|
||||
|
||||
// Check if GL version we compile with should have the glGenerateMipmap function.
|
||||
#if defined(GL_VERSION_3_0) || defined(GL_ES_VERSION_2_0)
|
||||
#define IRR_OPENGL_HAS_glGenerateMipmap
|
||||
#endif
|
||||
#include "mt_opengl.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
@ -57,6 +54,8 @@ public:
|
||||
KeepImage = Driver->getTextureCreationFlag(ETCF_ALLOW_MEMORY_COPY);
|
||||
|
||||
getImageValues(images[0]);
|
||||
if (!InternalFormat)
|
||||
return;
|
||||
|
||||
const core::array<IImage*>* tmpImages = &images;
|
||||
|
||||
@ -90,32 +89,23 @@ public:
|
||||
tmpImages = &Images;
|
||||
}
|
||||
|
||||
glGenTextures(1, &TextureName);
|
||||
GL.GenTextures(1, &TextureName);
|
||||
|
||||
const COpenGLCoreTexture* prevTexture = Driver->getCacheHandler()->getTextureCache().get(0);
|
||||
Driver->getCacheHandler()->getTextureCache().set(0, this);
|
||||
|
||||
glTexParameteri(TextureType, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(TextureType, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
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))
|
||||
glHint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
|
||||
GL.Hint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
|
||||
else if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_QUALITY))
|
||||
glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
|
||||
GL.Hint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
|
||||
else
|
||||
glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(IRR_OPENGL_HAS_glGenerateMipmap) && defined(GL_GENERATE_MIPMAP)
|
||||
if (HasMipMaps)
|
||||
{
|
||||
LegacyAutoGenerateMipMaps = Driver->getTextureCreationFlag(ETCF_AUTO_GENERATE_MIP_MAPS) &&
|
||||
Driver->queryFeature(EVDF_MIP_MAP_AUTO_UPDATE);
|
||||
glTexParameteri(TextureType, GL_GENERATE_MIPMAP, LegacyAutoGenerateMipMaps ? GL_TRUE : GL_FALSE);
|
||||
GL.Hint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -172,21 +162,22 @@ public:
|
||||
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;
|
||||
}
|
||||
|
||||
glGenTextures(1, &TextureName);
|
||||
GL.GenTextures(1, &TextureName);
|
||||
|
||||
const COpenGLCoreTexture* prevTexture = Driver->getCacheHandler()->getTextureCache().get(0);
|
||||
Driver->getCacheHandler()->getTextureCache().set(0, this);
|
||||
|
||||
|
||||
glTexParameteri(TextureType, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(TextureType, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(TextureType, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(TextureType, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
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)
|
||||
glTexParameteri(TextureType, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||
GL.TexParameteri(TextureType, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||
#endif
|
||||
|
||||
StatesCache.WrapU = ETC_CLAMP_TO_EDGE;
|
||||
@ -196,15 +187,15 @@ public:
|
||||
switch (Type)
|
||||
{
|
||||
case ETT_2D:
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, InternalFormat, Size.Width, Size.Height, 0, PixelFormat, PixelType, 0);
|
||||
GL.TexImage2D(GL_TEXTURE_2D, 0, InternalFormat, Size.Width, Size.Height, 0, PixelFormat, PixelType, 0);
|
||||
break;
|
||||
case ETT_CUBEMAP:
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, InternalFormat, Size.Width, Size.Height, 0, PixelFormat, PixelType, 0);
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, InternalFormat, Size.Width, Size.Height, 0, PixelFormat, PixelType, 0);
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, InternalFormat, Size.Width, Size.Height, 0, PixelFormat, PixelType, 0);
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, InternalFormat, Size.Width, Size.Height, 0, PixelFormat, PixelType, 0);
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, InternalFormat, Size.Width, Size.Height, 0, PixelFormat, PixelType, 0);
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, InternalFormat, Size.Width, Size.Height, 0, PixelFormat, PixelType, 0);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -220,7 +211,7 @@ public:
|
||||
virtual ~COpenGLCoreTexture()
|
||||
{
|
||||
if (TextureName)
|
||||
glDeleteTextures(1, &TextureName);
|
||||
GL.DeleteTextures(1, &TextureName);
|
||||
|
||||
if (LockImage)
|
||||
LockImage->drop();
|
||||
@ -278,7 +269,7 @@ public:
|
||||
tmpTextureType = GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer;
|
||||
}
|
||||
|
||||
glGetTexImage(tmpTextureType, MipLevelStored, PixelFormat, PixelType, tmpImage->getData());
|
||||
GL.GetTexImage(tmpTextureType, MipLevelStored, PixelFormat, PixelType, tmpImage->getData());
|
||||
Driver->testGLError(__LINE__);
|
||||
|
||||
if (IsRenderTarget && lockFlags == ETLF_FLIP_Y_UP_RTT)
|
||||
@ -321,12 +312,12 @@ public:
|
||||
|
||||
Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tmpTexture->getOpenGLTextureName(), 0);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
GL.Clear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
Driver->draw2DImage(this, layer, true);
|
||||
|
||||
IImage* tmpImage = Driver->createImage(ECF_A8R8G8B8, Size);
|
||||
glReadPixels(0, 0, Size.Width, Size.Height, GL_RGBA, GL_UNSIGNED_BYTE, tmpImage->getData());
|
||||
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);
|
||||
@ -428,9 +419,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef IRR_OPENGL_HAS_glGenerateMipmap
|
||||
Driver->irrGlGenerateMipmap(TextureType);
|
||||
#endif
|
||||
}
|
||||
|
||||
Driver->getCacheHandler()->getTextureCache().set(0, prevTexture);
|
||||
@ -517,7 +506,8 @@ protected:
|
||||
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);
|
||||
// not quitting as it will use some alternative internal format
|
||||
InternalFormat = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (IImage::isCompressedFormat(image->getColorFormat()))
|
||||
@ -595,9 +585,9 @@ protected:
|
||||
case GL_TEXTURE_2D:
|
||||
case GL_TEXTURE_CUBE_MAP:
|
||||
if (initTexture)
|
||||
glTexImage2D(tmpTextureType, level, InternalFormat, width, height, 0, PixelFormat, PixelType, tmpData);
|
||||
GL.TexImage2D(tmpTextureType, level, InternalFormat, width, height, 0, PixelFormat, PixelType, tmpData);
|
||||
else
|
||||
glTexSubImage2D(tmpTextureType, level, 0, 0, width, height, PixelFormat, PixelType, tmpData);
|
||||
GL.TexSubImage2D(tmpTextureType, level, 0, 0, width, height, PixelFormat, PixelType, tmpData);
|
||||
Driver->testGLError(__LINE__);
|
||||
break;
|
||||
default:
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
#include "COpenGLCacheHandler.h"
|
||||
#include "COpenGLMaterialRenderer.h"
|
||||
#include "COpenGLShaderMaterialRenderer.h"
|
||||
#include "COpenGLSLMaterialRenderer.h"
|
||||
|
||||
#include "COpenGLCoreTexture.h"
|
||||
@ -45,6 +44,7 @@ bool COpenGLDriver::initDriver()
|
||||
ContextManager->generateContext();
|
||||
ExposedData = ContextManager->getContext();
|
||||
ContextManager->activateContext(ExposedData, false);
|
||||
GL.LoadAllProcedures(ContextManager);
|
||||
|
||||
genericDriverInit();
|
||||
|
||||
@ -52,8 +52,6 @@ bool COpenGLDriver::initDriver()
|
||||
extGlSwapInterval(Params.Vsync ? 1 : 0);
|
||||
#endif
|
||||
|
||||
GL.LoadAllProcedures(ContextManager);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -90,9 +88,9 @@ bool COpenGLDriver::genericDriverInit()
|
||||
if (ContextManager)
|
||||
ContextManager->grab();
|
||||
|
||||
Name=L"OpenGL ";
|
||||
Name="OpenGL ";
|
||||
Name.append(glGetString(GL_VERSION));
|
||||
s32 pos=Name.findNext(L' ', 7);
|
||||
s32 pos=Name.findNext(' ', 7);
|
||||
if (pos != -1)
|
||||
Name=Name.subString(0, pos);
|
||||
printVersion();
|
||||
@ -109,7 +107,7 @@ bool COpenGLDriver::genericDriverInit()
|
||||
u32 i;
|
||||
|
||||
// load extensions
|
||||
initExtensions(Params.Stencilbuffer);
|
||||
initExtensions(ContextManager, Params.Stencilbuffer);
|
||||
|
||||
// reset cache handler
|
||||
delete CacheHandler;
|
||||
@ -171,8 +169,6 @@ bool COpenGLDriver::genericDriverInit()
|
||||
|
||||
glClearDepth(1.0);
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
||||
glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST);
|
||||
glFrontFace(GL_CW);
|
||||
// adjust flat coloring scheme to DirectX version
|
||||
#if defined(GL_ARB_provoking_vertex) || defined(GL_EXT_provoking_vertex)
|
||||
@ -2557,46 +2553,29 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
|
||||
}
|
||||
|
||||
// Anti aliasing
|
||||
if (resetAllRenderStates || lastmaterial.AntiAliasing != material.AntiAliasing)
|
||||
{
|
||||
if (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 ((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);
|
||||
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
|
||||
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);
|
||||
}
|
||||
else
|
||||
glDisable(GL_MULTISAMPLE_ARB);
|
||||
}
|
||||
if ((material.AntiAliasing & EAAM_LINE_SMOOTH) != (lastmaterial.AntiAliasing & EAAM_LINE_SMOOTH))
|
||||
{
|
||||
if (material.AntiAliasing & EAAM_LINE_SMOOTH)
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
else if (lastmaterial.AntiAliasing & EAAM_LINE_SMOOTH)
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
}
|
||||
if ((material.AntiAliasing & EAAM_POINT_SMOOTH) != (lastmaterial.AntiAliasing & EAAM_POINT_SMOOTH))
|
||||
{
|
||||
if (material.AntiAliasing & EAAM_POINT_SMOOTH)
|
||||
// often in software, and thus very slow
|
||||
glEnable(GL_POINT_SMOOTH);
|
||||
else if (lastmaterial.AntiAliasing & EAAM_POINT_SMOOTH)
|
||||
glDisable(GL_POINT_SMOOTH);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
glDisable(GL_MULTISAMPLE_ARB);
|
||||
}
|
||||
|
||||
// Texture parameters
|
||||
@ -2939,7 +2918,7 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh
|
||||
|
||||
|
||||
//! \return Returns the name of the video driver.
|
||||
const wchar_t* COpenGLDriver::getName() const
|
||||
const char* COpenGLDriver::getName() const
|
||||
{
|
||||
return Name.c_str();
|
||||
}
|
||||
@ -3403,20 +3382,6 @@ s32 COpenGLDriver::getPixelShaderConstantID(const c8* name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
//! Sets a vertex shader constant.
|
||||
void COpenGLDriver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
|
||||
{
|
||||
for (s32 i=0; i<constantAmount; ++i)
|
||||
extGlProgramLocalParameter4fv(GL_VERTEX_PROGRAM_ARB, startRegister+i, &data[i*4]);
|
||||
}
|
||||
|
||||
//! Sets a pixel shader constant.
|
||||
void COpenGLDriver::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
|
||||
{
|
||||
for (s32 i=0; i<constantAmount; ++i)
|
||||
extGlProgramLocalParameter4fv(GL_FRAGMENT_PROGRAM_ARB, startRegister+i, &data[i*4]);
|
||||
}
|
||||
|
||||
//! Sets a constant for the vertex shader based on an index.
|
||||
bool COpenGLDriver::setVertexShaderConstant(s32 index, const f32* floats, int count)
|
||||
{
|
||||
@ -3457,23 +3422,6 @@ bool COpenGLDriver::setPixelShaderConstant(s32 index, const u32* ints, int count
|
||||
}
|
||||
|
||||
|
||||
//! Adds a new material renderer to the VideoDriver, using pixel and/or
|
||||
//! vertex shaders to render geometry.
|
||||
s32 COpenGLDriver::addShaderMaterial(const c8* vertexShaderProgram,
|
||||
const c8* pixelShaderProgram,
|
||||
IShaderConstantSetCallBack* callback,
|
||||
E_MATERIAL_TYPE baseMaterial, s32 userData)
|
||||
{
|
||||
s32 nr = -1;
|
||||
COpenGLShaderMaterialRenderer* r = new COpenGLShaderMaterialRenderer(
|
||||
this, nr, vertexShaderProgram, pixelShaderProgram,
|
||||
callback, baseMaterial, userData);
|
||||
|
||||
r->drop();
|
||||
return nr;
|
||||
}
|
||||
|
||||
|
||||
//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry.
|
||||
s32 COpenGLDriver::addHighLevelShaderMaterial(
|
||||
const c8* vertexShaderProgram,
|
||||
|
@ -205,7 +205,7 @@ namespace video
|
||||
|
||||
//! \return Returns the name of the video driver. Example: In case of the Direct3D8
|
||||
//! driver, it would return "Direct3D8.1".
|
||||
const wchar_t* getName() const override;
|
||||
const char* getName() const override;
|
||||
|
||||
//! Sets the dynamic ambient light color. The default color is
|
||||
//! (0,0,0,0) which means it is dark.
|
||||
@ -259,12 +259,6 @@ namespace video
|
||||
//! Get a pixel shader constant index.
|
||||
s32 getPixelShaderConstantID(const c8* name) override;
|
||||
|
||||
//! Sets a vertex shader constant.
|
||||
void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) override;
|
||||
|
||||
//! Sets a pixel shader constant.
|
||||
void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) override;
|
||||
|
||||
//! Sets a constant for the vertex shader based on an index.
|
||||
bool setVertexShaderConstant(s32 index, const f32* floats, int count) override;
|
||||
|
||||
@ -287,12 +281,6 @@ namespace video
|
||||
//! Returns whether disabling was successful or not.
|
||||
bool disableTextures(u32 fromStage=0);
|
||||
|
||||
//! Adds a new material renderer to the VideoDriver, using
|
||||
//! extGLGetObjectParameteriv(shaderHandle, GL_OBJECT_COMPILE_STATUS_ARB, &status)
|
||||
//! pixel and/or vertex shaders to render geometry.
|
||||
virtual s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram,
|
||||
IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData) override;
|
||||
|
||||
//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry.
|
||||
virtual s32 addHighLevelShaderMaterial(
|
||||
const c8* vertexShaderProgram,
|
||||
@ -439,7 +427,7 @@ namespace video
|
||||
|
||||
COpenGLCacheHandler* CacheHandler;
|
||||
|
||||
core::stringw Name;
|
||||
core::stringc Name;
|
||||
core::matrix4 Matrices[ETS_COUNT];
|
||||
core::array<u8> ColorBuffer;
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "irrString.h"
|
||||
#include "SMaterial.h"
|
||||
#include "fast_atof.h"
|
||||
#include "IContextManager.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
@ -23,7 +24,6 @@ COpenGLExtensionHandler::COpenGLExtensionHandler() :
|
||||
MaxTextureSize(1), MaxGeometryVerticesOut(0),
|
||||
MaxTextureLODBias(0.f), Version(0), ShaderLanguageVersion(0),
|
||||
OcclusionQuerySupport(false), IsAtiRadeonX(false)
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
,pGlActiveTexture(0)
|
||||
,pGlActiveTextureARB(0), pGlClientActiveTextureARB(0),
|
||||
pGlGenProgramsARB(0), pGlGenProgramsNV(0),
|
||||
@ -105,7 +105,6 @@ COpenGLExtensionHandler::COpenGLExtensionHandler() :
|
||||
#if defined(GLX_MESA_swap_control)
|
||||
,pGlxSwapIntervalMESA(0)
|
||||
#endif
|
||||
#endif // _IRR_OPENGL_USE_EXTPOINTER_
|
||||
{
|
||||
for (u32 i=0; i<IRR_OpenGL_Feature_Count; ++i)
|
||||
FeatureAvailable[i]=false;
|
||||
@ -127,7 +126,7 @@ void COpenGLExtensionHandler::dump(ELOG_LEVEL logLevel) const
|
||||
}
|
||||
|
||||
|
||||
void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
|
||||
void COpenGLExtensionHandler::initExtensions(video::IContextManager *cmgr, bool stencilBuffer)
|
||||
{
|
||||
const f32 ogl_ver = core::fast_atof(reinterpret_cast<const c8*>(glGetString(GL_VERSION)));
|
||||
Version = static_cast<u16>(core::floor32(ogl_ver)*100+core::round32(core::fract(ogl_ver)*10.0f));
|
||||
@ -179,37 +178,7 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
|
||||
IsAtiRadeonX = (strncmp(renderer, "ATI RADEON X", 12) == 0) || (strncmp(renderer, "ATI MOBILITY RADEON X", 21) == 0);
|
||||
}
|
||||
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
#ifdef _IRR_WINDOWS_API_
|
||||
#define IRR_OGL_LOAD_EXTENSION(x) wglGetProcAddress(reinterpret_cast<const char*>(x))
|
||||
#elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_) && !defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
#define IRR_OGL_LOAD_EXTENSION(x) SDL_GL_GetProcAddress(reinterpret_cast<const char*>(x))
|
||||
#else
|
||||
// Accessing the correct function is quite complex
|
||||
// All libraries should support the ARB version, however
|
||||
// since GLX 1.4 the non-ARB version is the official one
|
||||
// So we have to check the runtime environment and
|
||||
// choose the proper symbol
|
||||
// In case you still have problems please enable the
|
||||
// next line by uncommenting it
|
||||
// #define _IRR_GETPROCADDRESS_WORKAROUND_
|
||||
|
||||
#ifndef _IRR_GETPROCADDRESS_WORKAROUND_
|
||||
__GLXextFuncPtr (*IRR_OGL_LOAD_EXTENSION_FUNCP)(const GLubyte*)=0;
|
||||
#ifdef GLX_VERSION_1_4
|
||||
int major=0,minor=0;
|
||||
if (glXGetCurrentDisplay())
|
||||
glXQueryVersion(glXGetCurrentDisplay(), &major, &minor);
|
||||
if ((major>1) || (minor>3))
|
||||
IRR_OGL_LOAD_EXTENSION_FUNCP=glXGetProcAddress;
|
||||
else
|
||||
#endif
|
||||
IRR_OGL_LOAD_EXTENSION_FUNCP=glXGetProcAddressARB;
|
||||
#define IRR_OGL_LOAD_EXTENSION(X) IRR_OGL_LOAD_EXTENSION_FUNCP(reinterpret_cast<const GLubyte*>(X))
|
||||
#else
|
||||
#define IRR_OGL_LOAD_EXTENSION(X) glXGetProcAddressARB(reinterpret_cast<const GLubyte*>(X))
|
||||
#endif // workaround
|
||||
#endif // Windows, SDL, or Linux
|
||||
#define IRR_OGL_LOAD_EXTENSION(x) cmgr->getProcAddress(x)
|
||||
|
||||
// get multitexturing function pointers
|
||||
pGlActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) IRR_OGL_LOAD_EXTENSION("glActiveTextureARB");
|
||||
@ -412,7 +381,6 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
|
||||
#if defined(GLX_MESA_swap_control) && !defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
|
||||
pGlxSwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)IRR_OGL_LOAD_EXTENSION("glXSwapIntervalMESA");
|
||||
#endif
|
||||
#endif // use extension pointer
|
||||
|
||||
GLint num=0;
|
||||
// set some properties
|
||||
@ -533,14 +501,12 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
if (!pGlActiveTextureARB || !pGlClientActiveTextureARB)
|
||||
{
|
||||
Feature.MaxTextureUnits = 1;
|
||||
os::Printer::log("Failed to load OpenGL's multitexture extension, proceeding without.", ELL_WARNING);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
Feature.MaxTextureUnits = core::min_(Feature.MaxTextureUnits, static_cast<u8>(MATERIAL_MAX_TEXTURES));
|
||||
|
||||
#ifdef GL_ARB_occlusion_query
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -571,16 +571,6 @@ s32 COpenGLSLMaterialRenderer::getPixelShaderConstantID(const c8* name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void COpenGLSLMaterialRenderer::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
|
||||
{
|
||||
os::Printer::log("Cannot set constant, please use high level shader call instead.", ELL_WARNING);
|
||||
}
|
||||
|
||||
void COpenGLSLMaterialRenderer::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
|
||||
{
|
||||
os::Printer::log("Cannot set constant, use high level shader call.", ELL_WARNING);
|
||||
}
|
||||
|
||||
bool COpenGLSLMaterialRenderer::setVertexShaderConstant(s32 index, const f32* floats, int count)
|
||||
{
|
||||
return setPixelShaderConstant(index, floats, count);
|
||||
|
@ -72,8 +72,6 @@ public:
|
||||
void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates) override;
|
||||
s32 getVertexShaderConstantID(const c8* name) override;
|
||||
s32 getPixelShaderConstantID(const c8* name) override;
|
||||
void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) override;
|
||||
void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) 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;
|
||||
|
@ -1,403 +0,0 @@
|
||||
// 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 "COpenGLShaderMaterialRenderer.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||
|
||||
#include "IGPUProgrammingServices.h"
|
||||
#include "IShaderConstantSetCallBack.h"
|
||||
#include "IVideoDriver.h"
|
||||
#include "os.h"
|
||||
|
||||
#include "COpenGLDriver.h"
|
||||
#include "COpenGLCacheHandler.h"
|
||||
#include "COpenGLMaterialRenderer.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
|
||||
//! Constructor
|
||||
COpenGLShaderMaterialRenderer::COpenGLShaderMaterialRenderer(video::COpenGLDriver* 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), AlphaTest(false),
|
||||
VertexShader(0), UserData(userData)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("COpenGLShaderMaterialRenderer");
|
||||
#endif
|
||||
|
||||
PixelShader.set_used(4);
|
||||
for (u32 i=0; i<4; ++i)
|
||||
{
|
||||
PixelShader[i]=0;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram, EVT_STANDARD);
|
||||
}
|
||||
|
||||
|
||||
//! constructor only for use by derived classes who want to
|
||||
//! create a fall back material for example.
|
||||
COpenGLShaderMaterialRenderer::COpenGLShaderMaterialRenderer(COpenGLDriver* driver,
|
||||
IShaderConstantSetCallBack* callback,
|
||||
E_MATERIAL_TYPE baseMaterial, s32 userData)
|
||||
: Driver(driver), CallBack(callback), Alpha(false), Blending(false), AlphaTest(false),
|
||||
VertexShader(0), UserData(userData)
|
||||
{
|
||||
PixelShader.set_used(4);
|
||||
for (u32 i=0; i<4; ++i)
|
||||
{
|
||||
PixelShader[i]=0;
|
||||
}
|
||||
|
||||
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
|
||||
COpenGLShaderMaterialRenderer::~COpenGLShaderMaterialRenderer()
|
||||
{
|
||||
if (CallBack)
|
||||
CallBack->drop();
|
||||
|
||||
if (VertexShader)
|
||||
Driver->extGlDeletePrograms(1, &VertexShader);
|
||||
|
||||
for (u32 i=0; i<PixelShader.size(); ++i)
|
||||
if (PixelShader[i])
|
||||
Driver->extGlDeletePrograms(1, &PixelShader[i]);
|
||||
}
|
||||
|
||||
|
||||
void COpenGLShaderMaterialRenderer::init(s32& outMaterialTypeNr,
|
||||
const c8* vertexShaderProgram, const c8* pixelShaderProgram,
|
||||
E_VERTEX_TYPE type)
|
||||
{
|
||||
outMaterialTypeNr = -1;
|
||||
|
||||
bool success;
|
||||
|
||||
// create vertex shader
|
||||
success=createVertexShader(vertexShaderProgram);
|
||||
|
||||
// create pixel shader
|
||||
if (!createPixelShader(pixelShaderProgram) || !success)
|
||||
return;
|
||||
|
||||
// register as a new material
|
||||
outMaterialTypeNr = Driver->addMaterialRenderer(this);
|
||||
}
|
||||
|
||||
|
||||
bool COpenGLShaderMaterialRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype)
|
||||
{
|
||||
// call callback to set shader constants
|
||||
if (CallBack && (VertexShader || PixelShader[0]))
|
||||
CallBack->OnSetConstants(service, UserData);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void COpenGLShaderMaterialRenderer::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 (VertexShader)
|
||||
{
|
||||
// set new vertex shader
|
||||
#ifdef GL_ARB_vertex_program
|
||||
Driver->extGlBindProgram(GL_VERTEX_PROGRAM_ARB, VertexShader);
|
||||
glEnable(GL_VERTEX_PROGRAM_ARB);
|
||||
#elif defined(GL_NV_vertex_program)
|
||||
Driver->extGlBindProgram(GL_VERTEX_PROGRAM_NV, VertexShader);
|
||||
glEnable(GL_VERTEX_PROGRAM_NV);
|
||||
#endif
|
||||
}
|
||||
|
||||
// set new pixel shader
|
||||
if (PixelShader[0])
|
||||
{
|
||||
GLuint nextShader=PixelShader[0];
|
||||
if (material.FogEnable)
|
||||
{
|
||||
GLint curFogMode;
|
||||
glGetIntegerv(GL_FOG_MODE, &curFogMode);
|
||||
// if (Driver->LinearFog && PixelShader[1])
|
||||
if (curFogMode==GL_LINEAR && PixelShader[1])
|
||||
nextShader=PixelShader[1];
|
||||
// else if (!Driver->LinearFog && PixelShader[2])
|
||||
else if (curFogMode==GL_EXP && PixelShader[2])
|
||||
nextShader=PixelShader[2];
|
||||
else if (curFogMode==GL_EXP2 && PixelShader[3])
|
||||
nextShader=PixelShader[3];
|
||||
}
|
||||
#ifdef GL_ARB_fragment_program
|
||||
Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_ARB, nextShader);
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
#elif defined(GL_NV_fragment_program)
|
||||
Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_NV, nextShader);
|
||||
glEnable(GL_FRAGMENT_PROGRAM_NV);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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 COpenGLShaderMaterialRenderer::OnUnsetMaterial()
|
||||
{
|
||||
// disable vertex shader
|
||||
#ifdef GL_ARB_vertex_program
|
||||
if (VertexShader)
|
||||
glDisable(GL_VERTEX_PROGRAM_ARB);
|
||||
#elif defined(GL_NV_vertex_program)
|
||||
if (VertexShader)
|
||||
glDisable(GL_VERTEX_PROGRAM_NV);
|
||||
#endif
|
||||
|
||||
#ifdef GL_ARB_fragment_program
|
||||
if (PixelShader[0])
|
||||
glDisable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
#elif defined(GL_NV_fragment_program)
|
||||
if (PixelShader[0])
|
||||
glDisable(GL_FRAGMENT_PROGRAM_NV);
|
||||
#endif
|
||||
|
||||
COpenGLCacheHandler* cacheHandler = Driver->getCacheHandler();
|
||||
if (Alpha || Blending)
|
||||
{
|
||||
cacheHandler->setBlend(false);
|
||||
}
|
||||
else if (AlphaTest)
|
||||
{
|
||||
cacheHandler->setAlphaTest(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Returns if the material is transparent.
|
||||
bool COpenGLShaderMaterialRenderer::isTransparent() const
|
||||
{
|
||||
return (Alpha || Blending);
|
||||
}
|
||||
|
||||
|
||||
// This method needs a properly cleaned error state before the checked instruction is called
|
||||
bool COpenGLShaderMaterialRenderer::checkError(const irr::c8* type)
|
||||
{
|
||||
#if defined(GL_ARB_vertex_program) || defined(GL_NV_vertex_program) || defined(GL_ARB_fragment_program) || defined(GL_NV_fragment_program)
|
||||
GLenum g = glGetError();
|
||||
if (g == GL_NO_ERROR)
|
||||
return false;
|
||||
|
||||
core::stringc errString = type;
|
||||
errString += " compilation failed";
|
||||
|
||||
errString += " at position ";
|
||||
GLint errPos=-1;
|
||||
#if defined(GL_ARB_vertex_program) || defined(GL_ARB_fragment_program)
|
||||
glGetIntegerv( GL_PROGRAM_ERROR_POSITION_ARB, &errPos );
|
||||
#else
|
||||
glGetIntegerv( GL_PROGRAM_ERROR_POSITION_NV, &errPos );
|
||||
#endif
|
||||
errString += core::stringc(s32(errPos));
|
||||
errString += ":\n";
|
||||
#if defined(GL_ARB_vertex_program) || defined(GL_ARB_fragment_program)
|
||||
errString += reinterpret_cast<const char*>(glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
#else
|
||||
errString += reinterpret_cast<const char*>(glGetString(GL_PROGRAM_ERROR_STRING_NV));
|
||||
#endif
|
||||
#else
|
||||
core::stringc errString("Shaders not supported.");
|
||||
#endif
|
||||
os::Printer::log(errString.c_str(), ELL_ERROR);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool COpenGLShaderMaterialRenderer::createPixelShader(const c8* pxsh)
|
||||
{
|
||||
if (!pxsh)
|
||||
return true;
|
||||
|
||||
const core::stringc inshdr(pxsh);
|
||||
core::stringc shdr;
|
||||
const s32 pos = inshdr.find("#_IRR_FOG_MODE_");
|
||||
const u32 numShaders = (-1 != pos)?4:1;
|
||||
|
||||
for (u32 i=0; i<numShaders; ++i)
|
||||
{
|
||||
if (i==0)
|
||||
{
|
||||
shdr=inshdr;
|
||||
}
|
||||
else
|
||||
{
|
||||
shdr = inshdr.subString(0, pos);
|
||||
switch (i) {
|
||||
case 1: shdr += "OPTION ARB_fog_linear;"; break;
|
||||
case 2: shdr += "OPTION ARB_fog_exp;"; break;
|
||||
case 3: shdr += "OPTION ARB_fog_exp2;"; break;
|
||||
}
|
||||
shdr += inshdr.subString(pos+16, inshdr.size()-pos-16);
|
||||
}
|
||||
Driver->extGlGenPrograms(1, &PixelShader[i]);
|
||||
#ifdef GL_ARB_fragment_program
|
||||
Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_ARB, PixelShader[i]);
|
||||
#elif defined GL_NV_fragment_program
|
||||
Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_NV, PixelShader[i]);
|
||||
#endif
|
||||
|
||||
// clear error buffer
|
||||
while(glGetError() != GL_NO_ERROR)
|
||||
{}
|
||||
|
||||
#ifdef GL_ARB_fragment_program
|
||||
// compile
|
||||
Driver->extGlProgramString(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
shdr.size(), shdr.c_str());
|
||||
#elif defined GL_NV_fragment_program
|
||||
Driver->extGlLoadProgram(GL_FRAGMENT_PROGRAM_NV, PixelShader[i],
|
||||
shdr.size(), shdr.c_str());
|
||||
#endif
|
||||
|
||||
if (checkError("Pixel shader"))
|
||||
{
|
||||
Driver->extGlDeletePrograms(1, &PixelShader[i]);
|
||||
PixelShader[i]=0;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool COpenGLShaderMaterialRenderer::createVertexShader(const c8* vtxsh)
|
||||
{
|
||||
if (!vtxsh)
|
||||
return true;
|
||||
|
||||
Driver->extGlGenPrograms(1, &VertexShader);
|
||||
#ifdef GL_ARB_vertex_program
|
||||
Driver->extGlBindProgram(GL_VERTEX_PROGRAM_ARB, VertexShader);
|
||||
#elif defined GL_NV_vertex_program
|
||||
Driver->extGlBindProgram(GL_VERTEX_PROGRAM_NV, VertexShader);
|
||||
#endif
|
||||
|
||||
// clear error buffer
|
||||
while(glGetError() != GL_NO_ERROR)
|
||||
{}
|
||||
|
||||
// compile
|
||||
#ifdef GL_ARB_vertex_program
|
||||
Driver->extGlProgramString(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
(GLsizei)strlen(vtxsh), vtxsh);
|
||||
#elif defined GL_NV_vertex_program
|
||||
Driver->extGlLoadProgram(GL_VERTEX_PROGRAM_NV, VertexShader,
|
||||
(GLsizei)strlen(vtxsh), vtxsh);
|
||||
#endif
|
||||
|
||||
if (checkError("Vertex shader"))
|
||||
{
|
||||
Driver->extGlDeletePrograms(1, &VertexShader);
|
||||
VertexShader=0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
@ -1,91 +0,0 @@
|
||||
// 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 "COpenGLCommon.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
class COpenGLDriver;
|
||||
class IShaderConstantSetCallBack;
|
||||
|
||||
//! Class for using vertex and pixel shaders with OpenGL (asm not glsl!)
|
||||
class COpenGLShaderMaterialRenderer : public IMaterialRenderer
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
COpenGLShaderMaterialRenderer(COpenGLDriver* driver,
|
||||
s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram,
|
||||
IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData);
|
||||
|
||||
//! Destructor
|
||||
virtual ~COpenGLShaderMaterialRenderer();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//! constructor only for use by derived classes who want to
|
||||
//! create a fall back material for example.
|
||||
COpenGLShaderMaterialRenderer(COpenGLDriver* driver,
|
||||
IShaderConstantSetCallBack* callback,
|
||||
E_MATERIAL_TYPE baseMaterial, s32 userData=0);
|
||||
|
||||
// must not be called more than once!
|
||||
void init(s32& outMaterialTypeNr, const c8* vertexShaderProgram,
|
||||
const c8* pixelShaderProgram, E_VERTEX_TYPE type);
|
||||
|
||||
bool createPixelShader(const c8* pxsh);
|
||||
bool createVertexShader(const c8* vtxsh);
|
||||
bool checkError(const irr::c8* type);
|
||||
|
||||
COpenGLDriver* Driver;
|
||||
IShaderConstantSetCallBack* CallBack;
|
||||
|
||||
// I didn't write this, but here's my understanding:
|
||||
// Those flags seem to be exclusive so far (so could be an enum).
|
||||
// Maybe the idea was to make them non-exclusive in future (basically having a shader-material)
|
||||
// Actually currently there's not even any need to cache them (probably even slower than not doing so).
|
||||
// They seem to be mostly for downward compatibility.
|
||||
// I suppose the idea is to use SMaterial.BlendOperation + SMaterial.BlendFactor and a simple non-transparent type as base for more flexibility in the future.
|
||||
// Note that SMaterial.BlendOperation + SMaterial.BlendFactor are in some drivers already evaluated before OnSetMaterial.
|
||||
bool Alpha;
|
||||
bool Blending;
|
||||
bool AlphaTest;
|
||||
|
||||
GLuint VertexShader;
|
||||
// We have 4 values here, [0] is the non-fog version, the other three are
|
||||
// ARB_fog_linear, ARB_fog_exp, and ARB_fog_exp2 in that order
|
||||
core::array<GLuint> PixelShader;
|
||||
s32 UserData;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
@ -697,7 +697,8 @@ ISceneNode* CSceneManager::getSceneNodeFromName(const char* name, ISceneNode* st
|
||||
if (start == 0)
|
||||
start = getRootSceneNode();
|
||||
|
||||
if (!strcmp(start->getName(),name))
|
||||
auto startName = start->getName();
|
||||
if (startName.has_value() && startName == name)
|
||||
return start;
|
||||
|
||||
ISceneNode* node = 0;
|
||||
|
@ -3,6 +3,7 @@
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "CSkinnedMesh.h"
|
||||
#include <optional>
|
||||
#include "CBoneSceneNode.h"
|
||||
#include "IAnimatedMeshSceneNode.h"
|
||||
#include "os.h"
|
||||
@ -624,18 +625,18 @@ u32 CSkinnedMesh::getJointCount() const
|
||||
return AllJoints.size();
|
||||
}
|
||||
|
||||
|
||||
//! Gets the name of a joint.
|
||||
const c8* CSkinnedMesh::getJointName(u32 number) const
|
||||
{
|
||||
if (number >= AllJoints.size())
|
||||
return 0;
|
||||
return AllJoints[number]->Name.c_str();
|
||||
const std::optional<std::string> &CSkinnedMesh::getJointName(u32 number) const {
|
||||
if (number >= getJointCount()) {
|
||||
static const std::optional<std::string> nullopt;
|
||||
return nullopt;
|
||||
}
|
||||
return AllJoints[number]->Name;
|
||||
}
|
||||
|
||||
|
||||
//! Gets a joint number from its name
|
||||
s32 CSkinnedMesh::getJointNumber(const c8* name) const
|
||||
std::optional<u32> CSkinnedMesh::getJointNumber(const std::string &name) const
|
||||
{
|
||||
for (u32 i=0; i<AllJoints.size(); ++i)
|
||||
{
|
||||
@ -643,7 +644,7 @@ s32 CSkinnedMesh::getJointNumber(const c8* name) const
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
||||
@ -1396,7 +1397,7 @@ void CSkinnedMesh::addJoints(core::array<IBoneSceneNode*> &jointChildSceneNodes,
|
||||
//Create new joints
|
||||
for (u32 i=0; i<AllJoints.size(); ++i)
|
||||
{
|
||||
jointChildSceneNodes.push_back(new CBoneSceneNode(0, smgr, 0, i, AllJoints[i]->Name.c_str()));
|
||||
jointChildSceneNodes.push_back(new CBoneSceneNode(0, smgr, 0, i, AllJoints[i]->Name));
|
||||
}
|
||||
|
||||
//Match up parents
|
||||
|
@ -8,9 +8,6 @@
|
||||
|
||||
#include "ISkinnedMesh.h"
|
||||
#include "SMeshBuffer.h"
|
||||
#include "S3DVertex.h"
|
||||
#include "irrString.h"
|
||||
#include "matrix4.h"
|
||||
#include "quaternion.h"
|
||||
|
||||
namespace irr
|
||||
@ -84,10 +81,10 @@ namespace scene
|
||||
u32 getJointCount() const override;
|
||||
|
||||
//! Gets the name of a joint.
|
||||
const c8* getJointName(u32 number) const override;
|
||||
const std::optional<std::string> &getJointName(u32 number) const override;
|
||||
|
||||
//! Gets a joint number from its name
|
||||
s32 getJointNumber(const c8* name) const override;
|
||||
std::optional<u32> getJointNumber(const std::string &name) const override;
|
||||
|
||||
//! uses animation from another mesh
|
||||
bool useAnimationFrom(const ISkinnedMesh *mesh) override;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,141 +0,0 @@
|
||||
// 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 "SIrrCreationParameters.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WEBGL1_
|
||||
|
||||
#include "COGLES2Driver.h"
|
||||
#include "CWebGLExtensionHandler.h"
|
||||
#include "CMeshBuffer.h"
|
||||
#include "EHardwareBufferFlags.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
//! WebGL friendly subset of OGL ES 2.0.
|
||||
//! Written for use with emscripten
|
||||
class CWebGL1Driver : public COGLES2Driver
|
||||
{
|
||||
friend class COpenGLCoreTexture<CWebGL1Driver>;
|
||||
friend IVideoDriver* createWebGL1Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager);
|
||||
|
||||
protected:
|
||||
//! constructor
|
||||
CWebGL1Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager);
|
||||
|
||||
public:
|
||||
|
||||
//! destructor
|
||||
virtual ~CWebGL1Driver();
|
||||
|
||||
//! Returns type of video driver
|
||||
E_DRIVER_TYPE getDriverType() const override;
|
||||
|
||||
//! Is VBO recommended on this mesh?
|
||||
bool isHardwareBufferRecommend(const scene::IMeshBuffer* mb) override
|
||||
{
|
||||
// All buffers must be bound, WebGL doesn't allow sending unbound buffers at all.
|
||||
return true;
|
||||
}
|
||||
|
||||
//! 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 mesh buffer
|
||||
void drawMeshBuffer(const scene::IMeshBuffer* mb) override;
|
||||
|
||||
virtual void draw2DImage(const video::ITexture* texture,
|
||||
const core::position2d<s32>& destPos,
|
||||
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
|
||||
SColor color = SColor(255, 255, 255, 255), bool useAlphaChannelOfTexture = false) override;
|
||||
|
||||
virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
|
||||
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
|
||||
const video::SColor* const colors = 0, bool useAlphaChannelOfTexture = false) override;
|
||||
|
||||
// internally used
|
||||
void draw2DImage(const video::ITexture* texture, u32 layer, bool flip) override;
|
||||
|
||||
//! draws a set of 2d images
|
||||
virtual void draw2DImageBatch(const video::ITexture* texture,
|
||||
const core::position2d<s32>& pos,
|
||||
const core::array<core::rect<s32> >& sourceRects,
|
||||
const core::array<s32>& indices, s32 kerningWidth = 0,
|
||||
const core::rect<s32>* clipRect = 0,
|
||||
SColor color = SColor(255, 255, 255, 255),
|
||||
bool useAlphaChannelOfTexture = false) override;
|
||||
|
||||
void draw2DImageBatch(const video::ITexture* texture,
|
||||
const core::array<core::position2d<s32> >& positions,
|
||||
const core::array<core::rect<s32> >& sourceRects,
|
||||
const core::rect<s32>* clipRect,
|
||||
SColor color,
|
||||
bool useAlphaChannelOfTexture) override;
|
||||
|
||||
//! draw an 2d rectangle
|
||||
virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos,
|
||||
const core::rect<s32>* clip = 0) override;
|
||||
|
||||
//!Draws an 2d rectangle with a gradient.
|
||||
virtual void draw2DRectangle(const core::rect<s32>& pos,
|
||||
SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown,
|
||||
const core::rect<s32>* clip = 0) override;
|
||||
|
||||
//! Draws a 2d line.
|
||||
virtual void draw2DLine(const core::position2d<s32>& start,
|
||||
const core::position2d<s32>& end,
|
||||
SColor color = SColor(255, 255, 255, 255)) override;
|
||||
|
||||
//! Draws a single pixel
|
||||
void drawPixel(u32 x, u32 y, const SColor & color) 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 shadow volume into the stencil buffer.
|
||||
void drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail, u32 debugDataVisible=0) override;
|
||||
|
||||
//! Fills the stencil shadow with color.
|
||||
virtual void drawStencilShadow(bool clearStencilBuffer=false,
|
||||
video::SColor leftUpEdge = video::SColor(0,0,0,0),
|
||||
video::SColor rightUpEdge = video::SColor(0,0,0,0),
|
||||
video::SColor leftDownEdge = video::SColor(0,0,0,0),
|
||||
video::SColor rightDownEdge = video::SColor(0,0,0,0)) override;
|
||||
|
||||
//! Get ZBuffer bits.
|
||||
GLenum getZBufferBits() const override;
|
||||
|
||||
virtual bool getColorFormatParameters(ECOLOR_FORMAT format, GLint& internalFormat, GLenum& pixelFormat,
|
||||
GLenum& pixelType, void(**converter)(const void*, s32, void*)) const override;
|
||||
|
||||
protected:
|
||||
// create a meshbuffer which has as many vertices as indices
|
||||
scene::SMeshBuffer* createSimpleMeshBuffer(irr::u32 numVertices, scene::E_PRIMITIVE_TYPE primitiveType, scene::E_HARDWARE_MAPPING vertexMappingHint=scene::EHM_STREAM, scene::E_HARDWARE_MAPPING indexMappingHint=scene::EHM_STATIC) const;
|
||||
|
||||
bool genericDriverInit(const core::dimension2d<u32>& screenSize, bool stencilBuffer) override;
|
||||
void initWebGLExtensions();
|
||||
|
||||
private:
|
||||
// CWebGL1Driver is derived from COGLES2Driver so it already got an extension handler from that.
|
||||
// But we shouldn't use other extensions most of the time as there are minor differences.
|
||||
CWebGLExtensionHandler WebGLExtensions;
|
||||
|
||||
// Because we can't have unbound buffers in webgl we give drawing functions bound buffers to use
|
||||
scene::SMeshBuffer* MBTriangleFanSize4;
|
||||
scene::SMeshBuffer* MBLinesSize2;
|
||||
scene::SMeshBuffer* MBPointsSize1;
|
||||
};
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_WEBGL1_
|
@ -1,178 +0,0 @@
|
||||
// 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
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_WEBGL1_) // Note: should also work with WebGL2 once we add that to Irrlicht
|
||||
|
||||
#include "COpenGLCoreFeature.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
// Extension handling for WebGL.
|
||||
class CWebGLExtensionHandler
|
||||
{
|
||||
public:
|
||||
// Enums used internally to check for WebGL extensions quickly.
|
||||
// We buffer all extensions on start once in an array.
|
||||
enum EWebGLFeatures
|
||||
{
|
||||
// If you update this enum also update the corresponding WebGLFeatureStrings string-array
|
||||
// Last updated was up to (including) extension number 35 (EXT_float_blend)
|
||||
|
||||
// Khronos ratified WebGL Extensions
|
||||
IRR_OES_texture_float, // 1
|
||||
IRR_OES_texture_half_float, // 2
|
||||
IRR_WEBGL_lose_context, // 3
|
||||
IRR_OES_standard_derivatives, // 4
|
||||
IRR_OES_vertex_array_object, // 5
|
||||
IRR_WEBGL_debug_renderer_info, // 6
|
||||
IRR_WEBGL_debug_shaders, // 7
|
||||
IRR_WEBGL_compressed_texture_s3tc, // 8
|
||||
IRR_WEBGL_depth_texture, // 9
|
||||
IRR_OES_element_index_uint, // 10
|
||||
IRR_EXT_texture_filter_anisotropic, // 11
|
||||
IRR_EXT_frag_depth, // 16
|
||||
IRR_WEBGL_draw_buffers, // 18
|
||||
IRR_ANGLE_instanced_arrays, // 19
|
||||
IRR_OES_texture_float_linear, // 20
|
||||
IRR_OES_texture_half_float_linear, // 21
|
||||
IRR_EXT_blend_minmax, // 25
|
||||
IRR_EXT_shader_texture_lod, // 27
|
||||
|
||||
// Community approved WebGL Extensions
|
||||
IRR_WEBGL_compressed_texture_atc, // 12
|
||||
IRR_WEBGL_compressed_texture_pvrtc, // 13
|
||||
IRR_EXT_color_buffer_half_float, // 14
|
||||
IRR_WEBGL_color_buffer_float, // 15
|
||||
IRR_EXT_sRGB, // 17
|
||||
IRR_WEBGL_compressed_texture_etc1, // 24
|
||||
IRR_EXT_disjoint_timer_query, // 26
|
||||
IRR_WEBGL_compressed_texture_etc, // 29
|
||||
IRR_WEBGL_compressed_texture_astc, // 30
|
||||
IRR_EXT_color_buffer_float, // 31
|
||||
IRR_WEBGL_compressed_texture_s3tc_srgb, // 32
|
||||
IRR_EXT_disjoint_timer_query_webgl2, // 33
|
||||
|
||||
// Draft WebGL Extensions
|
||||
IRR_WEBGL_shared_resources, // 22
|
||||
IRR_WEBGL_security_sensitive_resources, // 23
|
||||
IRR_OES_fbo_render_mipmap, // 28
|
||||
IRR_WEBGL_get_buffer_sub_data_async, // 34
|
||||
IRR_EXT_float_blend, // 35
|
||||
|
||||
IRR_WEBGL_Feature_Count
|
||||
};
|
||||
|
||||
CWebGLExtensionHandler()
|
||||
{
|
||||
for (u32 i = 0; i < IRR_WEBGL_Feature_Count; ++i)
|
||||
FeatureAvailable[i] = false;
|
||||
}
|
||||
|
||||
virtual ~CWebGLExtensionHandler() {}
|
||||
|
||||
void dump() const
|
||||
{
|
||||
for (u32 i = 0; i < IRR_WEBGL_Feature_Count; ++i)
|
||||
os::Printer::log(getFeatureString(i), FeatureAvailable[i] ? " true" : " false");
|
||||
}
|
||||
|
||||
bool queryWebGLFeature(EWebGLFeatures feature) const
|
||||
{
|
||||
return FeatureAvailable[feature];
|
||||
}
|
||||
|
||||
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_WEBGL_Feature_Count; ++j)
|
||||
{
|
||||
if (!strcmp(getFeatureString(j), p))
|
||||
{
|
||||
FeatureAvailable[j] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
p = p + strlen(p) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
delete[] str;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
const char* getFeatureString(size_t index) const
|
||||
{
|
||||
// Based on https://www.khronos.org/registry/webgl/extensions
|
||||
// One for each EWebGLFeatures
|
||||
static const char* const WebGLFeatureStrings[IRR_WEBGL_Feature_Count] =
|
||||
{
|
||||
"OES_texture_float",
|
||||
"OES_texture_half_float",
|
||||
"WEBGL_lose_context",
|
||||
"OES_standard_derivatives",
|
||||
"OES_vertex_array_object",
|
||||
"WEBGL_debug_renderer_info",
|
||||
"WEBGL_debug_shaders",
|
||||
"WEBGL_compressed_texture_s3tc",
|
||||
"WEBGL_depth_texture",
|
||||
"OES_element_index_uint",
|
||||
"EXT_texture_filter_anisotropic",
|
||||
"EXT_frag_depth",
|
||||
"WEBGL_draw_buffers",
|
||||
"ANGLE_instanced_arrays",
|
||||
"OES_texture_float_linear",
|
||||
"OES_texture_half_float_linear",
|
||||
"EXT_blend_minmax",
|
||||
"EXT_shader_texture_lod",
|
||||
|
||||
"WEBGL_compressed_texture_atc",
|
||||
"WEBGL_compressed_texture_pvrtc",
|
||||
"EXT_color_buffer_half_float",
|
||||
"WEBGL_color_buffer_float",
|
||||
"EXT_sRGB",
|
||||
"WEBGL_compressed_texture_etc1",
|
||||
"EXT_disjoint_timer_query",
|
||||
"WEBGL_compressed_texture_etc",
|
||||
"WEBGL_compressed_texture_astc",
|
||||
"EXT_color_buffer_float",
|
||||
"WEBGL_compressed_texture_s3tc_srgb",
|
||||
"EXT_disjoint_timer_query_webgl2",
|
||||
|
||||
"WEBGL_shared_resources",
|
||||
"WEBGL_security_sensitive_resources",
|
||||
"OES_fbo_render_mipmap",
|
||||
"WEBGL_get_buffer_sub_data_async",
|
||||
"EXT_float_blend"
|
||||
};
|
||||
|
||||
return WebGLFeatureStrings[index];
|
||||
}
|
||||
|
||||
bool FeatureAvailable[IRR_WEBGL_Feature_Count];
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // defined(_IRR_COMPILE_WITH_WEBGL1_)
|
@ -594,16 +594,11 @@ bool CXMeshFileLoader::parseDataObjectFrame(CSkinnedMesh::SJoint *Parent)
|
||||
|
||||
CSkinnedMesh::SJoint *joint=0;
|
||||
|
||||
if (name.size())
|
||||
{
|
||||
for (u32 n=0; n < AnimatedMesh->getAllJoints().size(); ++n)
|
||||
{
|
||||
if (AnimatedMesh->getAllJoints()[n]->Name==name)
|
||||
{
|
||||
joint=AnimatedMesh->getAllJoints()[n];
|
||||
JointID=n;
|
||||
break;
|
||||
}
|
||||
if (name.size()) {
|
||||
auto n = AnimatedMesh->getJointNumber(name.c_str());
|
||||
if (n.has_value()) {
|
||||
JointID = *n;
|
||||
joint = AnimatedMesh->getAllJoints()[JointID];
|
||||
}
|
||||
}
|
||||
|
||||
@ -613,7 +608,7 @@ bool CXMeshFileLoader::parseDataObjectFrame(CSkinnedMesh::SJoint *Parent)
|
||||
os::Printer::log("creating joint ", name.c_str(), ELL_DEBUG);
|
||||
#endif
|
||||
joint=AnimatedMesh->addJoint(Parent);
|
||||
joint->Name=name;
|
||||
joint->Name=name.c_str();
|
||||
JointID=AnimatedMesh->getAllJoints().size()-1;
|
||||
}
|
||||
else
|
||||
@ -1121,17 +1116,8 @@ bool CXMeshFileLoader::parseDataObjectSkinWeights(SXMesh &mesh)
|
||||
|
||||
mesh.HasSkinning=true;
|
||||
|
||||
CSkinnedMesh::SJoint *joint=0;
|
||||
|
||||
u32 n;
|
||||
for (n=0; n < AnimatedMesh->getAllJoints().size(); ++n)
|
||||
{
|
||||
if (AnimatedMesh->getAllJoints()[n]->Name==TransformNodeName)
|
||||
{
|
||||
joint=AnimatedMesh->getAllJoints()[n];
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto n = AnimatedMesh->getJointNumber(TransformNodeName.c_str());
|
||||
CSkinnedMesh::SJoint *joint = n.has_value() ? AnimatedMesh->getAllJoints()[*n] : nullptr;
|
||||
|
||||
if (!joint)
|
||||
{
|
||||
@ -1140,7 +1126,7 @@ bool CXMeshFileLoader::parseDataObjectSkinWeights(SXMesh &mesh)
|
||||
#endif
|
||||
n = AnimatedMesh->getAllJoints().size();
|
||||
joint=AnimatedMesh->addJoint(0);
|
||||
joint->Name=TransformNodeName;
|
||||
joint->Name=TransformNodeName.c_str();
|
||||
}
|
||||
|
||||
// read vertex weights
|
||||
@ -1157,7 +1143,7 @@ bool CXMeshFileLoader::parseDataObjectSkinWeights(SXMesh &mesh)
|
||||
|
||||
for (i=0; i<nWeights; ++i)
|
||||
{
|
||||
mesh.WeightJoint.push_back(n);
|
||||
mesh.WeightJoint.push_back(*n);
|
||||
mesh.WeightNum.push_back(joint->Weights.size());
|
||||
|
||||
CSkinnedMesh::SWeight *weight=AnimatedMesh->addWeight(joint);
|
||||
@ -1668,41 +1654,33 @@ bool CXMeshFileLoader::parseDataObjectAnimation()
|
||||
#ifdef _XREADER_DEBUG
|
||||
os::Printer::log("frame name", FrameName.c_str(), ELL_DEBUG);
|
||||
#endif
|
||||
CSkinnedMesh::SJoint *joint=0;
|
||||
auto n = AnimatedMesh->getJointNumber(FrameName.c_str());
|
||||
|
||||
u32 n;
|
||||
for (n=0; n < AnimatedMesh->getAllJoints().size(); ++n)
|
||||
{
|
||||
if (AnimatedMesh->getAllJoints()[n]->Name==FrameName)
|
||||
{
|
||||
joint=AnimatedMesh->getAllJoints()[n];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!joint)
|
||||
{
|
||||
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;
|
||||
joint->Name=FrameName.c_str();
|
||||
}
|
||||
|
||||
joint->PositionKeys.reallocate(joint->PositionKeys.size()+animationDump.PositionKeys.size());
|
||||
for (n=0; n<animationDump.PositionKeys.size(); ++n)
|
||||
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 (n=0; n<animationDump.ScaleKeys.size(); ++n)
|
||||
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 (n=0; n<animationDump.RotationKeys.size(); ++n)
|
||||
for (u32 n=0; n<animationDump.RotationKeys.size(); ++n)
|
||||
{
|
||||
joint->RotationKeys.push_back(animationDump.RotationKeys[n]);
|
||||
}
|
||||
|
@ -56,7 +56,6 @@ public:
|
||||
core::stringc Name;
|
||||
|
||||
virtual E_ATTRIBUTE_TYPE getType() const = 0;
|
||||
virtual const wchar_t* getTypeString() const = 0;
|
||||
};
|
||||
|
||||
} // end namespace io
|
||||
|
@ -5,9 +5,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <SDL_video.h>
|
||||
#include <SDL_opengl.h>
|
||||
#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 <SDL_video.h>
|
||||
#include <SDL_opengl.h>
|
||||
#else
|
||||
#include "vendor/gl.h"
|
||||
#endif
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
@ -205,7 +205,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
||||
|
||||
// print renderer information
|
||||
VendorName = GL.GetString(GL_VENDOR);
|
||||
os::Printer::log(VendorName.c_str(), ELL_INFORMATION);
|
||||
os::Printer::log("Vendor", VendorName.c_str(), ELL_INFORMATION);
|
||||
|
||||
Version = getVersionFromOpenGL();
|
||||
}
|
||||
@ -222,6 +222,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
||||
{
|
||||
initVersion();
|
||||
initFeatures();
|
||||
printTextureFormats();
|
||||
|
||||
// reset cache handler
|
||||
delete CacheHandler;
|
||||
@ -276,6 +277,22 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
||||
return true;
|
||||
}
|
||||
|
||||
void COpenGL3DriverBase::printTextureFormats()
|
||||
{
|
||||
char buf[128];
|
||||
for (u32 i = 0; i < static_cast<u32>(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);
|
||||
@ -290,9 +307,9 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
||||
io::IReadFile* vsFile = FileSystem->createAndOpenFile(vsPath);
|
||||
if ( !vsFile )
|
||||
{
|
||||
core::stringw warning(L"Warning: Missing shader files needed to simulate fixed function materials:\n");
|
||||
warning += core::stringw(vsPath) + L"\n";
|
||||
warning += L"Shaderpath can be changed in SIrrCreationParamters::OGLES2ShaderPath";
|
||||
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;
|
||||
}
|
||||
@ -300,9 +317,9 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
||||
io::IReadFile* fsFile = FileSystem->createAndOpenFile(fsPath);
|
||||
if ( !fsFile )
|
||||
{
|
||||
core::stringw warning(L"Warning: Missing shader files needed to simulate fixed function materials:\n");
|
||||
warning += core::stringw(fsPath) + L"\n";
|
||||
warning += L"Shaderpath can be changed in SIrrCreationParamters::OGLES2ShaderPath";
|
||||
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;
|
||||
}
|
||||
@ -314,6 +331,10 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
||||
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)
|
||||
@ -326,6 +347,10 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
||||
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();
|
||||
@ -478,10 +503,12 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
||||
{
|
||||
HWBuffer->vbo_verticesSize = bufferSize;
|
||||
|
||||
if (HWBuffer->Mapped_Vertex == scene::EHM_STATIC)
|
||||
GL.BufferData(GL_ARRAY_BUFFER, bufferSize, buffer, GL_STATIC_DRAW);
|
||||
else
|
||||
GL.BufferData(GL_ARRAY_BUFFER, bufferSize, buffer, GL_DYNAMIC_DRAW);
|
||||
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);
|
||||
@ -541,10 +568,12 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
||||
{
|
||||
HWBuffer->vbo_indicesSize = indexCount * indexSize;
|
||||
|
||||
if (HWBuffer->Mapped_Index == scene::EHM_STATIC)
|
||||
GL.BufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, GL_STATIC_DRAW);
|
||||
else
|
||||
GL.BufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, GL_DYNAMIC_DRAW);
|
||||
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);
|
||||
@ -1611,7 +1640,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
||||
|
||||
|
||||
//! \return Returns the name of the video driver.
|
||||
const wchar_t* COpenGL3DriverBase::getName() const
|
||||
const char* COpenGL3DriverBase::getName() const
|
||||
{
|
||||
return Name.c_str();
|
||||
}
|
||||
@ -1687,18 +1716,6 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
||||
return -1;
|
||||
}
|
||||
|
||||
//! Sets a vertex shader constant.
|
||||
void COpenGL3DriverBase::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
|
||||
{
|
||||
os::Printer::log("Error: Please call services->setVertexShaderConstant(), not VideoDriver->setPixelShaderConstant().");
|
||||
}
|
||||
|
||||
//! Sets a pixel shader constant.
|
||||
void COpenGL3DriverBase::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
|
||||
{
|
||||
os::Printer::log("Error: Please call services->setPixelShaderConstant(), not VideoDriver->setPixelShaderConstant().");
|
||||
}
|
||||
|
||||
//! Sets a constant for the vertex shader based on an index.
|
||||
bool COpenGL3DriverBase::setVertexShaderConstant(s32 index, const f32* floats, int count)
|
||||
{
|
||||
@ -1739,18 +1756,6 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Adds a new material renderer to the VideoDriver, using pixel and/or
|
||||
//! vertex shaders to render geometry.
|
||||
s32 COpenGL3DriverBase::addShaderMaterial(const c8* vertexShaderProgram,
|
||||
const c8* pixelShaderProgram,
|
||||
IShaderConstantSetCallBack* callback,
|
||||
E_MATERIAL_TYPE baseMaterial, s32 userData)
|
||||
{
|
||||
os::Printer::log("No shader support.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry.
|
||||
s32 COpenGL3DriverBase::addHighLevelShaderMaterial(
|
||||
const c8* vertexShaderProgram,
|
||||
|
@ -136,7 +136,7 @@ namespace video
|
||||
// virtual void drawPixel(u32 x, u32 y, const SColor & color);
|
||||
|
||||
//! Returns the name of the video driver.
|
||||
const wchar_t* getName() const override;
|
||||
const char* getName() const override;
|
||||
|
||||
//! Returns the maximum texture size supported.
|
||||
core::dimension2du getMaxTextureSize() const override;
|
||||
@ -168,12 +168,6 @@ namespace video
|
||||
//! Get a pixel shader constant index.
|
||||
s32 getPixelShaderConstantID(const c8* name) override;
|
||||
|
||||
//! Sets a vertex shader constant.
|
||||
void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount = 1) override;
|
||||
|
||||
//! Sets a pixel shader constant.
|
||||
void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount = 1) override;
|
||||
|
||||
//! Sets a constant for the vertex shader based on an index.
|
||||
bool setVertexShaderConstant(s32 index, const f32* floats, int count) override;
|
||||
|
||||
@ -192,10 +186,6 @@ namespace video
|
||||
//! 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 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram,
|
||||
IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData) override;
|
||||
|
||||
//! Adds a new material renderer to the VideoDriver
|
||||
virtual s32 addHighLevelShaderMaterial(
|
||||
const c8* vertexShaderProgram,
|
||||
@ -282,7 +272,6 @@ namespace video
|
||||
COpenGL3CacheHandler* getCacheHandler() const;
|
||||
|
||||
protected:
|
||||
//! inits the opengl-es driver
|
||||
virtual bool genericDriverInit(const core::dimension2d<u32>& screenSize, bool stencilBuffer);
|
||||
|
||||
void initVersion();
|
||||
@ -345,7 +334,7 @@ namespace video
|
||||
void endDraw(const VertexType &vertexType);
|
||||
|
||||
COpenGL3CacheHandler* CacheHandler;
|
||||
core::stringw Name;
|
||||
core::stringc Name;
|
||||
core::stringc VendorName;
|
||||
SIrrlichtCreationParameters Params;
|
||||
OpenGLVersion Version;
|
||||
@ -401,6 +390,8 @@ private:
|
||||
|
||||
IContextManager* ContextManager;
|
||||
|
||||
void printTextureFormats();
|
||||
|
||||
void addDummyMaterial(E_MATERIAL_TYPE type);
|
||||
|
||||
unsigned QuadIndexCount;
|
||||
|
@ -9,8 +9,11 @@
|
||||
#include "irrString.h"
|
||||
#include "SMaterial.h"
|
||||
#include "fast_atof.h"
|
||||
#include "os.h"
|
||||
#include <mt_opengl.h>
|
||||
|
||||
// FIXME: this basically duplicates what mt_opengl.h already does
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
@ -24,7 +27,7 @@ namespace video
|
||||
pos = next + 1;
|
||||
}
|
||||
addExtension(pos);
|
||||
updateLegacyExtensionList();
|
||||
extensionsLoaded();
|
||||
}
|
||||
|
||||
void COpenGL3ExtensionHandler::initExtensionsNew()
|
||||
@ -32,10 +35,10 @@ namespace video
|
||||
int ext_count = GetInteger(GL_NUM_EXTENSIONS);
|
||||
for (int k = 0; k < ext_count; k++)
|
||||
addExtension(reinterpret_cast<const char *>(GL.GetStringi(GL_EXTENSIONS, k)));
|
||||
updateLegacyExtensionList();
|
||||
extensionsLoaded();
|
||||
}
|
||||
|
||||
void COpenGL3ExtensionHandler::addExtension(std::string name) {
|
||||
void COpenGL3ExtensionHandler::addExtension(std::string &&name) {
|
||||
Extensions.emplace(std::move(name));
|
||||
}
|
||||
|
||||
@ -43,7 +46,10 @@ namespace video
|
||||
return Extensions.find(name) != Extensions.end();
|
||||
}
|
||||
|
||||
void COpenGL3ExtensionHandler::updateLegacyExtensionList() {
|
||||
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));
|
||||
}
|
||||
|
@ -159,8 +159,8 @@ namespace video
|
||||
bool BlendMinMaxSupported = false;
|
||||
|
||||
private:
|
||||
void addExtension(std::string name);
|
||||
void updateLegacyExtensionList();
|
||||
void addExtension(std::string &&name);
|
||||
void extensionsLoaded();
|
||||
|
||||
std::unordered_set<std::string> Extensions;
|
||||
};
|
||||
|
@ -343,16 +343,6 @@ s32 COpenGL3MaterialRenderer::getPixelShaderConstantID(const c8* name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void COpenGL3MaterialRenderer::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
|
||||
{
|
||||
os::Printer::log("Cannot set constant, please use high level shader call instead.", ELL_WARNING);
|
||||
}
|
||||
|
||||
void COpenGL3MaterialRenderer::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
|
||||
{
|
||||
os::Printer::log("Cannot set constant, use high level shader call.", ELL_WARNING);
|
||||
}
|
||||
|
||||
bool COpenGL3MaterialRenderer::setVertexShaderConstant(s32 index, const f32* floats, int count)
|
||||
{
|
||||
return setPixelShaderConstant(index, floats, count);
|
||||
|
@ -52,8 +52,6 @@ public:
|
||||
|
||||
s32 getVertexShaderConstantID(const c8* name) override;
|
||||
s32 getPixelShaderConstantID(const c8* name) override;
|
||||
void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) override;
|
||||
void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) 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;
|
||||
|
@ -31,6 +31,8 @@ namespace video {
|
||||
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};
|
||||
@ -49,9 +51,9 @@ namespace video {
|
||||
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_RGBA, GL_BGRA, GL_UNSIGNED_BYTE};
|
||||
else if (FeatureAvailable[IRR_GL_APPLE_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};
|
||||
@ -68,9 +70,9 @@ namespace video {
|
||||
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_RGBA, GL_BGRA, GL_UNSIGNED_BYTE};
|
||||
else if (FeatureAvailable[IRR_GL_APPLE_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};
|
||||
|
@ -1,26 +0,0 @@
|
||||
// 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 "vector2d.h"
|
||||
|
||||
typedef signed short TZBufferType;
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
struct S2DVertex
|
||||
{
|
||||
core::vector2d<s32> Pos; // position
|
||||
core::vector2d<s32> TCoords; // texture coordinates
|
||||
TZBufferType ZValue; // zvalue
|
||||
u16 Color;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
@ -39,7 +39,7 @@ struct SB3dChunk
|
||||
|
||||
struct SB3dTexture
|
||||
{
|
||||
core::stringc TextureName;
|
||||
std::string TextureName;
|
||||
s32 Flags;
|
||||
s32 Blend;
|
||||
f32 Xpos;
|
||||
|
@ -263,12 +263,6 @@ namespace os
|
||||
Logger->log(message, ll);
|
||||
}
|
||||
|
||||
void Printer::log(const wchar_t* message, ELOG_LEVEL ll)
|
||||
{
|
||||
if (Logger)
|
||||
Logger->log(message, ll);
|
||||
}
|
||||
|
||||
void Printer::log(const c8* message, const c8* hint, ELOG_LEVEL ll)
|
||||
{
|
||||
if (Logger)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user