aboutsummaryrefslogtreecommitdiff
path: root/render/gles2/surface.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/surface.c
parent97f6e9b69aecf1fbcbc2fa95cb2009f873c86d40 (diff)
parent486ec5953cf51f5fde834bf8fa7fbe56f0be9a0e (diff)
Merge branch 'wlcore'
Diffstat (limited to 'render/gles2/surface.c')
-rw-r--r--render/gles2/surface.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/render/gles2/surface.c b/render/gles2/surface.c
index c9be6ac2..f730a499 100644
--- a/render/gles2/surface.c
+++ b/render/gles2/surface.c
@@ -8,19 +8,27 @@
#include <wlr/render.h>
#include <wlr/render/interface.h>
#include <wlr/render/matrix.h>
+#include <wlr/util/log.h>
#include "render/gles2.h"
static bool gles2_surface_attach_pixels(struct wlr_surface_state *surface,
- uint32_t format, int stride, int width, int height, const unsigned char *pixels) {
+ enum wl_shm_format format, int stride, int width, int height,
+ const unsigned char *pixels) {
assert(surface);
+ const struct pixel_format *fmt = gl_format_for_wl_format(format);
+ if (!fmt || !fmt->gl_format) {
+ wlr_log(L_ERROR, "No supported pixel format for this surface");
+ return false;
+ }
surface->wlr_surface->width = width;
surface->wlr_surface->height = height;
surface->wlr_surface->format = format;
+ surface->pixel_format = fmt;
GL_CALL(glGenTextures(1, &surface->tex_id));
GL_CALL(glBindTexture(GL_TEXTURE_2D, surface->tex_id));
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, stride));
- GL_CALL(glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0,
- format, GL_UNSIGNED_BYTE, pixels));
+ GL_CALL(glTexImage2D(GL_TEXTURE_2D, 0, fmt->gl_format, width, height, 0,
+ fmt->gl_format, fmt->gl_type, pixels));
GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, 0));
surface->wlr_surface->valid = true;
return true;
@@ -43,6 +51,7 @@ static void gles2_surface_bind(struct wlr_surface_state *surface) {
GL_CALL(glBindTexture(GL_TEXTURE_2D, surface->tex_id));
GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
+ GL_CALL(glUseProgram(*surface->pixel_format->shader));
}
static void gles2_surface_destroy(struct wlr_surface_state *surface) {