CheckEnumerationProperty< DepthFunction::Type >( renderer, Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS, DepthFunction::ALWAYS, DepthFunction::GREATER, "GREATER" );
CheckEnumerationProperty< DepthTestMode::Type >( renderer, Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO, DepthTestMode::OFF, DepthTestMode::ON, "ON" );
CheckEnumerationProperty< StencilFunction::Type >( renderer, Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS, StencilFunction::LESS, StencilFunction::EQUAL, "EQUAL" );
- CheckEnumerationProperty< RenderMode::Type >( renderer, Renderer::Property::RENDER_MODE, RenderMode::AUTO, RenderMode::NONE, RenderMode::STENCIL, "STENCIL" );
+ CheckEnumerationProperty< StencilMode::Type >( renderer, Renderer::Property::STENCIL_MODE, StencilMode::AUTO, StencilMode::OFF, StencilMode::ON, "ON" );
CheckEnumerationProperty< StencilOperation::Type >( renderer, Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
CheckEnumerationProperty< StencilOperation::Type >( renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
CheckEnumerationProperty< StencilOperation::Type >( renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
END_TEST;
}
-int UtcDaliRendererSetRenderModeToUseStencilBuffer(void)
+int UtcDaliRendererSetStencilMode(void)
{
TestApplication application;
- tet_infoline("Test setting the RenderMode to use the stencil buffer");
+ tet_infoline("Test setting the StencilMode");
Renderer renderer = RendererTestFixture( application );
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
- // Set the StencilFunction to something other than the default, to confirm it is set as a property,
- // but NO GL call has been made while the RenderMode is set to not use the stencil buffer.
- renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::NONE );
ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
+ // Set the StencilFunction to something other than the default, to confirm it is set as a property,
+ // but NO GL call has been made while the StencilMode is set to OFF.
renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, StencilFunction::NEVER );
DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get<int>() ), static_cast<int>( StencilFunction::NEVER ), TEST_LOCATION );
-
- ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
- std::string methodString( "StencilFunc" );
- DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
-
- // Test the other RenderModes that will not enable the stencil buffer.
- renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::AUTO );
ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
- DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
- renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
- ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
+ std::string methodString( "StencilFunc" );
DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
- // Now set the RenderMode to modes that will use the stencil buffer, and check the StencilFunction has changed.
- renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
- ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
-
- DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetStencilTestString() ) );
- DALI_TEST_CHECK( glStencilFunctionStack.FindMethod( methodString ) );
-
- // Test the COLOR_STENCIL RenderMode as it also enables the stencil buffer.
- renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR_STENCIL );
+ // Now set the StencilMode to ON and check the StencilFunction has changed.
+ renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON );
ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetStencilTestString() ) );
END_TEST;
}
-// Helper function for the SetRenderModeToUseColorBuffer test.
-void CheckRenderModeColorMask( TestApplication& application, Renderer& renderer, RenderMode::Type renderMode, bool expectedValue )
-{
- // Set the RenderMode property to a value that should not allow color buffer writes.
- renderer.SetProperty( Renderer::Property::RENDER_MODE, renderMode );
- application.SendNotification();
- application.Render();
-
- // Check if ColorMask has been called, and that the values are correct.
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- const TestGlAbstraction::ColorMaskParams& colorMaskParams( glAbstraction.GetColorMaskParams() );
-
- DALI_TEST_EQUALS<bool>( colorMaskParams.red, expectedValue, TEST_LOCATION );
- DALI_TEST_EQUALS<bool>( colorMaskParams.green, expectedValue, TEST_LOCATION );
- DALI_TEST_EQUALS<bool>( colorMaskParams.blue, expectedValue, TEST_LOCATION );
- DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, expectedValue, TEST_LOCATION );
-}
-
-int UtcDaliRendererSetRenderModeToUseColorBuffer(void)
-{
- TestApplication application;
- tet_infoline("Test setting the RenderMode to use the color buffer");
-
- Renderer renderer = RendererTestFixture( application );
-
- // Set the RenderMode property to a value that should not allow color buffer writes.
- // Then check if ColorMask has been called, and that the values are correct.
- CheckRenderModeColorMask( application, renderer, RenderMode::AUTO, true );
- CheckRenderModeColorMask( application, renderer, RenderMode::NONE, false );
- CheckRenderModeColorMask( application, renderer, RenderMode::COLOR, true );
- CheckRenderModeColorMask( application, renderer, RenderMode::STENCIL, false );
- CheckRenderModeColorMask( application, renderer, RenderMode::COLOR_STENCIL, true );
-
- END_TEST;
-}
-
int UtcDaliRendererSetStencilFunction(void)
{
TestApplication application;
TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
- // RenderMode must use the stencil for StencilFunction to operate.
- renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
+ // StencilMode must be ON for StencilFunction to operate.
+ renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON );
ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
/*
TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
- // RenderMode must use the stencil for StencilOperation to operate.
- renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
+ // StencilMode must be ON for StencilOperation to operate.
+ renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON );
/*
* Lookup table for testing StencilOperation.
TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
- // RenderMode must use the stencil for StencilMask to operate.
- renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
+ // StencilMode must be ON for StencilMask to operate.
+ renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON );
// Set the StencilMask property to a value.
renderer.SetProperty( Renderer::Property::STENCIL_MASK, 0x00 );
END_TEST;
}
+
+int UtcDaliRendererSetWriteToColorBuffer(void)
+{
+ TestApplication application;
+ tet_infoline("Test setting the WriteToColorBuffer flag");
+
+ Renderer renderer = RendererTestFixture( application );
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+
+ // Set the StencilMask property to a value.
+ renderer.SetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER, false );
+
+ // Check GetProperty returns the same value.
+ DALI_TEST_CHECK( !renderer.GetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER ).Get<bool>() );
+
+ application.SendNotification();
+ application.Render();
+
+ // Check if ColorMask has been called, and that the values are correct.
+ const TestGlAbstraction::ColorMaskParams& colorMaskParams( glAbstraction.GetColorMaskParams() );
+
+ DALI_TEST_EQUALS<bool>( colorMaskParams.red, false, TEST_LOCATION );
+ DALI_TEST_EQUALS<bool>( colorMaskParams.green, false, TEST_LOCATION );
+ DALI_TEST_EQUALS<bool>( colorMaskParams.blue, false, TEST_LOCATION );
+ DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, false, TEST_LOCATION );
+
+ // Set the StencilMask property to true.
+ renderer.SetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER, true );
+
+ // Check GetProperty returns the same value.
+ DALI_TEST_CHECK( renderer.GetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER ).Get<bool>() );
+
+ application.SendNotification();
+ application.Render();
+
+ // Check if ColorMask has been called, and that the values are correct.
+ const TestGlAbstraction::ColorMaskParams& colorMaskParamsChanged( glAbstraction.GetColorMaskParams() );
+
+ DALI_TEST_EQUALS<bool>( colorMaskParamsChanged.red, true, TEST_LOCATION );
+ DALI_TEST_EQUALS<bool>( colorMaskParamsChanged.green, true, TEST_LOCATION );
+ DALI_TEST_EQUALS<bool>( colorMaskParamsChanged.blue, true, TEST_LOCATION );
+ DALI_TEST_EQUALS<bool>( colorMaskParamsChanged.alpha, true, TEST_LOCATION );
+
+ END_TEST;
+}
template <> struct ParameterType< Dali::DepthWriteMode::Type > : public BasicType< Dali::DepthWriteMode::Type > {};
template <> struct ParameterType< Dali::DepthTestMode::Type > : public BasicType< Dali::DepthTestMode::Type > {};
template <> struct ParameterType< Dali::DepthFunction::Type > : public BasicType< Dali::DepthFunction::Type > {};
-template <> struct ParameterType< Dali::RenderMode::Type > : public BasicType< Dali::RenderMode::Type > {};
+template <> struct ParameterType< Dali::StencilMode::Type > : public BasicType< Dali::StencilMode::Type > {};
template <> struct ParameterType< Dali::StencilFunction::Type > : public BasicType< Dali::StencilFunction::Type > {};
template <> struct ParameterType< Dali::StencilOperation::Type > : public BasicType< Dali::StencilOperation::Type > {};
DALI_PROPERTY( "depthWriteMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_WRITE_MODE )
DALI_PROPERTY( "depthFunction", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_FUNCTION )
DALI_PROPERTY( "depthTestMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_TEST_MODE )
-DALI_PROPERTY( "renderMode", INTEGER, true, false, false, Dali::Renderer::Property::RENDER_MODE )
DALI_PROPERTY( "stencilFunction", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION )
DALI_PROPERTY( "stencilFunctionMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_MASK )
DALI_PROPERTY( "stencilFunctionReference", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE )
DALI_PROPERTY( "stencilMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_MASK )
+DALI_PROPERTY( "stencilMode", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_MODE )
DALI_PROPERTY( "stencilOperationOnFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL )
DALI_PROPERTY( "stencilOperationOnZFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL )
DALI_PROPERTY( "stencilOperationOnZPass", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS )
+DALI_PROPERTY( "writeToColorBuffer", BOOLEAN, true, false, false, Dali::Renderer::Property::WRITE_TO_COLOR_BUFFER )
DALI_PROPERTY_TABLE_END( DEFAULT_RENDERER_PROPERTY_START_INDEX )
// Property string to enumeration tables:
DALI_ENUM_TO_STRING_WITH_SCOPE( StencilFunction, ALWAYS )
DALI_ENUM_TO_STRING_TABLE_END( STENCIL_FUNCTION )
-DALI_ENUM_TO_STRING_TABLE_BEGIN( RENDER_MODE )
-DALI_ENUM_TO_STRING_WITH_SCOPE( RenderMode, NONE )
-DALI_ENUM_TO_STRING_WITH_SCOPE( RenderMode, AUTO )
-DALI_ENUM_TO_STRING_WITH_SCOPE( RenderMode, COLOR )
-DALI_ENUM_TO_STRING_WITH_SCOPE( RenderMode, STENCIL )
-DALI_ENUM_TO_STRING_WITH_SCOPE( RenderMode, COLOR_STENCIL )
-DALI_ENUM_TO_STRING_TABLE_END( RENDER_MODE )
+DALI_ENUM_TO_STRING_TABLE_BEGIN( STENCIL_MODE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( StencilMode, OFF )
+DALI_ENUM_TO_STRING_WITH_SCOPE( StencilMode, AUTO )
+DALI_ENUM_TO_STRING_WITH_SCOPE( StencilMode, ON )
+DALI_ENUM_TO_STRING_TABLE_END( STENCIL_MODE )
DALI_ENUM_TO_STRING_TABLE_BEGIN( STENCIL_OPERATION )
DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, ZERO )
}
break;
}
- case Dali::Renderer::Property::RENDER_MODE:
+ case Dali::Renderer::Property::STENCIL_MODE:
{
- RenderMode::Type convertedValue = mStencilParameters.renderMode;
- if( Scripting::GetEnumerationProperty< RenderMode::Type >( propertyValue, RENDER_MODE_TABLE, RENDER_MODE_TABLE_COUNT, convertedValue ) )
+ StencilMode::Type convertedValue = mStencilParameters.stencilMode;
+ if( Scripting::GetEnumerationProperty< StencilMode::Type >( propertyValue, STENCIL_MODE_TABLE, STENCIL_MODE_TABLE_COUNT, convertedValue ) )
{
- mStencilParameters.renderMode = convertedValue;
- SetRenderModeMessage( GetEventThreadServices(), *mSceneObject, convertedValue );
+ mStencilParameters.stencilMode = convertedValue;
+ SetStencilModeMessage( GetEventThreadServices(), *mSceneObject, convertedValue );
}
break;
}
}
break;
}
+ case Dali::Renderer::Property::WRITE_TO_COLOR_BUFFER:
+ {
+ bool writeToColorBuffer;
+ if( propertyValue.Get( writeToColorBuffer ) )
+ {
+ if( mWriteToColorBuffer != writeToColorBuffer )
+ {
+ mWriteToColorBuffer = writeToColorBuffer;
+ SetWriteToColorBufferMessage( GetEventThreadServices(), *mSceneObject, writeToColorBuffer );
+ }
+ }
+ break;
+ }
}
}
value = mStencilParameters.stencilMask;
break;
}
- case Dali::Renderer::Property::RENDER_MODE:
+ case Dali::Renderer::Property::STENCIL_MODE:
{
- value = mStencilParameters.renderMode;
+ value = mStencilParameters.stencilMode;
break;
}
case Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL:
value = mStencilParameters.stencilOperationOnZPass;
break;
}
+ case Dali::Renderer::Property::WRITE_TO_COLOR_BUFFER:
+ {
+ value = mWriteToColorBuffer;
+ break;
+ }
}
return value;
}
mOnStageCount( 0 ),
mIndexedDrawFirstElement( 0 ),
mIndexedDrawElementCount( 0 ),
- mStencilParameters( RenderMode::AUTO, StencilFunction::ALWAYS, 0xFF, 0x00, 0xFF, StencilOperation::KEEP, StencilOperation::KEEP, StencilOperation::KEEP ),
+ mStencilParameters( StencilMode::AUTO, StencilFunction::ALWAYS, 0xFF, 0x00, 0xFF, StencilOperation::KEEP, StencilOperation::KEEP, StencilOperation::KEEP ),
mBlendingOptions(),
mDepthFunction( DepthFunction::LESS ),
mFaceCullingMode( FaceCullingMode::NONE ),
mBlendMode( BlendMode::AUTO ),
mDepthWriteMode( DepthWriteMode::AUTO ),
mDepthTestMode( DepthTestMode::AUTO ),
+ mWriteToColorBuffer( true ),
mPremultipledAlphaEnabled( false )
{
}
BlendMode::Type mBlendMode:2; ///< Local copy of the mode of blending
DepthWriteMode::Type mDepthWriteMode:2; ///< Local copy of the depth write mode
DepthTestMode::Type mDepthTestMode:2; ///< Local copy of the depth test mode
+ bool mWriteToColorBuffer:1; ///< Local copy of the write to color buffer flag
bool mPremultipledAlphaEnabled:1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
};
// Setup the color buffer based on the renderers properties.
Renderer *renderer = item.mRenderer;
- RenderMode::Type renderMode = renderer->GetRenderMode();
- const bool writeToColorBuffer = ( renderMode == RenderMode::AUTO ) || ( renderMode == RenderMode::COLOR ) || ( renderMode == RenderMode::COLOR_STENCIL );
- context.ColorMask( writeToColorBuffer );
+ context.ColorMask( renderer->GetWriteToColorBuffer() );
// If the stencil buffer is disabled for this renderer, exit now to save unnecessary value setting.
- if( ( renderMode != RenderMode::STENCIL ) && ( renderMode != RenderMode::COLOR_STENCIL ) )
+ if( renderer->GetStencilMode() != StencilMode::ON )
{
// No per-renderer stencil setup, exit.
context.EnableStencilBuffer( false );
DepthWriteMode::Type depthWriteMode,
DepthTestMode::Type depthTestMode,
DepthFunction::Type depthFunction,
- StencilParameters& stencilParameters )
+ StencilParameters& stencilParameters,
+ bool writeToColorBuffer )
{
return new Renderer( dataProvider, geometry, blendingBitmask, blendColor,
faceCullingMode, preMultipliedAlphaEnabled, depthWriteMode, depthTestMode,
- depthFunction, stencilParameters );
+ depthFunction, stencilParameters, writeToColorBuffer );
}
Renderer::Renderer( SceneGraph::RenderDataProvider* dataProvider,
DepthWriteMode::Type depthWriteMode,
DepthTestMode::Type depthTestMode,
DepthFunction::Type depthFunction,
- StencilParameters& stencilParameters )
+ StencilParameters& stencilParameters,
+ bool writeToColorBuffer )
: mRenderDataProvider( dataProvider ),
mContext( NULL),
mTextureCache( NULL ),
mFaceCullingMode( faceCullingMode ),
mDepthWriteMode( depthWriteMode ),
mDepthTestMode( depthTestMode ),
+ mWriteToColorBuffer( writeToColorBuffer ),
mUpdateAttributesLocation( true ),
mPremultipledAlphaEnabled( preMultipliedAlphaEnabled )
{
return mDepthFunction;
}
-void Renderer::SetRenderMode( RenderMode::Type renderMode )
+void Renderer::SetStencilMode( StencilMode::Type stencilMode )
{
- mStencilParameters.renderMode = renderMode;
+ mStencilParameters.stencilMode = stencilMode;
}
-RenderMode::Type Renderer::GetRenderMode() const
+StencilMode::Type Renderer::GetStencilMode() const
{
- return mStencilParameters.renderMode;
+ return mStencilParameters.stencilMode;
}
void Renderer::SetStencilFunction( StencilFunction::Type stencilFunction )
return mStencilParameters.stencilOperationOnZPass;
}
+void Renderer::SetWriteToColorBuffer( bool writeToColorBuffer )
+{
+ mWriteToColorBuffer = writeToColorBuffer;
+}
+
+bool Renderer::GetWriteToColorBuffer() const
+{
+ return mWriteToColorBuffer;
+}
+
void Renderer::Render( Context& context,
SceneGraph::TextureCache& textureCache,
BufferIndex bufferIndex,
*/
struct StencilParameters
{
- StencilParameters( RenderMode::Type renderMode, StencilFunction::Type stencilFunction, int stencilFunctionMask,
+ StencilParameters( StencilMode::Type stencilMode, StencilFunction::Type stencilFunction, int stencilFunctionMask,
int stencilFunctionReference, int stencilMask, StencilOperation::Type stencilOperationOnFail,
StencilOperation::Type stencilOperationOnZFail, StencilOperation::Type stencilOperationOnZPass )
: stencilFunctionMask ( stencilFunctionMask ),
stencilFunctionReference ( stencilFunctionReference ),
stencilMask ( stencilMask ),
- renderMode ( renderMode ),
stencilFunction ( stencilFunction ),
stencilOperationOnFail ( stencilOperationOnFail ),
stencilOperationOnZFail ( stencilOperationOnZFail ),
- stencilOperationOnZPass ( stencilOperationOnZPass )
+ stencilOperationOnZPass ( stencilOperationOnZPass ),
+ stencilMode ( stencilMode )
{
}
int stencilFunctionMask; ///< The stencil function mask
int stencilFunctionReference; ///< The stencil function reference
int stencilMask; ///< The stencil mask
- RenderMode::Type renderMode:3; ///< The render mode
- StencilFunction::Type stencilFunction:3; ///< The stencil function
+ StencilFunction::Type stencilFunction:3; ///< The stencil function
StencilOperation::Type stencilOperationOnFail:3; ///< The stencil operation for stencil test fail
StencilOperation::Type stencilOperationOnZFail:3; ///< The stencil operation for depth test fail
StencilOperation::Type stencilOperationOnZPass:3; ///< The stencil operation for depth test pass
+ StencilMode::Type stencilMode:2; ///< The stencil mode
};
/**
* @param[in] depthTestMode Depth buffer test mode
* @param[in] depthFunction Depth function
* @param[in] stencilParameters Struct containing all stencil related options
+ * @param[in] writeToColorBuffer Set to True to write to the color buffer
*/
static Renderer* New( SceneGraph::RenderDataProvider* dataProviders,
Render::Geometry* geometry,
DepthWriteMode::Type depthWriteMode,
DepthTestMode::Type depthTestMode,
DepthFunction::Type depthFunction,
- StencilParameters& stencilParameters );
+ StencilParameters& stencilParameters,
+ bool writeToColorBuffer );
/**
* Constructor.
* @param[in] depthTestMode Depth buffer test mode
* @param[in] depthFunction Depth function
* @param[in] stencilParameters Struct containing all stencil related options
+ * @param[in] writeToColorBuffer Set to True to write to the color buffer
*/
Renderer( SceneGraph::RenderDataProvider* dataProviders,
Render::Geometry* geometry,
DepthWriteMode::Type depthWriteMode,
DepthTestMode::Type depthTestMode,
DepthFunction::Type depthFunction,
- StencilParameters& stencilParameters );
+ StencilParameters& stencilParameters,
+ bool writeToColorBuffer );
/**
* Change the data providers of the renderer
DepthFunction::Type GetDepthFunction() const;
/**
- * Sets the render mode
- * @param[in] renderMode The render mode
+ * Sets the stencil mode
+ * @param[in] stencilMode The stencil function
*/
- void SetRenderMode( RenderMode::Type mode );
+ void SetStencilMode( StencilMode::Type stencilMode );
/**
- * Gets the render mode
- * @return The render mode
+ * Gets the stencil mode
+ * @return The stencil function
*/
- RenderMode::Type GetRenderMode() const;
+ StencilMode::Type GetStencilMode() const;
/**
* Sets the stencil function
StencilOperation::Type GetStencilOperationOnZPass() const;
/**
+ * Sets whether or not to write to the color buffer
+ * @param[in] writeToColorBuffer True to write to the color buffer
+ */
+ void SetWriteToColorBuffer( bool writeToColorBuffer );
+
+ /**
+ * Gets whether or not to write to the color buffer
+ * @return True to write to the color buffer
+ */
+ bool GetWriteToColorBuffer() const;
+
+ /**
* Called to render during RenderManager::Render().
* @param[in] context The context used for rendering
* @param[in] textureCache The texture cache used to get textures
BlendMode::Type mBlendMode:2; ///< The mode of blending
DepthWriteMode::Type mDepthWriteMode:2; ///< The depth write mode
DepthTestMode::Type mDepthTestMode:2; ///< The depth test mode
+ bool mWriteToColorBuffer:1; ///< True if we are writing to the color buffer
bool mUpdateAttributesLocation:1; ///< Indicates attribute locations have changed
bool mPremultipledAlphaEnabled:1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
};
RESEND_DEPTH_WRITE_MODE = 1 << 8,
RESEND_DEPTH_TEST_MODE = 1 << 9,
RESEND_DEPTH_FUNCTION = 1 << 10,
- RESEND_RENDER_MODE = 1 << 11,
+ RESEND_STENCIL_MODE = 1 << 11,
RESEND_STENCIL_FUNCTION = 1 << 12,
RESEND_STENCIL_FUNCTION_MASK = 1 << 13,
RESEND_STENCIL_FUNCTION_REFERENCE = 1 << 14,
RESEND_STENCIL_MASK = 1 << 15,
RESEND_STENCIL_OPERATION_ON_FAIL = 1 << 16,
RESEND_STENCIL_OPERATION_ON_Z_FAIL = 1 << 17,
- RESEND_STENCIL_OPERATION_ON_Z_PASS = 1 << 18
+ RESEND_STENCIL_OPERATION_ON_Z_PASS = 1 << 18,
+ RESEND_WRITE_TO_COLOR_BUFFER = 1 << 19
};
} // Anonymous namespace
mGeometry( NULL ),
mShader( NULL ),
mBlendColor( NULL ),
- mStencilParameters( RenderMode::AUTO, StencilFunction::ALWAYS, 0xFF, 0x00, 0xFF, StencilOperation::KEEP, StencilOperation::KEEP, StencilOperation::KEEP ),
+ mStencilParameters( StencilMode::AUTO, StencilFunction::ALWAYS, 0xFF, 0x00, 0xFF, StencilOperation::KEEP, StencilOperation::KEEP, StencilOperation::KEEP ),
mIndexedDrawFirstElement( 0u ),
mIndexedDrawElementsCount( 0u ),
mBlendBitmask( 0u ),
mBlendMode( BlendMode::AUTO ),
mDepthWriteMode( DepthWriteMode::AUTO ),
mDepthTestMode( DepthTestMode::AUTO ),
+ mWriteToColorBuffer( true ),
mResourcesReady( false ),
mFinishedResourceAcquisition( false ),
mPremultipledAlphaEnabled( false ),
new (slot) DerivedType( mRenderer, &Render::Renderer::SetDepthFunction, mDepthFunction );
}
- if( mResendFlag & RESEND_RENDER_MODE )
+ if( mResendFlag & RESEND_STENCIL_MODE )
{
- typedef MessageValue1< Render::Renderer, RenderMode::Type > DerivedType;
+ typedef MessageValue1< Render::Renderer, StencilMode::Type > DerivedType;
unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetRenderMode, mStencilParameters.renderMode );
+ new (slot) DerivedType( mRenderer, &Render::Renderer::SetStencilMode, mStencilParameters.stencilMode );
}
if( mResendFlag & RESEND_STENCIL_FUNCTION )
new (slot) DerivedType( mRenderer, &Render::Renderer::SetStencilOperationOnZPass, mStencilParameters.stencilOperationOnZPass );
}
+ if( mResendFlag & RESEND_WRITE_TO_COLOR_BUFFER )
+ {
+ typedef MessageValue1< Render::Renderer, bool > DerivedType;
+ unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
+ new (slot) DerivedType( mRenderer, &Render::Renderer::SetWriteToColorBuffer, mWriteToColorBuffer );
+ }
+
mResendFlag = 0;
}
}
mResendFlag |= RESEND_DEPTH_FUNCTION;
}
-void Renderer::SetRenderMode( RenderMode::Type mode )
+void Renderer::SetStencilMode( StencilMode::Type mode )
{
- mStencilParameters.renderMode = mode;
- mResendFlag |= RESEND_RENDER_MODE;
+ mStencilParameters.stencilMode = mode;
+ mResendFlag |= RESEND_STENCIL_MODE;
}
void Renderer::SetStencilFunction( StencilFunction::Type stencilFunction )
mResendFlag |= RESEND_STENCIL_OPERATION_ON_Z_PASS;
}
+void Renderer::SetWriteToColorBuffer( bool writeToColorBuffer )
+{
+ mWriteToColorBuffer = writeToColorBuffer;
+ mResendFlag |= RESEND_WRITE_TO_COLOR_BUFFER;
+}
+
//Called when SceneGraph::Renderer is added to update manager ( that happens when an "event-thread renderer" is created )
void Renderer::ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
{
RenderDataProvider* dataProvider = NewRenderDataProvider();
mRenderer = Render::Renderer::New( dataProvider, mGeometry, mBlendBitmask, mBlendColor, static_cast< FaceCullingMode::Type >( mFaceCullingMode ),
- mPremultipledAlphaEnabled, mDepthWriteMode, mDepthTestMode, mDepthFunction, mStencilParameters );
+ mPremultipledAlphaEnabled, mDepthWriteMode, mDepthTestMode, mDepthFunction, mStencilParameters, mWriteToColorBuffer );
mSceneController->GetRenderMessageDispatcher().AddRenderer( *mRenderer );
}
void SetDepthFunction( DepthFunction::Type depthFunction );
/**
- * Sets the render mode
- * @param[in] mode The render mode
+ * Sets the stencil mode
+ * @param[in] mode The stencil function
*/
- void SetRenderMode( RenderMode::Type mode );
+ void SetStencilMode( StencilMode::Type mode );
/**
* Sets the stencil function
void SetStencilOperationOnZPass( StencilOperation::Type stencilOperationOnZPass );
/**
+ * Sets whether or not to write to the color buffer
+ * @param[in] writeToColorBuffer True to write to the color buffer
+ */
+ void SetWriteToColorBuffer( bool writeToColorBuffer );
+
+ /**
* Prepare the object for rendering.
* This is called by the UpdateManager when an object is due to be rendered in the current frame.
* @param[in] updateBufferIndex The current update buffer index.
BlendMode::Type mBlendMode:2; ///< Local copy of the mode of blending
DepthWriteMode::Type mDepthWriteMode:2; ///< Local copy of the depth write mode
DepthTestMode::Type mDepthTestMode:2; ///< Local copy of the depth test mode
+ bool mWriteToColorBuffer:1; ///< Local copy of the write to color buffer flag
bool mUniformMapChanged[2]; ///< Records if the uniform map has been altered this frame
bool mResourcesReady; ///< Set during the Update algorithm; true if the renderer has resources ready for the current frame.
new (slot) LocalType( &renderer, &Renderer::SetDepthFunction, depthFunction );
}
-inline void SetRenderModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, RenderMode::Type mode )
+inline void SetStencilModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilMode::Type mode )
{
- typedef MessageValue1< Renderer, RenderMode::Type > LocalType;
+ typedef MessageValue1< Renderer, StencilMode::Type > LocalType;
// Reserve some memory inside the message queue
unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
- new (slot) LocalType( &renderer, &Renderer::SetRenderMode, mode );
+ new (slot) LocalType( &renderer, &Renderer::SetStencilMode, mode );
}
inline void SetStencilFunctionMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilFunction::Type stencilFunction )
new (slot) LocalType( &renderer, &Renderer::SetStencilOperationOnZPass, stencilOperation );
}
+inline void SetWriteToColorBufferMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, bool writeToColorBuffer )
+{
+ typedef MessageValue1< Renderer, bool > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+ new (slot) LocalType( &renderer, &Renderer::SetWriteToColorBuffer, writeToColorBuffer );
+}
} // namespace SceneGraph
} // namespace Internal
} // namespace DepthFunction
-namespace RenderMode
-{
-
-/**
- * @brief Controls how this renderer uses its stencil properties and writes to the color buffer.
- * @SINCE_1_2.5
- */
-enum Type
-{
- NONE, ///< Don’t write to either color or stencil buffer (But will potentially render to depth buffer). @SINCE_1_2.5
- AUTO, ///< Managed by the Actor Clipping API. This is the default. @SINCE_1_2.5
- COLOR, ///< Ingore stencil properties. Write to the color buffer. @SINCE_1_2.5
- STENCIL, ///< Use the stencil properties. Do not write to the color buffer. @SINCE_1_2.5
- COLOR_STENCIL ///< Use the stencil properties AND Write to the color buffer. @SINCE_1_2.5
-};
-
-} // namespace RenderMode
-
namespace StencilFunction
{
} // namespace StencilFunction
+namespace StencilMode
+{
+
+/**
+ * @brief How the stencil buffer will be managed.
+ * @SINCE_1_1.43
+ */
+enum Type
+{
+ OFF, ///< Off for this renderer @SINCE_1_1.43
+ AUTO, ///< Managed by the Actor clipping API. This is the default @SINCE_1_1.43
+ ON ///< On for this renderer. Select this to use the Renderer stencil properties to manage behavior. Note that Actor clipping management is bypassed for this renderer @SINCE_1_1.43
+};
+
+} // namespace StencilMode
+
namespace StencilOperation
{
DEPTH_TEST_MODE,
/**
- * @brief name "renderMode", type INTEGER
- * @see RenderMode
- * @note The default value is RenderMode::AUTO
- * @SINCE_1_2.5
- */
- RENDER_MODE,
-
- /**
* @brief name "stencilFunction", type INTEGER
* @see StencilFunction
* @note The default value is StencilFunction::ALWAYS
STENCIL_MASK,
/**
+ * @brief name "stencilMode", type INTEGER
+ * @see StencilMode
+ * @note The default value is StencilMode::AUTO
+ * @SINCE_1_1.43
+ */
+ STENCIL_MODE,
+
+ /**
* @brief name "stencilOperationOnFail", type INTEGER
* @see StencilOperation
* @note The default value is StencilOperation::KEEP
* @SINCE_1_1.43
*/
STENCIL_OPERATION_ON_Z_PASS,
+
+ /**
+ * @brief name "writeToColorBuffer", type BOOLEAN
+ * This allows per-renderer control of writing to the color buffer.
+ * For example: This can be turned off to write to the stencil or depth buffers only.
+ * @note The default value is True
+ * @SINCE_1_1.43
+ */
+ WRITE_TO_COLOR_BUFFER
};
};