[Scummvm-git-logs] scummvm master -> 653afbbed608f52f0d5779280547a52467ef2cdb

neuromancer noreply at scummvm.org
Sun Aug 6 18:12:36 UTC 2023


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

Summary:
f7fa9e07f1 FREESCAPE: draw crossair inside gfx using blending effect
653afbbed6 FREESCAPE: avoid crashes in driller cga


Commit: f7fa9e07f1e7a2ca7e18efb12ace41963ed6f8ee
    https://github.com/scummvm/scummvm/commit/f7fa9e07f1e7a2ca7e18efb12ace41963ed6f8ee
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-08-06T20:13:07+02:00

Commit Message:
FREESCAPE: draw crossair inside gfx using blending effect

Changed paths:
    engines/freescape/gfx.h
    engines/freescape/gfx_opengl.cpp
    engines/freescape/gfx_opengl.h
    engines/freescape/gfx_opengl_shaders.cpp
    engines/freescape/gfx_opengl_shaders.h
    engines/freescape/gfx_tinygl.cpp
    engines/freescape/gfx_tinygl.h
    engines/freescape/ui.cpp


diff --git a/engines/freescape/gfx.h b/engines/freescape/gfx.h
index 746e0e3f64f..1a190222117 100644
--- a/engines/freescape/gfx.h
+++ b/engines/freescape/gfx.h
@@ -84,6 +84,8 @@ public:
 
 	virtual void renderSensorShoot(byte color, const Math::Vector3d sensor, const Math::Vector3d player, const Common::Rect viewPort) = 0;
 	virtual void renderPlayerShoot(byte color, const Common::Point position, const Common::Rect viewPort) = 0;
+	virtual void renderCrossair(const Common::Point crossairPosition) = 0;
+
 	virtual void renderCube(const Math::Vector3d &position, const Math::Vector3d &size, Common::Array<uint8> *colours);
 	virtual void renderRectangle(const Math::Vector3d &position, const Math::Vector3d &size, Common::Array<uint8> *colours);
 	virtual void renderPolygon(const Math::Vector3d &origin, const Math::Vector3d &size, const Common::Array<uint16> *ordinates, Common::Array<uint8> *colours);
diff --git a/engines/freescape/gfx_opengl.cpp b/engines/freescape/gfx_opengl.cpp
index 41609da0f57..f6eafa711bc 100644
--- a/engines/freescape/gfx_opengl.cpp
+++ b/engines/freescape/gfx_opengl.cpp
@@ -195,6 +195,45 @@ void OpenGLRenderer::renderSensorShoot(byte color, const Math::Vector3d sensor,
 	glDepthMask(GL_TRUE);
 }
 
+void OpenGLRenderer::renderCrossair(const Common::Point crossairPosition) {
+	glMatrixMode(GL_PROJECTION);
+	glLoadIdentity();
+	glOrtho(0, _screenW, _screenH, 0, 0, 1);
+	glMatrixMode(GL_MODELVIEW);
+	glLoadIdentity();
+	glEnable(GL_BLEND);
+	glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
+
+	glDisable(GL_DEPTH_TEST);
+	glDepthMask(GL_FALSE);
+
+	useColor(255, 255, 255);
+
+	glLineWidth(8); // It will not work in every OpenGL implementation since the
+					 // spec doesn't require support for line widths other than 1
+	glEnableClientState(GL_VERTEX_ARRAY);
+	copyToVertexArray(0, Math::Vector3d(crossairPosition.x - 3, crossairPosition.y, 0));
+	copyToVertexArray(1, Math::Vector3d(crossairPosition.x - 1, crossairPosition.y, 0));
+
+	copyToVertexArray(2, Math::Vector3d(crossairPosition.x + 1, crossairPosition.y, 0));
+	copyToVertexArray(3, Math::Vector3d(crossairPosition.x + 3, crossairPosition.y, 0));
+
+	copyToVertexArray(4, Math::Vector3d(crossairPosition.x, crossairPosition.y - 3, 0));
+	copyToVertexArray(5, Math::Vector3d(crossairPosition.x, crossairPosition.y - 1, 0));
+
+	copyToVertexArray(6, Math::Vector3d(crossairPosition.x, crossairPosition.y + 1, 0));
+	copyToVertexArray(7, Math::Vector3d(crossairPosition.x, crossairPosition.y + 3, 0));
+
+	glVertexPointer(3, GL_FLOAT, 0, _verts);
+	glDrawArrays(GL_LINES, 0, 8);
+	glDisableClientState(GL_VERTEX_ARRAY);
+	glLineWidth(1);
+
+	glDisable(GL_BLEND);
+	glEnable(GL_DEPTH_TEST);
+	glDepthMask(GL_TRUE);
+}
+
 void OpenGLRenderer::renderPlayerShoot(byte color, const Common::Point position, const Common::Rect viewArea) {
 	uint8 r, g, b;
 
diff --git a/engines/freescape/gfx_opengl.h b/engines/freescape/gfx_opengl.h
index 40b68f68458..946aedff7cf 100644
--- a/engines/freescape/gfx_opengl.h
+++ b/engines/freescape/gfx_opengl.h
@@ -100,6 +100,8 @@ public:
 
 	virtual void renderSensorShoot(byte color, const Math::Vector3d sensor, const Math::Vector3d player, const Common::Rect viewPort) override;
 	virtual void renderPlayerShoot(byte color, const Common::Point position, const Common::Rect viewPort) override;
+	virtual void renderCrossair(const Common::Point crossairPosition) override;
+
 	virtual void renderFace(const Common::Array<Math::Vector3d> &vertices) override;
 
 	virtual void flipBuffer() override;
diff --git a/engines/freescape/gfx_opengl_shaders.cpp b/engines/freescape/gfx_opengl_shaders.cpp
index 8f2db32c47a..d69e86e0e0d 100644
--- a/engines/freescape/gfx_opengl_shaders.cpp
+++ b/engines/freescape/gfx_opengl_shaders.cpp
@@ -242,6 +242,56 @@ void OpenGLShaderRenderer::renderPlayerShoot(byte color, const Common::Point pos
 	glDepthMask(GL_TRUE);
 }
 
+void OpenGLShaderRenderer::renderCrossair(const Common::Point crossairPosition) {
+	Math::Matrix4 identity;
+	identity(0, 0) = 1.0;
+	identity(1, 1) = 1.0;
+	identity(2, 2) = 1.0;
+	identity(3, 3) = 1.0;
+
+	_triangleShader->use();
+	_triangleShader->setUniform("useStipple", false);
+	_triangleShader->setUniform("mvpMatrix", identity);
+
+	glMatrixMode(GL_PROJECTION);
+	glLoadIdentity();
+	glOrtho(0, _screenW, _screenH, 0, 0, 1);
+	glMatrixMode(GL_MODELVIEW);
+	glLoadIdentity();
+	glEnable(GL_BLEND);
+	glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
+
+	glDisable(GL_DEPTH_TEST);
+	glDepthMask(GL_FALSE);
+
+	useColor(255, 255, 255);
+
+	glLineWidth(8); // It will not work in every OpenGL implementation since the
+					 // spec doesn't require support for line widths other than 1
+	glEnableClientState(GL_VERTEX_ARRAY);
+	copyToVertexArray(0, Math::Vector3d(remap(crossairPosition.x - 3, _screenW), remap(_screenH - crossairPosition.y, _screenH), 0));
+	copyToVertexArray(1, Math::Vector3d(remap(crossairPosition.x - 1, _screenW), remap(_screenH - crossairPosition.y, _screenH), 0));
+
+	copyToVertexArray(2, Math::Vector3d(remap(crossairPosition.x + 1, _screenW), remap(_screenH - crossairPosition.y, _screenH), 0));
+	copyToVertexArray(3, Math::Vector3d(remap(crossairPosition.x + 3, _screenW), remap(_screenH - crossairPosition.y, _screenH), 0));
+
+	copyToVertexArray(4, Math::Vector3d(remap(crossairPosition.x, _screenW), remap(_screenH - crossairPosition.y - 3, _screenH), 0));
+	copyToVertexArray(5, Math::Vector3d(remap(crossairPosition.x, _screenW), remap(_screenH - crossairPosition.y - 1, _screenH), 0));
+
+	copyToVertexArray(6, Math::Vector3d(remap(crossairPosition.x, _screenW), remap(_screenH - crossairPosition.y + 1, _screenH), 0));
+	copyToVertexArray(7, Math::Vector3d(remap(crossairPosition.x, _screenW), remap(_screenH - crossairPosition.y + 3, _screenH), 0));
+
+	glBindBuffer(GL_ARRAY_BUFFER, _triangleVBO);
+	glBufferData(GL_ARRAY_BUFFER, 8 * 3 * sizeof(float), _verts, GL_DYNAMIC_DRAW);
+	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), nullptr);
+	glDrawArrays(GL_LINES, 0, 8);
+
+	glLineWidth(1);
+	glDisable(GL_BLEND);
+	glEnable(GL_DEPTH_TEST);
+	glDepthMask(GL_TRUE);
+}
+
 void OpenGLShaderRenderer::renderFace(const Common::Array<Math::Vector3d> &vertices) {
 	assert(vertices.size() >= 2);
 	const Math::Vector3d &v0 = vertices[0];
diff --git a/engines/freescape/gfx_opengl_shaders.h b/engines/freescape/gfx_opengl_shaders.h
index 65512b7a56c..5504e274690 100644
--- a/engines/freescape/gfx_opengl_shaders.h
+++ b/engines/freescape/gfx_opengl_shaders.h
@@ -82,6 +82,8 @@ public:
 
 	virtual void renderSensorShoot(byte color, const Math::Vector3d sensor, const Math::Vector3d player, const Common::Rect viewPort) override;
 	virtual void renderPlayerShoot(byte color, const Common::Point position, const Common::Rect viewPort) override;
+	virtual void renderCrossair(const Common::Point crossairPosition) override;
+
 	virtual void renderFace(const Common::Array<Math::Vector3d> &vertices) override;
 
 	virtual void flipBuffer() override;
diff --git a/engines/freescape/gfx_tinygl.cpp b/engines/freescape/gfx_tinygl.cpp
index ba73b80aaee..3b84b2fdcde 100644
--- a/engines/freescape/gfx_tinygl.cpp
+++ b/engines/freescape/gfx_tinygl.cpp
@@ -166,6 +166,42 @@ void TinyGLRenderer::renderPlayerShoot(byte color, const Common::Point position,
 	tglDepthMask(TGL_TRUE);
 }
 
+void TinyGLRenderer::renderCrossair(const Common::Point crossairPosition) {
+	tglMatrixMode(TGL_PROJECTION);
+	tglLoadIdentity();
+	tglOrtho(0, _screenW, _screenH, 0, 0, 1);
+	tglMatrixMode(TGL_MODELVIEW);
+	tglLoadIdentity();
+	tglEnable(TGL_BLEND);
+	tglBlendFunc(TGL_ONE_MINUS_DST_COLOR, TGL_ZERO);
+
+	tglDisable(TGL_DEPTH_TEST);
+	tglDepthMask(TGL_FALSE);
+
+	useColor(255, 255, 255);
+
+	tglEnableClientState(TGL_VERTEX_ARRAY);
+	copyToVertexArray(0, Math::Vector3d(crossairPosition.x - 3, crossairPosition.y, 0));
+	copyToVertexArray(1, Math::Vector3d(crossairPosition.x - 1, crossairPosition.y, 0));
+
+	copyToVertexArray(2, Math::Vector3d(crossairPosition.x + 1, crossairPosition.y, 0));
+	copyToVertexArray(3, Math::Vector3d(crossairPosition.x + 3, crossairPosition.y, 0));
+
+	copyToVertexArray(4, Math::Vector3d(crossairPosition.x, crossairPosition.y - 3, 0));
+	copyToVertexArray(5, Math::Vector3d(crossairPosition.x, crossairPosition.y - 1, 0));
+
+	copyToVertexArray(6, Math::Vector3d(crossairPosition.x, crossairPosition.y + 1, 0));
+	copyToVertexArray(7, Math::Vector3d(crossairPosition.x, crossairPosition.y + 3, 0));
+
+	tglVertexPointer(3, TGL_FLOAT, 0, _verts);
+	tglDrawArrays(TGL_LINES, 0, 8);
+	tglDisableClientState(TGL_VERTEX_ARRAY);
+
+	tglDisable(TGL_BLEND);
+	tglEnable(TGL_DEPTH_TEST);
+	tglDepthMask(TGL_TRUE);
+}
+
 void TinyGLRenderer::renderFace(const Common::Array<Math::Vector3d> &vertices) {
 	assert(vertices.size() >= 2);
 	const Math::Vector3d &v0 = vertices[0];
diff --git a/engines/freescape/gfx_tinygl.h b/engines/freescape/gfx_tinygl.h
index 89cb9277312..c5a49b7c043 100644
--- a/engines/freescape/gfx_tinygl.h
+++ b/engines/freescape/gfx_tinygl.h
@@ -61,6 +61,8 @@ public:
 
 	virtual void renderSensorShoot(byte color, const Math::Vector3d sensor, const Math::Vector3d player, const Common::Rect viewPort) override;
 	virtual void renderPlayerShoot(byte color, const Common::Point position, const Common::Rect viewPort) override;
+	virtual void renderCrossair(const Common::Point crossairPosition) override;
+
 	virtual void renderFace(const Common::Array<Math::Vector3d> &vertices) override;
 
 	virtual void flipBuffer() override;
diff --git a/engines/freescape/ui.cpp b/engines/freescape/ui.cpp
index 092afddb927..ce5db7ff840 100644
--- a/engines/freescape/ui.cpp
+++ b/engines/freescape/ui.cpp
@@ -195,7 +195,6 @@ void FreescapeEngine::drawUI() {
 		surface = new Graphics::Surface();
 		surface->create(_screenW, _screenH, _gfx->_texturePixelFormat);
 		surface->fillRect(_fullscreenViewArea, gray);
-		drawCrossair(surface);
 	} else
 		return;
 
@@ -212,6 +211,9 @@ void FreescapeEngine::drawUI() {
 
 	drawFullscreenSurface(surface);
 
+	_gfx->setViewport(_fullscreenViewArea);
+	_gfx->renderCrossair(_crossairPosition);
+
 	surface->free();
 	delete surface;
 }


Commit: 653afbbed608f52f0d5779280547a52467ef2cdb
    https://github.com/scummvm/scummvm/commit/653afbbed608f52f0d5779280547a52467ef2cdb
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-08-06T20:13:07+02:00

Commit Message:
FREESCAPE: avoid crashes in driller cga

Changed paths:
    engines/freescape/games/driller/dos.cpp
    engines/freescape/games/palettes.cpp
    engines/freescape/ui.cpp


diff --git a/engines/freescape/games/driller/dos.cpp b/engines/freescape/games/driller/dos.cpp
index c96235196cf..0cad8a75326 100644
--- a/engines/freescape/games/driller/dos.cpp
+++ b/engines/freescape/games/driller/dos.cpp
@@ -314,6 +314,7 @@ void DrillerEngine::loadAssetsDOSFullGame() {
 		loadGlobalObjects(&file, 0x1fa2, 8);
 		_border = load8bitBinImage(&file, 0x210);
 		_border->setPalette((byte*)&kCGAPalettePinkBlueWhiteData, 0, 4);
+		swapPalette(1);
 	} else
 		error("Unsupported video mode for DOS");
 }
diff --git a/engines/freescape/games/palettes.cpp b/engines/freescape/games/palettes.cpp
index ad14649f479..6a926df724f 100644
--- a/engines/freescape/games/palettes.cpp
+++ b/engines/freescape/games/palettes.cpp
@@ -118,9 +118,9 @@ void FreescapeEngine::loadColorPalette() {
 	} else if (_renderMode == Common::kRenderCPC) {
 		_gfx->_palette = (byte *)kDrillerCPCPalette;
 	} else if (_renderMode == Common::kRenderCGA) {
-		_gfx->_palette = nullptr; // palette depends on the area
+		// palette depends on the area
 	} else if (_renderMode == Common::kRenderAmiga || _renderMode == Common::kRenderAtariST) {
-		_gfx->_palette = nullptr; // palette depends on the area
+		// palette depends on the area
 	} else
 		error("Invalid render mode, no palette selected");
 
diff --git a/engines/freescape/ui.cpp b/engines/freescape/ui.cpp
index ce5db7ff840..96628138dc6 100644
--- a/engines/freescape/ui.cpp
+++ b/engines/freescape/ui.cpp
@@ -115,7 +115,7 @@ void FreescapeEngine::borderScreen() {
 	if (isDriller()) {
 		drawBorderScreenAndWait(nullptr);
 
-		if (isAmiga())
+		if (isAmiga() || isAtariST() || isDemo())
 			return;
 	}
 




More information about the Scummvm-git-logs mailing list