Day 29 complete.
This commit is contained in:
+16
-15
@@ -178,6 +178,11 @@ static void SDLDisplayBufferInWindow(offscreen_buffer Buffer,
|
||||
SDL_Renderer *Renderer)
|
||||
{
|
||||
SDL_Rect dest_rect;
|
||||
S32 OffsetX = 10;
|
||||
S32 OffsetY = 10;
|
||||
|
||||
SDL_SetRenderDrawColor(Renderer, 0, 0, 0, 255);
|
||||
SDL_RenderClear(Renderer);
|
||||
|
||||
if(SDL_UpdateTexture(Buffer.Texture, 0, Buffer.Memory, Buffer.Pitch)) {
|
||||
/* TODO: Do something about this error! */
|
||||
@@ -186,8 +191,8 @@ static void SDLDisplayBufferInWindow(offscreen_buffer Buffer,
|
||||
/* TODO: We temporarily introduce the target rectangle to avoid
|
||||
* stretching the canvas. */
|
||||
/* SDL_RenderCopy(Renderer, Buffer.Texture, 0, 0); */
|
||||
dest_rect.x = 0;
|
||||
dest_rect.y = 0;
|
||||
dest_rect.x = OffsetX;
|
||||
dest_rect.y = OffsetY;
|
||||
dest_rect.w = RESOLUTION_WIDTH;
|
||||
dest_rect.h = RESOLUTION_HEIGHT;
|
||||
SDL_RenderCopy(Renderer, Buffer.Texture, 0, (const SDL_Rect *)(&dest_rect));
|
||||
@@ -646,7 +651,7 @@ void GetExecutablePath(char *path, size_t path_size)
|
||||
#endif
|
||||
|
||||
if(path_size > 0) {
|
||||
path[0] = '\0';
|
||||
path[0] = '\0';
|
||||
|
||||
#if __APPLE__ && __MACH__
|
||||
size = path_size;
|
||||
@@ -684,6 +689,13 @@ static void SDLGetDLLPath(char *path, size_t path_size, char *exe_path)
|
||||
snprintf(path, path_size, "%s%s", exe_path, GAME_DLL_NAME);
|
||||
}
|
||||
|
||||
#if !(__x86_64__ || __i386__)
|
||||
U64 __rdtsc()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
S32 main(S32 argc, char *argv[])
|
||||
{
|
||||
sdl_state SDLState;
|
||||
@@ -818,9 +830,7 @@ S32 main(S32 argc, char *argv[])
|
||||
S32 MonitorRefreshHz, GameUpdateHz;
|
||||
|
||||
U64 LastCounter;
|
||||
#if __x86_64__ || __i386__
|
||||
U64 LastCycleCount;
|
||||
#endif
|
||||
|
||||
MonitorRefreshHz = SDLGetWindowRefreshRate(Window);
|
||||
/*GameUpdateHz = MonitorRefreshHz;*/
|
||||
@@ -848,23 +858,19 @@ S32 main(S32 argc, char *argv[])
|
||||
U64 WorkCounter, EndCounter;
|
||||
F32 WorkSecondsElapsed, SecondsElapsedForFrame;
|
||||
F64 MSPerFrame, FPS;
|
||||
#if __x86_64__ || __i386__
|
||||
U64 EndCycleCount, CyclesElapsed;
|
||||
F64 MCPF;
|
||||
#endif
|
||||
|
||||
NewInput->dtForFrame = TargetSecondsPerFrame;
|
||||
|
||||
LastCounter = SDLGetWallClock();
|
||||
|
||||
#if __x86_64__ || __i386__
|
||||
/* NOTE: rdtsc reports clock cylces, however it is not
|
||||
* meant for really precise profiler work as the
|
||||
* value returned is varied. */
|
||||
/* Also, __rdtsc is not available on MacOS ARM; I
|
||||
* have not checked MacOS x64. */
|
||||
LastCycleCount = __rdtsc();
|
||||
#endif
|
||||
LastCycleCount = __rdtsc();
|
||||
|
||||
NewDLLWriteTime = GetLastWriteTime(SDLState.DLLPath);
|
||||
if(NewDLLWriteTime > Game.DLLLastWriteTime) {
|
||||
@@ -1126,17 +1132,12 @@ S32 main(S32 argc, char *argv[])
|
||||
LastCounter = EndCounter;
|
||||
|
||||
#if 0
|
||||
#if __x86_64__ || __i386__
|
||||
EndCycleCount = __rdtsc();
|
||||
CyclesElapsed = EndCycleCount - LastCycleCount;
|
||||
MCPF = ((double)CyclesElapsed / (1000.0 * 1000.0));
|
||||
fprintf(stderr, "%.02f ms/f, %.02f/s, %.02f mc/f\n",
|
||||
MSPerFrame, FPS, MCPF);
|
||||
LastCycleCount = EndCycleCount;
|
||||
#else
|
||||
fprintf(stderr, "%.02f ms/f, %.02f/s\n",
|
||||
MSPerFrame, FPS);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
SWAP(game_input *, NewInput, OldInput);
|
||||
|
||||
Reference in New Issue
Block a user