From 23e51e336360dfa5e9acd57d935acd2dd56aeb58 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 25 Oct 2014 12:11:27 +0800 Subject: [PATCH] demos/tri: fix the shaders The GLSL code was apparently copy-and-pasted from some other test when the hardcoded shaders were replaced. It was not supposed to work. --- demos/tri.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/demos/tri.c b/demos/tri.c index 5474fe3..a7f6d69 100644 --- a/demos/tri.c +++ b/demos/tri.c @@ -1,3 +1,9 @@ +/* + * Draw a textured triangle with depth testing. This is written against Intel + * ICD. It does not do state transition nor object memory binding like it + * should. It also does no error checking. + */ + #include #include #include @@ -528,6 +534,7 @@ static XGL_SHADER demo_prepare_shader(struct demo *demo, err = xglCreateShader(demo->device, &createInfo, &shader); if (err) { free((void *) createInfo.pCode); + return NULL; } return shader; @@ -537,13 +544,12 @@ static XGL_SHADER demo_prepare_vs(struct demo *demo) { static const char *vertShaderText = "#version 130\n" - "uniform mat4 mvp;\n" + "in vec4 pos;\n" + "in vec2 attr;\n" + "out vec2 texcoord;\n" "void main() {\n" - " vec2 vertices[3];" - " vertices[0] = vec2(-0.5, -0.5);\n" - " vertices[1] = vec2( 0.5, -0.5);\n" - " vertices[2] = vec2( 0.5, 0.5);\n" - " gl_Position = vec4(vertices[gl_VertexID % 3], 0.0, 1.0) * mvp;\n" + " texcoord = attr;\n" + " gl_Position = pos;\n" "}\n"; return demo_prepare_shader(demo, XGL_SHADER_STAGE_VERTEX, @@ -555,8 +561,10 @@ static XGL_SHADER demo_prepare_fs(struct demo *demo) { static const char *fragShaderText = "#version 130\n" + "uniform sampler2D tex;\n" + "in vec2 texcoord;\n" "void main() {\n" - " gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n" + " gl_FragColor = texture(tex, texcoord);\n" "}\n"; return demo_prepare_shader(demo, XGL_SHADER_STAGE_FRAGMENT, -- 2.7.4