-
Notifications
You must be signed in to change notification settings - Fork 1
/
vtkMultiChannelRenderWindowManager.cxx
188 lines (149 loc) · 5.35 KB
/
vtkMultiChannelRenderWindowManager.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*=========================================================================
Name: vtkMultiChannelRenderWindowManager.cxx
Author: David Borland, The Renaissance Computing Institute (RENCI)
Copyright: The Renaissance Computing Institute (RENCI)
License: Licensed under the RENCI Open Source Software License v. 1.0.
See included License.txt or
http://www.renci.org/resources/open-source-software-license
for details.
=========================================================================*/
#include "vtkMultiChannelRenderWindowManager.h"
#include "vtkCollection.h"
#include "vtkGraphicsFactory.h"
#include "vtkMultiChannelRenderWindowHelper.h"
#include "vtkObjectFactory.h"
#include "vtkRenderWindowChannel.h"
#include "vtkRenderer.h"
// Include platform-specific headers via code borrowed from vtkGraphicsFactory.h
// Win32 specific stuff
#ifdef _WIN32
# ifndef VTK_USE_OGLR
# include "vtkOpenGLMultiChannelCamera.h"
# include "vtkWin32OpenGLMultiChannelRenderWindow.h"
# define VTK_DISPLAY_WIN32_OGL
# endif // VTK_USE_OGLR
#endif
// Apple OSX stuff
#ifdef VTK_USE_CARBON
# include "vtkCarbonMultiChannelRenderWindow.h"
# define VTK_DISPLAY_CARBON
#endif
#ifdef VTK_USE_COCOA
# include "vtkCocoaMultiChannelRenderWindow.h"
# define VTK_DISPLAY_COCOA
#endif
// X OpenGL stuff
#ifdef VTK_USE_OGLR
# include "vtkXOpenGLMultiChannelRenderWindow.h"
# define VTK_DISPLAY_X11_OGL
#endif
// OSMESA OpenGL stuff
#ifdef VTK_USE_OSMESA
# include "vtkOSOpenGLMultiChannelRenderWindow.h"
//# define VTK_DISPLAY_X11_OGL
#endif
#if defined(VTK_USE_MANGLED_MESA)
#include "vtkXMesaRenderMultiChannelRenderWindow.h"
#endif
vtkCxxRevisionMacro(vtkMultiChannelRenderWindowManager, "$Revision: 1.0 $");
vtkStandardNewMacro(vtkMultiChannelRenderWindowManager);
//----------------------------------------------------------------------------
vtkMultiChannelRenderWindowManager::vtkMultiChannelRenderWindowManager()
{
this->Helper = vtkMultiChannelRenderWindowHelper::New();
this->NeedsStereo = false;
}
//----------------------------------------------------------------------------
vtkMultiChannelRenderWindowManager::~vtkMultiChannelRenderWindowManager()
{
this->Helper->Delete();
}
//----------------------------------------------------------------------------
void vtkMultiChannelRenderWindowManager::AddChannel(vtkRenderWindowChannel *channel)
{
this->Helper->GetChannels()->AddItem(channel);
if (channel->GetStereoType() != VTK_MULTICHANNEL_STEREO_NONE)
{
this->NeedsStereo = true;
}
}
//----------------------------------------------------------------------------
void vtkMultiChannelRenderWindowManager::ClearChannels()
{
this->Helper->GetChannels()->RemoveAllItems();
this->NeedsStereo = false;
}
//----------------------------------------------------------------------------
vtkRenderWindow* vtkMultiChannelRenderWindowManager::GetRenderWindow()
{
// Return the correct platform-specific vtkRenderWindow subclass
const char *rl = vtkGraphicsFactory::GetRenderLibrary();
#ifdef VTK_USE_OGLR
if (!strcmp("OpenGL",rl))
{
#if defined(VTK_USE_MANGLED_MESA)
if ( vtkGraphicsFactory::UseMesaClasses )
{
vtkErrorMacro(<<"Multi-channel rendering not implemented for this platform yet.");
return vtkXMesaRenderWindow::New();
}
#endif
vtkErrorMacro(<<"Multi-channel rendering not implemented for this platform yet.");
return vtkXOpenGLRenderWindow::New();
}
#endif
#if defined(VTK_USE_OSMESA)
vtkErrorMacro(<<"Multi-channel rendering not implemented for this platform yet.");
return vtkOSOpenGLRenderWindow::New();
#endif
#ifdef VTK_DISPLAY_WIN32_OGL
if (!strcmp("Win32OpenGL",rl))
{
vtkWin32OpenGLMultiChannelRenderWindow* window = vtkWin32OpenGLMultiChannelRenderWindow::New();
window->SetHelper(this->Helper);
if (this->NeedsStereo)
{
window->StereoCapableWindowOn();
window->StereoRenderOn();
}
// Create a new helper for the next window to be created
this->Helper->Delete();
this->Helper = vtkMultiChannelRenderWindowHelper::New();
this->NeedsStereo = false;
return window;
}
#endif
#ifdef VTK_USE_CARBON
vtkErrorMacro(<<"Multi-channel rendering not implemented for this platform yet.");
return vtkCarbonRenderWindow::New();
#endif
#ifdef VTK_USE_COCOA
vtkErrorMacro(<<"Multi-channel rendering not implemented for this platform yet.");
return vtkCocoaRenderWindow::New();
#endif
return 0;
}
//----------------------------------------------------------------------------
vtkRenderer *vtkMultiChannelRenderWindowManager::GetRenderer()
{
vtkRenderer* renderer = vtkRenderer::New();
#if defined(VTK_USE_MANGLED_MESA)
if (vtkGraphicsFactor::UseMesaClasses)
{
vtkErrorMacro(<<"Multi-channel rendering not implemented for this rendering library yet.");
return 0;
}
#endif
vtkOpenGLMultiChannelCamera *camera = vtkOpenGLMultiChannelCamera::New();
renderer->SetActiveCamera(camera);
camera->Delete();
return renderer;
}
//----------------------------------------------------------------------------
void vtkMultiChannelRenderWindowManager::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
os << indent << "Helper:\n";
this->Helper->PrintSelf(os,indent.GetNextIndent());
os << indent << "NeedsStereo: " << this->NeedsStereo << "\n";
}