X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-demo.git;a=blobdiff_plain;f=examples%2Fpoint-mesh%2Fpoint-mesh-example.cpp;h=37fb023e738725350fed969ee0e9e4015b8b64d8;hp=38b4028a013a98957004a79572b5c1583fde0448;hb=1b19fd140ff139b5854a1a62447faf31b175d8f6;hpb=b26d446b0cb6a316abc3a79d4fc70d0ae1b7994c diff --git a/examples/point-mesh/point-mesh-example.cpp b/examples/point-mesh/point-mesh-example.cpp index 38b4028..37fb023 100644 --- a/examples/point-mesh/point-mesh-example.cpp +++ b/examples/point-mesh/point-mesh-example.cpp @@ -19,92 +19,91 @@ #include // INTERNAL INCLUDES -#include "shared/view.h" #include "shared/utility.h" +#include "shared/view.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" ); +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 +#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); -} + 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; -} -); + 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))); -} -); + 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))); + }); Geometry CreateGeometry() { // Create vertices - struct Vertex { Vector2 position; float hue; }; + struct Vertex + { + Vector2 position; + float hue; + }; const unsigned int numSides = 20; - Vertex polyhedraVertexData[numSides]; - float angle=0; - float sectorAngle = 2.0f * Math::PI / (float) numSides; + Vertex polyhedraVertexData[numSides]; + float angle = 0; + float sectorAngle = 2.0f * Math::PI / (float)numSides; - for(unsigned int i=0; i