From 201fff5aa2aeb0cb306254dfd946e88d0171f9c0 Mon Sep 17 00:00:00 2001 From: Kalle Raita Date: Fri, 15 Apr 2016 14:39:57 -0700 Subject: [PATCH] Reset border color state on GLES 3.2 context GL_BORDER_COLOR was previously reset only if the extension GL_EXT_texture_border_clamp was supported. The extension become core functionality with GLES 3.2. Changed the code to execute the appropriate reset when either the extension is supported or the context is GLES 3.2 compatible. Change-Id: I682a8326d04843d1192b9a91c6c1b57c0f4420b9 --- framework/opengl/gluStateReset.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/framework/opengl/gluStateReset.cpp b/framework/opengl/gluStateReset.cpp index efa904f..f91b921 100644 --- a/framework/opengl/gluStateReset.cpp +++ b/framework/opengl/gluStateReset.cpp @@ -144,8 +144,10 @@ void resetStateES (const RenderContext& renderCtx, const ContextInfo& ctxInfo) // Texture state. // \todo [2013-04-08 pyry] Reset all levels? { - const float borderColor[] = { 0.0f, 0.0f, 0.0f, 0.0f }; - int numTexUnits = 0; + const float borderColor[] = { 0.0f, 0.0f, 0.0f, 0.0f }; + int numTexUnits = 0; + const bool supportsBorderClamp = ctxInfo.isExtensionSupported("GL_EXT_texture_border_clamp") || contextSupports(type, ApiType::es(3,2)); + gl.getIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &numTexUnits); for (int ndx = 0; ndx < numTexUnits; ndx++) @@ -177,7 +179,7 @@ void resetStateES (const RenderContext& renderCtx, const ContextInfo& ctxInfo) if (contextSupports(type, ApiType::es(3,1))) gl.texParameteri(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_DEPTH_COMPONENT); - if (ctxInfo.isExtensionSupported("GL_EXT_texture_border_clamp")) + if (supportsBorderClamp) gl.texParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, &borderColor[0]); // Reset cube map texture. @@ -210,7 +212,7 @@ void resetStateES (const RenderContext& renderCtx, const ContextInfo& ctxInfo) if (contextSupports(type, ApiType::es(3,1))) gl.texParameteri(GL_TEXTURE_CUBE_MAP, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_DEPTH_COMPONENT); - if (ctxInfo.isExtensionSupported("GL_EXT_texture_border_clamp")) + if (supportsBorderClamp) gl.texParameterfv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BORDER_COLOR, &borderColor[0]); if (contextSupports(type, ApiType::es(3,0))) @@ -233,7 +235,7 @@ void resetStateES (const RenderContext& renderCtx, const ContextInfo& ctxInfo) gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_NONE); gl.texParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); - if (ctxInfo.isExtensionSupported("GL_EXT_texture_border_clamp")) + if (supportsBorderClamp) gl.texParameterfv(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BORDER_COLOR, &borderColor[0]); } @@ -261,7 +263,7 @@ void resetStateES (const RenderContext& renderCtx, const ContextInfo& ctxInfo) gl.texParameteri(GL_TEXTURE_3D, GL_TEXTURE_COMPARE_MODE, GL_NONE); gl.texParameteri(GL_TEXTURE_3D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); - if (ctxInfo.isExtensionSupported("GL_EXT_texture_border_clamp")) + if (supportsBorderClamp) gl.texParameterfv(GL_TEXTURE_3D, GL_TEXTURE_BORDER_COLOR, &borderColor[0]); } @@ -310,7 +312,7 @@ void resetStateES (const RenderContext& renderCtx, const ContextInfo& ctxInfo) gl.texParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_NONE); gl.texParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); - if (ctxInfo.isExtensionSupported("GL_EXT_texture_border_clamp")) + if (supportsBorderClamp) gl.texParameterfv(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_BORDER_COLOR, &borderColor[0]); } } -- 2.7.4