[Scummvm-git-logs] scummvm master -> 7c6b316b0d6572d0629b8ffc97d8f6d7c60a759b
bluegr
noreply at scummvm.org
Wed Apr 15 16:43:33 UTC 2026
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:
7c6b316b0d HPL1: Simplify texture format handling
Commit: 7c6b316b0d6572d0629b8ffc97d8f6d7c60a759b
https://github.com/scummvm/scummvm/commit/7c6b316b0d6572d0629b8ffc97d8f6d7c60a759b
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2026-04-15T19:43:30+03:00
Commit Message:
HPL1: Simplify texture format handling
Changed paths:
engines/hpl1/engine/graphics/GraphicsTypes.h
engines/hpl1/engine/graphics/Texture.h
engines/hpl1/engine/graphics/bitmap2D.cpp
engines/hpl1/engine/graphics/bitmap2D.h
engines/hpl1/engine/impl/LowLevelGraphicsSDL.cpp
engines/hpl1/engine/impl/LowLevelGraphicsSDL.h
engines/hpl1/engine/impl/SDLTexture.cpp
engines/hpl1/engine/impl/SDLTexture.h
engines/hpl1/engine/impl/low_level_graphics_tgl.cpp
engines/hpl1/engine/impl/low_level_graphics_tgl.h
engines/hpl1/engine/impl/texture_tgl.cpp
engines/hpl1/engine/impl/texture_tgl.h
diff --git a/engines/hpl1/engine/graphics/GraphicsTypes.h b/engines/hpl1/engine/graphics/GraphicsTypes.h
index 611e2083111..09deb3b67a3 100644
--- a/engines/hpl1/engine/graphics/GraphicsTypes.h
+++ b/engines/hpl1/engine/graphics/GraphicsTypes.h
@@ -70,17 +70,6 @@ typedef tFlag tAnimTransformFlag;
const tAnimTransformFlag kvAnimTransformFlags[] = {eAnimTransformFlag_Translate,
eAnimTransformFlag_Scale, eAnimTransformFlag_Rotate};
-//-----------------------------------------
-
-enum eColorDataFormat {
- eColorDataFormat_RGB,
- eColorDataFormat_RGBA,
- eColorDataFormat_ALPHA,
- eColorDataFormat_BGR,
- eColorDataFormat_BGRA,
- eColorDataFormat_LastEnum
-};
-
//---------------------------------------
enum eFontAlign {
diff --git a/engines/hpl1/engine/graphics/Texture.h b/engines/hpl1/engine/graphics/Texture.h
index 4cc8bf2bec6..72bd92e36f9 100644
--- a/engines/hpl1/engine/graphics/Texture.h
+++ b/engines/hpl1/engine/graphics/Texture.h
@@ -135,9 +135,6 @@ public:
virtual void Update(float afTimeStep) = 0;
- virtual void SetPixels2D(int alLevel, const cVector2l &avOffset, const cVector2l &avSize,
- eColorDataFormat aDataFormat, void *apPixelData) = 0;
-
virtual void SetFilter(eTextureFilter aFilter) = 0;
virtual void SetAnisotropyDegree(float afX) = 0;
eTextureFilter GetFilter() { return mFilter; }
diff --git a/engines/hpl1/engine/graphics/bitmap2D.cpp b/engines/hpl1/engine/graphics/bitmap2D.cpp
index 494162d778a..26a3a0be887 100644
--- a/engines/hpl1/engine/graphics/bitmap2D.cpp
+++ b/engines/hpl1/engine/graphics/bitmap2D.cpp
@@ -40,8 +40,8 @@ static Image::ImageDecoder *loadImage(const tString &filepath, Image::ImageDecod
return decoder;
}
-Image::JPEGDecoder *setupJPEGDecoder(Image::JPEGDecoder *jpeg) {
- jpeg->setOutputPixelFormat(Graphics::PixelFormat::createFormatRGBA32());
+Image::JPEGDecoder *setupJPEGDecoder(Image::JPEGDecoder *jpeg, const Graphics::PixelFormat &desiredFormat) {
+ jpeg->setOutputPixelFormat(desiredFormat);
return jpeg;
}
@@ -54,7 +54,7 @@ Bitmap2D::Bitmap2D(const tString &filepath, const tString &type, const Graphics:
else if (type == "tga")
_decoder.reset(loadImage(filepath, new Image::TGADecoder));
else if (type == "jpg" || type == "jpeg")
- _decoder.reset(loadImage(filepath, setupJPEGDecoder(new Image::JPEGDecoder)));
+ _decoder.reset(loadImage(filepath, setupJPEGDecoder(new Image::JPEGDecoder, desiredFormat)));
#ifdef USE_GIF
else if (type == "gif")
_decoder.reset(loadImage(filepath, new Image::GIFDecoder));
diff --git a/engines/hpl1/engine/graphics/bitmap2D.h b/engines/hpl1/engine/graphics/bitmap2D.h
index 9b8db809f35..b1437e3aca1 100644
--- a/engines/hpl1/engine/graphics/bitmap2D.h
+++ b/engines/hpl1/engine/graphics/bitmap2D.h
@@ -42,7 +42,7 @@ namespace hpl {
class Bitmap2D : public LowLevelPicture {
public:
Bitmap2D(const cVector2l &size, const Graphics::PixelFormat &format);
- Bitmap2D(const tString &filename, const tString &type, const Graphics::PixelFormat &desiredFormat = {});
+ Bitmap2D(const tString &filename, const tString &type, const Graphics::PixelFormat &desiredFormat);
~Bitmap2D();
diff --git a/engines/hpl1/engine/impl/LowLevelGraphicsSDL.cpp b/engines/hpl1/engine/impl/LowLevelGraphicsSDL.cpp
index 19ca4decfe6..e64ab851df5 100644
--- a/engines/hpl1/engine/impl/LowLevelGraphicsSDL.cpp
+++ b/engines/hpl1/engine/impl/LowLevelGraphicsSDL.cpp
@@ -48,25 +48,6 @@
namespace hpl {
-GLenum ColorFormatToGL(eColorDataFormat format) {
- switch (format) {
- case eColorDataFormat_RGB:
- return GL_RGB;
- case eColorDataFormat_RGBA:
- return GL_RGBA;
- case eColorDataFormat_ALPHA:
- return GL_ALPHA;
- case eColorDataFormat_BGR:
- return GL_BGR;
- case eColorDataFormat_BGRA:
- return GL_BGRA;
- default:
- break;
- }
- Hpl1::logError(Hpl1::kDebugOpenGL, "invalid color format (%d)\n", format);
- return GL_RGB;
-}
-
GLenum TextureTargetToGL(eTextureTarget target) {
switch (target) {
case eTextureTarget_1D:
diff --git a/engines/hpl1/engine/impl/LowLevelGraphicsSDL.h b/engines/hpl1/engine/impl/LowLevelGraphicsSDL.h
index 1b264da7311..fc6cdeca819 100644
--- a/engines/hpl1/engine/impl/LowLevelGraphicsSDL.h
+++ b/engines/hpl1/engine/impl/LowLevelGraphicsSDL.h
@@ -41,8 +41,6 @@ namespace hpl {
//-------------------------------------------------
-GLenum ColorFormatToGL(eColorDataFormat format);
-
GLenum TextureTargetToGL(eTextureTarget target);
//-------------------------------------------------
diff --git a/engines/hpl1/engine/impl/SDLTexture.cpp b/engines/hpl1/engine/impl/SDLTexture.cpp
index ed003736714..2a1ca3b0c13 100644
--- a/engines/hpl1/engine/impl/SDLTexture.cpp
+++ b/engines/hpl1/engine/impl/SDLTexture.cpp
@@ -38,33 +38,6 @@
namespace hpl {
-static void getSettings(Bitmap2D *apSrc, int &alChannels, GLint &internalFormat, GLenum &format) {
- alChannels = apSrc->getNumChannels();
- tString sType = cString::ToLowerCase(apSrc->getType());
- const Common::String bmpFormat = apSrc->format().toString();
-
- if (alChannels == 4) {
- internalFormat = GL_RGBA;
- if (bmpFormat.contains("BGRA")) {
- format = GL_BGRA;
- } else {
- format = GL_RGBA;
- }
- }
- if (alChannels == 3) {
- internalFormat = GL_RGB;
- if (bmpFormat.contains("BGR")) {
- format = GL_BGR;
- } else {
- format = GL_RGB;
- }
- }
- if (alChannels == 1) {
- format = GL_RED;
- internalFormat = GL_RED;
- }
-}
-
//////////////////////////////////////////////////////////////////////////
// CONSTRUCTORS
//////////////////////////////////////////////////////////////////////////
@@ -167,10 +140,9 @@ bool cSDLTexture::CreateCubeFromBitmapVec(tBitmap2DVec *avBitmaps) {
GLenum target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + i;
- int lChannels;
- GLenum format;
- GLint internalFormat;
- getSettings(pSrc, lChannels, internalFormat, format);
+ int lChannels = 4;
+ GLenum format = GL_RGBA;
+ GLint internalFormat = GL_RGBA;
glTexImage2D(target, 0, internalFormat, pSrc->getWidth(), pSrc->getHeight(),
0, format, GL_UNSIGNED_BYTE, pSrc->getRawData());
@@ -267,17 +239,6 @@ bool cSDLTexture::CreateFromArray(unsigned char *apPixelData, int alChannels, co
//-----------------------------------------------------------------------
-void cSDLTexture::SetPixels2D(int alLevel, const cVector2l &avOffset, const cVector2l &avSize,
- eColorDataFormat aDataFormat, void *apPixelData) {
- if (mTarget != eTextureTarget_2D && mTarget != eTextureTarget_Rect)
- return;
-
- GL_CHECK(glTexSubImage2D(TextureTargetToGL(mTarget), alLevel, avOffset.x, avOffset.y, avSize.x, avSize.y,
- ColorFormatToGL(aDataFormat), GL_UNSIGNED_BYTE, apPixelData));
-}
-
-//-----------------------------------------------------------------------
-
void cSDLTexture::Update(float afTimeStep) {
if (mvTextureHandles.size() > 1) {
float fMax = (float)(mvTextureHandles.size());
@@ -514,10 +475,9 @@ bool cSDLTexture::CreateFromBitmapToHandle(Bitmap2D *pBmp, int alHandleIdx) {
if ((!cMath::IsPow2(_height) || !cMath::IsPow2(_width)) && mTarget != eTextureTarget_Rect)
Hpl1::logWarning(Hpl1::kDebugTextures, "Texture '%s' does not have a pow2 size", msName.c_str());
- int lChannels = 0;
- GLint internalFormat = 0;
- GLenum format = 0;
- getSettings(pBitmapSrc, lChannels, internalFormat, format);
+ int lChannels = 4;
+ GLint internalFormat = GL_RGBA;
+ GLenum format = GL_RGBA;
_bpp = lChannels * 8;
diff --git a/engines/hpl1/engine/impl/SDLTexture.h b/engines/hpl1/engine/impl/SDLTexture.h
index 429c1389c78..665e9f2da33 100644
--- a/engines/hpl1/engine/impl/SDLTexture.h
+++ b/engines/hpl1/engine/impl/SDLTexture.h
@@ -54,9 +54,6 @@ public:
bool CreateFromArray(unsigned char *apPixelData, int alChannels, const cVector3l &avSize);
- void SetPixels2D(int alLevel, const cVector2l &avOffset, const cVector2l &avSize,
- eColorDataFormat aDataFormat, void *apPixelData);
-
float GetGamma() { return 0; }
void SetGamma(float afGamma) {}
int GetHandle() { return (int)mvTextureHandles[0]; }
diff --git a/engines/hpl1/engine/impl/low_level_graphics_tgl.cpp b/engines/hpl1/engine/impl/low_level_graphics_tgl.cpp
index 163ca83edd7..6960f8f8ddb 100644
--- a/engines/hpl1/engine/impl/low_level_graphics_tgl.cpp
+++ b/engines/hpl1/engine/impl/low_level_graphics_tgl.cpp
@@ -37,25 +37,6 @@
namespace hpl {
-TGLenum ColorFormatToTGL(eColorDataFormat format) {
- switch (format) {
- case eColorDataFormat_RGB:
- return TGL_RGB;
- case eColorDataFormat_RGBA:
- return TGL_RGBA;
- case eColorDataFormat_ALPHA:
- return TGL_ALPHA;
- case eColorDataFormat_BGR:
- return TGL_BGR;
- case eColorDataFormat_BGRA:
- return TGL_BGRA;
- default:
- break;
- }
- Hpl1::logError(Hpl1::kDebugOpenGL, "invalid color format (%d)\n", format);
- return 0;
-}
-
TGLenum TextureTargetToTGL(eTextureTarget target) {
switch (target) {
case eTextureTarget_1D:
diff --git a/engines/hpl1/engine/impl/low_level_graphics_tgl.h b/engines/hpl1/engine/impl/low_level_graphics_tgl.h
index 0d952610250..5d92f3bb66b 100644
--- a/engines/hpl1/engine/impl/low_level_graphics_tgl.h
+++ b/engines/hpl1/engine/impl/low_level_graphics_tgl.h
@@ -33,8 +33,6 @@
namespace hpl {
-TGLenum ColorFormatToTGL(eColorDataFormat format);
-
TGLenum TextureTargetToTGL(eTextureTarget target);
TGLenum GetTGLTextureTargetEnum(eTextureTarget type);
diff --git a/engines/hpl1/engine/impl/texture_tgl.cpp b/engines/hpl1/engine/impl/texture_tgl.cpp
index 4c0b85225bd..53e8548ecac 100644
--- a/engines/hpl1/engine/impl/texture_tgl.cpp
+++ b/engines/hpl1/engine/impl/texture_tgl.cpp
@@ -30,33 +30,6 @@
namespace hpl {
-static void getSettings(Bitmap2D *apSrc, int &alChannels, TGLint &internalFormat, TGLenum &format) {
- alChannels = apSrc->getNumChannels();
- tString sType = cString::ToLowerCase(apSrc->getType());
- const Common::String bmpFormat = apSrc->format().toString();
-
- if (alChannels == 4) {
- internalFormat = TGL_RGBA;
- if (bmpFormat.contains("BGRA")) {
- format = TGL_BGRA;
- } else {
- format = TGL_RGBA;
- }
- }
- if (alChannels == 3) {
- internalFormat = TGL_RGB;
- if (bmpFormat.contains("BGR")) {
- format = TGL_BGR;
- } else {
- format = TGL_RGB;
- }
- }
- if (alChannels == 1) {
- format = TGL_RED;
- internalFormat = TGL_RED;
- }
-}
-
//////////////////////////////////////////////////////////////////////////
// CONSTRUCTORS
//////////////////////////////////////////////////////////////////////////
@@ -175,13 +148,6 @@ bool TGLTexture::CreateFromArray(unsigned char *apPixelData, int alChannels, con
//-----------------------------------------------------------------------
-void TGLTexture::SetPixels2D(int alLevel, const cVector2l &avOffset, const cVector2l &avSize,
- eColorDataFormat aDataFormat, void *apPixelData) {
- HPL1_UNIMPLEMENTED(TGLTexture::SetPixels2D);
-}
-
-//-----------------------------------------------------------------------
-
void TGLTexture::Update(float afTimeStep) {
if (mvTextureHandles.size() > 1) {
float fMax = (float)(mvTextureHandles.size());
@@ -371,10 +337,9 @@ bool TGLTexture::CreateFromBitmapToHandle(Bitmap2D *pBmp, int alHandleIdx) {
if ((!cMath::IsPow2(_height) || !cMath::IsPow2(_width)) && mTarget != eTextureTarget_Rect)
Hpl1::logWarning(Hpl1::kDebugTextures, "texture '%s' does not have a pow2 size", msName.c_str());
- int lChannels = 0;
- TGLint internalFormat = 0;
- TGLenum format = 0;
- getSettings(pBitmapSrc, lChannels, internalFormat, format);
+ int lChannels = 4;
+ TGLint internalFormat = TGL_RGBA;
+ TGLenum format = TGL_RGBA;
_bpp = lChannels * 8;
diff --git a/engines/hpl1/engine/impl/texture_tgl.h b/engines/hpl1/engine/impl/texture_tgl.h
index 87cd29ca739..48ba01d26e9 100644
--- a/engines/hpl1/engine/impl/texture_tgl.h
+++ b/engines/hpl1/engine/impl/texture_tgl.h
@@ -46,9 +46,6 @@ public:
bool CreateFromArray(unsigned char *apPixelData, int alChannels, const cVector3l &avSize);
- void SetPixels2D(int alLevel, const cVector2l &avOffset, const cVector2l &avSize,
- eColorDataFormat aDataFormat, void *apPixelData);
-
float GetGamma() { return 0; }
void SetGamma(float afGamma) {}
int GetHandle() { return (int)mvTextureHandles[0]; }
More information about the Scummvm-git-logs
mailing list