]> OCCT Git - occt-copy.git/commitdiff
0025464: Visualization - provide package for Volume Rendering.
authorisk <isk@opencascade.com>
Wed, 10 Feb 2016 08:29:00 +0000 (11:29 +0300)
committerduv <duv@opencascade.com>
Fri, 25 Mar 2016 09:44:57 +0000 (12:44 +0300)
Add two functions OSD_OpenStream for std::ifstream.
Add four functions SetUnfirom in the OpenGl_ShaderProgram for 64-bit unsigned integer variables.
Add OpenGl_Texture::Init3D.
Update Declarations.glsl.

src/BVH/BVH_Box.hxx
src/NCollection/NCollection_Vec3.hxx
src/OpenGl/OpenGl_Context.hxx
src/OpenGl/OpenGl_Texture.cxx
src/Shaders/Declarations.glsl

index 838fb90352d6192b579003af364ce1436296d2cd..e0755db224a729892c2d77e7aaebcecec3f82aa6 100644 (file)
@@ -281,4 +281,18 @@ namespace BVH
 
 #include <BVH_Box.lxx>
 
+//! 2D box of double precision reals.
+typedef BVH_Box<Standard_Real, 2> BVH_Box2d;
+//! 3D box of double precision reals.
+typedef BVH_Box<Standard_Real, 3> BVH_Box3d;
+//! 4D box of double precision reals.
+typedef BVH_Box<Standard_Real, 4> BVH_Box4d;
+
+//! 2D box of single precision reals.
+typedef BVH_Box<Standard_ShortReal, 2> BVH_Box2f;
+//! 3D box of single precision reals.
+typedef BVH_Box<Standard_ShortReal, 3> BVH_Box3f;
+//! 4D box of single precision reals.
+typedef BVH_Box<Standard_ShortReal, 4> BVH_Box4f;
+
 #endif // _BVH_Box_Header
index 73b97433689712512b8da9dc8b043ff882498b92..82efc597bd94ad3ce203b05404563238e7bb0b55 100644 (file)
@@ -351,6 +351,15 @@ public:
     return NCollection_Vec3 (Element_t(0), Element_t(0), Element_t(1));
   }
 
+  //! Convert the vector.
+  template<class T>
+  NCollection_Vec3<T> Convert() const
+  {
+    return NCollection_Vec3<T> (static_cast<T> (v[0]),
+                                static_cast<T> (v[1]),
+                                static_cast<T> (v[2]));
+  }
+
 private:
 
   Element_t v[3]; //!< define the vector as array to avoid structure alignment issues
index a41b111f609d99f22c34f5cfaa786465e088674c..acd44db4a7051013291b1565035c2dd2d9b9f430 100644 (file)
@@ -284,6 +284,12 @@ public:
   Standard_EXPORT static Standard_Boolean CheckExtension (const char* theExtString,
                                                           const char* theExtName);
 
+  //! Returns true if hardware supports floating-point texture.
+  bool HasFloatingPointTexture()
+  {
+    return (IsGlGreaterEqual (3, 0) || CheckExtension ("GL_ARB_texture_float"));
+  }
+
   //! Auxiliary template to retrieve GL function pointer.
   //! Pointer to function retrieved from library is statically casted
   //! to requested type - there no way to check real signature of exported function.
index 7511909d6081aaf788fddc5e277f482a9accd60c..9b36091df14aa693279cfab42668fadabe47483c 100644 (file)
@@ -186,7 +186,7 @@ bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx,
     {
       if (theCtx->core11 == NULL)
       {
-        theTextFormat  = GL_R8;  // GL_R32F
+        theTextFormat  = GL_R32F;
         thePixelFormat = GL_RED;
       }
       else
@@ -201,7 +201,7 @@ bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx,
     {
       if (theCtx->core11 == NULL)
       {
-        theTextFormat  = GL_R8;  // GL_R32F
+        theTextFormat  = GL_R32F;
         thePixelFormat = GL_RED;
       }
       else
@@ -214,7 +214,7 @@ bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx,
     }
     case Image_PixMap::ImgRGBAF:
     {
-      theTextFormat  = GL_RGBA8; // GL_RGBA32F
+      theTextFormat  = GL_RGBA32F;
       thePixelFormat = GL_RGBA;
       theDataType    = GL_FLOAT;
       return true;
@@ -225,14 +225,14 @@ bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx,
       {
         return false;
       }
-      theTextFormat  = GL_RGBA8;    // GL_RGBA32F
+      theTextFormat  = GL_RGBA32F;
       thePixelFormat = GL_BGRA_EXT; // equals to GL_BGRA
       theDataType    = GL_FLOAT;
       return true;
     }
     case Image_PixMap::ImgRGBF:
     {
-      theTextFormat  = GL_RGB8; // GL_RGB32F
+      theTextFormat  = GL_RGB32F;
       thePixelFormat = GL_RGB;
       theDataType    = GL_FLOAT;
       return true;
@@ -240,7 +240,7 @@ bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx,
     case Image_PixMap::ImgBGRF:
     {
     #if !defined(GL_ES_VERSION_2_0)
-      theTextFormat  = GL_RGB8; // GL_RGB32F
+      theTextFormat  = GL_RGB32F;
       thePixelFormat = GL_BGR;  // equals to GL_BGR_EXT
       theDataType    = GL_FLOAT;
       return true;
@@ -376,6 +376,19 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
   myHasMipmaps             = Standard_False;
   myTextFormat             = thePixelFormat;
 #if !defined(GL_ES_VERSION_2_0)
+  if (theTextFormat >= Image_PixMap::ImgGrayF
+   && !theCtx->HasFloatingPointTexture())
+  {
+    TCollection_ExtendedString aMsg ("Error: floating-point textures are not supproted by hardware.");
+    theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION,
+                         GL_DEBUG_TYPE_ERROR,
+                         0,
+                         GL_DEBUG_SEVERITY_HIGH,
+                         aMsg);
+
+    Release (theCtx.operator->());
+    return false;
+  }
   const GLint anIntFormat  = theTextFormat;
 #else
   // ES does not support sized formats and format conversions - them detected from data type
@@ -477,7 +490,7 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
       glTexImage1D (GL_PROXY_TEXTURE_1D, 0, anIntFormat,
                     aWidth, 0,
                     thePixelFormat, theDataType, NULL);
-      glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &aTestWidth);
+      glGetTexLevelParameteriv (GL_PROXY_TEXTURE_1D, 0, GL_TEXTURE_WIDTH, &aTestWidth);
       if (aTestWidth == 0)
       {
         // no memory or broken input parameters
@@ -747,6 +760,22 @@ bool OpenGl_Texture::InitRectangle (const Handle(OpenGl_Context)& theCtx,
   const GLint anIntFormat = theFormat.Internal();
   myTextFormat = theFormat.Format();
 
+  if (anIntFormat == GL_FLOAT
+   || !theCtx->HasFloatingPointTexture())
+  {
+    TCollection_ExtendedString aMsg ("Error: floating-point textures are not supproted by hardware.");
+
+    theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION_ARB,
+                         GL_DEBUG_TYPE_ERROR_ARB,
+                         0,
+                         GL_DEBUG_SEVERITY_HIGH_ARB,
+                         aMsg);
+
+    Release (theCtx.operator->());
+    Unbind (theCtx);
+    return false;
+  }
+
   glTexImage2D (GL_PROXY_TEXTURE_RECTANGLE,
                 0,
                 anIntFormat,
index 6dd9f62c3d525bb7a846bbd61dda88032f138e04..e8af5db3d2ab9df1358983d4b54dbd946152b580 100644 (file)
   #define THE_SHADER_IN  in
   #define THE_SHADER_OUT out
   #define THE_OUT        out
+  #define occTexture1D   texture
   #define occTexture2D   texture
+  #define occTexture3D   texture
 #else
   #define THE_ATTRIBUTE  attribute
   #define THE_SHADER_IN  varying
   #define THE_SHADER_OUT varying
   #define THE_OUT
+  #define occTexture1D   texture1D
   #define occTexture2D   texture2D
+  #define occTexture3D   texture3D
 #endif
 
 #ifdef GL_ES
   THE_ATTRIBUTE vec4 occTexCoord;
   THE_ATTRIBUTE vec4 occVertColor;
 #elif (__VERSION__ >= 130)
-  out vec4 occFragColor;
+  out vec4  occFragColor;
+  out float occFragDepth;
 #else
   #define occFragColor gl_FragColor
+  #define occFragDepth gl_FragDepth
 #endif
 
 // Matrix state