[PATCH] RFC, weston: Use eglGetProcAddress to retrieve GLESv2 functions

Armin Krezović krezovic.armin at gmail.com
Sat Sep 10 20:23:14 UTC 2016


It appears that in current Mesa git master, GLESv2 function
prototypes are hidden.

Per Emil's suggestion on [1], use eglGetProcAdddress to get
the functions and update the code to use such functions.

[1] https://patchwork.freedesktop.org/patch/108369/

Signed-off-by: Armin Krezović <krezovic.armin at gmail.com>
---
 clients/simple-egl.c      |  56 +++++-----
 clients/subsurfaces.c     |  56 +++++-----
 libweston/gl-renderer.c   | 264 +++++++++++++++++++++++-----------------------
 shared/platform.h         | 142 +++++++++++++++++++++++++
 tests/buffer-count-test.c |   6 +-
 5 files changed, 337 insertions(+), 187 deletions(-)

diff --git a/clients/simple-egl.c b/clients/simple-egl.c
index 9d401f9..59c0db3 100644
--- a/clients/simple-egl.c
+++ b/clients/simple-egl.c
@@ -215,17 +215,17 @@ create_shader(struct window *window, const char *source, GLenum shader_type)
 	GLuint shader;
 	GLint status;
 
-	shader = glCreateShader(shader_type);
+	shader = weston_glCreateShader(shader_type);
 	assert(shader != 0);
 
-	glShaderSource(shader, 1, (const char **) &source, NULL);
-	glCompileShader(shader);
+	weston_glShaderSource(shader, 1, (const char **) &source, NULL);
+	weston_glCompileShader(shader);
 
-	glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
+	weston_glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
 	if (!status) {
 		char log[1000];
 		GLsizei len;
-		glGetShaderInfoLog(shader, 1000, &len, log);
+		weston_glGetShaderInfoLog(shader, 1000, &len, log);
 		fprintf(stderr, "Error: compiling %s: %*s\n",
 			shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment",
 			len, log);
@@ -245,31 +245,31 @@ init_gl(struct window *window)
 	frag = create_shader(window, frag_shader_text, GL_FRAGMENT_SHADER);
 	vert = create_shader(window, vert_shader_text, GL_VERTEX_SHADER);
 
-	program = glCreateProgram();
-	glAttachShader(program, frag);
-	glAttachShader(program, vert);
-	glLinkProgram(program);
+	program = weston_glCreateProgram();
+	weston_glAttachShader(program, frag);
+	weston_glAttachShader(program, vert);
+	weston_glLinkProgram(program);
 
-	glGetProgramiv(program, GL_LINK_STATUS, &status);
+	weston_glGetProgramiv(program, GL_LINK_STATUS, &status);
 	if (!status) {
 		char log[1000];
 		GLsizei len;
-		glGetProgramInfoLog(program, 1000, &len, log);
+		weston_glGetProgramInfoLog(program, 1000, &len, log);
 		fprintf(stderr, "Error: linking:\n%*s\n", len, log);
 		exit(1);
 	}
 
-	glUseProgram(program);
+	weston_glUseProgram(program);
 
 	window->gl.pos = 0;
 	window->gl.col = 1;
 
-	glBindAttribLocation(program, window->gl.pos, "pos");
-	glBindAttribLocation(program, window->gl.col, "color");
-	glLinkProgram(program);
+	weston_glBindAttribLocation(program, window->gl.pos, "pos");
+	weston_glBindAttribLocation(program, window->gl.col, "color");
+	weston_glLinkProgram(program);
 
 	window->gl.rotation_uniform =
-		glGetUniformLocation(program, "rotation");
+		weston_glGetUniformLocation(program, "rotation");
 }
 
 static void
@@ -508,23 +508,23 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)
 		eglQuerySurface(display->egl.dpy, window->egl_surface,
 				EGL_BUFFER_AGE_EXT, &buffer_age);
 
-	glViewport(0, 0, window->geometry.width, window->geometry.height);
+	weston_glViewport(0, 0, window->geometry.width, window->geometry.height);
 
-	glUniformMatrix4fv(window->gl.rotation_uniform, 1, GL_FALSE,
+	weston_glUniformMatrix4fv(window->gl.rotation_uniform, 1, GL_FALSE,
 			   (GLfloat *) rotation);
 
-	glClearColor(0.0, 0.0, 0.0, 0.5);
-	glClear(GL_COLOR_BUFFER_BIT);
+	weston_glClearColor(0.0, 0.0, 0.0, 0.5);
+	weston_glClear(GL_COLOR_BUFFER_BIT);
 
-	glVertexAttribPointer(window->gl.pos, 2, GL_FLOAT, GL_FALSE, 0, verts);
-	glVertexAttribPointer(window->gl.col, 3, GL_FLOAT, GL_FALSE, 0, colors);
-	glEnableVertexAttribArray(window->gl.pos);
-	glEnableVertexAttribArray(window->gl.col);
+	weston_glVertexAttribPointer(window->gl.pos, 2, GL_FLOAT, GL_FALSE, 0, verts);
+	weston_glVertexAttribPointer(window->gl.col, 3, GL_FLOAT, GL_FALSE, 0, colors);
+	weston_glEnableVertexAttribArray(window->gl.pos);
+	weston_glEnableVertexAttribArray(window->gl.col);
 
-	glDrawArrays(GL_TRIANGLES, 0, 3);
+	weston_glDrawArrays(GL_TRIANGLES, 0, 3);
 
-	glDisableVertexAttribArray(window->gl.pos);
-	glDisableVertexAttribArray(window->gl.col);
+	weston_glDisableVertexAttribArray(window->gl.pos);
+	weston_glDisableVertexAttribArray(window->gl.col);
 
 	if (window->opaque || window->fullscreen) {
 		region = wl_compositor_create_region(window->display->compositor);
@@ -873,6 +873,8 @@ main(int argc, char **argv)
 
 	wl_display_roundtrip(display.display);
 
+	weston_gles2_api_init();
+
 	init_egl(&display, &window);
 	create_surface(&window);
 	init_gl(&window);
diff --git a/clients/subsurfaces.c b/clients/subsurfaces.c
index 45801a8..63f5be8 100644
--- a/clients/subsurfaces.c
+++ b/clients/subsurfaces.c
@@ -284,17 +284,17 @@ create_shader(const char *source, GLenum shader_type)
 	GLuint shader;
 	GLint status;
 
-	shader = glCreateShader(shader_type);
+	shader = weston_glCreateShader(shader_type);
 	assert(shader != 0);
 
-	glShaderSource(shader, 1, (const char **) &source, NULL);
-	glCompileShader(shader);
+	weston_glShaderSource(shader, 1, (const char **) &source, NULL);
+	weston_glCompileShader(shader);
 
-	glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
+	weston_glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
 	if (!status) {
 		char log[1000];
 		GLsizei len;
-		glGetShaderInfoLog(shader, 1000, &len, log);
+		weston_glGetShaderInfoLog(shader, 1000, &len, log);
 		fprintf(stderr, "Error: compiling %s: %*s\n",
 			shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment",
 			len, log);
@@ -314,30 +314,30 @@ triangle_init_gl(struct triangle_gl_state *trigl)
 	frag = create_shader(frag_shader_text, GL_FRAGMENT_SHADER);
 	vert = create_shader(vert_shader_text, GL_VERTEX_SHADER);
 
-	program = glCreateProgram();
-	glAttachShader(program, frag);
-	glAttachShader(program, vert);
-	glLinkProgram(program);
+	program = weston_glCreateProgram();
+	weston_glAttachShader(program, frag);
+	weston_glAttachShader(program, vert);
+	weston_glLinkProgram(program);
 
-	glGetProgramiv(program, GL_LINK_STATUS, &status);
+	weston_glGetProgramiv(program, GL_LINK_STATUS, &status);
 	if (!status) {
 		char log[1000];
 		GLsizei len;
-		glGetProgramInfoLog(program, 1000, &len, log);
+		weston_glGetProgramInfoLog(program, 1000, &len, log);
 		fprintf(stderr, "Error: linking:\n%*s\n", len, log);
 		exit(1);
 	}
 
-	glUseProgram(program);
+	weston_glUseProgram(program);
 
 	trigl->pos = 0;
 	trigl->col = 1;
 
-	glBindAttribLocation(program, trigl->pos, "pos");
-	glBindAttribLocation(program, trigl->col, "color");
-	glLinkProgram(program);
+	weston_glBindAttribLocation(program, trigl->pos, "pos");
+	weston_glBindAttribLocation(program, trigl->col, "color");
+	weston_glLinkProgram(program);
 
-	trigl->rotation_uniform = glGetUniformLocation(program, "rotation");
+	trigl->rotation_uniform = weston_glGetUniformLocation(program, "rotation");
 }
 
 static void
@@ -368,21 +368,21 @@ triangle_draw(const struct triangle_gl_state *trigl, uint32_t time)
 	rotation[2][0] = -sin(angle);
 	rotation[2][2] =  cos(angle);
 
-	glUniformMatrix4fv(trigl->rotation_uniform, 1, GL_FALSE,
+	weston_glUniformMatrix4fv(trigl->rotation_uniform, 1, GL_FALSE,
 			   (GLfloat *) rotation);
 
-	glClearColor(0.0, 0.0, 0.0, 0.5);
-	glClear(GL_COLOR_BUFFER_BIT);
+	weston_glClearColor(0.0, 0.0, 0.0, 0.5);
+	weston_glClear(GL_COLOR_BUFFER_BIT);
 
-	glVertexAttribPointer(trigl->pos, 2, GL_FLOAT, GL_FALSE, 0, verts);
-	glVertexAttribPointer(trigl->col, 3, GL_FLOAT, GL_FALSE, 0, colors);
-	glEnableVertexAttribArray(trigl->pos);
-	glEnableVertexAttribArray(trigl->col);
+	weston_glVertexAttribPointer(trigl->pos, 2, GL_FLOAT, GL_FALSE, 0, verts);
+	weston_glVertexAttribPointer(trigl->col, 3, GL_FLOAT, GL_FALSE, 0, colors);
+	weston_glEnableVertexAttribArray(trigl->pos);
+	weston_glEnableVertexAttribArray(trigl->col);
 
-	glDrawArrays(GL_TRIANGLES, 0, 3);
+	weston_glDrawArrays(GL_TRIANGLES, 0, 3);
 
-	glDisableVertexAttribArray(trigl->pos);
-	glDisableVertexAttribArray(trigl->col);
+	weston_glDisableVertexAttribArray(trigl->pos);
+	weston_glDisableVertexAttribArray(trigl->col);
 }
 
 static void
@@ -409,7 +409,7 @@ triangle_frame_callback(void *data, struct wl_callback *callback,
 	eglMakeCurrent(tri->egl->dpy, tri->egl_surface,
 				   tri->egl_surface, tri->egl->ctx);
 
-	glViewport(0, 0, tri->width, tri->height);
+	weston_glViewport(0, 0, tri->width, tri->height);
 
 	triangle_draw(&tri->gl, tri->time);
 
@@ -797,6 +797,8 @@ main(int argc, char *argv[])
 		return -1;
 	}
 
+	weston_gles2_api_init();
+
 	app = demoapp_create(display);
 
 	display_run(display);
diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index 031576b..d4424df 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -606,11 +606,11 @@ triangle_fan_debug(struct weston_view *view, int first, int count)
 		*index++ = first + i;
 	}
 
-	glUseProgram(gr->solid_shader.program);
-	glUniform4fv(gr->solid_shader.color_uniform, 1,
+	weston_glUseProgram(gr->solid_shader.program);
+	weston_glUniform4fv(gr->solid_shader.color_uniform, 1,
 			color[color_idx++ % ARRAY_LENGTH(color)]);
-	glDrawElements(GL_LINES, nelems, GL_UNSIGNED_SHORT, buffer);
-	glUseProgram(gr->current_shader->program);
+	weston_glDrawElements(GL_LINES, nelems, GL_UNSIGNED_SHORT, buffer);
+	weston_glUseProgram(gr->current_shader->program);
 	free(buffer);
 }
 
@@ -638,22 +638,22 @@ repaint_region(struct weston_view *ev, pixman_region32_t *region,
 	vtxcnt = gr->vtxcnt.data;
 
 	/* position: */
-	glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof *v, &v[0]);
-	glEnableVertexAttribArray(0);
+	weston_glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof *v, &v[0]);
+	weston_glEnableVertexAttribArray(0);
 
 	/* texcoord: */
-	glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof *v, &v[2]);
-	glEnableVertexAttribArray(1);
+	weston_glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof *v, &v[2]);
+	weston_glEnableVertexAttribArray(1);
 
 	for (i = 0, first = 0; i < nfans; i++) {
-		glDrawArrays(GL_TRIANGLE_FAN, first, vtxcnt[i]);
+		weston_glDrawArrays(GL_TRIANGLE_FAN, first, vtxcnt[i]);
 		if (gr->fan_debug)
 			triangle_fan_debug(ev, first, vtxcnt[i]);
 		first += vtxcnt[i];
 	}
 
-	glDisableVertexAttribArray(1);
-	glDisableVertexAttribArray(0);
+	weston_glDisableVertexAttribArray(1);
+	weston_glDisableVertexAttribArray(0);
 
 	gr->vertices.size = 0;
 	gr->vtxcnt.size = 0;
@@ -702,7 +702,7 @@ use_shader(struct gl_renderer *gr, struct gl_shader *shader)
 
 	if (gr->current_shader == shader)
 		return;
-	glUseProgram(shader->program);
+	weston_glUseProgram(shader->program);
 	gr->current_shader = shader;
 }
 
@@ -715,13 +715,13 @@ shader_uniforms(struct gl_shader *shader,
 	struct gl_surface_state *gs = get_surface_state(view->surface);
 	struct gl_output_state *go = get_output_state(output);
 
-	glUniformMatrix4fv(shader->proj_uniform,
+	weston_glUniformMatrix4fv(shader->proj_uniform,
 			   1, GL_FALSE, go->output_matrix.d);
-	glUniform4fv(shader->color_uniform, 1, gs->color);
-	glUniform1f(shader->alpha_uniform, view->alpha);
+	weston_glUniform4fv(shader->color_uniform, 1, gs->color);
+	weston_glUniform1f(shader->alpha_uniform, view->alpha);
 
 	for (i = 0; i < gs->num_textures; i++)
-		glUniform1i(shader->tex_uniforms[i], i);
+		weston_glUniform1i(shader->tex_uniforms[i], i);
 }
 
 static void
@@ -754,7 +754,7 @@ draw_view(struct weston_view *ev, struct weston_output *output,
 	if (!pixman_region32_not_empty(&repaint))
 		goto out;
 
-	glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+	weston_glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
 
 	if (gr->fan_debug) {
 		use_shader(gr, &gr->solid_shader);
@@ -771,10 +771,10 @@ draw_view(struct weston_view *ev, struct weston_output *output,
 		filter = GL_NEAREST;
 
 	for (i = 0; i < gs->num_textures; i++) {
-		glActiveTexture(GL_TEXTURE0 + i);
-		glBindTexture(gs->target, gs->textures[i]);
-		glTexParameteri(gs->target, GL_TEXTURE_MIN_FILTER, filter);
-		glTexParameteri(gs->target, GL_TEXTURE_MAG_FILTER, filter);
+		weston_glActiveTexture(GL_TEXTURE0 + i);
+		weston_glBindTexture(gs->target, gs->textures[i]);
+		weston_glTexParameteri(gs->target, GL_TEXTURE_MIN_FILTER, filter);
+		weston_glTexParameteri(gs->target, GL_TEXTURE_MAG_FILTER, filter);
 	}
 
 	/* blended region is whole surface minus opaque region: */
@@ -807,16 +807,16 @@ draw_view(struct weston_view *ev, struct weston_output *output,
 		}
 
 		if (ev->alpha < 1.0)
-			glEnable(GL_BLEND);
+			weston_glEnable(GL_BLEND);
 		else
-			glDisable(GL_BLEND);
+			weston_glDisable(GL_BLEND);
 
 		repaint_region(ev, &repaint, &surface_opaque);
 	}
 
 	if (pixman_region32_not_empty(&surface_blend)) {
 		use_shader(gr, gs->shader);
-		glEnable(GL_BLEND);
+		weston_glEnable(GL_BLEND);
 		repaint_region(ev, &repaint, &surface_blend);
 	}
 
@@ -849,7 +849,7 @@ draw_output_border_texture(struct gl_output_state *go,
 
 	if (!img->data) {
 		if (img->tex) {
-			glDeleteTextures(1, &img->tex);
+			weston_glDeleteTextures(1, &img->tex);
 			img->tex = 0;
 		}
 
@@ -857,26 +857,26 @@ draw_output_border_texture(struct gl_output_state *go,
 	}
 
 	if (!img->tex) {
-		glGenTextures(1, &img->tex);
-		glBindTexture(GL_TEXTURE_2D, img->tex);
+		weston_glGenTextures(1, &img->tex);
+		weston_glBindTexture(GL_TEXTURE_2D, img->tex);
 
-		glTexParameteri(GL_TEXTURE_2D,
+		weston_glTexParameteri(GL_TEXTURE_2D,
 				GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-		glTexParameteri(GL_TEXTURE_2D,
+		weston_glTexParameteri(GL_TEXTURE_2D,
 				GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-		glTexParameteri(GL_TEXTURE_2D,
+		weston_glTexParameteri(GL_TEXTURE_2D,
 				GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-		glTexParameteri(GL_TEXTURE_2D,
+		weston_glTexParameteri(GL_TEXTURE_2D,
 				GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 	} else {
-		glBindTexture(GL_TEXTURE_2D, img->tex);
+		weston_glBindTexture(GL_TEXTURE_2D, img->tex);
 	}
 
 	if (go->border_status & (1 << side)) {
-		glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, 0);
-		glPixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, 0);
-		glPixelStorei(GL_UNPACK_SKIP_ROWS_EXT, 0);
-		glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
+		weston_glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, 0);
+		weston_glPixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, 0);
+		weston_glPixelStorei(GL_UNPACK_SKIP_ROWS_EXT, 0);
+		weston_glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
 			     img->tex_width, img->height, 0,
 			     GL_BGRA_EXT, GL_UNSIGNED_BYTE, img->data);
 	}
@@ -895,15 +895,15 @@ draw_output_border_texture(struct gl_output_state *go,
 		x, y + height
 	};
 
-	glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, verts);
-	glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, texcoord);
-	glEnableVertexAttribArray(0);
-	glEnableVertexAttribArray(1);
+	weston_glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, verts);
+	weston_glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, texcoord);
+	weston_glEnableVertexAttribArray(0);
+	weston_glEnableVertexAttribArray(1);
 
-	glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
+	weston_glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
 
-	glDisableVertexAttribArray(1);
-	glDisableVertexAttribArray(0);
+	weston_glDisableVertexAttribArray(1);
+	weston_glDisableVertexAttribArray(0);
 }
 
 static int
@@ -939,19 +939,19 @@ draw_output_borders(struct weston_output *output,
 	full_width = output->current_mode->width + left->width + right->width;
 	full_height = output->current_mode->height + top->height + bottom->height;
 
-	glDisable(GL_BLEND);
+	weston_glDisable(GL_BLEND);
 	use_shader(gr, shader);
 
-	glViewport(0, 0, full_width, full_height);
+	weston_glViewport(0, 0, full_width, full_height);
 
 	weston_matrix_init(&matrix);
 	weston_matrix_translate(&matrix, -full_width/2.0, -full_height/2.0, 0);
 	weston_matrix_scale(&matrix, 2.0/full_width, -2.0/full_height, 1);
-	glUniformMatrix4fv(shader->proj_uniform, 1, GL_FALSE, matrix.d);
+	weston_glUniformMatrix4fv(shader->proj_uniform, 1, GL_FALSE, matrix.d);
 
-	glUniform1i(shader->tex_uniforms[0], 0);
-	glUniform1f(shader->alpha_uniform, 1);
-	glActiveTexture(GL_TEXTURE0);
+	weston_glUniform1i(shader->tex_uniforms[0], 0);
+	weston_glUniform1f(shader->alpha_uniform, 1);
+	weston_glActiveTexture(GL_TEXTURE0);
 
 	if (border_status & BORDER_TOP_DIRTY)
 		draw_output_border_texture(go, GL_RENDERER_BORDER_TOP,
@@ -1093,7 +1093,7 @@ gl_renderer_repaint_output(struct weston_output *output,
 		return;
 
 	/* Calculate the viewport */
-	glViewport(go->borders[GL_RENDERER_BORDER_LEFT].width,
+	weston_glViewport(go->borders[GL_RENDERER_BORDER_LEFT].width,
 		   go->borders[GL_RENDERER_BORDER_BOTTOM].height,
 		   output->current_mode->width,
 		   output->current_mode->height);
@@ -1213,8 +1213,8 @@ gl_renderer_read_pixels(struct weston_output *output,
 	if (use_output(output) < 0)
 		return -1;
 
-	glPixelStorei(GL_PACK_ALIGNMENT, 1);
-	glReadPixels(x, y, width, height, gl_format,
+	weston_glPixelStorei(GL_PACK_ALIGNMENT, 1);
+	weston_glReadPixels(x, y, width, height, gl_format,
 		     GL_UNSIGNED_BYTE, pixels);
 
 	return 0;
@@ -1257,11 +1257,11 @@ gl_renderer_flush_damage(struct weston_surface *surface)
 	    !gs->needs_full_upload)
 		goto done;
 
-	glBindTexture(GL_TEXTURE_2D, gs->textures[0]);
+	weston_glBindTexture(GL_TEXTURE_2D, gs->textures[0]);
 
 	if (!gr->has_unpack_subimage) {
 		wl_shm_buffer_begin_access(buffer->shm_buffer);
-		glTexImage2D(GL_TEXTURE_2D, 0, gs->gl_format,
+		weston_glTexImage2D(GL_TEXTURE_2D, 0, gs->gl_format,
 			     gs->pitch, buffer->height, 0,
 			     gs->gl_format, gs->gl_pixel_type,
 			     wl_shm_buffer_get_data(buffer->shm_buffer));
@@ -1270,14 +1270,14 @@ gl_renderer_flush_damage(struct weston_surface *surface)
 		goto done;
 	}
 
-	glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, gs->pitch);
+	weston_glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, gs->pitch);
 	data = wl_shm_buffer_get_data(buffer->shm_buffer);
 
 	if (gs->needs_full_upload) {
-		glPixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, 0);
-		glPixelStorei(GL_UNPACK_SKIP_ROWS_EXT, 0);
+		weston_glPixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, 0);
+		weston_glPixelStorei(GL_UNPACK_SKIP_ROWS_EXT, 0);
 		wl_shm_buffer_begin_access(buffer->shm_buffer);
-		glTexImage2D(GL_TEXTURE_2D, 0, gs->gl_format,
+		weston_glTexImage2D(GL_TEXTURE_2D, 0, gs->gl_format,
 			     gs->pitch, buffer->height, 0,
 			     gs->gl_format, gs->gl_pixel_type, data);
 		wl_shm_buffer_end_access(buffer->shm_buffer);
@@ -1291,9 +1291,9 @@ gl_renderer_flush_damage(struct weston_surface *surface)
 
 		r = weston_surface_to_buffer_rect(surface, rectangles[i]);
 
-		glPixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, r.x1);
-		glPixelStorei(GL_UNPACK_SKIP_ROWS_EXT, r.y1);
-		glTexSubImage2D(GL_TEXTURE_2D, 0, r.x1, r.y1,
+		weston_glPixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, r.x1);
+		weston_glPixelStorei(GL_UNPACK_SKIP_ROWS_EXT, r.y1);
+		weston_glTexSubImage2D(GL_TEXTURE_2D, 0, r.x1, r.y1,
 				r.x2 - r.x1, r.y2 - r.y1,
 				gs->gl_format, gs->gl_pixel_type, data);
 	}
@@ -1316,15 +1316,15 @@ ensure_textures(struct gl_surface_state *gs, int num_textures)
 		return;
 
 	for (i = gs->num_textures; i < num_textures; i++) {
-		glGenTextures(1, &gs->textures[i]);
-		glBindTexture(gs->target, gs->textures[i]);
-		glTexParameteri(gs->target,
+		weston_glGenTextures(1, &gs->textures[i]);
+		weston_glBindTexture(gs->target, gs->textures[i]);
+		weston_glTexParameteri(gs->target,
 				GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-		glTexParameteri(gs->target,
+		weston_glTexParameteri(gs->target,
 				GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 	}
 	gs->num_textures = num_textures;
-	glBindTexture(gs->target, 0);
+	weston_glBindTexture(gs->target, 0);
 }
 
 static void
@@ -1454,8 +1454,8 @@ gl_renderer_attach_egl(struct weston_surface *es, struct weston_buffer *buffer,
 		}
 		gs->num_images++;
 
-		glActiveTexture(GL_TEXTURE0 + i);
-		glBindTexture(gs->target, gs->textures[i]);
+		weston_glActiveTexture(GL_TEXTURE0 + i);
+		weston_glBindTexture(gs->target, gs->textures[i]);
 		gr->image_target_texture_2d(gs->target,
 					    gs->images[i]->image);
 	}
@@ -1867,8 +1867,8 @@ gl_renderer_attach_dmabuf(struct weston_surface *surface,
 	gs->target = image->target;
 	ensure_textures(gs, gs->num_images);
 	for (i = 0; i < gs->num_images; ++i) {
-		glActiveTexture(GL_TEXTURE0 + i);
-		glBindTexture(gs->target, gs->textures[i]);
+		weston_glActiveTexture(GL_TEXTURE0 + i);
+		weston_glBindTexture(gs->target, gs->textures[i]);
 		gr->image_target_texture_2d(gs->target, gs->images[i]->image);
 	}
 
@@ -1898,7 +1898,7 @@ gl_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
 			gs->images[i] = NULL;
 		}
 		gs->num_images = 0;
-		glDeleteTextures(gs->num_textures, gs->textures);
+		weston_glDeleteTextures(gs->num_textures, gs->textures);
 		gs->num_textures = 0;
 		gs->buffer_type = BUFFER_TYPE_NULL;
 		gs->y_inverted = 1;
@@ -2023,64 +2023,64 @@ gl_renderer_surface_copy_content(struct weston_surface *surface,
 		break;
 	}
 
-	glGenTextures(1, &tex);
-	glBindTexture(GL_TEXTURE_2D, tex);
-	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, cw, ch,
+	weston_glGenTextures(1, &tex);
+	weston_glBindTexture(GL_TEXTURE_2D, tex);
+	weston_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, cw, ch,
 		     0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
-	glBindTexture(GL_TEXTURE_2D, 0);
+	weston_glBindTexture(GL_TEXTURE_2D, 0);
 
-	glGenFramebuffers(1, &fbo);
-	glBindFramebuffer(GL_FRAMEBUFFER, fbo);
-	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+	weston_glGenFramebuffers(1, &fbo);
+	weston_glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+	weston_glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
 			       GL_TEXTURE_2D, tex, 0);
 
-	status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
+	status = weston_glCheckFramebufferStatus(GL_FRAMEBUFFER);
 	if (status != GL_FRAMEBUFFER_COMPLETE) {
 		weston_log("%s: fbo error: %#x\n", __func__, status);
-		glDeleteFramebuffers(1, &fbo);
-		glDeleteTextures(1, &tex);
+		weston_glDeleteFramebuffers(1, &fbo);
+		weston_glDeleteTextures(1, &tex);
 		return -1;
 	}
 
-	glViewport(0, 0, cw, ch);
-	glDisable(GL_BLEND);
+	weston_glViewport(0, 0, cw, ch);
+	weston_glDisable(GL_BLEND);
 	use_shader(gr, gs->shader);
 	if (gs->y_inverted)
 		proj = projmat_normal;
 	else
 		proj = projmat_yinvert;
 
-	glUniformMatrix4fv(gs->shader->proj_uniform, 1, GL_FALSE, proj);
-	glUniform1f(gs->shader->alpha_uniform, 1.0f);
+	weston_glUniformMatrix4fv(gs->shader->proj_uniform, 1, GL_FALSE, proj);
+	weston_glUniform1f(gs->shader->alpha_uniform, 1.0f);
 
 	for (i = 0; i < gs->num_textures; i++) {
-		glUniform1i(gs->shader->tex_uniforms[i], i);
+		weston_glUniform1i(gs->shader->tex_uniforms[i], i);
 
-		glActiveTexture(GL_TEXTURE0 + i);
-		glBindTexture(gs->target, gs->textures[i]);
-		glTexParameteri(gs->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-		glTexParameteri(gs->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+		weston_glActiveTexture(GL_TEXTURE0 + i);
+		weston_glBindTexture(gs->target, gs->textures[i]);
+		weston_glTexParameteri(gs->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+		weston_glTexParameteri(gs->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 	}
 
 	/* position: */
-	glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, verts);
-	glEnableVertexAttribArray(0);
+	weston_glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, verts);
+	weston_glEnableVertexAttribArray(0);
 
 	/* texcoord: */
-	glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, verts);
-	glEnableVertexAttribArray(1);
+	weston_glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, verts);
+	weston_glEnableVertexAttribArray(1);
 
-	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+	weston_glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
 
-	glDisableVertexAttribArray(1);
-	glDisableVertexAttribArray(0);
+	weston_glDisableVertexAttribArray(1);
+	weston_glDisableVertexAttribArray(0);
 
-	glPixelStorei(GL_PACK_ALIGNMENT, bytespp);
-	glReadPixels(src_x, src_y, width, height, gl_format,
+	weston_glPixelStorei(GL_PACK_ALIGNMENT, bytespp);
+	weston_glReadPixels(src_x, src_y, width, height, gl_format,
 		     GL_UNSIGNED_BYTE, target);
 
-	glDeleteFramebuffers(1, &fbo);
-	glDeleteTextures(1, &tex);
+	weston_glDeleteFramebuffers(1, &fbo);
+	weston_glDeleteTextures(1, &tex);
 
 	return 0;
 }
@@ -2095,7 +2095,7 @@ surface_state_destroy(struct gl_surface_state *gs, struct gl_renderer *gr)
 
 	gs->surface->renderer_state = NULL;
 
-	glDeleteTextures(gs->num_textures, gs->textures);
+	weston_glDeleteTextures(gs->num_textures, gs->textures);
 
 	for (i = 0; i < gs->num_images; i++)
 		egl_image_unref(gs->images[i]);
@@ -2288,12 +2288,12 @@ compile_shader(GLenum type, int count, const char **sources)
 	char msg[512];
 	GLint status;
 
-	s = glCreateShader(type);
-	glShaderSource(s, count, sources, NULL);
-	glCompileShader(s);
-	glGetShaderiv(s, GL_COMPILE_STATUS, &status);
+	s = weston_glCreateShader(type);
+	weston_glShaderSource(s, count, sources, NULL);
+	weston_glCompileShader(s);
+	weston_glGetShaderiv(s, GL_COMPILE_STATUS, &status);
 	if (!status) {
-		glGetShaderInfoLog(s, sizeof msg, NULL, msg);
+		weston_glGetShaderInfoLog(s, sizeof msg, NULL, msg);
 		weston_log("shader info: %s\n", msg);
 		return GL_NONE;
 	}
@@ -2327,26 +2327,26 @@ shader_init(struct gl_shader *shader, struct gl_renderer *renderer,
 	shader->fragment_shader =
 		compile_shader(GL_FRAGMENT_SHADER, count, sources);
 
-	shader->program = glCreateProgram();
-	glAttachShader(shader->program, shader->vertex_shader);
-	glAttachShader(shader->program, shader->fragment_shader);
-	glBindAttribLocation(shader->program, 0, "position");
-	glBindAttribLocation(shader->program, 1, "texcoord");
+	shader->program = weston_glCreateProgram();
+	weston_glAttachShader(shader->program, shader->vertex_shader);
+	weston_glAttachShader(shader->program, shader->fragment_shader);
+	weston_glBindAttribLocation(shader->program, 0, "position");
+	weston_glBindAttribLocation(shader->program, 1, "texcoord");
 
-	glLinkProgram(shader->program);
-	glGetProgramiv(shader->program, GL_LINK_STATUS, &status);
+	weston_glLinkProgram(shader->program);
+	weston_glGetProgramiv(shader->program, GL_LINK_STATUS, &status);
 	if (!status) {
-		glGetProgramInfoLog(shader->program, sizeof msg, NULL, msg);
+		weston_glGetProgramInfoLog(shader->program, sizeof msg, NULL, msg);
 		weston_log("link info: %s\n", msg);
 		return -1;
 	}
 
-	shader->proj_uniform = glGetUniformLocation(shader->program, "proj");
-	shader->tex_uniforms[0] = glGetUniformLocation(shader->program, "tex");
-	shader->tex_uniforms[1] = glGetUniformLocation(shader->program, "tex1");
-	shader->tex_uniforms[2] = glGetUniformLocation(shader->program, "tex2");
-	shader->alpha_uniform = glGetUniformLocation(shader->program, "alpha");
-	shader->color_uniform = glGetUniformLocation(shader->program, "color");
+	shader->proj_uniform = weston_glGetUniformLocation(shader->program, "proj");
+	shader->tex_uniforms[0] = weston_glGetUniformLocation(shader->program, "tex");
+	shader->tex_uniforms[1] = weston_glGetUniformLocation(shader->program, "tex1");
+	shader->tex_uniforms[2] = weston_glGetUniformLocation(shader->program, "tex2");
+	shader->alpha_uniform = weston_glGetUniformLocation(shader->program, "alpha");
+	shader->color_uniform = weston_glGetUniformLocation(shader->program, "color");
 
 	return 0;
 }
@@ -2354,9 +2354,9 @@ shader_init(struct gl_shader *shader, struct gl_renderer *renderer,
 static void
 shader_release(struct gl_shader *shader)
 {
-	glDeleteShader(shader->vertex_shader);
-	glDeleteShader(shader->fragment_shader);
-	glDeleteProgram(shader->program);
+	weston_glDeleteShader(shader->vertex_shader);
+	weston_glDeleteShader(shader->fragment_shader);
+	weston_glDeleteProgram(shader->program);
 
 	shader->vertex_shader = 0;
 	shader->fragment_shader = 0;
@@ -2403,19 +2403,19 @@ log_egl_gl_info(EGLDisplay egldpy)
 	str = eglQueryString(egldpy, EGL_EXTENSIONS);
 	log_extensions("EGL extensions", str ? str : "(null)");
 
-	str = (char *)glGetString(GL_VERSION);
+	str = (char *)weston_glGetString(GL_VERSION);
 	weston_log("GL version: %s\n", str ? str : "(null)");
 
-	str = (char *)glGetString(GL_SHADING_LANGUAGE_VERSION);
+	str = (char *)weston_glGetString(GL_SHADING_LANGUAGE_VERSION);
 	weston_log("GLSL version: %s\n", str ? str : "(null)");
 
-	str = (char *)glGetString(GL_VENDOR);
+	str = (char *)weston_glGetString(GL_VENDOR);
 	weston_log("GL vendor: %s\n", str ? str : "(null)");
 
-	str = (char *)glGetString(GL_RENDERER);
+	str = (char *)weston_glGetString(GL_RENDERER);
 	weston_log("GL renderer: %s\n", str ? str : "(null)");
 
-	str = (char *)glGetString(GL_EXTENSIONS);
+	str = (char *)weston_glGetString(GL_EXTENSIONS);
 	log_extensions("GL extensions", str ? str : "(null)");
 }
 
@@ -2961,6 +2961,8 @@ gl_renderer_create(struct weston_compositor *ec, EGLenum platform,
 		goto fail_terminate;
 	}
 
+	weston_gles2_api_init();
+
 	ec->renderer = &gr->base;
 	ec->capabilities |= WESTON_CAP_ROTATION_ANY;
 	ec->capabilities |= WESTON_CAP_CAPTURE_YFLIP;
@@ -3125,7 +3127,7 @@ gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
 	gr->image_target_texture_2d =
 		(void *) eglGetProcAddress("glEGLImageTargetTexture2DOES");
 
-	extensions = (const char *) glGetString(GL_EXTENSIONS);
+	extensions = (const char *) weston_glGetString(GL_EXTENSIONS);
 	if (!extensions) {
 		weston_log("Retrieving GL extension string failed.\n");
 		return -1;
@@ -3147,7 +3149,7 @@ gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
 	if (weston_check_egl_extension(extensions, "GL_OES_EGL_image_external"))
 		gr->has_egl_image_external = 1;
 
-	glActiveTexture(GL_TEXTURE0);
+	weston_glActiveTexture(GL_TEXTURE0);
 
 	if (compile_shaders(ec))
 		return -1;
diff --git a/shared/platform.h b/shared/platform.h
index 1eb96fd..294a948 100644
--- a/shared/platform.h
+++ b/shared/platform.h
@@ -33,6 +33,7 @@
 #include <wayland-egl.h>
 #include <EGL/egl.h>
 #include <EGL/eglext.h>
+#include <GLES2/gl2.h>
 #endif
 
 #include "weston-egl-ext.h"
@@ -43,6 +44,52 @@ extern "C" {
 
 #ifdef ENABLE_EGL
 
+static PFNGLACTIVETEXTUREPROC weston_glActiveTexture;
+static PFNGLATTACHSHADERPROC weston_glAttachShader;
+static PFNGLBINDATTRIBLOCATIONPROC weston_glBindAttribLocation;
+static PFNGLBINDFRAMEBUFFERPROC weston_glBindFramebuffer;
+static PFNGLBINDTEXTUREPROC weston_glBindTexture;
+static PFNGLBLENDFUNCPROC weston_glBlendFunc;
+static PFNGLCHECKFRAMEBUFFERSTATUSPROC weston_glCheckFramebufferStatus;
+static PFNGLCLEARPROC weston_glClear;
+static PFNGLCLEARCOLORPROC weston_glClearColor;
+static PFNGLCOMPILESHADERPROC weston_glCompileShader;
+static PFNGLCREATEPROGRAMPROC weston_glCreateProgram;
+static PFNGLCREATESHADERPROC weston_glCreateShader;
+static PFNGLDELETEFRAMEBUFFERSPROC weston_glDeleteFramebuffers;
+static PFNGLDELETEPROGRAMPROC weston_glDeleteProgram;
+static PFNGLDELETESHADERPROC weston_glDeleteShader;
+static PFNGLDELETETEXTURESPROC weston_glDeleteTextures;
+static PFNGLDISABLEPROC weston_glDisable;
+static PFNGLDISABLEVERTEXATTRIBARRAYPROC weston_glDisableVertexAttribArray;
+static PFNGLDRAWARRAYSPROC weston_glDrawArrays;
+static PFNGLDRAWELEMENTSPROC weston_glDrawElements;
+static PFNGLENABLEPROC weston_glEnable;
+static PFNGLENABLEVERTEXATTRIBARRAYPROC weston_glEnableVertexAttribArray;
+static PFNGLFRAMEBUFFERTEXTURE2DPROC weston_glFramebufferTexture2D;
+static PFNGLGENFRAMEBUFFERSPROC weston_glGenFramebuffers;
+static PFNGLGENTEXTURESPROC weston_glGenTextures;
+static PFNGLGETPROGRAMINFOLOGPROC weston_glGetProgramInfoLog;
+static PFNGLGETPROGRAMIVPROC weston_glGetProgramiv;
+static PFNGLGETSHADERINFOLOGPROC weston_glGetShaderInfoLog;
+static PFNGLGETSHADERIVPROC weston_glGetShaderiv;
+static PFNGLGETSTRINGPROC weston_glGetString;
+static PFNGLGETUNIFORMLOCATIONPROC weston_glGetUniformLocation;
+static PFNGLLINKPROGRAMPROC weston_glLinkProgram;
+static PFNGLPIXELSTOREIPROC weston_glPixelStorei;
+static PFNGLREADPIXELSPROC weston_glReadPixels;
+static PFNGLSHADERSOURCEPROC weston_glShaderSource;
+static PFNGLTEXIMAGE2DPROC weston_glTexImage2D;
+static PFNGLTEXPARAMETERIPROC weston_glTexParameteri;
+static PFNGLTEXSUBIMAGE2DPROC weston_glTexSubImage2D;
+static PFNGLUNIFORM1FPROC weston_glUniform1f;
+static PFNGLUNIFORM1IPROC weston_glUniform1i;
+static PFNGLUNIFORM4FVPROC weston_glUniform4fv;
+static PFNGLUNIFORMMATRIX4FVPROC weston_glUniformMatrix4fv;
+static PFNGLUSEPROGRAMPROC weston_glUseProgram;
+static PFNGLVERTEXATTRIBPOINTERPROC weston_glVertexAttribPointer;
+static PFNGLVIEWPORTPROC weston_glViewport;
+
 static bool
 weston_check_egl_extension(const char *extensions, const char *extension)
 {
@@ -128,6 +175,101 @@ weston_platform_create_egl_surface(EGLDisplay dpy, EGLConfig config,
 				      attrib_list);
 }
 
+static inline void
+weston_gles2_api_init(void)
+{
+	weston_glActiveTexture =
+		(void *) weston_platform_get_egl_proc_address("glActiveTexture");
+	weston_glAttachShader =
+		(void *) weston_platform_get_egl_proc_address("glAttachShader");
+	weston_glBindAttribLocation =
+		(void *) weston_platform_get_egl_proc_address("glBindAttribLocation");
+	weston_glBindFramebuffer =
+		(void *) weston_platform_get_egl_proc_address("glBindFramebuffer");
+	weston_glBindTexture =
+		(void *) weston_platform_get_egl_proc_address("glBindTexture");
+	weston_glBlendFunc =
+		(void *)  weston_platform_get_egl_proc_address("glBlendFunc");
+	weston_glCheckFramebufferStatus =
+		(void *) weston_platform_get_egl_proc_address("glCheckFramebufferStatus");
+	weston_glClear =
+		(void *) weston_platform_get_egl_proc_address("glClear");
+	weston_glClearColor =
+		(void *) weston_platform_get_egl_proc_address("glClearColor");
+	weston_glCompileShader =
+		(void *) weston_platform_get_egl_proc_address("glCompileShader");
+	weston_glCreateProgram =
+		(void *) weston_platform_get_egl_proc_address("glCreateProgram");
+	weston_glCreateShader =
+		(void *) weston_platform_get_egl_proc_address("glCreateShader");
+	weston_glDeleteFramebuffers =
+		(void *) weston_platform_get_egl_proc_address("glDeleteFramebuffers");
+	weston_glDeleteProgram =
+		(void *) weston_platform_get_egl_proc_address("glDeleteProgram");
+	weston_glDeleteShader =
+		(void *) weston_platform_get_egl_proc_address("glDeleteShader");
+	weston_glDeleteTextures =
+		(void *) weston_platform_get_egl_proc_address("glDeleteTextures");
+	weston_glDisable =
+		(void *) weston_platform_get_egl_proc_address("glDisable");
+	weston_glDisableVertexAttribArray =
+		(void *) weston_platform_get_egl_proc_address("glDisableVertexAttribArray");
+	weston_glDrawArrays =
+		(void *) weston_platform_get_egl_proc_address("glDrawArrays");
+	weston_glDrawElements =
+		(void *) weston_platform_get_egl_proc_address("glDrawElements");
+	weston_glEnable =
+		(void *) weston_platform_get_egl_proc_address("glEnable");
+	weston_glEnableVertexAttribArray =
+		(void *) weston_platform_get_egl_proc_address("glEnableVertexAttribArray");
+	weston_glFramebufferTexture2D =
+		(void *) weston_platform_get_egl_proc_address("glFramebufferTexture2D");
+	weston_glGenFramebuffers =
+		(void *) weston_platform_get_egl_proc_address("glGenFramebuffers");
+	weston_glGenTextures =
+		(void *) weston_platform_get_egl_proc_address("glGenTextures");
+	weston_glGetProgramInfoLog =
+		(void *) weston_platform_get_egl_proc_address("glGetProgramInfoLog");
+	weston_glGetProgramiv =
+		(void *) weston_platform_get_egl_proc_address("glGetProgramiv");
+	weston_glGetShaderInfoLog =
+		(void *) weston_platform_get_egl_proc_address("glGetShaderInfoLog");
+	weston_glGetShaderiv =
+		(void *) weston_platform_get_egl_proc_address("glGetShaderiv");
+	weston_glGetString =
+		(void *) weston_platform_get_egl_proc_address("glGetString");
+	weston_glGetUniformLocation =
+		(void *) weston_platform_get_egl_proc_address("glGetUniformLocation");
+	weston_glLinkProgram =
+		(void *) weston_platform_get_egl_proc_address("glLinkProgram");
+	weston_glPixelStorei =
+		(void *) weston_platform_get_egl_proc_address("glPixelStorei");
+	weston_glReadPixels =
+		(void *) weston_platform_get_egl_proc_address("glReadPixels");
+	weston_glShaderSource =
+		(void *) weston_platform_get_egl_proc_address("glShaderSource");
+	weston_glTexImage2D =
+		(void *) weston_platform_get_egl_proc_address("glTexImage2D");
+	weston_glTexParameteri =
+		(void *) weston_platform_get_egl_proc_address("glTexParameteri");
+	weston_glTexSubImage2D =
+		(void *) weston_platform_get_egl_proc_address("glTexSubImage2D");
+	weston_glUniform1f =
+		(void *) weston_platform_get_egl_proc_address("glUniform1f");
+	weston_glUniform1i =
+		(void *) weston_platform_get_egl_proc_address("glUniform1i");
+	weston_glUniform4fv =
+		(void *) weston_platform_get_egl_proc_address("glUniform4fv");
+	weston_glUniformMatrix4fv =
+		(void *) weston_platform_get_egl_proc_address("glUniformMatrix4fv");
+	weston_glUseProgram =
+		(void *) weston_platform_get_egl_proc_address("glUseProgram");
+	weston_glVertexAttribPointer =
+		(void *) weston_platform_get_egl_proc_address("glVertexAttribPointer");
+	weston_glViewport =
+		(void *) weston_platform_get_egl_proc_address("glViewport");
+}
+
 #else /* ENABLE_EGL */
 
 static inline void *
diff --git a/tests/buffer-count-test.c b/tests/buffer-count-test.c
index e7d8ca7..d342826 100644
--- a/tests/buffer-count-test.c
+++ b/tests/buffer-count-test.c
@@ -110,7 +110,7 @@ init_egl(struct test_data *test_data)
 
 	/* This test is specific to mesa 10.1 and later, which is the
 	 * first release that doesn't accidentally triple-buffer. */
-	str = (const char *) glGetString(GL_VERSION);
+	str = (const char *) weston_glGetString(GL_VERSION);
 	mesa = strstr(str, "Mesa ");
 	if (mesa == NULL)
 		skip("unknown EGL implementation (%s)\n", str);
@@ -132,6 +132,8 @@ TEST(test_buffer_count)
 	if (!test_data.client->has_wl_drm)
 		skip("compositor has not bound its display to EGL\n");
 
+	weston_gles2_api_init();
+
 	if (init_egl(&test_data) < 0)
 		skip("could not initialize egl, "
 		     "possibly using the headless backend\n");
@@ -144,7 +146,7 @@ TEST(test_buffer_count)
 	 * doing */
 
 	for (i = 0; i < 10; i++) {
-		glClear(GL_COLOR_BUFFER_BIT);
+		weston_glClear(GL_COLOR_BUFFER_BIT);
 		eglSwapBuffers(test_data.egl_dpy, test_data.egl_surface);
 	}
 
-- 
2.10.0



More information about the wayland-devel mailing list