1 #ifndef DALI_INTERNAL_SCENE_GRAPH_RENDER_GEOMETRY_H
2 #define DALI_INTERNAL_SCENE_GRAPH_RENDER_GEOMETRY_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.
20 #include <dali/public-api/common/dali-vector.h>
21 #include <dali/devel-api/common/owner-container.h>
22 #include <dali/integration-api/gl-defines.h>
23 #include <dali/internal/common/buffer-index.h>
24 #include <dali/internal/common/owner-pointer.h>
25 #include <dali/integration-api/gl-abstraction.h>
26 #include <dali/internal/update/rendering/scene-graph-geometry.h>
45 * This class encapsulates the GPU buffers. It is used to upload vertex data
46 * to it's GPU buffers, to bind all the buffers and to setup/teardown vertex attribute
53 typedef SceneGraph::Geometry::GeometryType GeometryType;
55 * Constructor. Creates a render geometry object with no GPU buffers.
56 * @param[in] center The center of the geometry
57 * @param[in] geometryType The geometry type
58 * @param[in] requiresDepthTest True if geometry requires depth testing, false otherwise
60 RenderGeometry( GeometryType geometryType, bool requiresDepthTest );
67 * Called on Gl Context created
69 void GlContextCreated( Context& context );
72 * Called on Gl Context destroyed.
74 void GlContextDestroyed();
77 * Adds a property buffer to the geometry
78 * @param[in] dataProvider The PropertyBuffer data provider
79 * @param[in] isIndexBuffer True if the property buffer is intended to be used as an index buffer
81 void AddPropertyBuffer( Render::PropertyBuffer* propertyBuffer, bool isIndexBuffer );
84 * Removes a PropertyBuffer from the geometry
85 * @param[in] propertyBuffer The property buffer to be removed
87 void RemovePropertyBuffer( const Render::PropertyBuffer* propertyBuffer );
90 * Gets the attribute locations on the shader for the attributes defined in the geometry RenderBuffers
91 * @param[out] attributeLocation The vector where the attributes locations will be stored
92 * @param[in] program The program
93 * @param[in] bufferIndex The current buffer index
95 void GetAttributeLocationFromProgram( Vector<GLint>& attributeLocation, Program& program, BufferIndex bufferIndex ) const;
98 * Called from RenderManager to notify the geometry that current rendering pass has finished.
100 void OnRenderFinished();
103 * Chack if the attributes for the geometry have changed
104 * @return True if vertex buffers have been added or removed since last frame, false otherwise
106 bool AttributesChanged() const
108 return mAttributesChanged;
112 * Sets the geometry type
113 * @param[in] type The new geometry type
115 void SetGeometryType( GeometryType type )
117 mGeometryType = type;
121 * Sets if the geometry requires depth testing
122 * @param[in] requiresDepthTest True if depth testing is required, false otherwise
124 void SetRequiresDepthTest( bool requiresDepthTest )
126 mRequiresDepthTest = requiresDepthTest;
130 * Check if geometry requires depth testing
131 * @return True if depth testing is required, false otherwise
133 bool RequiresDepthTest() const
135 return mRequiresDepthTest;
139 * Upload the geometry if it has changed, set up the attributes and perform
140 * the Draw call corresponding to the geometry type
141 * @param[in] context The GL context
142 * @param[in] bufferIndex The current buffer index
143 * @param[in] attributeLocation The location for the attributes in the shader
145 void UploadAndDraw(Context& context,
146 BufferIndex bufferIndex,
147 Vector<GLint>& attributeLocation );
152 Render::PropertyBuffer* mIndexBuffer;
153 Vector<Render::PropertyBuffer*> mVertexBuffers;
155 GeometryType mGeometryType;
158 bool mRequiresDepthTest : 1;
159 bool mHasBeenUpdated : 1;
160 bool mAttributesChanged : 1;
164 } // namespace SceneGraph
165 } // namespace Internal
168 #endif // DALI_INTERNAL_SCENE_GRAPH_SAMPLER_DATA_PROVIDER_H