[Scummvm-git-logs] scummvm master -> d96ac486c9bc5b751e466bddc2aea3d7f8d6c459

sev- sev at scummvm.org
Sun May 16 15:09:47 UTC 2021


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
ada51d0b49 SLUDGE: Implement Dissolve transition
d359183fc0 SLUDGE: Implement TV transition
d96ac486c9 SLUDGE: Implement Blinds transition


Commit: ada51d0b492fb0dcede135283f3fbd2bfa9ca049
    https://github.com/scummvm/scummvm/commit/ada51d0b492fb0dcede135283f3fbd2bfa9ca049
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-16T17:09:32+02:00

Commit Message:
SLUDGE: Implement Dissolve transition

Changed paths:
    engines/sludge/graphics.cpp
    engines/sludge/graphics.h
    engines/sludge/transition.cpp


diff --git a/engines/sludge/graphics.cpp b/engines/sludge/graphics.cpp
index 84b0f22770..56dabe35b7 100644
--- a/engines/sludge/graphics.cpp
+++ b/engines/sludge/graphics.cpp
@@ -90,6 +90,7 @@ void GraphicsManager::init() {
 	resetRandW();
 	_brightnessLevel = 255;
 	_fadeMode = 2;
+	_transitionTexture = nullptr;
 }
 
 void GraphicsManager::kill() {
@@ -142,6 +143,12 @@ void GraphicsManager::kill() {
 
 	if (_origBackdropSurface.getPixels())
 		_origBackdropSurface.free();
+
+	if (_transitionTexture) {
+		_transitionTexture->free();
+		delete _transitionTexture;
+		_transitionTexture = nullptr;
+	}
 }
 
 bool GraphicsManager::initGfx() {
diff --git a/engines/sludge/graphics.h b/engines/sludge/graphics.h
index dcfdfbb50d..448cc79a3c 100644
--- a/engines/sludge/graphics.h
+++ b/engines/sludge/graphics.h
@@ -185,8 +185,10 @@ public:
 	void setFadeMode(int fadeMode) { _fadeMode = fadeMode; };
 	void fixBrightness();
 	void resetRandW();
+	void reserveTransitionTexture();
 
 	void transitionFader();
+	void transitionDisolve();
 
 private:
 	SludgeEngine *_vm;
@@ -244,6 +246,12 @@ private:
 	byte _brightnessLevel;
 	byte _fadeMode;
 
+#define RANDKK 17
+
+	uint32 _randbuffer[RANDKK][2];
+	int _randp1, _randp2;
+	Graphics::TransparentSurface *_transitionTexture;
+
 	// Parallax
 	ParallaxLayers *_parallaxLayers;
 
diff --git a/engines/sludge/transition.cpp b/engines/sludge/transition.cpp
index 8e0b56d30d..e2a4615ac2 100644
--- a/engines/sludge/transition.cpp
+++ b/engines/sludge/transition.cpp
@@ -20,6 +20,7 @@
  *
  */
 
+#include "common/textconsole.h"
 #include "sludge/graphics.h"
 
 namespace Sludge {
@@ -124,121 +125,68 @@ void transitionSnapshotBox() {
 // FAST PSEUDO-RANDOM NUMBER STUFF FOR DISOLVE EFFECT
 //----------------------------------------------------
 
-#define KK 17
-uint32 randbuffer[KK][2];  // history buffer
-int p1, p2;
-
 void GraphicsManager::resetRandW() {
 	int32 seed = 12345;
 
-	for (int i = 0; i < KK; i++) {
+	for (int i = 0; i < RANDKK; i++) {
 		for (int j = 0; j < 2; j++) {
 			seed = seed * 2891336453u + 1;
-			randbuffer[i][j] = seed;
+			_randbuffer[i][j] = seed;
 		}
 	}
 
-	p1 = 0;
-	p2 = 10;
+	_randp1 = 0;
+	_randp2 = 10;
 }
 
-#if 0
-GLubyte *transitionTexture = NULL;
-GLuint transitionTextureName = 0;
-#endif
-
-bool reserveTransitionTexture() {
-#if 0
-	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-
-	if (! transitionTexture) {
-		transitionTexture = new GLubyte [256 * 256 * 4];
-		if (! checkNew(transitionTexture)) return false;
-	}
-
-	if (! transitionTextureName) glGenTextures(1, &transitionTextureName);
-	glBindTexture(GL_TEXTURE_2D, transitionTextureName);
-	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);
+void GraphicsManager::reserveTransitionTexture() {
+	_transitionTexture = new Graphics::TransparentSurface;
 
-	texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, transitionTexture, transitionTextureName);
-#endif
-	return true;
+	_transitionTexture->create(256, 256, _transitionTexture->getSupportedPixelFormat());
 }
 
-void transitionDisolve() {
+void GraphicsManager::transitionDisolve() {
+	if (!_transitionTexture)
+		reserveTransitionTexture();
 
-#if 0
-	if (! transitionTextureName) reserveTransitionTexture();
-
-	if (! brightnessLevel) {
+	if (!_brightnessLevel) {
 		transitionFader();
 		return;
 	}
 
-	uint32 n;
-	uint32 y;
-
-	GLubyte *toScreen = transitionTexture;
-	GLubyte *end = transitionTexture + (256 * 256 * 4);
+	byte *toScreen = (byte *)_transitionTexture->getPixels();
+	byte *end = (byte *)_transitionTexture->getBasePtr(255, 255);
 
 	do {
 		// generate next number
-		n = randbuffer[p1][1];
-		y = (n << 27) | ((n >> (32 - 27)) + randbuffer[p2][1]);
+		uint32 n = _randbuffer[_randp1][1];
+		uint32 y = (n << 27) | ((n >> (32 - 27)) + _randbuffer[_randp2][1]);
 
-		n = randbuffer[p1][0];
-		randbuffer[p1][1] = (n << 19) | ((n >> (32 - 19)) + randbuffer[p2][0]);
-		randbuffer[p1][0] = y;
+		n = _randbuffer[_randp1][0];
+		_randbuffer[_randp1][1] = (n << 19) | ((n >> (32 - 19)) + _randbuffer[_randp2][0]);
+		_randbuffer[_randp1][0] = y;
 
 		// rotate list pointers
-		if (! p1 --) p1 = KK - 1;
-		if (! p2 --) p2 = KK - 1;
-
-		if ((y & 255u) > brightnessLevel) {
-			toScreen[0] = toScreen[1] = toScreen[2] = 0;
-			toScreen[3] = 255;
+		if (!_randp1--)
+			_randp1 = RANDKK - 1;
+		if (!_randp2--)
+			_randp2 = RANDKK - 1;
+
+		if ((y & 0xff) > _brightnessLevel) {
+			toScreen[0] = 255;
+			toScreen[1] = toScreen[2] = toScreen[3] = 0;
 		} else {
 			toScreen[0] = toScreen[1] = toScreen[2] = toScreen[3] = 0;
 		}
 		toScreen += 4;
-	}while (toScreen < end);
-
-	texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, transitionTexture, transitionTextureName);
-
-	glEnable(GL_BLEND);
-
-	const GLfloat vertices[] = {
-		0.f, (GLfloat)winHeight, 0.f,
-		(GLfloat)winWidth, (GLfloat)winHeight, 0.f,
-		0.f, 0.f, 0.f,
-		(GLfloat)winWidth, 0.f, 0.f
-	};
-
-	const GLfloat texCoords[] = {
-		0.0f, 1.0f,
-		1.0f, 1.0f,
-		0.0f, 0.0f,
-		1.0f, 0.0f
-	};
-
-	glUseProgram(shader.texture);
-
-	setPMVMatrix(shader.texture);
-
-	glUniform1i(glGetUniformLocation(shader.texture, "modulateColor"), 1);
-
-	setPrimaryColor(1.0f, 1.0f, 1.0f, 1.0f);
-
-	drawQuad(shader.texture, vertices, 1, texCoords);
+	} while (toScreen < end);
 
-	glUniform1i(glGetUniformLocation(shader.texture, "modulateColor"), 0);
-	glUseProgram(0);
-
-	glDisable(GL_BLEND);
-#endif
+	// The original stretched the texture, we just tile it
+	for (uint y = 0; y < _sceneHeight; y += _transitionTexture->h) {
+		for (uint x = 0; x < _sceneWidth; x += _transitionTexture->w) {
+			_transitionTexture->blit(_renderSurface, x, y);
+		}
+	}
 }
 
 void transitionTV() {
@@ -254,16 +202,18 @@ void transitionTV() {
 
 	do {
 		// generate next number
-		n = randbuffer[p1][1];
-		y = (n << 27) | ((n >> (32 - 27)) + randbuffer[p2][1]);
+		n = _randbuffer[_randp1][1];
+		y = (n << 27) | ((n >> (32 - 27)) + _randbuffer[_randp2][1]);
 
-		n = randbuffer[p1][0];
-		randbuffer[p1][1] = (n << 19) | ((n >> (32 - 19)) + randbuffer[p2][0]);
-		randbuffer[p1][0] = y;
+		n = _randbuffer[_randp1][0];
+		_randbuffer[_randp1][1] = (n << 19) | ((n >> (32 - 19)) + _randbuffer[_randp2][0]);
+		_randbuffer[_randp1][0] = y;
 
 		// rotate list pointers
-		if (! p1 --) p1 = KK - 1;
-		if (! p2 --) p2 = KK - 1;
+		if (!_randp1--)
+			_randp1 = RANDKK - 1;
+		if (!_randp2--)
+			_randp2 = RANDKK - 1;
 
 		if ((y & 255u) > brightnessLevel) {
 			toScreen[0] = toScreen[1] = toScreen[2] = (n & 255);


Commit: d359183fc0e3e08caab38bb7ff18590467160d02
    https://github.com/scummvm/scummvm/commit/d359183fc0e3e08caab38bb7ff18590467160d02
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-16T17:09:32+02:00

Commit Message:
SLUDGE: Implement TV transition

Changed paths:
    engines/sludge/graphics.h
    engines/sludge/transition.cpp


diff --git a/engines/sludge/graphics.h b/engines/sludge/graphics.h
index 448cc79a3c..c54128d552 100644
--- a/engines/sludge/graphics.h
+++ b/engines/sludge/graphics.h
@@ -189,6 +189,7 @@ public:
 
 	void transitionFader();
 	void transitionDisolve();
+	void transitionTV();
 
 private:
 	SludgeEngine *_vm;
diff --git a/engines/sludge/transition.cpp b/engines/sludge/transition.cpp
index e2a4615ac2..7464cf776a 100644
--- a/engines/sludge/transition.cpp
+++ b/engines/sludge/transition.cpp
@@ -189,21 +189,17 @@ void GraphicsManager::transitionDisolve() {
 	}
 }
 
-void transitionTV() {
-
-#if 0
-	if (! transitionTextureName) reserveTransitionTexture();
-
-	uint32 n;
-	uint32 y;
+void GraphicsManager::transitionTV() {
+	if (!_transitionTexture)
+		reserveTransitionTexture();
 
-	GLubyte *toScreen = transitionTexture;
-	GLubyte *end = transitionTexture + (256 * 256 * 4);
+	byte *toScreen = (byte *)_transitionTexture->getPixels();
+	byte *end = (byte *)_transitionTexture->getBasePtr(255, 255);
 
 	do {
 		// generate next number
-		n = _randbuffer[_randp1][1];
-		y = (n << 27) | ((n >> (32 - 27)) + _randbuffer[_randp2][1]);
+		uint32 n = _randbuffer[_randp1][1];
+		uint32 y = (n << 27) | ((n >> (32 - 27)) + _randbuffer[_randp2][1]);
 
 		n = _randbuffer[_randp1][0];
 		_randbuffer[_randp1][1] = (n << 19) | ((n >> (32 - 19)) + _randbuffer[_randp2][0]);
@@ -215,48 +211,21 @@ void transitionTV() {
 		if (!_randp2--)
 			_randp2 = RANDKK - 1;
 
-		if ((y & 255u) > brightnessLevel) {
-			toScreen[0] = toScreen[1] = toScreen[2] = (n & 255);
-			toScreen[3] = (n & 255);
+		if ((y & 255u) > _brightnessLevel) {
+			toScreen[0] = (n & 255);
+			toScreen[1] = toScreen[2] = toScreen[3] = (n & 255);
 		} else {
 			toScreen[0] = toScreen[1] = toScreen[2] = toScreen[3] = 0;
 		}
 		toScreen += 4;
-	}while (toScreen < end);
-
-	texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, transitionTexture, transitionTextureName);
-
-	glEnable(GL_BLEND);
-
-	const GLfloat vertices[] = {
-		0.f, (GLfloat)winHeight, 0.f,
-		(GLfloat)winWidth, (GLfloat)winHeight, 0.f,
-		0.f, 0.f, 0.f,
-		(GLfloat)winWidth, 0.f, 0.f
-	};
-
-	const GLfloat texCoords[] = {
-		0.0f, 1.0f,
-		1.0f, 1.0f,
-		0.0f, 0.0f,
-		1.0f, 0.0f
-	};
-
-	glUseProgram(shader.texture);
-
-	setPMVMatrix(shader.texture);
-
-	glUniform1i(glGetUniformLocation(shader.texture, "modulateColor"), 1);
-
-	setPrimaryColor(1.0f, 1.0f, 1.0f, 1.0f);
-
-	drawQuad(shader.texture, vertices, 1, texCoords);
-
-	glUniform1i(glGetUniformLocation(shader.texture, "modulateColor"), 0);
-	glUseProgram(0);
+	} while (toScreen < end);
 
-	glDisable(GL_BLEND);
-#endif
+	// The original stretched the texture, we just tile it
+	for (uint y = 0; y < _sceneHeight; y += _transitionTexture->h) {
+		for (uint x = 0; x < _sceneWidth; x += _transitionTexture->w) {
+			_transitionTexture->blit(_renderSurface, x, y);
+		}
+	}
 }
 
 void transitionBlinds() {


Commit: d96ac486c9bc5b751e466bddc2aea3d7f8d6c459
    https://github.com/scummvm/scummvm/commit/d96ac486c9bc5b751e466bddc2aea3d7f8d6c459
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-16T17:09:32+02:00

Commit Message:
SLUDGE: Implement Blinds transition

Changed paths:
    engines/sludge/graphics.h
    engines/sludge/transition.cpp


diff --git a/engines/sludge/graphics.h b/engines/sludge/graphics.h
index c54128d552..d0861fd2e5 100644
--- a/engines/sludge/graphics.h
+++ b/engines/sludge/graphics.h
@@ -190,6 +190,7 @@ public:
 	void transitionFader();
 	void transitionDisolve();
 	void transitionTV();
+	void transitionBlinds();
 
 private:
 	SludgeEngine *_vm;
diff --git a/engines/sludge/transition.cpp b/engines/sludge/transition.cpp
index 7464cf776a..d25817cb2d 100644
--- a/engines/sludge/transition.cpp
+++ b/engines/sludge/transition.cpp
@@ -228,52 +228,35 @@ void GraphicsManager::transitionTV() {
 	}
 }
 
-void transitionBlinds() {
-#if 0
-	if (! transitionTextureName) reserveTransitionTexture();
-
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
-
-	GLubyte *toScreen = transitionTexture;
-
-	int level = brightnessLevel / 8;
-
-	if (level) memset(toScreen, 0, 256 * 32 * level);
-	if (level < 32) memset(toScreen + 256 * 32 * level, 255, 256 * 32 * (32 - level));
-
-	texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, transitionTexture, transitionTextureName);
-
-	glEnable(GL_BLEND);
-
-	const GLfloat vertices[] = {
-		0.f, (GLfloat)winHeight, 0.f,
-		(GLfloat)winWidth, (GLfloat)winHeight, 0.f,
-		0.f, 0.f, 0.f,
-		(GLfloat)winWidth, 0.f, 0.f
-	};
-
-	const GLfloat texCoords[] = {
-		0.0f, 0.0f,
-		1.0f, 0.0f,
-		0.0f, 25.0f,
-		1.0f, 25.0f
-	};
-
-	glUseProgram(shader.texture);
-
-	setPMVMatrix(shader.texture);
-
-	glUniform1i(glGetUniformLocation(shader.texture, "modulateColor"), 1);
-
-	setPrimaryColor(0.0f, 0.0f, 0.0f, 1.0f);
-
-	drawQuad(shader.texture, vertices, 1, texCoords);
+void GraphicsManager::transitionBlinds() {
+	if (!_transitionTexture)
+		reserveTransitionTexture();
 
-	glUniform1i(glGetUniformLocation(shader.texture, "modulateColor"), 0);
-	glUseProgram(0);
+	int level = _brightnessLevel / 16;
+
+	for (int b = 0; b < 16; b++) {
+		byte *toScreen = (byte *)_transitionTexture->getBasePtr(0, b * 16);
+
+		if (level)
+			memset(toScreen, 0, 256 * 4 * level);
+		if (level < 32) {
+			for (int y = 0; y < 16 - level; y++) {
+				toScreen = (byte *)_transitionTexture->getBasePtr(0, b * 16 + y);
+				for (int i = 0; i < 256; i++) {
+					toScreen[0] = 0xff;
+					toScreen[1] = toScreen[2] = toScreen[3] = 0;
+					toScreen += 4;
+				}
+			}
+		}
 
-	glDisable(GL_BLEND);
-#endif
+		// The original stretched the texture, we just tile it
+		for (uint y = 0; y < _sceneHeight; y += _transitionTexture->h) {
+			for (uint x = 0; x < _sceneWidth; x += _transitionTexture->w) {
+				_transitionTexture->blit(_renderSurface, x, y);
+			}
+		}
+	}
 }
 
 //----------------------------------------------------




More information about the Scummvm-git-logs mailing list