aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bindings/cxx/include/pugl/gl.hpp15
-rw-r--r--include/pugl/gl.h18
-rw-r--r--include/pugl/pugl.h30
-rw-r--r--src/implementation.c12
-rw-r--r--src/mac_gl.m12
-rw-r--r--src/win_gl.c12
-rw-r--r--src/x11_gl.c12
7 files changed, 69 insertions, 42 deletions
diff --git a/bindings/cxx/include/pugl/gl.hpp b/bindings/cxx/include/pugl/gl.hpp
index ba7143b..529babb 100644
--- a/bindings/cxx/include/pugl/gl.hpp
+++ b/bindings/cxx/include/pugl/gl.hpp
@@ -24,6 +24,7 @@
#include "pugl/gl.h"
#include "pugl/pugl.h"
+#include "pugl/pugl.hpp"
namespace pugl {
@@ -44,6 +45,20 @@ getProcAddress(const char* name) noexcept
return puglGetProcAddress(name);
}
+/// @copydoc puglEnterContext
+inline Status
+enterContext(View& view) noexcept
+{
+ return static_cast<Status>(puglEnterContext(view.cobj()));
+}
+
+/// @copydoc puglLeaveContext
+inline Status
+leaveContext(View& view) noexcept
+{
+ return static_cast<Status>(puglLeaveContext(view.cobj()));
+}
+
/// @copydoc puglGlBackend
inline const PuglBackend*
glBackend() noexcept
diff --git a/include/pugl/gl.h b/include/pugl/gl.h
index 36b2887..79cb6e9 100644
--- a/include/pugl/gl.h
+++ b/include/pugl/gl.h
@@ -74,6 +74,24 @@ PUGL_API PuglGlFunc
puglGetProcAddress(const char* name);
/**
+ Enter the OpenGL 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.
+*/
+PUGL_API PuglStatus
+puglEnterContext(PuglView* view);
+
+/**
+ Leave the OpenGL context.
+
+ This must only be called after puglEnterContext().
+*/
+PUGL_API PuglStatus
+puglLeaveContext(PuglView* view);
+
+/**
OpenGL graphics backend.
Pass the returned value to puglSetBackend() to draw to a view with OpenGL.
diff --git a/include/pugl/pugl.h b/include/pugl/pugl.h
index 4018c45..30d92c6 100644
--- a/include/pugl/pugl.h
+++ b/include/pugl/pugl.h
@@ -1064,36 +1064,6 @@ 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.
- - Vulkan: 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.
- - Vulkan: 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
diff --git a/src/implementation.c b/src/implementation.c
index 88794f2..35c4c26 100644
--- a/src/implementation.c
+++ b/src/implementation.c
@@ -292,18 +292,6 @@ puglDispatchEvents(PuglWorld* world)
#endif
PuglStatus
-puglEnterContext(PuglView* view)
-{
- return view->backend->enter(view, NULL);
-}
-
-PuglStatus
-puglLeaveContext(PuglView* view)
-{
- return view->backend->leave(view, NULL);
-}
-
-PuglStatus
puglSetEventFunc(PuglView* view, PuglEventFunc eventFunc)
{
view->eventFunc = eventFunc;
diff --git a/src/mac_gl.m b/src/mac_gl.m
index f8847c0..8a48578 100644
--- a/src/mac_gl.m
+++ b/src/mac_gl.m
@@ -189,6 +189,18 @@ puglGetProcAddress(const char *name)
return func;
}
+PuglStatus
+puglEnterContext(PuglView* view)
+{
+ return view->backend->enter(view, NULL);
+}
+
+PuglStatus
+puglLeaveContext(PuglView* view)
+{
+ return view->backend->leave(view, NULL);
+}
+
const PuglBackend*
puglGlBackend(void)
{
diff --git a/src/win_gl.c b/src/win_gl.c
index e46ece8..662baef 100644
--- a/src/win_gl.c
+++ b/src/win_gl.c
@@ -310,6 +310,18 @@ puglGetProcAddress(const char* name)
: (PuglGlFunc)GetProcAddress(GetModuleHandle("opengl32.dll"), name);
}
+PuglStatus
+puglEnterContext(PuglView* view)
+{
+ return view->backend->enter(view, NULL);
+}
+
+PuglStatus
+puglLeaveContext(PuglView* view)
+{
+ return view->backend->leave(view, NULL);
+}
+
const PuglBackend*
puglGlBackend(void)
{
diff --git a/src/x11_gl.c b/src/x11_gl.c
index 34ac7e8..64061d1 100644
--- a/src/x11_gl.c
+++ b/src/x11_gl.c
@@ -209,6 +209,18 @@ puglGetProcAddress(const char* name)
return glXGetProcAddress((const uint8_t*)name);
}
+PuglStatus
+puglEnterContext(PuglView* view)
+{
+ return view->backend->enter(view, NULL);
+}
+
+PuglStatus
+puglLeaveContext(PuglView* view)
+{
+ return view->backend->leave(view, NULL);
+}
+
const PuglBackend*
puglGlBackend(void)
{