1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

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.
This commit is contained in:
isk
2016-02-10 11:29:00 +03:00
committed by duv
parent a4c29e8425
commit dc834db34c
5 changed files with 72 additions and 8 deletions

View 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

View 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

View 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.

View 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,

View File

@@ -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