BaseHandle Create()
{
- Internal::ShaderEffectPtr internal = Internal::ShaderEffect::New( );
-
- ShaderFactory::LoadTextSubtypeShaders(internal);
+ Internal::ShaderEffectPtr internal = Internal::ShaderEffect::New();
return Dali::ShaderEffect(internal.Get());
}
Dali::ShaderEffect::GeometryHints hints )
{
ShaderEffectPtr shaderEffect( New(hints) );
- ShaderFactory::LoadTextSubtypeShaders(shaderEffect);
shaderEffect->SetPrograms( geometryTypes, vertexShaderPrefix, vertexShader, fragmentShaderPrefix, fragmentShader );
return shaderEffect;
{
ShaderEffectPtr shaderEffect( New(hints) );
- ShaderFactory::LoadTextSubtypeShaders(shaderEffect);
-
shaderEffect->SetWrappedProgram( GEOMETRY_TYPE_IMAGE, SHADER_SUBTYPE_ALL, "", "", imageVertexShader, imageFragmentShader );
shaderEffect->SetWrappedProgram( GEOMETRY_TYPE_TEXT, SHADER_DEFAULT, "", "", textVertexShader, textFragmentShader );
shaderEffect->SetWrappedProgram( GEOMETRY_TYPE_TEXTURED_MESH, SHADER_SUBTYPE_ALL, "", "", texturedMeshVertexShader, texturedMeshFragmentShader );
{
SetWrappedProgram( GEOMETRY_TYPE_IMAGE, SHADER_SUBTYPE_ALL, vertexShaderPrefix, fragmentShaderPrefix, vertexShader, fragmentShader );
}
- else
- {
- SetWrappedProgram( GEOMETRY_TYPE_IMAGE, SHADER_SUBTYPE_ALL, emptyStr, emptyStr, emptyStr, emptyStr );
- }
if( geometryTypes & GEOMETRY_TYPE_TEXT )
{
// Only change the default program, leaving the other sub-types as-is.
SetWrappedProgram( GEOMETRY_TYPE_TEXT, SHADER_DEFAULT, vertexShaderPrefix, fragmentShaderPrefix, vertexShader, fragmentShader );
}
- else
- {
- SetWrappedProgram( GEOMETRY_TYPE_TEXT, SHADER_DEFAULT, emptyStr, emptyStr, emptyStr, emptyStr );
- }
if( geometryTypes & GEOMETRY_TYPE_TEXTURED_MESH )
{
SetWrappedProgram( GEOMETRY_TYPE_TEXTURED_MESH, SHADER_SUBTYPE_ALL, vertexShaderPrefix, fragmentShaderPrefix, vertexShader, fragmentShader );
}
- else
- {
- SetWrappedProgram( GEOMETRY_TYPE_TEXTURED_MESH, SHADER_SUBTYPE_ALL, emptyStr, emptyStr, emptyStr, emptyStr );
- }
if( geometryTypes & GEOMETRY_TYPE_MESH )
{
SetWrappedProgram( GEOMETRY_TYPE_MESH, SHADER_SUBTYPE_ALL, vertexShaderPrefix, fragmentShaderPrefix, vertexShader, fragmentShader );
}
- else
- {
- SetWrappedProgram( GEOMETRY_TYPE_MESH, SHADER_SUBTYPE_ALL, emptyStr, emptyStr, emptyStr, emptyStr );
- }
}
void ShaderEffect::SetWrappedProgram( GeometryType geometryType, ShaderSubTypes subType,
mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXT, SHADER_DEFAULT, DistanceFieldFontVertex, DistanceFieldFontFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
- LoadTextSubtypeShaders(mDefaultShader); // TODO: Remove when applications no longer need these shaders
+ mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT, SHADER_DEF_USE_GRADIENT, SHADER_DEF_USE_GRADIENT, DistanceFieldFontVertex, DistanceFieldFontFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
+
+ mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_GLOW, DistanceFieldFontGlowVertex, DistanceFieldFontGlowFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
+
+ mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_SHADOW, DistanceFieldFontShadowVertex, DistanceFieldFontShadowFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
+
+ mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_OUTLINE, DistanceFieldFontOutlineVertex, DistanceFieldFontOutlineFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
+
+ mDefaultShader->SetProgram( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_OUTLINE_GLOW, DistanceFieldFontOutlineGlowVertex, DistanceFieldFontOutlineGlowFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
// Untextured meshes
mDefaultShader->SetProgram( GEOMETRY_TYPE_MESH, SHADER_DEFAULT,
ShaderEffect::MODIFIES_GEOMETRY );
}
-void ShaderFactory::LoadTextSubtypeShaders(ShaderEffectPtr shaderEffect)
-{
- shaderEffect->SetProgram(GEOMETRY_TYPE_TEXT, SHADER_GRADIENT,
- SHADER_DEF_USE_GRADIENT,
- SHADER_DEF_USE_GRADIENT,
- DistanceFieldFontVertex, DistanceFieldFontFragment,
- ShaderEffect::DOESNT_MODIFY_GEOMETRY );
-
- shaderEffect->SetProgram(GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_GLOW, DistanceFieldFontGlowVertex, DistanceFieldFontGlowFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
-
- shaderEffect->SetProgram(GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_SHADOW, DistanceFieldFontShadowVertex, DistanceFieldFontShadowFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
-
- shaderEffect->SetProgram(GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_OUTLINE, DistanceFieldFontOutlineVertex, DistanceFieldFontOutlineFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
-
- shaderEffect->SetProgram(GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_OUTLINE_GLOW, DistanceFieldFontOutlineGlowVertex, DistanceFieldFontOutlineGlowFragment, ShaderEffect::DOESNT_MODIFY_GEOMETRY );
-}
-
-
} // namespace Internal
} // namespace Dali
*/
void LoadDefaultShaders();
- /**
- * Called during ShaderEffect::New() to load shaders for text sub-types
- * (Default shader can be overridden)
- * @param[in] shaderEffect The shader effect for which to load the sub-type shaders
- */
- static void LoadTextSubtypeShaders(ShaderEffectPtr shaderEffect);
-
private:
// Undefined
* Process a render-list.
* @param[in] renderList The render-list to process.
* @param[in] context The GL context.
+ * @param[in] defaultShader The default shader to use.
* @param[in] buffer The current render buffer index (previous update buffer)
* @param[in] frameTime The elapsed time between the last two updates.
* @param[in] viewMatrix The view matrix from the appropriate camera.
*/
inline void ProcessRenderList( const RenderList& renderList,
Context& context,
+ SceneGraph::Shader& defaultShader,
BufferIndex bufferIndex,
float frameTime,
const Matrix& viewMatrix,
SceneGraph::Renderer* renderer = const_cast< SceneGraph::Renderer* >( item.GetRenderer() );
const Matrix& modelViewMatrix = item.GetModelViewMatrix();
- renderer->Render( bufferIndex, modelViewMatrix, viewMatrix, projectionMatrix, frameTime, cullMode );
+ renderer->Render( bufferIndex, defaultShader, modelViewMatrix, viewMatrix, projectionMatrix, frameTime, cullMode );
}
}
void ProcessRenderInstruction( const RenderInstruction& instruction,
Context& context,
+ SceneGraph::Shader& defaultShader,
BufferIndex bufferIndex,
float frameTime )
{
if( renderList &&
!renderList->IsEmpty() )
{
- ProcessRenderList( *renderList, context, bufferIndex, frameTime, *viewMatrix, *projectionMatrix, instruction.mCullMode );
+ ProcessRenderList( *renderList, context, defaultShader, bufferIndex, frameTime, *viewMatrix, *projectionMatrix, instruction.mCullMode );
}
}
}
namespace SceneGraph
{
class RenderInstruction;
+class Shader;
}
namespace Render
* Process a render-instruction.
* @param[in] instruction The render-instruction to process.
* @param[in] context The GL context.
+ * @param[in] defaultShader The default shader.
* @param[in] buffer The current render buffer index (previous update buffer)
* @param[in] frameTime The elapsed time between the last two updates.
*/
void ProcessRenderInstruction( const SceneGraph::RenderInstruction& instruction,
Context& context,
+ SceneGraph::Shader& defaultShader,
BufferIndex bufferIndex,
float frameTime );
rendererContainer(),
materials(),
renderersAdded( false ),
- firstRenderCompleted( false )
+ firstRenderCompleted( false ),
+ defaultShader( NULL )
{
}
RenderTrackerContainer mRenderTrackers; ///< List of render trackers
bool firstRenderCompleted; ///< False until the first render is done
+ Shader* defaultShader; ///< Default shader to use
};
RenderManager* RenderManager::New( Integration::GlAbstraction& glAbstraction, ResourcePostProcessList& resourcePostProcessQ )
mImpl->RemoveRenderTracker(renderTracker);
}
+void RenderManager::SetDefaultShader( Shader* shader )
+{
+ mImpl->defaultShader = shader;
+}
+
bool RenderManager::Render( Integration::RenderStatus& status )
{
DALI_PRINT_RENDER_START( mImpl->renderBufferIndex );
// @todo move programs out of context onto a program controller and let that handle this
mImpl->context.ResetProgramMatrices();
- size_t count = mImpl->instructions.Count( mImpl->renderBufferIndex );
- for ( size_t i = 0; i < count; ++i )
+ // if we don't have default shader, no point doing the render calls
+ if( mImpl->defaultShader )
{
- RenderInstruction& instruction = mImpl->instructions.At( mImpl->renderBufferIndex, i );
+ size_t count = mImpl->instructions.Count( mImpl->renderBufferIndex );
+ for ( size_t i = 0; i < count; ++i )
+ {
+ RenderInstruction& instruction = mImpl->instructions.At( mImpl->renderBufferIndex, i );
- DoRender( instruction, mImpl->lastFrameTime );
+ DoRender( instruction, *mImpl->defaultShader, mImpl->lastFrameTime );
- const RenderListContainer::SizeType countRenderList = instruction.RenderListCount();
- if ( countRenderList > 0 )
- {
- status.SetHasRendered( true );
+ const RenderListContainer::SizeType countRenderList = instruction.RenderListCount();
+ if ( countRenderList > 0 )
+ {
+ status.SetHasRendered( true );
+ }
}
- }
-
- GLenum attachments[] = { GL_DEPTH, GL_STENCIL };
- mImpl->context.InvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments);
+ GLenum attachments[] = { GL_DEPTH, GL_STENCIL };
+ mImpl->context.InvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments);
- mImpl->UpdateTrackers();
+ mImpl->UpdateTrackers();
- mImpl->firstRenderCompleted = true;
+ mImpl->firstRenderCompleted = true;
+ }
}
PERF_MONITOR_END(PerformanceMonitor::DRAW_NODES);
return updateRequired;
}
-void RenderManager::DoRender( RenderInstruction& instruction, float elapsedTime )
+void RenderManager::DoRender( RenderInstruction& instruction, Shader& defaultShader, float elapsedTime )
{
Rect<int> viewportRect;
Vector4 clearColor;
Render::ProcessRenderInstruction( instruction,
mImpl->context,
+ defaultShader,
mImpl->renderBufferIndex,
elapsedTime );
class RenderInstruction;
class RenderInstructionContainer;
class RenderTracker;
+class Shader;
/**
* RenderManager is responsible for rendering the result of the previous "update", which
*/
void RemoveRenderTracker( RenderTracker* renderTracker );
+ /**
+ * Set the default shader that is to be used in absence of custom shader
+ * @param[in] shader that is the default one
+ */
+ void SetDefaultShader( Shader* shader );
+
// This method should be called from Core::Render()
/**
/**
* Helper to process a single RenderInstruction.
* @param[in] instruction A description of the rendering operation.
+ * @param[in] defaultShader default shader to use.
+ * @param[in] elapsedTime from previous render.
*/
- void DoRender( RenderInstruction& instruction, float elapsedTime );
+ void DoRender( RenderInstruction& instruction, Shader& defaultShader, float elapsedTime );
private:
void Context::GlContextDestroyed()
{
DALI_LOG_INFO(gContextLogFilter, Debug::Verbose, "Context::GlContextDestroyed()\n");
-
+ SetCurrentProgram( NULL );
// Inform programs they are no longer valid
const ProgramContainer::iterator endp = mProgramCache.end();
for ( ProgramContainer::iterator itp = mProgramCache.begin(); itp != endp; ++itp )
#include <dali/internal/render/shaders/shader.h>
#include <dali/internal/update/controllers/scene-controller.h>
-using namespace std;
-
namespace
{
#if defined(DEBUG_ENABLED)
namespace
{
-
-static Matrix gModelViewProjectionMatrix( false ); ///< a shared matrix to calculate the MVP matrix, dont want to store it locally to reduce storage overhead
-static Matrix3 gNormalMatrix; ///< a shared matrix to calculate normal matrix, dont want to store it locally to reduce storage overhead
+static Matrix gModelViewProjectionMatrix( false ); ///< a shared matrix to calculate the MVP matrix, dont want to store it in object to reduce storage overhead
+static Matrix3 gNormalMatrix; ///< a shared matrix to calculate normal matrix, dont want to store it in object to reduce storage overhead
/**
* Helper to set view and projection matrices once per program
}
void Renderer::Render( BufferIndex bufferIndex,
+ Shader& defaultShader,
const Matrix& modelViewMatrix,
const Matrix& viewMatrix,
const Matrix& projectionMatrix,
bool cull )
{
DALI_ASSERT_DEBUG( mContext && "Renderer::Render. Renderer not initialised!! (mContext == NULL)." );
- DALI_ASSERT_DEBUG( mShader && "Renderer::Render. Shader not set!!" );
+
+ // if mShader is NULL it means we're set to default
+ if( !mShader )
+ {
+ mShader = &defaultShader;
+ }
if( !CheckResources() )
{
ShaderSubTypes subType=SHADER_DEFAULT;
ResolveGeometryTypes( bufferIndex, geometryType, subType );
unsigned int programIndex = 0;
- Program& program = mShader->GetProgram( *mContext, geometryType, subType, programIndex );
+ Program* program = mShader->GetProgram( *mContext, geometryType, subType, programIndex );
+ if( !program )
+ {
+ // if program is NULL it means this is a custom shader with non matching geometry type so we need to use default shaders program
+ program = defaultShader.GetProgram( *mContext, geometryType, subType, programIndex );
+ DALI_ASSERT_ALWAYS( program && "Default shader is missing a geometry type!!" );
+ }
// Check culling (does not need the program to be in use)
- if( cull && ! program.ModifiesGeometry() )
+ if( cull && ! program->ModifiesGeometry() )
{
if( IsOutsideClipSpace( modelMatrix, gModelViewProjectionMatrix ) )
{
}
// Take the program into use so we can send uniforms to it
- program.Use();
+ program->Use();
// Enables/disables blending mode.
mContext->SetBlend( mUseBlend );
// Ignore missing uniforms - custom shaders and flat color shaders don't have SAMPLER
// set projection and view matrix if program has not yet received them yet this frame
- SetMatrices( program, modelMatrix, viewMatrix, projectionMatrix, modelViewMatrix, gModelViewProjectionMatrix );
+ SetMatrices( *program, modelMatrix, viewMatrix, projectionMatrix, modelViewMatrix, gModelViewProjectionMatrix );
// set color uniform
- GLint loc = program.GetUniformLocation( Program::UNIFORM_COLOR );
+ GLint loc = program->GetUniformLocation( Program::UNIFORM_COLOR );
if( Program::UNIFORM_UNKNOWN != loc )
{
const Vector4& color = mDataProvider.GetRenderColor( bufferIndex );
- program.SetUniform4f( loc, color.r, color.g, color.b, color.a );
+ program->SetUniform4f( loc, color.r, color.g, color.b, color.a );
}
- loc = program.GetUniformLocation(Program::UNIFORM_TIME_DELTA);
+ loc = program->GetUniformLocation(Program::UNIFORM_TIME_DELTA);
if( Program::UNIFORM_UNKNOWN != loc )
{
- program.SetUniform1f( loc, frametime );
+ program->SetUniform1f( loc, frametime );
}
// set custom uniforms
- mShader->SetUniforms( *mContext, program, bufferIndex, programIndex, subType );
+ mShader->SetUniforms( *mContext, *program, bufferIndex, programIndex, subType );
// subclass rendering and actual draw call
- DoRender( bufferIndex, program, modelViewMatrix, viewMatrix );
+ DoRender( bufferIndex, *program, modelViewMatrix, viewMatrix );
}
Renderer::Renderer( RenderDataProvider& dataprovider )
/**
* Called to render during RenderManager::Render().
* @param[in] bufferIndex The index of the previous update buffer.
+ * @param[in] defaultShader in case there is no custom shader
* @param[in] modelViewMatrix The model-view matrix.
* @param[in] viewMatrix The view matrix.
* @param[in] projectionMatrix The projection matrix.
* @param[in] cull Whether to frustum cull this renderer
*/
void Render( BufferIndex bufferIndex,
+ Shader& defaultShader,
const Matrix& modelViewMatrix,
const Matrix& viewMatrix,
const Matrix& projectionMatrix,
void Program::GlContextDestroyed()
{
mLinked = false;
-
mVertexShaderId = 0;
mFragmentShaderId = 0;
mProgramId = 0;
- mContext.SetCurrentProgram( NULL );
ResetAttribsUniformCache();
}
{
// Convert Geometry type bitmask to an array index
-unsigned int GetGeometryTypeIndex(GeometryType type)
+inline unsigned int GetGeometryTypeIndex(GeometryType type)
{
unsigned int index = Log<GEOMETRY_TYPE_IMAGE>::value;
if ( type & GEOMETRY_TYPE_IMAGE )
theSubType = SHADER_DEFAULT;
}
+ const unsigned int geometryIndex = GetGeometryTypeIndex( geometryType );
if(geometryType != GEOMETRY_TYPE_TEXT && subType == SHADER_SUBTYPE_ALL)
{
- mPrograms[GetGeometryTypeIndex(geometryType)].Resize(1);
- mPrograms[GetGeometryTypeIndex(geometryType)][theSubType] = program;
- mPrograms[GetGeometryTypeIndex(geometryType)].mUseDefaultForAllSubtypes = true;
+ mPrograms[geometryIndex].Resize(1);
+ mPrograms[geometryIndex][theSubType] = program;
+ mPrograms[geometryIndex].mUseDefaultForAllSubtypes = true;
}
else
{
- mPrograms[GetGeometryTypeIndex(geometryType)][theSubType] = program;
- mPrograms[GetGeometryTypeIndex(geometryType)].mUseDefaultForAllSubtypes = false;
+ mPrograms[geometryIndex][theSubType] = program;
+ mPrograms[geometryIndex].mUseDefaultForAllSubtypes = false;
}
if( !precompiledBinary )
return ! mPrograms[ programType ].mUseDefaultForAllSubtypes;
}
-Program& Shader::GetProgram( Context& context,
+Program* Shader::GetProgram( Context& context,
GeometryType type,
ShaderSubTypes subType,
unsigned int& programIndex )
programIndex = GetGeometryTypeIndex( type );
- DALI_ASSERT_DEBUG(!mPrograms[ programIndex ].mUseDefaultForAllSubtypes || subType == SHADER_DEFAULT);
DALI_ASSERT_DEBUG((unsigned int)subType < mPrograms[ programIndex ].Count());
- DALI_ASSERT_DEBUG(NULL != mPrograms[ programIndex ][ subType ]);
- Program& program = *(mPrograms[ programIndex ][ subType ]);
- return program;
+ return mPrograms[ programIndex ][ subType ];
}
*/
void Resize(size_t length)
{
- mSubPrograms.Resize(length);
+ mSubPrograms.Resize( length, NULL );
}
/**
* @param[out] programIndex returns the program index to be passed onto SetUniforms.
* @return the program to use.
*/
- Program& GetProgram( Context& context,
+ Program* GetProgram( Context& context,
GeometryType type,
ShaderSubTypes subType,
unsigned int& programIndex );
RenderQueue& renderQueue,
DiscardQueue& discardQueue,
TextureCache& textureCache,
- CompleteStatusManager& completeStatusManager,
- Shader*& defaultShader )
+ CompleteStatusManager& completeStatusManager )
: mRenderMessageDispatcher( renderMessageDispatcher ),
mRenderQueue( renderQueue ),
mDiscardQueue( discardQueue ),
mTextureCache( textureCache ),
- mCompleteStatusManager( completeStatusManager ),
- mDefaultShader( defaultShader )
+ mCompleteStatusManager( completeStatusManager )
{
mLightController = new LightControllerImpl;
}
RenderQueue& renderQueue,
DiscardQueue& discardQueue,
TextureCache& textureCache,
- CompleteStatusManager& completeStatusManager,
- Shader*& defaultShader );
+ CompleteStatusManager& completeStatusManager );
/**
* Destructor
*/
virtual CompleteStatusManager& GetCompleteStatusManager() { return mCompleteStatusManager; }
- /**
- * @copydoc SceneController::GetDefaultShader()
- */
- virtual Shader* GetDefaultShader() { return mDefaultShader; }
-
private:
// Undefined copy constructor.
DiscardQueue& mDiscardQueue; ///< discard queue
TextureCache& mTextureCache; ///< texture cache
CompleteStatusManager& mCompleteStatusManager; ///< Complete Status manager
- Shader*& mDefaultShader; ///< default shader, reference to a pointer as it will be setup later
};
class RenderQueue;
class DiscardQueue;
class TextureCache;
-class Shader;
/**
* Abstract interface for the scene controller
*/
virtual CompleteStatusManager& GetCompleteStatusManager() = 0;
- /**
- * Return the default shader
- * @return pointer to the default shader
- */
- virtual Shader* GetDefaultShader() = 0;
-
private:
// Undefined copy constructor.
systemLevelTaskList ( completeStatusManager ),
root( NULL ),
systemLevelRoot( NULL ),
- defaultShader( NULL ),
messageQueue( renderController, sceneGraphBuffers ),
dynamicsChanged( false ),
keepRenderingSeconds( 0.0f ),
renderSortingHelper(),
renderTaskWaiting( false )
{
- sceneController = new SceneControllerImpl( renderMessageDispatcher, renderQueue, discardQueue, textureCache, completeStatusManager, defaultShader );
+ sceneController = new SceneControllerImpl( renderMessageDispatcher, renderQueue, discardQueue, textureCache, completeStatusManager );
}
~Impl()
AnimationContainer animations; ///< A container of owned animations
PropertyNotificationContainer propertyNotifications; ///< A container of owner property notifications.
- Shader* defaultShader; ///< The default shader; owned by ShaderContainer
ShaderContainer shaders; ///< A container of owned shaders
AnimatableMeshContainer animatableMeshes; ///< A container of owned animatable meshes
MaterialContainer materials; ///< A container of owned materials
propertyNotification->SetNotifyMode( notifyMode );
}
-Shader* UpdateManager::GetDefaultShader()
-{
- return mImpl->defaultShader;
-}
-
void UpdateManager::AddShader( Shader* shader )
{
DALI_ASSERT_DEBUG( NULL != shader );
- // Note: The first shader added becomes the default shader
- if( NULL == mImpl->defaultShader )
+ if( mImpl->shaders.Count() == 0 )
{
- mImpl->defaultShader = shader;
+ // the first added shader becomes our default shader
+ // Construct message in the render queue memory; note that delete should not be called on the return value
+ typedef MessageValue1< RenderManager, Shader* > DerivedType;
+
+ // Reserve some memory inside the render queue
+ unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+
+ // Construct message in the render queue memory; note that delete should not be called on the return value
+ new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetDefaultShader, shader );
}
mImpl->shaders.PushBack( shader );
// Shaders
/**
- * Retrieve the default shader.
- * @return The default shader.
- */
- Shader* GetDefaultShader();
-
- /**
* Add a newly created shader.
* @param[in] shader The shader to add.
* @post The shader is owned by the UpdateManager.
void ImageAttachment::ShaderChanged( BufferIndex updateBufferIndex )
{
- DALI_ASSERT_DEBUG( mShader != NULL );
DALI_ASSERT_DEBUG( mSceneController );
- int hints = mShader->GetGeometryHints();
-
+ int hints = 0; // default shader hints are 0
+ if( mShader )
+ {
+ hints = mShader->GetGeometryHints();
+ }
if ( hints != mPreviousRefreshHints )
{
mPreviousRefreshHints = hints;
void RenderableAttachment::RemoveShader( BufferIndex updateBufferIndex )
{
// return to default shader
- mShader = mSceneController->GetDefaultShader();
+ mShader = NULL;
// send the message to renderer
SendShaderChangeMessage( updateBufferIndex );
void RenderableAttachment::ConnectToSceneGraph( SceneController& sceneController, BufferIndex updateBufferIndex )
{
mSceneController = &sceneController;
- // get the default shader
- mShader = mSceneController->GetDefaultShader();
// Chain to derived attachments
ConnectToSceneGraph2( updateBufferIndex );