Commit 3b6810ff authored by Dan Lipsa's avatar Dan Lipsa

BUG: OSMESA configuration flags can cause link errors.

This fixes:
   VTK_OPENGL_HAS_OSMESA on
   VTK_USE_X             on
   caused link errors in Rendering/OpenGL as some of the cxx
   files contained code ifdef using VTK_OPENGL_HAS_OSMESA instead of
   VTK_USE_OSMESA

In the past, one could link against both MESA and OSMESA and use OSMESA only
for off-screen rendering. In recent versions of MESA this is not the case anymore.
parent dcadad3b
......@@ -76,13 +76,10 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/TestFBOInclude.h.in
# test.
vtk_module_test_executable(TestFBOImplementation
TestFBOImplementation.cxx)
vtk_opengl_link(TestFBOImplementation)
target_link_libraries(TestFBOImplementation LINK_PRIVATE
vtkRenderingOpenGL ${OPENGL_gl_LIBRARY})
vtkRenderingOpenGL)
if(VTK_OPENGL_HAS_OSMESA AND OSMESA_LIBRARY)
target_link_libraries(TestFBOImplementation LINK_PRIVATE ${OSMESA_LIBRARY})
target_link_libraries(${vtk-module}CxxTests LINK_PRIVATE ${OSMESA_LIBRARY})
endif()
# Add other odd tests or executables
foreach(exe
......@@ -91,19 +88,16 @@ foreach(exe
VTKBenchMark
)
add_executable(${exe} ${exe}.cxx)
target_link_libraries(${exe}
vtk_opengl_link(${exe})
target_link_libraries(${exe} LINK_PRIVATE
vtkRenderingOpenGL
vtkInteractionStyle
vtkImagingSources
vtkImagingGeneral
vtkFiltersSources
vtkIOCore
${OPENGL_gl_LIBRARY})
if(APPLE)
target_link_libraries(${exe} "-framework GLUT")
endif()
if(VTK_OPENGL_HAS_OSMESA AND OSMESA_LIBRARY)
target_link_libraries(${exe} ${OSMESA_LIBRARY})
vtkIOCore)
if(APPLE AND NOT VTK_USE_OSMESA)
target_link_libraries(${exe} LINK_PRIVATE "-framework GLUT")
endif()
endforeach()
......
......@@ -22,7 +22,7 @@ PURPOSE. See the above copyright notice for more information.
#include <GL/gl.h>
#include "vtkgl.h"
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
# include <GL/osmesa.h>
#endif
......
......@@ -47,7 +47,7 @@ extern "C" vtkglX::__GLXextFuncPtr glXGetProcAddressARB(const GLubyte *);
#include <dlfcn.h>
#endif //VTK_USE_APPLE_LOADER
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
# include <GL/osmesa.h>
#endif
......@@ -720,7 +720,7 @@ vtkOpenGLExtensionManager::GetProcAddress(const char *fname)
return NULL;
#endif //VTK_USE_VTK_DYNAMIC_LOADER
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
return static_cast<vtkOpenGLExtensionManagerFunctionPointer>(
OSMesaGetProcAddress(fname));
#endif
......
......@@ -28,7 +28,7 @@
#cmakedefine VTK_USE_GLX_GET_PROC_ADDRESS_ARB
#cmakedefine VTK_USE_VTK_DYNAMIC_LOADER
#cmakedefine VTK_NO_EXTENSION_LOADING
#cmakedefine VTK_OPENGL_HAS_OSMESA
#cmakedefine VTK_USE_OSMESA
#cmakedefine VTK_DEFINE_GLX_GET_PROC_ADDRESS_PROTOTYPE
......
......@@ -25,7 +25,7 @@
/* Rendering Configuration */
#cmakedefine VTK_USE_X
#define VTK_USE_OPENGL_LIBRARY
#cmakedefine VTK_OPENGL_HAS_OSMESA
#cmakedefine VTK_USE_OSMESA
#cmakedefine VTK_USE_OFFSCREEN
#cmakedefine VTK_USE_GLSL_SHADERS
......@@ -53,9 +53,4 @@
# define VTK_USE_OGLR
#endif
#if (defined(VTK_OPENGL_HAS_OSMESA) && !defined(VTK_USE_OGLR) && \
!defined(_WIN32) && !defined(VTK_USE_COCOA))
# define VTK_USE_OSMESA
#endif
#endif
......@@ -41,7 +41,7 @@ typedef ptrdiff_t GLsizeiptr;
#include "vtkToolkits.h"
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
# include <GL/osmesa.h>
#endif
......@@ -86,7 +86,7 @@ private:
int ScreenDoubleBuffer;
int ScreenMapped;
#if defined( VTK_OPENGL_HAS_OSMESA )
#if defined( VTK_USE_OSMESA )
// OffScreen stuff
OSMesaContext OffScreenContextId;
void *OffScreenWindow;
......@@ -108,7 +108,7 @@ vtkXOpenGLRenderWindowInternal::vtkXOpenGLRenderWindowInternal(
this->ScreenDoubleBuffer = rw->GetDoubleBuffer();
// OpenGL specific
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
this->OffScreenContextId = NULL;
this->OffScreenWindow = NULL;
#endif
......@@ -118,7 +118,7 @@ vtkStandardNewMacro(vtkXOpenGLRenderWindow);
#define MAX_LIGHTS 8
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
// a couple of routines for offscreen rendering
void vtkOSMesaDestroyWindow(void *Window)
{
......@@ -484,7 +484,7 @@ void vtkXOpenGLRenderWindow::SetStereoCapableWindow(int capable)
{
if (!this->Internal->ContextId && !this->Internal->PixmapContextId
&& !this->Internal->PbufferContextId
#if defined( VTK_OPENGL_HAS_OSMESA )
#if defined( VTK_USE_OSMESA )
&& !this->Internal->OffScreenContextId
#endif
)
......@@ -814,7 +814,7 @@ void vtkXOpenGLRenderWindow::CreateOffScreenWindow(int width, int height)
this->DoubleBuffer = 0;
// always prefer OSMESA if we built with it
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
if(1)
{
if (!this->Internal->OffScreenWindow)
......@@ -963,7 +963,7 @@ void vtkXOpenGLRenderWindow::DestroyOffScreenWindow()
}
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
if (this->Internal->OffScreenContextId)
{
OSMesaDestroyContext(this->Internal->OffScreenContextId);
......@@ -1008,7 +1008,7 @@ void vtkXOpenGLRenderWindow::ResizeOffScreenWindow(int width, int height)
// Generally, we simply destroy and recreate the offscreen window/contexts.
// However, that's totally unnecessary for OSMesa. So we avoid that.
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
if (this->Internal->OffScreenContextId && this->Internal->OffScreenWindow)
{
vtkOSMesaDestroyWindow(this->Internal->OffScreenWindow);
......@@ -1064,7 +1064,7 @@ void vtkXOpenGLRenderWindow::Initialize (void)
else if(this->OffScreenRendering &&
! (this->Internal->PixmapContextId ||
this->Internal->PbufferContextId
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
|| this->Internal->OffScreenContextId
#endif
|| this->OffScreenUseFrameBuffer
......@@ -1286,7 +1286,7 @@ void vtkXOpenGLRenderWindow::PrintSelf(ostream& os, vtkIndent indent)
this->Superclass::PrintSelf(os,indent);
os << indent << "ContextId: " << this->Internal->ContextId << "\n";
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
os << indent << "OffScreenContextId: " << this->Internal->OffScreenContextId << "\n";
#endif
os << indent << "Color Map: " << this->ColorMap << "\n";
......@@ -1314,7 +1314,7 @@ void vtkXOpenGLRenderWindow::MakeCurrent()
// XSynchronize(this->DisplayId,1);
// }
// XSetErrorHandler(vtkXError);
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
// set the current window
if (this->OffScreenRendering && this->Internal->OffScreenContextId)
......@@ -1369,7 +1369,7 @@ void vtkXOpenGLRenderWindow::MakeCurrent()
bool vtkXOpenGLRenderWindow::IsCurrent()
{
bool result=false;
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
if(this->OffScreenRendering && this->Internal->OffScreenContextId)
{
result=this->Internal->OffScreenContextId==OSMesaGetCurrentContext();
......@@ -1388,7 +1388,7 @@ bool vtkXOpenGLRenderWindow::IsCurrent()
result=this->Internal->ContextId==glXGetCurrentContext();
}
}
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
}
#endif
return result;
......@@ -1421,7 +1421,7 @@ extern "C"
void *vtkXOpenGLRenderWindow::GetGenericContext()
{
#if defined(MESA) && defined(VTK_OPENGL_HAS_OSMESA)
#if defined(MESA) && defined(VTK_USE_OSMESA)
if (this->OffScreenRendering && this->Internal->OffScreenContextId)
{
return (void *)this->Internal->OffScreenContextId;
......@@ -1938,7 +1938,7 @@ void vtkXOpenGLRenderWindow::SetOffScreenRendering(int i)
// This probably has been moved to superclass.
void *vtkXOpenGLRenderWindow::GetGenericWindowId()
{
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
if (this->OffScreenRendering && this->Internal->OffScreenWindow)
{
return reinterpret_cast<void*>(this->Internal->OffScreenWindow);
......
......@@ -18,7 +18,7 @@
#include "vtkToolkits.h"
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
#include <GL/osmesa.h>
#endif
......
......@@ -26,7 +26,7 @@
/* Rendering Configuration */
#cmakedefine VTK_USE_X
#define VTK_USE_OPENGL_LIBRARY
#cmakedefine VTK_OPENGL_HAS_OSMESA
#cmakedefine VTK_USE_OSMESA
#cmakedefine VTK_USE_OFFSCREEN
#define VTK_USE_GLSL_SHADERS
......@@ -48,9 +48,4 @@
# define VTK_USE_OGLR
#endif
#if (defined(VTK_OPENGL_HAS_OSMESA) && !defined(VTK_USE_OGLR) && \
!defined(_WIN32) && !defined(VTK_USE_COCOA))
# define VTK_USE_OSMESA
#endif
#endif
......@@ -32,7 +32,7 @@ typedef ptrdiff_t GLsizeiptr;
#include "vtkToolkits.h"
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
#include <GL/osmesa.h>
#endif
......@@ -82,7 +82,7 @@ private:
int ScreenDoubleBuffer;
int ScreenMapped;
#if defined( VTK_OPENGL_HAS_OSMESA )
#if defined( VTK_USE_OSMESA )
// OffScreen stuff
OSMesaContext OffScreenContextId;
void *OffScreenWindow;
......@@ -104,7 +104,7 @@ vtkXOpenGLRenderWindowInternal::vtkXOpenGLRenderWindowInternal(
this->ScreenDoubleBuffer = rw->GetDoubleBuffer();
// OpenGL specific
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
this->OffScreenContextId = NULL;
this->OffScreenWindow = NULL;
#endif
......@@ -114,7 +114,7 @@ vtkStandardNewMacro(vtkXOpenGLRenderWindow);
#define MAX_LIGHTS 8
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
// a couple of routines for offscreen rendering
void vtkOSMesaDestroyWindow(void *Window)
{
......@@ -405,7 +405,7 @@ void vtkXOpenGLRenderWindow::SetStereoCapableWindow(int capable)
{
if (!this->Internal->ContextId && !this->Internal->PixmapContextId
&& !this->Internal->PbufferContextId
#if defined( VTK_OPENGL_HAS_OSMESA )
#if defined( VTK_USE_OSMESA )
&& !this->Internal->OffScreenContextId
#endif
)
......@@ -744,7 +744,7 @@ void vtkXOpenGLRenderWindow::CreateOffScreenWindow(int width, int height)
this->DoubleBuffer = 0;
// always prefer OSMESA if we built with it
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
if(1)
{
if (!this->Internal->OffScreenWindow)
......@@ -886,7 +886,7 @@ void vtkXOpenGLRenderWindow::DestroyOffScreenWindow()
}
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
if (this->Internal->OffScreenContextId)
{
OSMesaDestroyContext(this->Internal->OffScreenContextId);
......@@ -931,7 +931,7 @@ void vtkXOpenGLRenderWindow::ResizeOffScreenWindow(int width, int height)
// Generally, we simply destroy and recreate the offscreen window/contexts.
// However, that's totally unnecessary for OSMesa. So we avoid that.
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
if (this->Internal->OffScreenContextId && this->Internal->OffScreenWindow)
{
vtkOSMesaDestroyWindow(this->Internal->OffScreenWindow);
......@@ -987,7 +987,7 @@ void vtkXOpenGLRenderWindow::Initialize (void)
else if(this->OffScreenRendering &&
! (this->Internal->PixmapContextId ||
this->Internal->PbufferContextId
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
|| this->Internal->OffScreenContextId
#endif
|| this->OffScreenUseFrameBuffer
......@@ -1209,7 +1209,7 @@ void vtkXOpenGLRenderWindow::PrintSelf(ostream& os, vtkIndent indent)
this->Superclass::PrintSelf(os,indent);
os << indent << "ContextId: " << this->Internal->ContextId << "\n";
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
os << indent << "OffScreenContextId: " << this->Internal->OffScreenContextId << "\n";
#endif
os << indent << "Color Map: " << this->ColorMap << "\n";
......@@ -1237,7 +1237,7 @@ void vtkXOpenGLRenderWindow::MakeCurrent()
// XSynchronize(this->DisplayId,1);
// }
// XSetErrorHandler(vtkXError);
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
// set the current window
if (this->OffScreenRendering && this->Internal->OffScreenContextId)
......@@ -1292,7 +1292,7 @@ void vtkXOpenGLRenderWindow::MakeCurrent()
bool vtkXOpenGLRenderWindow::IsCurrent()
{
bool result=false;
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
if(this->OffScreenRendering && this->Internal->OffScreenContextId)
{
result=this->Internal->OffScreenContextId==OSMesaGetCurrentContext();
......@@ -1311,7 +1311,7 @@ bool vtkXOpenGLRenderWindow::IsCurrent()
result=this->Internal->ContextId==glXGetCurrentContext();
}
}
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
}
#endif
return result;
......@@ -1344,7 +1344,7 @@ extern "C"
void *vtkXOpenGLRenderWindow::GetGenericContext()
{
#if defined(MESA) && defined(VTK_OPENGL_HAS_OSMESA)
#if defined(VTK_USE_OSMESA)
if (this->OffScreenRendering && this->Internal->OffScreenContextId)
{
return (void *)this->Internal->OffScreenContextId;
......@@ -1864,7 +1864,7 @@ void vtkXOpenGLRenderWindow::SetOffScreenRendering(int i)
// This probably has been moved to superclass.
void *vtkXOpenGLRenderWindow::GetGenericWindowId()
{
#ifdef VTK_OPENGL_HAS_OSMESA
#ifdef VTK_USE_OSMESA
if (this->OffScreenRendering && this->Internal->OffScreenWindow)
{
return reinterpret_cast<void*>(this->Internal->OffScreenWindow);
......
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