tourne et manege
This commit is contained in:
parent
2363588e88
commit
1472c11a0a
4 changed files with 59 additions and 5 deletions
|
@ -23,6 +23,9 @@ void transitionsInit(void);
|
|||
// Transition zoom
|
||||
void zoomIn(void (*)(int), void (*)(int), Uint32, Uint32, const int);
|
||||
|
||||
// Transition qui tourne
|
||||
void rotation(void (*)(int), void (*)(int), Uint32, Uint32, const int);
|
||||
|
||||
// Personnage
|
||||
struct manifestant {
|
||||
GLuint corps, tete, jambe_g, jambe_d, bras_g, bras_d;
|
||||
|
|
2
main.c
2
main.c
|
@ -23,7 +23,7 @@ int main(const int argc, char *argv[]) {
|
|||
GL4DHanime animations[] = {{10000, manif, NULL, NULL}, // Manifestation
|
||||
{2000, manif, tag, zoomIn}, // Transition
|
||||
{10000, tag, NULL, NULL}, // Tag
|
||||
{2000, tag, credits, zoomIn}, // Transition
|
||||
{2000, tag, credits, rotation}, // Transition
|
||||
{9500, credits, NULL, NULL}, // Crédits
|
||||
{0, NULL, NULL, NULL}};
|
||||
|
||||
|
|
25
shaders/rotation.fs
Normal file
25
shaders/rotation.fs
Normal 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));
|
||||
}
|
|
@ -195,3 +195,29 @@ void drawManifestant(const char *matrix_model, const struct manifestant *hero,
|
|||
gl4duSendMatrices();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue