diff options
| author | Chia-I Wu <olv@lunarg.com> | 2014-10-25 12:11:27 +0800 |
|---|---|---|
| committer | Courtney Goeltzenleuchter <courtney@LunarG.com> | 2014-10-31 15:29:19 -0600 |
| commit | 23e51e336360dfa5e9acd57d935acd2dd56aeb58 (patch) | |
| tree | f4072bac9bdd0235a07d51f61c03cc666c9bb8cd | |
| parent | 5255f7bcdbc267620157884f975ad29394047f6f (diff) | |
| download | usermoji-23e51e336360dfa5e9acd57d935acd2dd56aeb58.tar.xz | |
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.
| -rw-r--r-- | demos/tri.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/demos/tri.c b/demos/tri.c index 5474fe37..a7f6d690 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 <stdio.h> #include <stdlib.h> #include <string.h> @@ -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, |
