mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-08-09 20:24:14 +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:
@@ -76,6 +76,7 @@ static bool sdlInit(const LG_DSInitParams params)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_OPENGL
|
||||
if (params.opengl)
|
||||
{
|
||||
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_BLUE_SIZE , 8);
|
||||
}
|
||||
#endif
|
||||
|
||||
sdl.window = SDL_CreateWindow(
|
||||
params.title,
|
||||
@@ -254,6 +256,7 @@ static void sdlEGLSwapBuffers(EGLDisplay display, EGLSurface surface)
|
||||
}
|
||||
#endif //ENABLE_EGL
|
||||
|
||||
#ifdef ENABLE_OPENGL
|
||||
static LG_DSGLContext sdlGLCreateContext(void)
|
||||
{
|
||||
return (LG_DSGLContext)SDL_GL_CreateContext(sdl.window);
|
||||
@@ -278,6 +281,7 @@ static void sdlGLSwapBuffers(void)
|
||||
{
|
||||
SDL_GL_SwapWindow(sdl.window);
|
||||
}
|
||||
#endif //ENABLE_OPENGL
|
||||
|
||||
static int sdlEventFilter(void * userdata, SDL_Event * event)
|
||||
{
|
||||
@@ -517,11 +521,13 @@ struct LG_DisplayServerOps LGDS_SDL =
|
||||
.eglSwapBuffers = sdlEGLSwapBuffers,
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_OPENGL
|
||||
.glCreateContext = sdlGLCreateContext,
|
||||
.glDeleteContext = sdlGLDeleteContext,
|
||||
.glMakeCurrent = sdlGLMakeCurrent,
|
||||
.glSetSwapInterval = sdlGLSetSwapInterval,
|
||||
.glSwapBuffers = sdlGLSwapBuffers,
|
||||
#endif
|
||||
|
||||
.showPointer = sdlShowPointer,
|
||||
.grabPointer = sdlGrabPointer,
|
||||
|
@@ -31,9 +31,11 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include <SDL2/SDL.h>
|
||||
#include <wayland-client.h>
|
||||
|
||||
#include <wayland-egl.h>
|
||||
#include "egl_dynprocs.h"
|
||||
#include <EGL/eglext.h>
|
||||
#if defined(ENABLE_EGL) || defined(ENABLE_OPENGL)
|
||||
# include <wayland-egl.h>
|
||||
# include "egl_dynprocs.h"
|
||||
# include <EGL/eglext.h>
|
||||
#endif
|
||||
|
||||
#include "app.h"
|
||||
#include "common/debug.h"
|
||||
@@ -66,9 +68,11 @@ struct WaylandDSState
|
||||
struct wl_egl_window * eglWindow;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_OPENGL
|
||||
EGLDisplay glDisplay;
|
||||
EGLConfig glConfig;
|
||||
EGLSurface glSurface;
|
||||
#endif
|
||||
|
||||
struct xdg_wm_base * xdgWmBase;
|
||||
struct xdg_surface * xdgSurface;
|
||||
@@ -559,6 +563,7 @@ static bool waylandInit(const LG_DSInitParams params)
|
||||
wl_surface_commit(wm.cursor);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_OPENGL
|
||||
if (params.opengl)
|
||||
{
|
||||
EGLint attr[] =
|
||||
@@ -604,6 +609,7 @@ static bool waylandInit(const LG_DSInitParams params)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
wm.width = params.w;
|
||||
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)
|
||||
{
|
||||
EGLNativeDisplayType native = (EGLNativeDisplayType) wm.display;
|
||||
@@ -643,13 +657,6 @@ static EGLDisplay waylandGetEGLDisplay(void)
|
||||
return eglGetDisplay(native);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_EGL
|
||||
static EGLNativeWindowType waylandGetEGLNativeWindow(void)
|
||||
{
|
||||
return (EGLNativeWindowType) wm.eglWindow;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void waylandEGLSwapBuffers(EGLDisplay display, EGLSurface surface)
|
||||
{
|
||||
eglSwapBuffers(display, surface);
|
||||
@@ -668,6 +675,9 @@ static void waylandEGLSwapBuffers(EGLDisplay display, EGLSurface surface)
|
||||
wm.resizeSerial = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_OPENGL
|
||||
static LG_DSGLContext waylandGLCreateContext(void)
|
||||
{
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
@@ -693,6 +703,7 @@ static void waylandGLSwapBuffers(void)
|
||||
{
|
||||
waylandEGLSwapBuffers(wm.glDisplay, wm.glSurface);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void waylandShowPointer(bool show)
|
||||
{
|
||||
@@ -1214,11 +1225,13 @@ struct LG_DisplayServerOps LGDS_Wayland =
|
||||
.eglSwapBuffers = waylandEGLSwapBuffers,
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_OPENGL
|
||||
.glCreateContext = waylandGLCreateContext,
|
||||
.glDeleteContext = waylandGLDeleteContext,
|
||||
.glMakeCurrent = waylandGLMakeCurrent,
|
||||
.glSetSwapInterval = waylandGLSetSwapInterval,
|
||||
.glSwapBuffers = waylandGLSwapBuffers,
|
||||
#endif
|
||||
|
||||
.showPointer = waylandShowPointer,
|
||||
.grabPointer = waylandGrabPointer,
|
||||
|
@@ -146,6 +146,7 @@ static bool x11Init(const LG_DSInitParams params)
|
||||
};
|
||||
unsigned long swaMask = CWEventMask;
|
||||
|
||||
#ifdef ENABLE_OPENGL
|
||||
if (params.opengl)
|
||||
{
|
||||
GLint glXAttribs[] =
|
||||
@@ -174,6 +175,7 @@ static bool x11Init(const LG_DSInitParams params)
|
||||
x11.visual->visual, AllocNone);
|
||||
swaMask |= CWColormap;
|
||||
}
|
||||
#endif
|
||||
|
||||
x11.window = XCreateWindow(
|
||||
x11.display,
|
||||
@@ -911,6 +913,7 @@ static void x11EGLSwapBuffers(EGLDisplay display, EGLSurface surface)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_OPENGL
|
||||
static LG_DSGLContext x11GLCreateContext(void)
|
||||
{
|
||||
return (LG_DSGLContext)
|
||||
@@ -936,6 +939,7 @@ static void x11GLSwapBuffers(void)
|
||||
{
|
||||
glXSwapBuffers(x11.display, x11.window);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void x11ShowPointer(bool show)
|
||||
{
|
||||
@@ -1488,11 +1492,13 @@ struct LG_DisplayServerOps LGDS_X11 =
|
||||
.getEGLNativeWindow = x11GetEGLNativeWindow,
|
||||
.eglSwapBuffers = x11EGLSwapBuffers,
|
||||
#endif
|
||||
#ifdef ENABLE_OPENGL
|
||||
.glCreateContext = x11GLCreateContext,
|
||||
.glDeleteContext = x11GLDeleteContext,
|
||||
.glMakeCurrent = x11GLMakeCurrent,
|
||||
.glSetSwapInterval = x11GLSetSwapInterval,
|
||||
.glSwapBuffers = x11GLSwapBuffers,
|
||||
#endif
|
||||
.showPointer = x11ShowPointer,
|
||||
.grabPointer = x11GrabPointer,
|
||||
.ungrabPointer = x11UngrabPointer,
|
||||
|
Reference in New Issue
Block a user