aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics
diff options
context:
space:
mode:
authorJohannes Schickel2016-01-03 14:06:02 +0100
committerJohannes Schickel2016-03-16 20:29:26 +0100
commit08553a09cfa2110d56b200bf6c69d01d5adbc6bb (patch)
tree3a18208f99fef300543feb4ee8328757ed3d3ede /backends/graphics
parentbf2735cd53f13d22cf4e6013a251896a3d411b97 (diff)
downloadscummvm-rg350-08553a09cfa2110d56b200bf6c69d01d5adbc6bb.tar.gz
scummvm-rg350-08553a09cfa2110d56b200bf6c69d01d5adbc6bb.tar.bz2
scummvm-rg350-08553a09cfa2110d56b200bf6c69d01d5adbc6bb.zip
OPENGL: Support GLSL based CLUT8 look up for GLES2+.
Diffstat (limited to 'backends/graphics')
-rw-r--r--backends/graphics/opengl/context.cpp4
-rw-r--r--backends/graphics/opengl/opengl-func.h2
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp2
-rw-r--r--backends/graphics/opengl/opengl-sys.h3
-rw-r--r--backends/graphics/opengl/texture.cpp17
-rw-r--r--backends/graphics/opengl/texture.h5
6 files changed, 14 insertions, 19 deletions
diff --git a/backends/graphics/opengl/context.cpp b/backends/graphics/opengl/context.cpp
index c149b12f19..89f0ed7910 100644
--- a/backends/graphics/opengl/context.cpp
+++ b/backends/graphics/opengl/context.cpp
@@ -36,7 +36,6 @@ void Context::reset() {
shadersSupported = false;
multitextureSupported = false;
framebufferObjectSupported = false;
- textureRGSupported = false;
#define GL_FUNC_DEF(ret, name, param) name = nullptr;
#include "backends/graphics/opengl/opengl-func.h"
@@ -206,8 +205,6 @@ void OpenGLGraphicsManager::initializeGLContext() {
ARBFragmentShader = true;
} else if (token == "GL_ARB_multitexture") {
g_context.multitextureSupported = true;
- } else if (token == "GL_ARB_texture_rg") {
- g_context.textureRGSupported = true;
} else if (token == "GL_EXT_framebuffer_object") {
g_context.framebufferObjectSupported = true;
}
@@ -248,7 +245,6 @@ void OpenGLGraphicsManager::initializeGLContext() {
debug(5, "OpenGL: NPOT texture support: %d", g_context.NPOTSupported);
debug(5, "OpenGL: Shader support: %d", g_context.shadersSupported);
debug(5, "OpenGL: Multitexture support: %d", g_context.multitextureSupported);
- debug(5, "OpenGL: Texture RG support: %d", g_context.textureRGSupported);
debug(5, "OpenGL: FBO support: %d", g_context.framebufferObjectSupported);
}
diff --git a/backends/graphics/opengl/opengl-func.h b/backends/graphics/opengl/opengl-func.h
index 763d5e9143..554ac3c6ff 100644
--- a/backends/graphics/opengl/opengl-func.h
+++ b/backends/graphics/opengl/opengl-func.h
@@ -130,13 +130,11 @@ GL_FUNC_2_DEF(void, glGetShaderInfoLog, glGetInfoLogARB, (GLshader shader, GLsiz
GL_FUNC_2_DEF(void, glShaderSource, glShaderSourceARB, (GLshader shader, GLsizei count, const GLchar *const *string, const GLint *length));
GL_FUNC_2_DEF(void, glCompileShader, glCompileShaderARB, (GLshader shader));
-#if !USE_FORCED_GLES2
GL_FUNC_2_DEF(void, glBindFramebuffer, glBindFramebufferEXT, (GLenum target, GLuint renderbuffer));
GL_FUNC_2_DEF(void, glDeleteFramebuffers, glDeleteFramebuffersEXT, (GLsizei n, const GLuint *framebuffers));
GL_FUNC_2_DEF(void, glGenFramebuffers, glGenFramebuffersEXT, (GLsizei n, GLuint *renderbuffers));
GL_FUNC_2_DEF(void, glFramebufferTexture2D, glFramebufferTexture2DEXT, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level));
GL_FUNC_2_DEF(GLenum, glCheckFramebufferStatus, glCheckFramebufferStatusEXT, (GLenum target));
-#endif
GL_FUNC_2_DEF(void, glActiveTexture, glActiveTextureARB, (GLenum texture));
#endif
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index d9c9377e51..1ec40015af 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -1016,7 +1016,7 @@ void OpenGLGraphicsManager::setMousePosition(int x, int y) {
Surface *OpenGLGraphicsManager::createSurface(const Graphics::PixelFormat &format, bool wantAlpha) {
GLenum glIntFormat, glFormat, glType;
if (format.bytesPerPixel == 1) {
-#if !USE_FORCED_GLES && !USE_FORCED_GLES2
+#if !USE_FORCED_GLES
if (TextureCLUT8GPU::isSupportedByContext()) {
return new TextureCLUT8GPU();
}
diff --git a/backends/graphics/opengl/opengl-sys.h b/backends/graphics/opengl/opengl-sys.h
index 9c3dfe8244..a584259abe 100644
--- a/backends/graphics/opengl/opengl-sys.h
+++ b/backends/graphics/opengl/opengl-sys.h
@@ -114,9 +114,6 @@ struct Context {
/** Whether multi texture support is available or not. */
bool multitextureSupported;
- /** Whether (GLES2) RG texture formats are supported. */
- bool textureRGSupported;
-
/** Whether FBO support is available or not. */
bool framebufferObjectSupported;
diff --git a/backends/graphics/opengl/texture.cpp b/backends/graphics/opengl/texture.cpp
index 5ae4987874..f98bf8be06 100644
--- a/backends/graphics/opengl/texture.cpp
+++ b/backends/graphics/opengl/texture.cpp
@@ -504,9 +504,9 @@ void TextureRGB555::updateTexture() {
}
#endif // !USE_FORCED_GL
-#if !USE_FORCED_GLES && !USE_FORCED_GLES2
+#if !USE_FORCED_GLES
namespace {
-const char *const g_lookUpFragmentShaderGL =
+const char *const g_lookUpFragmentShader =
"varying vec2 texCoord;\n"
"varying vec4 blendColor;\n"
"\n"
@@ -517,12 +517,17 @@ const char *const g_lookUpFragmentShaderGL =
"\n"
"void main(void) {\n"
"\tvec4 index = texture2D(texture, texCoord);\n"
- "\tgl_FragColor = blendColor * texture2D(palette, vec2(index.x * adjustFactor, 0.0));\n"
+ "\tgl_FragColor = blendColor * texture2D(palette, vec2(index.a * adjustFactor, 0.0));\n"
"}\n";
} // End of anonymous namespace
+// _clut8Texture needs 8 bits internal precision, otherwise graphics glitches
+// can occur. GL_ALPHA does not have any internal precision requirements.
+// However, in practice (according to fuzzie) it's 8bit. If we run into
+// problems, we need to switch to GL_R8 and GL_RED, but that is only supported
+// for ARB_texture_rg and GLES3+ (EXT_rexture_rg does not support GL_R8).
TextureCLUT8GPU::TextureCLUT8GPU()
- : _clut8Texture(GL_R8, GL_RED, GL_UNSIGNED_BYTE),
+ : _clut8Texture(GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE),
_paletteTexture(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE),
_glTexture(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE),
_glFBO(0), _clut8Vertices(), _projectionMatrix(),
@@ -531,7 +536,7 @@ TextureCLUT8GPU::TextureCLUT8GPU()
// Allocate space for 256 colors.
_paletteTexture.setSize(256, 1);
- _lookUpShader = new Shader(g_defaultVertexShader, g_lookUpFragmentShaderGL);
+ _lookUpShader = new Shader(g_defaultVertexShader, g_lookUpFragmentShader);
_lookUpShader->recreate();
_paletteLocation = _lookUpShader->getUniformLocation("palette");
@@ -772,6 +777,6 @@ void TextureCLUT8GPU::setupFBO() {
// Restore old FBO.
GL_CALL(glBindFramebuffer(GL_FRAMEBUFFER, oldFBO));
}
-#endif // !USE_FORCED_GLES && !USE_FORCED_GLES2
+#endif // !USE_FORCED_GLES
} // End of namespace OpenGL
diff --git a/backends/graphics/opengl/texture.h b/backends/graphics/opengl/texture.h
index 06fe47a241..959281539f 100644
--- a/backends/graphics/opengl/texture.h
+++ b/backends/graphics/opengl/texture.h
@@ -317,7 +317,7 @@ private:
};
#endif // !USE_FORCED_GL
-#if !USE_FORCED_GLES && !USE_FORCED_GLES2
+#if !USE_FORCED_GLES
class TextureCLUT8GPU : public Surface {
public:
TextureCLUT8GPU();
@@ -351,7 +351,6 @@ public:
static bool isSupportedByContext() {
return g_context.shadersSupported
&& g_context.multitextureSupported
- && g_context.textureRGSupported
&& g_context.framebufferObjectSupported;
}
private:
@@ -376,7 +375,7 @@ private:
byte _palette[4 * 256];
bool _paletteDirty;
};
-#endif // !USE_FORCED_GLES && !USE_FORCED_GLES2
+#endif // !USE_FORCED_GLES
} // End of namespace OpenGL