1
0
Fork 0
2018-soft-3d-renderer/src/main.cpp

69 lines
1.4 KiB
C++
Raw Normal View History

#include "engine.h"
#include "platform.h"
#include <cstdint>
#include <cstdio>
#include <cstdlib>
// MAIN
int main(int argc, char *argv[])
{
2018-09-15 01:46:30 +00:00
if (argc != 3)
{
2018-09-15 01:46:30 +00:00
fprintf(stderr, "Usage: %s <OBJ> <MTL>\n", argv[0]);
return EXIT_FAILURE;
}
2018-09-15 01:46:30 +00:00
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)
{
2018-09-20 02:14:45 +00:00
EngineBuffer buffer = {};
2018-09-07 01:32:15 +00:00
buffer.buffer = (uint32_t*)platform.surface->pixels;
buffer.width = platform.surface->w;
buffer.height = platform.surface->h;
2018-09-20 02:14:45 +00:00
result = EngineInit(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);
2018-09-20 02:14:45 +00:00
EngineRender(buffer, platform.input);
Platform_UpdateWindow(platform);
Platform_SyncToFramerate(platform);
}
2018-09-20 02:14:45 +00:00
EngineShutdown();
Platform_Shutdown(platform);
}
else
{
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}