aboutsummaryrefslogtreecommitdiffstats
path: root/pugl/detail/x11_gl.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-09-07 14:16:19 +0200
committerDavid Robillard <d@drobilla.net>2019-09-07 14:40:39 +0200
commitdc9f1d852d3fba8ddcf7bb535810ad384900fe06 (patch)
treeb3ea2e2b5be850fa3b42c476ae03f04d960b0433 /pugl/detail/x11_gl.c
parent7162fa4f5656ad7dfe2d6fea02f9f33c5aa1b1cf (diff)
downloadpugl-dc9f1d852d3fba8ddcf7bb535810ad384900fe06.tar.gz
pugl-dc9f1d852d3fba8ddcf7bb535810ad384900fe06.tar.bz2
pugl-dc9f1d852d3fba8ddcf7bb535810ad384900fe06.zip
Clean up error handling
Diffstat (limited to 'pugl/detail/x11_gl.c')
-rw-r--r--pugl/detail/x11_gl.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/pugl/detail/x11_gl.c b/pugl/detail/x11_gl.c
index b6f3c51..ea93de2 100644
--- a/pugl/detail/x11_gl.c
+++ b/pugl/detail/x11_gl.c
@@ -39,13 +39,13 @@ typedef struct {
int double_buffered;
} PuglX11GlSurface;
-static int
+static PuglStatus
puglX11GlHintValue(const int value)
{
return value == PUGL_DONT_CARE ? (int)GLX_DONT_CARE : value;
}
-static int
+static PuglStatus
puglX11GlGetAttrib(Display* const display,
const GLXFBConfig fb_config,
const int attrib)
@@ -55,7 +55,7 @@ puglX11GlGetAttrib(Display* const display,
return value;
}
-static int
+static PuglStatus
puglX11GlConfigure(PuglView* view)
{
PuglInternals* const impl = view->impl;
@@ -86,7 +86,7 @@ puglX11GlConfigure(PuglView* view)
GLXFBConfig* fbc = glXChooseFBConfig(display, screen, attrs, &n_fbc);
if (n_fbc <= 0) {
fprintf(stderr, "error: Failed to create GL context\n");
- return 1;
+ return PUGL_CREATE_CONTEXT_FAILED;
}
surface->fb_config = fbc[0];
@@ -105,10 +105,10 @@ puglX11GlConfigure(PuglView* view)
XFree(fbc);
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglX11GlCreate(PuglView* view)
{
PuglInternals* const impl = view->impl;
@@ -131,22 +131,25 @@ puglX11GlCreate(PuglView* view)
(CreateContextAttribs)glXGetProcAddress(
(const GLubyte*)"glXCreateContextAttribsARB");
- impl->surface = surface;
- surface->ctx = create_context(display, fb_config, 0, GL_TRUE, ctx_attrs);
+ surface->ctx = create_context(display, fb_config, 0, GL_TRUE, ctx_attrs);
if (!surface->ctx) {
surface->ctx =
glXCreateNewContext(display, fb_config, GLX_RGBA_TYPE, 0, True);
}
+ if (!surface->ctx) {
+ return PUGL_CREATE_CONTEXT_FAILED;
+ }
+
glXGetConfig(impl->display,
impl->vi,
GLX_DOUBLEBUFFER,
&surface->double_buffered);
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglX11GlDestroy(PuglView* view)
{
PuglX11GlSurface* surface = (PuglX11GlSurface*)view->impl->surface;
@@ -155,18 +158,18 @@ puglX11GlDestroy(PuglView* view)
free(surface);
view->impl->surface = NULL;
}
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglX11GlEnter(PuglView* view, bool PUGL_UNUSED(drawing))
{
PuglX11GlSurface* surface = (PuglX11GlSurface*)view->impl->surface;
glXMakeCurrent(view->impl->display, view->impl->win, surface->ctx);
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglX11GlLeave(PuglView* view, bool drawing)
{
PuglX11GlSurface* surface = (PuglX11GlSurface*)view->impl->surface;
@@ -179,15 +182,15 @@ puglX11GlLeave(PuglView* view, bool drawing)
glXMakeCurrent(view->impl->display, None, NULL);
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglX11GlResize(PuglView* PUGL_UNUSED(view),
int PUGL_UNUSED(width),
int PUGL_UNUSED(height))
{
- return 0;
+ return PUGL_SUCCESS;
}
static void*