gl-renderer: save OpenGL version in renderer context

This will allow to make some assumptions in further patches when GLES3
is available.

Signed-off-by: Arnaud Vrac <avrac@freebox.fr>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
dev
Arnaud Vrac 7 years ago committed by Daniel Stone
parent e95169b6af
commit 88abc6ab74
  1. 31
      libweston/gl-renderer.c

@ -60,6 +60,12 @@
#include "shared/timespec-util.h"
#include "weston-egl-ext.h"
#define GR_GL_VERSION(major, minor) \
(((uint32_t)(major) << 16) | (uint32_t)(minor))
#define GR_GL_VERSION_INVALID \
GR_GL_VERSION(0, 0)
struct gl_shader {
GLuint program;
GLuint vertex_shader, fragment_shader;
@ -199,6 +205,8 @@ struct gl_renderer {
EGLSurface dummy_surface;
uint32_t gl_version;
struct wl_array vertices;
struct wl_array vtxcnt;
@ -3586,6 +3594,22 @@ fan_debug_repaint_binding(struct weston_keyboard *keyboard,
weston_compositor_damage_all(compositor);
}
static uint32_t
get_gl_version(void)
{
const char *version;
int major, minor;
version = (const char *) glGetString(GL_VERSION);
if (version &&
(sscanf(version, "%d.%d", &major, &minor) == 2 ||
sscanf(version, "OpenGL ES %d.%d", &major, &minor) == 2)) {
return GR_GL_VERSION(major, minor);
}
return GR_GL_VERSION_INVALID;
}
static int
gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
{
@ -3626,6 +3650,13 @@ gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
return -1;
}
gr->gl_version = get_gl_version();
if (gr->gl_version == GR_GL_VERSION_INVALID) {
weston_log("warning: failed to detect GLES version, "
"defaulting to 2.0.\n");
gr->gl_version = GR_GL_VERSION(2, 0);
}
log_egl_gl_info(gr->egl_display);
gr->image_target_texture_2d =

Loading…
Cancel
Save