#include "VISU_OpenGLPointSpriteMapper.hxx"
+#include <SVTK_Extension.h>
+
#include <vtkCamera.h>
#include <vtkCellArray.h>
#include <vtkCellData.h>
#define VTK_PDPSM_NORMAL_TYPE_DOUBLE 0x0020
#define VTK_PDPSM_OPAQUE_COLORS 0x0040
-//#ifndef WIN32
-
#ifndef APIENTRY
#define APIENTRY
#endif
static PFNGLBUFFERDATAARBPROC vglBufferDataARB = NULL;
static PFNGLDELETEBUFFERSARBPROC vglDeleteBuffersARB = NULL;
-int InitializeARB()
+void InitializeARB()
{
-#ifdef WIN32
- HMODULE OpenGLLibrary = ::LoadLibrary( "nvoglnt.dll" );
-
- FARPROC vglShaderSourceARB1 = GetProcAddress( OpenGLLibrary, "DrvGetProcAddress" );
- vglShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)::GetProcAddress( OpenGLLibrary, "glShaderSourceARB" );
- vglCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)::GetProcAddress( OpenGLLibrary, "glCreateShaderObjectARB" );
- vglCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)::GetProcAddress( OpenGLLibrary, "glCompileShaderARB" );
- vglCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)::GetProcAddress( OpenGLLibrary, "glCreateProgramObjectARB" );
- vglAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)::GetProcAddress( OpenGLLibrary, "glAttachObjectARB" );
- vglLinkProgramARB = (PFNGLLINKPROGRAMARBPROC)::GetProcAddress( OpenGLLibrary, "glLinkProgramARB" );
- vglUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)::GetProcAddress( OpenGLLibrary, "glUseProgramObjectARB" );
- vglGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)::GetProcAddress( OpenGLLibrary, "glGetObjectParameterivARB" );
- vglGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)::GetProcAddress( OpenGLLibrary, "glGetInfoLogARB" );
- vglGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC)::GetProcAddress( OpenGLLibrary, "glGetAttribLocationARB" );
- vglVertexAttrib1fARB = (PFNGLVERTEXATTRIB1FARBPROC)::GetProcAddress( OpenGLLibrary, "glVertexAttrib1fARB" );
-
- vglGenBuffersARB = (PFNGLGENBUFFERSARBPROC)::GetProcAddress( OpenGLLibrary, "glGenBuffersARB" );
- vglBindBufferARB = (PFNGLBINDBUFFERARBPROC)::GetProcAddress( OpenGLLibrary, "glBindBufferARB" );
- vglBufferDataARB = (PFNGLBUFFERDATAARBPROC)::GetProcAddress( OpenGLLibrary, "glBufferDataARB" );
- vglDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)::GetProcAddress( OpenGLLibrary, "glDeleteBuffersARB" );
-#else
- void* OpenGLLibrary = dlopen( "libGL.so", RTLD_LAZY );
-
- vglShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)dlsym( OpenGLLibrary, "glShaderSourceARB" );
- vglCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)dlsym( OpenGLLibrary, "glCreateShaderObjectARB" );
- vglCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)dlsym( OpenGLLibrary, "glCompileShaderARB" );
- vglCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)dlsym( OpenGLLibrary, "glCreateProgramObjectARB" );
- vglAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)dlsym( OpenGLLibrary, "glAttachObjectARB" );
- vglLinkProgramARB = (PFNGLLINKPROGRAMARBPROC)dlsym( OpenGLLibrary, "glLinkProgramARB" );
- vglUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)dlsym( OpenGLLibrary, "glUseProgramObjectARB" );
- vglGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)dlsym( OpenGLLibrary, "glGetObjectParameterivARB" );
- vglGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)dlsym( OpenGLLibrary, "glGetInfoLogARB" );
- vglGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC)dlsym( OpenGLLibrary, "glGetAttribLocationARB" );
- vglVertexAttrib1fARB = (PFNGLVERTEXATTRIB1FARBPROC)dlsym( OpenGLLibrary, "glVertexAttrib1fARB" );
-
- vglGenBuffersARB = (PFNGLGENBUFFERSARBPROC)dlsym( OpenGLLibrary, "glGenBuffersARB" );
- vglBindBufferARB = (PFNGLBINDBUFFERARBPROC)dlsym( OpenGLLibrary, "glBindBufferARB" );
- vglBufferDataARB = (PFNGLBUFFERDATAARBPROC)dlsym( OpenGLLibrary, "glBufferDataARB" );
- vglDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)dlsym( OpenGLLibrary, "glDeleteBuffersARB" );
-#endif
-
-
- return 1;
+ vglShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)SVTK::getOpenGLExtension( "glShaderSourceARB" );
+ vglCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)SVTK::getOpenGLExtension( "glCreateShaderObjectARB" );
+ vglCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)SVTK::getOpenGLExtension( "glCompileShaderARB" );
+ vglCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)SVTK::getOpenGLExtension( "glCreateProgramObjectARB" );
+ vglAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)SVTK::getOpenGLExtension( "glAttachObjectARB" );
+ vglLinkProgramARB = (PFNGLLINKPROGRAMARBPROC)SVTK::getOpenGLExtension( "glLinkProgramARB" );
+ vglUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)SVTK::getOpenGLExtension( "glUseProgramObjectARB" );
+ vglGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)SVTK::getOpenGLExtension( "glGetObjectParameterivARB" );
+ vglGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)SVTK::getOpenGLExtension( "glGetInfoLogARB" );
+ vglGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC)SVTK::getOpenGLExtension( "glGetAttribLocationARB" );
+ vglVertexAttrib1fARB = (PFNGLVERTEXATTRIB1FARBPROC)SVTK::getOpenGLExtension( "glVertexAttrib1fARB" );
+
+ vglGenBuffersARB = (PFNGLGENBUFFERSARBPROC)SVTK::getOpenGLExtension( "glGenBuffersARB" );
+ vglBindBufferARB = (PFNGLBINDBUFFERARBPROC)SVTK::getOpenGLExtension( "glBindBufferARB" );
+ vglBufferDataARB = (PFNGLBUFFERDATAARBPROC)SVTK::getOpenGLExtension( "glBufferDataARB" );
+ vglDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)SVTK::getOpenGLExtension( "glDeleteBuffersARB" );
};
-static int IsARBInitialized = InitializeARB();
-
-//#endif // #ifndef WIN32
-
static float Tolerance = 1.0 / VTK_LARGE_FLOAT;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
bool VISU_OpenGLPointSpriteMapper::InitExtensions()
{
+ if( this->ExtensionsInitialized )
+ return true;
+
+ InitializeARB();
+
char* ext = (char*)glGetString( GL_EXTENSIONS );
//cout << "OpenGL extensions : " << ext << endl;
bool isUseThisMapper = !( this->UseOpenGLMapper ||
this->PrimitiveType == VISU_OpenGLPointSpriteMapper::GeomSphere );
- if( !this->ExtensionsInitialized && isUseThisMapper )
- {
+ if( isUseThisMapper )
if( !this->InitExtensions() )
return;
- }
if( !isUseThisMapper )
{