aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/OpenGL/TexturedShader.cs
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2015-03-16 13:36:36 +0100
committerjpbruyere <jp.bruyere@hotmail.com>2015-03-16 13:36:36 +0100
commit4338402e29d2c448c24f4efe6a788adb84f81785 (patch)
treeb22d52562f0dadf4532556cbbd93d8567d50ee23 /src/OpenGL/TexturedShader.cs
parent871f7388f22f642f913ea955662840ce8da2f7ce (diff)
OpenGL indirect drawing for ui quad
(shader and vao)
Diffstat (limited to 'src/OpenGL/TexturedShader.cs')
-rw-r--r--src/OpenGL/TexturedShader.cs65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/OpenGL/TexturedShader.cs b/src/OpenGL/TexturedShader.cs
new file mode 100644
index 00000000..a410b16e
--- /dev/null
+++ b/src/OpenGL/TexturedShader.cs
@@ -0,0 +1,65 @@
+using System;
+using OpenTK.Graphics.OpenGL;
+
+namespace go.GLBackend
+{
+ public class TexturedShader : Shader
+ {
+ public TexturedShader ()
+ {
+ vertSource = @"
+ #version 130
+
+ precision highp float;
+
+ uniform mat4 projection_matrix;
+ uniform mat4 modelview_matrix;
+
+ in vec2 in_position;
+ in vec2 in_tex;
+ out vec2 texCoord;
+
+
+ void main(void)
+ {
+ texCoord = in_tex;
+ gl_Position = projection_matrix * modelview_matrix * vec4(in_position,0, 1);
+ }";
+
+ fragSource = @"
+ #version 130
+ precision highp float;
+
+ uniform vec4 color;
+ uniform sampler2D tex;
+ uniform sampler2D stencil;
+
+ in vec2 texCoord;
+ out vec4 out_frag_color;
+
+ void main(void)
+ {
+// vec4 s = texture( stencil, texCoord);
+// if (s.r == 0)
+// discard;
+ vec4 t = texture( tex, texCoord);
+ out_frag_color = t;
+ }";
+
+ Compile ();
+
+ }
+
+ protected override void BindVertexAttributes ()
+ {
+ base.BindVertexAttributes ();
+ GL.BindAttribLocation(pgmId, 1, "in_tex");
+ }
+ protected override void BindSamplesSlots ()
+ {
+ GL.Uniform1(GL.GetUniformLocation (pgmId, "tex"),0);
+ GL.Uniform1(GL.GetUniformLocation (pgmId, "stencil"),1);
+ }
+ }
+}
+