1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0031405: Advanced wrappers, C# wrapper - dark colors in WPF sample

D3DHost_FrameBuffer::IsSRGBReady() - added new propery defining if
D3D application handles FBO as sRGB-ready texture or not.
This commit is contained in:
kgv 2020-03-04 17:32:44 +03:00 committed by bugmaster
parent fffc249f21
commit e5c11edd7b
4 changed files with 19 additions and 4 deletions

View File

@ -34,7 +34,8 @@ D3DHost_FrameBuffer::D3DHost_FrameBuffer()
myGlD3dDevice (NULL),
myGlD3dSurf (NULL),
myLockCount (0),
myD3dFallback (Standard_False)
myD3dFallback (Standard_False),
myIsSRGBReady (Standard_False)
{
//
}
@ -277,6 +278,7 @@ void D3DHost_FrameBuffer::BindBuffer (const Handle(OpenGl_Context)& theCtx)
}
OpenGl_FrameBuffer::BindBuffer (theCtx);
theCtx->SetFrameBufferSRGB (true, myIsSRGBReady);
if (myD3dFallback)
{
return;

View File

@ -103,6 +103,13 @@ public:
//! 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;
@ -115,6 +122,7 @@ protected:
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:

View File

@ -517,7 +517,7 @@ void OpenGl_Context::SetDrawBuffers (const Standard_Integer theNb, const Standar
// function : SetFrameBufferSRGB
// purpose :
// =======================================================================
void OpenGl_Context::SetFrameBufferSRGB (bool theIsFbo)
void OpenGl_Context::SetFrameBufferSRGB (bool theIsFbo, bool theIsFboSRgb)
{
if (!hasFboSRGB)
{
@ -525,7 +525,8 @@ void OpenGl_Context::SetFrameBufferSRGB (bool theIsFbo)
return;
}
myIsSRgbActive = ToRenderSRGB()
&& (theIsFbo || myIsSRgbWindow);
&& (theIsFbo || myIsSRgbWindow)
&& theIsFboSRgb;
if (!hasSRGBControl)
{
return;

View File

@ -584,6 +584,9 @@ public:
//! (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.
@ -794,7 +797,8 @@ public: //! @name methods to alter or retrieve current state
//! - 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; }