aboutsummaryrefslogtreecommitdiffstats
path: root/pugl/detail/win_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/win_gl.c
parent7162fa4f5656ad7dfe2d6fea02f9f33c5aa1b1cf (diff)
downloadpugl-dc9f1d852d3fba8ddcf7bb535810ad384900fe06.tar.gz
pugl-dc9f1d852d3fba8ddcf7bb535810ad384900fe06.tar.bz2
pugl-dc9f1d852d3fba8ddcf7bb535810ad384900fe06.zip
Clean up error handling
Diffstat (limited to 'pugl/detail/win_gl.c')
-rw-r--r--pugl/detail/win_gl.c43
1 files changed, 21 insertions, 22 deletions
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*