aboutsummaryrefslogtreecommitdiff
path: root/src/egl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/egl.c')
-rw-r--r--src/egl.c59
1 files changed, 28 insertions, 31 deletions
diff --git a/src/egl.c b/src/egl.c
index dbc8928..325a06f 100644
--- a/src/egl.c
+++ b/src/egl.c
@@ -57,7 +57,10 @@ static bool gsr_egl_create_window(gsr_egl *self) {
goto fail;
}
- self->eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context);
+ if(!self->eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context)) {
+ fprintf(stderr, "gsr error: gsr_egl_create_window failed: failed to make context current\n");
+ goto fail;
+ }
self->egl_display = egl_display;
self->egl_surface = egl_surface;
@@ -79,6 +82,7 @@ static bool gsr_egl_create_window(gsr_egl *self) {
static bool gsr_egl_load_egl(gsr_egl *self, void *library) {
dlsym_assign required_dlsym[] = {
+ { (void**)&self->eglGetError, "eglGetError" },
{ (void**)&self->eglGetDisplay, "eglGetDisplay" },
{ (void**)&self->eglInitialize, "eglInitialize" },
{ (void**)&self->eglTerminate, "eglTerminate" },
@@ -182,52 +186,45 @@ bool gsr_egl_load(gsr_egl *self, Display *dpy) {
memset(self, 0, sizeof(gsr_egl));
self->dpy = dpy;
+ void *egl_lib = NULL;
+ void *gl_lib = NULL;
+
dlerror(); /* clear */
- void *egl_lib = dlopen("libEGL.so.1", RTLD_LAZY);
+ egl_lib = dlopen("libEGL.so.1", RTLD_LAZY);
if(!egl_lib) {
fprintf(stderr, "gsr error: gsr_egl_load: failed to load libEGL.so.1, error: %s\n", dlerror());
- return false;
+ goto fail;
}
- void *gl_lib = dlopen("libGL.so.1", RTLD_LAZY);
+ gl_lib = dlopen("libGL.so.1", RTLD_LAZY);
if(!egl_lib) {
fprintf(stderr, "gsr error: gsr_egl_load: failed to load libGL.so.1, error: %s\n", dlerror());
- dlclose(egl_lib);
- memset(self, 0, sizeof(gsr_egl));
- return false;
+ goto fail;
}
- if(!gsr_egl_load_egl(self, egl_lib)) {
- dlclose(egl_lib);
- dlclose(gl_lib);
- memset(self, 0, sizeof(gsr_egl));
- return false;
- }
+ if(!gsr_egl_load_egl(self, egl_lib))
+ goto fail;
- if(!gsr_egl_load_gl(self, gl_lib)) {
- dlclose(egl_lib);
- dlclose(gl_lib);
- memset(self, 0, sizeof(gsr_egl));
- return false;
- }
+ if(!gsr_egl_load_gl(self, gl_lib))
+ goto fail;
- if(!gsr_egl_proc_load_egl(self)) {
- dlclose(egl_lib);
- dlclose(gl_lib);
- memset(self, 0, sizeof(gsr_egl));
- return false;
- }
+ if(!gsr_egl_proc_load_egl(self))
+ goto fail;
- if(!gsr_egl_create_window(self)) {
- dlclose(egl_lib);
- dlclose(gl_lib);
- memset(self, 0, sizeof(gsr_egl));
- return false;
- }
+ if(!gsr_egl_create_window(self))
+ goto fail;
self->egl_library = egl_lib;
self->gl_library = gl_lib;
return true;
+
+ fail:
+ if(egl_lib)
+ dlclose(egl_lib);
+ if(gl_lib)
+ dlclose(gl_lib);
+ memset(self, 0, sizeof(gsr_egl));
+ return false;
}
void gsr_egl_unload(gsr_egl *self) {