diff options
-rw-r--r-- | include/pugl/detail/implementation.c | 22 | ||||
-rw-r--r-- | include/pugl/pugl.h | 61 |
2 files changed, 34 insertions, 49 deletions
diff --git a/include/pugl/detail/implementation.c b/include/pugl/detail/implementation.c index 6a5f932..e9a3450 100644 --- a/include/pugl/detail/implementation.c +++ b/include/pugl/detail/implementation.c @@ -331,30 +331,20 @@ puglDispatchEvents(PuglWorld* world) return puglUpdate(world, 0.0); } +#endif + PuglStatus -puglEnterContext(PuglView* view, bool drawing) +puglEnterContext(PuglView* view) { - const PuglEventExpose expose = { - PUGL_EXPOSE, 0, 0.0, 0.0, view->frame.width, view->frame.height}; - - view->backend->enter(view, drawing ? &expose : NULL); - - return PUGL_SUCCESS; + return view->backend->enter(view, NULL); } PuglStatus -puglLeaveContext(PuglView* view, bool drawing) +puglLeaveContext(PuglView* view) { - const PuglEventExpose expose = { - PUGL_EXPOSE, 0, 0.0, 0.0, view->frame.width, view->frame.height}; - - view->backend->leave(view, drawing ? &expose : NULL); - - return PUGL_SUCCESS; + return view->backend->leave(view, NULL); } -#endif - PuglStatus puglSetEventFunc(PuglView* view, PuglEventFunc eventFunc) { diff --git a/include/pugl/pugl.h b/include/pugl/pugl.h index 13c0b22..96482c1 100644 --- a/include/pugl/pugl.h +++ b/include/pugl/pugl.h @@ -1121,6 +1121,34 @@ puglGetNativeWindow(PuglView* view); */ /** + Enter the graphics context. + + This can be used to enter the graphics context in unusual situations, for + doing things like loading textures. Note that this must not be used for + drawing, which may only be done while processing an expose event. Note also + that initial setup should not use this, but instead be done while handling a + #PUGL_CREATE event. + + - Cairo: Does nothing. + - OpenGL: Sets the current OpenGL context. + - Stub: Does nothing. +*/ +PUGL_API PuglStatus +puglEnterContext(PuglView* view); + +/** + Leave the graphics context. + + This must only be called after puglEnterContext(). + + - Cairo: Does nothing. + - OpenGL: Resets the current OpenGL context. + - Stub: Does nothing. +*/ +PUGL_API PuglStatus +puglLeaveContext(PuglView* view); + +/** Get the graphics context. This is a backend-specific context used for drawing if the backend graphics @@ -1575,39 +1603,6 @@ puglPollEvents(PuglWorld* world, double timeout); PUGL_API PUGL_DEPRECATED_BY("puglUpdate") PuglStatus puglDispatchEvents(PuglWorld* world); -/** - Enter the graphics context. - - Note that, unlike some similar libraries, Pugl automatically enters and - leaves the graphics context when required and application should not - normally do this. Drawing in Pugl is only allowed during the processing of - an expose event. - - However, this can be used to enter the graphics context elsewhere, for - example to call any GL functions during setup. - - @param view The view being entered. - @param drawing If true, prepare for drawing. - - @deprecated Set up graphics when a #PUGL_CREATE event is received. -*/ -PUGL_API PUGL_DEPRECATED_BY("PUGL_CREATE") PuglStatus -puglEnterContext(PuglView* view, bool drawing); - -/** - Leave the graphics context. - - This must be called after puglEnterContext() with a matching `drawing` - parameter. - - @param view The view being left. - @param drawing If true, finish drawing, for example by swapping buffers. - - @deprecated Shut down graphics when a #PUGL_DESTROY event is received. -*/ -PUGL_API PUGL_DEPRECATED_BY("PUGL_DESTROY") PuglStatus -puglLeaveContext(PuglView* view, bool drawing); - #endif // PUGL_DISABLE_DEPRECATED /** |