#include "engine.h" #include "platform.h" #include #include #include // CONSTANTS const unsigned int WINDOW_WIDTH = 1920; const unsigned int WINDOW_HEIGHT = 1080; const unsigned int WINDOW_FPS = 30; // MAIN int main(int argc, char *argv[]) { if (argc != 3) { fprintf(stderr, "Usage: %s \n", argv[0]); return EXIT_FAILURE; } char *objFilename = argv[1]; char *mtlFilename = argv[2]; Platform platform = {}; int result = Platform_Init(platform, WINDOW_WIDTH, WINDOW_HEIGHT); platform.framerateMillis = (1000 / WINDOW_FPS); if (result == PLATFORM_OK) { Engine_Buffer buffer = {}; buffer.buffer = (uint32_t*)platform.surface->pixels; buffer.zbuffer = (float*)calloc((size_t)(platform.surface->w * platform.surface->h), sizeof(float)); buffer.width = platform.surface->w; buffer.height = platform.surface->h; result = Engine_Init(buffer, objFilename, mtlFilename); if (result < 0) { return EXIT_FAILURE; } while (true) { Platform_GetFrameTime(platform); result = Platform_CheckForEvents(platform); if (result == PLATFORM_QUIT) { break; } Platform_ClearWindow(platform); Engine_Render(buffer, platform.input); Platform_UpdateWindow(platform); Platform_SyncToFramerate(platform); } Engine_Shutdown(); Platform_Shutdown(platform); } else { return EXIT_FAILURE; } return EXIT_SUCCESS; }