-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathshader.c
30 lines (27 loc) · 990 Bytes
/
shader.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "tigr.h"
#include "math.h"
const char fxShader[] =
"void fxShader(out vec4 color, in vec2 uv) {"
" vec2 tex_size = vec2(textureSize(image, 0));"
" vec4 c = texture(image, (floor(uv * tex_size) + 0.5 * sin(parameters.x)) / tex_size);"
" color = c;"
"}";
int main(int argc, char* argv[]) {
Tigr* screen = tigrWindow(320, 240, "Shady", 0);
tigrSetPostShader(screen, fxShader, sizeof(fxShader) - 1);
float duration = 1;
float phase = 0;
while (!tigrClosed(screen) && !tigrKeyDown(screen, TK_ESCAPE)) {
phase += tigrTime();
while (phase > duration) {
phase -= duration;
}
float p = 6.28 * phase / duration;
tigrSetPostFX(screen, p, 0, 0, 0);
tigrClear(screen, tigrRGB(0x80, 0x90, 0xa0));
tigrPrint(screen, tfont, 120, 110, tigrRGB(0xff, 0xff, 0xff), "Shady business");
tigrUpdate(screen);
}
tigrFree(screen);
return 0;
}