Day 39 complete.

This commit is contained in:
igor
2026-04-24 14:08:11 -07:00
parent 0149719030
commit 536c2664fe
4 changed files with 45 additions and 17 deletions
+13 -9
View File
@@ -402,6 +402,7 @@ static U32 GetLastWriteTime(const char *FileName)
{
struct stat file_info;
memset(&file_info, 0, sizeof(file_info));
if(stat(FileName, &file_info) != 0) {
/* TODO: Diagnostic. perror("stat failed"); */
}
@@ -550,16 +551,14 @@ S32 main(S32 argc, char *argv[])
/* NOTE: Floating windows are not supported oficially by Wayland
* protocol. However, SDL_WINDOW_ALWAYS_ON_TOP does work on KDE
* under Wayland. I have not tested GNOME. */
SDL_Window *Window = SDL_CreateWindow("Handmade Hero", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, RESOLUTION_WIDTH+20, RESOLUTION_HEIGHT+20, SDL_WINDOW_RESIZABLE);
/*SDL_WINDOW_RESIZABLE |
SDL_WINDOW_ALWAYS_ON_TOP);*/
SDL_Window *Window = SDL_CreateWindow("Handmade Hero", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, RESOLUTION_WIDTH+20, RESOLUTION_HEIGHT+20, SDL_WINDOW_RESIZABLE/* | SDL_WINDOW_ALWAYS_ON_TOP*/);
if(Window) {
SDL_DisplayMode display_mode;
SDL_GetCurrentDisplayMode(0, &display_mode);
SDL_Renderer *Renderer = SDL_CreateRenderer(Window, -1, SDL_RENDERER_PRESENTVSYNC);
SDL_SetWindowPosition(Window, (display_mode.w - RESOLUTION_WIDTH-20), (display_mode.h - RESOLUTION_HEIGHT-20));
SDL_SetWindowPosition(Window, (display_mode.w - RESOLUTION_WIDTH-30), (display_mode.h - RESOLUTION_HEIGHT-30));
/* NOTE: For future reference, the custom window bar should use
* SDL_SetWindowHitTest to define areas that will be used to
@@ -793,16 +792,21 @@ S32 main(S32 argc, char *argv[])
SDLDisplayBufferInWindow(GlobalBackbuffer, Window, Renderer);
F64 MSPerFrame = 1000.0 * SDLGetSecondsElapsed(LastCounter, EndCounter);
F64 FPS = 0.0;
F64 FPS = 1000.0 / MSPerFrame;
LastCounter = EndCounter;
#if 0
#if 1
U64 EndCycleCount = __rdtsc();
U64 CyclesElapsed = EndCycleCount - LastCycleCount;
F64 MCPF = ((double)CyclesElapsed / (1000.0 * 1000.0));
fprintf(stderr, "%.02f ms/f, %.02f/s, %.02f mc/f\n",
MSPerFrame, FPS, MCPF);
F64 MCPF = ((F64)CyclesElapsed / (1000.0 * 1000.0));
//fprintf(stderr, "%.02f ms/f, %.02f f/s, %.02f mc/f\n", MSPerFrame, FPS, MCPF);
static char fps_buffer[128];
snprintf(fps_buffer, sizeof(fps_buffer), "%.02f ms/f, %.02f f/s, %.02f mc/f", MSPerFrame, FPS, MCPF);
SDL_SetWindowTitle(Window, (const char *)fps_buffer);
LastCycleCount = EndCycleCount;
#endif