vtkRenderStepsPass.cxx 6.2 KB
Newer Older
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
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkRenderStepsPass.cxx

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/

#include "vtkRenderStepsPass.h"
#include "vtkObjectFactory.h"
#include <cassert>

#include "vtkCameraPass.h"
#include "vtkLightsPass.h"
#include "vtkOpaquePass.h"
#include "vtkOverlayPass.h"
#include "vtkRenderPassCollection.h"
#include "vtkSequencePass.h"
#include "vtkTranslucentPass.h"
#include "vtkVolumetricPass.h"


vtkStandardNewMacro(vtkRenderStepsPass);

vtkCxxSetObjectMacro(vtkRenderStepsPass,CameraPass,vtkCameraPass);
vtkCxxSetObjectMacro(vtkRenderStepsPass,LightsPass,vtkRenderPass);
vtkCxxSetObjectMacro(vtkRenderStepsPass,OpaquePass,vtkRenderPass);
vtkCxxSetObjectMacro(vtkRenderStepsPass,TranslucentPass,vtkRenderPass);
vtkCxxSetObjectMacro(vtkRenderStepsPass,VolumetricPass,vtkRenderPass);
vtkCxxSetObjectMacro(vtkRenderStepsPass,OverlayPass,vtkRenderPass);
vtkCxxSetObjectMacro(vtkRenderStepsPass,PostProcessPass,vtkRenderPass);

// ----------------------------------------------------------------------------
vtkRenderStepsPass::vtkRenderStepsPass()
{
  this->CameraPass = vtkCameraPass::New();
  this->LightsPass = vtkLightsPass::New();
  this->OpaquePass = vtkOpaquePass::New();
  this->TranslucentPass = vtkTranslucentPass::New();
  this->VolumetricPass = vtkVolumetricPass::New();
  this->OverlayPass = vtkOverlayPass::New();
  this->SequencePass = vtkSequencePass::New();
  vtkRenderPassCollection *rpc = vtkRenderPassCollection::New();
  this->SequencePass->SetPasses(rpc);
  rpc->Delete();
  this->CameraPass->SetDelegatePass(this->SequencePass);
  this->PostProcessPass = NULL;
}

// ----------------------------------------------------------------------------
vtkRenderStepsPass::~vtkRenderStepsPass()
{
  if (this->CameraPass)
61
  {
62 63
    this->CameraPass->Delete();
    this->CameraPass = 0;
64
  }
65
  if (this->LightsPass)
66
  {
67 68
    this->LightsPass->Delete();
    this->LightsPass = 0;
69
  }
70
  if (this->OpaquePass)
71
  {
72 73
    this->OpaquePass->Delete();
    this->OpaquePass = 0;
74
  }
75
  if (this->TranslucentPass)
76
  {
77 78
    this->TranslucentPass->Delete();
    this->TranslucentPass = 0;
79
  }
80
  if (this->VolumetricPass)
81
  {
82 83
    this->VolumetricPass->Delete();
    this->VolumetricPass = 0;
84
  }
85
  if (this->OverlayPass)
86
  {
87 88
    this->OverlayPass->Delete();
    this->OverlayPass = 0;
89
  }
90
  if (this->PostProcessPass)
91
  {
92 93
    this->PostProcessPass->Delete();
    this->PostProcessPass = 0;
94
  }
95
  if (this->SequencePass)
96
  {
97 98 99
    this->SequencePass->Delete();
    this->SequencePass = 0;
  }
100
}
101 102 103 104 105 106 107 108

// ----------------------------------------------------------------------------
void vtkRenderStepsPass::PrintSelf(ostream& os, vtkIndent indent)
{
  this->Superclass::PrintSelf(os, indent);

  os << indent << "CameraPass:";
  if (this->CameraPass != 0)
109
  {
110
    this->CameraPass->PrintSelf(os, indent);
111
  }
112
  else
113
  {
114
    os << "(none)" <<endl;
115
  }
116 117
  os << indent << "LightsPass:";
  if (this->LightsPass != 0)
118
  {
119
    this->LightsPass->PrintSelf(os, indent);
120
  }
121
  else
122
  {
123
    os << "(none)" <<endl;
124
  }
125 126
  os << indent << "opaquePass:";
  if (this->OpaquePass != 0)
127
  {
128
    this->OpaquePass->PrintSelf(os, indent);
129
  }
130
  else
131
  {
132
    os << "(none)" <<endl;
133
  }
134 135
  os << indent << "TranslucentPass:";
  if (this->TranslucentPass != 0)
136
  {
137
    this->TranslucentPass->PrintSelf(os, indent);
138
  }
139
  else
140
  {
141
    os << "(none)" <<endl;
142
  }
143 144
  os << indent << "VolumetricPass:";
  if (this->VolumetricPass != 0)
145
  {
146
    this->VolumetricPass->PrintSelf(os, indent);
147
  }
148
  else
149
  {
150
    os << "(none)" <<endl;
151
  }
152 153
  os << indent << "OverlayPass:";
  if (this->OverlayPass != 0)
154
  {
155
    this->OverlayPass->PrintSelf(os, indent);
156
  }
157
  else
158
  {
159
    os << "(none)" <<endl;
160
  }
161 162
  os << indent << "PostProcessPass:";
  if (this->PostProcessPass != 0)
163
  {
164
    this->PostProcessPass->PrintSelf(os, indent);
165
  }
166
  else
167
  {
168
    os << "(none)" <<endl;
169
  }
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
}

// ----------------------------------------------------------------------------
// Description:
// Perform rendering according to a render state \p s.
// \pre s_exists: s!=0
void vtkRenderStepsPass::Render(const vtkRenderState *s)
{
  assert("pre: s_exists" && s != 0);

  vtkRenderPassCollection *passes =
    this->SequencePass->GetPasses();
  passes->RemoveAllItems();

  if (this->LightsPass)
185
  {
186
    passes->AddItem(this->LightsPass);
187
  }
188
  if (this->OpaquePass)
189
  {
190
    passes->AddItem(this->OpaquePass);
191
  }
192
  if (this->TranslucentPass)
193
  {
194
    passes->AddItem(this->TranslucentPass);
195
  }
196
  if (this->VolumetricPass)
197
  {
198
    passes->AddItem(this->VolumetricPass);
199
  }
200
  if (this->OverlayPass)
201
  {
202
    passes->AddItem(this->OverlayPass);
203
  }
204 205 206

  this->NumberOfRenderedProps = 0;
  if (this->CameraPass)
207
  {
208 209
    this->CameraPass->Render(s);
    this->NumberOfRenderedProps += this->CameraPass->GetNumberOfRenderedProps();
210
  }
211
  if (this->PostProcessPass)
212
  {
213 214
    this->PostProcessPass->Render(s);
    this->NumberOfRenderedProps += this->PostProcessPass->GetNumberOfRenderedProps();
215
  }
216 217 218 219 220 221 222 223 224 225 226 227
}

// ----------------------------------------------------------------------------
// Description:
// Release graphics resources and ask components to release their own
// resources.
// \pre w_exists: w!=0
void vtkRenderStepsPass::ReleaseGraphicsResources(vtkWindow *w)
{
  assert("pre: w_exists" && w != 0);

  if (this->CameraPass)
228
  {
229
    this->CameraPass->ReleaseGraphicsResources(w);
230
  }
231
  if (this->LightsPass)
232
  {
233
    this->LightsPass->ReleaseGraphicsResources(w);
234
  }
235
  if (this->OpaquePass)
236
  {
237
    this->OpaquePass->ReleaseGraphicsResources(w);
238
  }
239
  if (this->TranslucentPass)
240
  {
241
    this->TranslucentPass->ReleaseGraphicsResources(w);
242
  }
243
  if (this->VolumetricPass)
244
  {
245
    this->VolumetricPass->ReleaseGraphicsResources(w);
246
  }
247
  if (this->OverlayPass)
248
  {
249
    this->OverlayPass->ReleaseGraphicsResources(w);
250
  }
251
  if (this->PostProcessPass)
252
  {
253
    this->PostProcessPass->ReleaseGraphicsResources(w);
254
  }
255
}