Salome HOME
Merge branch 'V8_3_asterstudy' into V8_3_BR
[modules/gui.git] / src / VTKViewer / VTKViewer_PolyDataMapper.h
index a3d9e90053827fb67fbfc43d0c3a7829cdca7b56..14418801a163c50146aee4304fb3f4b621409cad 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 
 #include <map>
 
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
 #include <GL/gl.h>
+#endif
 
 #include <vtkSmartPointer.h>
 
@@ -43,10 +47,7 @@ class vtkImageData;
 #define MAPPER_SUPERCLASS vtkMesaPolyDataMapper
 #endif
 
-#ifndef GL_ARB_shader_objects
-typedef GLuint GLhandleARB;
-#endif
-
+#include "VTKViewer_OpenGLHelper.h"
 
 //----------------------------------------------------------------------------
 //! OpenGL Point Sprites PolyData Mapper.
@@ -97,9 +98,12 @@ public:
 
   //! Implement superclass render method.
   virtual void RenderPiece( vtkRenderer*, vtkActor* );
-
   //! Draw method for OpenGL.
+#ifndef VTK_OPENGL2
   virtual int Draw( vtkRenderer*, vtkActor* );
+#else
+  virtual void RenderPieceDraw( vtkRenderer*, vtkActor* );
+#endif    
 
 protected:
   VTKViewer_PolyDataMapper();
@@ -118,7 +122,9 @@ protected:
   void              InitTextures();
 
   //! Initializing of the Vertex Shader.
-  void              InitShader();
+  int               InitShader();
+
+  void              InternalDraw(vtkRenderer*, vtkActor*);
 
 private:
   int               ExtensionsInitialized;
@@ -126,11 +132,35 @@ private:
   GLuint            PointSpriteTexture;
 
   vtkSmartPointer<vtkImageData> ImageData;
-  
-  GLhandleARB       VertexProgram;
+
+  VTKViewer_OpenGLHelper OpenGLHelper;
+  GLhandleARB PointProgram;
+#ifdef VTK_OPENGL2
+  GLhandleARB VertexShader;
+  GLhandleARB FragmentShader;
+  GLuint      VertexArrayObject;
+#endif
+
+  struct Locations {
+    static const GLint INVALID_LOCATION = -1;
+
+    GLint ModelViewProjection;
+    GLint Projection;
+    GLint GeneralPointSize;
+    GLint PointSprite;
+
+    Locations()
+    : ModelViewProjection (INVALID_LOCATION),
+      Projection          (INVALID_LOCATION),
+      GeneralPointSize    (INVALID_LOCATION),
+      PointSprite         (INVALID_LOCATION)
+    {
+          //
+    }
+  } myLocations;
 
   bool              MarkerEnabled;
-  bool              BallEnabled; 
+  bool              BallEnabled;
   double            BallScale;
   VTK::MarkerType   MarkerType;
   VTK::MarkerScale  MarkerScale;