Dawn/src/dawnemscripten/host/DawnEmscripten.cpp

48 lines
904 B
C++

// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "host/DawnEmscripten.hpp"
#include "host/DawnHost.hpp"
#include "game/DawnGame.hpp"
using namespace Dawn;
int main() {
int32_t result;
memoryInit();
auto host = new DawnHost();
auto game = new DawnGame(host);
result = host->init(game);
switch(result) {
case DAWN_HOST_INIT_RESULT_SUCCESS:
break;
default:
return result;
}
// Request the main loop to start running.
result = host->start(game);
switch(result) {
case DAWN_HOST_START_RESULT_SUCCESS:
break;
case DAWN_HOST_START_RESULT_EXIT_SUCCESS:
break;
default:
return result;
}
// Main loop finished without errors, cleanup
host->unload(game);
delete game;
delete host;
memoryDispose();
// Success
return 0;
}