summaryrefslogtreecommitdiff
path: root/include/render
diff options
context:
space:
mode:
authorErik Reider <[email protected]>2023-07-13 14:55:28 +0200
committerWilliam McKinnon <[email protected]>2023-07-18 13:14:53 -0400
commitd462d952de20bdb7c3c84b05ed94d15b07ee5116 (patch)
tree7cbe0e380c6c130495a30d8728365ab49cc4d956 /include/render
parent920c3c70d20e58b4af5a7abe52b24f47b90bc575 (diff)
feat: initial fx_renderer implementation
Diffstat (limited to 'include/render')
-rw-r--r--include/render/fx_renderer/fx_renderer.h80
-rw-r--r--include/render/fx_renderer/matrix.h9
2 files changed, 89 insertions, 0 deletions
diff --git a/include/render/fx_renderer/fx_renderer.h b/include/render/fx_renderer/fx_renderer.h
new file mode 100644
index 0000000..085cd1c
--- /dev/null
+++ b/include/render/fx_renderer/fx_renderer.h
@@ -0,0 +1,80 @@
+#ifndef _FX_OPENGL_H
+#define _FX_OPENGL_H
+
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <stdbool.h>
+#include <wlr/render/egl.h>
+#include <wlr/render/wlr_texture.h>
+#include <wlr/util/addon.h>
+#include <wlr/util/box.h>
+
+enum fx_tex_shader_source {
+ SHADER_SOURCE_TEXTURE_RGBA = 1,
+ SHADER_SOURCE_TEXTURE_RGBX = 2,
+ SHADER_SOURCE_TEXTURE_EXTERNAL = 3,
+};
+
+struct quad_shader {
+ GLuint program;
+ GLint proj;
+ GLint color;
+ GLint pos_attrib;
+};
+
+struct tex_shader {
+ GLuint program;
+ GLint proj;
+ GLint tex;
+ GLint alpha;
+ GLint pos_attrib;
+ GLint tex_attrib;
+ GLint size;
+ GLint position;
+ GLint radius;
+};
+
+struct fx_renderer {
+ float projection[9];
+
+ struct wlr_addon addon;
+
+ struct {
+ bool OES_egl_image_external;
+ } exts;
+
+ struct {
+ PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES;
+ } procs;
+
+ struct {
+ struct quad_shader quad;
+ struct tex_shader tex_rgba;
+ struct tex_shader tex_rgbx;
+ struct tex_shader tex_ext;
+ } shaders;
+};
+
+void fx_renderer_init_addon(struct wlr_egl *egl, struct wlr_addon_set *addons,
+ const void * owner);
+
+struct fx_renderer *fx_renderer_addon_find(struct wlr_addon_set *addons,
+ const void * owner);
+
+struct fx_renderer *fx_renderer_create(struct wlr_egl *egl);
+
+void fx_renderer_fini(struct fx_renderer *renderer);
+
+void fx_renderer_begin(struct fx_renderer *renderer, int width, int height);
+
+void fx_renderer_clear(const float color[static 4]);
+
+void fx_renderer_scissor(struct wlr_box *box);
+
+bool fx_render_subtexture_with_matrix(struct fx_renderer *renderer, struct wlr_texture *wlr_texture,
+ const struct wlr_fbox *src_box, const struct wlr_box *dst_box, const float matrix[static 9]);
+
+void fx_render_rect(struct fx_renderer *renderer, const struct wlr_box *box,
+ const float color[static 4], const float projection[static 9]);
+
+#endif
diff --git a/include/render/fx_renderer/matrix.h b/include/render/fx_renderer/matrix.h
new file mode 100644
index 0000000..6931e8d
--- /dev/null
+++ b/include/render/fx_renderer/matrix.h
@@ -0,0 +1,9 @@
+#ifndef _MATRIX_H
+#define _MATRIX_H
+
+#include <wlr/types/wlr_output.h>
+
+void matrix_projection(float mat[static 9], int width, int height,
+ enum wl_output_transform transform);
+
+#endif