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
|
/*=========================================================================
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 <vtkConeSource.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkNew.h>
//This tests if the offscreen rendering works
static bool TestWin32OpenGLRenderWindowOffScreen(vtkWin32OpenGLRenderWindow* renderWindow)
{
//Create a cone
vtkNew<vtkConeSource> coneSource;
coneSource->Update();
//Create a mapper and actor
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputConnection(coneSource->GetOutputPort());
vtkNew<vtkActor> actor;
actor->SetMapper(mapper.GetPointer());
//Create a renderer, render window, and interactor
vtkNew<vtkRenderer> renderer;
renderWindow->AddRenderer(renderer.GetPointer());
//Add the actors to the scene
renderer->AddActor(actor.GetPointer());
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 vtkNotUsed(argc), char* vtkNotUsed(argv)[])
{
vtkWin32OpenGLRenderWindow* renderWindow(NULL);
vtkNew<vtkRenderWindow> renderWindowBase;
renderWindow = vtkWin32OpenGLRenderWindow::SafeDownCast(renderWindowBase.GetPointer());
TestWin32OpenGLRenderWindowOffScreen(renderWindow);
return EXIT_SUCCESS;
}
|