Compare commits
7 Commits
fb9e93d9cf
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 7fe522ffbe | |||
| 4cd1528343 | |||
| 31f57eddf7 | |||
| e9808fb47f | |||
| fa05feceb8 | |||
| 4b89548102 | |||
| 99d508c5ed |
@@ -50,7 +50,7 @@ bool Application::Init() {
|
||||
|
||||
m_AppData.windowdata.eventCallback = [this](Event &event) { RaiseEvent(event); };
|
||||
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) {
|
||||
Shutdown();
|
||||
return false;
|
||||
@@ -138,8 +138,8 @@ void Application::Run() {
|
||||
if (!m_isRunning) {
|
||||
break;
|
||||
}
|
||||
// Rendering
|
||||
|
||||
// Rendering
|
||||
for (auto &layer : m_LayerStack) {
|
||||
layer->OnRender();
|
||||
}
|
||||
@@ -147,7 +147,7 @@ void Application::Run() {
|
||||
m_ImGui->Begin();
|
||||
|
||||
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);
|
||||
|
||||
for (auto &layer : m_LayerStack) {
|
||||
|
||||
@@ -8,13 +8,11 @@
|
||||
#include <span>
|
||||
|
||||
namespace SakuraVNE {
|
||||
Window::Window(const WindowData &data) : m_Data(data) {}
|
||||
Window::Window(const WindowData &data) : m_Data(data), m_Flags(0) {}
|
||||
Window::~Window() { Destroy(); }
|
||||
|
||||
bool Window::Create(std::span<const SDL_WindowFlags> flags) {
|
||||
for (auto &flag : flags) {
|
||||
m_Flags |= flag;
|
||||
}
|
||||
bool Window::Create(const SDL_WindowFlags flags) {
|
||||
m_Flags |= 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;
|
||||
}
|
||||
|
||||
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
|
||||
// should this be static or go somewhere else | probably in application?
|
||||
auto Window::GetMousePos() const {
|
||||
auto Window::GetMousePos() {
|
||||
struct result {
|
||||
float *x;
|
||||
float *y;
|
||||
float x;
|
||||
float y;
|
||||
};
|
||||
|
||||
SDL_GetMouseState(m_MouseXPos, m_MouseYPos);
|
||||
SDL_GetMouseState(&m_MouseXPos, &m_MouseYPos);
|
||||
|
||||
return result{m_MouseXPos, m_MouseYPos};
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
namespace SakuraVNE {
|
||||
struct WindowData {
|
||||
SDL_WindowFlags windowFlags = 0;
|
||||
std::string title = "Window Title";
|
||||
int width = 1280;
|
||||
int height = 720;
|
||||
@@ -26,13 +27,11 @@ public:
|
||||
Window(const WindowData &data = WindowData());
|
||||
~Window();
|
||||
|
||||
bool Create(std::span<const SDL_WindowFlags> flags = {});
|
||||
bool Create(const SDL_WindowFlags flags = 0);
|
||||
void Destroy();
|
||||
|
||||
void Update();
|
||||
// TODO: implement
|
||||
void AddFlags(std::span<const SDL_WindowFlags> flags = {});
|
||||
// TODO: implement
|
||||
void RemoveFlags(std::span<const SDL_WindowFlags> flags = {});
|
||||
void Resize();
|
||||
void ProcessEvent(const SDL_Event &event);
|
||||
@@ -40,7 +39,7 @@ public:
|
||||
void RaiseEvent(Event &event);
|
||||
|
||||
bool ShouldClose() const;
|
||||
auto GetMousePos() const;
|
||||
auto GetMousePos();
|
||||
|
||||
SDL_Window *GetHandle() const { return m_Handle; }
|
||||
|
||||
@@ -48,8 +47,8 @@ private:
|
||||
WindowData m_Data;
|
||||
SDL_Window *m_Handle = nullptr;
|
||||
SDL_WindowFlags m_Flags;
|
||||
float *m_MouseXPos = nullptr;
|
||||
float *m_MouseYPos = nullptr;
|
||||
float m_MouseXPos;
|
||||
float m_MouseYPos;
|
||||
};
|
||||
|
||||
} // namespace SakuraVNE
|
||||
|
||||
Reference in New Issue
Block a user