myGlD3dDevice (NULL),
myGlD3dSurf (NULL),
myLockCount (0),
- myD3dFallback (Standard_False)
+ myD3dFallback (Standard_False),
+ myIsSRGBReady (Standard_False)
{
//
}
}
OpenGl_FrameBuffer::BindBuffer (theCtx);
+ theCtx->SetFrameBufferSRGB (true, myIsSRGBReady);
if (myD3dFallback)
{
return;
//! Returns TRUE if FBO has been initialized without WGL/D3D interop.
Standard_Boolean D3dFallback() const { return myD3dFallback; }
+ //! Returns TRUE if color buffer is sRGB ready; FALSE by default.
+ //! Requires D3DSAMP_SRGBTEXTURE sampler parameter being set on D3D level for rendering D3D surface.
+ Standard_Boolean IsSRGBReady() const { return myIsSRGBReady; }
+
+ //! Set if color buffer is sRGB ready.
+ void SetSRGBReady (Standard_Boolean theIsReady) { myIsSRGBReady = theIsReady; }
+
protected:
using OpenGl_FrameBuffer::Init;
void* myGlD3dSurf; //!< WGL/D3D surface handle
Standard_Integer myLockCount; //!< locking counter
Standard_Boolean myD3dFallback; //!< indicates that FBO has been initialized without WGL/D3D interop
+ Standard_Boolean myIsSRGBReady; //!< indicates that color buffer is sRGB ready
public:
// function : SetFrameBufferSRGB
// purpose :
// =======================================================================
-void OpenGl_Context::SetFrameBufferSRGB (bool theIsFbo)
+void OpenGl_Context::SetFrameBufferSRGB (bool theIsFbo, bool theIsFboSRgb)
{
if (!hasFboSRGB)
{
return;
}
myIsSRgbActive = ToRenderSRGB()
- && (theIsFbo || myIsSRgbWindow);
+ && (theIsFbo || myIsSRgbWindow)
+ && theIsFboSRgb;
if (!hasSRGBControl)
{
return;
//! (GL_FRAMEBUFFER_SRGB can be considered as always tuned ON).
bool IsWindowSRGB() const { return myIsSRgbWindow; }
+ //! Overrides if window/surface buffer is sRGB-ready or not (initialized with the context).
+ void SetWindowSRGB (bool theIsSRgb) { myIsSRgbWindow = theIsSRgb; }
+
//! Convert Quantity_ColorRGBA into vec4
//! with conversion or no conversion into non-linear sRGB
//! basing on ToRenderSRGB() flag.
//! - FALSE if sRGB rendering is not supported or sRGB-not-ready window buffer is used for drawing.
//! @param theIsFbo [in] flag indicating writing into offscreen FBO (always expected sRGB-ready when sRGB FBO is supported)
//! or into window buffer (FALSE, sRGB-readiness might vary).
- Standard_EXPORT void SetFrameBufferSRGB (bool theIsFbo);
+ //! @param theIsSRgb [in] flag indicating off-screen FBO is sRGB-ready
+ Standard_EXPORT void SetFrameBufferSRGB (bool theIsFbo, bool theIsFboSRgb = true);
//! Return cached flag indicating writing into color buffer is enabled or disabled (glColorMask).
bool ColorMask() const { return myColorMask; }