X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions backends/graphics/android/android-graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,8 @@ void AndroidGraphicsManager::initSurface() {
// If not 16, this must be 24 or 32 bpp so make use of them
notifyContextCreate(OpenGL::kContextGLES2,
new OpenGL::Backbuffer(),
#ifdef SCUMM_BIG_ENDIAN
Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0),
Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)
#else
Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0),
Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24)
#endif
OpenGL::Texture::getRGBPixelFormat(),
OpenGL::Texture::getRGBAPixelFormat()
);
}

Expand Down
11 changes: 2 additions & 9 deletions backends/graphics/ios/ios-graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,8 @@ void iOSGraphicsManager::initSurface() {

notifyContextCreate(OpenGL::kContextGLES2,
new OpenGL::RenderbufferTarget(rbo),
// Currently iOS runs the ARMs in little-endian mode but prepare if
// that is changed in the future.
#ifdef SCUMM_LITTLE_ENDIAN
Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24),
Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
#else
Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0),
Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
#endif
OpenGL::Texture::getRGBAPixelFormat(),
OpenGL::Texture::getRGBAPixelFormat());
handleResize(sys->getScreenWidth(), sys->getScreenHeight());

_old_touch_mode = kTouchModeTouchpad;
Expand Down
43 changes: 10 additions & 33 deletions backends/graphics/opengl/opengl-graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,9 @@ Common::List<Graphics::PixelFormat> OpenGLGraphicsManager::getSupportedFormats()
// it is the only 32bit color mode we can safely assume to be present in
// OpenGL and OpenGL ES implementations. Thus, we need to supply different
// logical formats based on endianness.
#ifdef SCUMM_LITTLE_ENDIAN
// ABGR8888
formats.push_back(Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
#else
// RGBA8888
formats.push_back(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
#endif

// ABGR8888/RGBA8888
formats.push_back(OpenGL::Texture::getRGBAPixelFormat());
// RGB565
formats.push_back(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
// RGBA5551
Expand Down Expand Up @@ -1494,11 +1490,7 @@ Surface *OpenGLGraphicsManager::createSurface(const Graphics::PixelFormat &forma
if (getGLPixelFormat(format, glIntFormat, glFormat, glType)) {
return new ScaledTextureSurface(glIntFormat, glFormat, glType, format, format);
} else {
#ifdef SCUMM_LITTLE_ENDIAN
return new ScaledTextureSurface(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), format);
#else
return new ScaledTextureSurface(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0), format);
#endif
return new ScaledTextureSurface(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, OpenGL::Texture::getRGBAPixelFormat(), format);
}
}
#endif
Expand Down Expand Up @@ -1532,29 +1524,17 @@ Surface *OpenGLGraphicsManager::createSurface(const Graphics::PixelFormat &forma
#endif
return new TextureSurfaceRGBA8888Swap();
} else {
#ifdef SCUMM_LITTLE_ENDIAN
return new FakeTextureSurface(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), format);
#else
return new FakeTextureSurface(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0), format);
#endif
return new FakeTextureSurface(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, OpenGL::Texture::getRGBAPixelFormat(), format);
}
}

bool OpenGLGraphicsManager::getGLPixelFormat(const Graphics::PixelFormat &pixelFormat, GLenum &glIntFormat, GLenum &glFormat, GLenum &glType) const {
#ifdef SCUMM_LITTLE_ENDIAN
if (pixelFormat == Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24)) { // ABGR8888
#else
if (pixelFormat == Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)) { // RGBA8888
#endif
if (pixelFormat == OpenGL::Texture::getRGBAPixelFormat()) { // ABGR8888 / RGBA8888
glIntFormat = GL_RGBA;
glFormat = GL_RGBA;
glType = GL_UNSIGNED_BYTE;
return true;
#ifdef SCUMM_LITTLE_ENDIAN
} else if (pixelFormat == Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0)) { // BGR888
#else
} else if (pixelFormat == Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0)) { // RGB888
#endif
} else if (pixelFormat == OpenGL::Texture::getRGBPixelFormat()) { // BGR888 / RGB888
glIntFormat = GL_RGB;
glFormat = GL_RGB;
glType = GL_UNSIGNED_BYTE;
Expand Down Expand Up @@ -1803,15 +1783,12 @@ bool OpenGLGraphicsManager::saveScreenshot(const Common::Path &filename) const {
// The second is an implementation-chosen format. " and the implementation-chosen formats are buggy:
// https://github.com/KhronosGroup/WebGL/issues/2747
GL_CALL(glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, &pixels.front()));
const Graphics::PixelFormat format(4, 8, 8, 8, 8, 0, 8, 16, 24);

const Graphics::PixelFormat format(OpenGL::Texture::getRGBAPixelFormat());
#else
GL_CALL(glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, &pixels.front()));

#ifdef SCUMM_LITTLE_ENDIAN
const Graphics::PixelFormat format(3, 8, 8, 8, 0, 0, 8, 16, 0);
#else
const Graphics::PixelFormat format(3, 8, 8, 8, 0, 16, 8, 0, 0);
#endif
const Graphics::PixelFormat format(OpenGL::Texture::getRGBPixelFormat());
#endif
Graphics::Surface data;
data.init(width, height, lineSize, &pixels.front(), format);
Expand Down
9 changes: 2 additions & 7 deletions backends/graphics/opengl/pipelines/libretro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,8 @@ static Graphics::Surface *loadViaImageDecoder(const Common::Path &fileName, Comm

// Use a cast to resolve ambiguities in JPEGDecoder
const Graphics::Palette & palette = static_cast<Image::ImageDecoder &>(decoder).getPalette();
return decoder.getSurface()->convertTo(
#ifdef SCUMM_LITTLE_ENDIAN
Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24),
#else
Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0),
#endif
palette.data(), palette.size());
return decoder.getSurface()->convertTo(OpenGL::Texture::getRGBAPixelFormat(),
palette.data(), palette.size());
}

struct ImageLoader {
Expand Down
12 changes: 3 additions & 9 deletions backends/graphics/opengl/texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,9 @@ void TextureSurfaceRGB555::updateGLTexture() {

TextureSurfaceRGBA8888Swap::TextureSurfaceRGBA8888Swap()
#ifdef SCUMM_LITTLE_ENDIAN
: FakeTextureSurface(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)) // RGBA8888 -> ABGR8888
: FakeTextureSurface(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, OpenGL::Texture::getRGBAPixelFormat(), Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)) // RGBA8888 -> ABGR8888
#else
: FakeTextureSurface(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0), Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24)) // ABGR8888 -> RGBA8888
: FakeTextureSurface(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, OpenGL::Texture::getRGBAPixelFormat(), Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24)) // ABGR8888 -> RGBA8888
#endif
{
}
Expand Down Expand Up @@ -653,13 +653,7 @@ void TextureSurfaceCLUT8GPU::updateGLTexture() {
// Update palette if necessary.
if (_paletteDirty) {
Graphics::Surface palSurface;
palSurface.init(256, 1, 256, _palette,
#ifdef SCUMM_LITTLE_ENDIAN
Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24) // ABGR8888
#else
Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0) // RGBA8888
#endif
);
palSurface.init(256, 1, 256, _palette, OpenGL::Texture::getRGBAPixelFormat());

_paletteTexture.updateArea(Common::Rect(256, 1), palSurface);
_paletteDirty = false;
Expand Down
9 changes: 2 additions & 7 deletions backends/graphics/openglsdl/openglsdl-graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,12 +596,7 @@ bool OpenGLSdlGraphicsManager::setupMode(uint width, uint height) {
// whether we run on little endian or big endian. However, we can
// only safely assume that RGBA8888 in memory layout is supported.
// Thus, we chose this one.
const Graphics::PixelFormat rgba8888 =
#ifdef SCUMM_LITTLE_ENDIAN
Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
#else
Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
#endif
const Graphics::PixelFormat rgba8888 = OpenGL::Texture::getRGBAPixelFormat();

#if SDL_VERSION_ATLEAST(2, 0, 0)
if (_glContext) {
Expand Down Expand Up @@ -980,7 +975,7 @@ void *OpenGLSdlGraphicsManager::getImGuiTexture(const Graphics::Surface &image,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // Same

// Upload pixels into texture
Graphics::Surface *s = image.convertTo(Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0), palette, palCount);
Graphics::Surface *s = image.convertTo(OpenGL::Texture::getRGBPixelFormat(), palette, palCount);
glPixelStorei(GL_UNPACK_ALIGNMENT, s->format.bytesPerPixel);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, s->w, s->h, 0, GL_RGB, GL_UNSIGNED_BYTE, s->getPixels());
Expand Down
12 changes: 2 additions & 10 deletions backends/graphics3d/android/texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,7 @@ class GLES888Texture : public GLESTexture {
virtual ~GLES888Texture() {}

static Graphics::PixelFormat pixelFormat() {
#ifdef SCUMM_BIG_ENDIAN
return Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0);
#else
return Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0);
#endif
return OpenGL::Texture::getRGBPixelFormat();
}
};

Expand All @@ -300,11 +296,7 @@ class GLES8888Texture : public GLESTexture {
virtual ~GLES8888Texture() {}

static Graphics::PixelFormat pixelFormat() {
#ifdef SCUMM_BIG_ENDIAN
return Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
#else
return Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
#endif
return OpenGL::Texture::getRGBAPixelFormat();
}
};

Expand Down
10 changes: 3 additions & 7 deletions backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ bool OpenGLSdlGraphics3dManager::saveScreenshot(const Common::Path &filename) co
// The second is an implementation-chosen format. " and the implementation-chosen formats are buggy:
// https://github.com/KhronosGroup/WebGL/issues/2747
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, &pixels.front());
const Graphics::PixelFormat format(4, 8, 8, 8, 8, 0, 8, 16, 24);
const Graphics::PixelFormat format(OpenGL::Texture::getRGBAPixelFormat());
#else

if (_frameBuffer) {
Expand All @@ -899,11 +899,7 @@ bool OpenGLSdlGraphics3dManager::saveScreenshot(const Common::Path &filename) co
_frameBuffer->attach();
}

#ifdef SCUMM_LITTLE_ENDIAN
const Graphics::PixelFormat format(3, 8, 8, 8, 0, 0, 8, 16, 0);
#else
const Graphics::PixelFormat format(3, 8, 8, 8, 0, 16, 8, 0, 0);
#endif
const Graphics::PixelFormat format(OpenGL::Texture::getRGBPixelFormat());
#endif

Graphics::Surface data;
Expand All @@ -930,7 +926,7 @@ void *OpenGLSdlGraphics3dManager::getImGuiTexture(const Graphics::Surface &image
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // Same

// Upload pixels into texture
Graphics::Surface *s = image.convertTo(Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0));
Graphics::Surface *s = image.convertTo(OpenGL::Texture::getRGBPixelFormat());
glPixelStorei(GL_UNPACK_ALIGNMENT, s->format.bytesPerPixel);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, s->w, s->h, 0, GL_RGB, GL_UNSIGNED_BYTE, s->getPixels());
Expand Down
7 changes: 1 addition & 6 deletions backends/platform/libretro/src/libretro-graphics-opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,7 @@ void LibretroHWFramebuffer::activateInternal() {
}

void LibretroOpenGLGraphics::resetContext(OpenGL::ContextType contextType) {
const Graphics::PixelFormat rgba8888 =
#ifdef SCUMM_LITTLE_ENDIAN
Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
#else
Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
#endif
const Graphics::PixelFormat rgba8888 = OpenGL::Texture::getRGBAPixelFormat();
notifyContextDestroy();
notifyContextCreate(contextType, new LibretroHWFramebuffer(), rgba8888, rgba8888);

Expand Down
8 changes: 0 additions & 8 deletions graphics/opengl/texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,6 @@ void Texture::updateArea(const Common::Rect &area, const Graphics::Surface &src)
_glFormat, _glType, src.getBasePtr(0, area.top)));
}

const Graphics::PixelFormat Texture::getRGBAPixelFormat() {
#ifdef SCUMM_BIG_ENDIAN
return Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
#else
return Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
#endif
}

} // End of namespace OpenGL

#endif
Expand Down
16 changes: 15 additions & 1 deletion graphics/opengl/texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,21 @@ class Texture {
*/
GLuint getGLTexture() const { return _glTexture; }

static const Graphics::PixelFormat getRGBAPixelFormat();
static inline const Graphics::PixelFormat getRGBPixelFormat() {
#ifdef SCUMM_BIG_ENDIAN
return Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0);
#else
return Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0);
#endif
}

static inline const Graphics::PixelFormat getRGBAPixelFormat() {
#ifdef SCUMM_BIG_ENDIAN
return Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
#else
return Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
#endif
}

protected:
const GLenum _glIntFormat;
Expand Down
Loading
X Tutup