remove ctx.update_multiplicity
This commit is contained in:
parent
688d71953a
commit
851ab80292
@ -72,11 +72,6 @@ typedef struct EngineContext {
|
||||
SDL_Window *window;
|
||||
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 window_size_has_changed;
|
||||
bool resync_flag;
|
||||
|
@ -204,34 +204,32 @@ static void main_loop(void) {
|
||||
|
||||
/* finally, let's get to work */
|
||||
int frames = 0;
|
||||
while (ctx.frame_accumulator >= ctx.desired_frametime * ctx.update_multiplicity) {
|
||||
while (ctx.frame_accumulator >= ctx.desired_frametime) {
|
||||
frames += 1;
|
||||
for (size_t i = 0; i < ctx.update_multiplicity; ++i) {
|
||||
/* TODO: disable rendering pushes on not-last ? */
|
||||
render_queue_clear();
|
||||
poll_events();
|
||||
if (ctx.window_size_has_changed)
|
||||
update_viewport();
|
||||
input_state_update(&ctx.input);
|
||||
game_object_tick();
|
||||
input_state_update_postframe(&ctx.input);
|
||||
/* TODO: disable rendering pushes on not-last ? */
|
||||
render_queue_clear();
|
||||
poll_events();
|
||||
if (ctx.window_size_has_changed)
|
||||
update_viewport();
|
||||
input_state_update(&ctx.input);
|
||||
game_object_tick();
|
||||
input_state_update_postframe(&ctx.input);
|
||||
|
||||
#ifdef TWN_FEATURE_PUSH_AUDIO
|
||||
static uint8_t audio_buffer[(AUDIO_FREQUENCY / 60) * sizeof (float) * 2];
|
||||
audio_callback(NULL, audio_buffer, sizeof audio_buffer);
|
||||
if (SDL_QueueAudio(ctx.audio_device, audio_buffer, sizeof audio_buffer))
|
||||
CRY_SDL("Error queueing audio: ");
|
||||
#endif
|
||||
#ifdef TWN_FEATURE_PUSH_AUDIO
|
||||
static uint8_t audio_buffer[(AUDIO_FREQUENCY / 60) * sizeof (float) * 2];
|
||||
audio_callback(NULL, audio_buffer, sizeof audio_buffer);
|
||||
if (SDL_QueueAudio(ctx.audio_device, audio_buffer, sizeof audio_buffer))
|
||||
CRY_SDL("Error queueing audio: ");
|
||||
#endif
|
||||
|
||||
preserve_persistent_ctx_fields();
|
||||
preserve_persistent_ctx_fields();
|
||||
|
||||
ctx.frame_accumulator -= ctx.desired_frametime;
|
||||
ctx.game.frame_number++;
|
||||
/* TODO: should we ask for reinitialization in such case? */
|
||||
if (ctx.game.frame_number > 16777216)
|
||||
ctx.game.frame_number = 0;
|
||||
ctx.game.initialization_needed = false;
|
||||
}
|
||||
ctx.frame_accumulator -= ctx.desired_frametime;
|
||||
ctx.game.frame_number++;
|
||||
/* TODO: should we ask for reinitialization in such case? */
|
||||
if (ctx.game.frame_number > 16777216)
|
||||
ctx.game.frame_number = 0;
|
||||
ctx.game.initialization_needed = false;
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
/* SDL_GetPerformanceCounter returns some platform-dependent number. */
|
||||
/* it should vary between game instances. i checked! random enough for me. */
|
||||
|
Loading…
Reference in New Issue
Block a user