2022-08-13 16:14:23 +10:00
|
|
|
#ifndef _SWAY_OPENGL_H
|
|
|
|
#define _SWAY_OPENGL_H
|
|
|
|
|
|
|
|
#include <GLES2/gl2.h>
|
2022-11-12 13:21:51 +11:00
|
|
|
#include <GLES2/gl2ext.h>
|
2022-10-10 02:47:34 +11:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2022-11-12 12:05:05 +11:00
|
|
|
enum corner_location { ALL, TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT };
|
2022-08-13 16:14:23 +10:00
|
|
|
|
|
|
|
struct gles2_tex_shader {
|
|
|
|
GLuint program;
|
|
|
|
GLint proj;
|
|
|
|
GLint tex;
|
|
|
|
GLint alpha;
|
|
|
|
GLint pos_attrib;
|
|
|
|
GLint tex_attrib;
|
2022-10-26 17:48:49 +11:00
|
|
|
GLint size;
|
2022-08-30 08:25:11 +10:00
|
|
|
GLint position;
|
|
|
|
GLint radius;
|
2022-11-12 11:38:09 +11:00
|
|
|
GLint saturation;
|
2022-11-11 17:19:02 +11:00
|
|
|
GLint has_titlebar;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rounded_quad_shader {
|
|
|
|
GLuint program;
|
|
|
|
GLint proj;
|
|
|
|
GLint color;
|
|
|
|
GLint pos_attrib;
|
|
|
|
GLint size;
|
|
|
|
GLint position;
|
|
|
|
GLint radius;
|
2022-08-13 16:14:23 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
struct fx_renderer {
|
|
|
|
struct wlr_egl *egl;
|
|
|
|
|
|
|
|
float projection[9];
|
|
|
|
|
2022-11-12 13:21:51 +11:00
|
|
|
struct {
|
|
|
|
bool OES_egl_image_external;
|
|
|
|
} exts;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES;
|
|
|
|
} procs;
|
|
|
|
|
|
|
|
|
2022-08-13 16:14:23 +10:00
|
|
|
// Shaders
|
|
|
|
struct {
|
|
|
|
struct {
|
|
|
|
GLuint program;
|
|
|
|
GLint proj;
|
|
|
|
GLint color;
|
|
|
|
GLint pos_attrib;
|
|
|
|
} quad;
|
2022-11-11 17:19:02 +11:00
|
|
|
|
2022-11-12 12:05:05 +11:00
|
|
|
struct rounded_quad_shader rounded_quad;
|
2022-11-11 17:19:02 +11:00
|
|
|
struct rounded_quad_shader rounded_tl_quad;
|
|
|
|
struct rounded_quad_shader rounded_tr_quad;
|
|
|
|
|
2022-10-10 02:47:34 +11:00
|
|
|
struct {
|
|
|
|
GLuint program;
|
|
|
|
GLint proj;
|
|
|
|
GLint color;
|
|
|
|
GLint pos_attrib;
|
|
|
|
GLint is_top_left;
|
|
|
|
GLint is_top_right;
|
|
|
|
GLint is_bottom_left;
|
|
|
|
GLint is_bottom_right;
|
|
|
|
GLint position;
|
|
|
|
GLint radius;
|
2022-10-26 15:25:33 +11:00
|
|
|
GLint half_size;
|
|
|
|
GLint half_thickness;
|
2022-10-10 02:47:34 +11:00
|
|
|
} corner;
|
2022-11-11 17:19:02 +11:00
|
|
|
|
2022-08-13 16:14:23 +10:00
|
|
|
struct gles2_tex_shader tex_rgba;
|
|
|
|
struct gles2_tex_shader tex_rgbx;
|
|
|
|
struct gles2_tex_shader tex_ext;
|
|
|
|
} shaders;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct fx_renderer *fx_renderer_create(struct wlr_egl *egl);
|
|
|
|
|
|
|
|
void fx_renderer_begin(struct fx_renderer *renderer, uint32_t width, uint32_t height);
|
|
|
|
|
|
|
|
void fx_renderer_end();
|
|
|
|
|
|
|
|
void fx_renderer_clear(const float color[static 4]);
|
|
|
|
|
|
|
|
void fx_renderer_scissor(struct wlr_box *box);
|
|
|
|
|
2022-08-30 08:25:11 +10:00
|
|
|
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],
|
2022-11-12 11:38:09 +11:00
|
|
|
float alpha, int radius, float saturation, const bool has_titlebar);
|
2022-08-13 16:14:23 +10:00
|
|
|
|
2022-08-30 08:25:11 +10:00
|
|
|
bool fx_render_texture_with_matrix(struct fx_renderer *renderer, struct wlr_texture *wlr_texture,
|
2022-11-12 11:38:09 +11:00
|
|
|
const struct wlr_box *dst_box, const float matrix[static 9], float alpha, int radius, float saturation,
|
2022-11-11 17:19:02 +11:00
|
|
|
const bool has_titlebar);
|
2022-08-13 16:14:23 +10:00
|
|
|
|
2022-08-30 08:25:11 +10:00
|
|
|
void fx_render_rect(struct fx_renderer *renderer, const struct wlr_box *box,
|
|
|
|
const float color[static 4], const float projection[static 9]);
|
2022-08-22 06:30:00 +10:00
|
|
|
|
2022-11-11 17:19:02 +11:00
|
|
|
void fx_render_rounded_rect(struct fx_renderer *renderer, const struct wlr_box *box,
|
|
|
|
const float color[static 4], const float projection[static 9],
|
|
|
|
int radius, enum corner_location corner_location);
|
|
|
|
|
2022-10-10 02:47:34 +11:00
|
|
|
void fx_render_border_corner(struct fx_renderer *renderer, const struct wlr_box *box,
|
|
|
|
const float color[static 4], const float projection[static 9],
|
|
|
|
enum corner_location corner_location, int radius, int border_thickness);
|
|
|
|
|
2022-08-13 16:14:23 +10:00
|
|
|
#endif
|