summaryrefslogtreecommitdiff
path: root/sway/desktop/fx_renderer.c
diff options
context:
space:
mode:
authorWill McKinnon <[email protected]>2022-08-25 00:27:14 -0400
committerWill McKinnon <[email protected]>2022-08-25 00:27:14 -0400
commit3b287a73b919a46b48eac710353bcd2b123487a5 (patch)
treeed9d8e5daca51e9b3c24d70055b4c8ac35a91efd /sway/desktop/fx_renderer.c
parentbdbd2512a8e741168f7058283481f1d5324c9118 (diff)
moved shaders to header
Diffstat (limited to 'sway/desktop/fx_renderer.c')
-rw-r--r--sway/desktop/fx_renderer.c218
1 files changed, 1 insertions, 217 deletions
diff --git a/sway/desktop/fx_renderer.c b/sway/desktop/fx_renderer.c
index 6dbccc23..ede1ff04 100644
--- a/sway/desktop/fx_renderer.c
+++ b/sway/desktop/fx_renderer.c
@@ -17,226 +17,10 @@
#include <wlr/util/box.h>
#include "log.h"
#include "sway/desktop/fx_renderer.h"
+#include "sway/desktop/shaders.h"
#include "sway/output.h"
#include "sway/server.h"
-/************************
- Shaders
-*************************/
-
-// Colored quads
-const GLchar quad_vertex_src[] =
-"uniform mat3 proj;\n"
-"uniform vec4 color;\n"
-"attribute vec2 pos;\n"
-"attribute vec2 texcoord;\n"
-"varying vec4 v_color;\n"
-"varying vec2 v_texcoord;\n"
-"\n"
-"void main() {\n"
-" gl_Position = vec4(proj * vec3(pos, 1.0), 1.0);\n"
-" v_color = color;\n"
-" v_texcoord = texcoord;\n"
-"}\n";
-
-const GLchar quad_fragment_src[] =
-"precision mediump float;\n"
-"varying vec4 v_color;\n"
-"varying vec2 v_texcoord;\n"
-"\n"
-"void main() {\n"
-" gl_FragColor = v_color;\n"
-"}\n";
-
-// Textured quads
-const GLchar tex_vertex_src[] =
-"uniform mat3 proj;\n"
-"attribute vec2 pos;\n"
-"attribute vec2 texcoord;\n"
-"varying vec2 v_texcoord;\n"
-"\n"
-"void main() {\n"
-" gl_Position = vec4(proj * vec3(pos, 1.0), 1.0);\n"
-" v_texcoord = texcoord;\n"
-"}\n";
-
-const GLchar tex_fragment_src_rgba[] =
-"precision mediump float;\n"
-"varying vec2 v_texcoord;\n"
-"uniform sampler2D tex;\n"
-"uniform float alpha;\n"
-"\n"
-"uniform vec2 topLeft;\n"
-"uniform vec2 bottomRight;\n"
-"uniform vec2 fullSize;\n"
-"uniform float radius;\n"
-"\n"
-"uniform int discardOpaque;\n"
-"\n"
-"void main() {\n"
-" vec4 pixColor = texture2D(tex, v_texcoord);\n"
-"\n"
-" if (discardOpaque == 1 && pixColor[3] * alpha == 1.0) {\n"
-" discard;\n"
-" return;\n"
-" }\n"
-"\n"
-" vec2 pixCoord = fullSize * v_texcoord;\n"
-"\n"
-" if (pixCoord[0] < topLeft[0]) {\n"
-" // we're close left\n"
-" if (pixCoord[1] < topLeft[1]) {\n"
- // top
-" if (distance(topLeft, pixCoord) > radius) {\n"
-" discard;\n"
-" return;\n"
-" }\n"
-" } else if (pixCoord[1] > bottomRight[1]) {\n"
- // bottom
-" if (distance(vec2(topLeft[0], bottomRight[1]), pixCoord) > radius) {\n"
-" discard;\n"
-" return;\n"
-" }\n"
-" }\n"
-" }\n"
-" else if (pixCoord[0] > bottomRight[0]) {\n"
- // we're close right
-" if (pixCoord[1] < topLeft[1]) {\n"
- // top
-" if (distance(vec2(bottomRight[0], topLeft[1]), pixCoord) > radius) {\n"
-" discard;\n"
-" return;\n"
-" }\n"
-" } else if (pixCoord[1] > bottomRight[1]) {\n"
- // bottom
-" if (distance(bottomRight, pixCoord) > radius) {\n"
-" discard;\n"
-" return;\n"
-" }\n"
-" }\n"
-" }\n"
-"\n"
-" gl_FragColor = pixColor * alpha;\n"
-"}\n";
-
-const GLchar tex_fragment_src_rgbx[] =
-"precision mediump float;\n"
-"varying vec2 v_texcoord;\n"
-"uniform sampler2D tex;\n"
-"uniform float alpha;\n"
-"\n"
-"uniform vec2 topLeft;\n"
-"uniform vec2 bottomRight;\n"
-"uniform vec2 fullSize;\n"
-"uniform float radius;\n"
-"\n"
-"uniform int discardOpaque;\n"
-"\n"
-"void main() {\n"
-"\n"
-" if (discardOpaque == 1 && alpha == 1.0) {\n"
-" discard;\n"
-" return;\n"
-" }\n"
-"\n"
-" vec2 pixCoord = fullSize * v_texcoord;\n"
-"\n"
-" if (pixCoord[0] < topLeft[0]) {\n"
- // we're close left
-" if (pixCoord[1] < topLeft[1]) {\n"
- // top
-" if (distance(topLeft, pixCoord) > radius) {\n"
-" discard;\n"
-" return;\n"
-" }\n"
-" } else if (pixCoord[1] > bottomRight[1]) {\n"
- // bottom
-" if (distance(vec2(topLeft[0], bottomRight[1]), pixCoord) > radius) {\n"
-" discard;\n"
-" return;\n"
-" }\n"
-" }\n"
-" }\n"
-" else if (pixCoord[0] > bottomRight[0]) {\n"
- // we're close right
-" if (pixCoord[1] < topLeft[1]) {\n"
- // top
-" if (distance(vec2(bottomRight[0], topLeft[1]), pixCoord) > radius) {\n"
-" discard;\n"
-" return;\n"
-" }\n"
-" } else if (pixCoord[1] > bottomRight[1]) {\n"
- // bottom
-" if (distance(bottomRight, pixCoord) > radius) {\n"
-" discard;\n"
-" return;\n"
-" }\n"
-" }\n"
-" }\n"
-"\n"
-" gl_FragColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0) * alpha;\n"
-"}\n";
-
-const GLchar tex_fragment_src_external[] =
-"#extension GL_OES_EGL_image_external : require\n\n"
-"precision mediump float;\n"
-"varying vec2 v_texcoord;\n"
-"uniform samplerExternalOES texture0;\n"
-"uniform float alpha;\n"
-"\n"
-"uniform vec2 topLeft;\n"
-"uniform vec2 bottomRight;\n"
-"uniform vec2 fullSize;\n"
-"uniform float radius;\n"
-"\n"
-"uniform int discardOpaque;\n"
-"\n"
-"void main() {\n"
-"\n"
-" vec4 pixColor = texture2D(texture0, v_texcoord);\n"
-"\n"
-" if (discardOpaque == 1 && pixColor[3] * alpha == 1.0) {\n"
-" discard;\n"
-" return;\n"
-" }\n"
-"\n"
-" vec2 pixCoord = fullSize * v_texcoord;\n"
-"\n"
-" if (pixCoord[0] < topLeft[0]) {\n"
- // we're close left
-" if (pixCoord[1] < topLeft[1]) {\n"
- // top
-" if (distance(topLeft, pixCoord) > radius) {\n"
-" discard;\n"
-" return;\n"
-" }\n"
-" } else if (pixCoord[1] > bottomRight[1]) {\n"
- // bottom
-" if (distance(vec2(topLeft[0], bottomRight[1]), pixCoord) > radius) {\n"
-" discard;\n"
-" return;\n"
-" }\n"
-" }\n"
-" }\n"
-" else if (pixCoord[0] > bottomRight[0]) {\n"
- // we're close right
-" if (pixCoord[1] < topLeft[1]) {\n"
- // top
-" if (distance(vec2(bottomRight[0], topLeft[1]), pixCoord) > radius) {\n"
-" discard;\n"
-" return;\n"
-" }\n"
-" } else if (pixCoord[1] > bottomRight[1]) {\n"
- // bottom
-" if (distance(bottomRight, pixCoord) > radius) {\n"
-" discard;\n"
-" return;\n"
-" }\n"
-" }\n"
-" }\n"
-"\n"
-" gl_FragColor = pixColor * alpha;\n"
-"}\n";
/************************
Matrix Consts