f3a90043b04f1ff7345c7cbd23af63d4d6920181
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / text / rendering / shaders / text-basic-shader.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali-toolkit/public-api/text/rendering/text-renderer.h>
20
21 namespace Dali
22 {
23
24 namespace Toolkit
25 {
26
27 namespace Text
28 {
29
30 namespace BasicShader
31 {
32
33 Dali::ShaderEffect New()
34 {
35   std::string vertexShader = DALI_COMPOSE_SHADER(
36       uniform mediump vec4 uTextureRect;\n
37       void main()\n
38       {\n
39         gl_Position = uMvpMatrix * vec4( aPosition.xy, 0.0, 1.0 );\n
40         vTexCoord = aTexCoord.xy;\n
41       }\n
42   );
43
44   std::string fragmentShader = DALI_COMPOSE_SHADER(
45       void main()\n
46       {\n
47         mediump vec4 color = texture2D( sTexture, vTexCoord );
48         gl_FragColor = vec4(uColor.rgb, uColor.a*color.r);
49       }\n
50   );
51
52   Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New( vertexShader, fragmentShader,
53                                                              Dali::GeometryType( Dali::GEOMETRY_TYPE_TEXTURED_MESH ),
54                                                              Dali::ShaderEffect::GeometryHints( Dali::ShaderEffect::HINT_NONE ) );
55   return shaderEffect;
56 }
57
58 } // namespace BasicShader
59
60 } // namespace Text
61
62 } // namespace Toolkit
63
64 } // namespace Dali