From: isk Date: Wed, 10 Feb 2016 08:29:00 +0000 (+0300) Subject: 0025464: Visualization - provide package for Volume Rendering. X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=dc834db34cdfa85e9299913d5778520eb73c1a7e;p=occt-copy.git 0025464: Visualization - provide package for Volume Rendering. 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. --- diff --git a/src/BVH/BVH_Box.hxx b/src/BVH/BVH_Box.hxx index 838fb90352..e0755db224 100644 --- a/src/BVH/BVH_Box.hxx +++ b/src/BVH/BVH_Box.hxx @@ -281,4 +281,18 @@ namespace BVH #include +//! 2D box of double precision reals. +typedef BVH_Box BVH_Box2d; +//! 3D box of double precision reals. +typedef BVH_Box BVH_Box3d; +//! 4D box of double precision reals. +typedef BVH_Box BVH_Box4d; + +//! 2D box of single precision reals. +typedef BVH_Box BVH_Box2f; +//! 3D box of single precision reals. +typedef BVH_Box BVH_Box3f; +//! 4D box of single precision reals. +typedef BVH_Box BVH_Box4f; + #endif // _BVH_Box_Header diff --git a/src/NCollection/NCollection_Vec3.hxx b/src/NCollection/NCollection_Vec3.hxx index 73b9743368..82efc597bd 100644 --- a/src/NCollection/NCollection_Vec3.hxx +++ b/src/NCollection/NCollection_Vec3.hxx @@ -351,6 +351,15 @@ public: return NCollection_Vec3 (Element_t(0), Element_t(0), Element_t(1)); } + //! Convert the vector. + template + NCollection_Vec3 Convert() const + { + return NCollection_Vec3 (static_cast (v[0]), + static_cast (v[1]), + static_cast (v[2])); + } + private: Element_t v[3]; //!< define the vector as array to avoid structure alignment issues diff --git a/src/OpenGl/OpenGl_Context.hxx b/src/OpenGl/OpenGl_Context.hxx index a41b111f60..acd44db4a7 100644 --- a/src/OpenGl/OpenGl_Context.hxx +++ b/src/OpenGl/OpenGl_Context.hxx @@ -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. diff --git a/src/OpenGl/OpenGl_Texture.cxx b/src/OpenGl/OpenGl_Texture.cxx index 7511909d60..9b36091df1 100644 --- a/src/OpenGl/OpenGl_Texture.cxx +++ b/src/OpenGl/OpenGl_Texture.cxx @@ -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, diff --git a/src/Shaders/Declarations.glsl b/src/Shaders/Declarations.glsl index 6dd9f62c3d..e8af5db3d2 100644 --- a/src/Shaders/Declarations.glsl +++ b/src/Shaders/Declarations.glsl @@ -24,13 +24,17 @@ #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 @@ -46,9 +50,11 @@ 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