glerminal/examples/basic.cpp

55 lines
1.4 KiB
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-17 04:51:45 +00:00
glerminal_update_sprite(1, {
0x5000FF00, 0x5000FF00, 0x5000FF00, 0x5000FF00, 0x5000FF00, 0x5000FF00, 0x5000FF00, 0x5000FF00,
0x5000FF00, 0x500000FF, 0x500000FF, 0x500000FF, 0x500000FF, 0x500000FF, 0x500000FF, 0x5000FF00,
0x5000FF00, 0x500000FF, 0x500000FF, 0x500000FF, 0x500000FF, 0x500000FF, 0x500000FF, 0x5000FF00,
0x5000FF00, 0x500000FF, 0x500000FF, 0x500000FF, 0x500000FF, 0x500000FF, 0x500000FF, 0x5000FF00,
0x5000FF00, 0x500000FF, 0x500000FF, 0x500000FF, 0x500000FF, 0x500000FF, 0x500000FF, 0x5000FF00,
0x5000FF00, 0x500000FF, 0x500000FF, 0x500000FF, 0x500000FF, 0x500000FF, 0x500000FF, 0x5000FF00,
0x5000FF00, 0x500000FF, 0x500000FF, 0x500000FF, 0x500000FF, 0x500000FF, 0x500000FF, 0x5000FF00,
0x5000FF00, 0x5000FF00, 0x5000FF00, 0x5000FF00, 0x5000FF00, 0x5000FF00, 0x5000FF00, 0x5000FF00
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;
}
2024-05-15 03:03:45 +00:00
for (int i = 0; i < 40; i++)
2024-05-15 02:42:49 +00:00
{
2024-05-15 03:03:45 +00:00
for (int j = 0; j < 25; j++)
2024-05-15 02:42:49 +00:00
{
2024-05-17 04:51:45 +00:00
for (int k = 0; k < 256; k++)
2024-05-15 02:42:49 +00:00
{
2024-05-17 04:51:45 +00:00
glerminal_set(i, j, k, rand() % 8 == 0);
glerminal_offset(i, j, k, (rand() * rand()) % 64 - 32, (rand() * rand()) % 64 - 32);
2024-05-15 02:42:49 +00:00
}
}
}
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
}