// Create indices
unsigned int numIndices = 2 * 3 * NUM_GRADIENT_INTERVALS;
- unsigned int indices[ numIndices ];
+ unsigned short indices[ numIndices ];
- unsigned int* currentIndex = indices;
+ unsigned short* currentIndex = indices;
for( int y = 0; y < NUM_GRADIENT_INTERVALS; ++y )
{
*currentIndex++ = (2 * y);
Dali::PropertyBuffer vertexPropertyBuffer = Dali::PropertyBuffer::New( vertexFormat );
vertexPropertyBuffer.SetData( vertices, numVertices );
- Dali::Property::Map indexFormat;
- indexFormat[ "indices" ] = Dali::Property::INTEGER;
- Dali::PropertyBuffer indexPropertyBuffer = Dali::PropertyBuffer::New( indexFormat );
- indexPropertyBuffer.SetData( indices, numIndices );
-
// Create the geometry object
mTranslucentGeometry = Dali::Geometry::New();
mTranslucentGeometry.AddVertexBuffer( vertexPropertyBuffer );
- mTranslucentGeometry.SetIndexBuffer( indexPropertyBuffer );
+ mTranslucentGeometry.SetIndexBuffer( &indices[0], numIndices );
}
return mTranslucentGeometry;
{ Vector2( -0.5f, 0.5f ), 1.0f }, { Vector2( 0.5f, 0.5f ), 1.0f } };
// Create indices
- unsigned int indices[ 6 ] = { 0, 3, 1, 0, 2, 3 };
+ unsigned short indices[ 6 ] = { 0, 3, 1, 0, 2, 3 };
Dali::Property::Map vertexFormat;
vertexFormat[ "aPosition" ] = Dali::Property::VECTOR2;
Dali::PropertyBuffer vertexPropertyBuffer = Dali::PropertyBuffer::New( vertexFormat );
vertexPropertyBuffer.SetData( vertices, 4 );
- Dali::Property::Map indexFormat;
- indexFormat[ "indices" ] = Dali::Property::INTEGER;
- Dali::PropertyBuffer indexPropertyBuffer = Dali::PropertyBuffer::New( indexFormat );
- indexPropertyBuffer.SetData( indices, 6 );
// Create the geometry object
mSolidGeometry = Dali::Geometry::New();
mSolidGeometry.AddVertexBuffer( vertexPropertyBuffer );
- mSolidGeometry.SetIndexBuffer( indexPropertyBuffer );
+ mSolidGeometry.SetIndexBuffer( &indices[0], 6 );
}
return mSolidGeometry;
#include "actor-wrapper.h"
#include "animation-wrapper.h"
#include "emscripten-utils.h"
+#include "geometry-wrapper.h"
#include "handle-wrapper.h"
#include "image-wrapper.h"
#include "property-buffer-wrapper.h"
.constructor<>(&Dali::Geometry::New)
.function("addVertexBuffer", &Dali::Geometry::AddVertexBuffer)
.function("getNumberOfVertexBuffers", &Dali::Geometry::GetNumberOfVertexBuffers)
- .function("setIndexBuffer", &Dali::Geometry::SetIndexBuffer)
+ .function("setIndexBuffer", &SetIndexBufferDataRaw)
.function("setGeometryType", &Dali::Geometry::SetGeometryType)
.function("getGeometryType", &Dali::Geometry::GetGeometryType)
.function("setRequiresDepthTesting", &Dali::Geometry::SetRequiresDepthTesting)
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "geometry-wrapper.h"
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Emscripten
+{
+
+void SetIndexBufferDataRaw(Dali::Geometry& self, const std::string& data, std::size_t size )
+{
+ self.SetIndexBuffer( reinterpret_cast<unsigned short*>( const_cast<char*>(data.c_str()) ), size );
+}
+
+}; // namespace Emscripten
+}; // namespace Internal
+}; // namespace Dali
--- /dev/null
+#ifndef __DALI_GEOMETRY_WRAPPER_H__
+#define __DALI_GEOMETRY_WRAPPER_H__
+
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/dali-core.h>
+#include <dali/devel-api/rendering/geometry.h>
+#include "emscripten/emscripten.h"
+#include "emscripten/val.h"
+#include "emscripten/bind.h"
+
+// INTERNAL INCLUDES
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Emscripten
+{
+
+/**
+ * Sets the index buffer
+ *
+ * @param[in] self The Geometry
+ * @param[in] data The raw byte data
+ *
+ */
+void SetIndexBufferDataRaw(Dali::Geometry& self, const std::string& data, std::size_t size );
+
+}; // namespace Emscripten
+}; // namespace Internal
+}; // namespace Dali
+
+#endif // header
{ Vector2( halfQuadSize, halfQuadSize), Vector2(1.f, 1.f) } };
vertexData.SetData(texturedQuadVertexData, 4);
- unsigned int indexData[6] = { 0, 3, 1, 0, 2, 3 };
- Property::Map indexFormat;
- indexFormat["indices"] = Property::INTEGER;
- PropertyBuffer indices = PropertyBuffer::New( indexFormat );
- indices.SetData( indexData, sizeof(indexData)/sizeof(indexData[0]) );
+ unsigned short indexData[6] = { 0, 3, 1, 0, 2, 3 };
Geometry geometry = Geometry::New();
geometry.AddVertexBuffer( vertexData );
- geometry.SetIndexBuffer( indices );
+ geometry.SetIndexBuffer( indexData, sizeof(indexData)/sizeof(indexData[0]) );
return geometry;
}