mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-08 14:17:06 +03:00
0032841: Visualization - add 16-bit grayscale pixel format to Image_PixMap
Added Image_Format_Gray16 pixel format definition, which could be uploaded into GL_R16 texture. Added Image_Format_GrayF_half mapped to GL_R16F texture.
This commit is contained in:
@@ -176,6 +176,7 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
|
||||
extDrawBuffers (Standard_False),
|
||||
extGS (NULL),
|
||||
extBgra(Standard_False),
|
||||
extTexR16(Standard_False),
|
||||
extAnis(Standard_False),
|
||||
extPDS (Standard_False),
|
||||
atiMem (Standard_False),
|
||||
@@ -1552,6 +1553,10 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
|
||||
mySupportedFormats->Add (Image_Format_BGR32);
|
||||
mySupportedFormats->Add (Image_Format_BGRA);
|
||||
}
|
||||
if (extTexR16)
|
||||
{
|
||||
mySupportedFormats->Add (Image_Format_Gray16);
|
||||
}
|
||||
if (arbTexFloat)
|
||||
{
|
||||
mySupportedFormats->Add (Image_Format_GrayF);
|
||||
@@ -1567,6 +1572,7 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
|
||||
mySupportedFormats->Add (Image_Format_RGF);
|
||||
if (hasHalfFloatBuffer != OpenGl_FeatureNotAvailable)
|
||||
{
|
||||
mySupportedFormats->Add (Image_Format_GrayF_half);
|
||||
mySupportedFormats->Add (Image_Format_RGF_half);
|
||||
}
|
||||
}
|
||||
|
@@ -1069,6 +1069,7 @@ public: //! @name extensions
|
||||
Standard_Boolean extDrawBuffers; //!< GL_EXT_draw_buffers
|
||||
OpenGl_ExtGS* extGS; //!< GL_EXT_geometry_shader4
|
||||
Standard_Boolean extBgra; //!< GL_EXT_bgra or GL_EXT_texture_format_BGRA8888 on OpenGL ES
|
||||
Standard_Boolean extTexR16; //!< GL_EXT_texture_norm16 on OpenGL ES; always available on desktop
|
||||
Standard_Boolean extAnis; //!< GL_EXT_texture_filter_anisotropic
|
||||
Standard_Boolean extPDS; //!< GL_EXT_packed_depth_stencil
|
||||
Standard_Boolean atiMem; //!< GL_ATI_meminfo
|
||||
|
@@ -983,6 +983,17 @@ Standard_Boolean OpenGl_FrameBuffer::BufferDump (const Handle(OpenGl_Context)& t
|
||||
aType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
}
|
||||
case Image_Format_Gray16:
|
||||
{
|
||||
if (theGlCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
aFormat = theBufferType == Graphic3d_BT_Depth ? GL_DEPTH_COMPONENT : GL_RED;
|
||||
aType = GL_UNSIGNED_SHORT;
|
||||
break;
|
||||
}
|
||||
case Image_Format_GrayF:
|
||||
{
|
||||
if (theGlCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
|
||||
@@ -1090,6 +1101,7 @@ Standard_Boolean OpenGl_FrameBuffer::BufferDump (const Handle(OpenGl_Context)& t
|
||||
case Image_Format_Alpha:
|
||||
case Image_Format_AlphaF:
|
||||
return Standard_False; // GL_ALPHA is no more supported in core context
|
||||
case Image_Format_GrayF_half:
|
||||
case Image_Format_RGF_half:
|
||||
case Image_Format_UNKNOWN:
|
||||
return Standard_False;
|
||||
|
@@ -1733,6 +1733,7 @@ void OpenGl_GlFunctions::load (OpenGl_Context& theCtx,
|
||||
theCtx.arbTexRG = isGlGreaterEqualShort (3, 0)
|
||||
|| checkExtensionShort ("GL_EXT_texture_rg");
|
||||
theCtx.extBgra = checkExtensionShort ("GL_EXT_texture_format_BGRA8888");
|
||||
theCtx.extTexR16 = checkExtensionShort ("GL_EXT_texture_norm16");
|
||||
theCtx.extAnis = checkExtensionShort ("GL_EXT_texture_filter_anisotropic");
|
||||
theCtx.extPDS = isGlGreaterEqualShort (3, 0)
|
||||
|| checkExtensionShort ("GL_OES_packed_depth_stencil");
|
||||
@@ -2160,6 +2161,7 @@ void OpenGl_GlFunctions::load (OpenGl_Context& theCtx,
|
||||
|| checkExtensionShort ("NV_depth_clamp");
|
||||
theCtx.extBgra = isGlGreaterEqualShort (1, 2)
|
||||
|| checkExtensionShort ("GL_EXT_bgra");
|
||||
theCtx.extTexR16 = true;
|
||||
theCtx.extAnis = checkExtensionShort ("GL_EXT_texture_filter_anisotropic");
|
||||
theCtx.extPDS = checkExtensionShort ("GL_EXT_packed_depth_stencil");
|
||||
theCtx.atiMem = checkExtensionShort ("GL_ATI_meminfo");
|
||||
|
@@ -333,6 +333,9 @@ typedef double GLclampd;
|
||||
#define GL_RGB8 0x8051
|
||||
#define GL_RGBA8 0x8058
|
||||
|
||||
// only in desktop OpenGL
|
||||
#define GL_LUMINANCE16 0x8042
|
||||
|
||||
// in core since OpenGL ES 3.0, extension GL_OES_rgb8_rgba8
|
||||
#define GL_LUMINANCE8 0x8040
|
||||
// GL_EXT_texture_format_BGRA8888
|
||||
|
@@ -72,6 +72,7 @@ TCollection_AsciiString OpenGl_TextureFormat::FormatFormat (GLint theInternalFor
|
||||
case 0x803C: return "GL_ALPHA8";
|
||||
case 0x803E: return "GL_ALPHA16";
|
||||
case GL_LUMINANCE: return "GL_LUMINANCE";
|
||||
case GL_LUMINANCE16: return "GL_LUMINANCE16";
|
||||
case GL_LUMINANCE_ALPHA: return "GL_LUMINANCE_ALPHA";
|
||||
//
|
||||
case GL_DEPTH_COMPONENT: return "GL_DEPTH_COMPONENT";
|
||||
@@ -219,6 +220,19 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
|
||||
aFormat.SetDataType (GL_FLOAT);
|
||||
return aFormat;
|
||||
}
|
||||
case Image_Format_GrayF_half:
|
||||
{
|
||||
aFormat.SetNbComponents (1);
|
||||
aFormat.SetInternalFormat (GL_R16F);
|
||||
aFormat.SetPixelFormat (GL_RED);
|
||||
aFormat.SetDataType (GL_HALF_FLOAT);
|
||||
if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions
|
||||
&& theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
|
||||
{
|
||||
aFormat.SetDataType (GL_HALF_FLOAT_OES);
|
||||
}
|
||||
return aFormat;
|
||||
}
|
||||
case Image_Format_RGF_half:
|
||||
{
|
||||
aFormat.SetNbComponents (2);
|
||||
@@ -443,6 +457,28 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
|
||||
aFormat.SetDataType (GL_UNSIGNED_BYTE);
|
||||
return aFormat;
|
||||
}
|
||||
case Image_Format_Gray16:
|
||||
{
|
||||
if (!theCtx->extTexR16)
|
||||
{
|
||||
return OpenGl_TextureFormat();
|
||||
}
|
||||
|
||||
aFormat.SetNbComponents (1);
|
||||
if (useRedRedAlpha
|
||||
|| theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
|
||||
{
|
||||
aFormat.SetInternalFormat (GL_R16);
|
||||
aFormat.SetPixelFormat (GL_RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
aFormat.SetInternalFormat (GL_LUMINANCE16);
|
||||
aFormat.SetPixelFormat (GL_LUMINANCE);
|
||||
}
|
||||
aFormat.SetDataType (GL_UNSIGNED_SHORT);
|
||||
return aFormat;
|
||||
}
|
||||
case Image_Format_UNKNOWN:
|
||||
{
|
||||
return OpenGl_TextureFormat();
|
||||
@@ -509,7 +545,7 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindSizedFormat (const Handle(OpenGl_
|
||||
aFormat.SetInternalFormat (theSizedFormat);
|
||||
aFormat.SetPixelFormat (GL_RED);
|
||||
aFormat.SetDataType (GL_HALF_FLOAT);
|
||||
aFormat.SetImageFormat (Image_Format_GrayF);
|
||||
aFormat.SetImageFormat (Image_Format_GrayF_half);
|
||||
if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions)
|
||||
{
|
||||
aFormat.SetDataType (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
|
||||
|
Reference in New Issue
Block a user