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 Handle
56 * @brief An enumeration of properties belonging to the Geometry class.
62 GEOMETRY_TYPE = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "geometryType", type STRING
63 REQUIRES_DEPTH_TEST, ///< name "requiresDepthTesting", type BOOLEAN
68 * @brief Creates a new Geometry object
70 * @return An handle to a newly allocated Geometry
72 static Geometry New();
75 * @brief Default constructor, creates an empty handle
85 * @brief Copy constructor, creates a new handle to the same object
87 * @param[in] handle Handle to an object
89 Geometry( const Geometry& handle );
92 * @brief Downcast to a geometry.
94 * If not the returned handle is left uninitialized.
95 * @param[in] handle to an object
96 * @return geometry handle or an uninitialized handle
98 static Geometry DownCast( BaseHandle handle );
101 * @brief Assignment operator, changes this handle to point at the same object
103 * @param[in] handle Handle to an object
104 * @return Reference to the assigned object
106 Geometry& operator=( const Geometry& handle );
109 * @brief Add a PropertyBuffer to be used as source of geometry vertices
111 * @param[in] vertexBuffer PropertyBuffer to be used as source of geometry vertices
112 * @return Index of the newly added buffer, can be used with RemoveVertexBuffer to remove
113 * this buffer if no longer required
115 std::size_t AddVertexBuffer( PropertyBuffer& vertexBuffer );
118 * @brief Retrieve the number of vertex buffers that have been added to this geometry
120 * @return Number of vertex buffers that have been added to this geometry
122 std::size_t GetNumberOfVertexBuffers() const;
125 * @brief Remove a vertex buffer
127 * The index must be between 0 and GetNumberOfVertexBuffers()
129 * @param[in] index Index to the vertex buffer to remove
131 void RemoveVertexBuffer( std::size_t index );
134 * @brief Set a PropertyBuffer to be used as a source of indices for the geometry
136 * This buffer is required to have exactly one component and it must be of the type Property::INTEGER
138 * By setting this buffer the will case the geometry to be rendered using indices.
139 * To unset call SetIndexBuffer with an empty handle.
141 * @param[in] indexBuffer PropertyBuffer to be used as a source of indices for the geometry
143 void SetIndexBuffer( PropertyBuffer& indexBuffer );
146 * @brief Set the type of primitives this geometry contains
148 * @param[in] geometryType Type of primitives this geometry contains
150 void SetGeometryType( GeometryType geometryType );
153 * @brief Get the type of primitives this geometry contains
155 * Calling this function sets the property GEOMETRY_TYPE
157 * @return Type of primitives this geometry contains
159 GeometryType GetGeometryType() const;
162 * @brief Set if the geometry requires depth testing
164 * Should be set to true if this geometry has overlapping triangles in arbitrary order
166 * Calling this function is equivalent to setting the REQUIRES_DEPTH_TESTING property
168 * @param[in] requiresDepthTest Specifies if the geometry requires depth testing
170 void SetRequiresDepthTesting( bool requiresDepthTest );
173 * @brief Return if the geometry requires depth testing
175 * @return True if the geometry requires depth testing
177 bool GetRequiresDepthTesting() const;
181 * @brief The constructor
183 * @param [in] pointer A pointer to a newly allocated Geometry
185 explicit DALI_INTERNAL Geometry( Internal::Geometry* pointer );
190 #endif // DALI_GEOMETRY_H