unigi/test/graphics.c

47 lines
1.1 KiB
C
Raw Normal View History

#include "../src/main.h"
2024-06-30 20:20:07 +00:00
#include "../../unigi.platform.sdl1/src/main.c"
uint32_t seed = 1337;
uint32_t example_random() {
seed = (seed * 1103515245 + 12345) & 0x7FFFFFFF;
return seed;
}
int main(int argc, char *argv[]) {
unigi_init();
2024-06-30 21:25:02 +00:00
unigi_type_event event;
2024-06-30 20:20:07 +00:00
unigi_type_resolution res;
2024-07-20 16:09:25 +00:00
res.width = 320;
res.height = 240;
2024-06-30 20:20:07 +00:00
res.depth = 32;
2024-07-20 17:39:02 +00:00
unigi_type_color pixels[res.width * res.height];
2024-06-30 20:20:07 +00:00
unigi_type_resolution_2d_coord x;
unigi_type_resolution_2d_coord y;
unigi_type_resolution_1d_coord max = res.width * res.height;
uint32_t t = 0;
uint32_t t2 = 0;
unigi_graphics_init();
unigi_window_create(res,"game");
while (1) {
2024-06-30 21:25:02 +00:00
unigi_event_get(&event);
if (event.type == unigi_enum_event_input_keyboard) {
exit(0);
}
2024-07-20 17:39:02 +00:00
2024-06-30 20:20:07 +00:00
for (y = 0; y < res.height; y++) {
for (x = 0; x < res.width; x++) {
//unigi_graphics_draw((y * res.width) + x,(t + (x ^ y)) + y);
2024-07-20 17:39:02 +00:00
//unigi_graphics_draw((((y * res.width) + x) + t) % max,(t + (x ^ y)) + y);
pixels[(((y * res.width) + x) + t) % max] = (t + (x ^ y)) + y;
2024-06-30 20:20:07 +00:00
}
t2++;
}
2024-07-20 16:09:25 +00:00
unigi_graphics_blit(0,pixels,res.width * res.height);
2024-06-30 20:20:07 +00:00
unigi_graphics_flush();
t++;
}
return 0;
}