remove ctx.update_multiplicity
This commit is contained in:
		@@ -72,11 +72,6 @@ typedef struct EngineContext {
 | 
				
			|||||||
    SDL_Window *window;
 | 
					    SDL_Window *window;
 | 
				
			||||||
    uint32_t window_id;
 | 
					    uint32_t window_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* this should be a multiple of the current ticks per second */
 | 
					 | 
				
			||||||
    /* use it to simulate low framerate (e.g. at 60 tps, set to 2 for 30 fps) */
 | 
					 | 
				
			||||||
    /* it can be changed at runtime; any resulting logic anomalies are bugs */
 | 
					 | 
				
			||||||
    uint32_t update_multiplicity;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    bool is_running;
 | 
					    bool is_running;
 | 
				
			||||||
    bool window_size_has_changed;
 | 
					    bool window_size_has_changed;
 | 
				
			||||||
    bool resync_flag;
 | 
					    bool resync_flag;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -204,34 +204,32 @@ static void main_loop(void) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /* finally, let's get to work */
 | 
					    /* finally, let's get to work */
 | 
				
			||||||
    int frames = 0;
 | 
					    int frames = 0;
 | 
				
			||||||
    while (ctx.frame_accumulator >= ctx.desired_frametime * ctx.update_multiplicity) {
 | 
					    while (ctx.frame_accumulator >= ctx.desired_frametime) {
 | 
				
			||||||
        frames += 1;
 | 
					        frames += 1;
 | 
				
			||||||
        for (size_t i = 0; i < ctx.update_multiplicity; ++i) {
 | 
					        /* TODO: disable rendering pushes on not-last ? */
 | 
				
			||||||
            /* TODO: disable rendering pushes on not-last ? */
 | 
					        render_queue_clear();
 | 
				
			||||||
            render_queue_clear();
 | 
					        poll_events();
 | 
				
			||||||
            poll_events();
 | 
					        if (ctx.window_size_has_changed)
 | 
				
			||||||
            if (ctx.window_size_has_changed)
 | 
					            update_viewport();
 | 
				
			||||||
                update_viewport();
 | 
					        input_state_update(&ctx.input);
 | 
				
			||||||
            input_state_update(&ctx.input);
 | 
					        game_object_tick();
 | 
				
			||||||
            game_object_tick();
 | 
					        input_state_update_postframe(&ctx.input);
 | 
				
			||||||
            input_state_update_postframe(&ctx.input);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            #ifdef TWN_FEATURE_PUSH_AUDIO
 | 
					        #ifdef TWN_FEATURE_PUSH_AUDIO
 | 
				
			||||||
            static uint8_t audio_buffer[(AUDIO_FREQUENCY / 60) * sizeof (float) * 2];
 | 
					        static uint8_t audio_buffer[(AUDIO_FREQUENCY / 60) * sizeof (float) * 2];
 | 
				
			||||||
            audio_callback(NULL, audio_buffer, sizeof audio_buffer);
 | 
					        audio_callback(NULL, audio_buffer, sizeof audio_buffer);
 | 
				
			||||||
            if (SDL_QueueAudio(ctx.audio_device, audio_buffer, sizeof audio_buffer))
 | 
					        if (SDL_QueueAudio(ctx.audio_device, audio_buffer, sizeof audio_buffer))
 | 
				
			||||||
                CRY_SDL("Error queueing audio: ");
 | 
					            CRY_SDL("Error queueing audio: ");
 | 
				
			||||||
            #endif
 | 
					        #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            preserve_persistent_ctx_fields();
 | 
					        preserve_persistent_ctx_fields();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            ctx.frame_accumulator -= ctx.desired_frametime;
 | 
					        ctx.frame_accumulator -= ctx.desired_frametime;
 | 
				
			||||||
            ctx.game.frame_number++;
 | 
					        ctx.game.frame_number++;
 | 
				
			||||||
            /* TODO: should we ask for reinitialization in such case? */
 | 
					        /* TODO: should we ask for reinitialization in such case? */
 | 
				
			||||||
            if (ctx.game.frame_number > 16777216)
 | 
					        if (ctx.game.frame_number > 16777216)
 | 
				
			||||||
                ctx.game.frame_number = 0;
 | 
					            ctx.game.frame_number = 0;
 | 
				
			||||||
            ctx.game.initialization_needed = false;
 | 
					        ctx.game.initialization_needed = false;
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* TODO: in some cases machine might want to assume frames will be fed as much as possible */
 | 
					    /* TODO: in some cases machine might want to assume frames will be fed as much as possible */
 | 
				
			||||||
@@ -555,9 +553,6 @@ static bool initialize(void) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* you could change this at runtime if you wanted */
 | 
					 | 
				
			||||||
    ctx.update_multiplicity = 1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /* random seeding */
 | 
					    /* random seeding */
 | 
				
			||||||
    /* SDL_GetPerformanceCounter returns some platform-dependent number. */
 | 
					    /* SDL_GetPerformanceCounter returns some platform-dependent number. */
 | 
				
			||||||
    /* it should vary between game instances. i checked! random enough for me. */
 | 
					    /* it should vary between game instances. i checked! random enough for me. */
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user