glerminal/examples/basic.cpp

43 lines
680 B
C++

#include <glerminal.h>
#include <cstdlib>
#include <cmath>
namespace
{
void init()
{
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);
}
}
}
void mainloop(double dt)
{
static double time = 0;
time += dt;
time = fmodf(time, 3.1415926f * 2);
for (int i = 0; i < GRID_WIDTH + 2; i++)
{
for (int j = 0; j < GRID_HEIGHT + 2; j++)
{
glerminal_offset(i, j, 0, cosf(time - i / 3.1415f), sinf(time - j / 3.1415f));
}
}
glerminal_flush();
}
}
int main(int argc, char** argv)
{
glerminal_run({init, mainloop});
}