Otclient  14/8/2020
painterogl2_shadersources.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #ifndef PAINTEROGL2_SHADERSOURCES_H
24 #define PAINTEROGL2_SHADERSOURCES_H
25 
26 static const std::string glslMainVertexShader = "\n\
27  highp vec4 calculatePosition();\n\
28  void main() {\n\
29  gl_Position = calculatePosition();\n\
30  }\n";
31 
32 static const std::string glslMainWithTexCoordsVertexShader = "\n\
33  attribute highp vec2 a_TexCoord;\n\
34  uniform highp mat3 u_TextureMatrix;\n\
35  varying highp vec2 v_TexCoord;\n\
36  highp vec4 calculatePosition();\n\
37  void main()\n\
38  {\n\
39  gl_Position = calculatePosition();\n\
40  v_TexCoord = (u_TextureMatrix * vec3(a_TexCoord,1.0)).xy;\n\
41  }\n";
42 
43 static std::string glslPositionOnlyVertexShader = "\n\
44  attribute highp vec2 a_Vertex;\n\
45  uniform highp mat3 u_TransformMatrix;\n\
46  uniform highp mat3 u_ProjectionMatrix;\n\
47  highp vec4 calculatePosition() {\n\
48  return vec4(u_ProjectionMatrix * u_TransformMatrix * vec3(a_Vertex.xy, 1.0), 1.0);\n\
49  }\n";
50 
51 static const std::string glslMainFragmentShader = "\n\
52  uniform lowp float u_Opacity;\n\
53  lowp vec4 calculatePixel();\n\
54  void main()\n\
55  {\n\
56  gl_FragColor = calculatePixel();\n\
57  gl_FragColor.a *= u_Opacity;\n\
58  }\n";
59 
60 static const std::string glslTextureSrcFragmentShader = "\n\
61  varying mediump vec2 v_TexCoord;\n\
62  uniform lowp vec4 u_Color;\n\
63  uniform sampler2D u_Tex0;\n\
64  lowp vec4 calculatePixel() {\n\
65  return texture2D(u_Tex0, v_TexCoord) * u_Color;\n\
66  }\n";
67 
68 static const std::string glslSolidColorFragmentShader = "\n\
69  uniform lowp vec4 u_Color;\n\
70  lowp vec4 calculatePixel() {\n\
71  return u_Color;\n\
72  }\n";
73 
74 #endif