mirror of
https://github.com/minetest/irrlicht.git
synced 2025-01-11 18:40:18 +01:00
OpenGL3: New extension listing system
This commit is contained in:
parent
13680ef42d
commit
81ad195aa3
@ -334,8 +334,6 @@ namespace video
|
|||||||
IRR_GL_SUN_multi_draw_arrays, // 69
|
IRR_GL_SUN_multi_draw_arrays, // 69
|
||||||
IRR_GL_VIV_shader_binary, // 85
|
IRR_GL_VIV_shader_binary, // 85
|
||||||
WGL_ARB_context_flush_control, // 191
|
WGL_ARB_context_flush_control, // 191
|
||||||
IRR_GL_EXT_draw_range_elements, // 112 again?
|
|
||||||
IRR_GL_ARB_framebuffer_object, // 45 again?
|
|
||||||
|
|
||||||
IRR_OGLES_Feature_Count
|
IRR_OGLES_Feature_Count
|
||||||
};
|
};
|
||||||
@ -687,9 +685,7 @@ namespace video
|
|||||||
"GL_QCOM_writeonly_rendering",
|
"GL_QCOM_writeonly_rendering",
|
||||||
"GL_SUN_multi_draw_arrays",
|
"GL_SUN_multi_draw_arrays",
|
||||||
"GL_VIV_shader_binary",
|
"GL_VIV_shader_binary",
|
||||||
"WGL_ARB_context_flush_control",
|
"WGL_ARB_context_flush_control"
|
||||||
"GL_EXT_draw_range_elements",
|
|
||||||
"GL_ARB_framebuffer_object",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return OGLESFeatureStrings[index];
|
return OGLESFeatureStrings[index];
|
||||||
|
@ -1504,16 +1504,14 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef GL_EXT_texture_filter_anisotropic
|
if (AnisotropicFilterSupported &&
|
||||||
if (FeatureAvailable[COGLESCoreExtensionHandler::IRR_GL_EXT_texture_filter_anisotropic] &&
|
|
||||||
(!tmpTexture->getStatesCache().IsCached || material.TextureLayer[i].AnisotropicFilter != tmpTexture->getStatesCache().AnisotropicFilter))
|
(!tmpTexture->getStatesCache().IsCached || material.TextureLayer[i].AnisotropicFilter != tmpTexture->getStatesCache().AnisotropicFilter))
|
||||||
{
|
{
|
||||||
glTexParameteri(tmpTextureType, GL_TEXTURE_MAX_ANISOTROPY_EXT,
|
glTexParameteri(tmpTextureType, GL.TEXTURE_MAX_ANISOTROPY,
|
||||||
material.TextureLayer[i].AnisotropicFilter>1 ? core::min_(MaxAnisotropy, material.TextureLayer[i].AnisotropicFilter) : 1);
|
material.TextureLayer[i].AnisotropicFilter>1 ? core::min_(MaxAnisotropy, material.TextureLayer[i].AnisotropicFilter) : 1);
|
||||||
|
|
||||||
tmpTexture->getStatesCache().AnisotropicFilter = material.TextureLayer[i].AnisotropicFilter;
|
tmpTexture->getStatesCache().AnisotropicFilter = material.TextureLayer[i].AnisotropicFilter;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!tmpTexture->getStatesCache().IsCached || material.TextureLayer[i].TextureWrapU != tmpTexture->getStatesCache().WrapU)
|
if (!tmpTexture->getStatesCache().IsCached || material.TextureLayer[i].TextureWrapU != tmpTexture->getStatesCache().WrapU)
|
||||||
{
|
{
|
||||||
|
@ -20,11 +20,11 @@ namespace video
|
|||||||
auto extensions_string = reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS));
|
auto extensions_string = reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS));
|
||||||
const char *pos = extensions_string;
|
const char *pos = extensions_string;
|
||||||
while (const char *next = strchr(pos, ' ')) {
|
while (const char *next = strchr(pos, ' ')) {
|
||||||
std::string name{pos, next};
|
addExtension(std::string{pos, next});
|
||||||
addExtension(name.c_str());
|
|
||||||
pos = next + 1;
|
pos = next + 1;
|
||||||
}
|
}
|
||||||
addExtension(pos);
|
addExtension(pos);
|
||||||
|
updateLegacyExtensionList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void COpenGL3ExtensionHandler::initExtensionsNew()
|
void COpenGL3ExtensionHandler::initExtensionsNew()
|
||||||
@ -32,15 +32,21 @@ namespace video
|
|||||||
int ext_count = GetInteger(GL_NUM_EXTENSIONS);
|
int ext_count = GetInteger(GL_NUM_EXTENSIONS);
|
||||||
for (int k = 0; k < ext_count; k++)
|
for (int k = 0; k < ext_count; k++)
|
||||||
addExtension(reinterpret_cast<const char *>(GL.GetStringi(GL_EXTENSIONS, k)));
|
addExtension(reinterpret_cast<const char *>(GL.GetStringi(GL_EXTENSIONS, k)));
|
||||||
|
updateLegacyExtensionList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void COpenGL3ExtensionHandler::addExtension(const char *name) {
|
void COpenGL3ExtensionHandler::addExtension(std::string name) {
|
||||||
for (size_t j=0; j<IRR_OGLES_Feature_Count; ++j) {
|
Extensions.emplace(std::move(name));
|
||||||
if (!strcmp(getFeatureString(j), name)) {
|
|
||||||
FeatureAvailable[j] = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool COpenGL3ExtensionHandler::queryExtension(const std::string &name) const{
|
||||||
|
return Extensions.find(name) != Extensions.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void COpenGL3ExtensionHandler::updateLegacyExtensionList() {
|
||||||
|
for (size_t j = 0; j < IRR_OGLES_Feature_Count; ++j)
|
||||||
|
FeatureAvailable[j] = queryExtension(getFeatureString(j));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace video
|
} // end namespace video
|
||||||
} // end namespace irr
|
} // end namespace irr
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
#include "EDriverFeatures.h"
|
#include "EDriverFeatures.h"
|
||||||
#include "irrTypes.h"
|
#include "irrTypes.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
@ -28,6 +30,9 @@ namespace video
|
|||||||
void initExtensionsOld();
|
void initExtensionsOld();
|
||||||
void initExtensionsNew();
|
void initExtensionsNew();
|
||||||
|
|
||||||
|
/// Checks whether a named extension is present
|
||||||
|
bool queryExtension(const std::string &name) const noexcept;
|
||||||
|
|
||||||
bool queryFeature(video::E_VIDEO_DRIVER_FEATURE feature) const
|
bool queryFeature(video::E_VIDEO_DRIVER_FEATURE feature) const
|
||||||
{
|
{
|
||||||
switch (feature)
|
switch (feature)
|
||||||
@ -160,8 +165,13 @@ namespace video
|
|||||||
glBlendEquation(mode);
|
glBlendEquation(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AnisotropicFilterSupported = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addExtension(const char *name);
|
void addExtension(std::string name);
|
||||||
|
void updateLegacyExtensionList();
|
||||||
|
|
||||||
|
std::unordered_set<std::string> Extensions;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "Driver.h"
|
#include "Driver.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include "mt_opengl.h"
|
||||||
|
|
||||||
namespace irr {
|
namespace irr {
|
||||||
namespace video {
|
namespace video {
|
||||||
@ -32,6 +33,8 @@ namespace video {
|
|||||||
assert (isVersionAtLeast(3, 2));
|
assert (isVersionAtLeast(3, 2));
|
||||||
initExtensionsNew();
|
initExtensionsNew();
|
||||||
|
|
||||||
|
AnisotropicFilterSupported = isVersionAtLeast(4, 6) || queryExtension("GL_ARB_texture_filter_anisotropic") || queryExtension("GL_EXT_texture_filter_anisotropic");
|
||||||
|
|
||||||
// COGLESCoreExtensionHandler::Feature
|
// COGLESCoreExtensionHandler::Feature
|
||||||
static_assert(MATERIAL_MAX_TEXTURES <= 16, "Only up to 16 textures are guaranteed");
|
static_assert(MATERIAL_MAX_TEXTURES <= 16, "Only up to 16 textures are guaranteed");
|
||||||
Feature.BlendOperation = true;
|
Feature.BlendOperation = true;
|
||||||
@ -40,8 +43,8 @@ namespace video {
|
|||||||
Feature.MultipleRenderTarget = GetInteger(GL_MAX_DRAW_BUFFERS);
|
Feature.MultipleRenderTarget = GetInteger(GL_MAX_DRAW_BUFFERS);
|
||||||
|
|
||||||
// COGLESCoreExtensionHandler
|
// COGLESCoreExtensionHandler
|
||||||
if (FeatureAvailable[IRR_GL_EXT_texture_filter_anisotropic])
|
if (AnisotropicFilterSupported)
|
||||||
MaxAnisotropy = GetInteger(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT);
|
MaxAnisotropy = GetInteger(GL.MAX_TEXTURE_MAX_ANISOTROPY);
|
||||||
MaxIndices = GetInteger(GL_MAX_ELEMENTS_INDICES);
|
MaxIndices = GetInteger(GL_MAX_ELEMENTS_INDICES);
|
||||||
MaxTextureSize = GetInteger(GL_MAX_TEXTURE_SIZE);
|
MaxTextureSize = GetInteger(GL_MAX_TEXTURE_SIZE);
|
||||||
glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS, &MaxTextureLODBias);
|
glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS, &MaxTextureLODBias);
|
||||||
|
@ -30,23 +30,27 @@ namespace video {
|
|||||||
else
|
else
|
||||||
initExtensionsOld();
|
initExtensionsOld();
|
||||||
|
|
||||||
|
const bool MRTSupported = Version.Major >= 3 || queryExtension("GL_EXT_draw_buffers");
|
||||||
|
AnisotropicFilterSupported = queryExtension("GL_EXT_texture_filter_anisotropic");
|
||||||
|
const bool TextureLODBiasSupported = queryExtension("GL_EXT_texture_lod_bias");
|
||||||
|
|
||||||
// COGLESCoreExtensionHandler::Feature
|
// COGLESCoreExtensionHandler::Feature
|
||||||
static_assert(MATERIAL_MAX_TEXTURES <= 8, "Only up to 8 textures are guaranteed");
|
static_assert(MATERIAL_MAX_TEXTURES <= 8, "Only up to 8 textures are guaranteed");
|
||||||
Feature.BlendOperation = true;
|
Feature.BlendOperation = true;
|
||||||
Feature.ColorAttachment = 1;
|
Feature.ColorAttachment = 1;
|
||||||
if (Version.Major >= 3 || FeatureAvailable[IRR_GL_EXT_draw_buffers])
|
if (MRTSupported)
|
||||||
Feature.ColorAttachment = GetInteger(GL_MAX_COLOR_ATTACHMENTS);
|
Feature.ColorAttachment = GetInteger(GL_MAX_COLOR_ATTACHMENTS);
|
||||||
Feature.MaxTextureUnits = MATERIAL_MAX_TEXTURES;
|
Feature.MaxTextureUnits = MATERIAL_MAX_TEXTURES;
|
||||||
if (Version.Major >= 3 || FeatureAvailable[IRR_GL_EXT_draw_buffers])
|
if (MRTSupported)
|
||||||
Feature.MultipleRenderTarget = GetInteger(GL_MAX_DRAW_BUFFERS);
|
Feature.MultipleRenderTarget = GetInteger(GL_MAX_DRAW_BUFFERS);
|
||||||
|
|
||||||
// COGLESCoreExtensionHandler
|
// COGLESCoreExtensionHandler
|
||||||
if (FeatureAvailable[IRR_GL_EXT_texture_filter_anisotropic])
|
if (AnisotropicFilterSupported)
|
||||||
MaxAnisotropy = GetInteger(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT);
|
MaxAnisotropy = GetInteger(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT);
|
||||||
if (Version.Major >= 3 || FeatureAvailable[IRR_GL_EXT_draw_range_elements])
|
if (Version.Major >= 3 || queryExtension("GL_EXT_draw_range_elements"))
|
||||||
MaxIndices = GetInteger(GL_MAX_ELEMENTS_INDICES);
|
MaxIndices = GetInteger(GL_MAX_ELEMENTS_INDICES);
|
||||||
MaxTextureSize = GetInteger(GL_MAX_TEXTURE_SIZE);
|
MaxTextureSize = GetInteger(GL_MAX_TEXTURE_SIZE);
|
||||||
if (FeatureAvailable[IRR_GL_EXT_texture_lod_bias])
|
if (TextureLODBiasSupported)
|
||||||
glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS, &MaxTextureLODBias);
|
glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS, &MaxTextureLODBias);
|
||||||
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine); // NOTE: this is not in the OpenGL ES 2.0 spec...
|
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine); // NOTE: this is not in the OpenGL ES 2.0 spec...
|
||||||
glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint);
|
glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint);
|
||||||
|
Loading…
Reference in New Issue
Block a user