vulkan_test2

changeset 10:8eb3126cc2f1

starting on shaders
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 21 Jun 2018 06:58:58 +0300
parents 20eb42197ab8
children dc85ded6ceee
files .hgignore Makefile sdr/pixel.glsl sdr/vertex.glsl
diffstat 4 files changed, 35 insertions(+), 1 deletions(-) [+]
line diff
     1.1 --- a/.hgignore	Wed Jun 20 05:57:34 2018 +0300
     1.2 +++ b/.hgignore	Thu Jun 21 06:58:58 2018 +0300
     1.3 @@ -2,3 +2,4 @@
     1.4  \.swp$
     1.5  \.d$
     1.6  ^test$
     1.7 +\.spv$
     2.1 --- a/Makefile	Wed Jun 20 05:57:34 2018 +0300
     2.2 +++ b/Makefile	Thu Jun 21 06:58:58 2018 +0300
     2.3 @@ -2,12 +2,22 @@
     2.4  obj = $(src:.c=.o)
     2.5  bin = test
     2.6  
     2.7 +sdr = $(wildcard sdr/*.glsl)
     2.8 +spv = $(sdr:.glsl=.spv)
     2.9 +
    2.10  CFLAGS = -pedantic -Wall -g
    2.11  LDFLAGS = -lvulkan -lX11
    2.12  
    2.13 -$(bin): $(obj)
    2.14 +$(bin): $(obj) $(spv)
    2.15  	$(CC) -o $@ $(obj) $(LDFLAGS)
    2.16  
    2.17 +sdr/vertex.spv: sdr/vertex.glsl
    2.18 +	glslangValidator -o $@ -S vert -V $<
    2.19 +
    2.20 +sdr/pixel.spv: sdr/pixel.glsl
    2.21 +	glslangValidator -o $@ -S frag -V $<
    2.22 +
    2.23 +
    2.24  .PHONY: clean
    2.25  clean:
    2.26  	rm -f $(obj) $(bin)
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/sdr/pixel.glsl	Thu Jun 21 06:58:58 2018 +0300
     3.3 @@ -0,0 +1,9 @@
     3.4 +#version 450
     3.5 +#extension GL_ARB_separate_shader_objects: enable
     3.6 +
     3.7 +layout(location = 0) out vec4 outcolor;
     3.8 +
     3.9 +void main()
    3.10 +{
    3.11 +	outcolor = vec4(1.0, 0.0, 0.0, 1.0);
    3.12 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/sdr/vertex.glsl	Thu Jun 21 06:58:58 2018 +0300
     4.3 @@ -0,0 +1,14 @@
     4.4 +#version 450
     4.5 +#extension GL_ARB_separate_shader_objects: enable
     4.6 +
     4.7 +layout(location = 0) out vec4 outpos;
     4.8 +
     4.9 +const vec3 vdata[] = vec3[](
    4.10 +	vec3(-0.5, -0.5, 0.0),
    4.11 +	vec3(0.5, -0.5, 0.0),
    4.12 +	vec3(0.7, 0.0, 0.0));
    4.13 +
    4.14 +void main()
    4.15 +{
    4.16 +	outpos = vec4(vdata[gl_VertexIndex], 1.0);
    4.17 +}