summaryrefslogtreecommitdiff
path: root/src/main.cpp
blob: 451c014093f0eeb59e2931d107ccfae5cd7c4b72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "game.h"
#include "game/assets.h"

#ifndef __has_feature
  #define __has_feature(feature) 0
#endif
#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
  #ifdef __cplusplus
    extern "C"
  #endif
  const char *__asan_default_options() { return "new_delete_type_mismatch=0"; }
#endif

I32* canvas;
GAME_DATA* game;
GL_DATA* gl;

U8 loop() {
  static U8 init = 0;

  if( !init || !gl ) {
    gl = gl_create( canvas );
    memcpy( gl->canvas_size, canvas, sizeof(I32) * 2 );

    gl_gen_buffers( gl );
    game = game_init( gl );

    init = 1;
    return 0;
  }

  return game_main_loop( game );
}

int main(int argc, char* argv[]) {
  if( !canvas )
    canvas = (I32*)malloc( sizeof(I32) * 2 );

  canvas[0] = 800;
  canvas[1] = 600;

  for( ;; ) {
    if( loop() ) break;
  }

  game_destroy( game );
  return 0;
}