transparent-cube

Minimal cross-platform native/wasm graphics example.
git clone git://git.amin.space/transparent-cube.git
Log | Files | Refs | README | LICENSE

game.h (795B)


      1 #pragma once
      2 
      3 #include <stddef.h>
      4 #include <stdint.h>
      5 #define static_assert _Static_assert
      6 
      7 #define NULL ((void*)0)
      8 
      9 // TODO: fix this
     10 #define assert(x) (void)0
     11 
     12 typedef _Bool bool;
     13 #define true 1
     14 #define false 0
     15 
     16 #ifdef GAME_WEBGL
     17 #include "webgl.h"
     18 #else
     19 #include "glad/glad.h"
     20 #endif
     21 
     22 #include "glmth.h"
     23 #include "shader.h"
     24 #include "platform.h"
     25 
     26 void *memcpy(void *dst, const void *src, size_t n)
     27 {
     28   u8 *destination = (u8 *)dst;
     29   u8 *source = (u8 *)src;
     30 
     31   while (n--) {
     32     *destination = *source;
     33     destination++;
     34     source++;
     35   }
     36 
     37   return dst;
     38 }
     39 
     40 // TODO: Consider finding a better way to make this func available
     41 static platform_print_func* print;
     42 
     43 void game_init(struct GameState *game_state, u32 screen_width, u32 screen_height);
     44 void game_cleanup(struct GameState *game_state);