diff options
author | ancarola <raffaele.ancarola@epfl.ch> | 2019-02-03 21:52:52 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2019-02-06 23:33:11 +0100 |
commit | 0d30bb843d3aeeacae211e1d0ba3cbf5faa01cd7 (patch) | |
tree | bbe7c5b43fb2f6b451336f69bef27153a84bbc24 /video.cpp | |
parent | Add basic texture wrapper (diff) | |
download | libwsdl2-0d30bb843d3aeeacae211e1d0ba3cbf5faa01cd7.tar.gz libwsdl2-0d30bb843d3aeeacae211e1d0ba3cbf5faa01cd7.zip |
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.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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; } + |