aboutsummaryrefslogtreecommitdiffstats
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
parent7162fa4f5656ad7dfe2d6fea02f9f33c5aa1b1cf (diff)
downloadpugl-dc9f1d852d3fba8ddcf7bb535810ad384900fe06.tar.gz
pugl-dc9f1d852d3fba8ddcf7bb535810ad384900fe06.tar.bz2
pugl-dc9f1d852d3fba8ddcf7bb535810ad384900fe06.zip
Clean up error handling
-rw-r--r--pugl/detail/implementation.c2
-rw-r--r--pugl/detail/mac_cairo.m28
-rw-r--r--pugl/detail/mac_gl.m24
-rw-r--r--pugl/detail/types.h12
-rw-r--r--pugl/detail/win.c18
-rw-r--r--pugl/detail/win.h4
-rw-r--r--pugl/detail/win_cairo.c4
-rw-r--r--pugl/detail/win_gl.c43
-rw-r--r--pugl/detail/x11.c20
-rw-r--r--pugl/detail/x11_cairo.c28
-rw-r--r--pugl/detail/x11_gl.c37
-rw-r--r--pugl/pugl.h17
12 files changed, 123 insertions, 114 deletions
diff --git a/pugl/detail/implementation.c b/pugl/detail/implementation.c
index f1fd57a..6375444 100644
--- a/pugl/detail/implementation.c
+++ b/pugl/detail/implementation.c
@@ -306,7 +306,7 @@ puglSetInternalClipboard(PuglView* const view,
const size_t len)
{
if (type && strcmp(type, "text/plain")) {
- return PUGL_ERR_UNSUPPORTED_TYPE;
+ return PUGL_UNSUPPORTED_TYPE;
}
puglSetBlob(&view->clipboard, data, len);
diff --git a/pugl/detail/mac_cairo.m b/pugl/detail/mac_cairo.m
index fcb4f07..143fbb0 100644
--- a/pugl/detail/mac_cairo.m
+++ b/pugl/detail/mac_cairo.m
@@ -61,13 +61,13 @@
@end
-static int
+static PuglStatus
puglMacCairoConfigure(PuglView* PUGL_UNUSED(view))
{
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglMacCairoCreate(PuglView* view)
{
PuglInternals* impl = view->impl;
@@ -82,10 +82,10 @@ puglMacCairoCreate(PuglView* view)
}
impl->drawView = drawView;
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglMacCairoDestroy(PuglView* view)
{
PuglCairoView* const drawView = (PuglCairoView*)view->impl->drawView;
@@ -94,15 +94,15 @@ puglMacCairoDestroy(PuglView* view)
[drawView release];
view->impl->drawView = nil;
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglMacCairoEnter(PuglView* view, bool drawing)
{
PuglCairoView* const drawView = (PuglCairoView*)view->impl->drawView;
if (!drawing) {
- return 0;
+ return PUGL_SUCCESS;
}
assert(!drawView->surface);
@@ -115,15 +115,15 @@ puglMacCairoEnter(PuglView* view, bool drawing)
drawView->cr = cairo_create(drawView->surface);
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglMacCairoLeave(PuglView* view, bool drawing)
{
PuglCairoView* const drawView = (PuglCairoView*)view->impl->drawView;
if (!drawing) {
- return 0;
+ return PUGL_SUCCESS;
}
assert(drawView->surface);
@@ -138,16 +138,16 @@ puglMacCairoLeave(PuglView* view, bool drawing)
CGContextFlush(context);
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglMacCairoResize(PuglView* PUGL_UNUSED(view),
int PUGL_UNUSED(width),
int PUGL_UNUSED(height))
{
// No need to resize, the surface is created for the drawing context
- return 0;
+ return PUGL_SUCCESS;
}
static void*
diff --git a/pugl/detail/mac_gl.m b/pugl/detail/mac_gl.m
index 58d815d..b84f799 100644
--- a/pugl/detail/mac_gl.m
+++ b/pugl/detail/mac_gl.m
@@ -93,13 +93,13 @@ typedef NSUInteger NSWindowStyleMask;
@end
-static int
+static PuglStatus
puglMacGlConfigure(PuglView* PUGL_UNUSED(view))
{
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglMacGlCreate(PuglView* view)
{
PuglInternals* impl = view->impl;
@@ -116,10 +116,10 @@ puglMacGlCreate(PuglView* view)
}
impl->drawView = drawView;
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglMacGlDestroy(PuglView* view)
{
PuglOpenGLView* const drawView = (PuglOpenGLView*)view->impl->drawView;
@@ -128,19 +128,19 @@ puglMacGlDestroy(PuglView* view)
[drawView release];
view->impl->drawView = nil;
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglMacGlEnter(PuglView* view, bool PUGL_UNUSED(drawing))
{
PuglOpenGLView* const drawView = (PuglOpenGLView*)view->impl->drawView;
[[drawView openGLContext] makeCurrentContext];
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglMacGlLeave(PuglView* view, bool drawing)
{
PuglOpenGLView* const drawView = (PuglOpenGLView*)view->impl->drawView;
@@ -151,17 +151,17 @@ puglMacGlLeave(PuglView* view, bool drawing)
[NSOpenGLContext clearCurrentContext];
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglMacGlResize(PuglView* view, int PUGL_UNUSED(width), int PUGL_UNUSED(height))
{
PuglOpenGLView* const drawView = (PuglOpenGLView*)view->impl->drawView;
[drawView reshape];
- return 0;
+ return PUGL_SUCCESS;
}
static void*
diff --git a/pugl/detail/types.h b/pugl/detail/types.h
index 4ac224b..d018be5 100644
--- a/pugl/detail/types.h
+++ b/pugl/detail/types.h
@@ -89,22 +89,22 @@ typedef void PuglSurface;
/** Graphics backend interface. */
struct PuglBackendImpl {
/** Get visual information from display and setup view as necessary. */
- int (*configure)(PuglView*);
+ PuglStatus (*configure)(PuglView*);
/** Create surface and drawing context. */
- int (*create)(PuglView*);
+ PuglStatus (*create)(PuglView*);
/** Destroy surface and drawing context. */
- int (*destroy)(PuglView*);
+ PuglStatus (*destroy)(PuglView*);
/** Enter drawing context, for drawing if parameter is true. */
- int (*enter)(PuglView*, bool);
+ PuglStatus (*enter)(PuglView*, bool);
/** Leave drawing context, after drawing if parameter is true. */
- int (*leave)(PuglView*, bool);
+ PuglStatus (*leave)(PuglView*, bool);
/** Resize drawing context to the given width and height. */
- int (*resize)(PuglView*, int, int);
+ PuglStatus (*resize)(PuglView*, int, int);
/** Return the puglGetContext() handle for the application, if any. */
void* (*getContext)(PuglView*);
diff --git a/pugl/detail/win.c b/pugl/detail/win.c
index 25780e0..90c133f 100644
--- a/pugl/detail/win.c
+++ b/pugl/detail/win.c
@@ -163,18 +163,18 @@ puglCreateWindow(PuglView* view, const char* title)
// Register window class if necessary
if (!puglRegisterWindowClass(view->world->className)) {
- return PUGL_ERR_UNKNOWN;
+ return PUGL_REGISTRATION_FAILED;
}
if (!view->backend || !view->backend->configure) {
- return PUGL_ERR_UNKNOWN;
+ return PUGL_BAD_BACKEND;
}
- int st = view->backend->configure(view);
+ PuglStatus st = view->backend->configure(view);
if (st || !impl->surface) {
- return PUGL_ERR_SET_FORMAT;
+ return PUGL_SET_FORMAT_FAILED;
} else if ((st = view->backend->create(view))) {
- return PUGL_ERR_CREATE_CONTEXT;
+ return PUGL_CREATE_CONTEXT_FAILED;
}
if (title) {
@@ -828,7 +828,7 @@ puglSetFrame(PuglView* view, const PuglRect frame)
rect.left, rect.top,
rect.right - rect.left, rect.bottom - rect.top,
(SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER))) {
- return PUGL_ERR_UNKNOWN;
+ return PUGL_UNKNOWN_ERROR;
}
}
@@ -896,7 +896,7 @@ puglSetClipboard(PuglView* const view,
if (st) {
return st;
} else if (!OpenClipboard(impl->hwnd)) {
- return PUGL_ERR_UNKNOWN;
+ return PUGL_UNKNOWN_ERROR;
}
// Measure string and allocate global memory for clipboard
@@ -905,7 +905,7 @@ puglSetClipboard(PuglView* const view,
HGLOBAL mem = GlobalAlloc(GMEM_MOVEABLE, (wlen + 1) * sizeof(wchar_t));
if (!mem) {
CloseClipboard();
- return PUGL_ERR_UNKNOWN;
+ return PUGL_UNKNOWN_ERROR;
}
// Lock global memory
@@ -913,7 +913,7 @@ puglSetClipboard(PuglView* const view,
if (!wstr) {
GlobalFree(mem);
CloseClipboard();
- return PUGL_ERR_UNKNOWN;
+ return PUGL_UNKNOWN_ERROR;
}
// Convert string into global memory and set it as clipboard data
diff --git a/pugl/detail/win.h b/pugl/detail/win.h
index b9e554c..6d89759 100644
--- a/pugl/detail/win.h
+++ b/pugl/detail/win.h
@@ -104,11 +104,11 @@ puglWinCreateWindow(const PuglView* const view,
CW_USEDEFAULT, CW_USEDEFAULT,
wr.right-wr.left, wr.bottom-wr.top,
(HWND)view->parent, NULL, NULL, NULL))) {
- return PUGL_ERR_CREATE_WINDOW;
+ return PUGL_CREATE_WINDOW_FAILED;
} else if (!(*hdc = GetDC(*hwnd))) {
DestroyWindow(*hwnd);
*hwnd = NULL;
- return PUGL_ERR_CREATE_WINDOW;
+ return PUGL_CREATE_WINDOW_FAILED;
}
return PUGL_SUCCESS;
diff --git a/pugl/detail/win_cairo.c b/pugl/detail/win_cairo.c
index cbca7e8..741f4cf 100644
--- a/pugl/detail/win_cairo.c
+++ b/pugl/detail/win_cairo.c
@@ -51,7 +51,7 @@ puglWinCairoCreateDrawContext(PuglView* view)
(st = cairo_surface_status(surface->surface)) ||
!(surface->cr = cairo_create(surface->surface)) ||
(st = cairo_status(surface->cr))) {
- return PUGL_ERR_CREATE_CONTEXT;
+ return PUGL_CREATE_CONTEXT_FAILED;
}
cairo_save(surface->cr);
@@ -95,7 +95,7 @@ puglWinCairoConfigure(PuglView* view)
DestroyWindow(impl->hwnd);
impl->hwnd = NULL;
impl->hdc = NULL;
- return PUGL_ERR_SET_FORMAT;
+ return PUGL_SET_FORMAT_FAILED;
}
impl->surface = (PuglWinCairoSurface*)calloc(
diff --git a/pugl/detail/win_gl.c b/pugl/detail/win_gl.c
index b7b03a4..db8fee5 100644
--- a/pugl/detail/win_gl.c
+++ b/pugl/detail/win_gl.c
@@ -77,8 +77,8 @@ typedef struct {
HDC hdc;
} PuglFakeWindow;
-static int
-puglWinError(PuglFakeWindow* fakeWin, const int status)
+static PuglStatus
+puglWinError(PuglFakeWindow* fakeWin, const PuglStatus status)
{
if (fakeWin->hwnd) {
ReleaseDC(fakeWin->hwnd, fakeWin->hdc);
@@ -102,7 +102,7 @@ static PuglWinGlProcs puglWinGlGetProcs(void)
return procs;
}
-static int
+static PuglStatus
puglWinGlConfigure(PuglView* view)
{
PuglInternals* impl = view->impl;
@@ -140,15 +140,15 @@ puglWinGlConfigure(PuglView* view)
const PuglWinPFD fakePfd = puglWinGetPixelFormatDescriptor(view->hints);
const int fakePfId = ChoosePixelFormat(fakeWin.hdc, &fakePfd);
if (!fakePfId) {
- return puglWinError(&fakeWin, PUGL_ERR_SET_FORMAT);
+ return puglWinError(&fakeWin, PUGL_SET_FORMAT_FAILED);
} else if (!SetPixelFormat(fakeWin.hdc, fakePfId, &fakePfd)) {
- return puglWinError(&fakeWin, PUGL_ERR_SET_FORMAT);
+ return puglWinError(&fakeWin, PUGL_SET_FORMAT_FAILED);
}
// Create fake GL context to get at the functions we need
HGLRC fakeRc = wglCreateContext(fakeWin.hdc);
if (!fakeRc) {
- return puglWinError(&fakeWin, PUGL_ERR_CREATE_CONTEXT);
+ return puglWinError(&fakeWin, PUGL_CREATE_CONTEXT_FAILED);
}
// Enter fake context and get extension functions
@@ -160,7 +160,7 @@ puglWinGlConfigure(PuglView* view)
UINT numFormats = 0;
if (!surface->procs.wglChoosePixelFormat(
fakeWin.hdc, pixelAttrs, NULL, 1u, &impl->pfId, &numFormats)) {
- return puglWinError(&fakeWin, PUGL_ERR_SET_FORMAT);
+ return puglWinError(&fakeWin, PUGL_SET_FORMAT_FAILED);
}
DescribePixelFormat(
@@ -177,10 +177,10 @@ puglWinGlConfigure(PuglView* view)
ReleaseDC(fakeWin.hwnd, fakeWin.hdc);
DestroyWindow(fakeWin.hwnd);
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglWinGlCreate(PuglView* view)
{
PuglInternals* const impl = view->impl;
@@ -205,16 +205,16 @@ puglWinGlCreate(PuglView* view)
DestroyWindow(impl->hwnd);
impl->hwnd = NULL;
impl->hdc = NULL;
- return PUGL_ERR_SET_FORMAT;
+ return PUGL_SET_FORMAT_FAILED;
}
// Create GL context
if (surface->procs.wglCreateContextAttribs &&
!(surface->hglrc = surface->procs.wglCreateContextAttribs(
impl->hdc, 0, contextAttribs))) {
- return PUGL_ERR_CREATE_CONTEXT;
+ return PUGL_CREATE_CONTEXT_FAILED;
} else if (!(surface->hglrc = wglCreateContext(impl->hdc))) {
- return PUGL_ERR_CREATE_CONTEXT;
+ return PUGL_CREATE_CONTEXT_FAILED;
}
// Enter context and set swap interval
@@ -223,10 +223,10 @@ puglWinGlCreate(PuglView* view)
surface->procs.wglSwapInterval(view->hints[PUGL_SWAP_INTERVAL]);
}
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglWinGlDestroy(PuglView* view)
{
PuglWinGlSurface* surface = (PuglWinGlSurface*)view->impl->surface;
@@ -237,10 +237,10 @@ puglWinGlDestroy(PuglView* view)
view->impl->surface = NULL;
}
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglWinGlEnter(PuglView* view, bool drawing)
{
PuglWinGlSurface* surface = (PuglWinGlSurface*)view->impl->surface;
@@ -252,10 +252,10 @@ puglWinGlEnter(PuglView* view, bool drawing)
BeginPaint(view->impl->hwnd, &ps);
}
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglWinGlLeave(PuglView* view, bool drawing)
{
if (drawing) {
@@ -265,16 +265,15 @@ puglWinGlLeave(PuglView* view, bool drawing)
}
wglMakeCurrent(NULL, NULL);
-
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglWinGlResize(PuglView* PUGL_UNUSED(view),
int PUGL_UNUSED(width),
int PUGL_UNUSED(height))
{
- return 0;
+ return PUGL_SUCCESS;
}
static void*
diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c
index adf8c9d..429d89f 100644
--- a/pugl/detail/x11.c
+++ b/pugl/detail/x11.c
@@ -127,7 +127,8 @@ puglPollEvents(PuglWorld* world, const double timeout)
ret = select(nfds, &fds, NULL, NULL, &tv);
}
- return ret < 0 ? PUGL_ERR_UNKNOWN : ret == 0 ? PUGL_FAILURE : PUGL_SUCCESS;
+ return ret < 0 ? PUGL_UNKNOWN_ERROR
+ : ret == 0 ? PUGL_FAILURE : PUGL_SUCCESS;
}
static PuglView*
@@ -185,10 +186,13 @@ puglCreateWindow(PuglView* view, const char* title)
impl->screen = DefaultScreen(display);
if (!view->backend || !view->backend->configure) {
- return 1;
- } else if (view->backend->configure(view) || !impl->vi) {
+ return PUGL_BAD_BACKEND;
+ }
+
+ PuglStatus st = view->backend->configure(view);
+ if (st || !impl->vi) {
view->backend->destroy(view);
- return 2;
+ return st ? st : PUGL_BACKEND_FAILED;
}
Window xParent = view->parent ? (Window)view->parent
@@ -207,8 +211,8 @@ puglCreateWindow(PuglView* view, const char* title)
0, impl->vi->depth, InputOutput,
impl->vi->visual, CWColormap | CWEventMask, &attr);
- if (view->backend->create(view)) {
- return 3;
+ if ((st = view->backend->create(view))) {
+ return st;
}
XSizeHints sizeHints = getSizeHints(view);
@@ -239,7 +243,7 @@ puglCreateWindow(PuglView* view, const char* title)
fprintf(stderr, "warning: XCreateIC failed\n");
}
- return 0;
+ return PUGL_SUCCESS;
}
PuglStatus
@@ -793,7 +797,7 @@ puglSetFrame(PuglView* view, const PuglRect frame)
XMoveResizeWindow(view->world->impl->display, view->impl->win,
(int)frame.x, (int)frame.y,
(int)frame.width, (int)frame.height)) {
- return PUGL_ERR_UNKNOWN;
+ return PUGL_UNKNOWN_ERROR;
}
return PUGL_SUCCESS;
diff --git a/pugl/detail/x11_cairo.c b/pugl/detail/x11_cairo.c
index 550144a..0753317 100644
--- a/pugl/detail/x11_cairo.c
+++ b/pugl/detail/x11_cairo.c
@@ -38,7 +38,7 @@ typedef struct {
cairo_t* frontCr;
} PuglX11CairoSurface;
-static int
+static PuglStatus
puglX11CairoConfigure(PuglView* view)
{
PuglInternals* const impl = view->impl;
@@ -48,10 +48,10 @@ puglX11CairoConfigure(PuglView* view)
pat.screen = impl->screen;
impl->vi = XGetVisualInfo(impl->display, VisualScreenMask, &pat, &n);
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglX11CairoCreate(PuglView* view)
{
PuglInternals* const impl = view->impl;
@@ -77,16 +77,16 @@ puglX11CairoCreate(PuglView* view)
cairo_destroy(surface.backCr);
cairo_surface_destroy(surface.front);
cairo_surface_destroy(surface.back);
- return PUGL_ERR_CREATE_CONTEXT;
+ return PUGL_CREATE_CONTEXT_FAILED;
}
impl->surface = calloc(1, sizeof(PuglX11CairoSurface));
*(PuglX11CairoSurface*)impl->surface = surface;
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglX11CairoDestroy(PuglView* view)
{
PuglInternals* const impl = view->impl;
@@ -98,10 +98,10 @@ puglX11CairoDestroy(PuglView* view)
cairo_surface_destroy(surface->back);
free(surface);
impl->surface = NULL;
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglX11CairoEnter(PuglView* view, bool drawing)
{
PuglInternals* const impl = view->impl;
@@ -111,10 +111,10 @@ puglX11CairoEnter(PuglView* view, bool drawing)
cairo_save(surface->frontCr);
}
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglX11CairoLeave(PuglView* view, bool drawing)
{
PuglInternals* const impl = view->impl;
@@ -126,10 +126,10 @@ puglX11CairoLeave(PuglView* view, bool drawing)
cairo_restore(surface->frontCr);
}
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglX11CairoResize(PuglView* view, int width, int height)
{
PuglInternals* const impl = view->impl;
@@ -141,13 +141,13 @@ puglX11CairoResize(PuglView* view, int width, int height)
cairo_surface_destroy(surface->front);
if (!(surface->front = cairo_surface_create_similar(
surface->back, CAIRO_CONTENT_COLOR, width, height))) {
- return PUGL_ERR_CREATE_CONTEXT;
+ return PUGL_CREATE_CONTEXT_FAILED;
}
surface->frontCr = cairo_create(surface->front);
cairo_save(surface->frontCr);
- return 0;
+ return PUGL_SUCCESS;
}
static void*
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*
diff --git a/pugl/pugl.h b/pugl/pugl.h
index 580e9dc..067d780 100644
--- a/pugl/pugl.h
+++ b/pugl/pugl.h
@@ -80,13 +80,16 @@ typedef void* PuglHandle;
Return status code.
*/
typedef enum {
- PUGL_SUCCESS,
- PUGL_FAILURE,
- PUGL_ERR_UNKNOWN,
- PUGL_ERR_CREATE_WINDOW,
- PUGL_ERR_SET_FORMAT,
- PUGL_ERR_CREATE_CONTEXT,
- PUGL_ERR_UNSUPPORTED_TYPE,
+ PUGL_SUCCESS, /**< Success */
+ PUGL_FAILURE, /**< Non-fatal failure */
+ PUGL_UNKNOWN_ERROR, /**< Unknown system error */
+ PUGL_BAD_BACKEND, /**< Invalid or missing backend */
+ PUGL_BACKEND_FAILED, /**< Backend initialisation failed */
+ PUGL_REGISTRATION_FAILED, /**< Window class registration failed */
+ PUGL_CREATE_WINDOW_FAILED, /**< Window creation failed */
+ PUGL_SET_FORMAT_FAILED, /**< Failed to set pixel format */
+ PUGL_CREATE_CONTEXT_FAILED, /**< Failed to create drawing context */
+ PUGL_UNSUPPORTED_TYPE, /**< Unsupported data type */
} PuglStatus;
/**