mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 14:57:20 +00:00
[client] opengl: make ds functions optional
Using a macro ENABLE_OPENGL just like ENABLE_EGL to optionally remove OpenGL implementation code. This is mostly because on Wayland it's just a rehash of the EGL code (as EGL is the only way to create OpenGL contexts on Wayland).
This commit is contained in:
parent
af2dafbdac
commit
ecebcc4c35
@ -53,6 +53,10 @@ add_compile_options(
|
|||||||
set(EXE_FLAGS "-Wl,--gc-sections -z noexecstack")
|
set(EXE_FLAGS "-Wl,--gc-sections -z noexecstack")
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
|
||||||
|
if (ENABLE_OPENGL)
|
||||||
|
add_definitions(-D ENABLE_OPENGL)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (ENABLE_EGL)
|
if (ENABLE_EGL)
|
||||||
add_definitions(-D ENABLE_EGL)
|
add_definitions(-D ENABLE_EGL)
|
||||||
endif()
|
endif()
|
||||||
|
@ -76,6 +76,7 @@ static bool sdlInit(const LG_DSInitParams params)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_OPENGL
|
||||||
if (params.opengl)
|
if (params.opengl)
|
||||||
{
|
{
|
||||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER , 1);
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER , 1);
|
||||||
@ -85,6 +86,7 @@ static bool sdlInit(const LG_DSInitParams params)
|
|||||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE , 8);
|
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE , 8);
|
||||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE , 8);
|
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE , 8);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
sdl.window = SDL_CreateWindow(
|
sdl.window = SDL_CreateWindow(
|
||||||
params.title,
|
params.title,
|
||||||
@ -254,6 +256,7 @@ static void sdlEGLSwapBuffers(EGLDisplay display, EGLSurface surface)
|
|||||||
}
|
}
|
||||||
#endif //ENABLE_EGL
|
#endif //ENABLE_EGL
|
||||||
|
|
||||||
|
#ifdef ENABLE_OPENGL
|
||||||
static LG_DSGLContext sdlGLCreateContext(void)
|
static LG_DSGLContext sdlGLCreateContext(void)
|
||||||
{
|
{
|
||||||
return (LG_DSGLContext)SDL_GL_CreateContext(sdl.window);
|
return (LG_DSGLContext)SDL_GL_CreateContext(sdl.window);
|
||||||
@ -278,6 +281,7 @@ static void sdlGLSwapBuffers(void)
|
|||||||
{
|
{
|
||||||
SDL_GL_SwapWindow(sdl.window);
|
SDL_GL_SwapWindow(sdl.window);
|
||||||
}
|
}
|
||||||
|
#endif //ENABLE_OPENGL
|
||||||
|
|
||||||
static int sdlEventFilter(void * userdata, SDL_Event * event)
|
static int sdlEventFilter(void * userdata, SDL_Event * event)
|
||||||
{
|
{
|
||||||
@ -517,11 +521,13 @@ struct LG_DisplayServerOps LGDS_SDL =
|
|||||||
.eglSwapBuffers = sdlEGLSwapBuffers,
|
.eglSwapBuffers = sdlEGLSwapBuffers,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_OPENGL
|
||||||
.glCreateContext = sdlGLCreateContext,
|
.glCreateContext = sdlGLCreateContext,
|
||||||
.glDeleteContext = sdlGLDeleteContext,
|
.glDeleteContext = sdlGLDeleteContext,
|
||||||
.glMakeCurrent = sdlGLMakeCurrent,
|
.glMakeCurrent = sdlGLMakeCurrent,
|
||||||
.glSetSwapInterval = sdlGLSetSwapInterval,
|
.glSetSwapInterval = sdlGLSetSwapInterval,
|
||||||
.glSwapBuffers = sdlGLSwapBuffers,
|
.glSwapBuffers = sdlGLSwapBuffers,
|
||||||
|
#endif
|
||||||
|
|
||||||
.showPointer = sdlShowPointer,
|
.showPointer = sdlShowPointer,
|
||||||
.grabPointer = sdlGrabPointer,
|
.grabPointer = sdlGrabPointer,
|
||||||
|
@ -31,9 +31,11 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
|
|
||||||
|
#if defined(ENABLE_EGL) || defined(ENABLE_OPENGL)
|
||||||
# include <wayland-egl.h>
|
# include <wayland-egl.h>
|
||||||
# include "egl_dynprocs.h"
|
# include "egl_dynprocs.h"
|
||||||
# include <EGL/eglext.h>
|
# include <EGL/eglext.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
@ -66,9 +68,11 @@ struct WaylandDSState
|
|||||||
struct wl_egl_window * eglWindow;
|
struct wl_egl_window * eglWindow;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_OPENGL
|
||||||
EGLDisplay glDisplay;
|
EGLDisplay glDisplay;
|
||||||
EGLConfig glConfig;
|
EGLConfig glConfig;
|
||||||
EGLSurface glSurface;
|
EGLSurface glSurface;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct xdg_wm_base * xdgWmBase;
|
struct xdg_wm_base * xdgWmBase;
|
||||||
struct xdg_surface * xdgSurface;
|
struct xdg_surface * xdgSurface;
|
||||||
@ -559,6 +563,7 @@ static bool waylandInit(const LG_DSInitParams params)
|
|||||||
wl_surface_commit(wm.cursor);
|
wl_surface_commit(wm.cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_OPENGL
|
||||||
if (params.opengl)
|
if (params.opengl)
|
||||||
{
|
{
|
||||||
EGLint attr[] =
|
EGLint attr[] =
|
||||||
@ -604,6 +609,7 @@ static bool waylandInit(const LG_DSInitParams params)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
wm.width = params.w;
|
wm.width = params.w;
|
||||||
wm.height = params.h;
|
wm.height = params.h;
|
||||||
@ -619,6 +625,14 @@ static void waylandShutdown(void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_EGL
|
||||||
|
static EGLNativeWindowType waylandGetEGLNativeWindow(void)
|
||||||
|
{
|
||||||
|
return (EGLNativeWindowType) wm.eglWindow;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ENABLE_EGL) || defined(ENABLE_OPENGL)
|
||||||
static EGLDisplay waylandGetEGLDisplay(void)
|
static EGLDisplay waylandGetEGLDisplay(void)
|
||||||
{
|
{
|
||||||
EGLNativeDisplayType native = (EGLNativeDisplayType) wm.display;
|
EGLNativeDisplayType native = (EGLNativeDisplayType) wm.display;
|
||||||
@ -643,13 +657,6 @@ static EGLDisplay waylandGetEGLDisplay(void)
|
|||||||
return eglGetDisplay(native);
|
return eglGetDisplay(native);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_EGL
|
|
||||||
static EGLNativeWindowType waylandGetEGLNativeWindow(void)
|
|
||||||
{
|
|
||||||
return (EGLNativeWindowType) wm.eglWindow;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void waylandEGLSwapBuffers(EGLDisplay display, EGLSurface surface)
|
static void waylandEGLSwapBuffers(EGLDisplay display, EGLSurface surface)
|
||||||
{
|
{
|
||||||
eglSwapBuffers(display, surface);
|
eglSwapBuffers(display, surface);
|
||||||
@ -668,6 +675,9 @@ static void waylandEGLSwapBuffers(EGLDisplay display, EGLSurface surface)
|
|||||||
wm.resizeSerial = 0;
|
wm.resizeSerial = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_OPENGL
|
||||||
static LG_DSGLContext waylandGLCreateContext(void)
|
static LG_DSGLContext waylandGLCreateContext(void)
|
||||||
{
|
{
|
||||||
eglBindAPI(EGL_OPENGL_API);
|
eglBindAPI(EGL_OPENGL_API);
|
||||||
@ -693,6 +703,7 @@ static void waylandGLSwapBuffers(void)
|
|||||||
{
|
{
|
||||||
waylandEGLSwapBuffers(wm.glDisplay, wm.glSurface);
|
waylandEGLSwapBuffers(wm.glDisplay, wm.glSurface);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void waylandShowPointer(bool show)
|
static void waylandShowPointer(bool show)
|
||||||
{
|
{
|
||||||
@ -1214,11 +1225,13 @@ struct LG_DisplayServerOps LGDS_Wayland =
|
|||||||
.eglSwapBuffers = waylandEGLSwapBuffers,
|
.eglSwapBuffers = waylandEGLSwapBuffers,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_OPENGL
|
||||||
.glCreateContext = waylandGLCreateContext,
|
.glCreateContext = waylandGLCreateContext,
|
||||||
.glDeleteContext = waylandGLDeleteContext,
|
.glDeleteContext = waylandGLDeleteContext,
|
||||||
.glMakeCurrent = waylandGLMakeCurrent,
|
.glMakeCurrent = waylandGLMakeCurrent,
|
||||||
.glSetSwapInterval = waylandGLSetSwapInterval,
|
.glSetSwapInterval = waylandGLSetSwapInterval,
|
||||||
.glSwapBuffers = waylandGLSwapBuffers,
|
.glSwapBuffers = waylandGLSwapBuffers,
|
||||||
|
#endif
|
||||||
|
|
||||||
.showPointer = waylandShowPointer,
|
.showPointer = waylandShowPointer,
|
||||||
.grabPointer = waylandGrabPointer,
|
.grabPointer = waylandGrabPointer,
|
||||||
|
@ -146,6 +146,7 @@ static bool x11Init(const LG_DSInitParams params)
|
|||||||
};
|
};
|
||||||
unsigned long swaMask = CWEventMask;
|
unsigned long swaMask = CWEventMask;
|
||||||
|
|
||||||
|
#ifdef ENABLE_OPENGL
|
||||||
if (params.opengl)
|
if (params.opengl)
|
||||||
{
|
{
|
||||||
GLint glXAttribs[] =
|
GLint glXAttribs[] =
|
||||||
@ -174,6 +175,7 @@ static bool x11Init(const LG_DSInitParams params)
|
|||||||
x11.visual->visual, AllocNone);
|
x11.visual->visual, AllocNone);
|
||||||
swaMask |= CWColormap;
|
swaMask |= CWColormap;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
x11.window = XCreateWindow(
|
x11.window = XCreateWindow(
|
||||||
x11.display,
|
x11.display,
|
||||||
@ -911,6 +913,7 @@ static void x11EGLSwapBuffers(EGLDisplay display, EGLSurface surface)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_OPENGL
|
||||||
static LG_DSGLContext x11GLCreateContext(void)
|
static LG_DSGLContext x11GLCreateContext(void)
|
||||||
{
|
{
|
||||||
return (LG_DSGLContext)
|
return (LG_DSGLContext)
|
||||||
@ -936,6 +939,7 @@ static void x11GLSwapBuffers(void)
|
|||||||
{
|
{
|
||||||
glXSwapBuffers(x11.display, x11.window);
|
glXSwapBuffers(x11.display, x11.window);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void x11ShowPointer(bool show)
|
static void x11ShowPointer(bool show)
|
||||||
{
|
{
|
||||||
@ -1488,11 +1492,13 @@ struct LG_DisplayServerOps LGDS_X11 =
|
|||||||
.getEGLNativeWindow = x11GetEGLNativeWindow,
|
.getEGLNativeWindow = x11GetEGLNativeWindow,
|
||||||
.eglSwapBuffers = x11EGLSwapBuffers,
|
.eglSwapBuffers = x11EGLSwapBuffers,
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ENABLE_OPENGL
|
||||||
.glCreateContext = x11GLCreateContext,
|
.glCreateContext = x11GLCreateContext,
|
||||||
.glDeleteContext = x11GLDeleteContext,
|
.glDeleteContext = x11GLDeleteContext,
|
||||||
.glMakeCurrent = x11GLMakeCurrent,
|
.glMakeCurrent = x11GLMakeCurrent,
|
||||||
.glSetSwapInterval = x11GLSetSwapInterval,
|
.glSetSwapInterval = x11GLSetSwapInterval,
|
||||||
.glSwapBuffers = x11GLSwapBuffers,
|
.glSwapBuffers = x11GLSwapBuffers,
|
||||||
|
#endif
|
||||||
.showPointer = x11ShowPointer,
|
.showPointer = x11ShowPointer,
|
||||||
.grabPointer = x11GrabPointer,
|
.grabPointer = x11GrabPointer,
|
||||||
.ungrabPointer = x11UngrabPointer,
|
.ungrabPointer = x11UngrabPointer,
|
||||||
|
@ -64,11 +64,13 @@ EGLNativeWindowType app_getEGLNativeWindow(void);
|
|||||||
void app_eglSwapBuffers(EGLDisplay display, EGLSurface surface);
|
void app_eglSwapBuffers(EGLDisplay display, EGLSurface surface);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_OPENGL
|
||||||
LG_DSGLContext app_glCreateContext(void);
|
LG_DSGLContext app_glCreateContext(void);
|
||||||
void app_glDeleteContext(LG_DSGLContext context);
|
void app_glDeleteContext(LG_DSGLContext context);
|
||||||
void app_glMakeCurrent(LG_DSGLContext context);
|
void app_glMakeCurrent(LG_DSGLContext context);
|
||||||
void app_glSetSwapInterval(int interval);
|
void app_glSetSwapInterval(int interval);
|
||||||
void app_glSwapBuffers(void);
|
void app_glSwapBuffers(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
void app_clipboardRelease(void);
|
void app_clipboardRelease(void);
|
||||||
void app_clipboardNotify(const LG_ClipboardData type, size_t size);
|
void app_clipboardNotify(const LG_ClipboardData type, size_t size);
|
||||||
|
@ -109,12 +109,14 @@ struct LG_DisplayServerOps
|
|||||||
void (*eglSwapBuffers)(EGLDisplay display, EGLSurface surface);
|
void (*eglSwapBuffers)(EGLDisplay display, EGLSurface surface);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_OPENGL
|
||||||
/* opengl platform specific methods */
|
/* opengl platform specific methods */
|
||||||
LG_DSGLContext (*glCreateContext)(void);
|
LG_DSGLContext (*glCreateContext)(void);
|
||||||
void (*glDeleteContext)(LG_DSGLContext context);
|
void (*glDeleteContext)(LG_DSGLContext context);
|
||||||
void (*glMakeCurrent)(LG_DSGLContext context);
|
void (*glMakeCurrent)(LG_DSGLContext context);
|
||||||
void (*glSetSwapInterval)(int interval);
|
void (*glSetSwapInterval)(int interval);
|
||||||
void (*glSwapBuffers)(void);
|
void (*glSwapBuffers)(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* dm specific cursor implementations */
|
/* dm specific cursor implementations */
|
||||||
void (*showPointer)(bool show);
|
void (*showPointer)(bool show);
|
||||||
@ -159,6 +161,12 @@ struct LG_DisplayServerOps
|
|||||||
#define ASSERT_EGL_FN(x)
|
#define ASSERT_EGL_FN(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_OPENGL
|
||||||
|
#define ASSERT_OPENGL_FN(x) assert(x)
|
||||||
|
#else
|
||||||
|
#define ASSERT_OPENGL_FN(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ASSERT_LG_DS_VALID(x) \
|
#define ASSERT_LG_DS_VALID(x) \
|
||||||
assert((x)->probe ); \
|
assert((x)->probe ); \
|
||||||
assert((x)->earlyInit ); \
|
assert((x)->earlyInit ); \
|
||||||
@ -170,11 +178,11 @@ struct LG_DisplayServerOps
|
|||||||
ASSERT_EGL_FN((x)->getEGLDisplay ); \
|
ASSERT_EGL_FN((x)->getEGLDisplay ); \
|
||||||
ASSERT_EGL_FN((x)->getEGLNativeWindow ); \
|
ASSERT_EGL_FN((x)->getEGLNativeWindow ); \
|
||||||
ASSERT_EGL_FN((x)->eglSwapBuffers ); \
|
ASSERT_EGL_FN((x)->eglSwapBuffers ); \
|
||||||
assert((x)->glCreateContext ); \
|
ASSERT_OPENGL_FN((x)->glCreateContext ); \
|
||||||
assert((x)->glDeleteContext ); \
|
ASSERT_OPENGL_FN((x)->glDeleteContext ); \
|
||||||
assert((x)->glMakeCurrent ); \
|
ASSERT_OPENGL_FN((x)->glMakeCurrent ); \
|
||||||
assert((x)->glSetSwapInterval ); \
|
ASSERT_OPENGL_FN((x)->glSetSwapInterval); \
|
||||||
assert((x)->glSwapBuffers ); \
|
ASSERT_OPENGL_FN((x)->glSwapBuffers ); \
|
||||||
assert((x)->showPointer ); \
|
assert((x)->showPointer ); \
|
||||||
assert((x)->grabPointer ); \
|
assert((x)->grabPointer ); \
|
||||||
assert((x)->ungrabPointer ); \
|
assert((x)->ungrabPointer ); \
|
||||||
|
@ -583,6 +583,7 @@ void app_eglSwapBuffers(EGLDisplay display, EGLSurface surface)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_OPENGL
|
||||||
LG_DSGLContext app_glCreateContext(void)
|
LG_DSGLContext app_glCreateContext(void)
|
||||||
{
|
{
|
||||||
return g_state.ds->glCreateContext();
|
return g_state.ds->glCreateContext();
|
||||||
@ -607,6 +608,7 @@ void app_glSwapBuffers(void)
|
|||||||
{
|
{
|
||||||
g_state.ds->glSwapBuffers();
|
g_state.ds->glSwapBuffers();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void app_alert(LG_MsgAlert type, const char * fmt, ...)
|
void app_alert(LG_MsgAlert type, const char * fmt, ...)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user