Add graphics test
This commit is contained in:
parent
7a3b8a38f2
commit
018a808bda
@ -18,7 +18,7 @@ A unigi app is built from different layers:
|
||||
* **[Headers](https://git.lumen.sh/Fierelier/unigi.headers)** - The functions to be implemented by the Platform
|
||||
* **[Platform](#official-platforms)** - Implements the functions from Headers to work on a particular system
|
||||
* **...** - Optionally, more layers
|
||||
* **App** - Your code, uses other layers for input/output
|
||||
* **App** - Your code, uses other layers for input/output. You can find examples in test/\*
|
||||
|
||||
# Platforms
|
||||
Platforms act as the translation layer for different systems. The idea is to minimize the amount of work it takes to port graphical applications.
|
||||
|
36
test/graphics.c
Normal file
36
test/graphics.c
Normal file
@ -0,0 +1,36 @@
|
||||
#include "../../unigi.headers/src/main.h"
|
||||
#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();
|
||||
unigi_type_resolution res;
|
||||
res.width = 640;
|
||||
res.height = 480;
|
||||
res.depth = 32;
|
||||
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) {
|
||||
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);
|
||||
unigi_graphics_draw((((y * res.width) + x) + t) % max,(t + (x ^ y)) + y);
|
||||
}
|
||||
t2++;
|
||||
}
|
||||
unigi_graphics_flush();
|
||||
t++;
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user