diff options
Diffstat (limited to 'pugl')
-rw-r--r-- | pugl/detail/mac_cairo.m | 20 | ||||
-rw-r--r-- | pugl/detail/mac_gl.m | 17 | ||||
-rw-r--r-- | pugl/detail/win_gl.c | 19 | ||||
-rw-r--r-- | pugl/detail/x11_gl.c | 19 | ||||
-rw-r--r-- | pugl/pugl_stub_backend.h | 103 |
5 files changed, 115 insertions, 63 deletions
diff --git a/pugl/detail/mac_cairo.m b/pugl/detail/mac_cairo.m index 143fbb0..1e4149c 100644 --- a/pugl/detail/mac_cairo.m +++ b/pugl/detail/mac_cairo.m @@ -21,6 +21,7 @@ #include "pugl/detail/implementation.h" #include "pugl/detail/mac.h" #include "pugl/pugl_cairo_backend.h" +#include "pugl/pugl_stub_backend.h" #include <cairo-quartz.h> @@ -62,12 +63,6 @@ @end static PuglStatus -puglMacCairoConfigure(PuglView* PUGL_UNUSED(view)) -{ - return PUGL_SUCCESS; -} - -static PuglStatus puglMacCairoCreate(PuglView* view) { PuglInternals* impl = view->impl; @@ -141,15 +136,6 @@ puglMacCairoLeave(PuglView* view, bool drawing) return PUGL_SUCCESS; } -static PuglStatus -puglMacCairoResize(PuglView* PUGL_UNUSED(view), - int PUGL_UNUSED(width), - int PUGL_UNUSED(height)) -{ - // No need to resize, the surface is created for the drawing context - return PUGL_SUCCESS; -} - static void* puglMacCairoGetContext(PuglView* view) { @@ -159,12 +145,12 @@ puglMacCairoGetContext(PuglView* view) const PuglBackend* puglCairoBackend(void) { static const PuglBackend backend = { - puglMacCairoConfigure, + puglStubConfigure, puglMacCairoCreate, puglMacCairoDestroy, puglMacCairoEnter, puglMacCairoLeave, - puglMacCairoResize, + puglStubResize, puglMacCairoGetContext }; diff --git a/pugl/detail/mac_gl.m b/pugl/detail/mac_gl.m index b84f799..6e3c1c6 100644 --- a/pugl/detail/mac_gl.m +++ b/pugl/detail/mac_gl.m @@ -21,6 +21,7 @@ #include "pugl/detail/implementation.h" #include "pugl/detail/mac.h" #include "pugl/pugl_gl_backend.h" +#include "pugl/pugl_stub_backend.h" #ifndef __MAC_10_10 #define NSOpenGLProfileVersion4_1Core NSOpenGLProfileVersion3_2Core @@ -94,12 +95,6 @@ typedef NSUInteger NSWindowStyleMask; @end static PuglStatus -puglMacGlConfigure(PuglView* PUGL_UNUSED(view)) -{ - return PUGL_SUCCESS; -} - -static PuglStatus puglMacGlCreate(PuglView* view) { PuglInternals* impl = view->impl; @@ -164,22 +159,16 @@ puglMacGlResize(PuglView* view, int PUGL_UNUSED(width), int PUGL_UNUSED(height)) return PUGL_SUCCESS; } -static void* -puglMacGlGetContext(PuglView* PUGL_UNUSED(view)) -{ - return NULL; -} - const PuglBackend* puglGlBackend(void) { static const PuglBackend backend = { - puglMacGlConfigure, + puglStubConfigure, puglMacGlCreate, puglMacGlDestroy, puglMacGlEnter, puglMacGlLeave, puglMacGlResize, - puglMacGlGetContext + puglStubGetContext }; return &backend; diff --git a/pugl/detail/win_gl.c b/pugl/detail/win_gl.c index e8ecedc..d872303 100644 --- a/pugl/detail/win_gl.c +++ b/pugl/detail/win_gl.c @@ -21,6 +21,7 @@ #include "pugl/detail/types.h" #include "pugl/detail/win.h" #include "pugl/pugl_gl_backend.h" +#include "pugl/pugl_stub_backend.h" #include <windows.h> @@ -272,20 +273,6 @@ puglWinGlLeave(PuglView* view, bool drawing) return PUGL_SUCCESS; } -static PuglStatus -puglWinGlResize(PuglView* PUGL_UNUSED(view), - int PUGL_UNUSED(width), - int PUGL_UNUSED(height)) -{ - return PUGL_SUCCESS; -} - -static void* -puglWinGlGetContext(PuglView* PUGL_UNUSED(view)) -{ - return NULL; -} - PuglGlFunc puglGetProcAddress(const char* name) { @@ -309,8 +296,8 @@ puglGlBackend() puglWinGlDestroy, puglWinGlEnter, puglWinGlLeave, - puglWinGlResize, - puglWinGlGetContext + puglStubResize, + puglStubGetContext }; return &backend; diff --git a/pugl/detail/x11_gl.c b/pugl/detail/x11_gl.c index f5dbe2c..ea34fc3 100644 --- a/pugl/detail/x11_gl.c +++ b/pugl/detail/x11_gl.c @@ -22,6 +22,7 @@ #include "pugl/detail/x11.h" #include "pugl/pugl.h" #include "pugl/pugl_gl_backend.h" +#include "pugl/pugl_stub_backend.h" #include <GL/gl.h> #include <GL/glx.h> @@ -188,20 +189,6 @@ puglX11GlLeave(PuglView* view, bool drawing) return PUGL_SUCCESS; } -static PuglStatus -puglX11GlResize(PuglView* PUGL_UNUSED(view), - int PUGL_UNUSED(width), - int PUGL_UNUSED(height)) -{ - return PUGL_SUCCESS; -} - -static void* -puglX11GlGetContext(PuglView* PUGL_UNUSED(view)) -{ - return NULL; -} - PuglGlFunc puglGetProcAddress(const char* name) { @@ -216,8 +203,8 @@ const PuglBackend* puglGlBackend(void) puglX11GlDestroy, puglX11GlEnter, puglX11GlLeave, - puglX11GlResize, - puglX11GlGetContext + puglStubResize, + puglStubGetContext }; return &backend; diff --git a/pugl/pugl_stub_backend.h b/pugl/pugl_stub_backend.h new file mode 100644 index 0000000..27a961b --- /dev/null +++ b/pugl/pugl_stub_backend.h @@ -0,0 +1,103 @@ +/* + Copyright 2019 David Robillard <http://drobilla.net> + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +/** + @file pugl_stub_backend.h Stub backend functions. +*/ + +#ifndef PUGL_STUB_BACKEND_H +#define PUGL_STUB_BACKEND_H + +#include "pugl/pugl.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + @name Stub backend functions + + Implementations of stub backend functions which do nothing and always return + success. These do not make for a usable backend on their own since the + platform implementation would fail to create a window, but are useful for + other backends to reuse since not all need non-trivial implementations of + every backend function. + + @{ +*/ + +static inline PuglStatus +puglStubConfigure(PuglView* view) +{ + (void)view; + return PUGL_SUCCESS; +} + +static inline PuglStatus +puglStubCreate(PuglView* view) +{ + (void)view; + return PUGL_SUCCESS; +} + +static inline PuglStatus +puglStubDestroy(PuglView* view) +{ + (void)view; + return PUGL_SUCCESS; +} + +static inline PuglStatus +puglStubEnter(PuglView* view, bool drawing) +{ + (void)view; + (void)drawing; + return PUGL_SUCCESS; +} + +static inline PuglStatus +puglStubLeave(PuglView* view, bool drawing) +{ + (void)view; + (void)drawing; + return PUGL_SUCCESS; +} + +static inline PuglStatus +puglStubResize(PuglView* view, int width, int height) +{ + (void)view; + (void)width; + (void)height; + return PUGL_SUCCESS; +} + +static inline void* +puglStubGetContext(PuglView* view) +{ + (void)view; + return NULL; +} + +/** + @} +*/ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif // PUGL_STUB_BACKEND_H |