diff options
author | Edward O'Callaghan <funfunctor@folklore1984.net> | 2017-02-08 01:45:16 +1100 |
---|---|---|
committer | Edward O'Callaghan <funfunctor@folklore1984.net> | 2017-02-08 01:45:16 +1100 |
commit | d912f9ee62341538a2d351763c17d66301d48150 (patch) | |
tree | 5f871eddaaf9bb62b70c5167f80ac5af38b5f43d /src | |
parent | 649ae2629b306c9a7f55726704bef4aae010ef8d (diff) |
src/shaders: Fixup GLSL, pass color from vertex to frag shader
Signed-off-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/shaders/triangle.frag | 6 | ||||
-rw-r--r-- | src/shaders/triangle.vert (renamed from src/shaders/triangle.vs) | 12 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/shaders/triangle.frag b/src/shaders/triangle.frag index 76dae17..df447fa 100644 --- a/src/shaders/triangle.frag +++ b/src/shaders/triangle.frag @@ -1,9 +1,9 @@ #version 450 +#extension GL_ARB_separate_shader_objects : enable -#extension GL_ARB_seperate_shader_objects : enable - +layout(location = 0) in vec3 fragColor; layout(location = 0) out vec4 outColor; void main() { - outColor = vec4(1.0 0.0, 0.0, 1.0); + outColor = vec4(fragColor, 1.0); } diff --git a/src/shaders/triangle.vs b/src/shaders/triangle.vert index ef28c81..eab0768 100644 --- a/src/shaders/triangle.vs +++ b/src/shaders/triangle.vert @@ -1,11 +1,12 @@ #version 450 - -Extension GL_ARB_seperate_shader_objects : enable +#extension GL_ARB_separate_shader_objects : enable out gl_PerVertex { vec4 gl_Position; }; +layout(location = 0) out vec3 fragColor; + // Vertex buffers are hard in Vk fuuccck.. vec2 positions[3] = vec2[]( vec2(0.0, -0.5), @@ -13,6 +14,13 @@ vec2 positions[3] = vec2[]( vec2(-0.5, 0.5) ); +vec3 colors[3] = vec3[]( + vec3(1.0, 0.0, 0.0), + vec3(0.0, 1.0, 0.0), + vec3(0.0, 0.0, 1.0) +); + void main() { gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0); + fragColor = colors[gl_VertexIndex]; } |