1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_MESH_RENDERER_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_MESH_RENDERER_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/internal/common/owner-pointer.h>
23 #include <dali/internal/render/renderers/render-material.h>
24 #include <dali/internal/render/renderers/scene-graph-renderer.h>
25 #include <dali/internal/update/modeling/bone-transforms.h>
26 #include <dali/internal/render/shaders/custom-uniform.h>
27 #include <dali/internal/event/effects/shader-declarations.h>
38 class RenderDataProvider;
39 struct BoneTransforms;
40 class LightController;
45 * An attachment for rendering a mesh with a material.
47 class MeshRenderer : public Renderer
52 * The information required to render a single mesh
64 RenderMaterial* material;
65 BoneTransforms boneTransforms; ///< Note, this is a std::vector. May be realloced in off-frame
69 * Construct a new MeshRenderer.
70 * @param dataprovider to render
71 * @param lightController to get the light information
72 * @return The newly allocated MeshRenderer.
74 static MeshRenderer* New( RenderDataProvider& dataprovider);
77 * Retrieve the mesh information for the next frame.
78 * This should only be accessed from the update-thread, using the current update buffer.
79 * @param[in] updateBufferIndex The current update buffer index.
81 MeshInfo& GetMeshInfo( BufferIndex updateBufferIndex )
83 return mMeshInfo[ updateBufferIndex ];
87 * Called when the shader has changed; mCustomUniform should be reset.
89 void ResetCustomUniforms();
94 virtual ~MeshRenderer();
99 * @copydoc Dali::Internal::GlResourceOwner::GlContextDestroyed()
101 virtual void GlContextDestroyed();
104 * @copydoc Dali::Internal::GlResourceOwner::GlCleanup()
106 virtual void GlCleanup();
109 * @copydoc Dali::Internal::SceneGraph::Renderer::RequiresDepthTest()
111 virtual bool RequiresDepthTest() const;
114 * @copydoc Dali::Internal::SceneGraph::Renderer::CheckResources()
116 virtual bool CheckResources();
119 * @copydoc Dali::Internal::SceneGraph::Renderer::ResolveGeometryTypes()
121 virtual void ResolveGeometryTypes( BufferIndex bufferIndex, GeometryType& outType, ShaderSubTypes& outSubType );
124 * @copydoc Dali::Internal::SceneGraph::Renderer::IsOutsideClipSpace()
126 virtual bool IsOutsideClipSpace( const Matrix& modelMatrix, const Matrix& modelViewProjectionMatrix );
129 * @copydoc Dali::Internal::SceneGraph::Renderer::DoRender()
131 virtual void DoRender( BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix );
134 * Apply the view matrix to the bone transforms, and generate inverse transforms (for normal
136 * @param[inout] boneTransforms The bone transform matrices to update
137 * @param[in] viewMatrix The current view matrix
139 void ApplyViewToBoneTransforms( BoneTransforms& boneTransforms, const Matrix& viewMatrix );
142 * Private constructor. See New()
144 MeshRenderer(RenderDataProvider& dataprovider);
147 MeshRenderer(const MeshRenderer&);
150 MeshRenderer& operator=(const MeshRenderer& rhs);
154 MeshInfo mMeshInfo[2]; ///< Double-buffered for update/render in separate threads.
155 GeometryType mGeometryType; ///< Records last geometry type
156 ShaderSubTypes mShaderType; ///< Records last shader type
158 static const unsigned int mNumberOfCustomUniforms = 13; // Number of uniforms needed for renderer
159 CustomUniform mCustomUniform[SHADER_SUBTYPE_LAST][ mNumberOfCustomUniforms ];
160 RenderMaterialUniforms mRenderMaterialUniforms; ///< Uniforms for render material
164 } // namespace SceneGraph
166 } // namespace Internal
170 #endif // __DALI_INTERNAL_SCENE_GRAPH_MESH_RENDERER_H__