/* * 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. * 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 // INTERNAL INCLUDES #include "shared/view.h" #include "shared/utility.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))); } ); Geometry CreateGeometry() { // Create vertices struct Vertex { Vector2 position; float hue; }; unsigned int numSides = 20; Vertex polyhedraVertexData[numSides]; float angle=0; float sectorAngle = 2.0f * Math::PI / (float) numSides; for(unsigned int i=0; i