aboutsummaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
authorsarbes <sarbes@kodi.tv>2024-04-10 10:26:27 +0200
committersarbes <sarbes@kodi.tv>2024-04-10 10:26:27 +0200
commita7283ef2b5e02b29c2fbe7f4d286fb4f8e9a18fc (patch)
tree2ef72620c65be05ed561d877a831a5729dda0dd1 /system
parentaf41d9a5798dd6b4e13a424e7da3afff55dc872d (diff)
GL: improve text rendering
Diffstat (limited to 'system')
-rw-r--r--system/shaders/GL/1.2/gl_shader_vert_clip.glsl39
-rw-r--r--system/shaders/GL/1.2/gl_shader_vert_simple.glsl26
-rw-r--r--system/shaders/GL/1.5/gl_shader_vert_clip.glsl39
-rw-r--r--system/shaders/GL/1.5/gl_shader_vert_simple.glsl26
4 files changed, 130 insertions, 0 deletions
diff --git a/system/shaders/GL/1.2/gl_shader_vert_clip.glsl b/system/shaders/GL/1.2/gl_shader_vert_clip.glsl
new file mode 100644
index 0000000000..37d67946f5
--- /dev/null
+++ b/system/shaders/GL/1.2/gl_shader_vert_clip.glsl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2024 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#version 120
+
+attribute vec4 m_attrpos;
+attribute vec4 m_attrcol;
+attribute vec4 m_attrcord0;
+attribute vec4 m_attrcord1;
+varying vec4 m_cord0;
+varying vec4 m_cord1;
+varying vec4 m_colour;
+uniform mat4 m_matrix;
+uniform vec4 m_shaderClip;
+uniform vec4 m_cordStep;
+
+// this shader can be used in cases where clipping via glScissor() is not
+// possible (e.g. when rotating). it can't discard triangles, but it may
+// degenerate them.
+
+void main ()
+{
+ // limit the vertices to the clipping area
+ vec4 position = m_attrpos;
+ position.xy = clamp(position.xy, m_shaderClip.xy, m_shaderClip.zw);
+ gl_Position = m_matrix * position;
+
+ // correct texture coordinates for clipped vertices
+ vec2 clipDist = m_attrpos.xy - position.xy;
+ m_cord0.xy = m_attrcord0.xy - clipDist * m_cordStep.xy;
+ m_cord1.xy = m_attrcord1.xy - clipDist * m_cordStep.zw;
+
+ m_colour = m_attrcol;
+}
diff --git a/system/shaders/GL/1.2/gl_shader_vert_simple.glsl b/system/shaders/GL/1.2/gl_shader_vert_simple.glsl
new file mode 100644
index 0000000000..f06893a085
--- /dev/null
+++ b/system/shaders/GL/1.2/gl_shader_vert_simple.glsl
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2024 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#version 120
+
+attribute vec4 m_attrpos;
+attribute vec4 m_attrcol;
+attribute vec4 m_attrcord0;
+attribute vec4 m_attrcord1;
+varying vec4 m_cord0;
+varying vec4 m_cord1;
+varying vec4 m_colour;
+uniform mat4 m_matrix;
+
+void main ()
+{
+ gl_Position = m_matrix * m_attrpos;
+ m_colour = m_attrcol;
+ m_cord0 = m_attrcord0;
+ m_cord1 = m_attrcord1;
+}
diff --git a/system/shaders/GL/1.5/gl_shader_vert_clip.glsl b/system/shaders/GL/1.5/gl_shader_vert_clip.glsl
new file mode 100644
index 0000000000..2fa1c63da1
--- /dev/null
+++ b/system/shaders/GL/1.5/gl_shader_vert_clip.glsl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2024 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#version 150
+
+in vec4 m_attrpos;
+in vec4 m_attrcol;
+in vec4 m_attrcord0;
+in vec4 m_attrcord1;
+out vec4 m_cord0;
+out vec4 m_cord1;
+out vec4 m_colour;
+uniform mat4 m_matrix;
+uniform vec4 m_shaderClip;
+uniform vec4 m_cordStep;
+
+// this shader can be used in cases where clipping via glScissor() is not
+// possible (e.g. when rotating). it can't discard triangles, but it may
+// degenerate them.
+
+void main ()
+{
+ // limit the vertices to the clipping area
+ vec4 position = m_attrpos;
+ position.xy = clamp(position.xy, m_shaderClip.xy, m_shaderClip.zw);
+ gl_Position = m_matrix * position;
+
+ // correct texture coordinates for clipped vertices
+ vec2 clipDist = m_attrpos.xy - position.xy;
+ m_cord0.xy = m_attrcord0.xy - clipDist * m_cordStep.xy;
+ m_cord1.xy = m_attrcord1.xy - clipDist * m_cordStep.zw;
+
+ m_colour = m_attrcol;
+}
diff --git a/system/shaders/GL/1.5/gl_shader_vert_simple.glsl b/system/shaders/GL/1.5/gl_shader_vert_simple.glsl
new file mode 100644
index 0000000000..9c1552d7a4
--- /dev/null
+++ b/system/shaders/GL/1.5/gl_shader_vert_simple.glsl
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2024 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#version 150
+
+in vec4 m_attrpos;
+in vec4 m_attrcol;
+in vec4 m_attrcord0;
+in vec4 m_attrcord1;
+out vec4 m_cord0;
+out vec4 m_cord1;
+out vec4 m_colour;
+uniform mat4 m_matrix;
+
+void main ()
+{
+ gl_Position = m_matrix * m_attrpos;
+ m_colour = m_attrcol;
+ m_cord0 = m_attrcord0;
+ m_cord1 = m_attrcord1;
+}