/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * 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.
* limitations under the License.
*
*/
+
+// CLASS HEADER
#include "mesh-builder.h"
+// EXTERNAL INCLUDES
+#include <dali/devel-api/images/texture-set-image.h>
+
namespace Dali
{
-Material CreateMaterial(float opacity)
+Shader CreateShader()
{
- Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
- Material material = Material::New(shader);
+ return Shader::New( "vertexSrc", "fragmentSrc" );
+}
- Vector4 color = Color::WHITE;
- color.a = opacity;
- material.SetProperty(Material::Property::COLOR, color);
- return material;
+TextureSet CreateTextureSet()
+{
+ return TextureSet::New();
}
-Geometry CreateQuadGeometry()
+TextureSet CreateTextureSet( Image image )
+{
+ TextureSet textureSet = TextureSet::New();
+ TextureSetImage( textureSet, 0u, image );
+ return textureSet;
+}
+
+PropertyBuffer CreatePropertyBuffer()
{
Property::Map texturedQuadVertexFormat;
texturedQuadVertexFormat["aPosition"] = Property::VECTOR2;
texturedQuadVertexFormat["aVertexCoord"] = Property::VECTOR2;
- PropertyBuffer vertexData = PropertyBuffer::New( PropertyBuffer::STATIC,
- texturedQuadVertexFormat, 4 );
+ PropertyBuffer vertexData = PropertyBuffer::New( texturedQuadVertexFormat );
+ return vertexData;
+}
+Geometry CreateQuadGeometry(void)
+{
+ PropertyBuffer vertexData = CreatePropertyBuffer();
const float halfQuadSize = .5f;
struct TexturedQuadVertex { Vector2 position; Vector2 textureCoordinates; };
TexturedQuadVertex texturedQuadVertexData[4] = {
{ Vector2( halfQuadSize, -halfQuadSize), Vector2(1.f, 0.f) },
{ Vector2(-halfQuadSize, halfQuadSize), Vector2(0.f, 1.f) },
{ Vector2( halfQuadSize, halfQuadSize), Vector2(1.f, 1.f) } };
- vertexData.SetData(texturedQuadVertexData);
+ vertexData.SetData(texturedQuadVertexData, 4);
unsigned short indexData[6] = { 0, 3, 1, 0, 2, 3 };
- Property::Map indexFormat;
- indexFormat["indices"] = Property::UNSIGNED_INTEGER; // Should be Unsigned Short
- PropertyBuffer indices = PropertyBuffer::New( PropertyBuffer::STATIC, indexFormat, 3 );
- indices.SetData(indexData);
Geometry geometry = Geometry::New();
geometry.AddVertexBuffer( vertexData );
- geometry.SetIndexBuffer( indices );
+ geometry.SetIndexBuffer( indexData, sizeof(indexData)/sizeof(indexData[0]) );
return geometry;
}