-void Renderer::GlContextDestroyed()
-{
- mGeometry->GlContextDestroyed();
-}
-
-void Renderer::GlCleanup()
-{
-}
-
-void Renderer::BuildUniformIndexMap(BufferIndex bufferIndex, const SceneGraph::NodeDataProvider& node, const Vector3& size, Program& program)
-{
- // Check if the map has changed
- DALI_ASSERT_DEBUG(mRenderDataProvider && "No Uniform map data provider available");
-
- const SceneGraph::UniformMapDataProvider& uniformMapDataProvider = mRenderDataProvider->GetUniformMap();
-
- if(uniformMapDataProvider.GetUniformMapChanged(bufferIndex) ||
- node.GetUniformMapChanged(bufferIndex) ||
- mUniformIndexMap.Count() == 0 ||
- mShaderChanged)
- {
- // Reset shader pointer
- mShaderChanged = false;
-
- const SceneGraph::CollectedUniformMap& uniformMap = uniformMapDataProvider.GetUniformMap(bufferIndex);
- const SceneGraph::CollectedUniformMap& uniformMapNode = node.GetUniformMap(bufferIndex);
-
- uint32_t maxMaps = static_cast<uint32_t>(uniformMap.Count() + uniformMapNode.Count()); // 4,294,967,295 maps should be enough
- mUniformIndexMap.Clear(); // Clear contents, but keep memory if we don't change size
- mUniformIndexMap.Resize(maxMaps);
-
- uint32_t mapIndex = 0;
- for(; mapIndex < uniformMap.Count(); ++mapIndex)
- {
- mUniformIndexMap[mapIndex].propertyValue = uniformMap[mapIndex].propertyPtr;
- mUniformIndexMap[mapIndex].uniformIndex = program.RegisterUniform(uniformMap[mapIndex].uniformName);
- mUniformIndexMap[mapIndex].uniformName = uniformMap[mapIndex].uniformName;
- mUniformIndexMap[mapIndex].uniformNameHash = uniformMap[mapIndex].uniformNameHash;
- mUniformIndexMap[mapIndex].uniformNameHashNoArray = uniformMap[mapIndex].uniformNameHashNoArray;
- mUniformIndexMap[mapIndex].arrayIndex = uniformMap[mapIndex].arrayIndex;
- }
-
- for(uint32_t nodeMapIndex = 0; nodeMapIndex < uniformMapNode.Count(); ++nodeMapIndex)
- {
- uint32_t uniformIndex = program.RegisterUniform(uniformMapNode[nodeMapIndex].uniformName);
- bool found(false);
- for(uint32_t i = 0; i < uniformMap.Count(); ++i)
- {
- if(mUniformIndexMap[i].uniformIndex == uniformIndex)
- {
- mUniformIndexMap[i].propertyValue = uniformMapNode[nodeMapIndex].propertyPtr;
- found = true;
- break;
- }
- }
-
- if(!found)
- {
- mUniformIndexMap[mapIndex].propertyValue = uniformMapNode[nodeMapIndex].propertyPtr;
- mUniformIndexMap[mapIndex].uniformName = uniformMapNode[nodeMapIndex].uniformName;
- mUniformIndexMap[mapIndex].uniformIndex = uniformIndex;
- mUniformIndexMap[mapIndex].uniformNameHash = uniformMapNode[nodeMapIndex].uniformNameHash;
- mUniformIndexMap[mapIndex].uniformNameHashNoArray = uniformMapNode[nodeMapIndex].uniformNameHashNoArray;
- mUniformIndexMap[mapIndex].arrayIndex = uniformMapNode[nodeMapIndex].arrayIndex;
- ++mapIndex;
- }
- }
-
- mUniformIndexMap.Resize(mapIndex);
- }
-
- // The code below is disabled because the uniforms should now be set in the graphics backend.
-
- /*
- // Set uniforms in local map
- for(UniformIndexMappings::Iterator iter = mUniformIndexMap.Begin(),
- end = mUniformIndexMap.End();
- iter != end;
- ++iter)
- {
- SetUniformFromProperty(bufferIndex, program, *iter);
- }
-
- GLint sizeLoc = program.GetUniformLocation(Program::UNIFORM_SIZE);
- if(-1 != sizeLoc)
- {
- program.SetSizeUniform3f(sizeLoc, size.x, size.y, size.z);
- }
-*/
-}
-
-void Renderer::SetUniformFromProperty(BufferIndex bufferIndex, Program& program, UniformIndexMap& map)
-{
- GLint location = program.GetUniformLocation(map.uniformIndex);
- if(Program::UNIFORM_UNKNOWN != location)
- {
- // switch based on property type to use correct GL uniform setter
- switch(map.propertyValue->GetType())
- {
- case Property::INTEGER:
- {
- program.SetUniform1i(location, map.propertyValue->GetInteger(bufferIndex));
- break;
- }
- case Property::FLOAT:
- {
- program.SetUniform1f(location, map.propertyValue->GetFloat(bufferIndex));
- break;
- }
- case Property::VECTOR2:
- {
- Vector2 value(map.propertyValue->GetVector2(bufferIndex));
- program.SetUniform2f(location, value.x, value.y);
- break;
- }
-
- case Property::VECTOR3:
- {
- Vector3 value(map.propertyValue->GetVector3(bufferIndex));
- program.SetUniform3f(location, value.x, value.y, value.z);
- break;
- }
-
- case Property::VECTOR4:
- {
- Vector4 value(map.propertyValue->GetVector4(bufferIndex));
- program.SetUniform4f(location, value.x, value.y, value.z, value.w);
- break;
- }
-
- case Property::ROTATION:
- {
- Quaternion value(map.propertyValue->GetQuaternion(bufferIndex));
- program.SetUniform4f(location, value.mVector.x, value.mVector.y, value.mVector.z, value.mVector.w);
- break;
- }
-
- case Property::MATRIX:
- {
- const Matrix& value = map.propertyValue->GetMatrix(bufferIndex);
- program.SetUniformMatrix4fv(location, 1, value.AsFloat());
- break;
- }
-
- case Property::MATRIX3:
- {
- const Matrix3& value = map.propertyValue->GetMatrix3(bufferIndex);
- program.SetUniformMatrix3fv(location, 1, value.AsFloat());
- break;
- }
-
- default:
- {
- // Other property types are ignored
- break;
- }
- }
- }
-}
-
-bool Renderer::BindTextures(Program& program, Graphics::CommandBuffer& commandBuffer, Vector<Graphics::Texture*>& boundTextures)