[Scummvm-git-logs] scummvm master -> a0af073131ecda66d3908631cf0c84611f8d214d
aquadran
noreply at scummvm.org
Sun Jun 15 11:53:03 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:
a0af073131 WINTERMUTE: Implement draw rectangle and drop drawLine
Commit: a0af073131ecda66d3908631cf0c84611f8d214d
https://github.com/scummvm/scummvm/commit/a0af073131ecda66d3908631cf0c84611f8d214d
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2025-06-15T13:52:59+02:00
Commit Message:
WINTERMUTE: Implement draw rectangle and drop drawLine
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
diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
index 648be37845e..8b40a033b90 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
@@ -211,8 +211,6 @@ bool BaseRenderOpenGL3D::setup3D(Camera3D *camera, bool force) {
setAmbientLightRenderState();
-
-
if (camera)
_camera = camera;
if (_camera) {
@@ -544,20 +542,26 @@ bool BaseRenderOpenGL3D::setProjection() {
return setProjectionTransform(matProj);
}
-bool BaseRenderOpenGL3D::drawLine(int x1, int y1, int x2, int y2, uint32 color) {
- x1 += _drawOffsetX;
- x2 += _drawOffsetX;
- y1 += _drawOffsetY;
- y2 += _drawOffsetY;
+bool BaseRenderOpenGL3D::fillRect(int x, int y, int w, int h, uint32 color) {
+ setupLines();
+
+ x += _drawOffsetX;
+ y += _drawOffsetY;
// position coords
- LineVertex vertices[2];
- vertices[0].x = x1;
- vertices[0].y = y1;
+ RectangleVertex vertices[4];
+ vertices[0].x = x;
+ vertices[0].y = y + h;
vertices[0].z = 0.9f;
- vertices[1].x = x2;
- vertices[1].y = y2;
+ vertices[1].x = x;
+ vertices[1].y = y;
vertices[1].z = 0.9f;
+ vertices[2].x = x + w;
+ vertices[2].y = y + h;
+ vertices[2].z = 0.9f;
+ vertices[3].x = x + w;
+ vertices[3].y = y;
+ vertices[3].z = 0.9f;
byte a = RGBCOLGetA(color);
byte r = RGBCOLGetR(color);
@@ -571,21 +575,12 @@ bool BaseRenderOpenGL3D::drawLine(int x1, int y1, int x2, int y2, uint32 color)
glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3, GL_FLOAT, sizeof(LineVertex), &vertices[0].x);
+ glVertexPointer(3, GL_FLOAT, sizeof(RectangleVertex), &vertices[0].x);
- glDrawArrays(GL_LINES, 0, 2);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY);
- return true;
-}
-
-bool BaseRenderOpenGL3D::fillRect(int x, int y, int w, int h, uint32 color) {
- // TODO: Use a simplified method for drawing rectangles with OpenGL
- setupLines();
- for (int i = 0; i < h; i++) {
- drawLine(x, y + i, x + w, y + i, color);
- }
setup2D();
return true;
}
@@ -599,7 +594,7 @@ void BaseRenderOpenGL3D::fadeToColor(byte r, byte g, byte b, byte a) {
top = _viewportRect.top;
// position coords
- LineVertex vertices[4];
+ RectangleVertex vertices[4];
vertices[0].x = left;
vertices[0].y = bottom;
vertices[0].z = 0.0f;
@@ -629,7 +624,7 @@ void BaseRenderOpenGL3D::fadeToColor(byte r, byte g, byte b, byte a) {
glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3, GL_FLOAT, sizeof(LineVertex), &vertices[0].x);
+ glVertexPointer(3, GL_FLOAT, sizeof(RectangleVertex), &vertices[0].x);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.h b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.h
index fceea0c52a9..b9d78725568 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.h
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.h
@@ -55,7 +55,7 @@ class BaseRenderOpenGL3D : public BaseRenderer3D {
float a;
};
- struct LineVertex {
+ struct RectangleVertex {
float x;
float y;
float z;
@@ -161,8 +161,6 @@ public:
private:
bool setupLines();
- bool drawLine(int x1, int y1, int x2, int y2, uint32 color);
-
void displaySimpleShadow(BaseObject *object) override;
SimpleShadowVertex _simpleShadow[4];
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 807769a8d60..e16539c87fc 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp
@@ -59,7 +59,7 @@ BaseRenderOpenGL3DShader::~BaseRenderOpenGL3DShader() {
_camera = nullptr; // ref only
glDeleteBuffers(1, &_spriteVBO);
glDeleteBuffers(1, &_fadeVBO);
- glDeleteBuffers(1, &_lineVBO);
+ glDeleteBuffers(1, &_rectangleVBO);
glDeleteBuffers(1, &_simpleShadowVBO);
glDeleteBuffers(1, &_postfilterVBO);
}
@@ -151,21 +151,21 @@ bool BaseRenderOpenGL3DShader::initRenderer(int width, int height, bool windowed
glGenBuffers(1, &_fadeVBO);
glBindBuffer(GL_ARRAY_BUFFER, _fadeVBO);
- glBufferData(GL_ARRAY_BUFFER, 4 * sizeof(LineVertex), nullptr, GL_STATIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, 4 * sizeof(RectangleVertex), nullptr, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
static const char *fadeAttributes[] = { "position", nullptr };
_fadeShader = OpenGL::Shader::fromFiles("wme_fade", fadeAttributes);
- _fadeShader->enableVertexAttribute("position", _fadeVBO, 3, GL_FLOAT, false, sizeof(LineVertex), 0);
+ _fadeShader->enableVertexAttribute("position", _fadeVBO, 3, GL_FLOAT, false, sizeof(RectangleVertex), 0);
- glGenBuffers(1, &_lineVBO);
- glBindBuffer(GL_ARRAY_BUFFER, _lineVBO);
- glBufferData(GL_ARRAY_BUFFER, 2 * sizeof(LineVertex), nullptr, GL_STATIC_DRAW);
+ glGenBuffers(1, &_rectangleVBO);
+ glBindBuffer(GL_ARRAY_BUFFER, _rectangleVBO);
+ glBufferData(GL_ARRAY_BUFFER, 4 * sizeof(RectangleVertex), nullptr, GL_STATIC_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, sizeof(LineVertex), 0);
+ _lineShader->enableVertexAttribute("position", _rectangleVBO, 3, GL_FLOAT, false, sizeof(RectangleVertex), 0);
const GLfloat quadVertices[] = {
-1.0f, -1.0f, 0.0f, 0.0f,
@@ -283,8 +283,6 @@ bool BaseRenderOpenGL3DShader::setup3D(Camera3D *camera, bool force) {
setAmbientLightRenderState();
-
-
if (camera)
_camera = camera;
if (_camera) {
@@ -632,24 +630,30 @@ bool BaseRenderOpenGL3DShader::setProjection() {
return setProjectionTransform(matProj);
}
-bool BaseRenderOpenGL3DShader::drawLine(int x1, int y1, int x2, int y2, uint32 color) {
- x1 += _drawOffsetX;
- x2 += _drawOffsetX;
- y1 += _drawOffsetY;
- y2 += _drawOffsetY;
+bool BaseRenderOpenGL3DShader::fillRect(int x, int y, int w, int h, uint32 color) {
+ setupLines();
+
+ x += _drawOffsetX;
+ y += _drawOffsetY;
// position coords
- LineVertex vertices[2];
- vertices[0].x = x1;
- vertices[0].y = y1;
+ RectangleVertex vertices[4];
+ vertices[0].x = x;
+ vertices[0].y = y + h;
vertices[0].z = 0.9f;
- vertices[1].x = x2;
- vertices[1].y = y2;
+ vertices[1].x = x;
+ vertices[1].y = y;
vertices[1].z = 0.9f;
+ vertices[2].x = x + w;
+ vertices[2].y = y + h;
+ vertices[2].z = 0.9f;
+ vertices[3].x = x + w;
+ vertices[3].y = y;
+ vertices[3].z = 0.9f;
- glBindBuffer(GL_ARRAY_BUFFER, _lineVBO);
+ glBindBuffer(GL_ARRAY_BUFFER, _rectangleVBO);
- glBufferSubData(GL_ARRAY_BUFFER, 0, 2 * sizeof(LineVertex), vertices);
+ glBufferSubData(GL_ARRAY_BUFFER, 0, 4 * sizeof(RectangleVertex), vertices);
byte a = RGBCOLGetA(color);
byte r = RGBCOLGetR(color);
@@ -666,21 +670,12 @@ bool BaseRenderOpenGL3DShader::drawLine(int x1, int y1, int x2, int y2, uint32 c
_lineShader->setUniform("color", colorValue);
glViewport(0, 0, _width, _height);
-
setProjection2D(_lineShader);
- glDrawArrays(GL_LINES, 0, 2);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindBuffer(GL_ARRAY_BUFFER, 0);
- return true;
-}
-bool BaseRenderOpenGL3DShader::fillRect(int x, int y, int w, int h, uint32 color) {
- // TODO: Use a simplified method for drawing rectangles with OpenGL
- setupLines();
- for (int i = 0; i < h; i++) {
- drawLine(x, y + i, x + w, y + i, color);
- }
setup2D();
return true;
}
@@ -694,7 +689,7 @@ void BaseRenderOpenGL3DShader::fadeToColor(byte r, byte g, byte b, byte a) {
top = _viewportRect.top;
// position coords
- LineVertex vertices[4];
+ RectangleVertex vertices[4];
vertices[0].x = left;
vertices[0].y = bottom;
vertices[0].z = 0.0f;
@@ -729,10 +724,12 @@ void BaseRenderOpenGL3DShader::fadeToColor(byte r, byte g, byte b, byte a) {
_fadeShader->setUniform("color", color);
glBindBuffer(GL_ARRAY_BUFFER, _fadeVBO);
- glBufferSubData(GL_ARRAY_BUFFER, 0, 4 * sizeof(LineVertex), vertices);
+ glBufferSubData(GL_ARRAY_BUFFER, 0, 4 * sizeof(RectangleVertex), vertices);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+
setup2D(true);
}
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 d883d32b5ca..b20ccc335bd 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.h
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.h
@@ -56,7 +56,7 @@ class BaseRenderOpenGL3DShader : public BaseRenderer3D {
float a;
};
- struct LineVertex {
+ struct RectangleVertex {
float x;
float y;
float z;
@@ -164,8 +164,6 @@ public:
private:
bool setupLines();
- bool drawLine(int x1, int y1, int x2, int y2, uint32 color);
-
void displaySimpleShadow(BaseObject *object) override;
SimpleShadowVertex _simpleShadow[4];
@@ -179,7 +177,7 @@ private:
GLuint _spriteVBO{};
GLuint _fadeVBO{};
- GLuint _lineVBO{};
+ GLuint _rectangleVBO{};
GLuint _simpleShadowVBO{};
GLuint _postfilterVBO{};
OpenGL::Shader *_spriteShader{};
More information about the Scummvm-git-logs
mailing list