[PATCH weston 1/5] gl-renderer: save OpenGL version in renderer context

Arnaud Vrac rawoul at gmail.com
Wed Nov 29 14:07:06 UTC 2017


From: Arnaud Vrac <avrac at freebox.fr>

---
 libweston/gl-renderer.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index 94d81ef4..0a7db13f 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -199,6 +199,9 @@ struct gl_renderer {
 
 	EGLSurface dummy_surface;
 
+	int gl_major;
+	int gl_minor;
+
 	struct wl_array vertices;
 	struct wl_array vtxcnt;
 
@@ -3572,6 +3575,27 @@ fan_debug_repaint_binding(struct weston_keyboard *keyboard,
 	weston_compositor_damage_all(compositor);
 }
 
+static bool
+get_gl_version(int *major, int *minor)
+{
+	const char *version;
+
+	version = (const char *) glGetString(GL_VERSION);
+	if (version) {
+		if (sscanf(version, "%d.%d", major, minor) == 2)
+			return true;
+
+		if (sscanf(version, "OpenGL ES %d.%d", major, minor) == 2)
+			return true;
+	}
+
+	weston_log("failed to get GL version, default to GLES 2.0\n");
+	*major = 2;
+	*minor = 0;
+
+	return false;
+}
+
 static int
 gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
 {
@@ -3612,6 +3636,8 @@ gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
 		return -1;
 	}
 
+	get_gl_version(&gr->gl_major, &gr->gl_minor);
+
 	log_egl_gl_info(gr->egl_display);
 
 	gr->image_target_texture_2d =
-- 
2.15.0



More information about the wayland-devel mailing list