/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
*/
// EXTERNAL INCLUDES
-#include <dali/devel-api/rendering/renderer.h>
#include <dali-toolkit/dali-toolkit.h>
#include <stdio.h>
#include <sstream>
// INTERNAL INCLUDES
#include "shared/view.h"
+#include "shared/utility.h"
using namespace Dali;
namespace
{
-const char* MATERIAL_SAMPLES[] =
+const char* IMAGES[] =
{
- DALI_IMAGE_DIR "people-medium-1.jpg",
- DALI_IMAGE_DIR "people-medium-4.jpg",
- DALI_IMAGE_DIR "people-medium-11.jpg",
- DALI_IMAGE_DIR "people-small-16.jpg",
- DALI_IMAGE_DIR "people-medium-15.jpg",
- DALI_IMAGE_DIR "people-medium-6.jpg",
+ DEMO_IMAGE_DIR "people-medium-1.jpg",
+ DEMO_IMAGE_DIR "people-medium-4.jpg",
+ DEMO_IMAGE_DIR "people-medium-11.jpg",
+ DEMO_IMAGE_DIR "people-small-16.jpg",
+ DEMO_IMAGE_DIR "people-medium-15.jpg",
+ DEMO_IMAGE_DIR "people-medium-6.jpg",
};
-const unsigned int NUMBER_OF_SAMPLES(sizeof(MATERIAL_SAMPLES)/sizeof(const char*));
+const unsigned int NUMBER_OF_SAMPLES(sizeof(IMAGES)/sizeof(const char*));
#define MAKE_SHADER(A)#A
}
);
-Geometry CreateGeometry()
-{
- // Create vertices
- const float halfQuadSize = .5f;
- struct TexturedQuadVertex { Vector2 position; Vector2 textureCoordinates; };
- TexturedQuadVertex texturedQuadVertexData[4] = {
- { Vector2(-halfQuadSize, -halfQuadSize), Vector2(0.f, 0.f) },
- { Vector2( halfQuadSize, -halfQuadSize), Vector2(1.f, 0.f) },
- { Vector2(-halfQuadSize, halfQuadSize), Vector2(0.f, 1.f) },
- { Vector2( halfQuadSize, halfQuadSize), Vector2(1.f, 1.f) } };
-
- Property::Map texturedQuadVertexFormat;
- texturedQuadVertexFormat["aPosition"] = Property::VECTOR2;
- texturedQuadVertexFormat["aTexCoord"] = Property::VECTOR2;
- PropertyBuffer texturedQuadVertices = PropertyBuffer::New( texturedQuadVertexFormat, 4 );
- texturedQuadVertices.SetData(texturedQuadVertexData);
-
- // Create indices
- unsigned int indexData[6] = { 0, 3, 1, 0, 2, 3 };
- Property::Map indexFormat;
- indexFormat["indices"] = Property::UNSIGNED_INTEGER;
- PropertyBuffer indices = PropertyBuffer::New( indexFormat, 6 );
- indices.SetData(indexData);
-
- // Create the geometry object
- Geometry texturedQuadGeometry = Geometry::New();
- texturedQuadGeometry.AddVertexBuffer( texturedQuadVertices );
- texturedQuadGeometry.SetIndexBuffer( indices );
-
- return texturedQuadGeometry;
-}
-
} // anonymous namespace
// This example shows how to use a simple mesh
application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE );
mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
- mGeometry = CreateGeometry();
+ mGeometry = DemoHelper::CreateTexturedQuad();
- Material firstMat;
+ TextureSet firstTextureSet;
for( unsigned i=0; i<NUMBER_OF_SAMPLES; ++i)
{
- Image image = ResourceImage::New( MATERIAL_SAMPLES[i] );
- Sampler sampler = Sampler::New(image, "sTexture");
- Material material = Material::New( mShader );
- material.AddSampler( sampler );
- if( i==0 ) { firstMat = material; }
+ Texture texture = DemoHelper::LoadTexture( IMAGES[i] );
+ TextureSet textureSet = TextureSet::New();
+ textureSet.SetTexture( 0u, texture );
+ if( i==0 ) { firstTextureSet = textureSet; }
- Renderer renderer = Renderer::New( mGeometry, material );
+ Renderer renderer = Renderer::New( mGeometry, mShader );
+ renderer.SetTextures( textureSet );
Actor meshActor = Actor::New();
mActors[i] = meshActor;
meshActor.AddRenderer( renderer );
meshActor.SetSize(175, 175);
meshActor.RegisterProperty("index", (int)i);
- renderer.SetDepthIndex(0);
+ renderer.SetProperty( Renderer::Property::DEPTH_INDEX, 0 );
// Test with actor alpha
meshActor.SetParentOrigin( ParentOrigin::CENTER );
meshActor.SetAnchorPoint( AnchorPoint::CENTER );
meshActor.RegisterProperty("uHue", i/(float)NUMBER_OF_SAMPLES);
- meshActor.TouchedSignal().Connect(this, &ExampleController::OnTouched);
+ meshActor.TouchSignal().Connect(this, &ExampleController::OnTouched);
std::ostringstream oss;
oss << "Mesh Actor " << i;
meshActor.SetName(oss.str());
stage.Add( meshActor );
}
- mActors[NUMBER_OF_SAMPLES-2].GetRendererAt(0).SetMaterial( firstMat );
+ mActors[NUMBER_OF_SAMPLES-2].GetRendererAt(0).SetTextures( firstTextureSet );
- stage.GetRootLayer().TouchedSignal().Connect(this, &ExampleController::OnStageTouched);
+ stage.GetRootLayer().TouchSignal().Connect(this, &ExampleController::OnStageTouched);
}
void PrintDepths()
printf("\n");
}
- bool OnTouched( Actor actor, const TouchEvent& event )
+ bool OnTouched( Actor actor, const TouchData& event )
{
- if( event.GetPoint(0).state == TouchPoint::Finished )
+ if( event.GetState( 0 ) == PointState::UP )
{
int index = actor.GetProperty<int>(actor.GetPropertyIndex("index"));
mDepthIndices[index] = newDepthIndex;
Renderer renderer = actor.GetRendererAt(0);
- renderer.SetDepthIndex(newDepthIndex);
+ renderer.SetProperty( Renderer::Property::DEPTH_INDEX, newDepthIndex);
PrintDepths();
}
return true;
}
- bool OnStageTouched( Actor rootLayer, const TouchEvent& event )
+ bool OnStageTouched( Actor rootLayer, const TouchData& event )
{
- if( event.GetPoint(0).state == TouchPoint::Finished )
+ if( event.GetState( 0 ) == PointState::UP )
{
switch( mZMode )
{
// Entry point for Linux & SLP applications
//
-int main( int argc, char **argv )
+int DALI_EXPORT_API main( int argc, char **argv )
{
Application application = Application::New( &argc, &argv );