aboutsummaryrefslogtreecommitdiff
path: root/render/gles2/renderer.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-06-29 16:00:24 -0400
committerDrew DeVault <sir@cmpwn.com>2017-06-29 16:00:24 -0400
commit8920b5d607c6b3b5d04894fc1837ac4f2d9558ae (patch)
tree3c79b4faff213544ed247e1c126fc89508bdd75d /render/gles2/renderer.c
parent97f6e9b69aecf1fbcbc2fa95cb2009f873c86d40 (diff)
parent486ec5953cf51f5fde834bf8fa7fbe56f0be9a0e (diff)
Merge branch 'wlcore'
Diffstat (limited to 'render/gles2/renderer.c')
-rw-r--r--render/gles2/renderer.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c
index 623f378e..897dc3b8 100644
--- a/render/gles2/renderer.c
+++ b/render/gles2/renderer.c
@@ -10,12 +10,7 @@
#include <wlr/util/log.h>
#include "render/gles2.h"
-static struct {
- bool initialized;
- GLuint rgb, rgba;
- GLuint quad;
- GLuint ellipse;
-} shaders;
+struct shaders shaders;
static bool compile_shader(GLuint type, const GLchar *src, GLuint *shader) {
*shader = GL_CALL(glCreateShader(type));
@@ -58,10 +53,10 @@ static void init_default_shaders() {
if (shaders.initialized) {
return;
}
- if (!compile_program(vertex_src, fragment_src_RGB, &shaders.rgb)) {
+ if (!compile_program(vertex_src, fragment_src_rgba, &shaders.rgba)) {
goto error;
}
- if (!compile_program(vertex_src, fragment_src_RGBA, &shaders.rgba)) {
+ if (!compile_program(vertex_src, fragment_src_rgbx, &shaders.rgbx)) {
goto error;
}
if (!compile_program(quad_vertex_src, quad_fragment_src, &shaders.quad)) {
@@ -129,20 +124,10 @@ static void draw_quad() {
static bool wlr_gles2_render_surface(struct wlr_renderer_state *state,
struct wlr_surface *surface, const float (*matrix)[16]) {
assert(surface && surface->valid);
- switch (surface->format) {
- case GL_RGB:
- GL_CALL(glUseProgram(shaders.rgb));
- break;
- case GL_RGBA:
- GL_CALL(glUseProgram(shaders.rgba));
- break;
- default:
- wlr_log(L_ERROR, "No shader for this surface format");
- return false;
- }
- gles2_flush_errors();
wlr_surface_bind(surface);
GL_CALL(glUniformMatrix4fv(0, 1, GL_FALSE, *matrix));
+ // TODO: source alpha from somewhere else I guess
+ GL_CALL(glUniform1f(2, 1.0f));
draw_quad();
return true;
}
@@ -163,6 +148,18 @@ static void wlr_gles2_render_ellipse(struct wlr_renderer_state *state,
draw_quad();
}
+static const enum wl_shm_format *wlr_gles2_formats(
+ struct wlr_renderer_state *state, size_t *len) {
+ static enum wl_shm_format formats[] = {
+ WL_SHM_FORMAT_ARGB8888,
+ WL_SHM_FORMAT_XRGB8888,
+ WL_SHM_FORMAT_ABGR8888,
+ WL_SHM_FORMAT_XBGR8888,
+ };
+ *len = sizeof(formats) / sizeof(formats[0]);
+ return formats;
+}
+
static void wlr_gles2_destroy(struct wlr_renderer_state *state) {
// no-op
}
@@ -174,6 +171,7 @@ static struct wlr_renderer_impl wlr_renderer_impl = {
.render_with_matrix = wlr_gles2_render_surface,
.render_quad = wlr_gles2_render_quad,
.render_ellipse = wlr_gles2_render_ellipse,
+ .formats = wlr_gles2_formats,
.destroy = wlr_gles2_destroy
};