[Scummvm-git-logs] scummvm master -> 2fe79fa140f158430b8f3b4e1a5e68813bc2bf62
aquadran
noreply at scummvm.org
Sun May 18 15:34:23 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
2fe79fa140 WINTERMUTE: Synced with original code for FadeToColor
Commit: 2fe79fa140f158430b8f3b4e1a5e68813bc2bf62
https://github.com/scummvm/scummvm/commit/2fe79fa140f158430b8f3b4e1a5e68813bc2bf62
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2025-05-18T17:34:19+02:00
Commit Message:
WINTERMUTE: Synced with original code for FadeToColor
Changed paths:
engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
engines/wintermute/base/gfx/opengl/base_render_opengl3d.h
engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp
engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.h
engines/wintermute/base/gfx/opengl/shaders/wme_fade.vertex
engines/wintermute/base/gfx/opengl/shaders/wme_sprite.vertex
diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
index 9585e29a410..b52d0e69613 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
@@ -560,61 +560,49 @@ bool BaseRenderOpenGL3D::drawLine(int x1, int y1, int x2, int y2, uint32 color)
}
void BaseRenderOpenGL3D::fadeToColor(byte r, byte g, byte b, byte a) {
- const int vertexSize = 16;
- byte vertices[4 * vertexSize];
- float *vertexCoords = reinterpret_cast<float *>(vertices);
-
- vertexCoords[0 * 4 + 1] = _viewportRect.left;
- vertexCoords[0 * 4 + 2] = _viewportRect.bottom;
- vertexCoords[0 * 4 + 3] = 0.0f;
- vertexCoords[1 * 4 + 1] = _viewportRect.left;
- vertexCoords[1 * 4 + 2] = _viewportRect.top;
- vertexCoords[1 * 4 + 3] = 0.0f;
- vertexCoords[2 * 4 + 1] = _viewportRect.right;
- vertexCoords[2 * 4 + 2] = _viewportRect.bottom;
- vertexCoords[2 * 4 + 3] = 0.0f;
- vertexCoords[3 * 4 + 1] = _viewportRect.right;
- vertexCoords[3 * 4 + 2] = _viewportRect.top;
- vertexCoords[3 * 4 + 3] = 0.0f;
-
- vertices[0 * vertexSize + 0] = r;
- vertices[0 * vertexSize + 1] = g;
- vertices[0 * vertexSize + 2] = b;
- vertices[0 * vertexSize + 3] = a;
- vertices[1 * vertexSize + 0] = r;
- vertices[1 * vertexSize + 1] = g;
- vertices[1 * vertexSize + 2] = b;
- vertices[1 * vertexSize + 3] = a;
- vertices[2 * vertexSize + 0] = r;
- vertices[2 * vertexSize + 1] = g;
- vertices[2 * vertexSize + 2] = b;
- vertices[2 * vertexSize + 3] = a;
- vertices[3 * vertexSize + 0] = r;
- vertices[3 * vertexSize + 1] = g;
- vertices[3 * vertexSize + 2] = b;
- vertices[3 * vertexSize + 3] = a;
+ float left, right, bottom, top;
+
+ left = _viewportRect.left;
+ right = _viewportRect.right;
+ bottom = _viewportRect.bottom;
+ top = _viewportRect.top;
+
+ // position coords
+ LineVertex vertices[4];
+ vertices[0].x = left;
+ vertices[0].y = bottom;
+ vertices[0].z = 0.0f;
+ vertices[1].x = left;
+ vertices[1].y = top;
+ vertices[1].z = 0.0f;
+ vertices[2].x = right;
+ vertices[2].y = bottom;
+ vertices[2].z = 0.0f;
+ vertices[3].x = right;
+ vertices[3].y = top;
+ vertices[3].z = 0.0f;
- setSpriteBlendMode(Graphics::BLEND_UNKNOWN);
- glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ setSpriteBlendMode(Graphics::BLEND_NORMAL);
+
+ glDisable(GL_DEPTH_TEST);
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
_lastTexture = nullptr;
+ glViewport(0, 0, _width, _height);
setProjection2D();
+ glColor4ub(r, g, b, a);
+
glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_COLOR_ARRAY);
- glVertexPointer(3, GL_FLOAT, vertexSize, vertices + 4);
- glColorPointer(4, GL_UNSIGNED_BYTE, vertexSize, vertices);
+ glVertexPointer(3, GL_FLOAT, sizeof(LineVertex), &vertices[0].x);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_COLOR_ARRAY);
setup2D(true);
}
diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.h b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.h
index fc8173d7730..7e3e7e504a1 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.h
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.h
@@ -49,10 +49,10 @@ class BaseRenderOpenGL3D : public BaseRenderer3D {
float z;
float u;
float v;
- uint8 r;
- uint8 g;
- uint8 b;
- uint8 a;
+ float r;
+ float g;
+ float b;
+ float a;
};
struct LineVertex {
diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp b/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp
index 3dc4c39d08c..d8c741416e5 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp
@@ -92,34 +92,23 @@ bool BaseRenderOpenGL3DShader::initRenderer(int width, int height, bool windowed
lightEnable(i, false);
}
- float fadeVertexCoords[8];
-
- fadeVertexCoords[0 * 2 + 0] = 0;
- fadeVertexCoords[0 * 2 + 1] = height;
- fadeVertexCoords[1 * 2 + 0] = 0;
- fadeVertexCoords[1 * 2 + 1] = 0;
- fadeVertexCoords[2 * 2 + 0] = width;
- fadeVertexCoords[2 * 2 + 1] = height;
- fadeVertexCoords[3 * 2 + 0] = width;
- fadeVertexCoords[3 * 2 + 1] = 0;
-
glGenBuffers(1, &_fadeVBO);
glBindBuffer(GL_ARRAY_BUFFER, _fadeVBO);
- glBufferData(GL_ARRAY_BUFFER, 4 * 8, fadeVertexCoords, GL_STATIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, 4 * sizeof(LineVertex), nullptr, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
static const char *fadeAttributes[] = { "position", nullptr };
_fadeShader = OpenGL::Shader::fromFiles("wme_fade", fadeAttributes);
- _fadeShader->enableVertexAttribute("position", _fadeVBO, 2, GL_FLOAT, false, 8, 0);
+ _fadeShader->enableVertexAttribute("position", _fadeVBO, 3, GL_FLOAT, false, sizeof(LineVertex), 0);
glGenBuffers(1, &_lineVBO);
glBindBuffer(GL_ARRAY_BUFFER, _lineVBO);
- glBufferData(GL_ARRAY_BUFFER, 2 * 12, nullptr, GL_DYNAMIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, 2 * sizeof(LineVertex), nullptr, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
static const char *lineAttributes[] = { "position", nullptr };
_lineShader = OpenGL::Shader::fromFiles("wme_line", lineAttributes);
- _lineShader->enableVertexAttribute("position", _lineVBO, 3, GL_FLOAT, false, 12, 0);
+ _lineShader->enableVertexAttribute("position", _lineVBO, 3, GL_FLOAT, false, sizeof(LineVertex), 0);
@@ -545,17 +534,17 @@ bool BaseRenderOpenGL3DShader::drawLine(int x1, int y1, int x2, int y2, uint32 c
y2 += _drawOffsetY;
// position coords
- float lineCoords[6];
- lineCoords[0] = x1;
- lineCoords[1] = y1;
- lineCoords[2] = 0.9f;
- lineCoords[3] = x2;
- lineCoords[4] = y2;
- lineCoords[5] = 0.9f;
+ LineVertex vertices[2];
+ vertices[0].x = x1;
+ vertices[0].y = y1;
+ vertices[0].z = 0.9f;
+ vertices[1].x = x2;
+ vertices[1].y = y2;
+ vertices[1].z = 0.9f;
glBindBuffer(GL_ARRAY_BUFFER, _lineVBO);
- glBufferSubData(GL_ARRAY_BUFFER, 0, 2 * 12, lineCoords);
+ glBufferSubData(GL_ARRAY_BUFFER, 0, 2 * sizeof(LineVertex), vertices);
byte a = RGBCOLGetA(color);
byte r = RGBCOLGetR(color);
@@ -582,25 +571,50 @@ bool BaseRenderOpenGL3DShader::drawLine(int x1, int y1, int x2, int y2, uint32 c
}
void BaseRenderOpenGL3DShader::fadeToColor(byte r, byte g, byte b, byte a) {
+ float left, right, bottom, top;
+
+ left = _viewportRect.left;
+ right = _viewportRect.right;
+ bottom = _viewportRect.bottom;
+ top = _viewportRect.top;
+
+ // position coords
+ LineVertex vertices[4];
+ vertices[0].x = left;
+ vertices[0].y = bottom;
+ vertices[0].z = 0.0f;
+ vertices[1].x = left;
+ vertices[1].y = top;
+ vertices[1].z = 0.0f;
+ vertices[2].x = right;
+ vertices[2].y = bottom;
+ vertices[2].z = 0.0f;
+ vertices[3].x = right;
+ vertices[3].y = top;
+ vertices[3].z = 0.0f;
+
Math::Vector4d color;
color.x() = r / 255.0f;
color.y() = g / 255.0f;
color.z() = b / 255.0f;
color.w() = a / 255.0f;
- setSpriteBlendMode(Graphics::BLEND_UNKNOWN);
+ glEnable(GL_BLEND);
+ setSpriteBlendMode(Graphics::BLEND_NORMAL);
glDisable(GL_DEPTH_TEST);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
- glBindBuffer(GL_ARRAY_BUFFER, _fadeVBO);
_lastTexture = nullptr;
+ glViewport(0, 0, _width, _height);
+ setProjection2D(_fadeShader);
+
_fadeShader->use();
_fadeShader->setUniform("color", color);
- setProjection2D(_fadeShader);
+
+ glBindBuffer(GL_ARRAY_BUFFER, _fadeVBO);
+ glBufferSubData(GL_ARRAY_BUFFER, 0, 4 * sizeof(LineVertex), vertices);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.h b/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.h
index 8112fb0fc85..2a2185e8e29 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.h
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.h
@@ -56,6 +56,24 @@ class BaseRenderOpenGL3DShader : public BaseRenderer3D {
float a;
};
+ struct LineVertex {
+ float x;
+ float y;
+ float z;
+ };
+
+ struct SimpleShadowVertex {
+ float u;
+ float v;
+ float nx;
+ float ny;
+ float nz;
+ float x;
+ float y;
+ float z;
+ };
+
+
public:
BaseRenderOpenGL3DShader(BaseGame *inGame = nullptr);
~BaseRenderOpenGL3DShader() override;
diff --git a/engines/wintermute/base/gfx/opengl/shaders/wme_fade.vertex b/engines/wintermute/base/gfx/opengl/shaders/wme_fade.vertex
index a2096ae4d8b..479282bc572 100644
--- a/engines/wintermute/base/gfx/opengl/shaders/wme_fade.vertex
+++ b/engines/wintermute/base/gfx/opengl/shaders/wme_fade.vertex
@@ -1,4 +1,4 @@
-in vec2 position;
+in vec3 position;
uniform highp mat4 projMatrix;
uniform vec4 color;
@@ -6,6 +6,6 @@ uniform vec4 color;
out vec4 Color;
void main() {
- gl_Position = projMatrix * vec4(position, 0.0, 1.0);
+ gl_Position = projMatrix * vec4(position, 1.0);
Color = color;
}
diff --git a/engines/wintermute/base/gfx/opengl/shaders/wme_sprite.vertex b/engines/wintermute/base/gfx/opengl/shaders/wme_sprite.vertex
index 29d0f257e87..76d15bc5e14 100644
--- a/engines/wintermute/base/gfx/opengl/shaders/wme_sprite.vertex
+++ b/engines/wintermute/base/gfx/opengl/shaders/wme_sprite.vertex
@@ -1,4 +1,4 @@
-in vec2 position;
+in vec3 position;
in vec2 texcoord;
in vec4 color;
@@ -10,8 +10,8 @@ out vec2 Texcoord;
out vec4 Color;
void main() {
- vec3 transformed_position = transform * vec3(position, 1.0);
- gl_Position = projMatrix * vec4(transformed_position.x, transformed_position.y, 0.9, 1.0);
+ vec3 transformed_position = transform * vec3(position);
+ gl_Position = projMatrix * vec4(transformed_position.x, transformed_position.y, transformed_position.z, 1.0);
Texcoord = texcoord;
Color = color;
}
More information about the Scummvm-git-logs
mailing list