summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/opengl/utils.h')
-rw-r--r--video/out/opengl/utils.h27
1 files changed, 24 insertions, 3 deletions
diff --git a/video/out/opengl/utils.h b/video/out/opengl/utils.h
index 3ec6077bf5..170e24d71a 100644
--- a/video/out/opengl/utils.h
+++ b/video/out/opengl/utils.h
@@ -71,7 +71,8 @@ struct fbotex {
GLuint texture;
GLenum iformat;
GLenum tex_filter;
- int w, h; // size of .texture
+ int rw, rh; // real (texture) size
+ int lw, lh; // logical (configured) size
};
bool fbotex_init(struct fbotex *fbo, GL *gl, struct mp_log *log, int w, int h,
@@ -86,10 +87,18 @@ void fbotex_set_filter(struct fbotex *fbo, GLenum gl_filter);
// A 3x2 matrix, with the translation part separate.
struct gl_transform {
+ // row-major, e.g. in mathematical notation:
+ // | m[0][0] m[0][1] |
+ // | m[1][0] m[1][1] |
float m[2][2];
float t[2];
};
+static const struct gl_transform identity_trans = {
+ .m = {{1.0, 0.0}, {0.0, 1.0}},
+ .t = {0.0, 0.0},
+};
+
void gl_transform_ortho(struct gl_transform *t, float x0, float x1,
float y0, float y1);
@@ -98,8 +107,8 @@ void gl_transform_ortho(struct gl_transform *t, float x0, float x1,
static inline void gl_transform_vec(struct gl_transform t, float *x, float *y)
{
float vx = *x, vy = *y;
- *x = vx * t.m[0][0] + vy * t.m[1][0] + t.t[0];
- *y = vx * t.m[0][1] + vy * t.m[1][1] + t.t[1];
+ *x = vx * t.m[0][0] + vy * t.m[0][1] + t.t[0];
+ *y = vx * t.m[1][0] + vy * t.m[1][1] + t.t[1];
}
struct mp_rect_f {
@@ -112,6 +121,18 @@ static inline void gl_transform_rect(struct gl_transform t, struct mp_rect_f *r)
gl_transform_vec(t, &r->x1, &r->y1);
}
+static inline bool gl_transform_eq(struct gl_transform a, struct gl_transform b)
+{
+ for (int x = 0; x < 2; x++) {
+ for (int y = 0; y < 2; y++) {
+ if (a.m[x][y] != b.m[x][y])
+ return false;
+ }
+ }
+
+ return a.t[0] == b.t[0] && a.t[1] == b.t[1];
+}
+
void gl_transform_trans(struct gl_transform t, struct gl_transform *x);
void gl_set_debug_logger(GL *gl, struct mp_log *log);