fix mixing up of SDL and libc allocators, proper flushing of quad build buffers
This commit is contained in:
		@@ -14,11 +14,11 @@
 | 
			
		||||
void game_tick(void) {
 | 
			
		||||
    if (ctx.initialization_needed) {
 | 
			
		||||
        if (!ctx.udata) {
 | 
			
		||||
            ctx.udata = ccalloc(1, sizeof (State));
 | 
			
		||||
            ctx.udata = calloc(1, sizeof (State));
 | 
			
		||||
 | 
			
		||||
            State *state = ctx.udata;
 | 
			
		||||
            state->ctx = &ctx;
 | 
			
		||||
            state->scene = ingame_scene(state);
 | 
			
		||||
            state->scene = title_scene(state);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,7 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define TERRAIN_FREQUENCY 0.15f
 | 
			
		||||
#define TERRAIN_DISTANCE 100
 | 
			
		||||
#define TERRAIN_DISTANCE 64
 | 
			
		||||
#define HALF_TERRAIN_DISTANCE ((float)TERRAIN_DISTANCE / 2)
 | 
			
		||||
#define PLAYER_HEIGHT 0.6f
 | 
			
		||||
 | 
			
		||||
@@ -237,7 +237,7 @@ static void ingame_end(State *state) {
 | 
			
		||||
Scene *ingame_scene(State *state) {
 | 
			
		||||
    (void)state;
 | 
			
		||||
 | 
			
		||||
    SceneIngame *new_scene = ccalloc(1, sizeof *new_scene);
 | 
			
		||||
    SceneIngame *new_scene = calloc(1, sizeof *new_scene);
 | 
			
		||||
    new_scene->base.tick = ingame_tick;
 | 
			
		||||
    new_scene->base.end = ingame_end;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,7 @@ static void title_tick(State *state) {
 | 
			
		||||
 | 
			
		||||
    /* draw the tick count as an example of dynamic text */
 | 
			
		||||
    size_t text_str_len = snprintf(NULL, 0, "%llu", (unsigned long long)state->ctx->frame_number) + 1;
 | 
			
		||||
    char *text_str = cmalloc(text_str_len);
 | 
			
		||||
    char *text_str = malloc(text_str_len);
 | 
			
		||||
    snprintf(text_str, text_str_len, "%llu", (unsigned long long)state->ctx->frame_number);
 | 
			
		||||
 | 
			
		||||
    const char *font = "/fonts/kenney-pixel.ttf";
 | 
			
		||||
@@ -34,8 +34,8 @@ static void title_tick(State *state) {
 | 
			
		||||
        (Rect) {
 | 
			
		||||
            .x = 0,
 | 
			
		||||
            .y = 0,
 | 
			
		||||
            .w = text_w,
 | 
			
		||||
            .h = text_h,
 | 
			
		||||
            .w = (float)text_w,
 | 
			
		||||
            .h = (float)text_h,
 | 
			
		||||
        },
 | 
			
		||||
        (Color) { 0, 0, 0, 255 }
 | 
			
		||||
    );
 | 
			
		||||
@@ -53,7 +53,7 @@ static void title_end(State *state) {
 | 
			
		||||
Scene *title_scene(State *state) {
 | 
			
		||||
    (void)state;
 | 
			
		||||
 | 
			
		||||
    SceneTitle *new_scene = ccalloc(1, sizeof *new_scene);
 | 
			
		||||
    SceneTitle *new_scene = calloc(1, sizeof *new_scene);
 | 
			
		||||
    new_scene->base.tick = title_tick;
 | 
			
		||||
    new_scene->base.end = title_end;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user