vdr-plugin-softhddevice-drm-gles 1.6.4-d0291bb
openglshader.h
Go to the documentation of this file.
1// SPDX-License-Identifier: AGPL-3.0-or-later
2
15#ifndef __SOFTHDDEVICE_OPENGLSHADER_H
16#define __SOFTHDDEVICE_OPENGLSHADER_H
17
18/********************************************************************************
19 * Shaders for Hardware Accelerated OpenGL OSD
20 *******************************************************************************/
21
30const char *rectVertexShader =
31"#version 100 \n\
32\
33attribute vec2 position; \
34varying vec4 rectCol; \
35uniform vec4 inColor; \
36uniform mat4 projection; \
37\
38void main() \
39{ \
40 gl_Position = projection * vec4(position.x, position.y, 0.0, 1.0); \
41 rectCol = inColor; \
42} \
43";
44
48const char *rectFragmentShader =
49"#version 100 \n\
50precision mediump float; \
51varying vec4 rectCol; \
52\
53void main() \
54{ \
55 gl_FragColor = rectCol; \
56} \
57";
58
63"#version 100 \n\
64\
65attribute vec2 position; \
66attribute vec2 texCoords; \
67\
68varying vec2 TexCoords; \
69varying vec4 alphaValue;\
70varying vec4 bColorValue;\
71\
72uniform vec4 bColor; \
73uniform mat4 projection; \
74uniform vec4 alpha; \
75\
76void main() \
77{ \
78 gl_Position = projection * vec4(position.x, position.y, 0.0, 1.0); \
79 TexCoords = texCoords; \
80 alphaValue = alpha; \
81 bColorValue = bColor; \
82} \
83";
84
89"#version 100 \n\
90precision mediump float; \
91varying vec2 TexCoords; \
92varying vec4 alphaValue; \
93varying vec4 bColorValue; \
94\
95uniform sampler2D screenTexture; \
96\
97float clamp_to_border_factor (vec2 coords) \
98{ \
99 bvec2 out1 = greaterThan (coords, vec2 (1,1)); \
100 bvec2 out2 = lessThan (coords, vec2 (0,0)); \
101 bool do_clamp = (any (out1) || any (out2)); \
102 return float (!do_clamp); \
103} \
104\
105void main() \
106{ \
107 vec4 color = texture2D(screenTexture, TexCoords) * alphaValue; \
108 float f = clamp_to_border_factor (TexCoords); \
109 gl_FragColor = mix (bColorValue, color, f); \
110} \
111";
112
120"#version 100 \n\
121precision mediump float; \
122varying vec2 TexCoords; \
123varying vec4 alphaValue; \
124varying vec4 bColorValue; \
125\
126uniform sampler2D screenTexture; \
127\
128float clamp_to_border_factor (vec2 coords) \
129{ \
130 bvec2 out1 = greaterThan (coords, vec2 (1,1)); \
131 bvec2 out2 = lessThan (coords, vec2 (0,0)); \
132 bool do_clamp = (any (out1) || any (out2)); \
133 return float (!do_clamp); \
134} \
135\
136void main() \
137{ \
138 vec4 color = texture2D(screenTexture, TexCoords) * alphaValue; \
139 vec4 color_swapped = vec4(color.b, color.g, color.r, color.a); \
140 float f = clamp_to_border_factor (TexCoords); \
141 gl_FragColor = mix (bColorValue, color_swapped, f); \
142} \
143";
144
148const char *textVertexShader =
149"#version 100 \n\
150\
151attribute vec2 position; \
152attribute vec2 texCoords; \
153\
154varying vec2 TexCoords; \
155varying vec4 textColor; \
156\
157uniform mat4 projection; \
158uniform vec4 inColor; \
159\
160void main() \
161{ \
162 gl_Position = projection * vec4(position.x, position.y, 0.0, 1.0); \
163 TexCoords = texCoords; \
164 textColor = inColor; \
165} \
166";
167
172"#version 100 \n\
173precision mediump float; \
174varying vec2 TexCoords; \
175varying vec4 textColor; \
176\
177uniform sampler2D glyphTexture; \
178\
179void main() \
180{ \
181 vec4 sampled = vec4(1.0, 1.0, 1.0, texture2D(glyphTexture, TexCoords).r); \
182 gl_FragColor = textColor * sampled; \
183} \
184";
185
188#endif
const char * textureFragmentShaderSwapBR
Texture Fragment Shader (swapped blue/red)
const char * rectVertexShader
Rectangle Vertex Shader.
const char * textureFragmentShader
Texture Fragment Shader.
const char * rectFragmentShader
Rectangle Fragment Shader.
const char * textFragmentShader
Text Fragment Shader.
const char * textureVertexShader
Texture Vertex Shader.
const char * textVertexShader
Text Vertex Shader.