Salome HOME
Fix bugs in the new opengl backend.
[modules/gui.git] / src / VTKViewer / VTKViewer_PolyDataMapper.h
index 350c1090296d2421fec9bd64060cdf578d9fe957..8f8349520cf422faac362e1391613c9f2e82699a 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2012  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
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -23,7 +23,7 @@
 #include "VTKViewer.h"
 #include "VTKViewer_MarkerDef.h"
 
-#ifdef WNT
+#ifdef WIN32
 #include <windows.h>
 #endif
 
@@ -43,6 +43,11 @@ class vtkImageData;
 #define MAPPER_SUPERCLASS vtkMesaPolyDataMapper
 #endif
 
+#ifndef GL_ARB_shader_objects
+typedef GLuint GLhandleARB;
+#endif
+
+
 //----------------------------------------------------------------------------
 //! OpenGL Point Sprites PolyData Mapper.
 /*!
@@ -65,6 +70,16 @@ public:
   //! Set point marker enabled
   void SetMarkerEnabled( bool );
 
+  //! Set point ball enabled
+  void SetBallEnabled( bool );
+  
+  bool GetBallEnabled( );
+
+  //! Set ball scale factor
+  void SetBallScale( double );
+
+  double GetBallScale( );
+
   //! Set standard point marker
   void SetMarkerStd( VTK::MarkerType, VTK::MarkerScale );
 
@@ -82,9 +97,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();
@@ -102,6 +120,11 @@ protected:
   //! Initializing textures for Point Sprites.
   void              InitTextures();
 
+  //! Initializing of the Vertex Shader.
+  int               InitShader();
+
+  void              InternalDraw(vtkRenderer*, vtkActor*);
+
 private:
   int               ExtensionsInitialized;
 
@@ -109,7 +132,32 @@ private:
 
   vtkSmartPointer<vtkImageData> ImageData;
 
+  GLhandleARB PointProgram;
+#ifdef VTK_OPENGL2
+  GLhandleARB VertexShader;
+  GLhandleARB FragmentShader;
+  GLuint      VertexArrayObject;
+#endif
+
+  struct Locations {
+    static const GLint INVALID_LOCATION = -1;
+
+    GLint ModelViewProjection;
+    GLint GeneralPointSize;
+    GLint PointSprite;
+
+    Locations()
+    : ModelViewProjection (INVALID_LOCATION),
+      GeneralPointSize    (INVALID_LOCATION),
+      PointSprite         (INVALID_LOCATION)
+    {
+          //
+    }
+  } myLocations;
+
   bool              MarkerEnabled;
+  bool              BallEnabled;
+  double            BallScale;
   VTK::MarkerType   MarkerType;
   VTK::MarkerScale  MarkerScale;
   int               MarkerId;
@@ -117,6 +165,7 @@ private:
   typedef std::map< int, vtkSmartPointer<vtkImageData> > ImageDataMap;
   ImageDataMap      StandardTextures;
   ImageDataMap      CustomTextures;
+  ImageDataMap      SpecialTextures;  //special predefined textures, used to draw point sprites.
 };
 
 #endif