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>
23 #include <dali/internal/render/data-providers/render-data-provider.h>
35 class RenderDataProvider;
36 class GeometryDataProvider;
39 * This class encapsulates the GPU buffers. It is used to upload vertex data
40 * to it's GPU buffers, to bind all the buffers and to setup/teardown vertex attribute
46 typedef OwnerContainer< GpuBuffer* > GpuBuffers;
49 * Constructor. Creates a render geometry object with no GPU buffers.
59 * Called on Gl Context created
61 void GlContextCreated( Context& context );
64 * Called on Gl Context destroyed.
66 void GlContextDestroyed();
69 * Upload the geometry if it has changed, set up the attributes and perform
70 * the Draw call corresponding to the geometry type
71 * @param[in] context The GL context
72 * @param[in] program The shader program to query for attribute locations
73 * @param[in] bufferIndex The current buffer index
74 * @param[in] dataProviders The data providers (to fetch geometry from)
76 void UploadAndDraw(Context& context,
78 BufferIndex bufferIndex,
79 const RenderDataProvider* dataProviders );
82 * Tell the object that the geometry has been updated.
83 * It will be uploaded on the next UploadAndDraw call.
85 void GeometryUpdated();
88 * Upload the vertex data if it needs uploading.
89 * @param[in] context The GL context
90 * @param[in] bufferIndex The current buffer index
91 * @param[in] geometryDataProvider The geometry data provider (to fetch geometry from)
93 void UploadVertexData( Context& context,
94 BufferIndex bufferIndex,
95 const RenderDataProvider* dataProviders );
99 * Perform the upload of the geometry
100 * @param[in] context The GL context
101 * @param[in] bufferIndex The current buffer index
102 * @param[in] dataProviders The data providers (to fetch geometry from)
104 void DoUpload( Context& context,
105 BufferIndex bufferIndex,
106 const RenderDataProvider* dataProviders );
109 * Bind the geometry buffers
114 * Enable the vertex attributes for each vertex buffer from the corresponding
116 * @param[in] context The GL context
117 * @param[in] program The shader program to query for attribute locations
119 void EnableVertexAttributes( Context& context, Program& progam );
122 * Disable the vertex attributes for each vertex buffer from the corresponding
124 * @param[in] context The GL context
125 * @param[in] program The shader program to query for attribute locations
127 void DisableVertexAttributes( Context& context, Program& program );
130 * Perform the correct draw call corresponding to the geometry type
131 * @param[in] context The GL context
132 * @param[in] bufferIndex The current buffer index
133 * @param[in] dataProviders The data providers (to fetch geometry from)
135 void Draw( Context& context,
136 BufferIndex bufferIndex,
137 const RenderDataProvider* dataProviders );
140 GpuBuffers mVertexBuffers;
141 OwnerPointer< GpuBuffer > mIndexBuffer;
143 bool mDataNeedsUploading;
146 } // namespace SceneGraph
147 } // namespace Internal
150 #endif // DALI_INTERNAL_SCENE_GRAPH_SAMPLER_DATA_PROVIDER_H