aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimei Yin2017-07-15 15:33:43 +0200
committerSimei Yin2017-07-15 17:51:57 +0200
commitc25a6ba4af63cf7f59cb0bd3945243b38607ff88 (patch)
tree223860e1f3b0b3373178933ab4c2100ae2577df1
parentfe1617ac513932b4ae5e202ad6bb4ee61289ecb0 (diff)
downloadscummvm-rg350-c25a6ba4af63cf7f59cb0bd3945243b38607ff88.tar.gz
scummvm-rg350-c25a6ba4af63cf7f59cb0bd3945243b38607ff88.tar.bz2
scummvm-rg350-c25a6ba4af63cf7f59cb0bd3945243b38607ff88.zip
SLUDGE: Complete snapshot
-rw-r--r--engines/sludge/backdrop.cpp112
-rw-r--r--engines/sludge/backdrop.h3
2 files changed, 14 insertions, 101 deletions
diff --git a/engines/sludge/backdrop.cpp b/engines/sludge/backdrop.cpp
index 25008b0510..84d68fb3fa 100644
--- a/engines/sludge/backdrop.cpp
+++ b/engines/sludge/backdrop.cpp
@@ -32,6 +32,8 @@
#include "sludge/fileset.h"
#include "sludge/backdrop.h"
#include "sludge/moreio.h"
+#include "sludge/statusba.h"
+#include "sludge/talk.h"
#include "sludge/zbuffer.h"
#include "sludge/graphics.h"
#include "sludge/sludge.h"
@@ -61,6 +63,7 @@ extern int zBufferToSet;
Graphics::Surface lightMap;
Graphics::Surface backdropSurface;
+Graphics::Surface snapshotSurface;
float snapTexW = 1.0;
float snapTexH = 1.0;
@@ -77,127 +80,40 @@ extern int cameraX, cameraY;
extern float cameraZoom;
void nosnapshot() {
-#if 0
- deleteTextures(1, &snapshotTextureName);
- snapshotTextureName = 0;
-#endif
+ if (snapshotSurface.getPixels())
+ snapshotSurface.free();
}
void saveSnapshot(Common::WriteStream *stream) {
-#if 0
- if (snapshotTextureName) {
+ if (snapshotSurface.getPixels()) {
stream->writeByte(1); // 1 for snapshot follows
- saveCoreHSI(stream, snapshotTextureName, winWidth, winHeight);
+ Image::writePNG(*stream, snapshotSurface);
} else {
stream->writeByte(0);
}
-#endif
}
bool snapshot() {
-
nosnapshot();
if (!freeze())
return false;
-#if 0
- setPixelCoords(true);
- glGenTextures(1, &snapshotTextureName);
-
- int w = winWidth;
- int h = winHeight;
- if (!NPOT_textures) {
- w = getNextPOT(winWidth);
- h = getNextPOT(winHeight);
- snapTexW = ((double)winWidth) / w;
- snapTexH = ((double)winHeight) / h;
- }
-
- glBindTexture(GL_TEXTURE_2D, snapshotTextureName);
- 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, snapshotTextureName);
-
- // 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...
-
- glDisable(GL_DEPTH_TEST);
-
- viewSpeech();// ...and anything being said
+ // draw snapshot to backdrop
+ displayBase();
+ viewSpeech(); // ...and anything being said
drawStatusBar();
- // Copy Our ViewPort To The Texture
- copyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewportOffsetX, viewportOffsetY, winWidth, winHeight, snapshotTextureName);
- setPixelCoords(false);
-#endif
+ // copy backdrop to snapshot
+ snapshotSurface.copyFrom(backdropSurface);
+
unfreeze(false);
return true;
}
bool restoreSnapshot(Common::SeekableReadStream *stream) {
- uint picWidth = stream->readUint16BE();
- uint picHeight = stream->readUint16BE();
-
- if ((picWidth != winWidth) || (picHeight != winHeight))
+ if (!(ImgLoader::loadImage(stream, &snapshotSurface))) {
return false;
-#if 0
- uint t1, t2, n;
- uint16 c;
- GLubyte *target;
- if (!NPOT_textures) {
- picWidth = getNextPOT(picWidth);
- picHeight = getNextPOT(picHeight);
- snapTexW = ((double)winWidth) / picWidth;
- snapTexH = ((double)winHeight) / picHeight;
- }
- GLubyte *snapshotTexture = new GLubyte [picHeight * picWidth * 4];
- if (!snapshotTexture) return fatal("Out of memory while restoring snapshot.");
-
- for (t2 = 0; t2 < winHeight; t2++) {
- t1 = 0;
- while (t1 < winWidth) {
- c = (uint16)stream->readUint16BE();
- if (c & 32) {
- n = stream->readByte() + 1;
- c -= 32;
- } else {
- n = 1;
- }
-
- while (n --) {
- target = snapshotTexture + 4 * picWidth * t2 + t1 * 4;
- target[0] = (GLubyte) redValue(c);
- target[1] = (GLubyte) greenValue(c);
- target[2] = (GLubyte) blueValue(c);
- target[3] = (GLubyte) 255;
- t1++;
- }
- }
}
-
- if (!snapshotTextureName) glGenTextures(1, &snapshotTextureName);
- glBindTexture(GL_TEXTURE_2D, snapshotTextureName);
- 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, picWidth, picHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, snapshotTexture, snapshotTextureName);
-
- delete snapshotTexture;
- snapshotTexture = NULL;
-#endif
return true;
}
diff --git a/engines/sludge/backdrop.h b/engines/sludge/backdrop.h
index dbab0dfa8d..14a31eb33f 100644
--- a/engines/sludge/backdrop.h
+++ b/engines/sludge/backdrop.h
@@ -58,9 +58,6 @@ void drawBackDrop();
void blankScreen(int x1, int y1, int x2, int y2);
void darkScreen();
void saveHSI(Common::WriteStream *stream);
-#if 0
-void saveCoreHSI(Common::WriteStream *stream, GLuint texture, int w, int h);
-#endif
bool loadHSI(Common::SeekableReadStream *stream, int, int, bool);
bool mixHSI(Common::SeekableReadStream *stream, int x = 0, int y = 0);
void drawHorizontalLine(uint, uint, uint);