diff --git a/src/modules/graphics/Graphics.cpp b/src/modules/graphics/Graphics.cpp index 7280ef200..7406c915e 100644 --- a/src/modules/graphics/Graphics.cpp +++ b/src/modules/graphics/Graphics.cpp @@ -258,6 +258,8 @@ StringMap::Entry Graphics::featur { "multicanvasformats", FEATURE_MULTI_CANVAS_FORMATS }, { "clampzero", FEATURE_CLAMP_ZERO }, { "lighten", FEATURE_LIGHTEN }, + { "fullnpot", FEATURE_FULL_NPOT }, + { "pixelshaderhighp", FEATURE_PIXEL_SHADER_HIGHP }, }; StringMap Graphics::features(Graphics::featureEntries, sizeof(Graphics::featureEntries)); @@ -268,6 +270,7 @@ StringMap::Entry Graphics::syst { "texturesize", LIMIT_TEXTURE_SIZE }, { "multicanvas", LIMIT_MULTI_CANVAS }, { "canvasmsaa", LIMIT_CANVAS_MSAA }, + { "anisotropy", LIMIT_ANISOTROPY }, }; StringMap Graphics::systemLimits(Graphics::systemLimitEntries, sizeof(Graphics::systemLimitEntries)); diff --git a/src/modules/graphics/Graphics.h b/src/modules/graphics/Graphics.h index cc713e2e4..cbacb38cc 100644 --- a/src/modules/graphics/Graphics.h +++ b/src/modules/graphics/Graphics.h @@ -151,6 +151,8 @@ public: FEATURE_MULTI_CANVAS_FORMATS, FEATURE_CLAMP_ZERO, FEATURE_LIGHTEN, + FEATURE_FULL_NPOT, + FEATURE_PIXEL_SHADER_HIGHP, FEATURE_MAX_ENUM }; @@ -167,6 +169,7 @@ public: LIMIT_TEXTURE_SIZE, LIMIT_MULTI_CANVAS, LIMIT_CANVAS_MSAA, + LIMIT_ANISOTROPY, LIMIT_MAX_ENUM }; diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 8e4feace5..2c43332f5 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -2009,6 +2009,8 @@ double Graphics::getSystemLimit(SystemLimit limittype) const return (double) gl.getMaxRenderTargets(); case Graphics::LIMIT_CANVAS_MSAA: return (double) gl.getMaxRenderbufferSamples(); + case Graphics::LIMIT_ANISOTROPY: + return (double) gl.getMaxAnisotropy(); default: return 0.0; } @@ -2024,6 +2026,10 @@ bool Graphics::isSupported(Feature feature) const return gl.isClampZeroTextureWrapSupported(); case FEATURE_LIGHTEN: return GLAD_VERSION_1_4 || GLAD_ES_VERSION_3_0 || GLAD_EXT_blend_minmax; + case FEATURE_FULL_NPOT: + return GLAD_VERSION_2_0 || GLAD_ES_VERSION_3_0 || GLAD_OES_texture_npot; + case FEATURE_PIXEL_SHADER_HIGHP: + return gl.isPixelShaderHighpSupported(); default: return false; } diff --git a/src/modules/graphics/opengl/OpenGL.cpp b/src/modules/graphics/opengl/OpenGL.cpp index 3749829af..f5a44775c 100644 --- a/src/modules/graphics/opengl/OpenGL.cpp +++ b/src/modules/graphics/opengl/OpenGL.cpp @@ -65,6 +65,7 @@ static void *LOVEGetProcAddress(const char *name) OpenGL::OpenGL() : stats() , contextInitialized(false) + , pixelShaderHighpSupported(false) , maxAnisotropy(1.0f) , maxTextureSize(0) , maxRenderTargets(1) @@ -268,6 +269,16 @@ void OpenGL::initOpenGLFunctions() void OpenGL::initMaxValues() { + if (GLAD_ES_VERSION_2_0 && !GLAD_ES_VERSION_3_0) + { + GLint range = 0; + GLint precision = 0; + glGetShaderPrecisionFormat(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, &range, &precision); + pixelShaderHighpSupported = range > 0; + } + else + pixelShaderHighpSupported = true; + // We'll need this value to clamp anisotropy. if (GLAD_EXT_texture_filter_anisotropic) glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy); @@ -715,6 +726,11 @@ bool OpenGL::isClampZeroTextureWrapSupported() const return GLAD_VERSION_1_3 || GLAD_EXT_texture_border_clamp || GLAD_NV_texture_border_clamp; } +bool OpenGL::isPixelShaderHighpSupported() const +{ + return pixelShaderHighpSupported; +} + int OpenGL::getMaxTextureSize() const { return maxTextureSize; @@ -740,6 +756,11 @@ float OpenGL::getMaxPointSize() const return maxPointSize; } +float OpenGL::getMaxAnisotropy() const +{ + return maxAnisotropy; +} + void OpenGL::updateTextureMemorySize(size_t oldsize, size_t newsize) { int64 memsize = (int64) stats.textureMemory + ((int64) newsize - (int64) oldsize); diff --git a/src/modules/graphics/opengl/OpenGL.h b/src/modules/graphics/opengl/OpenGL.h index f0905de10..099ed07f9 100644 --- a/src/modules/graphics/opengl/OpenGL.h +++ b/src/modules/graphics/opengl/OpenGL.h @@ -383,6 +383,7 @@ public: void setTextureWrap(const graphics::Texture::Wrap &w); bool isClampZeroTextureWrapSupported() const; + bool isPixelShaderHighpSupported() const; /** * Returns the maximum supported width or height of a texture. @@ -409,6 +410,12 @@ public: **/ float getMaxPointSize() const; + /** + * Returns the maximum anisotropic filtering value that can be used for + * Texture filtering. + **/ + float getMaxAnisotropy() const; + void updateTextureMemorySize(size_t oldsize, size_t newsize); @@ -438,6 +445,7 @@ private: bool contextInitialized; + bool pixelShaderHighpSupported; float maxAnisotropy; int maxTextureSize; int maxRenderTargets;