summaryrefslogtreecommitdiff
path: root/src/main.cpp
blob: 28886fa217ca7c595933ec0a0c909dbbd9465b5b (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
49
#include "game.h"
#include "game/assets.h"

// disable new_delete_type_mismatch asan warning
#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;

void 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;
  }

  game_main_loop( game );
}

int main() {
  if( !canvas )
    canvas = (I32*)malloc( sizeof(I32) * 2 );

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

  while( true ) {
    loop();
  }

  game_destroy( game );
  return 0;
}