X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fpoint-mesh%2Fpoint-mesh-example.cpp;h=1e66ab568b165d7fdd9105b581a6fb89fa9e4a6f;hb=refs%2Fchanges%2F13%2F252013%2F2;hp=ce7a08092eefbd5a499a72c03d9f4caa706e34be;hpb=07ab57fde5eb011ecd843162afd4eeae3f7d844b;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/point-mesh/point-mesh-example.cpp b/examples/point-mesh/point-mesh-example.cpp index ce7a080..1e66ab5 100644 --- a/examples/point-mesh/point-mesh-example.cpp +++ b/examples/point-mesh/point-mesh-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -16,95 +16,53 @@ */ // EXTERNAL INCLUDES -#include #include // INTERNAL INCLUDES +#include "shared/utility.h" #include "shared/view.h" +#include "generated/point-mesh-vert.h" +#include "generated/point-mesh-frag.h" using namespace Dali; namespace { -const char* MATERIAL_SAMPLE( DEMO_IMAGE_DIR "gallery-small-48.jpg" ); -const char* MATERIAL_SAMPLE2( DEMO_IMAGE_DIR "gallery-medium-19.jpg" ); - -#define MAKE_SHADER(A)#A - -const char* VERTEX_SHADER = MAKE_SHADER( -attribute mediump vec2 aPosition; -attribute highp float aHue; -varying mediump vec2 vTexCoord; -uniform mediump mat4 uMvpMatrix; -uniform mediump vec3 uSize; -uniform mediump float uPointSize; -uniform lowp vec4 uFadeColor; -varying mediump vec3 vVertexColor; -varying mediump float vHue; - -vec3 hsv2rgb(vec3 c) -{ - vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); - vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); - return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); -} - -void main() -{ - mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0); - vertexPosition.xyz *= (uSize-uPointSize); - vertexPosition = uMvpMatrix * vertexPosition; - vVertexColor = hsv2rgb( vec3( aHue, 0.7, 1.0 ) ); - vHue = aHue; - gl_PointSize = uPointSize; - gl_Position = vertexPosition; -} -); - -const char* FRAGMENT_SHADER = MAKE_SHADER( -varying mediump vec3 vVertexColor; -varying mediump float vHue; -uniform lowp vec4 uColor; -uniform sampler2D sTexture1; -uniform sampler2D sTexture2; -uniform lowp vec4 uFadeColor; - -void main() -{ - mediump vec4 texCol1 = texture2D(sTexture1, gl_PointCoord); - mediump vec4 texCol2 = texture2D(sTexture2, gl_PointCoord); - gl_FragColor = vec4(vVertexColor, 1.0) * ((texCol1*vHue) + (texCol2*(1.0-vHue))); -} -); +const char* MATERIAL_SAMPLE(DEMO_IMAGE_DIR "gallery-small-48.jpg"); +const char* MATERIAL_SAMPLE2(DEMO_IMAGE_DIR "gallery-medium-19.jpg"); Geometry CreateGeometry() { // Create vertices - struct Vertex { Vector2 position; float hue; }; + struct Vertex + { + Vector2 position; + float hue; + }; - unsigned int numSides = 20; - Vertex polyhedraVertexData[numSides]; - float angle=0; - float sectorAngle = 2.0f * Math::PI / (float) numSides; + const unsigned int numSides = 20; + Vertex polyhedraVertexData[numSides]; + float angle = 0; + float sectorAngle = 2.0f * Math::PI / (float)numSides; - for(unsigned int i=0; i