Skip to content

Commit

Permalink
STARK: Better check for texture and bitmap formats
Browse files Browse the repository at this point in the history
  • Loading branch information
ccawley2011 committed Feb 1, 2023
1 parent 818797f commit 962383e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 9 deletions.
4 changes: 1 addition & 3 deletions engines/stark/gfx/openglbitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void OpenGlBitmap::update(const Graphics::Surface *surface, const byte *palette)
_width = surface->w;
_height = surface->h;

if (surface->format.bytesPerPixel != 4) {
if (surface->format != Driver::getRGBAPixelFormat()) {
// Convert the surface to texture format
Graphics::Surface *convertedSurface = surface->convertTo(Driver::getRGBAPixelFormat(), palette);

Expand All @@ -69,8 +69,6 @@ void OpenGlBitmap::update(const Graphics::Surface *surface, const byte *palette)
convertedSurface->free();
delete convertedSurface;
} else {
assert(surface->format == Driver::getRGBAPixelFormat());

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->getPixels());
}
}
Expand Down
4 changes: 1 addition & 3 deletions engines/stark/gfx/opengltexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void OpenGlTexture::bind() const {
}

void OpenGlTexture::updateLevel(uint32 level, const Graphics::Surface *surface, const byte *palette) {
if (surface->format.bytesPerPixel != 4) {
if (surface->format != Driver::getRGBAPixelFormat()) {
// Convert the surface to texture format
Graphics::Surface *convertedSurface = surface->convertTo(Driver::getRGBAPixelFormat(), palette);

Expand All @@ -65,8 +65,6 @@ void OpenGlTexture::updateLevel(uint32 level, const Graphics::Surface *surface,
convertedSurface->free();
delete convertedSurface;
} else {
assert(surface->format == Driver::getRGBAPixelFormat());

glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, surface->w, surface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface->getPixels());
}
}
Expand Down
3 changes: 1 addition & 2 deletions engines/stark/gfx/tinyglbitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ void TinyGlBitmap::update(const Graphics::Surface *surface, const byte *palette)
_width = surface->w;
_height = surface->h;

if (surface->format.bytesPerPixel != 4) {
if (surface->format != Driver::getRGBAPixelFormat()) {
// Convert the surface to bitmap format
Graphics::Surface *convertedSurface = surface->convertTo(Driver::getRGBAPixelFormat(), palette);
tglUploadBlitImage(_blitImage, *convertedSurface, 0, false);
convertedSurface->free();
delete convertedSurface;
} else {
assert(surface->format == Driver::getRGBAPixelFormat());
// W/A for 1x1 size bitmap
// store pixel color used later fo creating scalled bitmap
if (_width == 1 && _height == 1) {
Expand Down
2 changes: 1 addition & 1 deletion engines/stark/gfx/tinygltexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void TinyGlTexture::bind() const {
}

void TinyGlTexture::updateLevel(uint32 level, const Graphics::Surface *surface, const byte *palette) {
if (surface->format.bytesPerPixel != 4) {
if (surface->format != Driver::getRGBAPixelFormat()) {
// Convert the surface to texture format
Graphics::Surface *convertedSurface = surface->convertTo(Driver::getRGBAPixelFormat(), palette);

Expand Down

0 comments on commit 962383e

Please sign in to comment.