gl_3_2 = 2
} gl_version;
+int check_gl(void);
+
void check_gl_log(gl_log_level level, const char *format, ...);
int check_gl_init(void);
-int check_gl(void);
+void check_gl_cleanup(void);
struct gl_context *check_gl_context_create(struct gl_context *share_ctx,
gl_version version);
return 1;
}
+void check_gl_cleanup(void)
+{
+}
+
struct gl_context *check_gl_context_create(struct gl_context *share_ctx,
gl_version version)
{
int check_gl(void)
{
- struct gl_context *ctx_2;
- struct gl_context *ctx_3_1;
- struct gl_context *ctx_3_2;
+ int res = 1;
+ struct gl_context *ctx_2 = NULL;
+ struct gl_context *ctx_3_1 = NULL;
+ struct gl_context *ctx_3_2 = NULL;
int have_es3 = 0;
int have_es3_compatibility = 0;
int have_es1 = 0;
if (!check_gl_procaddr((void**)&get_string, "glGetString", 0) ||
!check_gl_procaddr((void**)&get_stringi, "glGetStringi", 1) ||
!check_gl_procaddr((void**)&get_integerv, "glGetIntegerv", 0)) {
- return 1;
+ goto out;
}
ctx_2 = check_gl_version(gl_2);
if (!ctx_2 && !ctx_3_1 && !ctx_3_2) {
check_gl_log(gl_info, "Host does not have hardware GL acceleration!");
- return 1;
+ goto out;
}
have_es1 = (ctx_2 != NULL);
check_gl_log(gl_info, "Host has hardware GL acceleration!");
- return 0;
+ res = 0;
+
+out:
+ if (ctx_2) {
+ check_gl_context_destroy(ctx_2);
+ }
+
+ if (ctx_3_1) {
+ check_gl_context_destroy(ctx_3_1);
+ }
+
+ if (ctx_3_2) {
+ check_gl_context_destroy(ctx_3_2);
+ }
+
+ check_gl_cleanup();
+
+ return res;
}
if (!handle) {
check_gl_log(gl_error, "%s", dlerror());
- return 0;
+ goto fail;
}
get_proc_address = dlsym(handle, "glXGetProcAddress");
if (!get_proc_address) {
check_gl_log(gl_error, "%s", dlerror());
- return 0;
+ goto fail;
}
GLX_GET_PROC(choose_fb_config, glXChooseFBConfig);
if (!configs || (n <= 0)) {
check_gl_log(gl_error, "Unable to find suitable FB config");
- return 0;
+ goto fail;
}
x_config = configs[0];
XFree(configs);
return 1;
+
+fail:
+ XCloseDisplay(x_dpy);
+
+ return 0;
+}
+
+void check_gl_cleanup(void)
+{
+ XCloseDisplay(x_dpy);
}
struct gl_context *check_gl_context_create(struct gl_context *share_ctx,
return 0;
}
+void check_gl_cleanup(void)
+{
+ ReleaseDC(win, dc);
+ DestroyWindow(win);
+ delete_context(init_ctx);
+ ReleaseDC(init_win, init_dc);
+ DestroyWindow(init_win);
+
+ UnregisterClassA((LPCTSTR)"CheckGLWinClass", NULL);
+}
+
struct gl_context *check_gl_context_create(struct gl_context *share_ctx,
gl_version version)
{