aboutsummaryrefslogtreecommitdiff
path: root/render/surface.c
blob: 930e118dc4a63d62bbcb4c8ff1c2458119b3bb6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
#include <GLES3/gl3.h>
#include <wayland-util.h>
#include <wayland-server-protocol.h>
#include <wlr/render.h>
#include <wlr/render/matrix.h>
#include "render.h"

struct wlr_surface *wlr_surface_init() {
	return calloc(sizeof(struct wlr_surface), 1);
}

void wlr_surface_attach_pixels(struct wlr_surface *surf, uint32_t format,
		int width, int height, const unsigned char *pixels) {
	assert(surf);
	surf->width = width;
	surf->height = height;
	surf->format = format;
	// TODO: Error handling
	glGenTextures(1, &surf->tex_id);
	glBindTexture(GL_TEXTURE_2D, surf->tex_id);
	glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0,
			format, GL_UNSIGNED_BYTE, pixels);
	surf->valid = true;
}

void wlr_surface_attach_shm(struct wlr_surface *surf, uint32_t format,
		struct wl_shm_buffer *shm);

void wlr_surface_destroy(struct wlr_surface *tex) {
	// TODO
}