glerminal/examples/basic.cpp

59 lines
941 B
C++
Raw Normal View History

2024-05-09 19:42:12 +00:00
#include <glerminal.h>
2024-05-15 02:42:49 +00:00
#include <cstdlib>
2024-05-14 21:46:30 +00:00
namespace
{
void init()
{
2024-05-14 22:16:06 +00:00
glerminal_update_palette(0, 0x00000000);
2024-05-15 02:42:49 +00:00
glerminal_update_palette(1, 0xFF00007F);
glerminal_update_palette(2, 0x00FF007F);
2024-05-14 21:46:30 +00:00
2024-05-14 22:16:06 +00:00
glerminal_update_sprite(1, {
2, 2, 2, 2, 2, 2, 2, 2,
2, 1, 1, 1, 1, 1, 1, 2,
2, 1, 1, 1, 1, 1, 1, 2,
2, 1, 1, 1, 1, 1, 1, 2,
2, 1, 1, 1, 1, 1, 1, 2,
2, 1, 1, 1, 1, 1, 1, 2,
2, 1, 1, 1, 1, 1, 1, 2,
2, 2, 2, 2, 2, 2, 2, 2
2024-05-14 21:46:30 +00:00
});
}
void mainloop(float dt)
{
2024-05-15 02:42:49 +00:00
static float time = 1;
time += dt;
if (time < 0.2f)
{
return;
}
else
{
time = 0;
}
for (int i = 0; i < 32; i++)
{
for (int j = 0; j < 20; j++)
{
for (int k = 0; k < 16; k++)
{
glerminal_set(i, j, k, 1);
glerminal_offset(i, j, k, (rand() * rand()) % 256 - 128, (rand() * rand()) % 256 - 128);
}
}
}
2024-05-14 21:46:30 +00:00
glerminal_flush();
}
}
2024-05-09 19:42:12 +00:00
int main(int argc, char** argv)
{
2024-05-14 21:46:30 +00:00
glerminal_run(init, mainloop);
2024-05-09 19:42:12 +00:00
}