mHasUntrackedResources = false; // Only need to know this if the resources are not yet complete
mTrackedResources.Clear(); // Resource trackers are only needed if not yet completea
- if( Shader* shader = mParent->GetAppliedShader() )
+ if( mShader )
{
- Integration::ResourceId id = shader->GetEffectTextureResourceId();
+ Integration::ResourceId id = mShader->GetEffectTextureResourceId();
if( id != 0 )
{
mScaleForSizeDirty = false;
}
+void RenderableAttachment::ApplyShader( BufferIndex updateBufferIndex, Shader* shader )
+{
+ mShader = shader;
+
+ // send the message to renderer
+ SendShaderChangeMessage( updateBufferIndex );
+
+ // tell derived class to do something
+ ShaderChanged( updateBufferIndex );
+}
+
+void RenderableAttachment::RemoveShader( BufferIndex updateBufferIndex )
+{
+ // return to default shader
+ mShader = mSceneController->GetDefaultShader();
+
+ // send the message to renderer
+ SendShaderChangeMessage( updateBufferIndex );
+
+ // tell derived class to do something
+ ShaderChanged( updateBufferIndex );
+}
+
void RenderableAttachment::DoGetScaleForSize( const Vector3& nodeSize, Vector3& scaling )
{
scaling = Vector3::ONE;
RenderableAttachment::RenderableAttachment( bool usesGeometryScaling )
: mSceneController(NULL),
+ mShader( NULL ),
+ mTrackedResources(),
+ mSortModifier( 0.0f ),
mBlendingMode( Dali::RenderableActor::DEFAULT_BLENDING_MODE ),
mUsesGeometryScaling( usesGeometryScaling ),
mScaleForSizeDirty( true ),
mResourcesReady( false ),
mFinishedResourceAcquisition( false ),
mHasUntrackedResources( false ),
- mCullFaceMode( CullNone ),
- mSortModifier( 0.0f )
+ mCullFaceMode( CullNone )
{
}
void RenderableAttachment::ConnectToSceneGraph( SceneController& sceneController, BufferIndex updateBufferIndex )
{
mSceneController = &sceneController;
+ // get the default shader
+ mShader = mSceneController->GetDefaultShader();
// Chain to derived attachments
ConnectToSceneGraph2( updateBufferIndex );
// After derived classes have (potentially) created their renderer
- GetRenderer().SetCullFace( mCullFaceMode );
+ Renderer& renderer = GetRenderer();
+ renderer.SetCullFace( mCullFaceMode );
+
+ // set the default shader here as well
+ renderer.SetShader( mShader );
}
void RenderableAttachment::OnDestroy()
return this;
}
+void RenderableAttachment::SendShaderChangeMessage( BufferIndex updateBufferIndex )
+{
+ typedef MessageValue1< Renderer, Shader* > DerivedType;
+ // Reserve memory inside the render queue
+ unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
+ // Construct message in the mRenderer queue memory; note that delete should not be called on the return value
+ new (slot) DerivedType( &GetRenderer(), &Renderer::SetShader, mShader );
+}
} // namespace SceneGraph