renderer
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
#include <window/window.hpp>
|
||||
|
||||
namespace Game::Window {
|
||||
Window::Window() : mWindow(nullptr), mRunning(false) {}
|
||||
Window::Window() : mWindow(nullptr), mRunning(false), mRenderer() {}
|
||||
|
||||
Window::~Window() {
|
||||
if (mWindow) {
|
||||
SDL_DestroyWindow(mWindow);
|
||||
mWindow = nullptr;
|
||||
mRunning = false;
|
||||
LOG("Window destroyed successfully");
|
||||
SDL_Quit();
|
||||
}
|
||||
}
|
||||
@@ -16,6 +17,16 @@ namespace Game::Window {
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) { return false; }
|
||||
mWindow = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_SHOWN);
|
||||
if (!mWindow) {
|
||||
ERROR("Failed to create window: " << SDL_GetError());
|
||||
SDL_Quit();
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG("Window created successfully");
|
||||
|
||||
if (!mRenderer.init(mWindow)) {
|
||||
SDL_DestroyWindow(mWindow);
|
||||
mWindow = nullptr;
|
||||
SDL_Quit();
|
||||
return false;
|
||||
}
|
||||
@@ -32,7 +43,13 @@ namespace Game::Window {
|
||||
if (event.type == SDL_QUIT) {
|
||||
mRunning = false;
|
||||
}
|
||||
|
||||
// Handle other events (e.g., keyboard, mouse) here
|
||||
}
|
||||
|
||||
mRenderer.clear();
|
||||
// Render game objects here
|
||||
mRenderer.present();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user