1
0
Fork 0
2018-soft-3d-renderer/Source/Main.cpp

61 lines
1.0 KiB
C++

#include "Engine.hpp"
#include "Platform.hpp"
#include <cstdint>
#include <cstdio>
#include <cstdlib>
// MAIN
int main(int argc, char* argv[])
{
if (argc != 3)
{
fprintf(stderr, "Usage: %s <OBJ> <MTL>\n", argv[0]);
return EXIT_FAILURE;
}
char* objFilename = argv[1];
char* mtlFilename = argv[2];
Platform platform{};
if (Platform_Init(platform, WINDOW_WIDTH, WINDOW_HEIGHT) == PlatformStatus::Error)
{
return EXIT_FAILURE;
}
if (EngineInit(objFilename, mtlFilename) < 0)
{
return EXIT_FAILURE;
}
EngineBuffer buffer{};
buffer.buffer = reinterpret_cast<uint32_t*>(platform.surface->pixels);
buffer.width = platform.surface->w;
buffer.height = platform.surface->h;
while (true)
{
Platform_GetFrameTime(platform);
if (Platform_CheckForEvents(platform) == PlatformStatus::Quit)
{
break;
}
Platform_ClearWindow(platform);
EngineRender(buffer, platform.input);
Platform_UpdateWindow(platform);
Platform_SyncToFramerate(platform);
}
EngineShutdown();
Platform_Shutdown(platform);
return EXIT_SUCCESS;
}