aboutsummaryrefslogtreecommitdiffstats
path: root/pugl
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-09-01 22:23:47 -0400
committerDavid Robillard <d@drobilla.net>2016-09-01 22:23:47 -0400
commitddfcee0fd3e6daf7174497c6a7183d83651a5c88 (patch)
treede8b1ac8a9636dc1166690ef60e148260e136340 /pugl
parenta25ecaf03e75e61314b7271068a030b7d33eaf09 (diff)
downloadpugl-ddfcee0fd3e6daf7174497c6a7183d83651a5c88.tar.gz
pugl-ddfcee0fd3e6daf7174497c6a7183d83651a5c88.tar.bz2
pugl-ddfcee0fd3e6daf7174497c6a7183d83651a5c88.zip
Expose puglEnterContext() and puglLeaveContext()
This allows code in the main thread to set up the GL context outside the scope of a draw callback, which is useful for porting existing code that assumes the GL context can be entered anywhere.
Diffstat (limited to 'pugl')
-rw-r--r--pugl/pugl.h21
-rw-r--r--pugl/pugl_internal.h6
2 files changed, 20 insertions, 7 deletions
diff --git a/pugl/pugl.h b/pugl/pugl.h
index 0c6dd79..c376d3f 100644
--- a/pugl/pugl.h
+++ b/pugl/pugl.h
@@ -141,7 +141,7 @@ typedef void (*PuglSpecialFunc)(PuglView* view, bool press, PuglKey key);
*/
/**
- Create a Pugl context.
+ Create a Pugl view.
To create a window, call the various puglInit* functions as necessary, then
call puglCreateWindow().
@@ -310,6 +310,25 @@ PUGL_API void
puglIgnoreKeyRepeat(PuglView* view, bool ignore);
/**
+ Enter the drawing context.
+
+ This must be called before any code that accesses the drawing context,
+ including any GL functions. This is only necessary for code that does so
+ outside the usual draw callback or handling of an expose event.
+*/
+PUGL_API void
+puglEnterContext(PuglView* view);
+
+/**
+ Leave the drawing context.
+
+ This must be called after puglEnterContext and applies the results of the
+ drawing code (for example, by swapping buffers).
+*/
+PUGL_API void
+puglLeaveContext(PuglView* view, bool flush);
+
+/**
@name Event Callbacks
Functions to set event callbacks for handling user input.
@{
diff --git a/pugl/pugl_internal.h b/pugl/pugl_internal.h
index 9566c6f..d9dfdfa 100644
--- a/pugl/pugl_internal.h
+++ b/pugl/pugl_internal.h
@@ -253,12 +253,6 @@ puglSetSpecialFunc(PuglView* view, PuglSpecialFunc specialFunc)
view->specialFunc = specialFunc;
}
-void
-puglEnterContext(PuglView* view);
-
-void
-puglLeaveContext(PuglView* view, bool flush);
-
/** Return the code point for buf, or the replacement character on error. */
static uint32_t
puglDecodeUTF8(const uint8_t* buf)