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/integration-api/gl-defines.h>
22 #include <dali/internal/common/buffer-index.h>
23 #include <dali/internal/common/owner-container.h>
24 #include <dali/internal/common/owner-pointer.h>
25 #include <dali/internal/render/data-providers/render-data-provider.h>
26 #include <dali/internal/render/renderers/render-renderer-property-buffer.h>
38 class RenderDataProvider;
39 class GeometryDataProvider;
42 * This class encapsulates the GPU buffers. It is used to upload vertex data
43 * to it's GPU buffers, to bind all the buffers and to setup/teardown vertex attribute
51 * Constructor. Creates a render geometry object with no GPU buffers.
61 * Called on Gl Context created
63 void GlContextCreated( Context& context );
66 * Called on Gl Context destroyed.
68 void GlContextDestroyed();
71 * Upload the geometry if it has changed, set up the attributes and perform
72 * the Draw call corresponding to the geometry type
73 * @param[in] context The GL context
74 * @param[in] program The shader program to query for attribute locations
75 * @param[in] bufferIndex The current buffer index
76 * @param[in] dataProviders The data providers (to fetch geometry from)
78 void UploadAndDraw(Context& context,
80 BufferIndex bufferIndex,
81 const RenderDataProvider* dataProviders );
84 * Tell the object that the geometry has been updated.
85 * It will be uploaded on the next UploadAndDraw call.
87 void GeometryUpdated();
90 * Upload the vertex data if it needs uploading.
91 * @param[in] context The GL context
92 * @param[in] bufferIndex The current buffer index
93 * @param[in] geometryDataProvider The geometry data provider (to fetch geometry from)
95 void UploadVertexData( Context& context,
97 BufferIndex bufferIndex,
98 const RenderDataProvider* dataProviders );
102 * Perform the upload of the geometry
103 * @param[in] context The GL context
104 * @param[in] bufferIndex The current buffer index
105 * @param[in] dataProviders The data providers (to fetch geometry from)
107 void SetUpPropertyBuffers( Context& context,
108 BufferIndex bufferIndex,
109 const RenderDataProvider* dataProviders );
112 * Bind the geometry buffers
113 * @param[in] context The GL context
114 * @param[in] bufferIndex The current buffer index
115 * @param[in] program The shader program to query for attribute locations
117 void BindBuffers( Context& context,
118 BufferIndex bufferIndex,
122 * Enable the vertex attributes for each vertex buffer from the corresponding
124 * @param[in] context The GL context
125 * @param[in] bufferIndex The current buffer index
126 * @param[in] program The shader program to query for attribute locations
128 void EnableVertexAttributes( Context& context, BufferIndex bufferIndex, Program& progam );
131 * Disable the vertex attributes for each vertex buffer from the corresponding
133 * @param[in] context The GL context
134 * @param[in] bufferIndex The current buffer index
135 * @param[in] program The shader program to query for attribute locations
137 void DisableVertexAttributes( Context& context, BufferIndex bufferIndex, Program& program );
140 * Perform the correct 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] dataProviders The data providers (to fetch geometry from)
145 void Draw( Context& context,
146 BufferIndex bufferIndex,
147 const RenderDataProvider* dataProviders );
151 OwnerPointer< RenderPropertyBuffer > mIndexBuffer;
152 OwnerContainer< RenderPropertyBuffer* > mVertexBuffers;
155 bool mDataNeedsUploading;
159 } // namespace SceneGraph
160 } // namespace Internal
163 #endif // DALI_INTERNAL_SCENE_GRAPH_SAMPLER_DATA_PROVIDER_H