diff options
author | NeKit <nekit1000@gmail.com> | 2018-06-13 13:43:01 +0300 |
---|---|---|
committer | NeKit <nekit1000@gmail.com> | 2018-06-13 13:43:01 +0300 |
commit | 6f29db10446662ac6741e4a63bac74380f01199e (patch) | |
tree | 723b0bbdeae45c4a6abdaa5a630018d8363c11a0 /render | |
parent | de91c55ea9da1b4c22bc377a7013efdcc71fff06 (diff) |
gles2 renderer: introduce struct wlr_gles2_tex_shader
Diffstat (limited to 'render')
-rw-r--r-- | render/gles2/renderer.c | 34 |
1 files changed, 9 insertions, 25 deletions
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index dce59d88..05426fa9 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -118,38 +118,22 @@ static bool gles2_render_texture_with_matrix(struct wlr_renderer *wlr_renderer, struct wlr_gles2_texture *texture = get_gles2_texture_in_context(wlr_texture); - GLuint prog = 0; + struct wlr_gles2_tex_shader *shader = NULL; GLenum target = 0; - GLint proj_loc = 0; - GLint invert_y_loc = 0; - GLint tex_loc = 0; - GLint alpha_loc = 0; switch (texture->type) { case WLR_GLES2_TEXTURE_GLTEX: case WLR_GLES2_TEXTURE_WL_DRM_GL: if (texture->has_alpha) { - prog = renderer->shaders.tex_rgba.program; - proj_loc = renderer->shaders.tex_rgba.proj; - invert_y_loc = renderer->shaders.tex_rgba.invert_y; - tex_loc = renderer->shaders.tex_rgba.tex; - alpha_loc = renderer->shaders.tex_rgba.alpha; + shader = &renderer->shaders.tex_rgba; } else { - prog = renderer->shaders.tex_rgbx.program; - proj_loc = renderer->shaders.tex_rgbx.proj; - invert_y_loc = renderer->shaders.tex_rgbx.invert_y; - tex_loc = renderer->shaders.tex_rgbx.tex; - alpha_loc = renderer->shaders.tex_rgbx.alpha; + shader = &renderer->shaders.tex_rgbx; } target = GL_TEXTURE_2D; break; case WLR_GLES2_TEXTURE_WL_DRM_EXT: case WLR_GLES2_TEXTURE_DMABUF: - prog = renderer->shaders.tex_ext.program; - proj_loc = renderer->shaders.tex_ext.proj; - invert_y_loc = renderer->shaders.tex_ext.invert_y; - tex_loc = renderer->shaders.tex_ext.tex; - alpha_loc = renderer->shaders.tex_ext.alpha; + shader = &renderer->shaders.tex_ext; target = GL_TEXTURE_EXTERNAL_OES; break; } @@ -169,12 +153,12 @@ static bool gles2_render_texture_with_matrix(struct wlr_renderer *wlr_renderer, glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glUseProgram(prog); + glUseProgram(shader->program); - glUniformMatrix3fv(proj_loc, 1, GL_FALSE, transposition); - glUniform1i(invert_y_loc, texture->inverted_y); - glUniform1f(alpha_loc, alpha); - glUniform1i(tex_loc, 0); + glUniformMatrix3fv(shader->proj, 1, GL_FALSE, transposition); + glUniform1i(shader->invert_y, texture->inverted_y); + glUniform1i(shader->tex, 0); + glUniform1f(shader->alpha, alpha); draw_quad(); |