[Scummvm-git-logs] scummvm master -> 7d4560ae903d0e5eedb3783acb5cf28ffd59f00c
neuromancer
noreply at scummvm.org
Mon Oct 6 18:47:04 UTC 2025
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
12e7995715 FREESCAPE: ported thunder effect to tinygl
83382978d3 FREESCAPE: billboard effect in opengl shaders correctly implemented
7d4560ae90 FREESCAPE: missing stipple code in opengl shaders correctly implemented
Commit: 12e7995715a5709bb31aea942519efb5d17d6166
https://github.com/scummvm/scummvm/commit/12e7995715a5709bb31aea942519efb5d17d6166
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2025-10-06T15:46:46-03:00
Commit Message:
FREESCAPE: ported thunder effect to tinygl
Changed paths:
engines/freescape/gfx_tinygl.cpp
engines/freescape/gfx_tinygl.h
diff --git a/engines/freescape/gfx_tinygl.cpp b/engines/freescape/gfx_tinygl.cpp
index c2fc21f2ee3..1f778e21892 100644
--- a/engines/freescape/gfx_tinygl.cpp
+++ b/engines/freescape/gfx_tinygl.cpp
@@ -149,6 +149,49 @@ void TinyGLRenderer::drawSkybox(Texture *texture, Math::Vector3d camera) {
tglFlush();
}
+void TinyGLRenderer::drawThunder(Texture *texture, Math::Vector3d position, float size) {
+ TinyGL3DTexture *glTexture = static_cast<TinyGL3DTexture *>(texture);
+ tglPushMatrix();
+ {
+ tglTranslatef(position.x(), position.y(), position.z());
+
+ TGLfloat m[16];
+ tglGetFloatv(TGL_MODELVIEW_MATRIX, m);
+ for (int i = 0; i < 3; i++)
+ for (int j = 0; j < 3; j++)
+ m[i * 4 + j] = (i == j) ? 1.0f : 0.0f;
+ tglLoadMatrixf(m);
+
+ tglRotatef(-90, 0.0f, 0.0f, 1.0f);
+
+ // === Texturing setup ===
+ tglEnable(TGL_TEXTURE_2D);
+ tglBindTexture(TGL_TEXTURE_2D, glTexture->_id);
+ //tglTexParameteri(TGL_TEXTURE_2D, TGL_TEXTURE_WRAP_S, TGL_CLAMP_TO_BORDER);
+ //tglTexParameteri(TGL_TEXTURE_2D, TGL_TEXTURE_WRAP_T, TGL_CLAMP_TO_BORDER);
+
+ // === Blending (thunder should glow) ===
+ tglEnable(TGL_BLEND);
+ tglBlendFunc(TGL_ONE, TGL_ONE);
+
+ // === Draw the billboarded quad ===
+ float half = size * 0.5f;
+ tglBegin(TGL_QUADS);
+ tglTexCoord2f(0.0f, 0.0f); tglVertex3f(-half, -half, 0.0f);
+ tglTexCoord2f(0.0f, 0.72f); tglVertex3f( half, -half, 0.0f);
+ tglTexCoord2f(1.0f, 0.72f); tglVertex3f( half, half, 0.0f);
+ tglTexCoord2f(1.0f, 0.0f); tglVertex3f(-half, half, 0.0f);
+ tglEnd();
+
+ // === Cleanup ===
+ tglDisable(TGL_BLEND);
+ tglBindTexture(TGL_TEXTURE_2D, 0);
+ tglDisable(TGL_TEXTURE_2D);
+ }
+ tglPopMatrix();
+}
+
+
void TinyGLRenderer::updateProjectionMatrix(float fov, float aspectRatio, float nearClipPlane, float farClipPlane) {
tglMatrixMode(TGL_PROJECTION);
tglLoadIdentity();
diff --git a/engines/freescape/gfx_tinygl.h b/engines/freescape/gfx_tinygl.h
index a69027bc4f2..1b292640a16 100644
--- a/engines/freescape/gfx_tinygl.h
+++ b/engines/freescape/gfx_tinygl.h
@@ -84,6 +84,7 @@ public:
void freeTexture(Texture *texture) override;
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture) override;
void drawSkybox(Texture *texture, Math::Vector3d camera) override;
+ void drawThunder(Texture *texture, Math::Vector3d camera, float size) override;
virtual void renderSensorShoot(byte color, const Math::Vector3d sensor, const Math::Vector3d player, const Common::Rect &viewPort) override;
virtual void renderPlayerShootBall(byte color, const Common::Point &position, int frame, const Common::Rect &viewPort) override;
Commit: 83382978d3dccbde455c5f554fad1e136fd11818
https://github.com/scummvm/scummvm/commit/83382978d3dccbde455c5f554fad1e136fd11818
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2025-10-06T15:46:46-03:00
Commit Message:
FREESCAPE: billboard effect in opengl shaders correctly implemented
Changed paths:
engines/freescape/gfx_opengl_shaders.cpp
diff --git a/engines/freescape/gfx_opengl_shaders.cpp b/engines/freescape/gfx_opengl_shaders.cpp
index a853208b079..3b001c51d48 100644
--- a/engines/freescape/gfx_opengl_shaders.cpp
+++ b/engines/freescape/gfx_opengl_shaders.cpp
@@ -351,55 +351,89 @@ void OpenGLShaderRenderer::renderPlayerShootRay(byte color, const Common::Point
glDepthMask(GL_TRUE);
}
-void OpenGLShaderRenderer::drawCelestialBody(Math::Vector3d position, float radius, byte color) {
+void OpenGLShaderRenderer::drawCelestialBody(const Math::Vector3d position, float radius, byte color) {
+ // === Safety checks ===
+ if (!_triangleShader || radius <= 0.0f)
+ return;
+
+ // === Decode color from palette ===
uint8 r1, g1, b1, r2, g2, b2;
byte *stipple = nullptr;
getRGBAt(color, 0, r1, g1, b1, r2, g2, b2, stipple);
+ Math::Vector3d baseColor(r1 / 255.0f, g1 / 255.0f, b1 / 255.0f);
- useColor(r1, g1, b1);
+ // === Build circular vertex fan ===
+ const int triangleAmount = 20;
+ const float twicePi = 2.0f * static_cast<float>(M_PI);
+ const float adj = 1.25f;
- int triangleAmount = 20;
- float twicePi = (float)(2.0 * M_PI);
- float adj = 1.25; // Perspective correction
+ Common::Array<float> verts;
- // Quick billboard effect inspired from this code:
- // http://www.lighthouse3d.com/opengl/billboarding/index.php?billCheat
- /*Math::Matrix4 mvpMatrix = _mvpMatrix;
+ // Center vertex
+ verts.push_back(static_cast<float>(position.x()));
+ verts.push_back(static_cast<float>(position.y()));
+ verts.push_back(static_cast<float>(position.z()));
+
+ // Circle vertices in YZ plane (same as legacy code)
+ for (int i = 0; i <= triangleAmount; i++) {
+ float x = static_cast<float>(position.x());
+ float y = static_cast<float>(position.y()) + radius * cosf(i * twicePi / triangleAmount);
+ float z = static_cast<float>(position.z()) + adj * radius * sinf(i * twicePi / triangleAmount);
+ verts.push_back(x);
+ verts.push_back(y);
+ verts.push_back(z);
+ }
- for(int i = 2; i < 4; i++)
- for(int j = 2; j < 4; j++ ) {
+ if (verts.empty())
+ return;
+
+ // === Apply billboard effect to MVP matrix ===
+ // Replicate the legacy code's matrix modification
+ Math::Matrix4 billboardMVP = _mvpMatrix;
+
+ // Zero out rotation for rows 1, 3 (skip row 2), set diagonal to 1.0
+ // This matches: for (int i = 1; i < 4; i++) for (int j = 0; j < 4; j++)
+ for (int i = 1; i < 4; i++) {
+ for (int j = 0; j < 4; j++) {
if (i == 2)
continue;
if (i == j)
- _mvpMatrix.setValue(i, j, 1.0);
+ billboardMVP(i, j) = 2.5f;
else
- _mvpMatrix.setValue(i, j, 0.0);
- }*/
+ billboardMVP(i, j) = 0.0f;
+ }
+ }
+
+ // === Bind VBO ===
+ glBindBuffer(GL_ARRAY_BUFFER, _triangleVBO);
+ glBufferData(GL_ARRAY_BUFFER, verts.size() * sizeof(float), verts.data(), GL_DYNAMIC_DRAW);
+ // === Set vertex attribute 0 (position) ===
+ glEnableVertexAttribArray(0);
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), nullptr);
+
+ // === Shader uniforms ===
_triangleShader->use();
+ _triangleShader->setUniform("mvpMatrix", billboardMVP);
+ _triangleShader->setUniform("color", baseColor);
_triangleShader->setUniform("useStipple", false);
- _triangleShader->setUniform("mvpMatrix", _mvpMatrix);
+ // === Render settings ===
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
- copyToVertexArray(0, position);
-
- for (int i = 0; i <= triangleAmount; i++) {
- float x = position.x();
- float y = position.y() + (radius * cos(i * twicePi / triangleAmount));
- float z = position.z() + (adj * radius * sin(i * twicePi / triangleAmount));
- copyToVertexArray(i + 1, Math::Vector3d(x, y, z));
- }
-
- glBindBuffer(GL_ARRAY_BUFFER, _triangleVBO);
- glBufferData(GL_ARRAY_BUFFER, (triangleAmount + 2) * 3 * sizeof(float), _verts, GL_DYNAMIC_DRAW);
- glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), nullptr);
- glDrawArrays(GL_TRIANGLE_FAN, 0, (triangleAmount + 2));
+ // === Draw vertex fan ===
+ glDrawArrays(GL_TRIANGLE_FAN, 0, verts.size() / 3);
+ // === Restore state ===
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
- //_mvpMatrix = mvpMatrix;
+
+ // === Cleanup binding ===
+ glDisableVertexAttribArray(0);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+ _triangleShader->unbind();
}
void OpenGLShaderRenderer::renderCrossair(const Common::Point &crossairPosition) {
Commit: 7d4560ae903d0e5eedb3783acb5cf28ffd59f00c
https://github.com/scummvm/scummvm/commit/7d4560ae903d0e5eedb3783acb5cf28ffd59f00c
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2025-10-06T15:46:46-03:00
Commit Message:
FREESCAPE: missing stipple code in opengl shaders correctly implemented
Changed paths:
engines/freescape/gfx_opengl_shaders.cpp
diff --git a/engines/freescape/gfx_opengl_shaders.cpp b/engines/freescape/gfx_opengl_shaders.cpp
index 3b001c51d48..76e3659d67e 100644
--- a/engines/freescape/gfx_opengl_shaders.cpp
+++ b/engines/freescape/gfx_opengl_shaders.cpp
@@ -360,7 +360,7 @@ void OpenGLShaderRenderer::drawCelestialBody(const Math::Vector3d position, floa
uint8 r1, g1, b1, r2, g2, b2;
byte *stipple = nullptr;
getRGBAt(color, 0, r1, g1, b1, r2, g2, b2, stipple);
- Math::Vector3d baseColor(r1 / 255.0f, g1 / 255.0f, b1 / 255.0f);
+ useColor(r1, g1, b1);
// === Build circular vertex fan ===
const int triangleAmount = 20;
@@ -384,9 +384,6 @@ void OpenGLShaderRenderer::drawCelestialBody(const Math::Vector3d position, floa
verts.push_back(z);
}
- if (verts.empty())
- return;
-
// === Apply billboard effect to MVP matrix ===
// Replicate the legacy code's matrix modification
Math::Matrix4 billboardMVP = _mvpMatrix;
@@ -415,7 +412,6 @@ void OpenGLShaderRenderer::drawCelestialBody(const Math::Vector3d position, floa
// === Shader uniforms ===
_triangleShader->use();
_triangleShader->setUniform("mvpMatrix", billboardMVP);
- _triangleShader->setUniform("color", baseColor);
_triangleShader->setUniform("useStipple", false);
// === Render settings ===
@@ -425,6 +421,13 @@ void OpenGLShaderRenderer::drawCelestialBody(const Math::Vector3d position, floa
// === Draw vertex fan ===
glDrawArrays(GL_TRIANGLE_FAN, 0, verts.size() / 3);
+ if (r1 != r2 || g1 != g2 || b1 != b2) {
+ useStipple(true);
+ useColor(r2, g2, b2);
+ glDrawArrays(GL_TRIANGLE_FAN, 0, verts.size() / 3);
+ useStipple(false);
+ }
+
// === Restore state ===
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
More information about the Scummvm-git-logs
mailing list