OpenGL: Attempt to fix some build configurations (fixes #1839)

This commit is contained in:
Vicki Pfau 2020-08-04 18:01:35 -07:00
parent 453791d289
commit d68bf5bd1a
11 changed files with 72 additions and 50 deletions

View File

@ -70,7 +70,7 @@ if(NOT LIBMGBA_ONLY)
set(SKIP_LIBRARY OFF CACHE BOOL "Skip building the library (useful for only building libretro or OpenEmu cores)") set(SKIP_LIBRARY OFF CACHE BOOL "Skip building the library (useful for only building libretro or OpenEmu cores)")
set(BUILD_GL ON CACHE BOOL "Build with OpenGL") set(BUILD_GL ON CACHE BOOL "Build with OpenGL")
set(BUILD_GLES2 ON CACHE BOOL "Build with OpenGL|ES 2") set(BUILD_GLES2 ON CACHE BOOL "Build with OpenGL|ES 2")
set(BUILD_GLES3 OFF CACHE BOOL "Build with OpenGL|ES 3") set(BUILD_GLES3 ON CACHE BOOL "Build with OpenGL|ES 3")
set(USE_EPOXY ON CACHE STRING "Build with libepoxy") set(USE_EPOXY ON CACHE STRING "Build with libepoxy")
set(DISABLE_DEPS OFF CACHE BOOL "Build without dependencies") set(DISABLE_DEPS OFF CACHE BOOL "Build without dependencies")
set(DISTBUILD OFF CACHE BOOL "Build distribution packages") set(DISTBUILD OFF CACHE BOOL "Build distribution packages")
@ -427,6 +427,7 @@ if(CMAKE_SYSTEM_NAME MATCHES ".*BSD|DragonFly")
else() else()
find_feature(USE_EDITLINE "libedit") find_feature(USE_EDITLINE "libedit")
endif() endif()
if(BUILD_GL) if(BUILD_GL)
find_package(OpenGL QUIET) find_package(OpenGL QUIET)
if(NOT OPENGL_FOUND) if(NOT OPENGL_FOUND)
@ -436,18 +437,26 @@ endif()
if(NOT BUILD_GL) if(NOT BUILD_GL)
set(OPENGL_LIBRARY "" CACHE PATH "" FORCE) set(OPENGL_LIBRARY "" CACHE PATH "" FORCE)
endif() endif()
if(BUILD_GLES2 AND NOT BUILD_RASPI AND NOT CMAKE_SYSTEM_NAME MATCHES "^(Windows|Darwin|Linux|.*BSD|DragonFly|Haiku)$")
if(BUILD_GLES2 AND NOT BUILD_RASPI)
find_path(OPENGLES2_INCLUDE_DIR NAMES GLES2/gl2.h) find_path(OPENGLES2_INCLUDE_DIR NAMES GLES2/gl2.h)
find_library(OPENGLES2_LIBRARY NAMES GLESv2 GLESv2_CM) find_library(OPENGLES2_LIBRARY NAMES GLESv2 GLESv2_CM)
if(NOT OPENGLES2_INCLUDE_DIR OR NOT OPENGLES2_LIBRARY) if(NOT OPENGLES2_INCLUDE_DIR OR NOT OPENGLES2_LIBRARY)
set(BUILD_GLES2 OFF CACHE BOOL "OpenGL|ES 2 not found" FORCE) set(BUILD_GLES2 OFF CACHE BOOL "OpenGL|ES 2 not found" FORCE)
endif() endif()
endif() endif()
if(NOT BUILD_GLES2) if(BUILD_GLES3)
set(OPENGLES2_LIBRARY "" CACHE PATH "" FORCE) find_path(OPENGLES3_INCLUDE_DIR NAMES GLES3/gl3.h)
find_library(OPENGLES3_LIBRARY NAMES GLESv3 GLESv2)
if(NOT OPENGLES3_INCLUDE_DIR OR NOT OPENGLES3_LIBRARY)
set(BUILD_GLES3 OFF CACHE BOOL "OpenGL|ES 3 not found" FORCE)
endif()
endif() endif()
if(BUILD_GL) if(BUILD_GL)
list(APPEND OS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gl.c) list(APPEND OS_SRC
${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gl.c
${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gles2.c)
list(APPEND DEPENDENCY_LIB ${OPENGL_LIBRARY}) list(APPEND DEPENDENCY_LIB ${OPENGL_LIBRARY})
include_directories(${OPENGL_INCLUDE_DIR}) include_directories(${OPENGL_INCLUDE_DIR})
endif() endif()
@ -457,11 +466,9 @@ if(BUILD_GLES2)
include_directories(${OPENGLES2_INCLUDE_DIR}) include_directories(${OPENGLES2_INCLUDE_DIR})
endif() endif()
if(BUILD_GLES3) if(BUILD_GLES3)
find_path(OPENGLES3_INCLUDE_DIR NAMES GLES3/gl3.h) list(APPEND OS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gles2.c)
find_library(OPENGLES3_LIBRARY NAMES GLESv3 GLESv2) list(APPEND DEPENDENCY_LIB ${OPENGLES3_LIBRARY})
if(NOT OPENGLES3_INCLUDE_DIR OR NOT OPENGLES3_LIBRARY) include_directories(${OPENGLES3_INCLUDE_DIR})
set(BUILD_GLES3 OFF CACHE BOOL "OpenGL|ES 3 not found" FORCE)
endif()
endif() endif()
if(DISABLE_DEPS) if(DISABLE_DEPS)
@ -700,7 +707,7 @@ endif()
if(USE_EPOXY) if(USE_EPOXY)
list(APPEND OS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gl.c ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gles2.c) list(APPEND OS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gl.c ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gles2.c)
add_definitions(-DBUILD_GL -DBUILD_GLES2) add_definitions(-DBUILD_GL -DBUILD_GLES2 -DBUILD_GLES3)
list(APPEND FEATURES EPOXY) list(APPEND FEATURES EPOXY)
include_directories(AFTER ${EPOXY_INCLUDE_DIRS}) include_directories(AFTER ${EPOXY_INCLUDE_DIRS})
link_directories(${EPOXY_LIBRARY_DIRS}) link_directories(${EPOXY_LIBRARY_DIRS})
@ -897,7 +904,7 @@ else()
endif() endif()
if(BUILD_GL) if(BUILD_GL)
add_definitions(-DBUILD_GL) add_definitions(-DBUILD_GL -DBUILD_GLES2 -DBUILD_GLES3)
endif() endif()
if(BUILD_GLES2) if(BUILD_GLES2)

View File

@ -16,7 +16,7 @@ CXX_GUARD_START
#include <mgba/internal/gba/renderers/common.h> #include <mgba/internal/gba/renderers/common.h>
#include <mgba/internal/gba/video.h> #include <mgba/internal/gba/video.h>
#if defined(BUILD_GLES2) || defined(BUILD_GLES3) #ifdef BUILD_GLES3
#ifdef USE_EPOXY #ifdef USE_EPOXY
#include <epoxy/gl.h> #include <epoxy/gl.h>

View File

@ -18,7 +18,7 @@
#ifndef DISABLE_THREADING #ifndef DISABLE_THREADING
#include <mgba/feature/thread-proxy.h> #include <mgba/feature/thread-proxy.h>
#endif #endif
#if defined(BUILD_GLES2) || defined(BUILD_GLES3) #ifdef BUILD_GLES3
#include <mgba/internal/gba/renderers/gl.h> #include <mgba/internal/gba/renderers/gl.h>
#endif #endif
#include <mgba/internal/gba/renderers/proxy.h> #include <mgba/internal/gba/renderers/proxy.h>
@ -131,7 +131,7 @@ struct GBACore {
struct mCore d; struct mCore d;
struct GBAVideoRenderer dummyRenderer; struct GBAVideoRenderer dummyRenderer;
struct GBAVideoSoftwareRenderer renderer; struct GBAVideoSoftwareRenderer renderer;
#if defined(BUILD_GLES2) || defined(BUILD_GLES3) #ifdef BUILD_GLES3
struct GBAVideoGLRenderer glRenderer; struct GBAVideoGLRenderer glRenderer;
#endif #endif
#ifndef MINIMAL_CORE #ifndef MINIMAL_CORE
@ -189,7 +189,7 @@ static bool _GBACoreInit(struct mCore* core) {
GBAVideoSoftwareRendererCreate(&gbacore->renderer); GBAVideoSoftwareRendererCreate(&gbacore->renderer);
gbacore->renderer.outputBuffer = NULL; gbacore->renderer.outputBuffer = NULL;
#if defined(BUILD_GLES2) || defined(BUILD_GLES3) #ifdef BUILD_GLES3
GBAVideoGLRendererCreate(&gbacore->glRenderer); GBAVideoGLRendererCreate(&gbacore->glRenderer);
gbacore->glRenderer.outputTex = -1; gbacore->glRenderer.outputTex = -1;
#endif #endif
@ -241,7 +241,7 @@ static bool _GBACoreSupportsFeature(const struct mCore* core, enum mCoreFeature
UNUSED(core); UNUSED(core);
switch (feature) { switch (feature) {
case mCORE_FEATURE_OPENGL: case mCORE_FEATURE_OPENGL:
#if defined(BUILD_GLES2) || defined(BUILD_GLES3) #ifdef BUILD_GLES3
return true; return true;
#else #else
return false; return false;
@ -353,7 +353,7 @@ static void _GBACoreReloadConfigOption(struct mCore* core, const char* option, c
} }
struct GBACore* gbacore = (struct GBACore*) core; struct GBACore* gbacore = (struct GBACore*) core;
#if defined(BUILD_GLES2) || defined(BUILD_GLES3) #ifdef BUILD_GLES3
if (strcmp("videoScale", option) == 0) { if (strcmp("videoScale", option) == 0) {
if (config != &core->config) { if (config != &core->config) {
mCoreConfigCopyValue(&core->config, config, "videoScale"); mCoreConfigCopyValue(&core->config, config, "videoScale");
@ -371,7 +371,7 @@ static void _GBACoreReloadConfigOption(struct mCore* core, const char* option, c
if (gbacore->renderer.outputBuffer) { if (gbacore->renderer.outputBuffer) {
renderer = &gbacore->renderer.d; renderer = &gbacore->renderer.d;
} }
#if defined(BUILD_GLES2) || defined(BUILD_GLES3) #ifdef BUILD_GLES3
if (gbacore->glRenderer.outputTex != (unsigned) -1 && mCoreConfigGetIntValue(&core->config, "hwaccelVideo", &fakeBool) && fakeBool) { if (gbacore->glRenderer.outputTex != (unsigned) -1 && mCoreConfigGetIntValue(&core->config, "hwaccelVideo", &fakeBool) && fakeBool) {
mCoreConfigGetIntValue(&core->config, "videoScale", &gbacore->glRenderer.scale); mCoreConfigGetIntValue(&core->config, "videoScale", &gbacore->glRenderer.scale);
renderer = &gbacore->glRenderer.d; renderer = &gbacore->glRenderer.d;
@ -393,7 +393,7 @@ static void _GBACoreReloadConfigOption(struct mCore* core, const char* option, c
} }
static void _GBACoreDesiredVideoDimensions(const struct mCore* core, unsigned* width, unsigned* height) { static void _GBACoreDesiredVideoDimensions(const struct mCore* core, unsigned* width, unsigned* height) {
#if defined(BUILD_GLES2) || defined(BUILD_GLES3) #ifdef BUILD_GLES3
const struct GBACore* gbacore = (const struct GBACore*) core; const struct GBACore* gbacore = (const struct GBACore*) core;
int scale = gbacore->glRenderer.scale; int scale = gbacore->glRenderer.scale;
#else #else
@ -413,7 +413,7 @@ static void _GBACoreSetVideoBuffer(struct mCore* core, color_t* buffer, size_t s
} }
static void _GBACoreSetVideoGLTex(struct mCore* core, unsigned texid) { static void _GBACoreSetVideoGLTex(struct mCore* core, unsigned texid) {
#if defined(BUILD_GLES2) || defined(BUILD_GLES3) #ifdef BUILD_GLES3
struct GBACore* gbacore = (struct GBACore*) core; struct GBACore* gbacore = (struct GBACore*) core;
gbacore->glRenderer.outputTex = texid; gbacore->glRenderer.outputTex = texid;
#else #else
@ -547,7 +547,7 @@ static void _GBACoreReset(struct mCore* core) {
struct GBACore* gbacore = (struct GBACore*) core; struct GBACore* gbacore = (struct GBACore*) core;
struct GBA* gba = (struct GBA*) core->board; struct GBA* gba = (struct GBA*) core->board;
if (gbacore->renderer.outputBuffer if (gbacore->renderer.outputBuffer
#if defined(BUILD_GLES2) || defined(BUILD_GLES3) #ifdef BUILD_GLES3
|| gbacore->glRenderer.outputTex != (unsigned) -1 || gbacore->glRenderer.outputTex != (unsigned) -1
#endif #endif
) { ) {
@ -556,7 +556,7 @@ static void _GBACoreReset(struct mCore* core) {
renderer = &gbacore->renderer.d; renderer = &gbacore->renderer.d;
} }
int fakeBool ATTRIBUTE_UNUSED; int fakeBool ATTRIBUTE_UNUSED;
#if defined(BUILD_GLES2) || defined(BUILD_GLES3) #ifdef BUILD_GLES3
if (gbacore->glRenderer.outputTex != (unsigned) -1 && mCoreConfigGetIntValue(&core->config, "hwaccelVideo", &fakeBool) && fakeBool) { if (gbacore->glRenderer.outputTex != (unsigned) -1 && mCoreConfigGetIntValue(&core->config, "hwaccelVideo", &fakeBool) && fakeBool) {
mCoreConfigGetIntValue(&core->config, "videoScale", &gbacore->glRenderer.scale); mCoreConfigGetIntValue(&core->config, "videoScale", &gbacore->glRenderer.scale);
renderer = &gbacore->glRenderer.d; renderer = &gbacore->glRenderer.d;

View File

@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <mgba/internal/gba/renderers/gl.h> #include <mgba/internal/gba/renderers/gl.h>
#if defined(BUILD_GLES2) || defined(BUILD_GLES3) #ifdef BUILD_GLES3
#include <mgba/core/cache-set.h> #include <mgba/core/cache-set.h>
#include <mgba/internal/arm/macros.h> #include <mgba/internal/arm/macros.h>

View File

@ -159,6 +159,7 @@ static void mGLES2ContextInit(struct VideoBackend* v, WHandle handle) {
mGLES2ShaderInit(&context->finalShader, 0, 0, 0, 0, false, 0, 0); mGLES2ShaderInit(&context->finalShader, 0, 0, 0, 0, false, 0, 0);
mGLES2ShaderInit(&context->interframeShader, 0, _interframeFragmentShader, -1, -1, false, 0, 0); mGLES2ShaderInit(&context->interframeShader, 0, _interframeFragmentShader, -1, -1, false, 0, 0);
#ifdef BUILD_GLES3
if (context->initialShader.vao != (GLuint) -1) { if (context->initialShader.vao != (GLuint) -1) {
glBindVertexArray(context->initialShader.vao); glBindVertexArray(context->initialShader.vao);
glBindBuffer(GL_ARRAY_BUFFER, context->vbo); glBindBuffer(GL_ARRAY_BUFFER, context->vbo);
@ -168,6 +169,7 @@ static void mGLES2ContextInit(struct VideoBackend* v, WHandle handle) {
glBindBuffer(GL_ARRAY_BUFFER, context->vbo); glBindBuffer(GL_ARRAY_BUFFER, context->vbo);
glBindVertexArray(0); glBindVertexArray(0);
} }
#endif
glDeleteFramebuffers(1, &context->finalShader.fbo); glDeleteFramebuffers(1, &context->finalShader.fbo);
glDeleteTextures(1, &context->finalShader.tex); glDeleteTextures(1, &context->finalShader.tex);
@ -305,9 +307,12 @@ void _drawShader(struct mGLES2Context* context, struct mGLES2Shader* shader) {
glUseProgram(shader->program); glUseProgram(shader->program);
glUniform1i(shader->texLocation, 0); glUniform1i(shader->texLocation, 0);
glUniform2f(shader->texSizeLocation, context->d.width - padW, context->d.height - padH); glUniform2f(shader->texSizeLocation, context->d.width - padW, context->d.height - padH);
#ifdef BUILD_GLES3
if (shader->vao != (GLuint) -1) { if (shader->vao != (GLuint) -1) {
glBindVertexArray(shader->vao); glBindVertexArray(shader->vao);
} else { } else
#endif
{
glBindBuffer(GL_ARRAY_BUFFER, context->vbo); glBindBuffer(GL_ARRAY_BUFFER, context->vbo);
glEnableVertexAttribArray(shader->positionLocation); glEnableVertexAttribArray(shader->positionLocation);
glVertexAttribPointer(shader->positionLocation, 2, GL_FLOAT, GL_FALSE, 0, NULL); glVertexAttribPointer(shader->positionLocation, 2, GL_FLOAT, GL_FALSE, 0, NULL);
@ -399,9 +404,11 @@ void mGLES2ContextDrawFrame(struct VideoBackend* v) {
} }
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
glUseProgram(0); glUseProgram(0);
#ifdef BUILD_GLES3
if (context->finalShader.vao != (GLuint) -1) { if (context->finalShader.vao != (GLuint) -1) {
glBindVertexArray(0); glBindVertexArray(0);
} }
#endif
} }
void mGLES2ContextPostFrame(struct VideoBackend* v, const void* frame) { void mGLES2ContextPostFrame(struct VideoBackend* v, const void* frame) {
@ -516,6 +523,7 @@ void mGLES2ShaderInit(struct mGLES2Shader* shader, const char* vs, const char* f
shader->uniforms[i].location = glGetUniformLocation(shader->program, shader->uniforms[i].name); shader->uniforms[i].location = glGetUniformLocation(shader->program, shader->uniforms[i].name);
} }
#ifdef BUILD_GLES3
const GLubyte* extensions = glGetString(GL_EXTENSIONS); const GLubyte* extensions = glGetString(GL_EXTENSIONS);
if (shaderBuffer[0] == _gles2Header || version[0] >= '3' || (extensions && strstr((const char*) extensions, "_vertex_array_object") != NULL)) { if (shaderBuffer[0] == _gles2Header || version[0] >= '3' || (extensions && strstr((const char*) extensions, "_vertex_array_object") != NULL)) {
glGenVertexArrays(1, &shader->vao); glGenVertexArrays(1, &shader->vao);
@ -523,7 +531,9 @@ void mGLES2ShaderInit(struct mGLES2Shader* shader, const char* vs, const char* f
glEnableVertexAttribArray(shader->positionLocation); glEnableVertexAttribArray(shader->positionLocation);
glVertexAttribPointer(shader->positionLocation, 2, GL_FLOAT, GL_FALSE, 0, NULL); glVertexAttribPointer(shader->positionLocation, 2, GL_FLOAT, GL_FALSE, 0, NULL);
glBindVertexArray(0); glBindVertexArray(0);
} else { } else
#endif
{
shader->vao = -1; shader->vao = -1;
} }
@ -535,9 +545,11 @@ void mGLES2ShaderDeinit(struct mGLES2Shader* shader) {
glDeleteShader(shader->fragmentShader); glDeleteShader(shader->fragmentShader);
glDeleteProgram(shader->program); glDeleteProgram(shader->program);
glDeleteFramebuffers(1, &shader->fbo); glDeleteFramebuffers(1, &shader->fbo);
#ifdef BUILD_GLES3
if (shader->vao != (GLuint) -1) { if (shader->vao != (GLuint) -1) {
glDeleteVertexArrays(1, &shader->vao); glDeleteVertexArrays(1, &shader->vao);
} }
#endif
} }
void mGLES2ShaderAttach(struct mGLES2Context* context, struct mGLES2Shader* shaders, size_t nShaders) { void mGLES2ShaderAttach(struct mGLES2Context* context, struct mGLES2Shader* shaders, size_t nShaders) {
@ -555,16 +567,20 @@ void mGLES2ShaderAttach(struct mGLES2Context* context, struct mGLES2Shader* shad
glClearColor(0.f, 0.f, 0.f, 1.f); glClearColor(0.f, 0.f, 0.f, 1.f);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
#ifdef BUILD_GLES3
if (context->shaders[i].vao != (GLuint) -1) { if (context->shaders[i].vao != (GLuint) -1) {
glBindVertexArray(context->shaders[i].vao); glBindVertexArray(context->shaders[i].vao);
glBindBuffer(GL_ARRAY_BUFFER, context->vbo); glBindBuffer(GL_ARRAY_BUFFER, context->vbo);
glEnableVertexAttribArray(context->shaders[i].positionLocation); glEnableVertexAttribArray(context->shaders[i].positionLocation);
glVertexAttribPointer(context->shaders[i].positionLocation, 2, GL_FLOAT, GL_FALSE, 0, NULL); glVertexAttribPointer(context->shaders[i].positionLocation, 2, GL_FLOAT, GL_FALSE, 0, NULL);
} }
#endif
} }
#ifdef BUILD_GLES3
if (context->initialShader.vao != (GLuint) -1) { if (context->initialShader.vao != (GLuint) -1) {
glBindVertexArray(0); glBindVertexArray(0);
} }
#endif
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
} }

View File

@ -22,6 +22,9 @@ CXX_GUARD_START
#endif #endif
#else #else
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#ifdef BUILD_GLES3
#include <GLES3/gl3.h>
#endif
#endif #endif
#include "platform/video-backend.h" #include "platform/video-backend.h"

View File

@ -24,7 +24,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(Qt5 COMPONENTS Core Widgets OpenGL Network Multimedia) find_package(Qt5 COMPONENTS Core Widgets OpenGL Network Multimedia)
if(NOT BUILD_GL AND NOT BUILD_GLES2) if(NOT BUILD_GL AND NOT BUILD_GLES2 AND NOT BUILD_GLES3)
message(WARNING "OpenGL is recommended to build the Qt port") message(WARNING "OpenGL is recommended to build the Qt port")
endif() endif()
@ -241,7 +241,7 @@ if(NOT DEFINED DATADIR)
set(DATADIR ${CMAKE_INSTALL_DATADIR}/${BINARY_NAME}) set(DATADIR ${CMAKE_INSTALL_DATADIR}/${BINARY_NAME})
endif() endif()
endif() endif()
if(BUILD_GL OR BUILD_GLES2 OR BUILD_EPOXY) if(BUILD_GLES2 OR BUILD_GLES3 OR BUILD_EPOXY)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/res/shaders DESTINATION ${DATADIR} COMPONENT ${BINARY_NAME}-qt) install(DIRECTORY ${CMAKE_SOURCE_DIR}/res/shaders DESTINATION ${DATADIR} COMPONENT ${BINARY_NAME}-qt)
endif() endif()
install(FILES ${CMAKE_SOURCE_DIR}/res/nointro.dat DESTINATION ${DATADIR} COMPONENT ${BINARY_NAME}-qt) install(FILES ${CMAKE_SOURCE_DIR}/res/nointro.dat DESTINATION ${DATADIR} COMPONENT ${BINARY_NAME}-qt)
@ -291,8 +291,8 @@ if(WIN32)
endif() endif()
list(APPEND QT_LIBRARIES Qt5::Widgets Qt5::Network) list(APPEND QT_LIBRARIES Qt5::Widgets Qt5::Network)
if(BUILD_GL OR BUILD_GLES2 OR BUILD_EPOXY) if(BUILD_GL OR BUILD_GLES2 OR BUILD_GLES3 OR BUILD_EPOXY)
list(APPEND QT_LIBRARIES Qt5::OpenGL ${OPENGL_LIBRARY} ${OPENGLES2_LIBRARY}) list(APPEND QT_LIBRARIES Qt5::OpenGL ${OPENGL_LIBRARY} ${OPENGLES2_LIBRARY} ${OPENGLES3_LIBRARY})
endif() endif()
if(QT_STATIC) if(QT_STATIC)
find_library(QTPCRE NAMES qtpcre2 qtpcre) find_library(QTPCRE NAMES qtpcre2 qtpcre)
@ -302,7 +302,7 @@ if(QT_STATIC)
endif() endif()
list(APPEND QT_LIBRARIES Qt5::QWindowsIntegrationPlugin ${QWINDOWS_DEPS} dwmapi uxtheme imm32 -static-libgcc -static-libstdc++) list(APPEND QT_LIBRARIES Qt5::QWindowsIntegrationPlugin ${QWINDOWS_DEPS} dwmapi uxtheme imm32 -static-libgcc -static-libstdc++)
set_target_properties(Qt5::Core PROPERTIES INTERFACE_LINK_LIBRARIES "${QTPCRE};version;winmm;ssl;crypto;ws2_32;iphlpapi;crypt32;userenv;netapi32;wtsapi32") set_target_properties(Qt5::Core PROPERTIES INTERFACE_LINK_LIBRARIES "${QTPCRE};version;winmm;ssl;crypto;ws2_32;iphlpapi;crypt32;userenv;netapi32;wtsapi32")
set_target_properties(Qt5::Gui PROPERTIES INTERFACE_LINK_LIBRARIES ${OPENGL_LIBRARY} ${OPENGLES2_LIBRARY}) set_target_properties(Qt5::Gui PROPERTIES INTERFACE_LINK_LIBRARIES ${OPENGL_LIBRARY} ${OPENGLES2_LIBRARY} ${OPENGLES3_LIBRARY})
elseif(APPLE) elseif(APPLE)
find_package(Cups) find_package(Cups)
find_package(Qt5PrintSupport) find_package(Qt5PrintSupport)

View File

@ -10,21 +10,21 @@
using namespace QGBA; using namespace QGBA;
#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY) #if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(BUILD_GLES3) || defined(USE_EPOXY)
Display::Driver Display::s_driver = Display::Driver::OPENGL; Display::Driver Display::s_driver = Display::Driver::OPENGL;
#else #else
Display::Driver Display::s_driver = Display::Driver::QT; Display::Driver Display::s_driver = Display::Driver::QT;
#endif #endif
Display* Display::create(QWidget* parent) { Display* Display::create(QWidget* parent) {
#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY) #if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(BUILD_GLES3) || defined(USE_EPOXY)
QSurfaceFormat format; QSurfaceFormat format;
format.setSwapInterval(1); format.setSwapInterval(1);
format.setSwapBehavior(QSurfaceFormat::DoubleBuffer); format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
#endif #endif
switch (s_driver) { switch (s_driver) {
#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY) #if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(BUILD_GLES3) || defined(USE_EPOXY)
case Driver::OPENGL: case Driver::OPENGL:
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) { if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) {
format.setVersion(3, 0); format.setVersion(3, 0);
@ -44,7 +44,7 @@ Display* Display::create(QWidget* parent) {
return new DisplayQt(parent); return new DisplayQt(parent);
default: default:
#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY) #if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(BUILD_GLES3) || defined(USE_EPOXY)
return new DisplayGL(format, parent); return new DisplayGL(format, parent);
#else #else
return new DisplayQt(parent); return new DisplayQt(parent);

View File

@ -27,12 +27,8 @@ Q_OBJECT
public: public:
enum class Driver { enum class Driver {
QT = 0, QT = 0,
#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY)
OPENGL = 1, OPENGL = 1,
#endif
#ifdef BUILD_GL
OPENGL1 = 2, OPENGL1 = 2,
#endif
}; };
Display(QWidget* parent = nullptr); Display(QWidget* parent = nullptr);

View File

@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DisplayGL.h" #include "DisplayGL.h"
#if defined(BUILD_GL) || defined(BUILD_GLES2) #if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(BUILD_GLES3)
#include "CoreController.h" #include "CoreController.h"
@ -23,7 +23,7 @@
#ifdef BUILD_GL #ifdef BUILD_GL
#include "platform/opengl/gl.h" #include "platform/opengl/gl.h"
#endif #endif
#ifdef BUILD_GLES2 #if defined(BUILD_GLES2) || defined(BUILD_GLES3)
#include "platform/opengl/gles2.h" #include "platform/opengl/gles2.h"
#ifdef _WIN32 #ifdef _WIN32
#include <epoxy/wgl.h> #include <epoxy/wgl.h>
@ -265,7 +265,7 @@ PainterGL::PainterGL(QWindow* surface, QOpenGLContext* parent, int forceVersion)
#ifdef BUILD_GL #ifdef BUILD_GL
mGLContext* glBackend; mGLContext* glBackend;
#endif #endif
#ifdef BUILD_GLES2 #if defined(BUILD_GLES2) || defined(BUILD_GLES3)
mGLES2Context* gl2Backend; mGLES2Context* gl2Backend;
#endif #endif
@ -284,7 +284,7 @@ PainterGL::PainterGL(QWindow* surface, QOpenGLContext* parent, int forceVersion)
epoxy_handle_external_wglMakeCurrent(); epoxy_handle_external_wglMakeCurrent();
#endif #endif
#ifdef BUILD_GLES2 #if defined(BUILD_GLES2) || defined(BUILD_GLES3)
auto version = m_gl->format().version(); auto version = m_gl->format().version();
QStringList extensions = QString(reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS))).split(' '); QStringList extensions = QString(reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS))).split(' ');
if (forceVersion != 1 && ((version == qMakePair(2, 1) && extensions.contains("GL_ARB_framebuffer_object")) || version.first > 2)) { if (forceVersion != 1 && ((version == qMakePair(2, 1) && extensions.contains("GL_ARB_framebuffer_object")) || version.first > 2)) {
@ -316,7 +316,7 @@ PainterGL::PainterGL(QWindow* surface, QOpenGLContext* parent, int forceVersion)
}; };
m_backend->init(m_backend, 0); m_backend->init(m_backend, 0);
#ifdef BUILD_GLES2 #if defined(BUILD_GLES2) || defined(BUILD_GLES3)
if (m_supportsShaders) { if (m_supportsShaders) {
m_shader.preprocessShader = static_cast<void*>(&reinterpret_cast<mGLES2Context*>(m_backend)->initialShader); m_shader.preprocessShader = static_cast<void*>(&reinterpret_cast<mGLES2Context*>(m_backend)->initialShader);
} }
@ -337,7 +337,7 @@ PainterGL::~PainterGL() {
#if defined(_WIN32) && defined(USE_EPOXY) #if defined(_WIN32) && defined(USE_EPOXY)
epoxy_handle_external_wglMakeCurrent(); epoxy_handle_external_wglMakeCurrent();
#endif #endif
#ifdef BUILD_GLES2 #if defined(BUILD_GLES2) || defined(BUILD_GLES3)
if (m_shader.passes) { if (m_shader.passes) {
mGLES2ShaderFree(&m_shader); mGLES2ShaderFree(&m_shader);
} }
@ -411,7 +411,7 @@ void PainterGL::start() {
epoxy_handle_external_wglMakeCurrent(); epoxy_handle_external_wglMakeCurrent();
#endif #endif
#ifdef BUILD_GLES2 #if defined(BUILD_GLES2) || defined(BUILD_GLES3)
if (m_supportsShaders && m_shader.passes) { if (m_supportsShaders && m_shader.passes) {
mGLES2ShaderAttach(reinterpret_cast<mGLES2Context*>(m_backend), static_cast<mGLES2Shader*>(m_shader.passes), m_shader.nPasses); mGLES2ShaderAttach(reinterpret_cast<mGLES2Context*>(m_backend), static_cast<mGLES2Shader*>(m_shader.passes), m_shader.nPasses);
} }
@ -552,7 +552,7 @@ void PainterGL::setShaders(struct VDir* dir) {
if (!supportsShaders()) { if (!supportsShaders()) {
return; return;
} }
#ifdef BUILD_GLES2 #if defined(BUILD_GLES2) || defined(BUILD_GLES3)
if (!m_started) { if (!m_started) {
m_gl->makeCurrent(m_surface); m_gl->makeCurrent(m_surface);
#if defined(_WIN32) && defined(USE_EPOXY) #if defined(_WIN32) && defined(USE_EPOXY)
@ -576,7 +576,7 @@ void PainterGL::clearShaders() {
if (!supportsShaders()) { if (!supportsShaders()) {
return; return;
} }
#ifdef BUILD_GLES2 #if defined(BUILD_GLES2) || defined(BUILD_GLES3)
if (!m_started) { if (!m_started) {
m_gl->makeCurrent(m_surface); m_gl->makeCurrent(m_surface);
#if defined(_WIN32) && defined(USE_EPOXY) #if defined(_WIN32) && defined(USE_EPOXY)
@ -598,7 +598,7 @@ VideoShader* PainterGL::shaders() {
} }
int PainterGL::glTex() { int PainterGL::glTex() {
#ifdef BUILD_GLES2 #if defined(BUILD_GLES2) || defined(BUILD_GLES3)
if (supportsShaders()) { if (supportsShaders()) {
mGLES2Context* gl2Backend = reinterpret_cast<mGLES2Context*>(m_backend); mGLES2Context* gl2Backend = reinterpret_cast<mGLES2Context*>(m_backend);
return gl2Backend->tex; return gl2Backend->tex;

View File

@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#pragma once #pragma once
#if defined(BUILD_GL) || defined(BUILD_GLES2) #if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(BUILD_GLES3)
#include "Display.h" #include "Display.h"