[Scummvm-git-logs] scummvm branch-3-0 -> a243c2c6d1d3a0d53f41640da3bf9e5b502c2893

lephilousophe noreply at scummvm.org
Sun Dec 7 20:47:17 UTC 2025


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

Summary:
c20990c7dc STARK: Add support for OpenGL without NPOT
a243c2c6d1 NEWS: Add Stark fix


Commit: c20990c7dcadac739917ee612916f44f8ab4d99c
    https://github.com/scummvm/scummvm/commit/c20990c7dcadac739917ee612916f44f8ab4d99c
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-12-07T21:44:14+01:00

Commit Message:
STARK: Add support for OpenGL without NPOT

Only bitmaps need the support as textures (which are mipmapped) are
already POT sized.

Changed paths:
    engines/stark/gfx/openglbitmap.cpp
    engines/stark/gfx/openglbitmap.h
    engines/stark/gfx/openglsurface.cpp
    engines/stark/gfx/opengltexture.cpp


diff --git a/engines/stark/gfx/openglbitmap.cpp b/engines/stark/gfx/openglbitmap.cpp
index 8fda2926d1f..249eed6f589 100644
--- a/engines/stark/gfx/openglbitmap.cpp
+++ b/engines/stark/gfx/openglbitmap.cpp
@@ -57,19 +57,43 @@ void OpenGlBitmap::bind() const {
 void OpenGlBitmap::update(const Graphics::Surface *surface, const byte *palette) {
 	bind();
 
-	_width = surface->w;
-	_height = surface->h;
-
+	const Graphics::Surface *rgbaSurface = surface;
 	if (surface->format != Driver::getRGBAPixelFormat()) {
 		// Convert the surface to texture format
-		Graphics::Surface *convertedSurface = surface->convertTo(Driver::getRGBAPixelFormat(), palette);
+		rgbaSurface = surface->convertTo(Driver::getRGBAPixelFormat(), palette);
+	}
+
+	_width = rgbaSurface->w;
+	_height = rgbaSurface->h;
 
-		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, convertedSurface->w, convertedSurface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, convertedSurface->getPixels());
+	GLfloat s, t;
 
-		convertedSurface->free();
-		delete convertedSurface;
+	if (!OpenGLContext.NPOTSupported) {
+		uint32 texWidth  = Common::nextHigher2(rgbaSurface->w);
+		uint32 texHeight = Common::nextHigher2(rgbaSurface->h);
+		s = (GLfloat)_width / texWidth;
+		t = (GLfloat)_height / texHeight;
+
+		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
+		glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, rgbaSurface->w, rgbaSurface->h,
+		                GL_RGBA, GL_UNSIGNED_BYTE, rgbaSurface->getPixels());
 	} else {
-		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->getPixels());
+		s = t = 1.f;
+		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rgbaSurface->w, rgbaSurface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaSurface->getPixels());
+	}
+
+	_texCoords[0*2+0] = 0.0f;
+	_texCoords[0*2+1] = 0.0f;
+	_texCoords[1*2+0] = s;
+	_texCoords[1*2+1] = 0.0f;
+	_texCoords[2*2+0] = 0.0f;
+	_texCoords[2*2+1] = t;
+	_texCoords[3*2+0] = s;
+	_texCoords[3*2+1] = t;
+
+	if (rgbaSurface != surface) {
+		const_cast<Graphics::Surface *>(rgbaSurface)->free();
+		delete rgbaSurface;
 	}
 }
 
diff --git a/engines/stark/gfx/openglbitmap.h b/engines/stark/gfx/openglbitmap.h
index 59797f954bb..5713f5cd05a 100644
--- a/engines/stark/gfx/openglbitmap.h
+++ b/engines/stark/gfx/openglbitmap.h
@@ -45,8 +45,11 @@ public:
 	void setSamplingFilter(SamplingFilter filter) override;
 	Graphics::PixelFormat getBestPixelFormat() const override;
 
+	const GLfloat *getTexCoords() const { return _texCoords; }
+
 protected:
 	GLuint _id;
+	GLfloat _texCoords[2*4];
 };
 
 } // End of namespace Gfx
diff --git a/engines/stark/gfx/openglsurface.cpp b/engines/stark/gfx/openglsurface.cpp
index 37e1893cdd1..7abd1ae6294 100644
--- a/engines/stark/gfx/openglsurface.cpp
+++ b/engines/stark/gfx/openglsurface.cpp
@@ -20,7 +20,7 @@
  */
 
 #include "engines/stark/gfx/openglsurface.h"
-#include "engines/stark/gfx/bitmap.h"
+#include "engines/stark/gfx/openglbitmap.h"
 #include "engines/stark/gfx/color.h"
 
 #if defined(USE_OPENGL_GAME)
@@ -28,14 +28,6 @@
 namespace Stark {
 namespace Gfx {
 
-static const GLfloat textCords[] = {
-	// S   T
-	0.0f, 0.0f,
-	1.0f, 0.0f,
-	0.0f, 1.0f,
-	1.0f, 1.0f,
-};
-
 OpenGLSurfaceRenderer::OpenGLSurfaceRenderer(OpenGLDriver *gfx) :
 		SurfaceRenderer(),
 		_gfx(gfx) {
@@ -71,7 +63,7 @@ void OpenGLSurfaceRenderer::render(const Bitmap *bitmap, const Common::Point &de
 	glDisableClientState(GL_NORMAL_ARRAY);
 
 	glVertexPointer(2, GL_FLOAT, sizeof(SurfaceVertex), &vertices[0].x);
-	glTexCoordPointer(2, GL_FLOAT, 2 * sizeof(float), textCords);
+	glTexCoordPointer(2, GL_FLOAT, 2 * sizeof(float), ((const OpenGlBitmap *)bitmap)->getTexCoords());
 	glColor4f(1.0f - _fadeLevel, 1.0f - _fadeLevel, 1.0f - _fadeLevel, 1.0f);
 
 	bitmap->bind();
diff --git a/engines/stark/gfx/opengltexture.cpp b/engines/stark/gfx/opengltexture.cpp
index 81a96cf1ed1..e3872190a1b 100644
--- a/engines/stark/gfx/opengltexture.cpp
+++ b/engines/stark/gfx/opengltexture.cpp
@@ -56,16 +56,18 @@ void OpenGlTexture::bind() const {
 }
 
 void OpenGlTexture::updateLevel(uint32 level, const Graphics::Surface *surface, const byte *palette) {
+	const Graphics::Surface *rgbaSurface = surface;
 	if (surface->format != Driver::getRGBAPixelFormat()) {
 		// Convert the surface to texture format
-		Graphics::Surface *convertedSurface = surface->convertTo(Driver::getRGBAPixelFormat(), palette);
+		rgbaSurface = surface->convertTo(Driver::getRGBAPixelFormat(), palette);
+	}
 
-		glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, convertedSurface->w, convertedSurface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, convertedSurface->getPixels());
+	// Stark textures (not bitmaps!) are always POT
+	glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, rgbaSurface->w, rgbaSurface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaSurface->getPixels());
 
-		convertedSurface->free();
-		delete convertedSurface;
-	} else {
-		glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, surface->w, surface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->getPixels());
+	if (rgbaSurface != surface) {
+		const_cast<Graphics::Surface *>(rgbaSurface)->free();
+		delete rgbaSurface;
 	}
 }
 


Commit: a243c2c6d1d3a0d53f41640da3bf9e5b502c2893
    https://github.com/scummvm/scummvm/commit/a243c2c6d1d3a0d53f41640da3bf9e5b502c2893
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-12-07T21:46:58+01:00

Commit Message:
NEWS: Add Stark fix

Changed paths:
    NEWS.md


diff --git a/NEWS.md b/NEWS.md
index c8e68e967d3..a7fb83b9a75 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -196,6 +196,9 @@ For a more comprehensive changelog of the latest experimental code, see:
  Sherlock:
    - Added keymapper support.
 
+ Stark:
+   - The OpenGL renderer now works on older implementations not supporting non-power-of-two textures
+
  Supernova:
    - Added keymapper support.
 




More information about the Scummvm-git-logs mailing list