[Scummvm-git-logs] scummvm master -> 4ddb84c13352d04ab8dbeafe81f2fb6a37abc6a1
bluegr
noreply at scummvm.org
Sat Dec 6 14:04:36 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:
4ddb84c133 STARK: Add support for OpenGL without NPOT
Commit: 4ddb84c13352d04ab8dbeafe81f2fb6a37abc6a1
https://github.com/scummvm/scummvm/commit/4ddb84c13352d04ab8dbeafe81f2fb6a37abc6a1
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-12-06T16:04:32+02: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;
}
}
More information about the Scummvm-git-logs
mailing list