Commit 58e34140 authored by Sankhesh Jhaveri's avatar Sankhesh Jhaveri Committed by David C. Lonie

Enable OpenGL2 support for vtkRenderingExternal module

The module compiles fine with this change. However, there is a
runtime issue when creating VBOs.
parent 82c7c07e
......@@ -13,3 +13,9 @@ set(${vtk-module}_HDRS
)
vtk_module_library(vtkRenderingExternal ${Module_SRCS})
if ("${VTK_RENDERING_BACKEND}" STREQUAL "OpenGL2")
set_target_properties(
vtkRenderingExternal
PROPERTIES COMPILE_FLAGS -DVTK_OPENGL2)
endif ()
......@@ -10,4 +10,4 @@ VTK_ADD_TEST_CXX(${vtk-module}CxxTests tests
VTK_TEST_CXX_EXECUTABLE(${vtk-module}CxxTests tests)
TARGET_LINK_LIBRARIES(${vtk-module}CxxTests LINK_PRIVATE
vtkRenderingExternal ${OPENGL_gl_LIBRARY} ${GLUT_LIBRARY})
vtkRenderingExternal ${OPENGL_LIBRARIES} ${GLUT_LIBRARY})
......@@ -21,12 +21,13 @@
// vtkExternalOpenGLRenderer by drawing a GL_TRIANGLE in the scene before
// drawing the vtk sphere.
#include <vtk_glew.h>
// GLUT includes
#if defined(__APPLE__)
# include <GLUT/glut.h> // Include GLUT API.
#else
# include "vtkWindows.h" // Needed to include OpenGL header on Windows.
# include <GL/glut.h> // Include GLUT API.
# include <GL/freeglut.h> // Include GLUT API.
#endif
// STD includes
......@@ -166,6 +167,8 @@ int TestGLUTRenderWindow(int argc, char** argv)
NumArgs = argc;
ArgV = argv;
glutInit(&argc, argv); // Initialize GLUT
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL);
glutInitContextVersion(3, 3);
glutInitWindowSize(windowW, windowH); // Set the window's initial width & height
glutInitWindowPosition(101, 201); // Position the window's initial top-left corner
windowId = glutCreateWindow("VTK External Window Test"); // Create a window with the given title
......
# This module cannot be built when the rendering backend is OpenGL2
if (Module_vtkRenderingExternal AND
("${VTK_RENDERING_BACKEND}" STREQUAL "OpenGL2"))
message (SEND_ERROR "
vtkRenderingExternal cannot be built
when the rendering backend is OpenGL2.
Please disable vtkRenderingExternal or
change VTK_RENDERING_BACKEND to OpenGL.
")
return()
endif()
vtk_module(vtkRenderingExternal
DEPENDS
vtkRenderingCore
vtkRenderingOpenGL
vtkRendering${VTK_RENDERING_BACKEND}
TEST_DEPENDS
vtkTestingRendering
EXCLUDE_FROM_ALL
......
......@@ -14,7 +14,10 @@
=========================================================================*/
#include "vtkExternalOpenGLCamera.h"
#ifndef VTK_OPENGL2
#include "vtkgluPickMatrix.h"
#endif
#include "vtkMatrix4x4.h"
#include "vtkObjectFactory.h"
#include "vtkOpenGLError.h"
......@@ -36,11 +39,15 @@ vtkExternalOpenGLCamera::vtkExternalOpenGLCamera()
this->UserProvidedViewTransform = false;
}
//----------------------------------------------------------------------------
// Implement base class method.
void vtkExternalOpenGLCamera::Render(vtkRenderer *ren)
{
#ifdef VTK_OPENGL2
this->Superclass::Render(ren);
#else
vtkOpenGLClearErrorMacro();
double aspect[2];
......@@ -188,6 +195,8 @@ void vtkExternalOpenGLCamera::Render(vtkRenderer *ren)
matrix->Delete();
vtkOpenGLCheckErrorMacro("failed after Render");
#endif
}
//----------------------------------------------------------------------------
......
......@@ -19,7 +19,6 @@
#include "vtkExternalOpenGLCamera.h"
#include "vtkLightCollection.h"
#include "vtkLight.h"
#include "vtkLightingHelper.h"
#include "vtkMath.h"
#include "vtkMatrix4x4.h"
#include "vtkNew.h"
......@@ -29,6 +28,8 @@
#include "vtkRenderWindow.h"
#include "vtkTexture.h"
#define MAX_LIGHTS 8
vtkStandardNewMacro(vtkExternalOpenGLRenderer);
//----------------------------------------------------------------------------
......@@ -199,7 +200,7 @@ void vtkExternalOpenGLRenderer::Render(void)
// Query OpenGL lights
short curLight;
for (curLight = GL_LIGHT0;
curLight < GL_LIGHT0 + vtkLightingHelper::VTK_MAX_LIGHTS;
curLight < GL_LIGHT0 + MAX_LIGHTS;
curLight++)
{
GLboolean status;
......
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