aboutsummaryrefslogtreecommitdiff
path: root/src/utils.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2025-03-13 22:34:29 +0100
committerdec05eba <dec05eba@protonmail.com>2025-03-13 22:34:29 +0100
commitb0de8588f2f4a5204e9bc22218eed884fa741153 (patch)
tree6089c4688e9e65ce1f0d1ac3ee9709a020e0d942 /src/utils.c
parentf63409bdd758b80f3a4e414fd5cb5526e384c93a (diff)
Take screenshot with XGetImage on x11 to workaround nvidia driver (nvfbc) limitation that only allows one nvfbc session at a time
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c
index 473ac96..f053eed 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -912,3 +912,18 @@ vec2i scale_keep_aspect_ratio(vec2i from, vec2i to) {
return from;
}
+
+unsigned int gl_create_texture(gsr_egl *egl, int width, int height, int internal_format, unsigned int format, int filter) {
+ unsigned int texture_id = 0;
+ egl->glGenTextures(1, &texture_id);
+ egl->glBindTexture(GL_TEXTURE_2D, texture_id);
+ egl->glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format, GL_UNSIGNED_BYTE, NULL);
+
+ egl->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ egl->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ egl->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
+ egl->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
+
+ egl->glBindTexture(GL_TEXTURE_2D, 0);
+ return texture_id;
+}