1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_NEW_RENDERER_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_NEW_RENDERER_H__
5 * Copyright (c) 2015 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.
21 #include <dali/integration-api/resource-declarations.h> // For resource id
22 #include <dali/internal/render/data-providers/material-data-provider.h>
23 #include <dali/internal/render/gl-resources/texture-units.h>
24 #include <dali/internal/render/renderers/scene-graph-renderer.h>
25 #include <dali/internal/render/renderers/render-geometry.h>
33 class NodeDataProvider;
34 class ShaderDataProvider;
35 class SamplerDataProvider;
36 class MaterialDataProvider;
37 class GeometryDataProvider;
41 * The new geometry renderer.
43 * @todo MESH_REWORK It will be merged into the base class eventually
45 class NewRenderer : public Renderer
48 typedef Integration::ResourceId ResourceId;
51 * Create a new renderer instance
52 * @param[in] nodeDataProvider The node data provider
53 * @param[in] geoemtryDataProvider The geometry data provider
54 * @param[in] materialDataProvider The material data provider
56 static NewRenderer* New( NodeDataProvider& nodeDataProvider,
57 const GeometryDataProvider* geometryDataProvider,
58 const MaterialDataProvider* materialDataProvider );
61 * @param[in] nodeDataProvider The node data provider
62 * @param[in] geoemtryDataProvider The geometry data provider
63 * @param[in] materialDataProvider The material data provider
65 NewRenderer( NodeDataProvider& nodeDataProvider,
66 const GeometryDataProvider* geometryDataProvider,
67 const MaterialDataProvider* materialDataProvider );
69 virtual ~NewRenderer();
72 * Change the geometry data provider of the renderer
73 * @param[in] geoemtryDataProvider The geometry data provider
75 void SetGeometryDataProvider( const GeometryDataProvider* geometryDataProvider );
78 * Change the material data provider of the renderer
79 * @param[in] materialDataProvider The material data provider
81 void SetMaterialDataProvider( const MaterialDataProvider* materialDataProvider );
83 public: // Implementation of Renderer
85 * @copydoc SceneGraph::Renderer::RequiresDepthTest()
87 virtual bool RequiresDepthTest() const;
90 * @copydoc SceneGraph::Renderer::CheckResources()
92 virtual bool CheckResources();
95 * @copydoc SceneGraph::Renderer::ResolveGeometryTypes()
97 virtual void ResolveGeometryTypes( BufferIndex bufferIndex,
98 GeometryType& outType,
99 ShaderSubTypes& outSubType );
102 * @copydoc SceneGraph::Renderer::IsOutsideClipSpace()
104 virtual bool IsOutsideClipSpace( const Matrix& modelMatrix,
105 const Matrix& modelViewProjectionMatrix );
108 * @copydoc SceneGraph::Renderer::DoRender()
110 virtual void DoRender( BufferIndex bufferIndex,
112 const Matrix& modelViewMatrix,
113 const Matrix& viewMatrix );
115 public: // Implementation of GlResourceOwner
118 * @copydoc Dali::Internal::GlResourceOwner::GlContextDestroyed()
120 virtual void GlContextDestroyed();
123 * @copydoc Dali::Internal::GlResourceOwner::GlCleanup()
125 virtual void GlCleanup();
129 * Set the uniforms from properties according to the uniform map
130 * @param[in] program The shader program on which to set the uniforms.
132 void SetUniforms( BufferIndex bufferIndex, Program& program );
135 * Bind the material textures in the samplers and setup the samplers
136 * @param[in] bufferIndex The buffer index
137 * @param[in] program The shader program
138 * @param[in] samplers The samplers to bind
140 void BindTextures( BufferIndex bufferIndex,
142 const MaterialDataProvider::Samplers& samplers );
145 * Bind a material texture to a texture unit, and set the sampler's texture uniform
146 * to that texture unit.
147 * @param[in] program The shader program
148 * @param[in] id The resource id of the texture to bind
149 * @param[in] texture The texture to bind
150 * @param[in] textureUnit The texture unit index to use
151 * @param[in] nameIndex The index of the texture uniform in the program
153 void BindTexture( Program& program,
156 TextureUnit textureUnit,
157 unsigned int nameIndex );
160 * Apply the sampler modes to the texture.
161 * @param[in] bufferIndex The current buffer index
162 * @param[in] texture The texture to which to apply the sampler modes
163 * @param[in] textureUnit The texture unit of the texture
164 * @param[in] sampler The sampler from which to get the modes.
166 void ApplySampler( BufferIndex bufferIndex,
168 TextureUnit textureUnit,
169 const SamplerDataProvider& sampler );
172 * Get the texture uniform index of the name sampler in the program.
173 * If not already registered in the program, then this performs the registration
174 * @param[in] program The shader program
175 * @param[in] sampler The sampler holding a texture unit uniform name to search for
176 * @return The texture uniform index in the program
178 unsigned int GetTextureUnitUniformIndex( Program& program,
179 const SamplerDataProvider& sampler );
183 // @todo MESH_REWORK Make private - add getters
184 //const NodeDataProvider& mNodeDataProvider;
185 //const ShaderDataProvider& mShaderDataProvider;
186 const MaterialDataProvider* mMaterialDataProvider;
187 const GeometryDataProvider* mGeometryDataProvider;
191 RenderGeometry mRenderGeometry;
193 struct TextureUnitUniformIndex
195 const SamplerDataProvider* sampler;
199 typedef Dali::Vector< TextureUnitUniformIndex > TextureUnitUniforms;
200 TextureUnitUniforms mTextureUnitUniforms;
208 #endif // __DALI_INTERNAL_SCENE_GRAPH_NEW_RENDERER_H__