fix 🪱 fixed window logic breaking after moving it to WindowManager class

This commit is contained in:
2025-07-13 13:19:43 +02:00
parent 1b1d8a5d82
commit d04c0a6e15
26 changed files with 82 additions and 41 deletions

View File

@ -4,7 +4,7 @@
#include "WindowManager.h"
bool running = true;
WindowManager wm;
WindowManager *wm = nullptr;
bool Engine::Init() {
if (!SDL_Init(SDL_INIT_VIDEO)) {
@ -14,7 +14,7 @@ bool Engine::Init() {
wm = new WindowManager();
if (!wm.InitWindow("ShadowCrest", 800, 600)) {
if (!wm->InitWindow("ShadowCrest", 800, 600)) {
std::cerr << "SDL_Init failed: " << SDL_GetError() << "\n";
return false;
}
@ -36,6 +36,8 @@ void Engine::Run() {
}
void Engine::Shutdown() {
SDL_DestroyWindow(window);
if (wm != nullptr) {
wm->Close();
}
SDL_Quit();
}

View File

@ -1,12 +1,19 @@
#include "WindowManager.h"
#include <iostream>
#include <SDL3/SDL.h>
#include <Windows.h>
SDL_Window* window = nullptr;
bool WindowManager::InitWindow(char *name, int width, int height) {
bool WindowManager::InitWindow(const char *name, int width, int height) {
// creates window
window = SDL_CreateWindow(name, width, height, SDL_WINDOW_RESIZABLE);
return window != nullptr;
}
void WindowManager::Draw() {
std::cout << "draw to window";
}
void WindowManager::Close() {
SDL_DestroyWindow(window);
}

View File

@ -1,10 +1,8 @@
#include <string>
using namespace std;
#pragma once
class WindowManager {
public:
bool InitWindow(char *name, int width, int height);
bool InitWindow(const char* name, int width, int height);
void Draw();
void Close();
};