all repos — mgba @ 346d4210c61510a0eab78c23f7676aae5b93a42a

mGBA Game Boy Advance Emulator

OpenGL: Add libepoxy optional dependency
Jeffrey Pfau jeffrey@endrift.com
Sun, 01 Nov 2015 13:24:43 -0800
commit

346d4210c61510a0eab78c23f7676aae5b93a42a

parent

e830718be86a95cd193ab3367d05b0cf0c7838e3

M CMakeLists.txtCMakeLists.txt

@@ -24,6 +24,7 @@ set(BUILD_STATIC OFF CACHE BOOL "Build a static library")

set(BUILD_SHARED ON CACHE BOOL "Build a shared library") set(BUILD_GL ON CACHE STRING "Build with OpenGL") set(BUILD_GLES2 OFF CACHE STRING "Build with OpenGL|ES 2") +set(USE_EPOXY ON CACHE STRING "Build with libepoxy") set(DISABLE_DEPS OFF CACHE BOOL "Build without dependencies") file(GLOB ARM_SRC ${CMAKE_SOURCE_DIR}/src/arm/*.c) file(GLOB GBA_SRC ${CMAKE_SOURCE_DIR}/src/gba/*.c)

@@ -284,6 +285,7 @@ find_feature(USE_ZLIB "ZLIB")

find_feature(USE_PNG "PNG") find_feature(USE_LIBZIP "libzip") find_feature(USE_MAGICK "MagickWand") +find_feature(USE_EPOXY "epoxy") # Features set(DEBUGGER_SRC ${CMAKE_SOURCE_DIR}/src/debugger/debugger.c ${CMAKE_SOURCE_DIR}/src/debugger/memory-debugger.c)

@@ -435,6 +437,15 @@ ${CMAKE_SOURCE_DIR}/src/third-party/lzma/7zStream.c)

list(APPEND FEATURE_SRC ${LZMA_SRC}) list(APPEND FEATURES LZMA) endif() + +if(USE_EPOXY) + add_definitions(-DBUILD_GL -DBUILD_GLES2) + list(APPEND FEATURES EPOXY) + include_directories(AFTER ${EPOXY_INCLUDE_DIRS}) + set(OPENGLES2_LIBRARY ${EPOXY_LIBRARIES}) + set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libepoxy0") +endif() + set(FEATURE_DEFINES) foreach(FEATURE IN LISTS FEATURES)
M src/platform/opengl/gl.hsrc/platform/opengl/gl.h

@@ -6,7 +6,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef GL_H #define GL_H -#ifdef __APPLE__ +#ifdef USE_EPOXY +#include <epoxy/gl.h> +#elif defined(__APPLE__) #include <OpenGL/gl.h> #else #include <GL/gl.h>
M src/platform/opengl/gles2.hsrc/platform/opengl/gles2.h

@@ -6,12 +6,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef GLES2_H #define GLES2_H -#ifdef BUILD_GL +#ifdef USE_EPOXY +#include <epoxy/gl.h> +#elif defined(BUILD_GL) #ifdef __APPLE__ #include <OpenGL/gl3.h> #else -#include <GL/gl.h> #define GL_GLEXT_PROTOTYPES +#include <GL/gl.h> #include <GL/glext.h> #endif #else
M src/platform/qt/CMakeLists.txtsrc/platform/qt/CMakeLists.txt

@@ -48,7 +48,7 @@ endif()

if(BUILD_GL) list(APPEND PLATFORM_SRC ${CMAKE_SOURCE_DIR}/src/platform/opengl/gl.c) - if(NOT WIN32) + if(NOT WIN32 OR USE_EPOXY) list(APPEND PLATFORM_SRC ${CMAKE_SOURCE_DIR}/src/platform/opengl/gles2.c) endif() endif()
M src/platform/qt/DisplayGL.cppsrc/platform/qt/DisplayGL.cpp

@@ -14,8 +14,11 @@

#ifdef BUILD_GL #include "platform/opengl/gl.h" #endif -#if !defined(_WIN32) +#if !defined(_WIN32) || defined(USE_EPOXY) #include "platform/opengl/gles2.h" +#ifdef _WIN32 +#include <epoxy/wgl.h> +#endif #endif }

@@ -151,11 +154,11 @@ {

#ifdef BUILD_GL GBAGLContext* glBackend; #endif -#ifndef _WIN32 +#if !defined(_WIN32) || defined(USE_EPOXY) GBAGLES2Context* gl2Backend; #endif -#ifndef _WIN32 +#if !defined(_WIN32) || defined(USE_EPOXY) if (glVersion & QGLFormat::OpenGL_Version_3_0) { gl2Backend = new GBAGLES2Context; GBAGLES2ContextCreate(gl2Backend);

@@ -223,6 +226,9 @@ }

void PainterGL::start() { m_gl->makeCurrent(); +#if defined(_WIN32) && defined(USE_EPOXY) + epoxy_handle_external_wglMakeCurrent(); +#endif m_backend->init(m_backend, reinterpret_cast<WHandle>(m_gl->winId())); m_gl->doneCurrent(); m_active = true;

@@ -257,6 +263,9 @@

void PainterGL::stop() { m_active = false; m_gl->makeCurrent(); +#if defined(_WIN32) && defined(USE_EPOXY) + epoxy_handle_external_wglMakeCurrent(); +#endif dequeueAll(); m_backend->clear(m_backend); m_backend->swap(m_backend);
M src/platform/qt/DisplayGL.hsrc/platform/qt/DisplayGL.h

@@ -8,6 +8,11 @@ #define QGBA_DISPLAY_GL

#include "Display.h" +#ifdef USE_EPOXY +#include <epoxy/gl.h> +#include <epoxy/wgl.h> +#endif + #include <QGLWidget> #include <QList> #include <QMouseEvent>
M src/platform/video-backend.hsrc/platform/video-backend.h

@@ -9,6 +9,7 @@

#include "util/common.h" #ifdef _WIN32 +#include <windows.h> typedef HWND WHandle; #else typedef void* WHandle;