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/internal/common/buffer-index.h>
21 #include <dali/internal/common/owner-container.h>
22 #include <dali/internal/common/owner-pointer.h>
34 class GeometryDataProvider;
37 * This class encapsulates the GPU buffers. It is used to upload vertex data
38 * to it's GPU buffers, to bind all the buffers and to setup/teardown vertex attribute
44 typedef OwnerContainer< GpuBuffer* > GpuBuffers;
47 * Constructor. Creates a render geometry object with no GPU buffers.
57 * Called on Gl Context created
59 void GlContextCreated( Context& context );
62 * Called on Gl Context destroyed.
64 void GlContextDestroyed();
67 * Upload the geometry if it has changed, set up the attributes and perform
68 * the Draw call corresponding to the geometry type
69 * @param[in] context The GL context
70 * @param[in] program The shader program to query for attribute locations
71 * @param[in] bufferIndex The current buffer index
72 * @param[in] geometryDataProvider The geometry data provider (to fetch geometry from)
74 void UploadAndDraw(Context& context,
76 BufferIndex bufferIndex,
77 const GeometryDataProvider& geometryDataProvider );
80 * Tell the object that the geometry has been updated.
81 * It will be uploaded on the next UploadAndDraw call.
83 void GeometryUpdated();
86 * Upload the vertex data if it needs uploading.
87 * @param[in] context The GL context
88 * @param[in] bufferIndex The current buffer index
89 * @param[in] geometryDataProvider The geometry data provider (to fetch geometry from)
91 void UploadVertexData( Context& context,
92 BufferIndex bufferIndex,
93 const GeometryDataProvider& geometryDataProvider );
98 * Perform the upload of the geometry
99 * @param[in] context The GL context
100 * @param[in] bufferIndex The current buffer index
101 * @param[in] geometryDataProvider The geometry data provider (to fetch geometry from)
103 void DoUpload( Context& context,
104 BufferIndex bufferIndex,
105 const GeometryDataProvider& geometryDataProvider );
108 * Bind the geometry buffers
113 * Enable the vertex attributes for each vertex buffer from the corresponding
115 * @param[in] context The GL context
116 * @param[in] program The shader program to query for attribute locations
118 void EnableVertexAttributes( Context& context, Program& progam );
121 * Disable the vertex attributes for each vertex buffer from the corresponding
123 * @param[in] context The GL context
124 * @param[in] program The shader program to query for attribute locations
126 void DisableVertexAttributes( Context& context, Program& program );
129 * Perform the correct draw call corresponding to the geometry type
130 * @param[in] context The GL context
131 * @param[in] bufferIndex The current buffer index
132 * @param[in] geometryDataProvider The geometry data provider (to fetch geometry from)
134 void Draw( Context& context,
135 BufferIndex bufferIndex,
136 const GeometryDataProvider& geometry );
139 GpuBuffers mVertexBuffers;
140 OwnerPointer< GpuBuffer > mIndexBuffer;
142 bool mDataNeedsUploading;
145 } // namespace SceneGraph
146 } // namespace Internal
149 #endif // DALI_INTERNAL_SCENE_GRAPH_SAMPLER_DATA_PROVIDER_H