Shipwright/OTRGui/src/main.cpp
MaikelChan 3ab0c45bdb
Fixed window not properly disposing raylib and OpenGL when closing. (#59)
Closing the window with the X button will not close it immediately during the rendering of a frame, causing it to actually crash, but will set the engine in a pending state until it finishes the current frame.
2022-03-24 12:48:22 -06:00

40 lines
966 B
C++

#include <iostream>
#include "raylib.h"
#include "game/game.h"
#include "impl/fs-bridge/fs-bridge.h"
#include "impl/fs-bridge/windows/fs-windows.h"
#include "impl/fs-bridge/linux/fs-linux.h"
#include "impl.h"
using namespace std;
FSBridge* NativeFS = nullptr;
OTRGame* Game = nullptr;
void UpdateDrawFrame(void) {
Game->update();
Game->draw();
}
int main() {
constexpr Vector2 windowSize = Vector2(400, 200);
SetConfigFlags(FLAG_VSYNC_HINT);
SetConfigFlags(FLAG_WINDOW_HIGHDPI);
SetConfigFlags(FLAG_WINDOW_UNDECORATED);
SetConfigFlags(FLAG_MSAA_4X_HINT);
SetConfigFlags(FLAG_WINDOW_TRANSPARENT);
InitWindow(windowSize.x, windowSize.y, "");
#ifdef _WIN32
NativeFS = new WindowsBridge;
#else
NativeFS = new LinuxBridge;
#endif
Game = new OTRGame();
Game->preload();
Game->init();
while(!WindowShouldClose() && !Game->CloseRequested()) {
UpdateDrawFrame();
}
CloseWindow();
return 0;
}