diff --git a/other/build.nr b/other/build.nr index 05da436..9142bb4 100644 --- a/other/build.nr +++ b/other/build.nr @@ -1 +1 @@ -2007 +2008 diff --git a/src/ogfx/WindowBase.cpp b/src/ogfx/WindowBase.cpp index 4f5c766..272fce5 100644 --- a/src/ogfx/WindowBase.cpp +++ b/src/ogfx/WindowBase.cpp @@ -1,5 +1,7 @@ #include "WindowBase.hpp" #include "../ostd/utils/Time.hpp" +#include +#include namespace ogfx { @@ -26,12 +28,12 @@ namespace ogfx printf( "SDL could not initialize! Error: %s\n", SDL_GetError() ); exit(1); } - // int imgFlags = IMG_INIT_PNG; - // if (!(IMG_Init(imgFlags) & imgFlags)) - // { - // printf( "SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError() ); - // exit(2); - // } + int imgFlags = IMG_INIT_PNG; + if (!(IMG_Init(imgFlags) & imgFlags)) + { + printf( "SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError() ); + exit(2); + } m_window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, m_windowWidth, m_windowHeight, SDL_WINDOW_RESIZABLE); SDL_SetWindowResizable(m_window, SDL_FALSE); m_renderer = SDL_CreateRenderer(m_window, -1, SDL_RENDERER_ACCELERATED); @@ -121,6 +123,18 @@ namespace ogfx SDL_SetWindowResizable(m_window, (enable ? SDL_TRUE : SDL_FALSE)); } + void WindowBase::setIcon(const ostd::String& iconFilePath) + { + SDL_Surface* appIcon = IMG_Load(iconFilePath); + if (appIcon == nullptr) + { + //TODO: Error + return; + } + SDL_SetWindowIcon(m_window, appIcon); + SDL_FreeSurface(appIcon); + } + void WindowBase::__handle_events(void) { if (!m_initialized) return; diff --git a/src/ogfx/WindowBase.hpp b/src/ogfx/WindowBase.hpp index 0db6555..d1b3db2 100644 --- a/src/ogfx/WindowBase.hpp +++ b/src/ogfx/WindowBase.hpp @@ -20,6 +20,7 @@ #pragma once +#include #include #include #include @@ -41,6 +42,7 @@ namespace ogfx void setTitle(const ostd::String& title); void setCursor(eCursor cursor); void enableResizable(bool enable = true); + void setIcon(const ostd::String& iconFilePath); inline virtual void onRender(void) { } inline virtual void onUpdate(void) { }