summaryrefslogtreecommitdiffstats
path: root/video.cpp
diff options
context:
space:
mode:
authorancarola <raffaele.ancarola@epfl.ch>2019-02-03 21:52:52 +0100
committerNao Pross <naopross@thearcway.org>2019-02-06 23:33:11 +0100
commit0d30bb843d3aeeacae211e1d0ba3cbf5faa01cd7 (patch)
treebbe7c5b43fb2f6b451336f69bef27153a84bbc24 /video.cpp
parentAdd basic texture wrapper (diff)
downloadlibwsdl2-0d30bb843d3aeeacae211e1d0ba3cbf5faa01cd7.tar.gz
libwsdl2-0d30bb843d3aeeacae211e1d0ba3cbf5faa01cd7.zip
Create an interface to SDL eventsHEADmaster
List of basic events interfaces in namespace wsdl2::event - event_t - e_key - mouse::e_mouse - mouse::e_motion - mouse::e_button - e_quit (pure SDL quit callback) - window::e_window - window::e_resize - window::e_move
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;
}
+