]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
ARB extensions
authorouv <ouv@opencascade.com>
Thu, 27 Apr 2006 13:50:12 +0000 (13:50 +0000)
committerouv <ouv@opencascade.com>
Thu, 27 Apr 2006 13:50:12 +0000 (13:50 +0000)
src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx

index b956554fd2a13afb40798cce71627c42c4e42583..f1cef55502401309dd32fc16f5c4ad6cce8fafae 100755 (executable)
@@ -27,6 +27,8 @@
 
 #include "VISU_OpenGLPointSpriteMapper.hxx"
 
+#include <SVTK_Extension.h>
+
 #include <vtkCamera.h>
 #include <vtkCellArray.h>
 #include <vtkCellData.h>
@@ -67,8 +69,6 @@ vtkStandardNewMacro(VISU_OpenGLPointSpriteMapper);
 #define VTK_PDPSM_NORMAL_TYPE_DOUBLE 0x0020
 #define VTK_PDPSM_OPAQUE_COLORS      0x0040
 
-//#ifndef WIN32
-
 #ifndef APIENTRY
 #define APIENTRY
 #endif
@@ -138,57 +138,26 @@ static PFNGLBINDBUFFERARBPROC               vglBindBufferARB              = NULL
 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;
 
 //-----------------------------------------------------------------------------
@@ -412,6 +381,11 @@ void VISU_OpenGLPointSpriteMapper::SetPointSpriteAlphaThreshold( float theAlphaT
 //-----------------------------------------------------------------------------
 bool VISU_OpenGLPointSpriteMapper::InitExtensions()
 {
+  if( this->ExtensionsInitialized )
+    return true;
+
+  InitializeARB();
+
   char* ext = (char*)glGetString( GL_EXTENSIONS );
   //cout << "OpenGL extensions : " << ext << endl;
 
@@ -463,11 +437,9 @@ void VISU_OpenGLPointSpriteMapper::RenderPiece(vtkRenderer *ren, vtkActor *act)
   bool isUseThisMapper = !( this->UseOpenGLMapper ||
                            this->PrimitiveType == VISU_OpenGLPointSpriteMapper::GeomSphere );
 
-  if( !this->ExtensionsInitialized && isUseThisMapper )
-  {
+  if( isUseThisMapper )
     if( !this->InitExtensions() )
       return;
-  }
 
   if( !isUseThisMapper )
   {