上一节最后执行到:
this->GetRenderWindow()->Render();
也就是执行到了vtkRenderWindow::Render()了,我们可以看到这个函数是告诉这个RenderWindow下的每一个renderer去渲染他的图像,并且保持进程同步
// Ask each renderer owned by this RenderWindow to render its image and
// synchronize this process
void vtkRenderWindow::Render()
{
int *size;
int x,y;
float *p1;
// if we are in the middle of an abort check then return now
if (this->InAbortCheck)
{
return;
}
如果是在中止的中间过程,则check并且返回
// if we are in a render already from somewhere else abort now
if (this->InRender)
{
return;
}
如果从其他某个地方现在已经在渲染了,那么立即中止
// if SetSize has not yet been called (from a script, possible off
// screen use, other scenarios?) then call it here with reasonable
// default values
if (0 == this->Size[0] && 0 == this->Size[1])
{
this->SetSize(300, 300);
}
如果SetSize还没有被使用(通过一个脚本,或者关闭屏幕,或者其他情况),那么在这里调用它,并赋值默认值
// reset the Abort flag
this->AbortRender = 0;
this->InRender = 1;
vtkDebugMacro(<< "Starting Render Method.\n");
this->InvokeEvent(vtkCommand::StartEvent,NULL);
this->NeverRendered = 0;
if ( this->Interactor && ! this->Interactor->GetInitialized() )
{
this->Interactor->Initialize();
}
重置中止符号,开始渲染,设置InRender为1。调用开始事件。并且初始化关联器
// CAUTION:
// This method uses this->GetSize() and allocates buffers using that size.
// Remember that GetSize() will returns a size scaled by the TileScale factor.
// We should use GetActualSize() when we don't want the size to be scaled.
// if there is a reason for an AccumulationBuffer
if ( this->SubFrames || this->AAFrames || this->FDFrames)
{
// check the current size
size = this->GetSize();
unsigned int bufferSize = 3*size[0]*size[1];
// If there is not a buffer or the size is too small
// re-allocate it
if( !this->AccumulationBuffer
|| bufferSize > this->AccumulationBufferSize)
{
// it is OK to delete null, no sense in two if's
delete [] this->AccumulationBuffer;
// Save the size of the buffer
this->AccumulationBufferSize = 3*size[0]*size[1];
this->AccumulationBuffer = new float [this->AccumulationBufferSize];<span style="font-family: Arial, Helvetica, sans-serif;">memset(this->AccumulationBuffer,0,this->AccumulationBufferSize*sizeof(float));}}</span>
这个方法使用this->GetSize(),并且分配buffers从而使用这个size。这个GetSize()函数会根据TileScale调整比例。如果我们不希望这个size被调整,那么调用GetActualSize()。
上面这段代码我们可以看出,主要是为了确保AccumulationBuffer的正确性,如果过不存在或者比bufferSize小。则给它删除原有的,重新赋值并且分配空间。
// handle any sub frames
if (this->Su