ALL: Remove USE_GLES2 define

Replace it with USE_FORCED_GLES2
This commit is contained in:
Le Philousophe 2022-01-04 22:32:08 +01:00 committed by Paweł Kołodziejski
parent 453f7cfffe
commit d9b4e457e8
15 changed files with 87 additions and 85 deletions

View File

@ -482,9 +482,9 @@ ifdef ENABLE_AGI
DIST_FILES_ENGINEDATA+=$(srcdir)/dists/pred.dic
endif
# Shaders: install if USE_OPENGL_SHADERS or USE_GLES2 defined
# Shaders: install if USE_OPENGL_SHADERS is defined
DIST_FILES_SHADERS=
ifneq ($(USE_OPENGL_SHADERS)$(USE_GLES2),)
ifneq ($(USE_OPENGL_SHADERS),)
ifdef ENABLE_GRIM
DIST_FILES_SHADERS+=$(wildcard $(srcdir)/engines/grim/shaders/*)
endif

View File

@ -23,45 +23,10 @@
#define BACKENDS_GRAPHICS_OPENGL_OPENGL_SYS_H
#include "common/scummsys.h"
#include "graphics/opengl/system_headers.h"
#include "backends/graphics/opengl/debug.h"
// On OS X we only support GL contexts. The reason is that Apple's GL interface
// uses "void *" for GLhandleARB which is not type compatible with GLint. This
// kills our aliasing trick for extension functions and thus would force us to
// supply two different Shader class implementations or introduce other
// wrappers. OS X only supports GL contexts right now anyway (at least
// according to SDL2 sources), thus it is not much of an issue.
#if defined(MACOSX) && (!defined(USE_GLES_MODE) || USE_GLES_MODE != 0)
//#warning "Only forced OpenGL mode is supported on Mac OS X. Overriding settings."
#undef USE_GLES_MODE
#define USE_GLES_MODE 0
#endif
// We allow to force GL or GLES modes on compile time.
// For this the USE_GLES_MODE define is used. The following values represent
// the given selection choices:
// 0 - Force OpenGL context
// 1 - Force OpenGL ES context
// 2 - Force OpenGL ES 2.0 context
#ifdef USE_GLES_MODE
#define USE_FORCED_GL (USE_GLES_MODE == 0)
#define USE_FORCED_GLES (USE_GLES_MODE == 1)
#define USE_FORCED_GLES2 (USE_GLES_MODE == 2)
#else
#define USE_FORCED_GL 0
#define USE_FORCED_GLES 0
#define USE_FORCED_GLES2 0
#endif
#ifdef __ANDROID__
#include <GLES/gl.h>
#include <GLES2/gl2.h>
#else
#include "graphics/opengl/glad.h"
#define USE_GLAD
#endif
// This is an addition from us to alias ARB shader object extensions to
// OpenGL (ES) 2.0 style functions. It only works when GLhandleARB and GLuint
// are type compatible.

View File

@ -28,8 +28,10 @@
#include "graphics/opengl/context.h"
#ifdef USE_GLES2
#if !defined(GL_DEPTH24_STENCIL8)
#define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
#endif
#if !defined(GL_DEPTH_COMPONENT24)
#define GL_DEPTH_COMPONENT24 GL_DEPTH_COMPONENT24_OES
#endif
@ -122,7 +124,7 @@ void FrameBuffer::detach() {
glViewport(_prevStateViewport[0], _prevStateViewport[1], _prevStateViewport[2], _prevStateViewport[3]);
}
#if !defined(USE_GLES2) && !defined(AMIGAOS) && !defined(__MORPHOS__)
#if !USE_FORCED_GLES2 && !defined(AMIGAOS) && !defined(__MORPHOS__)
MultiSampleFrameBuffer::MultiSampleFrameBuffer(uint width, uint height, int samples)
: FrameBuffer(width,height) {
if (!OpenGLContext.framebufferObjectMultisampleSupported) {
@ -184,7 +186,7 @@ void MultiSampleFrameBuffer::detach() {
glViewport(_prevStateViewport[0], _prevStateViewport[1], _prevStateViewport[2], _prevStateViewport[3]);
}
#endif // !defined(USE_GLES2) && !defined(AMIGAOS) && !defined(__MORPHOS__)
#endif // !USE_FORCED_GLES2 && !defined(AMIGAOS) && !defined(__MORPHOS__)
} // End of namespace OpenGL

View File

@ -56,7 +56,7 @@ private:
GLint _prevStateViewport[4];
};
#if !defined(USE_GLES2) && !defined(AMIGAOS) && !defined(__MORPHOS__)
#if !USE_FORCED_GLES2 && !defined(AMIGAOS) && !defined(__MORPHOS__)
class MultiSampleFrameBuffer : public FrameBuffer {
public:
MultiSampleFrameBuffer(uint width, uint height, int samples);

View File

@ -83,7 +83,7 @@ OpenGLSdlGraphics3dManager::OpenGLSdlGraphics3dManager(SdlEventSource *eventSour
DEFAULT_GLES2_MINOR = 0
};
#ifdef USE_GLES2
#if USE_FORCED_GLES2
_glContextType = OpenGL::kOGLContextGLES2;
_glContextProfileMask = SDL_GL_CONTEXT_PROFILE_ES;
_glContextMajor = DEFAULT_GLES2_MAJOR;
@ -581,7 +581,7 @@ void OpenGLSdlGraphics3dManager::drawOverlay() {
#if !defined(__amigaos4__) && !defined(__MORPHOS__)
OpenGL::FrameBuffer *OpenGLSdlGraphics3dManager::createFramebuffer(uint width, uint height) {
#if !defined(USE_GLES2)
#if !USE_FORCED_GLES2
if (_antialiasing && OpenGLContext.framebufferObjectMultisampleSupported) {
return new OpenGL::MultiSampleFrameBuffer(width, height, _antialiasing);
} else

View File

@ -464,7 +464,7 @@ void AndroidGraphicsManager::initSizeIntern(uint width, uint height,
#else
_game_texture->allocBuffer(width, height);
#endif
#ifdef USE_GLES2
#if USE_FORCED_GLES2
_frame_buffer = new OpenGL::FrameBuffer(_game_texture->getTextureName(), _game_texture->width(), _game_texture->height(), _game_texture->texWidth(), _game_texture->texHeight());
_frame_buffer->attach();
#endif

View File

@ -50,7 +50,7 @@
#include "backends/graphics/openglsdl/openglsdl-graphics.h"
#include "graphics/cursorman.h"
#endif
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS) || defined(USE_GLES2)
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
#include "backends/graphics3d/openglsdl/openglsdl-graphics3d.h"
#include "graphics/opengl/context.h"
#endif
@ -208,7 +208,7 @@ void OSystem_SDL::initBackend() {
#endif
debug(1, "Using SDL Video Driver \"%s\"", sdlDriverName);
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS) || defined(USE_GLES2)
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
detectFramebufferSupport();
detectAntiAliasingSupport();
#endif
@ -305,10 +305,10 @@ void OSystem_SDL::initBackend() {
dynamic_cast<SdlGraphicsManager *>(_graphicsManager)->activateManager();
}
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS) || defined(USE_GLES2)
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
void OSystem_SDL::detectFramebufferSupport() {
_supportsFrameBuffer = false;
#if defined(USE_GLES2)
#if USE_FORCED_GLES2
// Framebuffers are always available with GLES2
_supportsFrameBuffer = true;
#elif !defined(AMIGAOS) && !defined(__MORPHOS__)
@ -476,7 +476,7 @@ void OSystem_SDL::setWindowCaption(const Common::U32String &caption) {
_window->setWindowCaption(cap);
}
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS) || defined(USE_GLES2)
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
Common::Array<uint> OSystem_SDL::getSupportedAntiAliasingLevels() const {
return _antiAliasLevels;
}
@ -772,7 +772,7 @@ bool OSystem_SDL::setGraphicsMode(int mode, uint flags) {
// If the new mode and the current mode are not from the same graphics
// manager, delete and create the new mode graphics manager
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS) || defined(USE_GLES2)
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
if (render3d && !supports3D) {
debug(1, "switching to OpenGL 3D graphics");
sdlGraphicsManager->deactivateManager();

View File

@ -93,7 +93,7 @@ public:
//Screenshots
virtual Common::String getScreenshotsPath();
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS) || defined(USE_GLES2)
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
Common::Array<uint> getSupportedAntiAliasingLevels() const override;
#endif
@ -131,7 +131,7 @@ protected:
SdlGraphicsManager::State _gfxManagerState;
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS) || defined(USE_GLES2)
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
// Graphics capabilities
void detectFramebufferSupport();
void detectAntiAliasingSupport();

View File

@ -199,7 +199,13 @@ const char gScummVMFeatures[] = ""
"(with shaders) "
#endif
#endif
#ifdef USE_GLES2
"OpenGL ES 2 "
#ifdef USE_GLES_MODE
#if USE_GLES_MODE == 0
"OpenGL desktop only "
#elif USE_GLES_MODE == 1
"OpenGL ES 1 only "
#elif USE_GLES_MODE == 2
"OpenGL ES 2 only "
#endif
#endif
;

1
configure vendored
View File

@ -5530,7 +5530,6 @@ fi
define_in_config_if_yes "$_opengl" "USE_OPENGL"
define_in_config_if_yes "$_opengl_game_classic" "USE_OPENGL_GAME"
define_in_config_if_yes "$_opengl_game_shaders" "USE_OPENGL_SHADERS"
define_in_config_if_yes "$_opengl_game_es2" "USE_GLES2"
if test "$_dynamic_modules" = yes ; then
case $_host_os in

View File

@ -114,7 +114,7 @@ xeen.ccs FILE "dists/engine-data/xeen.ccs"
#if PLUGIN_ENABLED_STATIC(AGI)
pred.dic FILE "dists/pred.dic"
#endif
#if defined(USE_OPENGL_SHADERS) || defined(USE_GLES2)
#if defined(USE_OPENGL_SHADERS)
#if PLUGIN_ENABLED_STATIC(GRIM)
shaders/grim_dim.fragment FILE "engines/grim/shaders/grim_dim.fragment"
shaders/grim_dim.vertex FILE "engines/grim/shaders/grim_dim.vertex"

View File

@ -2178,7 +2178,7 @@ Bitmap *GfxOpenGLS::getScreenshot(int w, int h, bool useStored) {
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glDeleteFramebuffers(1, &frameBuffer);
#ifndef USE_GLES2
#if !USE_FORCED_GLES2
} else {
glBindTexture(GL_TEXTURE_2D, _storedDisplay);
char *buffer = new char[_screenWidth * _screenHeight * 4];

View File

@ -102,7 +102,7 @@ void OpenGlTexture::setLevelCount(uint32 count) {
_levelCount = count;
if (count >= 1) {
#if !defined(USE_GLES2)
#if !USE_FORCED_GLES2
// GLES2 does not allow setting the max provided mipmap level.
// It expects all the levels to be provided, which is not the case in TLJ.
// FIXME: Enable mipmapping on GLES2

View File

@ -24,35 +24,65 @@
#include "common/scummsys.h"
#ifdef USE_GLES2
// On OS X we only support GL contexts. The reason is that Apple's GL interface
// uses "void *" for GLhandleARB which is not type compatible with GLint. This
// kills our aliasing trick for extension functions and thus would force us to
// supply two different Shader class implementations or introduce other
// wrappers. OS X only supports GL contexts right now anyway (at least
// according to SDL2 sources), thus it is not much of an issue.
#if defined(MACOSX) && (!defined(USE_GLES_MODE) || USE_GLES_MODE != 0)
//#warning "Only forced OpenGL mode is supported on Mac OS X. Overriding settings."
#undef USE_GLES_MODE
#define USE_GLES_MODE 0
#endif
#define GL_GLEXT_PROTOTYPES
#ifdef IPHONE
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
// We allow to force GL or GLES modes on compile time.
// For this the USE_GLES_MODE define is used. The following values represent
// the given selection choices:
// 0 - Force OpenGL context
// 1 - Force OpenGL ES context
// 2 - Force OpenGL ES 2.0 context
#ifdef USE_GLES_MODE
#define USE_FORCED_GL (USE_GLES_MODE == 0)
#define USE_FORCED_GLES (USE_GLES_MODE == 1)
#define USE_FORCED_GLES2 (USE_GLES_MODE == 2)
#else
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#endif
#undef GL_GLEXT_PROTOTYPES
#ifndef GL_BGRA
# define GL_BGRA GL_BGRA_EXT
#define USE_FORCED_GL 0
#define USE_FORCED_GLES 0
#define USE_FORCED_GLES2 0
#endif
#if !defined(GL_UNPACK_ROW_LENGTH)
// The Android SDK does not declare GL_UNPACK_ROW_LENGTH_EXT
#define GL_UNPACK_ROW_LENGTH 0x0CF2
#endif
#if USE_FORCED_GLES2
#if !defined(GL_MAX_SAMPLES)
// The Android SDK and SDL1 don't declare GL_MAX_SAMPLES
#define GL_MAX_SAMPLES 0x8D57
#endif
#define GL_GLEXT_PROTOTYPES
#if defined(IPHONE)
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
#else
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#endif
#undef GL_GLEXT_PROTOTYPES
#ifndef GL_BGRA
#define GL_BGRA GL_BGRA_EXT
#endif
#if !defined(GL_UNPACK_ROW_LENGTH)
// The Android SDK does not declare GL_UNPACK_ROW_LENGTH_EXT
#define GL_UNPACK_ROW_LENGTH 0x0CF2
#endif
#if !defined(GL_MAX_SAMPLES)
// The Android SDK and SDL1 don't declare GL_MAX_SAMPLES
#define GL_MAX_SAMPLES 0x8D57
#endif
#else
#define USE_GLAD
#include "graphics/opengl/glad.h"
#define USE_GLAD
#include "graphics/opengl/glad.h"
#endif
#endif

View File

@ -29,7 +29,7 @@ static const RendererTypeDescription rendererTypes[] = {
#if defined(USE_OPENGL_GAME)
{ "opengl", _s("OpenGL"), kRendererTypeOpenGL },
#endif
#if defined(USE_OPENGL_SHADERS) || defined(USE_GLES2)
#if defined(USE_OPENGL_SHADERS)
{ "opengl_shaders", _s("OpenGL with shaders"), kRendererTypeOpenGLShaders },
#endif
#ifdef USE_TINYGL
@ -73,19 +73,19 @@ RendererType getBestMatchingAvailableRendererType(RendererType desired) {
desired = kRendererTypeOpenGLShaders;
}
#if !defined(USE_OPENGL_SHADERS) && !defined(USE_GLES2)
#if !defined(USE_OPENGL_SHADERS)
if (desired == kRendererTypeOpenGLShaders) {
desired = kRendererTypeOpenGL;
}
#endif
#if (!defined(USE_OPENGL_GAME) && defined(USE_OPENGL_SHADERS)) || defined(USE_GLES2)
#if (!defined(USE_OPENGL_GAME) && defined(USE_OPENGL_SHADERS))
if (desired == kRendererTypeOpenGL) {
desired = kRendererTypeOpenGLShaders;
}
#endif
#if !defined(USE_OPENGL_GAME) && !defined(USE_GLES2) && !defined(USE_OPENGL_SHADERS)
#if !defined(USE_OPENGL_GAME) && !defined(USE_OPENGL_SHADERS)
if (desired == kRendererTypeOpenGL || desired == kRendererTypeOpenGLShaders) {
desired = kRendererTypeTinyGL;
}