glerminal/examples/basic.cpp

43 lines
680 B
C++
Raw Normal View History

2024-05-09 15:42:12 -04:00
#include <glerminal.h>
2024-05-14 21:42:49 -05:00
#include <cstdlib>
2024-05-25 23:16:23 -04:00
#include <cmath>
2024-05-14 21:42:49 -05:00
2024-05-14 16:46:30 -05:00
namespace
{
void init()
{
2024-05-19 21:46:56 -05:00
glerminal_load_sprites_file("resources/basic.png");
for (int i = 0; i < GRID_WIDTH + 2; i++)
{
for (int j = 0; j < GRID_HEIGHT + 2; j++)
{
glerminal_set(i, j, 0, 1);
}
}
2024-05-14 16:46:30 -05:00
}
2024-06-11 00:40:43 -04:00
void mainloop(double dt)
2024-05-14 16:46:30 -05:00
{
2024-06-11 00:40:43 -04:00
static double time = 0;
2024-05-14 21:42:49 -05:00
time += dt;
time = fmodf(time, 3.1415926f * 2);
2024-05-14 21:42:49 -05:00
for (int i = 0; i < GRID_WIDTH + 2; i++)
2024-05-14 21:42:49 -05:00
{
for (int j = 0; j < GRID_HEIGHT + 2; j++)
2024-05-14 21:42:49 -05:00
{
glerminal_offset(i, j, 0, cosf(time - i / 3.1415f), sinf(time - j / 3.1415f));
2024-05-14 21:42:49 -05:00
}
}
2024-05-14 16:46:30 -05:00
glerminal_flush();
}
}
2024-05-09 15:42:12 -04:00
int main(int argc, char** argv)
{
2024-06-11 00:40:43 -04:00
glerminal_run({init, mainloop});
2024-05-09 15:42:12 -04:00
}