1 #ifndef DALI_INTERNAL_RENDER_GEOMETRY_H
2 #define DALI_INTERNAL_RENDER_GEOMETRY_H
5 * Copyright (c) 2018 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.
21 #include <dali/public-api/common/dali-vector.h>
22 #include <dali/public-api/rendering/geometry.h>
23 #include <dali/devel-api/common/owner-container.h>
24 #include <dali/internal/common/owner-pointer.h>
25 #include <dali/internal/common/buffer-index.h>
26 #include <dali/internal/common/owner-pointer.h>
27 #include <dali/integration-api/gl-abstraction.h>
28 #include <dali/integration-api/gl-defines.h>
43 * This class encapsulates the GPU buffers. It is used to upload vertex data
44 * to it's GPU buffers, to bind all the buffers and to setup/teardown vertex attribute
50 typedef Dali::Geometry::Type Type;
60 * Called on Gl Context created
62 void GlContextCreated( Context& context );
65 * Called on Gl Context destroyed.
67 void GlContextDestroyed();
70 * Adds a property buffer to the geometry
71 * @param[in] dataProvider The PropertyBuffer data provider
73 void AddPropertyBuffer( Render::PropertyBuffer* propertyBuffer );
76 * Set the data for the index buffer to be used by the geometry
77 * @param[in] indices A vector containing the indices
79 void SetIndexBuffer( Dali::Vector<uint16_t>& indices );
82 * Removes a PropertyBuffer from the geometry
83 * @param[in] propertyBuffer The property buffer to be removed
85 void RemovePropertyBuffer( const Render::PropertyBuffer* propertyBuffer );
88 * Gets the attribute locations on the shader for the attributes defined in the geometry RenderBuffers
89 * @param[out] attributeLocation The vector where the attributes locations will be stored
90 * @param[in] program The program
91 * @param[in] bufferIndex The current buffer index
93 void GetAttributeLocationFromProgram( Vector<GLint>& attributeLocation, Program& program, BufferIndex bufferIndex ) const;
96 * Called from RenderManager to notify the geometry that current rendering pass has finished.
98 void OnRenderFinished();
101 * Check if the attributes for the geometry have changed
102 * @return True if vertex buffers have been added or removed since last frame, false otherwise
104 bool AttributesChanged() const
106 return mAttributesChanged;
110 * Sets the geometry type
111 * @param[in] type The new geometry type
113 void SetType( Type type )
115 mGeometryType = type;
119 * Upload the geometry if it has changed
120 * @param[in] context The GL context
122 void Upload( Context& context );
125 * Set up the attributes and perform the Draw call corresponding to the geometry type
126 * @param[in] context The GL context
127 * @param[in] bufferIndex The current buffer index
128 * @param[in] attributeLocation The location for the attributes in the shader
129 * @param[in] elementBufferOffset The index of first element to draw if index buffer bound
130 * @param[in] elementBufferCount Number of elements to draw if index buffer bound, uses whole buffer when 0
132 void Draw(Context& context,
133 BufferIndex bufferIndex,
134 Vector<GLint>& attributeLocation,
135 uint32_t elementBufferOffset,
136 uint32_t elementBufferCount );
141 Vector< Render::PropertyBuffer* > mVertexBuffers;
143 Dali::Vector< uint16_t > mIndices;
144 OwnerPointer< GpuBuffer > mIndexBuffer;
148 bool mIndicesChanged : 1;
149 bool mHasBeenUpdated : 1;
150 bool mAttributesChanged : 1;
153 } // namespace Render
154 } // namespace Internal
157 #endif // DALI_INTERNAL_RENDER_GEOMETRY_H