Compare commits

...

7 Commits

3 changed files with 16 additions and 19 deletions

View File

@@ -50,7 +50,7 @@ bool Application::Init() {
m_AppData.windowdata.eventCallback = [this](Event &event) { RaiseEvent(event); }; m_AppData.windowdata.eventCallback = [this](Event &event) { RaiseEvent(event); };
m_Window.push_back(std::make_shared<Window>(m_AppData.windowdata)); m_Window.push_back(std::make_shared<Window>(m_AppData.windowdata));
bool isSuccessful = m_Window[0]->Create(); bool isSuccessful = m_Window[0]->Create({m_AppData.windowdata.windowFlags});
if (!isSuccessful) { if (!isSuccessful) {
Shutdown(); Shutdown();
return false; return false;
@@ -138,8 +138,8 @@ void Application::Run() {
if (!m_isRunning) { if (!m_isRunning) {
break; break;
} }
// Rendering
// Rendering
for (auto &layer : m_LayerStack) { for (auto &layer : m_LayerStack) {
layer->OnRender(); layer->OnRender();
} }
@@ -147,7 +147,7 @@ void Application::Run() {
m_ImGui->Begin(); m_ImGui->Begin();
SDL_SetRenderScale(m_Renderer, io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y); SDL_SetRenderScale(m_Renderer, io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y);
SDL_SetRenderDrawColor(m_Renderer, (Uint8)111, (Uint8)232, (Uint8)168, (Uint8)0); SDL_SetRenderDrawColor(m_Renderer, (Uint8)111, (Uint8)232, (Uint8)168, (Uint8)255);
SDL_RenderClear(m_Renderer); SDL_RenderClear(m_Renderer);
for (auto &layer : m_LayerStack) { for (auto &layer : m_LayerStack) {

View File

@@ -8,13 +8,11 @@
#include <span> #include <span>
namespace SakuraVNE { namespace SakuraVNE {
Window::Window(const WindowData &data) : m_Data(data) {} Window::Window(const WindowData &data) : m_Data(data), m_Flags(0) {}
Window::~Window() { Destroy(); } Window::~Window() { Destroy(); }
bool Window::Create(std::span<const SDL_WindowFlags> flags) { bool Window::Create(const SDL_WindowFlags flags) {
for (auto &flag : flags) { m_Flags |= flags;
m_Flags |= flag;
}
m_Handle = SDL_CreateWindow(m_Data.title.c_str(), m_Data.width, m_Data.height, m_Flags); m_Handle = SDL_CreateWindow(m_Data.title.c_str(), m_Data.width, m_Data.height, m_Flags);
@@ -187,7 +185,7 @@ void Window::RemoveFlags(std::span<const SDL_WindowFlags> flags) {
break; break;
} }
m_Flags |= flag; m_Flags &= flag;
} }
} }
@@ -211,13 +209,13 @@ void Window::RaiseEvent(Event &event) {
// TODO: this need testing because i am really not sure this is correct // TODO: this need testing because i am really not sure this is correct
// should this be static or go somewhere else | probably in application? // should this be static or go somewhere else | probably in application?
auto Window::GetMousePos() const { auto Window::GetMousePos() {
struct result { struct result {
float *x; float x;
float *y; float y;
}; };
SDL_GetMouseState(m_MouseXPos, m_MouseYPos); SDL_GetMouseState(&m_MouseXPos, &m_MouseYPos);
return result{m_MouseXPos, m_MouseYPos}; return result{m_MouseXPos, m_MouseYPos};
} }

View File

@@ -9,6 +9,7 @@
namespace SakuraVNE { namespace SakuraVNE {
struct WindowData { struct WindowData {
SDL_WindowFlags windowFlags = 0;
std::string title = "Window Title"; std::string title = "Window Title";
int width = 1280; int width = 1280;
int height = 720; int height = 720;
@@ -26,13 +27,11 @@ public:
Window(const WindowData &data = WindowData()); Window(const WindowData &data = WindowData());
~Window(); ~Window();
bool Create(std::span<const SDL_WindowFlags> flags = {}); bool Create(const SDL_WindowFlags flags = 0);
void Destroy(); void Destroy();
void Update(); void Update();
// TODO: implement
void AddFlags(std::span<const SDL_WindowFlags> flags = {}); void AddFlags(std::span<const SDL_WindowFlags> flags = {});
// TODO: implement
void RemoveFlags(std::span<const SDL_WindowFlags> flags = {}); void RemoveFlags(std::span<const SDL_WindowFlags> flags = {});
void Resize(); void Resize();
void ProcessEvent(const SDL_Event &event); void ProcessEvent(const SDL_Event &event);
@@ -40,7 +39,7 @@ public:
void RaiseEvent(Event &event); void RaiseEvent(Event &event);
bool ShouldClose() const; bool ShouldClose() const;
auto GetMousePos() const; auto GetMousePos();
SDL_Window *GetHandle() const { return m_Handle; } SDL_Window *GetHandle() const { return m_Handle; }
@@ -48,8 +47,8 @@ private:
WindowData m_Data; WindowData m_Data;
SDL_Window *m_Handle = nullptr; SDL_Window *m_Handle = nullptr;
SDL_WindowFlags m_Flags; SDL_WindowFlags m_Flags;
float *m_MouseXPos = nullptr; float m_MouseXPos;
float *m_MouseYPos = nullptr; float m_MouseYPos;
}; };
} // namespace SakuraVNE } // namespace SakuraVNE