[Scummvm-git-logs] scummvm master -> 172a5962f11684050df4ad7b5fab9a7f72089450

aquadran noreply at scummvm.org
Sat Apr 5 19:31:57 UTC 2025


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:
342666a8ed PLAYGROUND3D: Left-click to start the next test.
d91852d222 PLAYGROUND3D: Implement Tests 2 and 4 in OpenGLShaders renderer
172a5962f1 PLAYGROUND3D: Move red square out of view before looping


Commit: 342666a8ed88c8c835e34cd3b7748e05c399392c
    https://github.com/scummvm/scummvm/commit/342666a8ed88c8c835e34cd3b7748e05c399392c
Author: Michael Ball (ballm4788 at gmail.com)
Date: 2025-04-05T21:31:53+02:00

Commit Message:
PLAYGROUND3D: Left-click to start the next test.

If Test 5 is currently running, the program will loop back to Test 1.

Changed paths:
    engines/playground3d/gfx_opengl.cpp
    engines/playground3d/gfx_opengl_shaders.cpp
    engines/playground3d/gfx_tinygl.cpp
    engines/playground3d/playground3d.cpp
    engines/playground3d/playground3d.h


diff --git a/engines/playground3d/gfx_opengl.cpp b/engines/playground3d/gfx_opengl.cpp
index f4600a34d85..fbbd54f9be5 100644
--- a/engines/playground3d/gfx_opengl.cpp
+++ b/engines/playground3d/gfx_opengl.cpp
@@ -176,6 +176,12 @@ void OpenGLRenderer::drawCube(const Math::Vector3d &pos, const Math::Vector3d &r
 	glMatrixMode(GL_MODELVIEW);
 	glLoadMatrixf(_modelViewMatrix.getData());
 
+	glDisable(GL_BLEND);
+	glBlendFunc(GL_ONE, GL_ZERO);
+	glEnable(GL_DEPTH_TEST);
+	glDepthMask(GL_TRUE);
+	glDisable(GL_TEXTURE_2D);
+
 	glTranslatef(pos.x(), pos.y(), pos.z());
 	glRotatef(roll.x(), 1.0f, 0.0f, 0.0f);
 	glRotatef(roll.y(), 0.0f, 1.0f, 0.0f);
@@ -193,6 +199,12 @@ void OpenGLRenderer::drawPolyOffsetTest(const Math::Vector3d &pos, const Math::V
 	glMatrixMode(GL_MODELVIEW);
 	glLoadMatrixf(_modelViewMatrix.getData());
 
+	glDisable(GL_BLEND);
+	glBlendFunc(GL_ONE, GL_ZERO);
+	glEnable(GL_DEPTH_TEST);
+	glDepthMask(GL_TRUE);
+	glDisable(GL_TEXTURE_2D);
+
 	glTranslatef(pos.x(), pos.y(), pos.z());
 	glRotatef(roll.y(), 0.0f, 1.0f, 0.0f);
 
diff --git a/engines/playground3d/gfx_opengl_shaders.cpp b/engines/playground3d/gfx_opengl_shaders.cpp
index ff279fc6942..87084f52a0d 100644
--- a/engines/playground3d/gfx_opengl_shaders.cpp
+++ b/engines/playground3d/gfx_opengl_shaders.cpp
@@ -84,8 +84,6 @@ void ShaderRenderer::init() {
 
 	computeScreenViewport();
 
-	glEnable(GL_DEPTH_TEST);
-
 	static const char *cubeAttributes[] = { "position", "normal", "color", "texcoord", nullptr };
 	_cubeShader = OpenGL::Shader::fromFiles("playground3d_cube", cubeAttributes);
 	_cubeVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(cubeVertices), cubeVertices);
@@ -172,6 +170,12 @@ void ShaderRenderer::enableFog(const Math::Vector4d &fogColor) {
 }
 
 void ShaderRenderer::drawCube(const Math::Vector3d &pos, const Math::Vector3d &roll) {
+	glDisable(GL_BLEND);
+	glBlendFunc(GL_ONE, GL_ZERO);
+	glEnable(GL_DEPTH_TEST);
+	glDepthMask(GL_TRUE);
+	glDisable(GL_TEXTURE_2D);
+
 	auto rotateMatrix = (Math::Quaternion::fromEuler(roll.x(), roll.y(), roll.z(), Math::EO_XYZ)).inverse().toMatrix();
 	_cubeShader->use();
 	_cubeShader->setUniform("textured", false);
diff --git a/engines/playground3d/gfx_tinygl.cpp b/engines/playground3d/gfx_tinygl.cpp
index 9e51c5f756e..cf427ca6218 100644
--- a/engines/playground3d/gfx_tinygl.cpp
+++ b/engines/playground3d/gfx_tinygl.cpp
@@ -206,6 +206,12 @@ void TinyGLRenderer::drawCube(const Math::Vector3d &pos, const Math::Vector3d &r
 	tglMatrixMode(TGL_MODELVIEW);
 	tglLoadMatrixf(_modelViewMatrix.getData());
 
+	tglDisable(TGL_BLEND);
+	tglBlendFunc(TGL_ONE, TGL_ZERO);
+	tglEnable(TGL_DEPTH_TEST);
+	tglDepthMask(TGL_TRUE);
+	tglDisable(TGL_TEXTURE_2D);
+
 	tglTranslatef(pos.x(), pos.y(), pos.z());
 	tglRotatef(roll.x(), 1.0f, 0.0f, 0.0f);
 	tglRotatef(roll.y(), 0.0f, 1.0f, 0.0f);
@@ -223,6 +229,12 @@ void TinyGLRenderer::drawPolyOffsetTest(const Math::Vector3d &pos, const Math::V
 	tglMatrixMode(TGL_MODELVIEW);
 	tglLoadMatrixf(_modelViewMatrix.getData());
 
+	tglDisable(TGL_BLEND);
+	tglBlendFunc(TGL_ONE, TGL_ZERO);
+	tglEnable(TGL_DEPTH_TEST);
+	tglDepthMask(TGL_TRUE);
+	tglDisable(TGL_TEXTURE_2D);
+
 	tglTranslatef(pos.x(), pos.y(), pos.z());
 	tglRotatef(roll.y(), 0.0f, 1.0f, 0.0f);
 
diff --git a/engines/playground3d/playground3d.cpp b/engines/playground3d/playground3d.cpp
index 5b2fc3df7d4..afa018f0bf8 100644
--- a/engines/playground3d/playground3d.cpp
+++ b/engines/playground3d/playground3d.cpp
@@ -54,6 +54,26 @@ bool Playground3dEngine::hasFeature(EngineFeature f) const {
 		(f == kSupportsArbitraryResolutions && !softRenderer);
 }
 
+void Playground3dEngine::genTextures() {
+#if defined(SCUMM_LITTLE_ENDIAN)
+	Graphics::PixelFormat pixelFormatRGBA(4, 8, 8, 8, 8, 0, 8, 16, 24);
+	Graphics::PixelFormat pixelFormatRGB(3, 8, 8, 8, 0, 0, 8, 16, 0);
+#else
+	Graphics::PixelFormat pixelFormatRGBA(4, 8, 8, 8, 8, 24, 16, 8, 0);
+	Graphics::PixelFormat pixelFormatRGB(3, 8, 8, 8, 0, 16, 8, 0, 0);
+#endif
+	Graphics::PixelFormat pixelFormatRGB565(2, 5, 6, 5, 0, 11, 5, 0, 0);
+	Graphics::PixelFormat pixelFormatRGB5551(2, 5, 5, 5, 1, 11, 6, 1, 0);
+	Graphics::PixelFormat pixelFormatRGB4444(2, 4, 4, 4, 4, 12, 8, 4, 0);
+	_rgbaTexture = generateRgbaTexture(120, 120, pixelFormatRGBA);
+	_rgbTexture = _rgbaTexture->convertTo(pixelFormatRGB);
+	_rgb565Texture = generateRgbaTexture(120, 120, pixelFormatRGB565);
+	_rgba5551Texture = generateRgbaTexture(120, 120, pixelFormatRGB5551);
+	_rgba4444Texture = generateRgbaTexture(120, 120, pixelFormatRGB4444);
+}
+
+static int testId;
+static bool texturesGenerated;
 Playground3dEngine::Playground3dEngine(OSystem *syst)
 		: Engine(syst), _system(syst), _gfx(nullptr), _frameLimiter(nullptr),
 		_rotateAngleX(0), _rotateAngleY(0), _rotateAngleZ(0), _fogEnable(false),
@@ -76,12 +96,14 @@ Common::Error Playground3dEngine::run() {
 
 	_system->showMouse(true);
 
+	texturesGenerated = false;
+
 	// 1 - rotated colorfull cube
 	// 2 - rotated two triangles with depth offset
 	// 3 - fade in/out
 	// 4 - moving filled rectangle in viewport
 	// 5 - drawing RGBA pattern texture to check endian correctness
-	int testId = 1;
+	testId = 1;
 	_fogEnable = false;
 
 	if (_fogEnable) {
@@ -104,21 +126,8 @@ Common::Error Playground3dEngine::run() {
 			break;
 		case 5: {
 			_clearColor = Math::Vector4d(0.5f, 0.5f, 0.5f, 1.0f);
-#if defined(SCUMM_LITTLE_ENDIAN)
-			Graphics::PixelFormat pixelFormatRGBA(4, 8, 8, 8, 8, 0, 8, 16, 24);
-			Graphics::PixelFormat pixelFormatRGB(3, 8, 8, 8, 0, 0, 8, 16, 0);
-#else
-			Graphics::PixelFormat pixelFormatRGBA(4, 8, 8, 8, 8, 24, 16, 8, 0);
-			Graphics::PixelFormat pixelFormatRGB(3, 8, 8, 8, 0, 16, 8, 0, 0);
-#endif
-			Graphics::PixelFormat pixelFormatRGB565(2, 5, 6, 5, 0, 11, 5, 0, 0);
-			Graphics::PixelFormat pixelFormatRGB5551(2, 5, 5, 5, 1, 11, 6, 1, 0);
-			Graphics::PixelFormat pixelFormatRGB4444(2, 4, 4, 4, 4, 12, 8, 4, 0);
-			_rgbaTexture = generateRgbaTexture(120, 120, pixelFormatRGBA);
-			_rgbTexture = _rgbaTexture->convertTo(pixelFormatRGB);
-			_rgb565Texture = generateRgbaTexture(120, 120, pixelFormatRGB565);
-			_rgba5551Texture = generateRgbaTexture(120, 120, pixelFormatRGB5551);
-			_rgba4444Texture = generateRgbaTexture(120, 120, pixelFormatRGB4444);
+			genTextures();
+			texturesGenerated = true;
 			break;
 		}
 		default:
@@ -148,6 +157,36 @@ void Playground3dEngine::processInput() {
 		if (event.type == Common::EVENT_SCREEN_CHANGED) {
 			_gfx->computeScreenViewport();
 		}
+		if (event.type == Common::EVENT_LBUTTONUP) {
+			testId++;
+			if (testId > 5)
+				testId = 1;
+			switch (testId) {
+				case 1:
+					_clearColor = Math::Vector4d(0.5f, 0.5f, 0.5f, 1.0f);
+					_rotateAngleX = 45, _rotateAngleY = 45, _rotateAngleZ = 10;
+					break;
+				case 2:
+					_clearColor = Math::Vector4d(0.5f, 0.5f, 0.5f, 1.0f);
+					break;
+				case 3:
+					_clearColor = Math::Vector4d(1.0f, 0.0f, 0.0f, 1.0f);
+					break;
+				case 4:
+					_clearColor = Math::Vector4d(0.5f, 0.5f, 0.5f, 1.0f);
+					break;
+				case 5: {
+					_clearColor = Math::Vector4d(0.5f, 0.5f, 0.5f, 1.0f);
+					if (!texturesGenerated) {
+						genTextures();
+						texturesGenerated = true;
+					}
+					break;
+				}
+				default:
+					assert(false);
+			}
+		}
 	}
 }
 
@@ -218,7 +257,7 @@ void Playground3dEngine::drawRgbaTexture() {
 	_gfx->drawRgbaTexture();
 }
 
-void Playground3dEngine::drawFrame(int testId) {
+void Playground3dEngine::drawFrame(int id) {
 	_gfx->clear(_clearColor);
 
 	float pitch = 0.0f;
@@ -229,7 +268,7 @@ void Playground3dEngine::drawFrame(int testId) {
 	Common::Rect vp = _gfx->viewport();
 	_gfx->setupViewport(vp.left, _system->getHeight() - vp.top - vp.height(), vp.width(), vp.height());
 
-	switch (testId) {
+	switch (id) {
 		case 1:
 			if (_fogEnable) {
 				_gfx->enableFog(_fogColor);
diff --git a/engines/playground3d/playground3d.h b/engines/playground3d/playground3d.h
index a5bd7661fff..da713cbc0eb 100644
--- a/engines/playground3d/playground3d.h
+++ b/engines/playground3d/playground3d.h
@@ -41,6 +41,8 @@ public:
 
 	bool hasFeature(EngineFeature f) const override;
 
+	void genTextures();
+
 	void processInput();
 
 	void drawFrame(int testId);


Commit: d91852d222cd631667d0cb5cb737702190218a9a
    https://github.com/scummvm/scummvm/commit/d91852d222cd631667d0cb5cb737702190218a9a
Author: Michael Ball (ballm4788 at gmail.com)
Date: 2025-04-05T21:31:53+02:00

Commit Message:
PLAYGROUND3D: Implement Tests 2 and 4 in OpenGLShaders renderer

Changed paths:
  A engines/playground3d/shaders/playground3d_offset.fragment
  A engines/playground3d/shaders/playground3d_offset.vertex
  A engines/playground3d/shaders/playground3d_viewport.fragment
  A engines/playground3d/shaders/playground3d_viewport.vertex
    devtools/create_project/xcode.cpp
    dists/scummvm.rc
    engines/playground3d/gfx_opengl_shaders.cpp
    engines/playground3d/gfx_opengl_shaders.h


diff --git a/devtools/create_project/xcode.cpp b/devtools/create_project/xcode.cpp
index 31cb5e6b27d..318d64d4155 100644
--- a/devtools/create_project/xcode.cpp
+++ b/devtools/create_project/xcode.cpp
@@ -1121,6 +1121,10 @@ XcodeProvider::ValueList& XcodeProvider::getResourceFiles(const BuildSetup &setu
 			files.push_back("engines/playground3d/shaders/playground3d_cube.vertex");
 			files.push_back("engines/playground3d/shaders/playground3d_fade.fragment");
 			files.push_back("engines/playground3d/shaders/playground3d_fade.vertex");
+			files.push_back("engines/playground3d/shaders/playground3d_offset.fragment");
+			files.push_back("engines/playground3d/shaders/playground3d_offset.vertex");
+			files.push_back("engines/playground3d/shaders/playground3d_viewport.fragment");
+			files.push_back("engines/playground3d/shaders/playground3d_viewport.vertex");
 		}
 		if (CONTAINS_DEFINE(setup.defines, "ENABLE_STARK")) {
 			files.push_back("engines/stark/shaders/stark_actor.fragment");
diff --git a/dists/scummvm.rc b/dists/scummvm.rc
index 059c6619f79..5074f03d701 100644
--- a/dists/scummvm.rc
+++ b/dists/scummvm.rc
@@ -126,6 +126,10 @@ shaders/playground3d_cube.fragment      FILE    "engines/playground3d/shaders/pl
 shaders/playground3d_cube.vertex        FILE    "engines/playground3d/shaders/playground3d_cube.vertex"
 shaders/playground3d_fade.fragment      FILE    "engines/playground3d/shaders/playground3d_fade.fragment"
 shaders/playground3d_fade.vertex        FILE    "engines/playground3d/shaders/playground3d_fade.vertex"
+shaders/playground3d_offset.fragment    FILE    "engines/playground3d/shaders/playground3d_offset.fragment"
+shaders/playground3d_offset.vertex      FILE    "engines/playground3d/shaders/playground3d_offset.vertex"
+shaders/playground3d_viewport.fragment  FILE    "engines/playground3d/shaders/playground3d_viewport.fragment"
+shaders/playground3d_viewport.vertex    FILE    "engines/playground3d/shaders/playground3d_viewport.vertex"
 #endif
 #if PLUGIN_ENABLED_STATIC(HPL1)
 shaders/hpl1_Ambient_Color.fragment                    FILE   "engines/hpl1/engine/impl/shaders/hpl1_Ambient_Color.fragment"
diff --git a/engines/playground3d/gfx_opengl_shaders.cpp b/engines/playground3d/gfx_opengl_shaders.cpp
index 87084f52a0d..d750233ca77 100644
--- a/engines/playground3d/gfx_opengl_shaders.cpp
+++ b/engines/playground3d/gfx_opengl_shaders.cpp
@@ -38,6 +38,18 @@
 
 namespace Playground3d {
 
+static const GLfloat offsetVertices[] = {
+	//  X      Y
+	// 1st triangle
+	-1.0f,  1.0f,
+	 1.0f,  1.0f,
+	 0.0f, -1.0f,
+	// 2nd triangle
+	-0.5f,  0.5f,
+	 0.5f,  0.5f,
+	 0.0f, -0.5f,
+};
+
 static const GLfloat dimRegionVertices[] = {
 	//  X      Y
 	-0.5f,  0.5f,
@@ -46,6 +58,20 @@ static const GLfloat dimRegionVertices[] = {
 	 0.5f, -0.5f,
 };
 
+static const GLfloat boxVertices[] = {
+	//  X      Y
+	// static green box
+	-1.0f,  1.0f,
+	 1.0f,  1.0f,
+	-1.0f, -1.0f,
+	 1.0f, -1.0f,
+	// moving red box
+	-0.1f,  0.1f,
+	 0.1f,  0.1f,
+	-0.1f, -0.1f,
+	 0.1f, -0.1f,
+};
+
 static const GLfloat bitmapVertices[] = {
 	//  X      Y     S     T
 	-0.2f,  0.2f, 0.0f, 0.0f,
@@ -62,20 +88,28 @@ ShaderRenderer::ShaderRenderer(OSystem *system) :
 		Renderer(system),
 		_currentViewport(kOriginalWidth, kOriginalHeight),
 		_cubeShader(nullptr),
+		_offsetShader(nullptr),
 		_fadeShader(nullptr),
+		_viewportShader(nullptr),
 		_bitmapShader(nullptr),
 		_cubeVBO(0),
+		_offsetVBO(0),
 		_fadeVBO(0),
+		_viewportVBO(0),
 		_bitmapVBO(0) {
 }
 
 ShaderRenderer::~ShaderRenderer() {
 	OpenGL::Shader::freeBuffer(_cubeVBO);
+	OpenGL::Shader::freeBuffer(_offsetVBO);
 	OpenGL::Shader::freeBuffer(_fadeVBO);
+	OpenGL::Shader::freeBuffer(_viewportVBO);
 	OpenGL::Shader::freeBuffer(_bitmapVBO);
 
 	delete _cubeShader;
+	delete _offsetShader;
 	delete _fadeShader;
+	delete _viewportShader;
 	delete _bitmapShader;
 }
 
@@ -92,11 +126,21 @@ void ShaderRenderer::init() {
 	_cubeShader->enableVertexAttribute("normal", _cubeVBO, 3, GL_FLOAT, GL_FALSE, 11 * sizeof(float), 20);
 	_cubeShader->enableVertexAttribute("color", _cubeVBO, 3, GL_FLOAT, GL_FALSE, 11 * sizeof(float), 32);
 
+	static const char *offsetAttributes[] = { "position", nullptr };
+	_offsetShader = OpenGL::Shader::fromFiles("playground3d_offset", offsetAttributes);
+	_offsetVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(offsetVertices), offsetVertices);
+	_offsetShader->enableVertexAttribute("position", _offsetVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0);
+
 	static const char *fadeAttributes[] = { "position", nullptr };
 	_fadeShader = OpenGL::Shader::fromFiles("playground3d_fade", fadeAttributes);
 	_fadeVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(dimRegionVertices), dimRegionVertices);
 	_fadeShader->enableVertexAttribute("position", _fadeVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0);
 
+	static const char *viewportAttributes[] = { "position", nullptr };
+	_viewportShader = OpenGL::Shader::fromFiles("playground3d_viewport", viewportAttributes);
+	_viewportVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(boxVertices), boxVertices);
+	_viewportShader->enableVertexAttribute("position", _viewportVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0);
+
 	static const char *bitmapAttributes[] = { "position", "texcoord", nullptr };
 	_bitmapShader = OpenGL::Shader::fromFiles("playground3d_bitmap", bitmapAttributes);
 	_bitmapVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(bitmapVertices), bitmapVertices);
@@ -192,7 +236,26 @@ void ShaderRenderer::drawCube(const Math::Vector3d &pos, const Math::Vector3d &r
 }
 
 void ShaderRenderer::drawPolyOffsetTest(const Math::Vector3d &pos, const Math::Vector3d &roll) {
-	error("Polygon offset test not implemented yet");
+	glDisable(GL_BLEND);
+	glBlendFunc(GL_ONE, GL_ZERO);
+	glEnable(GL_DEPTH_TEST);
+	glDepthMask(GL_TRUE);
+	glDisable(GL_TEXTURE_2D);
+
+	auto rotateMatrix = (Math::Quaternion::fromEuler(roll.x(), roll.y(), roll.z(), Math::EO_XYZ)).inverse().toMatrix();
+	_offsetShader->use();
+	_offsetShader->setUniform("mvpMatrix", _mvpMatrix);
+	_offsetShader->setUniform("rotateMatrix", rotateMatrix);
+	_offsetShader->setUniform("modelPos", pos);
+
+	_offsetShader->setUniform("triColor", Math::Vector3d(0.0f, 1.0f, 0.0f));
+	glDrawArrays(GL_TRIANGLES, 0, 3);
+
+	glPolygonOffset(-1.0f, 0.0f);
+	glEnable(GL_POLYGON_OFFSET_FILL);
+	_offsetShader->setUniform("triColor", Math::Vector3d(1.0f, 1.0f, 1.0f));
+	glDrawArrays(GL_TRIANGLES, 3, 3);
+	glDisable(GL_POLYGON_OFFSET_FILL);
 }
 
 void ShaderRenderer::dimRegionInOut(float fade) {
@@ -200,6 +263,7 @@ void ShaderRenderer::dimRegionInOut(float fade) {
 	glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
 	glDisable(GL_DEPTH_TEST);
 	glDepthMask(GL_FALSE);
+	glDisable(GL_TEXTURE_2D);
 
 	_fadeShader->use();
 	_fadeShader->setUniform1f("alphaLevel", 1.0 - fade);
@@ -208,7 +272,31 @@ void ShaderRenderer::dimRegionInOut(float fade) {
 }
 
 void ShaderRenderer::drawInViewport() {
-	error("Draw in viewport test not implemented yet");
+	glEnable(GL_BLEND);
+	glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+	glDisable(GL_DEPTH_TEST);
+	glDepthMask(GL_FALSE);
+	glDisable(GL_TEXTURE_2D);
+
+	_viewportShader->use();
+	_viewportShader->setUniform("offset", Math::Vector2d(0.0f, 0.0f));
+	_viewportShader->setUniform("color", Math::Vector3d(0.0f, 1.0f, 0.0f));
+	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+	_pos.setX(_pos.getX() + 0.01f);
+	_pos.setY(_pos.getY() + 0.01f);
+	if (_pos.getX() >= 1.0f) {
+		_pos.setX(-1.0f);
+		_pos.setY(-1.0f);
+	}
+
+	_viewportShader->setUniform("offset", _pos);
+	_viewportShader->setUniform("color", Math::Vector3d(1.0f, 0.0f, 0.0f));
+	glPolygonOffset(-1.0f, 0.0f);
+	glEnable(GL_POLYGON_OFFSET_FILL);
+	glDrawArrays(GL_TRIANGLE_STRIP, 4, 4);
+	glDisable(GL_POLYGON_OFFSET_FILL);
+	_viewportShader->unbind();
 }
 
 void ShaderRenderer::drawRgbaTexture() {
diff --git a/engines/playground3d/gfx_opengl_shaders.h b/engines/playground3d/gfx_opengl_shaders.h
index 0dee71431d1..86e266f8774 100644
--- a/engines/playground3d/gfx_opengl_shaders.h
+++ b/engines/playground3d/gfx_opengl_shaders.h
@@ -59,14 +59,19 @@ public:
 
 private:
 	OpenGL::Shader *_cubeShader;
+	OpenGL::Shader *_offsetShader;
 	OpenGL::Shader *_fadeShader;
+	OpenGL::Shader *_viewportShader;
 	OpenGL::Shader *_bitmapShader;
 
 	GLuint _cubeVBO;
+	GLuint _offsetVBO;
 	GLuint _fadeVBO;
+	GLuint _viewportVBO;
 	GLuint _bitmapVBO;
 
 	Common::Rect _currentViewport;
+	Math::Vector2d _pos;
 	GLuint _textureRgbaId[5];
 	GLuint _textureRgbId[5];
 	GLuint _textureRgb565Id[2];
diff --git a/engines/playground3d/shaders/playground3d_offset.fragment b/engines/playground3d/shaders/playground3d_offset.fragment
new file mode 100644
index 00000000000..0bcff71e6b0
--- /dev/null
+++ b/engines/playground3d/shaders/playground3d_offset.fragment
@@ -0,0 +1,8 @@
+
+OUTPUT
+
+uniform vec3 triColor;
+
+void main() {
+	outColor = vec4(triColor, 1.0);
+}
diff --git a/engines/playground3d/shaders/playground3d_offset.vertex b/engines/playground3d/shaders/playground3d_offset.vertex
new file mode 100644
index 00000000000..89a27f49515
--- /dev/null
+++ b/engines/playground3d/shaders/playground3d_offset.vertex
@@ -0,0 +1,12 @@
+in vec2 position;
+
+uniform mat4 mvpMatrix;
+uniform mat4 projMatrix;
+uniform mat4 modelMatrix;
+uniform mat4 rotateMatrix;
+uniform vec3 modelPos;
+
+void main() {
+	vec4 pos = rotateMatrix * vec4(position, 0.0, 1.0);
+	gl_Position = mvpMatrix * (pos + vec4(modelPos, 1.0));
+}
diff --git a/engines/playground3d/shaders/playground3d_viewport.fragment b/engines/playground3d/shaders/playground3d_viewport.fragment
new file mode 100644
index 00000000000..72a76e8fbe6
--- /dev/null
+++ b/engines/playground3d/shaders/playground3d_viewport.fragment
@@ -0,0 +1,8 @@
+
+OUTPUT
+
+uniform vec3 color;
+
+void main() {
+	outColor = vec4(color, 1.0);
+}
diff --git a/engines/playground3d/shaders/playground3d_viewport.vertex b/engines/playground3d/shaders/playground3d_viewport.vertex
new file mode 100644
index 00000000000..8f5a3486e5d
--- /dev/null
+++ b/engines/playground3d/shaders/playground3d_viewport.vertex
@@ -0,0 +1,7 @@
+in vec2 position;
+
+uniform vec2 offset;
+
+void main() {
+	gl_Position = vec4(position + offset, 0.0, 1.0);
+}


Commit: 172a5962f11684050df4ad7b5fab9a7f72089450
    https://github.com/scummvm/scummvm/commit/172a5962f11684050df4ad7b5fab9a7f72089450
Author: Michael Ball (ballm4788 at gmail.com)
Date: 2025-04-05T21:31:53+02:00

Commit Message:
PLAYGROUND3D: Move red square out of view before looping

Changed paths:
    engines/playground3d/gfx_opengl.cpp
    engines/playground3d/gfx_opengl_shaders.cpp
    engines/playground3d/gfx_tinygl.cpp


diff --git a/engines/playground3d/gfx_opengl.cpp b/engines/playground3d/gfx_opengl.cpp
index fbbd54f9be5..c6eff8d167a 100644
--- a/engines/playground3d/gfx_opengl.cpp
+++ b/engines/playground3d/gfx_opengl.cpp
@@ -283,9 +283,9 @@ void OpenGLRenderer::drawInViewport() {
 	glPushMatrix();
 	_pos.x() += 0.01f;
 	_pos.y() += 0.01f;
-	if (_pos.x() >= 1.0f) {
-		_pos.x() = -1.0f;
-		_pos.y() = -1.0f;
+	if (_pos.x() >= 1.1f) {
+		_pos.x() = -1.1f;
+		_pos.y() = -1.1f;
 	}
 	glTranslatef(_pos.x(), _pos.y(), 0);
 
diff --git a/engines/playground3d/gfx_opengl_shaders.cpp b/engines/playground3d/gfx_opengl_shaders.cpp
index d750233ca77..1f093b91068 100644
--- a/engines/playground3d/gfx_opengl_shaders.cpp
+++ b/engines/playground3d/gfx_opengl_shaders.cpp
@@ -285,9 +285,9 @@ void ShaderRenderer::drawInViewport() {
 
 	_pos.setX(_pos.getX() + 0.01f);
 	_pos.setY(_pos.getY() + 0.01f);
-	if (_pos.getX() >= 1.0f) {
-		_pos.setX(-1.0f);
-		_pos.setY(-1.0f);
+	if (_pos.getX() >= 1.1f) {
+		_pos.setX(-1.1f);
+		_pos.setY(-1.1f);
 	}
 
 	_viewportShader->setUniform("offset", _pos);
diff --git a/engines/playground3d/gfx_tinygl.cpp b/engines/playground3d/gfx_tinygl.cpp
index cf427ca6218..feadd111ced 100644
--- a/engines/playground3d/gfx_tinygl.cpp
+++ b/engines/playground3d/gfx_tinygl.cpp
@@ -329,9 +329,9 @@ void TinyGLRenderer::drawInViewport() {
 	tglPushMatrix();
 	_pos.x() += 0.01f;
 	_pos.y() += 0.01f;
-	if (_pos.x() >= 1.0f) {
-		_pos.x() = -1.0;
-		_pos.y() = -1.0;
+	if (_pos.x() >= 1.1f) {
+		_pos.x() = -1.1;
+		_pos.y() = -1.1;
 	}
 	tglTranslatef(_pos.x(), _pos.y(), 0);
 




More information about the Scummvm-git-logs mailing list