diff options
author | David Robillard <d@drobilla.net> | 2019-07-27 00:59:16 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-07-29 01:59:15 +0200 |
commit | 5049953041cbc9592f0470eb185e1448b69835d6 (patch) | |
tree | 8752948797a3cb00fb411b97902517e0dee625ac /pugl/pugl.h | |
parent | 657a30d29edbf28c2d12788114c988156cfd6996 (diff) | |
download | pugl-5049953041cbc9592f0470eb185e1448b69835d6.tar.gz pugl-5049953041cbc9592f0470eb185e1448b69835d6.tar.bz2 pugl-5049953041cbc9592f0470eb185e1448b69835d6.zip |
Completely separate backends from platform implementation
This removes PuglContextType and allows the user to pass a backend directly.
Normally this would come from one of the two accessors declared in the headers,
but it would be possible to add backends without changing any of the existing
code at all.
Unfortunately, it is not possible to preserve backwards compatibility and
achieve the ultimate goal of linking only to the required dependencies, so
puglInitContextType() has just been removed.
Diffstat (limited to 'pugl/pugl.h')
-rw-r--r-- | pugl/pugl.h | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/pugl/pugl.h b/pugl/pugl.h index b88392b..7e6036f 100644 --- a/pugl/pugl.h +++ b/pugl/pugl.h @@ -94,14 +94,6 @@ typedef enum { } PuglStatus; /** - Drawing context type. -*/ -typedef enum { - PUGL_GL = 1 << 0, /**< OpenGL (3D) */ - PUGL_CAIRO = 1 << 1 /**< Cairo (2D) */ -} PuglContextType; - -/** Window hint. */ typedef enum { @@ -503,10 +495,15 @@ PUGL_API void puglInitTransientFor(PuglView* view, uintptr_t parent); /** - Set the context type before creating a window. + Set the graphics backend to use. + + This needs to be called once before creating the window to set the graphics + backend. There are two backend accessors included with pugl: + puglGlBackend() and puglCairoBackend(), declared in pugl_gl_backend.h and + pugl_cairo_backend.h, respectively. */ -PUGL_API void -puglInitContextType(PuglView* view, PuglContextType type); +PUGL_API int +puglInitBackend(PuglView* view, const PuglBackend* backend); /** @} @@ -581,8 +578,10 @@ puglGetSize(PuglView* view, int* width, int* height); /** Get the drawing context. - For PUGL_GL contexts, this is unused and returns NULL. - For PUGL_CAIRO contexts, this returns a pointer to a cairo_t. + The context is only guaranteed to be available during an expose. + + For OpenGL backends, this is unused and returns NULL. + For Cairo backends, this returns a pointer to a `cairo_t`. */ PUGL_API void* puglGetContext(PuglView* view); |