1 /* This file is part of the Pangolin Project. 2 * http://github.com/stevenlovegrove/Pangolin 3 * 4 * Copyright (c) 2011 Steven Lovegrove 5 * 6 * Permission is hereby granted, free of charge, to any person 7 * obtaining a copy of this software and associated documentation 8 * files (the "Software"), to deal in the Software without 9 * restriction, including without limitation the rights to use, 10 * copy, modify, merge, publish, distribute, sublicense, and/or sell 11 * copies of the Software, and to permit persons to whom the 12 * Software is furnished to do so, subject to the following 13 * conditions: 14 * 15 * The above copyright notice and this permission notice shall be 16 * included in all copies or substantial portions of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 * OTHER DEALINGS IN THE SOFTWARE. 26 */ 27 28 #pragma once 29 30 #include <pangolin/platform.h> 31 #include <pangolin/display/window.h> 32 33 #include <pangolin/display/view.h> 34 #include <pangolin/display/user_app.h> 35 #include <functional> 36 #include <memory> 37 38 #include <map> 39 #include <queue> 40 41 #ifdef BUILD_PANGOLIN_VIDEO 42 # include <pangolin/video/video_output.h> 43 #endif // BUILD_PANGOLIN_VIDEO 44 45 46 namespace pangolin 47 { 48 49 // Forward Declarations 50 #ifdef HAVE_PYTHON 51 class ConsoleView; 52 #endif // HAVE_PYTHON 53 class GlFont; 54 55 typedef std::map<const std::string,View*> ViewMap; 56 typedef std::map<int,std::function<void(void)> > KeyhookMap; 57 58 struct PANGOLIN_EXPORT PangolinGl : public WindowInterface 59 { 60 PangolinGl(); 61 ~PangolinGl(); 62 63 // Base container for displays 64 View base; 65 66 // Named views which are managed by pangolin (i.e. created / deleted by pangolin) 67 ViewMap named_managed_views; 68 69 // Optional user app 70 UserApp* user_app; 71 72 // Global keypress hooks 73 KeyhookMap keypress_hooks; 74 75 // Manage fullscreen (ToggleFullscreen is quite new) 76 bool is_double_buffered; 77 bool is_fullscreen; 78 GLint windowed_size[2]; 79 bool is_high_res; 80 81 // State relating to interactivity 82 bool quit; 83 int had_input; 84 int has_resized; 85 int mouse_state; 86 View* activeDisplay; 87 88 std::queue<std::pair<std::string,Viewport> > screen_capture; 89 90 #ifdef BUILD_PANGOLIN_VIDEO 91 View* record_view; 92 VideoOutput recorder; 93 #endif 94 95 #ifdef HAVE_PYTHON 96 ConsoleView* console_view; 97 #endif 98 99 std::shared_ptr<GlFont> font; 100 ToggleFullscreenPangolinGl101 virtual void ToggleFullscreen() override { 102 pango_print_warn("ToggleFullscreen: Not available with non-pangolin window.\n"); 103 } 104 ProcessEventsPangolinGl105 virtual void ProcessEvents() override { 106 pango_print_warn("ProcessEvents: Not available with non-pangolin window.\n"); 107 } 108 SwapBuffersPangolinGl109 virtual void SwapBuffers() override { 110 pango_print_warn("SwapBuffers: Not available with non-pangolin window.\n"); 111 } 112 MakeCurrentPangolinGl113 virtual void MakeCurrent() override { 114 pango_print_warn("MakeCurrent: Not available with non-pangolin window.\n"); 115 } 116 RemoveCurrentPangolinGl117 virtual void RemoveCurrent() override { 118 pango_print_warn("RemoveCurrent: Not available with non-pangolin window.\n"); 119 } 120 MovePangolinGl121 virtual void Move(int /*x*/, int /*y*/) override { 122 pango_print_warn("Move: Not available with non-pangolin window.\n"); 123 } 124 ResizePangolinGl125 virtual void Resize(unsigned int /*w*/, unsigned int /*h*/) override { 126 pango_print_warn("Resize: Not available with non-pangolin window.\n"); 127 } 128 129 130 }; 131 132 PangolinGl* GetCurrentContext(); 133 void RegisterNewContext(const std::string& name, std::shared_ptr<PangolinGl> newcontext); 134 void DeleteContext(const std::string& name); 135 PangolinGl *FindContext(const std::string& name); 136 137 } 138 139