Skip to content

Commit

Permalink
Convert underlyingWindow handle to Window member field
Browse files Browse the repository at this point in the history
This removes a long standing comment to improve how we share the window handle.
  • Loading branch information
DanRStevens committed Mar 4, 2025
1 parent 5547b40 commit fed0769
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
4 changes: 0 additions & 4 deletions NAS2D/Renderer/RendererOpenGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@
using namespace NAS2D;


// UGLY ASS HACK!
extern SDL_Window* underlyingWindow;


namespace
{
constexpr std::array<GLfloat, 12> rectToQuad(Rectangle<GLfloat> rect)
Expand Down
14 changes: 5 additions & 9 deletions NAS2D/Renderer/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,11 @@
using namespace NAS2D;


// UGLY ASS HACK!
SDL_Window* underlyingWindow = nullptr;


namespace
{
bool isAnyWindowFlagSet(Uint32 testFlags)
bool isAnyWindowFlagSet(SDL_Window* window, Uint32 testFlags)
{
return (SDL_GetWindowFlags(underlyingWindow) & testFlags) != 0;
return (SDL_GetWindowFlags(window) & testFlags) != 0;
}


Expand Down Expand Up @@ -280,7 +276,7 @@ void Window::fullscreen(bool fullscreen, bool maintain)

bool Window::fullscreen() const
{
return isAnyWindowFlagSet(SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN_DESKTOP);
return isAnyWindowFlagSet(underlyingWindow, SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN_DESKTOP);
}


Expand Down Expand Up @@ -313,7 +309,7 @@ void Window::resizeable(bool resizable)

bool Window::resizeable() const
{
return isAnyWindowFlagSet(SDL_WINDOW_RESIZABLE);
return isAnyWindowFlagSet(underlyingWindow, SDL_WINDOW_RESIZABLE);
}


Expand All @@ -330,7 +326,7 @@ void Window::minimumSize(Vector<int> newSize)

Vector<int> Window::size() const
{
if (isAnyWindowFlagSet(SDL_WINDOW_FULLSCREEN_DESKTOP))
if (isAnyWindowFlagSet(underlyingWindow, SDL_WINDOW_FULLSCREEN_DESKTOP))
{
SDL_DisplayMode dm;
if (SDL_GetDesktopDisplayMode(0, &dm) != 0)
Expand Down
2 changes: 2 additions & 0 deletions NAS2D/Renderer/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


struct SDL_Cursor;
struct SDL_Window;


namespace NAS2D
Expand Down Expand Up @@ -79,5 +80,6 @@ namespace NAS2D
Vector<int> mResolution{1600, 900};
std::string mTitle;
std::map<int, SDL_Cursor*> cursors{};
SDL_Window* underlyingWindow{nullptr};
};
}

0 comments on commit fed0769

Please sign in to comment.