diff options
-rw-r--r-- | engines/sludge/backdrop.cpp | 21 | ||||
-rw-r--r-- | engines/sludge/freeze.cpp | 159 | ||||
-rw-r--r-- | engines/sludge/freeze.h | 12 | ||||
-rw-r--r-- | engines/sludge/zbuffer.h | 5 |
4 files changed, 44 insertions, 153 deletions
diff --git a/engines/sludge/backdrop.cpp b/engines/sludge/backdrop.cpp index dc46c410b1..a1f656f6aa 100644 --- a/engines/sludge/backdrop.cpp +++ b/engines/sludge/backdrop.cpp @@ -24,6 +24,7 @@ #include "common/rect.h" #include "image/png.h" #include "graphics/surface.h" +#include "graphics/transparent_surface.h" #include "graphics/palette.h" #include "sludge/allfiles.h" @@ -50,13 +51,14 @@ void unfreeze(bool); // Because FREEZE.H needs a load of other includes #if 0 GLubyte *backdropTexture = NULL; GLuint backdropTextureName = 0; -bool backdropExists = false; GLfloat backdropTexW = 1.0; GLfloat backdropTexH = 1.0; GLuint snapshotTextureName = 0; #endif +bool backdropExists = false; + Graphics::Surface lightMap; Graphics::Surface backdropSurface; @@ -210,8 +212,8 @@ void killBackDrop() { #if 0 deleteTextures(1, &backdropTextureName); backdropTextureName = 0; - backdropExists = false; #endif + backdropExists = false; } void killLightMap() { @@ -935,19 +937,19 @@ bool loadHSI(Common::SeekableReadStream *stream, int x, int y, bool reserve) { renderToTexture(tmpTex, x, y, picWidth, picHeight, realPicWidth, realPicHeight); deleteTextures(1, &tmpTex); - - backdropExists = true; #endif + backdropExists = true; return true; } bool mixHSI(Common::SeekableReadStream *stream, int x, int y) { debug(kSludgeDebugGraphics, "Load mixHSI"); - if (!ImgLoader::loadImage(stream, &backdropSurface, 0)) + Graphics::Surface mixSurface; + if (!ImgLoader::loadImage(stream, &mixSurface, 0)) return false; - int realPicWidth = backdropSurface.w; - int realPicHeight = backdropSurface.h; + int realPicWidth = mixSurface.w; + int realPicHeight = mixSurface.h; if (x == IN_THE_CENTRE) x = (sceneWidth - realPicWidth) >> 1; @@ -955,6 +957,11 @@ bool mixHSI(Common::SeekableReadStream *stream, int x, int y) { y = (sceneHeight - realPicHeight) >> 1; if (x < 0 || x + realPicWidth > sceneWidth || y < 0 || y + realPicHeight > sceneHeight) return false; + + Graphics::TransparentSurface tmp(mixSurface, false); + tmp.blit(backdropSurface, x, y); + mixSurface.free(); +; #if 0 float btx1, tx1; float btx2, tx2; diff --git a/engines/sludge/freeze.cpp b/engines/sludge/freeze.cpp index 676c06b87f..57d7d0dbe8 100644 --- a/engines/sludge/freeze.cpp +++ b/engines/sludge/freeze.cpp @@ -26,6 +26,7 @@ #include "sludge/sprites.h" #include "sludge/sprbanks.h" #include "sludge/people.h" +#include "sludge/sludge.h" #include "sludge/sludger.h" #include "sludge/objtypes.h" #include "sludge/region.h" @@ -43,9 +44,8 @@ extern screenRegion *allScreenRegions; extern screenRegion *overRegion; extern speechStruct *speech; extern inputType input; -#if 0 -extern GLuint backdropTextureName; -#endif +extern Graphics::Surface backdropSurface; +extern Graphics::Surface renderSurface; extern parallaxLayer *parallaxStuff; extern int lightMapNumber, zBufferNumber; extern eventHandlers *currentEvents; @@ -58,33 +58,17 @@ extern zBufferData zBuffer; extern bool backdropExists; frozenStuffStruct *frozenStuff = NULL; extern unsigned int sceneWidth, sceneHeight; +Graphics::Surface freezeSurface; void shufflePeople(); -#if 0 -GLuint freezeTextureName = 0; -#endif void freezeGraphics() { -#if 0 - glViewport(0, 0, realWinWidth, realWinHeight); - glGenTextures(1, &freezeTextureName); -#endif int w = winWidth; int h = winHeight; - if (!NPOT_textures) { - w = getNextPOT(winWidth); - h = getNextPOT(winHeight); - } -#if 0 - glBindTexture(GL_TEXTURE_2D, freezeTextureName); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - - texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, freezeTextureName); -#endif + + freezeSurface.create(w, h, *g_sludge->getScreenPixelFormat()); + // Temporarily disable AA int antiAlias = gameSettings.antiAlias; gameSettings.antiAlias = 0; @@ -106,45 +90,17 @@ void freezeGraphics() { } else { h = realWinHeight; } -#if 0 - const GLfloat bPMVMatrix[] = { - 2.0f / realWinWidth * cameraZoom, .0, .0, .0, - .0, 2.0f / realWinHeight * cameraZoom, .0, .0, - .0, .0, 1.0f, .0, - -2.0f * (x / realWinWidth) - 1.0f, -2.0f * (y / realWinHeight) - 1.0f, .0, 1.0f - - }; - for (int i = 0; i < 16; i++) { - aPMVMatrix[i] = bPMVMatrix[i]; - } - // Render scene - glDepthMask(GL_TRUE); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);// Clear The Screen - glDepthMask(GL_FALSE); - drawBackDrop();// Draw the room drawZBuffer(cameraX, cameraY, false); - - glEnable(GL_DEPTH_TEST); - drawPeople();// Then add any moving characters... + freezeSurface.copyFrom(renderSurface); - glDisable(GL_DEPTH_TEST); - - // Copy Our ViewPort To The Texture - copyTexSubImage2D(GL_TEXTURE_2D, 0, x, y, 0, 0, w, h, freezeTextureName); -#endif y += h; } x += w; } gameSettings.antiAlias = antiAlias; - -#if 0 - glViewport(viewportOffsetX, viewportOffsetY, viewportWidth, viewportHeight); - setPixelCoords(false); -#endif } bool freeze() { @@ -155,77 +111,36 @@ bool freeze() { // Grab a copy of the current scene freezeGraphics(); -#if 0 - newFreezer->backdropTextureName = backdropTextureName; -#endif int picWidth = sceneWidth; int picHeight = sceneHeight; if (!NPOT_textures) { picWidth = getNextPOT(picWidth); picHeight = getNextPOT(picHeight); } -#if 0 - newFreezer->backdropTexture = new GLubyte[picHeight * picWidth * 4]; - if (!checkNew(newFreezer->backdropTexture)) - return false; - - saveTexture(backdropTextureName, newFreezer->backdropTexture); - - backdropTextureName = 0; -#endif + newFreezer->backdropSurface.copyFrom(backdropSurface); newFreezer->sceneWidth = sceneWidth; newFreezer->sceneHeight = sceneHeight; newFreezer->cameraX = cameraX; newFreezer->cameraY = cameraY; newFreezer->cameraZoom = cameraZoom; -#if 0 - newFreezer->lightMapTexture = lightMap.data; - newFreezer->lightMapTextureName = lightMap.name; + + newFreezer->lightMapSurface.copyFrom(lightMap); newFreezer->lightMapNumber = lightMapNumber; - lightMap.data = NULL; - lightMap.name = 0; + newFreezer->parallaxStuff = parallaxStuff; parallaxStuff = NULL; - newFreezer->zBufferImage = zBuffer.tex; + newFreezer->zBufferImage.copyFrom(zBuffer.surface); newFreezer->zBufferNumber = zBuffer.originalNum; newFreezer->zPanels = zBuffer.numPanels; - zBuffer.tex = NULL; -#endif + zBuffer.surface.free(); // resizeBackdrop kills parallax stuff, light map, z-buffer... if (!killResizeBackdrop(winWidth, winHeight)) return fatal("Can't create new temporary backdrop buffer"); - if (!NPOT_textures) { - picWidth = getNextPOT(sceneWidth); - picHeight = getNextPOT(sceneHeight); -#if 0 - backdropTexW = (double)sceneWidth / picWidth; - backdropTexH = (double)sceneHeight / picHeight; -#endif - } - -#if 0 // Copy the old scene to the new backdrop - deleteTextures(1, &backdropTextureName); - backdropTextureName = freezeTextureName; + backdropSurface.copyFrom(freezeSurface); backdropExists = true; - // Free texture memory used by old stuff - parallaxStuff = newFreezer->parallaxStuff; - while (parallaxStuff) { - deleteTextures(1, ¶llaxStuff->textureName); - parallaxStuff = parallaxStuff->next; - } - if (newFreezer->zBufferImage) { - deleteTextures(1, &zBuffer.texName); - } - if (newFreezer->lightMapTextureName) { - deleteTextures(1, &newFreezer->lightMapTextureName); - } - if (newFreezer->backdropTextureName) { - deleteTextures(1, &newFreezer->backdropTextureName); - } -#endif newFreezer->allPeople = allPeople; allPeople = NULL; @@ -268,10 +183,6 @@ int howFrozen() { return a; } -#if 0 -extern GLubyte *backdropTexture; -#endif - void unfreeze(bool killImage) { frozenStuffStruct *killMe = frozenStuff; @@ -297,21 +208,18 @@ void unfreeze(bool killImage) { allScreenRegions = frozenStuff->allScreenRegions; killLightMap(); -#if 0 - lightMap.data = frozenStuff->lightMapTexture; - lightMap.name = frozenStuff->lightMapTextureName; + + lightMap.copyFrom(frozenStuff->lightMapSurface); lightMapNumber = frozenStuff->lightMapNumber; if (lightMapNumber) { - lightMap.name = 0; loadLightMap(lightMapNumber); } killZBuffer(); - zBuffer.tex = frozenStuff->zBufferImage; + zBuffer.surface.copyFrom(frozenStuff->zBufferImage); zBuffer.originalNum = frozenStuff->zBufferNumber; zBuffer.numPanels = frozenStuff->zPanels; if (zBuffer.numPanels) { - zBuffer.texName = 0; setZBuffer(zBuffer.originalNum); } @@ -321,36 +229,11 @@ void unfreeze(bool killImage) { if (killImage) killBackDrop(); - backdropTextureName = frozenStuff->backdropTextureName; - if (backdropTexture) - delete[] backdropTexture; - backdropTexture = frozenStuff->backdropTexture; + if (backdropSurface.getPixels()) + backdropSurface.free(); + backdropSurface.copyFrom(frozenStuff->backdropSurface); backdropExists = true; - if (backdropTextureName) { - backdropTextureName = 0; - glGenTextures(1, &backdropTextureName); - glBindTexture(GL_TEXTURE_2D, backdropTextureName); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - if (gameSettings.antiAlias < 0) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - } else { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - } - int picWidth = sceneWidth; - int picHeight = sceneHeight; - if (!NPOT_textures) { - picWidth = getNextPOT(picWidth); - picHeight = getNextPOT(picHeight); - } - // Restore the backdrop - texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, picWidth, picHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, frozenStuff->backdropTexture, backdropTextureName); - } -#endif deleteAnim(mouseCursorAnim); mouseCursorAnim = frozenStuff->mouseCursorAnim; mouseCursorFrameNum = frozenStuff->mouseCursorFrameNum; diff --git a/engines/sludge/freeze.h b/engines/sludge/freeze.h index 4472852217..cfd5747854 100644 --- a/engines/sludge/freeze.h +++ b/engines/sludge/freeze.h @@ -22,18 +22,16 @@ #ifndef SLUDGE_FREEZE_H #define SLUDGE_FREEZE_H +#include "graphics/surface.h" + namespace Sludge { struct frozenStuffStruct { onScreenPerson *allPeople; screenRegion *allScreenRegions; -#if 0 - GLubyte *backdropTexture; - GLuint backdropTextureName; - GLuint lightMapTextureName; - GLubyte *lightMapTexture; - GLubyte *zBufferImage; -#endif + Graphics::Surface backdropSurface; + Graphics::Surface lightMapSurface; + Graphics::Surface zBufferImage; int zPanels; parallaxLayer *parallaxStuff; int lightMapNumber, zBufferNumber; diff --git a/engines/sludge/zbuffer.h b/engines/sludge/zbuffer.h index bb0b2ed9d8..f78b655cd5 100644 --- a/engines/sludge/zbuffer.h +++ b/engines/sludge/zbuffer.h @@ -22,15 +22,18 @@ #ifndef SLUDGE_ZBUFFER_H #define SLUDGE_ZBUFFER_H +#include "graphics/surface.h" + namespace Sludge { struct zBufferData { - int width, height; // bool loaded; int numPanels; int panel[16]; int originalNum; + Graphics::Surface surface; #if 0 + int width, height; GLubyte *tex; GLuint texName; #endif |