summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGhostNaN <59353890+GhostNaN@users.noreply.github.com>2020-08-06 01:16:27 +0000
committerGitHub <noreply@github.com>2020-08-06 01:16:27 +0000
commit2369a0a7f9a1fb8298f3502a230bd0034a8b8e2b (patch)
tree23aad9c8bf732b8b436451f725a15cc843592253
parent6d7fe9f486db740e08b7a548e21ef241a68c2eca (diff)
Added OpenGL combatiblity checker for creating contexts ( correct file)
-rw-r--r--src/paper.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/paper.c b/src/paper.c
index 50e08c7..0d6fe89 100644
--- a/src/paper.c
+++ b/src/paper.c
@@ -180,15 +180,33 @@ int paper_init(char* _monitor, char* video_path, char* layer_name) {
EGLConfig config;
EGLint config_len;
eglChooseConfig(egl_display, win_attrib, &config, 1, &config_len);
- const EGLint ctx_attrib[] = {
- EGL_CONTEXT_MAJOR_VERSION, 3,
- EGL_CONTEXT_MINOR_VERSION, 0,
- EGL_NONE
+
+ // Check for OpenGL combatiblity for creating egl context
+ static const struct { int major, minor; } gl_versions[] = {
+ {4, 6}, {4, 5}, {4, 4}, {4, 3}, {4, 2}, {4, 1}, {4, 0},
+ {3, 3}, {3, 2}, {3, 1}, {3, 0},
+ {0, 0}
};
- EGLContext ctx = eglCreateContext(egl_display, config, EGL_NO_CONTEXT, ctx_attrib);
+ EGLContext egl_ctx = NULL;
+ for (int i = 0; gl_versions[i].major > 0; i++) {
+ const EGLint ctx_attrib[] = {
+ EGL_CONTEXT_MAJOR_VERSION, gl_versions[i].major,
+ EGL_CONTEXT_MINOR_VERSION, gl_versions[i].major,
+ EGL_NONE
+ };
+ egl_ctx = eglCreateContext(egl_display, config, EGL_NO_CONTEXT, ctx_attrib);
+ if (egl_ctx) {
+ printf("OpenGL %i.%i context loaded\n", gl_versions[i].major, gl_versions[i].minor);
+ break;
+ }
+ }
+ if (!egl_ctx) {
+ printf("Failed to create EGL context\n");
+ return 1;
+ }
EGLSurface egl_surface = eglCreatePlatformWindowSurface(egl_display, config, window, NULL);
- eglMakeCurrent(egl_display, egl_surface, egl_surface, ctx);
+ eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_ctx);
gladLoadGL();
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
@@ -197,7 +215,7 @@ int paper_init(char* _monitor, char* video_path, char* layer_name) {
// Start mpv
mpv_handle* mpv = mpv_create();
if (!mpv) {
- printf("failed creating context\n");
+ printf("Failed creating mpv context\n");
return 1;
}
@@ -219,7 +237,7 @@ int paper_init(char* _monitor, char* video_path, char* layer_name) {
};
mpv_render_context *mpv_gl;
if (mpv_render_context_create(&mpv_gl, mpv, params) < 0)
- printf("failed to initialize mpv GL context");
+ printf("Failed to initialize mpv GL context");
// Play this file.
const char* cmd[] = {"loadfile", video_path, NULL};