1 #ifndef DALI_GEOMETRY_H
2 #define DALI_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.
22 #include <cstddef> // std::size_t
25 #include <dali/public-api/object/handle.h> // Dali::Handle
26 #include <dali/public-api/object/property-index-ranges.h> // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX
27 #include <dali/devel-api/object/property-buffer.h> // Dali::PropertyBuffer
32 namespace Internal DALI_INTERNAL
38 * @brief Geometry is handle to an object that can be used to define a geometric elements.
40 class DALI_IMPORT_API Geometry : public BaseHandle
57 * @brief Creates a new Geometry object
59 * @return An handle to a newly allocated Geometry
61 static Geometry New();
64 * @brief Default constructor, creates an empty handle
74 * @brief Copy constructor, creates a new handle to the same object
76 * @param[in] handle Handle to an object
78 Geometry( const Geometry& handle );
81 * @brief Downcast to a geometry.
83 * If not the returned handle is left uninitialized.
84 * @param[in] handle to an object
85 * @return geometry handle or an uninitialized handle
87 static Geometry DownCast( BaseHandle handle );
90 * @brief Assignment operator, changes this handle to point at the same object
92 * @param[in] handle Handle to an object
93 * @return Reference to the assigned object
95 Geometry& operator=( const Geometry& handle );
98 * @brief Add a PropertyBuffer to be used as source of geometry vertices
100 * @param[in] vertexBuffer PropertyBuffer to be used as source of geometry vertices
101 * @return Index of the newly added buffer, can be used with RemoveVertexBuffer to remove
102 * this buffer if no longer required
104 std::size_t AddVertexBuffer( PropertyBuffer& vertexBuffer );
107 * @brief Retrieve the number of vertex buffers that have been added to this geometry
109 * @return Number of vertex buffers that have been added to this geometry
111 std::size_t GetNumberOfVertexBuffers() const;
114 * @brief Remove a vertex buffer
116 * The index must be between 0 and GetNumberOfVertexBuffers()
118 * @param[in] index Index to the vertex buffer to remove
120 void RemoveVertexBuffer( std::size_t index );
123 * @brief Set a the index data to be used as a source of indices for the geometry
125 * Setting this buffer will cause the geometry to be rendered using indices.
126 * To unset call SetIndexBuffer with a null pointer or count 0
128 * @param[in] indices Array of indices
129 * @param[in] count Number of indices in the array
131 void SetIndexBuffer( const unsigned short* indices, size_t count );
134 * @brief Set the type of primitives this geometry contains
136 * @param[in] geometryType Type of primitives this geometry contains
138 void SetGeometryType( GeometryType geometryType );
141 * @brief Get the type of primitives this geometry contains
143 * Calling this function sets the property GEOMETRY_TYPE
145 * @return Type of primitives this geometry contains
147 GeometryType GetGeometryType() const;
150 * @brief Unit quad geometry.
152 * The quad has its four corners located at [-0.5, -0.5], [-0.5, 0.5], [0.5, -0.5] and [0.5, 0.5].
153 * The attribute name for vertex position is 'aPosition'.
155 * @return The quad geometry.
157 static Geometry QUAD();
161 * @brief The constructor
163 * @param [in] pointer A pointer to a newly allocated Geometry
165 explicit DALI_INTERNAL Geometry( Internal::Geometry* pointer );
170 #endif // DALI_GEOMETRY_H