aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryinsimei2017-07-10 01:06:58 +0200
committerEugene Sandulenko2017-07-13 18:27:45 +0200
commit07e4982027f042c0c8fb27e28bd410cb70d51b27 (patch)
tree6525783e14b01c2bc1f789b602fcbe264e55cb9b
parent1e261d6cd3e40e67249d9036ae78cdb7e9d9e275 (diff)
downloadscummvm-rg350-07e4982027f042c0c8fb27e28bd410cb70d51b27.tar.gz
scummvm-rg350-07e4982027f042c0c8fb27e28bd410cb70d51b27.tar.bz2
scummvm-rg350-07e4982027f042c0c8fb27e28bd410cb70d51b27.zip
SLUDGE: remove #ifdef HAVE_GLES2 and clean code in graphics
-rw-r--r--engines/sludge/graphics.cpp381
-rw-r--r--engines/sludge/graphics.h66
-rw-r--r--engines/sludge/main_loop.cpp4
-rw-r--r--engines/sludge/movie.cpp13
-rw-r--r--engines/sludge/sludger.cpp136
-rw-r--r--engines/sludge/sprites.cpp132
-rw-r--r--engines/sludge/thumbnail.cpp7
7 files changed, 5 insertions, 734 deletions
diff --git a/engines/sludge/graphics.cpp b/engines/sludge/graphics.cpp
index 29cc47fd8d..dbcb691d29 100644
--- a/engines/sludge/graphics.cpp
+++ b/engines/sludge/graphics.cpp
@@ -21,15 +21,12 @@
*/
#include "sludge/allfiles.h"
-#include "sludge/debug.h"
-#include "sludge/platform-dependent.h"
#include "sludge/graphics.h"
#include "sludge/language.h"
#include "sludge/newfatal.h"
#include "sludge/sprbanks.h"
#include "sludge/zbuffer.h"
#include "sludge/backdrop.h"
-#include "sludge/shaders.h"
#include "sludge/movie.h"
#include "sludge/stringy.h"
#include "sludge/CommonCode/specialsettings.h"
@@ -48,232 +45,10 @@ extern int specialSettings;
void setMovieViewport();
-#if 0
-extern GLuint backdropTextureName;
-extern GLuint snapshotTextureName;
-#endif
-
extern unsigned int sceneWidth, sceneHeight;
extern zBufferData zBuffer;
extern int lightMapNumber;
-#if 0
-extern GLuint yTextureName;
-extern GLuint uTextureName;
-extern GLuint vTextureName;
-//extern GLubyte * ytex, * utex, * vtex;
-
-shaders shader;
-GLfloat aPMVMatrix[16];
-
-void sludgeDisplay();
-
-GLfloat primaryColor[4];
-GLfloat secondaryColor[4];
-#endif
-
-struct textureList *firstTexture = NULL;
-
-textureList *addTexture() {
- textureList *newTexture = new textureList;
- newTexture->next = firstTexture;
- firstTexture = newTexture;
- return newTexture;
-}
-
-#if 0
-void deleteTextures(GLsizei n, const GLuint *textures) {
- if (firstTexture == NULL) {
- //debugOut("Deleting texture while list is already empty.\n");
- } else {
- for (int i = 0; i < n; i++) {
- bool found = false;
- textureList *list = firstTexture;
- if (list->name == textures[i]) {
- found = true;
- firstTexture = list->next;
- delete list;
- continue;
- }
-
- while (list->next) {
- if (list->next->name == textures[i]) {
- found = true;
- textureList *deleteMe = list->next;
- list->next = list->next->next;
- delete deleteMe;
- break;
- }
- list = list->next;
- }
- //if (!found)
- // debugOut("Deleting texture that was not in list.\n");
- }
- }
-
- glDeleteTextures(n, textures);
-
-}
-
-void getTextureDimensions(GLuint name, GLint *width, GLint *height) {
- textureList *list = firstTexture;
- while (list) {
- if (list->name == name) {
- *width = list->width;
- *height = list->height;
-#if !defined(HAVE_GLES2)
- //For the following test it is assumed that glBindTexture is always
- //called for the right texture before getTextureDimensions.
- GLint tw, th;
- glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &tw);
- glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &th);
- if (tw != *width || th != *height) {
- debugOut("Warning: Texture dimensions don't match: They are %ix%i, but SLUDGEs bookkeeping says %ix%i.\n", tw, th, *width, *height);
- }
-#endif
- return;
- }
- list = list->next;
- }
- fatal("Texture not found in list.\n");
-}
-
-void storeTextureDimensions(GLuint name, GLsizei width, GLsizei height, const char *file, int line) {
- if (! NPOT_textures && !(((height & (height - 1)) == 0) || ((width & (width - 1)) == 0))) {
- debugOut("I was told to create a texture with dimensions %ix%i in %s @ line %d although NPOT textures are disabled.\n", width, height, file, line);
- //height = getNextPOT(height);
- //width = getNextPOT(width);
- }
-
- textureList *list = firstTexture;
- while (list) {
- if (list->name == name) {
- //debugOut("Texture dimensions are overwritten.\n");
- break;
- }
- list = list->next;
- }
- if (list == NULL) {
- list = addTexture();
- }
- list->name = name;
- list->width = width;
- list->height = height;
-
-}
-#endif
-
-#ifdef HAVE_GLES2
-void glesCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
- // Work around for broken glCopy(Sub)TexImage2D...
- void *tmp = malloc(width * height * 4);
- glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, tmp);
- glTexSubImage2D(target, level, xoffset, yoffset, width, height, GL_RGBA, GL_UNSIGNED_BYTE, tmp);
- free(tmp);
-}
-void glesCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) {
- // Work around for broken glCopy(Sub)TexImage2D...
- void *tmp = malloc(width * height * 4);
- glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, tmp);
- glTexImage2D(target, level, GL_RGBA, width, height, border, GL_RGBA, GL_UNSIGNED_BYTE, tmp);
- free(tmp);
-}
-#endif
-
-#if 0
-void dcopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border, GLuint name, const char *file, int line) {
-
- glBindTexture(GL_TEXTURE_2D, name);
-#ifdef HAVE_GLES2_
- glesCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
-#else
- glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
-#endif
-}
-
-void dcopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, GLuint name, const char *file, int line) {
- glBindTexture(GL_TEXTURE_2D, name);
-#ifdef HAVE_GLES2_
- glesCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
-#else
- glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
-#endif
-}
-
-void dtexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
- GLint border, GLenum format, GLenum type, const GLvoid *data, GLuint name, const char *file, int line) {
- storeTextureDimensions(name, width, height, file, line);
- glBindTexture(GL_TEXTURE_2D, name);
- glTexImage2D(target, level, internalformat, width, height, border, format, type, data);
-}
-
-void dtexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
- GLenum format, GLenum type, const GLvoid *data, GLuint name, const char *file, int line) {
- storeTextureDimensions(name, width, height, file, line);
- glBindTexture(GL_TEXTURE_2D, name);
- glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, data);
-}
-
-void setPrimaryColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
- primaryColor[0] = r;
- primaryColor[1] = g;
- primaryColor[2] = b;
- primaryColor[3] = a;
-}
-
-void setSecondaryColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
- secondaryColor[0] = r;
- secondaryColor[1] = g;
- secondaryColor[2] = b;
- secondaryColor[3] = a;
-}
-
-void drawQuad(GLint program, const GLfloat *vertices, int numTexCoords, ...) {
- int i, vertexLoc, texCoordLocs[numTexCoords];
- const GLfloat *texCoords[numTexCoords];
-
- va_list vl;
- va_start(vl, numTexCoords);
- for (i = 0; i < numTexCoords; i++) {
- texCoords[i] = va_arg(vl, const GLfloat *);
- }
- va_end(vl);
-
- glUniform4f(glGetUniformLocation(program, "myColor"), primaryColor[0], primaryColor[1], primaryColor[2], primaryColor[3]);
- if (program == shader.smartScaler || program == shader.paste) {
- glUniform4f(glGetUniformLocation(program, "mySecondaryColor"), secondaryColor[0], secondaryColor[1], secondaryColor[2], secondaryColor[3]);
- }
-
- vertexLoc = glGetAttribLocation(program, "myVertex");
- texCoordLocs[0] = glGetAttribLocation(program, "myUV0");
- if (numTexCoords > 1) texCoordLocs[1] = glGetAttribLocation(program, "myUV1");
- if (numTexCoords > 2) texCoordLocs[2] = glGetAttribLocation(program, "myUV2");
- if (numTexCoords > 3) texCoordLocs[3] = glGetAttribLocation(program, "myUV3");
- glEnableVertexAttribArray(vertexLoc);
- glVertexAttribPointer(vertexLoc, 3, GL_FLOAT, GL_FALSE, 0, vertices);
-
- for (i = 0; i < numTexCoords; i++) {
- if (texCoords[i]) {
- glEnableVertexAttribArray(texCoordLocs[i]);
- glVertexAttribPointer(texCoordLocs[i], 2, GL_FLOAT, GL_FALSE, 0, texCoords[i]);
- }
- }
-
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-
- for (i = 0; i < numTexCoords; i++) {
- if (texCoords[i]) {
- glDisableVertexAttribArray(texCoordLocs[i]);
- }
- }
- glDisableVertexAttribArray(vertexLoc);
-
-}
-
-void setPMVMatrix(GLint program) {
- glUniformMatrix4fv(glGetUniformLocation(program, "myPMVMatrix"), 1, GL_FALSE, aPMVMatrix);
-}
-#endif
// This is for swapping settings between rendering to texture or to the screen
void setPixelCoords(bool pixels) {
static int current = -1;
@@ -325,40 +100,6 @@ void setPixelCoords(bool pixels) {
#endif
}
-int desktopW = 0, desktopH = 0;
-bool runningFullscreen = false;
-
-#if defined(HAVE_GLES2)
-void saveTexture(GLuint tex, GLubyte *data) {
- // use an FBO to easily grab the texture...
- static GLuint fbo = 0;
- GLuint old_fbo;
- GLint tw, th;
- GLint old_vp[4];
- if (fbo == 0) {
- glGenFramebuffers(1, &fbo);
- }
- glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint *)&old_fbo);
- glBindFramebuffer(GL_FRAMEBUFFER, fbo);
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
- getTextureDimensions(tex, &tw, &th);
- glGetIntegerv(GL_VIEWPORT, old_vp);
- glViewport(0, 0, tw, th);
- glBindFramebuffer(GL_FRAMEBUFFER, fbo);
- glReadPixels(0, 0, tw, th, GL_RGBA, GL_UNSIGNED_BYTE, data);
- glViewport(old_vp[0], old_vp[1], old_vp[2], old_vp[3]);
- glBindFramebuffer(GL_FRAMEBUFFER, old_fbo);
-}
-#else
-#if 0
-void saveTexture(GLuint tex, GLubyte *data) {
-
- glBindTexture(GL_TEXTURE_2D, tex);
- glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
-}
-#endif
-#endif
-
// This is for setting windowed or fullscreen graphics.
// Used for switching, and for initial window creation.
void setGraphicsWindow(bool fullscreen, bool restoreGraphics, bool resize) {
@@ -419,11 +160,8 @@ void setGraphicsWindow(bool fullscreen, bool restoreGraphics, bool resize) {
if (fullscreen) {
specialSettings &= ~SPECIAL_INVISIBLE;
-#if !defined(HAVE_GLES2)
- videoflags = SDL_OPENGL | SDL_FULLSCREEN;
-#else
+
videoflags = SDL_SWSURFACE | SDL_FULLSCREEN;
-#endif
if (gameSettings.fixedPixels) {
viewportWidth = realWinWidth = winWidth;
@@ -450,11 +188,7 @@ void setGraphicsWindow(bool fullscreen, bool restoreGraphics, bool resize) {
}
} else {
-#if !defined(HAVE_GLES2)
- videoflags = SDL_OPENGL/* | SDL_RESIZABLE*/;
-#else
videoflags = SDL_SWSURFACE;
-#endif
if (resize) {
float realAspect = (float) desktopW / desktopH;
@@ -511,14 +245,12 @@ void setGraphicsWindow(bool fullscreen, bool restoreGraphics, bool resize) {
}
debugOut("Video mode %d %d set successfully.\n", realWinWidth, realWinHeight);
-#if defined(HAVE_GLES2)
if (EGL_Open()) {
msgBox("Startup Error", "Couldn't initialize EGL.");
SDL_Quit();
exit(1);
}
EGL_Init();
-#endif
GLint uniform;
const char *Vertex;
@@ -526,9 +258,6 @@ void setGraphicsWindow(bool fullscreen, bool restoreGraphics, bool resize) {
Vertex = shaderFileRead("scale.vert");
-#if !defined(HAVE_GLES2)
- Fragment = shaderFileRead("scale.frag");
-#else
/* const GLubyte *str;
int glDerivativesAvailable;
str = glGetString (GL_EXTENSIONS);
@@ -541,7 +270,6 @@ void setGraphicsWindow(bool fullscreen, bool restoreGraphics, bool resize) {
// }
Fragment = joinStrings("precision mediump float;\n", Fragment);
-#endif
if (! Vertex || ! Fragment) {
fatal("Error loading \"scale\" shader program!", "Try re-installing the game. (scale.frag, scale_noaa.frag or scale.vert was not found.)");
@@ -579,9 +307,7 @@ void setGraphicsWindow(bool fullscreen, bool restoreGraphics, bool resize) {
Vertex = shaderFileRead("fixScaleSprite.vert");
Fragment = shaderFileRead("fixScaleSprite.frag");
-#if defined(HAVE_GLES2)
Fragment = joinStrings("precision mediump float;\n", Fragment);
-#endif
if (! Vertex || ! Fragment) {
fatal("Error loading \"fixScaleSprite\" shader program!", "Try re-installing the game. (fixScaleSprite.frag or fixScaleSprite.vert was not found.)");
@@ -610,9 +336,7 @@ void setGraphicsWindow(bool fullscreen, bool restoreGraphics, bool resize) {
Vertex = shaderFileRead("yuv.vert");
Fragment = shaderFileRead("yuv.frag");
-#if defined(HAVE_GLES2)
Fragment = joinStrings("precision mediump float;\n", Fragment);
-#endif
if (! Vertex || ! Fragment) {
fatal("Error loading \"yuv\" shader program!", "Try re-installing the game. (yuv.frag or yuv.vert was not found.)");
@@ -639,9 +363,7 @@ void setGraphicsWindow(bool fullscreen, bool restoreGraphics, bool resize) {
Vertex = shaderFileRead("texture.vert");
Fragment = shaderFileRead("texture.frag");
-#if defined(HAVE_GLES2)
Fragment = joinStrings("precision mediump float;\n", Fragment);
-#endif
if (! Vertex || ! Fragment) {
fatal("Error loading \"texture\" shader program!", "Try re-installing the game. (texture.frag or texture.vert was not found.)");
@@ -669,9 +391,7 @@ void setGraphicsWindow(bool fullscreen, bool restoreGraphics, bool resize) {
Vertex = shaderFileRead("color.vert");
Fragment = shaderFileRead("color.frag");
-#if defined(HAVE_GLES2)
Fragment = joinStrings("precision mediump float;\n", Fragment);
-#endif
if (! Vertex || ! Fragment) {
fatal("Error loading \"color\" shader program!", "Try re-installing the game. (color.frag or color.vert was not found.)");
@@ -765,85 +485,6 @@ void setGraphicsWindow(bool fullscreen, bool restoreGraphics, bool resize) {
#endif
}
-void setupOpenGLStuff() {
-
- /*
- * Time to setup our requested window attributes for our OpenGL window.
- * We want *at least* 8 bits of red, green and blue. We also want at least a 16-bit
- * depth buffer.
- *
- * The last thing we do is request a double buffered window. '1' turns on double
- * buffering, '0' turns it off.
- */
-#if 0
- SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- setGraphicsWindow(gameSettings.userFullScreen, false);
-#endif
-#if !defined(HAVE_GLES2)
-#if 0
- /* Check for graphics capabilities... */
- if (GLEE_VERSION_2_0) {
- // Yes! Textures can be any size!
- NPOT_textures = true;
- debugOut("OpenGL 2.0! All is good.\n");
- } else {
- if (GLEE_VERSION_1_5) {
- debugOut("OpenGL 1.5!\n");
- } else if (GLEE_VERSION_1_4) {
- debugOut("OpenGL 1.4!\n");
- } else if (GLEE_VERSION_1_3) {
- debugOut("OpenGL 1.3!\n");
- } else if (GLEE_VERSION_1_2) {
- debugOut("OpenGL 1.2!\n");
- }
-
- if (GLEE_ARB_texture_non_power_of_two) {
- // Yes! Textures can be any size!
- NPOT_textures = true;
- } else {
- // Workaround needed for lesser graphics cards. Let's hope this works...
- NPOT_textures = false;
- debugOut("Warning: Old graphics card! GLEE_ARB_texture_non_power_of_two not supported.\n");
- }
-
- if (GLEE_ARB_shading_language_100) {
- debugOut("ARB_shading_language_100 supported.\n");
- } else {
- debugOut("Warning: Old graphics card! ARB_shading_language_100 not supported. Try updating your drivers.\n");
- }
- if (GLEE_ARB_shader_objects) {
- debugOut("ARB_shader_objects supported.\n");
- } else {
- fatal("Error: Old graphics card! ARB_shader_objects not supported.\n");
- }
- if (GLEE_ARB_vertex_shader) {
- debugOut("ARB_vertex_shader supported.\n");
- } else {
- fatal("Error: Old graphics card! ARB_vertex_shader not supported.\n");
- }
- if (GLEE_ARB_fragment_shader) {
- debugOut("ARB_fragment_shader supported.\n");
- } else {
- fatal("Error: Old graphics card! ARB_fragment_shader not supported.\n");
- }
- }
-#else
- NPOT_textures = false;
-#endif
-#endif
- int n;
-#if 0
- glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, (GLint *) &n);
-#endif
- debugOut("Max texture image units: %d\n", n);
-
-}
-
// I found this function on a coding forum on the 'net.
// Looks a bit weird, but it should work.
int getNextPOT(int n) {
@@ -857,24 +498,4 @@ int getNextPOT(int n) {
return n;
}
-int printOglError(const char *file, int line) {
- /* Returns 1 if an OpenGL error occurred, 0 otherwise. */
- int retCode = 0;
-#if 0
- GLenum glErr;
-
- glErr = glGetError();
- while (glErr != GL_NO_ERROR) {
-#if !defined(HAVE_GLES2)
- debugOut("glError in file %s @ line %d: %s\n", file, line, gluErrorString(glErr));
-#else
- debugOut("glError in file %s @ line %d: error code %i\n", file, line, glErr);
-#endif
- retCode = 1;
- glErr = glGetError();
- }
-#endif
- return retCode;
-}
-
} // End of namespace Sludge
diff --git a/engines/sludge/graphics.h b/engines/sludge/graphics.h
index 444d8a4534..c03d1947ab 100644
--- a/engines/sludge/graphics.h
+++ b/engines/sludge/graphics.h
@@ -26,31 +26,6 @@
namespace Sludge {
-#if 0
-struct shaders {
- GLuint paste;
- GLuint smartScaler;
- GLuint yuv;
- GLuint texture;
- GLuint color;
-};
-#endif
-
-struct textureList {
-#if 0
- GLuint name;
- GLsizei width;
- GLsizei height;
-#endif
- struct textureList *next;
-};
-
-#if 0
-// From Backdrop.cpp, but they're here anyway
-extern GLubyte *backdropTexture;
-extern GLfloat backdropTexW, backdropTexH;
-#endif
-
extern unsigned int winWidth, winHeight;
extern int viewportHeight, viewportWidth;
extern int viewportOffsetX, viewportOffsetY;
@@ -58,50 +33,11 @@ extern int realWinWidth, realWinHeight;
extern bool NPOT_textures;
-#if 0
-extern shaders shader;
-extern GLfloat aPMVMatrix[];
-
-void setPrimaryColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
-void setSecondaryColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
-
-void drawQuad(GLint program, const GLfloat *vertices, int numTexCoords, ...);
-
-void setPMVMatrix(GLint program);
-#endif
-
void setPixelCoords(bool pixels);
-void setGraphicsWindow(bool fullscreen, bool restoreGraphics = true,
- bool resize = false);
-
-void setupOpenGLStuff();
+void setGraphicsWindow(bool fullscreen, bool restoreGraphics = true, bool resize = false);
int getNextPOT(int n);
-#if 0
-void saveTexture(GLuint tex, GLubyte *data);
-
-void dcopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border, GLuint name, const char *file, int line);
-void dcopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, GLuint name, const char *file, int line);
-void dtexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *data, GLuint name, const char *file, int line);
-void dtexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *data, GLuint name, const char *file, int line);
-
-#define copyTexImage2D(target, level, internalformat, x, y, width, height, border, name) dcopyTexImage2D(target, level, internalformat, x, y, width,height, border, name, __FILE__, __LINE__)
-
-#define copyTexSubImage2D(target, level, xoffset,yoffset, x, y, width, height, name) dcopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height, name, __FILE__, __LINE__)
-
-#define texImage2D(target, level, internalformat, width, height, border, format, type, data,name) dtexImage2D( target, level, internalformat, width, height, border, format, type, data, name, __FILE__, __LINE__)
-
-#define texSubImage2D( target, level, xoffset, yoffset, width, height, format, type, data,name) dtexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, data, name, __FILE__, __LINE__)
-
-void deleteTextures(GLsizei n, const GLuint *textures);
-
-void getTextureDimensions(GLuint name, GLint *width, GLint *height);
-
-int printOglError(const char *file, int line);
-#define printOpenGLError() printOglError(__FILE__, __LINE__)
-#endif
-
}
// End of namespace Sludge
diff --git a/engines/sludge/main_loop.cpp b/engines/sludge/main_loop.cpp
index d530555a47..636deeb09c 100644
--- a/engines/sludge/main_loop.cpp
+++ b/engines/sludge/main_loop.cpp
@@ -337,10 +337,6 @@ int main_loop(const char *filename)
killSoundStuff();
-#if defined(HAVE_GLES2)
- EGL_Close();
-#endif
-
#if 0
/* Clean up the SDL library */
SDL_Quit();
diff --git a/engines/sludge/movie.cpp b/engines/sludge/movie.cpp
index 51f45e5120..2d431e8f60 100644
--- a/engines/sludge/movie.cpp
+++ b/engines/sludge/movie.cpp
@@ -607,11 +607,6 @@ int playMovie(int fileNumber) {
int frameCounter = 0;
movieStartTick = SDL_GetTicks();
-#ifdef HAVE_GLES2
- GLuint old_fbo;
- glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint *)&old_fbo);
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
-#endif
while (movieIsPlaying) {
@@ -932,18 +927,14 @@ int playMovie(int fileNumber) {
}
glFlush();
-#if !defined(HAVE_GLES2)
- SDL_GL_SwapBuffers();
-#else
+
EGL_SwapBuffers();
-#endif
}
videoUpdated = false;
}
// Cleanup
-#ifdef HAVE_GLES2
glBindFramebuffer(GL_FRAMEBUFFER, old_fbo);
movieIsPlaying = nothing;
@@ -985,7 +976,7 @@ int playMovie(int fileNumber) {
Init_Timer();
glViewport(viewportOffsetX, viewportOffsetY, viewportWidth, viewportHeight);
-#endif
+
setPixelCoords(false);
#endif
return 1;
diff --git a/engines/sludge/sludger.cpp b/engines/sludge/sludger.cpp
index c9005e3ff6..26412a01d8 100644
--- a/engines/sludge/sludger.cpp
+++ b/engines/sludge/sludger.cpp
@@ -525,13 +525,8 @@ bool initSludge(const char *filename) {
// There's no startup window on Linux and respecting this
// option from the ini file would disable commandline options.
-#if defined __unix__ && !(defined __APPLE__)
saveIniFile(filename);
-#else
- if (!gameSettings.noStartWindow) {
- saveIniFile(filename);
- }
-#endif
+
// Now set file indices properly to the chosen language.
languageNum = getLanguageForFileB();
@@ -581,99 +576,6 @@ void displayBase() {
}
void sludgeDisplay() {
-#if 0
-#if defined(HAVE_GLES2)
-#ifndef GL_DEPTH24_STENCIL8
-#define GL_DEPTH24_STENCIL8 0x88F0
-#endif
- // create an FBO
- static GLuint fbo = 0;
- static GLuint fbo_tex = 0;
- static GLuint fbo_rbo = 0;
- static float fbo_tex_w, fbo_tex_h;
- static GLuint fbo_shad, fbo_vert, fbo_frag;
- if (fbo == 0) {
- // create FBO
- int width = 1;
- while (width < realWinWidth) width *= 2;
- int height = 1;
- while (height < realWinHeight) height *= 2;
- glGenFramebuffers(1, &fbo);
- glGenTextures(1, &fbo_tex);
- glGenRenderbuffers(1, &fbo_rbo);
- glBindTexture(GL_TEXTURE_2D, fbo_tex);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
- glBindTexture(GL_TEXTURE_2D, 0);
- glBindRenderbuffer(GL_RENDERBUFFER, fbo_rbo);
- glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height);
- glBindRenderbuffer(GL_RENDERBUFFER, 0);
- glBindFramebuffer(GL_FRAMEBUFFER, fbo);
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fbo_tex, 0);
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fbo_rbo);
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fbo_rbo);
- GLenum ret = glCheckFramebufferStatus(GL_FRAMEBUFFER);
- printf("Screen is %dx%d, FBO(%dx%d) Status = 0x%04X\n", realWinWidth, realWinHeight, width, height, ret);
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
- glBindFramebuffer(GL_FRAMEBUFFER, fbo);
- fbo_tex_w = (float)realWinWidth / width;
- fbo_tex_h = (float)realWinHeight / height;
- // create shader for blitting the fbo...
- const char _blit_vsh[] = " \n\t"
- "attribute highp vec2 aPosition; \n\t"
- "attribute highp vec2 aTexCoord; \n\t"
- "varying mediump vec2 vTexCoord; \n\t"
- "void main(){ \n\t"
- "gl_Position = vec4(aPosition.x, aPosition.y, 0.0, 1.0);\n\t"
- "vTexCoord = aTexCoord; \n\t"
- "} \n\t";
-
- const char _blit_fsh[] = " \n\t"
- "uniform sampler2D uTex; \n\t"
- "varying mediump vec2 vTexCoord; \n\t"
- "void main(){ \n\t"
- "gl_FragColor = texture2D(uTex, vTexCoord); \n\t"
- "} \n\t";
-
- GLint success;
- fbo_frag = glCreateShader(GL_FRAGMENT_SHADER);
- const char *src[1];
- src[0] = _blit_fsh;
- glShaderSource(fbo_frag, 1, src, NULL);
- glCompileShader(fbo_frag);
- glGetShaderiv(fbo_frag, GL_COMPILE_STATUS, &success);
- if (!success) {
- printf("Failed to produce default fragment shader.\n");
- }
- fbo_vert = glCreateShader(GL_VERTEX_SHADER);
- src[0] = _blit_vsh;
- glShaderSource(fbo_vert, 1, src, NULL);
- glCompileShader(fbo_vert);
- glGetShaderiv(fbo_vert, GL_COMPILE_STATUS, &success);
- if (!success) {
- printf("Failed to produce default vertex shader.\n");
- }
- fbo_shad = glCreateProgram();
- glBindAttribLocation(fbo_shad, 0, "aPosition");
- glBindAttribLocation(fbo_shad, 1, "aTexCoord");
- glAttachShader(fbo_shad, fbo_frag);
- glAttachShader(fbo_shad, fbo_vert);
- glLinkProgram(fbo_shad);
- glGetProgramiv(fbo_shad, GL_LINK_STATUS, &success);
- if (!success) {
- printf("Failed to link default program.\n");
- }
- glUniform1i(glGetUniformLocation(fbo_shad, "uTex"), 0);
-
- }
-#endif
-
- glDepthMask(GL_TRUE);
-// glClearColor(0.5, 0.5, 1.0, 0.0);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);// Clear The Screen
- glDepthMask(GL_FALSE);
-#endif
displayBase();
viewSpeech();// ...and anything being said
drawStatusBar();
@@ -681,42 +583,6 @@ void sludgeDisplay() {
g_system->copyRectToScreen((byte *)renderSurface.getPixels(), renderSurface.pitch, 0, 0, renderSurface.w, renderSurface.h);
g_system->updateScreen();
if (brightnessLevel < 255) fixBrightness();// This is for transitionLevel special effects
-#if 0
- glFlush();
-#if !defined(HAVE_GLES2)
- SDL_GL_SwapBuffers();
-#else
- if (fbo) {
- // blit the FBO now
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
- GLuint old_prog;
- glGetIntegerv(GL_CURRENT_PROGRAM, (GLint *)&old_prog);
- glUseProgram(fbo_shad);
- glViewport(0, 0, realWinWidth, realWinHeight);
- const float vert[] = {
- -1.0, -1.0, +0.0, +0.0,
- +1.0, -1.0, fbo_tex_w, +0.0,
- -1.0, +1.0, +0.0, fbo_tex_h,
- +1.0, +1.0, fbo_tex_w, fbo_tex_h
- };
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, fbo_tex);
- glEnableVertexAttribArray(0);
- glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (float *)vert);
- glEnableVertexAttribArray(1);
- glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (float *)vert + 2);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- glBindTexture(GL_TEXTURE_2D, 0);
- glUseProgram(old_prog);
- glViewport(viewportOffsetX, viewportOffsetY, viewportWidth, viewportHeight);
- }
- EGL_SwapBuffers();
- if (fbo) {
- // Rebind FBO now
- glBindFramebuffer(GL_FRAMEBUFFER, fbo);
- }
-#endif
-#endif
}
void pauseFunction(loadedFunction *fun) {
diff --git a/engines/sludge/sprites.cpp b/engines/sludge/sprites.cpp
index a89d37d8c8..660e580b28 100644
--- a/engines/sludge/sprites.cpp
+++ b/engines/sludge/sprites.cpp
@@ -668,138 +668,6 @@ bool scaleSprite(sprite &single, const spritePalette &fontPal, onScreenPerson *t
return a != 0;
}
return false;
-
-#if 0
- GLfloat z;
-
- if ((!(thisPerson->extra & EXTRA_NOZB)) && zBuffer.numPanels) {
- int i;
- for (i = 1; i < zBuffer.numPanels; i++) {
- if (zBuffer.panel[i] >= y + cameraY) {
- i--;
- break;
- }
- }
- z = 0.999 - (double) i * (1.0 / 128.0);
- } else {
- z = -0.5;
- }
-
- float ltx1, ltx2, lty1, lty2;
- if (! NPOT_textures) {
- ltx1 = lightMap.texW * (x1 + cameraX) / sceneWidth;
- ltx2 = lightMap.texW * (x2 + cameraX) / sceneWidth;
- lty1 = lightMap.texH * (y1 + cameraY) / sceneHeight;
- lty2 = lightMap.texH * (y2 + cameraY) / sceneHeight;
- } else {
- ltx1 = (float)(x1 + cameraX) / sceneWidth;
- ltx2 = (float)(x2 + cameraX) / sceneWidth;
- lty1 = (float)(y1 + cameraY) / sceneHeight;
- lty2 = (float)(y2 + cameraY) / sceneHeight;
- }
-
- const GLfloat ltexCoords[] = {
- ltx1, lty1,
- ltx2, lty1,
- ltx1, lty2,
- ltx2, lty2
- };
-
- bool light = !(thisPerson->extra & EXTRA_NOLITE);
- if (light && lightMap.data) {
- if (lightMapMode == LIGHTMAPMODE_HOTSPOT) {
- int lx = (int)(x + cameraX);
- int ly = (int)(y + cameraY);
-
- if (lx < 0) lx = 0;
- else if (lx >= sceneWidth) lx = sceneWidth - 1;
- if (ly < 0) ly = 0;
- else if (ly >= sceneHeight) ly = sceneHeight - 1;
-
- GLubyte *target;
- if (! NPOT_textures) {
- target = lightMap.data + (ly * getNextPOT(sceneWidth) + lx) * 4;
- } else {
- target = lightMap.data + (ly * sceneWidth + lx) * 4;
- }
- curLight[0] = target[0];
- curLight[1] = target[1];
- curLight[2] = target[2];
- } else if (lightMapMode == LIGHTMAPMODE_PIXEL) {
- curLight[0] = curLight[1] = curLight[2] = 255;
-
- glActiveTexture(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_2D, lightMap.name);
- glActiveTexture(GL_TEXTURE0);
-
- }
- } else {
- curLight[0] = curLight[1] = curLight[2] = 255;
- }
-#ifndef HAVE_GLES2
- if (!(thisPerson->extra & EXTRA_RECTANGULAR))
- checkColourChange(true);
-#endif
- setDrawMode(thisPerson);
-
- glBindTexture(GL_TEXTURE_2D, fontPal.tex_names[single.texNum]);
-
- glEnable(GL_BLEND);
-
- glUseProgram(shader.smartScaler);
- GLuint uniform = glGetUniformLocation(shader.smartScaler, "useLightTexture");
- if (uniform >= 0) glUniform1i(uniform, light && lightMapMode == LIGHTMAPMODE_PIXEL && lightMap.data);
-
- setPMVMatrix(shader.smartScaler);
-
- if (gameSettings.antiAlias == 1) {
- glUniform1i(glGetUniformLocation(shader.smartScaler, "antialias"), 1);
- } else {
- glUniform1i(glGetUniformLocation(shader.smartScaler, "antialias"), 0);
- }
-
- const GLfloat vertices[] = {
- x1, y1, z,
- x2, y1, z,
- x1, y2, z,
- x2, y2, z
- };
-
- if (! mirror) {
- GLfloat tx3 = tx1;
- tx1 = tx2;
- tx2 = tx3;
- }
- const GLfloat texCoords[] = {
- tx2, ty1,
- tx1, ty1,
- tx2, ty2,
- tx1, ty2
- };
-
- drawQuad(shader.smartScaler, vertices, 2, texCoords, ltexCoords);
-
- glDisable(GL_BLEND);
- glUseProgram(0);
-
- if (light && lightMapMode == LIGHTMAPMODE_PIXEL) {
- glActiveTexture(GL_TEXTURE1);
- glActiveTexture(GL_TEXTURE0);
- }
-
- setSecondaryColor(0., 0., 0., 1.);
-
- // Are we pointing at the sprite?
- if (input.mouseX >= x1 && input.mouseX <= x2 && input.mouseY >= y1 && input.mouseY <= y2) {
- if (thisPerson->extra & EXTRA_RECTANGULAR) return true;
-#ifdef HAVE_GLES2
- return true;
-#else
- return checkColourChange(false);
-#endif
- }
- return false;
-#endif
}
void resetSpriteLayers(zBufferData *pz, int x, int y, bool upsidedown) {
diff --git a/engines/sludge/thumbnail.cpp b/engines/sludge/thumbnail.cpp
index b628f0bd8d..74c77ff5b4 100644
--- a/engines/sludge/thumbnail.cpp
+++ b/engines/sludge/thumbnail.cpp
@@ -99,7 +99,6 @@ bool saveThumbnail(Common::WriteStream *stream) {
thumbnailTextureName = 0;
// Save Our ViewPort
-#ifdef HAVE_GLES2
GLushort *image = new GLushort [thumbWidth * thumbHeight];
GLuint *tmp = new GLuint [thumbWidth * thumbHeight];
if (! checkNew(image)) return false;
@@ -111,12 +110,6 @@ bool saveThumbnail(Common::WriteStream *stream) {
}
}
delete[] tmp;
-#else
- GLushort *image = new GLushort [thumbWidth * thumbHeight];
- if (! checkNew(image)) return false;
-
- glReadPixels(viewportOffsetX, viewportOffsetY, thumbWidth, thumbHeight, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, image);
-#endif
glUseProgram(0);
#endif