1 #ifndef DALI_GEOMETRY_H
2 #define DALI_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.
22 #include <cstddef> // std::size_t
23 #include <cstdint> // uint16_t
26 #include <dali/public-api/object/handle.h> // Dali::Handle
27 #include <dali/public-api/object/property-index-ranges.h> // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX
28 #include <dali/public-api/rendering/property-buffer.h> // Dali::PropertyBuffer
33 namespace Internal DALI_INTERNAL
39 * @brief Geometry is handle to an object that can be used to define a geometric elements.
43 class DALI_CORE_API Geometry : public BaseHandle
48 * @brief Enumeration for the description of the type of geometry, used to determine how the coordinates will be used.
53 POINTS, ///< Individual points @SINCE_1_1.45
54 LINES, ///< Individual lines (made of 2 points each) @SINCE_1_1.45
55 LINE_LOOP, ///< A strip of lines (made of 1 point each) which also joins the first and last point @SINCE_1_1.45
56 LINE_STRIP, ///< A strip of lines (made of 1 point each) @SINCE_1_1.45
57 TRIANGLES, ///< Individual triangles (made of 3 points each) @SINCE_1_1.45
58 TRIANGLE_FAN, ///< A fan of triangles around a centre point (after the first triangle, following triangles need only 1 point) @SINCE_1_1.45
59 TRIANGLE_STRIP ///< A strip of triangles (after the first triangle, following triangles need only 1 point) @SINCE_1_1.45
64 * @brief Creates a new Geometry object.
67 * @return A handle to a newly allocated Geometry object
69 static Geometry New();
72 * @brief Default constructor, creates an empty handle.
86 * @brief Copy constructor, creates a new handle to the same object.
89 * @param[in] handle Handle to an object
91 Geometry( const Geometry& handle );
94 * @brief Downcasts to a geometry.
95 * If not, the returned handle is left uninitialized.
98 * @param[in] handle Handle to an object
99 * @return Geometry handle or an uninitialized handle
101 static Geometry DownCast( BaseHandle handle );
104 * @brief Assignment operator, changes this handle to point at the same object.
107 * @param[in] handle Handle to an object
108 * @return Reference to the assigned object
110 Geometry& operator=( const Geometry& handle );
113 * @brief Adds a PropertyBuffer to be used as source of geometry vertices.
116 * @param[in] vertexBuffer PropertyBuffer to be used as source of geometry vertices
117 * @return Index of the newly added buffer, can be used with RemoveVertexBuffer to remove
118 * this buffer if no longer required
120 std::size_t AddVertexBuffer( PropertyBuffer& vertexBuffer );
123 * @brief Retrieves the number of vertex buffers that have been added to this geometry.
126 * @return Number of vertex buffers that have been added to this geometry
128 std::size_t GetNumberOfVertexBuffers() const;
131 * @brief Removes a vertex buffer.
132 * The index must be between 0 and GetNumberOfVertexBuffers().
135 * @param[in] index Index to the vertex buffer to remove
137 void RemoveVertexBuffer( std::size_t index );
140 * @brief Sets a the index data to be used as a source of indices for the geometry
141 * Setting this buffer will cause the geometry to be rendered using indices.
142 * To unset call SetIndexBuffer with a null pointer or count 0.
145 * @param[in] indices Array of indices
146 * @param[in] count Number of indices in the array
148 void SetIndexBuffer( const uint16_t* indices, size_t count );
151 * @brief Sets the type of primitives this geometry contains.
154 * @param[in] geometryType Type of primitives this geometry contains
156 void SetType( Type geometryType );
159 * @brief Gets the type of primitives this geometry contains.
160 * Calling this function sets the property GEOMETRY_TYPE.
163 * @return Type of primitives this geometry contains
165 Type GetType() const;
170 * @brief The constructor.
171 * @note Not intended for application developers.
173 * @param[in] pointer A pointer to a newly allocated Geometry
175 explicit DALI_INTERNAL Geometry( Internal::Geometry* pointer );
180 #endif // DALI_GEOMETRY_H