mirror of https://github.com/mgba-emu/mgba.git
OpenGL: Add libepoxy optional dependency
This commit is contained in:
parent
e830718be8
commit
346d4210c6
|
@ -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)
|
||||
|
@ -436,6 +438,15 @@ if (USE_LZMA)
|
|||
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)
|
||||
list(APPEND FEATURE_DEFINES "USE_${FEATURE}")
|
||||
|
|
|
@ -6,7 +6,9 @@
|
|||
#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>
|
||||
|
|
|
@ -6,12 +6,14 @@
|
|||
#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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -14,8 +14,11 @@ extern "C" {
|
|||
#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 @@ PainterGL::PainterGL(QGLWidget* parent, QGLFormat::OpenGLVersionFlags glVersion)
|
|||
#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::filter(bool filter) {
|
|||
|
||||
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::forceDraw() {
|
|||
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);
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
|
||||
#include "Display.h"
|
||||
|
||||
#ifdef USE_EPOXY
|
||||
#include <epoxy/gl.h>
|
||||
#include <epoxy/wgl.h>
|
||||
#endif
|
||||
|
||||
#include <QGLWidget>
|
||||
#include <QList>
|
||||
#include <QMouseEvent>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "util/common.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
typedef HWND WHandle;
|
||||
#else
|
||||
typedef void* WHandle;
|
||||
|
|
Loading…
Reference in New Issue