tourne et manege

This commit is contained in:
Mylloon 2023-05-25 10:29:35 +02:00
parent 2363588e88
commit 1472c11a0a
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
4 changed files with 59 additions and 5 deletions

View file

@ -23,6 +23,9 @@ void transitionsInit(void);
// Transition zoom // Transition zoom
void zoomIn(void (*)(int), void (*)(int), Uint32, Uint32, const int); void zoomIn(void (*)(int), void (*)(int), Uint32, Uint32, const int);
// Transition qui tourne
void rotation(void (*)(int), void (*)(int), Uint32, Uint32, const int);
// Personnage // Personnage
struct manifestant { struct manifestant {
GLuint corps, tete, jambe_g, jambe_d, bras_g, bras_d; GLuint corps, tete, jambe_g, jambe_d, bras_g, bras_d;

10
main.c
View file

@ -20,11 +20,11 @@ int main(const int argc, char *argv[]) {
} }
// Animations // Animations
GL4DHanime animations[] = {{10000, manif, NULL, NULL}, // Manifestation GL4DHanime animations[] = {{10000, manif, NULL, NULL}, // Manifestation
{2000, manif, tag, zoomIn}, // Transition {2000, manif, tag, zoomIn}, // Transition
{10000, tag, NULL, NULL}, // Tag {10000, tag, NULL, NULL}, // Tag
{2000, tag, credits, zoomIn}, // Transition {2000, tag, credits, rotation}, // Transition
{9500, credits, NULL, NULL}, // Crédits {9500, credits, NULL, NULL}, // Crédits
{0, NULL, NULL, NULL}}; {0, NULL, NULL, NULL}};
gl4dhInit(animations, _dims[0], _dims[1], init); gl4dhInit(animations, _dims[0], _dims[1], init);

25
shaders/rotation.fs Normal file
View file

@ -0,0 +1,25 @@
#version 330
uniform sampler2D tex0;
uniform sampler2D tex1;
uniform float progress;
in vec2 vsoTexCoord;
out vec4 fragColor;
void main() {
vec2 center = vec2(.5);
vec2 offset = vsoTexCoord - center;
float angle = progress * radians(180) * 2;
float sinTheta = sin(angle);
float cosTheta = cos(angle);
vec2 rotatedOffset = vec2(cosTheta * offset.x - sinTheta * offset.y, sinTheta * offset.x + cosTheta * offset.y);
vec2 distortedTexCoord = center + rotatedOffset;
vec4 color1 = texture(tex0, vsoTexCoord);
vec4 color2 = texture(tex1, distortedTexCoord);
fragColor = mix(color1, color2, smoothstep(0., 1., progress));
}

View file

@ -195,3 +195,29 @@ void drawManifestant(const char *matrix_model, const struct manifestant *hero,
gl4duSendMatrices(); gl4duSendMatrices();
gl4dgDraw(hero->bras_d); gl4dgDraw(hero->bras_d);
} }
void rotation(void (*a0)(int), void (*a1)(int), Uint32 t, Uint32 et,
const int state) {
const int gpu = 1;
static GLuint tex[2];
switch (state) {
case GL4DH_INIT:
transition_init("rotation", gpu, tex);
break;
case GL4DH_DRAW:
transition_draw(a0, a1, t, et, state, gpu, tex);
break;
case GL4DH_FREE:
transition_deinit(tex);
break;
case GL4DH_UPDATE_WITH_AUDIO:
update_with_audio(a0, a1, state);
break;
default:
break;
}
}