1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkGenericRenderWindowInteractor.cxx
5 
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13 
14 =========================================================================*/
15 #include "vtkGenericOpenGLRenderWindow.h"
16 
17 #include "vtkCommand.h"
18 #include "vtkObjectFactory.h"
19 #include "vtkOpenGLError.h"
20 #include "vtkOpenGLRenderWindow.h"
21 #include "vtkOpenGLRenderer.h"
22 #include "vtkRendererCollection.h"
23 
24 vtkStandardNewMacro(vtkGenericOpenGLRenderWindow);
25 
vtkGenericOpenGLRenderWindow()26 vtkGenericOpenGLRenderWindow::vtkGenericOpenGLRenderWindow()
27 {
28   this->ReadyForRendering = true;
29   this->DirectStatus = 0;
30   this->CurrentStatus = false;
31   this->SupportsOpenGLStatus = 0;
32   this->ForceMaximumHardwareLineWidth = 0;
33   this->ScreenSize[0] = 0;
34   this->ScreenSize[1] = 0;
35 }
36 
~vtkGenericOpenGLRenderWindow()37 vtkGenericOpenGLRenderWindow::~vtkGenericOpenGLRenderWindow()
38 {
39   this->Finalize();
40 
41   vtkRenderer* ren;
42   vtkCollectionSimpleIterator rit;
43   this->Renderers->InitTraversal(rit);
44   while ((ren = this->Renderers->GetNextRenderer(rit)))
45   {
46     ren->SetRenderWindow(nullptr);
47   }
48 }
49 
PrintSelf(ostream & os,vtkIndent indent)50 void vtkGenericOpenGLRenderWindow::PrintSelf(ostream& os, vtkIndent indent)
51 {
52   this->Superclass::PrintSelf(os, indent);
53 }
54 
GetMaximumHardwareLineWidth()55 float vtkGenericOpenGLRenderWindow::GetMaximumHardwareLineWidth()
56 {
57   return this->ForceMaximumHardwareLineWidth > 0
58     ? this->ForceMaximumHardwareLineWidth
59     : this->Superclass::GetMaximumHardwareLineWidth();
60 }
61 
SetFrontBuffer(unsigned int b)62 void vtkGenericOpenGLRenderWindow::SetFrontBuffer(unsigned int b)
63 {
64   this->FrontBuffer = b;
65 }
66 
SetFrontLeftBuffer(unsigned int b)67 void vtkGenericOpenGLRenderWindow::SetFrontLeftBuffer(unsigned int b)
68 {
69   this->FrontLeftBuffer = b;
70 }
71 
SetFrontRightBuffer(unsigned int b)72 void vtkGenericOpenGLRenderWindow::SetFrontRightBuffer(unsigned int b)
73 {
74   this->FrontRightBuffer = b;
75 }
76 
SetBackBuffer(unsigned int b)77 void vtkGenericOpenGLRenderWindow::SetBackBuffer(unsigned int b)
78 {
79   this->BackBuffer = b;
80 }
81 
SetBackLeftBuffer(unsigned int b)82 void vtkGenericOpenGLRenderWindow::SetBackLeftBuffer(unsigned int b)
83 {
84   this->BackLeftBuffer = b;
85 }
86 
SetBackRightBuffer(unsigned int b)87 void vtkGenericOpenGLRenderWindow::SetBackRightBuffer(unsigned int b)
88 {
89   this->BackRightBuffer = b;
90 }
91 
Finalize()92 void vtkGenericOpenGLRenderWindow::Finalize()
93 {
94   // tell each of the renderers that this render window/graphics context
95   // is being removed (the RendererCollection is removed by vtkRenderWindow's
96   // destructor)
97   this->ReleaseGraphicsResources(this);
98 }
99 
Frame()100 void vtkGenericOpenGLRenderWindow::Frame()
101 {
102   this->InvokeEvent(vtkCommand::WindowFrameEvent, nullptr);
103 }
104 
MakeCurrent()105 void vtkGenericOpenGLRenderWindow::MakeCurrent()
106 {
107   this->InvokeEvent(vtkCommand::WindowMakeCurrentEvent, nullptr);
108 }
109 
IsCurrent()110 bool vtkGenericOpenGLRenderWindow::IsCurrent()
111 {
112   this->InvokeEvent(vtkCommand::WindowIsCurrentEvent, &this->CurrentStatus);
113   return this->CurrentStatus;
114 }
115 
SupportsOpenGL()116 int vtkGenericOpenGLRenderWindow::SupportsOpenGL()
117 {
118   this->InvokeEvent(vtkCommand::WindowSupportsOpenGLEvent,
119                     &this->SupportsOpenGLStatus);
120   return this->SupportsOpenGLStatus;
121 }
122 
IsDirect()123 int vtkGenericOpenGLRenderWindow::IsDirect()
124 {
125   this->InvokeEvent(vtkCommand::WindowIsDirectEvent, &this->DirectStatus);
126   return this->DirectStatus;
127 }
128 
SetWindowId(void *)129 void vtkGenericOpenGLRenderWindow::SetWindowId(void*)
130 {
131 }
132 
GetGenericWindowId()133 void* vtkGenericOpenGLRenderWindow::GetGenericWindowId()
134 {
135   return nullptr;
136 }
137 
SetDisplayId(void *)138 void vtkGenericOpenGLRenderWindow::SetDisplayId(void*)
139 {
140 }
141 
SetParentId(void *)142 void vtkGenericOpenGLRenderWindow::SetParentId(void*)
143 {
144 }
145 
GetGenericDisplayId()146 void* vtkGenericOpenGLRenderWindow::GetGenericDisplayId()
147 {
148   return nullptr;
149 }
150 
GetGenericParentId()151 void* vtkGenericOpenGLRenderWindow::GetGenericParentId()
152 {
153   return nullptr;
154 }
155 
GetGenericContext()156 void* vtkGenericOpenGLRenderWindow::GetGenericContext()
157 {
158   return nullptr;
159 }
160 
GetGenericDrawable()161 void* vtkGenericOpenGLRenderWindow::GetGenericDrawable()
162 {
163   return nullptr;
164 }
165 
SetWindowInfo(const char *)166 void vtkGenericOpenGLRenderWindow::SetWindowInfo(const char*)
167 {
168 }
169 
SetParentInfo(const char *)170 void vtkGenericOpenGLRenderWindow::SetParentInfo(const char*)
171 {
172 }
173 
GetScreenSize()174 int* vtkGenericOpenGLRenderWindow::GetScreenSize()
175 {
176   return this->ScreenSize;
177 }
178 
Start()179 void vtkGenericOpenGLRenderWindow::Start()
180 {
181 }
182 
HideCursor()183 void vtkGenericOpenGLRenderWindow::HideCursor()
184 {
185 }
186 
ShowCursor()187 void vtkGenericOpenGLRenderWindow::ShowCursor()
188 {
189 }
190 
SetFullScreen(vtkTypeBool)191 void vtkGenericOpenGLRenderWindow::SetFullScreen(vtkTypeBool)
192 {
193 }
194 
WindowRemap()195 void vtkGenericOpenGLRenderWindow::WindowRemap()
196 {
197 }
198 
GetEventPending()199 int vtkGenericOpenGLRenderWindow::GetEventPending()
200 {
201   return 0;
202 }
203 
SetNextWindowId(void *)204 void vtkGenericOpenGLRenderWindow::SetNextWindowId(void*)
205 {
206 }
207 
SetNextWindowInfo(const char *)208 void vtkGenericOpenGLRenderWindow::SetNextWindowInfo(const char*)
209 {
210 }
211 
CreateAWindow()212 void vtkGenericOpenGLRenderWindow::CreateAWindow()
213 {
214 }
215 
DestroyWindow()216 void vtkGenericOpenGLRenderWindow::DestroyWindow()
217 {
218 }
219 
SetIsDirect(int newValue)220 void vtkGenericOpenGLRenderWindow::SetIsDirect(int newValue)
221 {
222   this->DirectStatus = newValue;
223 }
224 
SetSupportsOpenGL(int newValue)225 void vtkGenericOpenGLRenderWindow::SetSupportsOpenGL(int newValue)
226 {
227   this->SupportsOpenGLStatus = newValue;
228 }
229 
SetIsCurrent(bool newValue)230 void vtkGenericOpenGLRenderWindow::SetIsCurrent(bool newValue)
231 {
232   this->CurrentStatus = newValue;
233 }
234 
Render()235 void vtkGenericOpenGLRenderWindow::Render()
236 {
237   if (this->ReadyForRendering)
238   {
239     // Query current GL state and store them
240     this->SaveGLState();
241 
242     this->Superclass::Render();
243 
244     // Restore state to previous known value
245     this->RestoreGLState();
246   }
247 }
248 
SetIsPicking(vtkTypeBool isPicking)249 void vtkGenericOpenGLRenderWindow::SetIsPicking(vtkTypeBool isPicking)
250 {
251   vtkDebugMacro(<< this->GetClassName() << " (" << this
252                 << "): setting IsPicking to " << isPicking);
253   if (this->IsPicking != isPicking)
254   {
255     this->IsPicking = isPicking;
256     this->Modified();
257     this->InvokeEvent(this->IsPicking ? vtkCommand::StartPickEvent
258                                       : vtkCommand::EndPickEvent,
259                       nullptr);
260   }
261 }
262 
SetCurrentCursor(int cShape)263 void vtkGenericOpenGLRenderWindow::SetCurrentCursor(int cShape)
264 {
265   vtkDebugMacro(<< this->GetClassName() << " (" << this
266                 << "): setting current Cursor to " << cShape);
267   if (this->GetCurrentCursor() != cShape)
268   {
269     this->CurrentCursor = cShape;
270     this->Modified();
271     this->InvokeEvent(vtkCommand::CursorChangedEvent, &cShape);
272   }
273 }
274