Probably should not fetch screen refresh rate in the loop, for now.
This commit is contained in:
+1
-1
@@ -11,7 +11,7 @@ static void GameOutputSound(game_state *GameState,
|
||||
S16 ToneVolume, *SampleOut;
|
||||
S32 WavePeriod, SampleIndex;
|
||||
|
||||
ToneVolume = 8000;
|
||||
ToneVolume = 0;
|
||||
WavePeriod = SoundBuffer->SamplesPerSecond / ToneHz;
|
||||
|
||||
SampleOut = SoundBuffer->Samples;
|
||||
|
||||
+9
-7
@@ -805,11 +805,18 @@ S32 main(S32 argc, char *argv[])
|
||||
game_input Input[2];
|
||||
game_input *NewInput, *OldInput;
|
||||
sdl_game_code Game;
|
||||
F32 TargetSecondsPerFrame;
|
||||
S32 MonitorRefreshHz, GameUpdateHz;
|
||||
|
||||
U64 LastCounter;
|
||||
#if __x86_64__ || __i386__
|
||||
U64 LastCycleCount;
|
||||
#endif
|
||||
|
||||
MonitorRefreshHz = SDLGetWindowRefreshRate(Window);
|
||||
GameUpdateHz = MonitorRefreshHz;
|
||||
TargetSecondsPerFrame = 1.0f / (F32)GameUpdateHz;
|
||||
|
||||
NewInput = &Input[0];
|
||||
OldInput = &Input[1];
|
||||
memset(&Input, 0, sizeof(Input));
|
||||
@@ -820,8 +827,6 @@ S32 main(S32 argc, char *argv[])
|
||||
|
||||
while(GlobalRunning) {
|
||||
thread_context Context;
|
||||
S32 MonitorRefreshHz, GameUpdateHz;
|
||||
F32 TargetSecondsPerFrame;
|
||||
U32 NewDLLWriteTime, ButtonIndex, ControllerIndex,
|
||||
SDLMouseButtons;
|
||||
game_controller_input *OldKeyboardController,
|
||||
@@ -849,10 +854,6 @@ S32 main(S32 argc, char *argv[])
|
||||
LastCycleCount = __rdtsc();
|
||||
#endif
|
||||
|
||||
MonitorRefreshHz = SDLGetWindowRefreshRate(Window);
|
||||
GameUpdateHz = MonitorRefreshHz;
|
||||
TargetSecondsPerFrame = 1.0f / (F32)GameUpdateHz;
|
||||
|
||||
NewDLLWriteTime = GetLastWriteTime(SDLState.DLLPath);
|
||||
if(NewDLLWriteTime > Game.DLLLastWriteTime) {
|
||||
SDLUnloadGameCode(&Game);
|
||||
@@ -1074,10 +1075,11 @@ S32 main(S32 argc, char *argv[])
|
||||
SDLPlaybackInput(&SDLState, NewInput);
|
||||
}
|
||||
|
||||
if(Game.UpdateAndRender)
|
||||
if(Game.UpdateAndRender) {
|
||||
Game.UpdateAndRender(&Context, &GameMemory,
|
||||
NewInput, &Buffer,
|
||||
&SoundBuffer);
|
||||
}
|
||||
|
||||
SDLFillSoundBuffer(&SoundOutput, BytesToWrite);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user