summaryrefslogtreecommitdiffstats
path: root/video.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'video.cpp')
-rw-r--r--video.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/video.cpp b/video.cpp
index 5a5e933..e777371 100644
--- a/video.cpp
+++ b/video.cpp
@@ -87,6 +87,10 @@ renderer::~renderer() {
/* class window */
+// existing window mapping (SDL_ID <-> window)
+std::map<Uint8, window*> window::win_map;
+
+
window::window(const std::string& title, std::size_t width, std::size_t height) {
// create (hidden) window
m_window = SDL_CreateWindow(
@@ -102,6 +106,9 @@ window::window(const std::string& title, std::size_t width, std::size_t height)
throw std::runtime_error("failed to create SDL window");
}
+ // put into window id mapping
+ win_map.insert(std::pair<Uint8, window*>(static_cast<Uint8>(SDL_GetWindowID(m_window)), this));
+
m_renderer.create_sdl_renderer(m_window);
// other attributes
@@ -134,7 +141,14 @@ bool window::is_visible() {
return SDL_WINDOW_SHOWN & SDL_GetWindowFlags(m_window);
}
+window * window::get(Uint8 id)
+{
+ auto it = win_map.find(id);
+ return (it != win_map.end()) ? it->second : 0;
+}
+
void window::update() {
+
m_renderer.clear();
m_renderer.present();
}
@@ -150,3 +164,4 @@ SDL_Window * window::sdl() {
return m_window;
}
+