vtkProbeOpenGLVersion.cxx 1.48 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
/*=========================================================================

  Program:   Visualization Toolkit

  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 "vtkAutoInit.h"
VTK_MODULE_INIT(vtkRenderingOpenGL2);

#include "vtkNew.h"
#include "vtkRenderer.h"
#include "vtkOpenGLRenderWindow.h"
#include "vtkOutputWindow.h"

#include <sstream>

int main(int , char* /* argv */[])
{
  int result = 0;

  vtkNew<vtkRenderer> renderer;
  vtkNew<vtkRenderWindow> renderWindow;
  renderWindow->AddRenderer(renderer);

  std::ostringstream toString;

  toString << "Class: " << renderWindow->GetClassName();

  if (!renderWindow->SupportsOpenGL())
  {
    toString << " failed to find a working OpenGL\n\n";
    toString << vtkOpenGLRenderWindow::SafeDownCast(renderWindow)->GetOpenGLSupportMessage();
    result = 1;
  }
  else
  {
    toString << " succeeded in finding a working OpenGL\n\n";
  }

  renderWindow->Render();
  toString << renderWindow->ReportCapabilities();

  vtkOutputWindow::GetInstance()->PromptUserOn();
  vtkOutputWindow::GetInstance()->DisplayText(toString.str().c_str());

  return result;
}