use FBO for transitions !

This commit is contained in:
Mylloon 2023-05-27 04:14:29 +02:00
parent 9f055704fa
commit d88ffce303
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -3,7 +3,8 @@
/* Mise-à-jour des animations en fonction du son */
static void update_with_audio(void (*)(int), void (*)(int), int);
static GLuint _transition_pId[2] = {0}, _transition_tId = 0, _quadId = 0;
static GLuint _transition_pId[2] = {0}, _transition_tId = 0, _quadId = 0,
_transition_fbo[2] = {0};
static void transition_init(const char *, const int, GLuint *);
static void transition_draw(void (*)(int), void (*)(int), Uint32, Uint32, int,
int, GLuint *);
@ -23,6 +24,7 @@ void transitionsInit(void) {
if (!_quadId) {
_quadId = gl4dgGenQuadf();
}
glGenFramebuffers(2, _transition_fbo);
}
void zoomIn(void (*a0)(int), void (*a1)(int), Uint32 t, Uint32 et,
@ -75,18 +77,21 @@ static void transition_draw(void (*a0)(int), void (*a1)(int), Uint32 t,
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
(GLint *)&_transition_tId);
glBindFramebuffer(GL_FRAMEBUFFER, _transition_fbo[0]);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
tex[0], 0);
if (a0) {
a0(state);
}
glBindFramebuffer(GL_FRAMEBUFFER, _transition_fbo[1]);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
tex[1], 0);
if (a1) {
a1(state);
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
_transition_tId, 0);
@ -115,7 +120,11 @@ static void transition_draw(void (*a0)(int), void (*a1)(int), Uint32 t,
static void transition_deinit(GLuint *tex) {
if (tex[0]) {
glDeleteTextures(2, tex);
tex[0] = tex[1] = 0;
tex[0] = 0;
}
if (_transition_fbo[0]) {
glDeleteFramebuffers(2, _transition_fbo);
_transition_fbo[0] = 0;
}
}