comparison Framework/Viewport/SdlViewport.h @ 947:1091b2adeb5a toa2019081001

Fixed animation frame stopping when returning false + big work on the OpenGL objects to make them lost context-safe + debug code to forcefully tag a context as lost + debug macros
author Benjamin Golinvaux <bgo@osimis.io>
date Sat, 10 Aug 2019 13:07:31 +0200
parents 685c9a2d115f
children a7351ad54960
comparison
equal deleted inserted replaced
946:dbe3e1e47019 947:1091b2adeb5a
59 59
60 virtual SdlWindow& GetWindow() = 0; 60 virtual SdlWindow& GetWindow() = 0;
61 61
62 virtual void UpdateSize(unsigned int width, 62 virtual void UpdateSize(unsigned int width,
63 unsigned int height) = 0; 63 unsigned int height) = 0;
64
64 }; 65 };
65 66
66 class SdlOpenGLViewport : public SdlViewport 67 class SdlOpenGLViewport : public SdlViewport
67 { 68 {
68 private: 69 private:
69 SdlOpenGLContext context_; 70 SdlOpenGLContext context_;
70 OpenGLCompositor compositor_; 71 std::auto_ptr<OpenGLCompositor> compositor_;
71 72
72 public: 73 public:
73 SdlOpenGLViewport(const char* title, 74 SdlOpenGLViewport(const char* title,
74 unsigned int width, 75 unsigned int width,
75 unsigned int height, 76 unsigned int height,
84 virtual SdlWindow& GetWindow() ORTHANC_OVERRIDE 85 virtual SdlWindow& GetWindow() ORTHANC_OVERRIDE
85 { 86 {
86 return context_.GetWindow(); 87 return context_.GetWindow();
87 } 88 }
88 89
90 bool OpenGLContextLost();
91
89 virtual void UpdateSize(unsigned int width, unsigned int height) ORTHANC_OVERRIDE 92 virtual void UpdateSize(unsigned int width, unsigned int height) ORTHANC_OVERRIDE
90 { 93 {
91 // nothing to do in OpenGL, the OpenGLCompositor::UpdateSize will be called automatically 94 // nothing to do in OpenGL, the OpenGLCompositor::UpdateSize will be called automatically
92 } 95 }
96 virtual void Refresh() ORTHANC_OVERRIDE;
93 97
94 protected: 98 protected:
95 virtual ICompositor& GetCompositor() ORTHANC_OVERRIDE 99 virtual void DisableCompositor() ORTHANC_OVERRIDE;
100 virtual void RestoreCompositor() ORTHANC_OVERRIDE;
101
102 virtual ICompositor* GetCompositor() ORTHANC_OVERRIDE
96 { 103 {
97 return compositor_; 104 return compositor_.get();
98 } 105 }
99 }; 106 };
100 107
101 108
102 class SdlCairoViewport : public SdlViewport 109 class SdlCairoViewport : public SdlViewport
123 virtual SdlWindow& GetWindow() ORTHANC_OVERRIDE 130 virtual SdlWindow& GetWindow() ORTHANC_OVERRIDE
124 { 131 {
125 return window_; 132 return window_;
126 } 133 }
127 134
135 virtual void DisableCompositor() ORTHANC_OVERRIDE;
136 virtual void RestoreCompositor() ORTHANC_OVERRIDE;
137
128 virtual void Refresh() ORTHANC_OVERRIDE; 138 virtual void Refresh() ORTHANC_OVERRIDE;
129 139
130 virtual void UpdateSize(unsigned int width, 140 virtual void UpdateSize(unsigned int width,
131 unsigned int height) ORTHANC_OVERRIDE; 141 unsigned int height) ORTHANC_OVERRIDE;
132 protected: 142 protected:
133 virtual ICompositor& GetCompositor() ORTHANC_OVERRIDE 143 virtual ICompositor* GetCompositor() ORTHANC_OVERRIDE
134 { 144 {
135 return compositor_; 145 return &compositor_;
136 } 146 }
137 147
138 private: 148 private:
139 void UpdateSdlSurfaceSize(unsigned int width, 149 void UpdateSdlSurfaceSize(unsigned int width,
140 unsigned int height); 150 unsigned int height);