1 /*
2  Copyright (C) 2010-2014 Kristian Duske
3 
4  This file is part of TrenchBroom.
5 
6  TrenchBroom is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  TrenchBroom is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef TrenchBroom_RenderView
21 #define TrenchBroom_RenderView
22 
23 #include "Color.h"
24 #include "Renderer/Vbo.h"
25 #include "View/GLAttribs.h"
26 #include "View/GLContext.h"
27 
28 #include <wx/glcanvas.h>
29 
30 namespace TrenchBroom {
31     namespace Renderer {
32         class FontManager;
33         class RenderContext;
34         class ShaderManager;
35     }
36 
37     namespace View {
38         class GLContextManager;
39 
40         class RenderView : public wxGLCanvas {
41         private:
42             GLContext::Ptr m_glContext;
43             GLAttribs m_attribs;
44             bool m_initialized;
45             Color m_focusColor;
46         protected:
47             RenderView(wxWindow* parent, GLContextManager& contextManager, const GLAttribs& attribs);
48         public:
49             void OnPaint(wxPaintEvent& event);
50             void OnSize(wxSizeEvent& event);
51             void OnSetFocus(wxFocusEvent& event);
52             void OnKillFocus(wxFocusEvent& event);
53         protected:
54             Renderer::Vbo& vertexVbo();
55             Renderer::Vbo& indexVbo();
56             Renderer::FontManager& fontManager();
57             Renderer::ShaderManager& shaderManager();
58 
59             int depthBits() const;
60             bool multisample() const;
61         private:
62             void bindEvents();
63 
64             void initializeGL();
65             void updateViewport();
66             void render();
67             void clearBackground();
68             void renderFocusIndicator();
69         private:
70             virtual void doInitializeGL(bool firstInitialization);
71             virtual void doUpdateViewport(int x, int y, int width, int height);
72             virtual bool doShouldRenderFocusIndicator() const = 0;
73             virtual void doRender() = 0;
74         };
75     }
76 }
77 
78 #endif /* defined(TrenchBroom_RenderView) */
79