Salome HOME
Unicode support: correct handling of unicode on GUI level
[modules/gui.git] / src / VTKViewer / VTKViewer_PolyDataMapper.cxx
index f61d2af2165adb49115956402d39580767249308..aa4861f806508e25910d97ae53273c0c814f9ccb 100644 (file)
 # ifndef GLX_GLXEXT_LEGACY
 #  define GLX_GLXEXT_LEGACY
 # endif
+#ifdef __APPLE__
+#import <mach-o/dyld.h>
+#import <stdlib.h>
+#import <string.h>
+void * glXGetProcAddressARB (const GLubyte *name)
+
+{
+    NSSymbol symbol;
+    char *symbolName;
+    symbolName = (char *)malloc (strlen ((const char *)name) + 2); // 1
+    strcpy(symbolName + 1, (const char *)name); // 2
+    symbolName[0] = '_'; // 3
+    symbol = NULL;
+    if (NSIsSymbolNameDefined (symbolName)) // 4
+        symbol = NSLookupAndBindSymbol (symbolName);
+    free (symbolName); // 5
+    return symbol ? NSAddressOfSymbol (symbol) : NULL; // 6
+}
+#else
 # include <GL/glx.h>
+#endif
 # include <dlfcn.h>
 #else
 # include <wingdi.h>
@@ -125,6 +145,7 @@ int VTKViewer_PolyDataMapper::InitShader()
   this->OpenGLHelper.vglUseProgramObjectARB( this->PointProgram );
 
   this->myLocations.ModelViewProjection = this->OpenGLHelper.vglGetUniformLocationARB( this->PointProgram, "uModelViewProjectionMatrix" );
+  this->myLocations.Projection          = this->OpenGLHelper.vglGetUniformLocationARB( this->PointProgram, "uProjectionMatrix" );
   this->myLocations.GeneralPointSize    = this->OpenGLHelper.vglGetUniformLocationARB( this->PointProgram, "uGeneralPointSize" );
   this->myLocations.PointSprite         = this->OpenGLHelper.vglGetUniformLocationARB( this->PointProgram, "uPointSprite" );
 
@@ -135,7 +156,7 @@ int VTKViewer_PolyDataMapper::InitShader()
   std::string fileName = std::string( getenv( "GUI_ROOT_DIR") ) +
                          "/share/salome/resources/gui/Vertex_Program_ARB.txt";
 
-  char* shader = readFromFile( fileName );
+  char* shader = GUI_OPENGL::readFromFile( fileName );
 
   GLhandleARB VertexShader = this->OpenGLHelper.vglCreateShaderObjectARB( GL_VERTEX_SHADER_ARB );
   this->OpenGLHelper.vglShaderSourceARB( VertexShader, 1, (const GLcharARB**)&shader, NULL );
@@ -244,7 +265,7 @@ void VTKViewer_PolyDataMapper::SetBallEnabled( bool theBallEnabled )
       
       QString anAlphaTexture = getenv( "GUI_ROOT_DIR" );
       anAlphaTexture.append( "/share/salome/resources/gui/sprite_alpha.vti" );
-      vtkSmartPointer<vtkImageData> aTextureValue = VTK::MakeTexture( aMainTexture.toLatin1().constData(), anAlphaTexture.toLatin1().constData() );
+      vtkSmartPointer<vtkImageData> aTextureValue = VTK::MakeTexture( aMainTexture.toUtf8().constData(), anAlphaTexture.toUtf8().constData() );
       this->SpecialTextures[BallTextureId] = aTextureValue;
     }
     this->ImageData = this->SpecialTextures[BallTextureId];
@@ -592,6 +613,8 @@ namespace VTK
     virtual
     void
     get( TVertex& theVertex, vtkIdType thePointId, vtkIdType theCellId ) = 0;
+
+    virtual ~TColorFunctorBase() {}
   };
 
   //-----------------------------------------------------------------------------
@@ -839,7 +862,6 @@ void VTKViewer_PolyDataMapper::InternalDraw(vtkRenderer* ren, vtkActor* act ) {
       }
 
       int* aSize = this->ImageData->GetDimensions();
-      //glPointSize( std::max( aSize[0], aSize[1] ) );
 
       int aMode = 0; // to remove
       {
@@ -883,6 +905,7 @@ void VTKViewer_PolyDataMapper::InternalDraw(vtkRenderer* ren, vtkActor* act ) {
         {
                this->OpenGLHelper.SetUniformMatrix( this->myLocations.ModelViewProjection, wcdc );
         }
+        this->OpenGLHelper.SetUniformMatrix( this->myLocations.Projection, vcdc );
 
         this->OpenGLHelper.vglUniform1iARB( this->myLocations.GeneralPointSize, std::max( aSize[0], aSize[1] ) );
 
@@ -943,7 +966,7 @@ void VTKViewer_PolyDataMapper::InternalDraw(vtkRenderer* ren, vtkActor* act ) {
 #else
        GLuint aBufferObjectID, aDiamsID = 0;
        GLint attribute_diams = -1;
-
+       glPointSize( std::max( aSize[0], aSize[1] ) );
        this->OpenGLHelper.vglGenBuffersARB( 1, &aBufferObjectID );
        this->OpenGLHelper.vglBindBufferARB( GL_ARRAY_BUFFER_ARB, aBufferObjectID );
 
@@ -972,7 +995,7 @@ void VTKViewer_PolyDataMapper::InternalDraw(vtkRenderer* ren, vtkActor* act ) {
          this->OpenGLHelper.vglBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 );
          this->OpenGLHelper.vglBindBufferARB( GL_ARRAY_BUFFER_ARB, aDiamsID );
 
-         attribute_diams = vglGetAttribLocationARB(this->PointProgram, "diameter");
+         attribute_diams = this->OpenGLHelper.vglGetAttribLocationARB(this->PointProgram, "diameter");
          this->OpenGLHelper.vglEnableVertexAttribArrayARB(attribute_diams);
          this->OpenGLHelper.vglBindBufferARB(GL_ARRAY_BUFFER_ARB, aDiamsID);
          this->OpenGLHelper.vglVertexAttribPointerARB(