fix 🪱 fixed window logic breaking after moving it to WindowManager class
This commit is contained in:
@ -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();
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
@ -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();
|
||||
};
|
||||
Reference in New Issue
Block a user