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,
96 BufferIndex bufferIndex,
97 const RenderDataProvider* dataProviders );
101 * Perform the upload of the geometry
102 * @param[in] context The GL context
103 * @param[in] bufferIndex The current buffer index
104 * @param[in] dataProviders The data providers (to fetch geometry from)
106 void DoUpload( Context& context,
107 BufferIndex bufferIndex,
108 const RenderDataProvider* dataProviders );
111 * Bind the geometry buffers
112 * @param[in] context The GL context
113 * @param[in] bufferIndex The current buffer index
114 * @param[in] program The shader program to query for attribute locations
116 void BindBuffers( Context& context,
117 BufferIndex bufferIndex,
121 * Enable the vertex attributes for each vertex buffer from the corresponding
123 * @param[in] context The GL context
124 * @param[in] bufferIndex The current buffer index
125 * @param[in] program The shader program to query for attribute locations
127 void EnableVertexAttributes( Context& context, BufferIndex bufferIndex, Program& progam );
130 * Disable the vertex attributes for each vertex buffer from the corresponding
132 * @param[in] context The GL context
133 * @param[in] bufferIndex The current buffer index
134 * @param[in] program The shader program to query for attribute locations
136 void DisableVertexAttributes( Context& context, BufferIndex bufferIndex, Program& program );
139 * Perform the correct draw call corresponding to the geometry type
140 * @param[in] context The GL context
141 * @param[in] bufferIndex The current buffer index
142 * @param[in] dataProviders The data providers (to fetch geometry from)
144 void Draw( Context& context,
145 BufferIndex bufferIndex,
146 const RenderDataProvider* dataProviders );
150 OwnerPointer< RenderPropertyBuffer > mIndexBuffer;
151 OwnerContainer< RenderPropertyBuffer* > mVertexBuffers;
154 bool mDataNeedsUploading;
158 } // namespace SceneGraph
159 } // namespace Internal
162 #endif // DALI_INTERNAL_SCENE_GRAPH_SAMPLER_DATA_PROVIDER_H