From: ouv Date: Thu, 27 Apr 2006 13:50:12 +0000 (+0000) Subject: ARB extensions X-Git-Tag: Before_Merging_BR_DEBUG_3_2_0b1_01jun06~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0ee6fa3c60291fc5481a8622da39890cfe9bee3c;p=modules%2Fvisu.git ARB extensions --- diff --git a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx index b956554f..f1cef555 100755 --- a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx +++ b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx @@ -27,6 +27,8 @@ #include "VISU_OpenGLPointSpriteMapper.hxx" +#include + #include #include #include @@ -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 ) {