Commit 9adc4bf8 authored by Yuanxin Liu's avatar Yuanxin Liu
Browse files

fix bug 0012702

parent 29d647ab
......@@ -79,6 +79,7 @@ IF(VTK_USE_DISPLAY)
TestTranslucentLUTDepthPeelingPass.cxx
TestTranslucentLUTTextureAlphaBlending.cxx
TestTranslucentLUTTextureDepthPeeling.cxx
TestWin32OpenGLRenderWindow.cxx
)
IF(VTK_DATA_ROOT)
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestWin32OpenGLRenderWindow.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 "vtkTestUtilities.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkActor.h"
#include "vtkConeSource.h"
#include "vtkWin32OpenGLRenderWindow.h"
#include <vtkSmartPointer.h>
#include <vtkConeSource.h>
#include <vtkPolyData.h>
#include <vtkSmartPointer.h>
#include <vtkPolyDataMapper.h>
//This tests if the offscreen rendering works
static bool TestWin32OpenGLRenderWindowOffScreen(vtkWin32OpenGLRenderWindow* renderWindow)
{
//Create a cone
vtkSmartPointer<vtkConeSource> coneSource =
vtkSmartPointer<vtkConeSource>::New();
coneSource->Update();
//Create a mapper and actor
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(coneSource->GetOutputPort());
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
//Create a renderer, render window, and interactor
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
renderWindow->AddRenderer(renderer);
//Add the actors to the scene
renderer->AddActor(actor);
renderer->SetBackground(.3, .2, .1); // Background color dark red
//Render and interact
renderWindow->SetOffScreenRendering(1);
renderWindow->SetSize(100,100);
renderWindow->Render();
return 1;
}
int TestWin32OpenGLRenderWindow(int argc, char* argv[])
{
vtkWin32OpenGLRenderWindow* renderWindow(NULL);
vtkSmartPointer<vtkRenderWindow> renderWindowBase = vtkSmartPointer<vtkRenderWindow>::New();
renderWindow = vtkWin32OpenGLRenderWindow::SafeDownCast(renderWindowBase);
TestWin32OpenGLRenderWindowOffScreen(renderWindow);
return EXIT_SUCCESS;
}
......@@ -23,7 +23,7 @@
#include "vtkRendererCollection.h"
#include "vtkTimerLog.h"
#include "vtkTransform.h"
#include "vtkToolKits.h"
//----------------------------------------------------------------------------
// Needed when we don't use the vtkStandardNewMacro.
......@@ -115,7 +115,11 @@ vtkRenderWindow *vtkRenderWindow::New()
{
// First try to create the object from the vtkObjectFactory
vtkObject* ret = vtkGraphicsFactory::CreateInstance("vtkRenderWindow");
return static_cast<vtkRenderWindow *>(ret);
vtkRenderWindow *retWin = static_cast<vtkRenderWindow *>(ret);
#ifdef VTK_USE_OFFSCREEN
retWin->SetOffScreenRendering(1);
#endif
return retWin;
}
//----------------------------------------------------------------------------
......
......@@ -56,6 +56,13 @@ vtkWin32OpenGLRenderWindow::vtkWin32OpenGLRenderWindow()
this->MemoryHdc = (HDC)0;
this->CreatingOffScreenWindow = 0;
this->WindowIdReferenceCount = 0;
this->ScreenMapped = this->Mapped;
this->ScreenWindowSize[0] = this->Size[0];
this->ScreenWindowSize[1] = this->Size[1];
this->ScreenDeviceContext = this->DeviceContext;
this->ScreenDoubleBuffer = this->DoubleBuffer;
this->ScreenContextId = this->ContextId;
}
vtkWin32OpenGLRenderWindow::~vtkWin32OpenGLRenderWindow()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment