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.
This commit is contained in:
parent
2722b688be
commit
3ab0c45bdb
|
@ -149,7 +149,7 @@ void OTRGame::draw() {
|
||||||
DrawTexture(titleTex, windowSize.x / 2 - titleTex.width / 2, titlebar.height / 2 - titleTex.height / 2, WHITE);
|
DrawTexture(titleTex, windowSize.x / 2 - titleTex.width / 2, titlebar.height / 2 - titleTex.height / 2, WHITE);
|
||||||
|
|
||||||
if (UIUtils::GuiIcon("Exit", windowSize.x - 36, titlebar.height / 2 - 10) && (extracting && currentStep.find("Done") != std::string::npos || !extracting)) {
|
if (UIUtils::GuiIcon("Exit", windowSize.x - 36, titlebar.height / 2 - 10) && (extracting && currentStep.find("Done") != std::string::npos || !extracting)) {
|
||||||
CloseWindow();
|
closeRequested = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BeginMode3D(camera);
|
BeginMode3D(camera);
|
||||||
|
|
|
@ -19,6 +19,8 @@ public:
|
||||||
void update();
|
void update();
|
||||||
void draw();
|
void draw();
|
||||||
void exit();
|
void exit();
|
||||||
|
|
||||||
|
inline bool CloseRequested() { return closeRequested; }
|
||||||
protected:
|
protected:
|
||||||
void LoadTexture(const std::string& name, const std::string& path) {
|
void LoadTexture(const std::string& name, const std::string& path) {
|
||||||
const Image tmp = LoadImage(path.c_str());
|
const Image tmp = LoadImage(path.c_str());
|
||||||
|
@ -32,6 +34,9 @@ protected:
|
||||||
SetTextureFilter(font.texture, TEXTURE_FILTER_POINT);
|
SetTextureFilter(font.texture, TEXTURE_FILTER_POINT);
|
||||||
Fonts[name] = font;
|
Fonts[name] = font;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool closeRequested = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern OTRGame* Game;
|
extern OTRGame* Game;
|
||||||
|
|
|
@ -17,7 +17,7 @@ void UpdateDrawFrame(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
constexpr Vector2 windowSize = Vector2(400, 200);
|
constexpr Vector2 windowSize = Vector2(400, 200);
|
||||||
SetConfigFlags(FLAG_VSYNC_HINT);
|
SetConfigFlags(FLAG_VSYNC_HINT);
|
||||||
SetConfigFlags(FLAG_WINDOW_HIGHDPI);
|
SetConfigFlags(FLAG_WINDOW_HIGHDPI);
|
||||||
SetConfigFlags(FLAG_WINDOW_UNDECORATED);
|
SetConfigFlags(FLAG_WINDOW_UNDECORATED);
|
||||||
|
@ -32,7 +32,7 @@ int main() {
|
||||||
Game = new OTRGame();
|
Game = new OTRGame();
|
||||||
Game->preload();
|
Game->preload();
|
||||||
Game->init();
|
Game->init();
|
||||||
while(!WindowShouldClose()) {
|
while(!WindowShouldClose() && !Game->CloseRequested()) {
|
||||||
UpdateDrawFrame();
|
UpdateDrawFrame();
|
||||||
}
|
}
|
||||||
CloseWindow();
|
CloseWindow();
|
||||||
|
|
Loading…
Reference in New Issue