Mesa (gallium-0.2): util: check for frag/vertShader=0 before attaching

Brian Paul brianp at kemper.freedesktop.org
Thu Dec 18 15:02:05 PST 2008


Module: Mesa
Branch: gallium-0.2
Commit: 7d41f10605c9e31b8d427f9f63f6505b187ac637
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7d41f10605c9e31b8d427f9f63f6505b187ac637

Author: Brian Paul <brian.paul at tungstengraphics.com>
Date:   Wed Dec 17 13:58:05 2008 -0700

util: check for frag/vertShader=0 before attaching

---

 progs/util/shaderutil.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/progs/util/shaderutil.c b/progs/util/shaderutil.c
index 7458513..2f1c4e3 100644
--- a/progs/util/shaderutil.c
+++ b/progs/util/shaderutil.c
@@ -6,6 +6,7 @@
  */
 
 
+#include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <GL/glut.h>
@@ -106,8 +107,12 @@ LinkShaders(GLuint vertShader, GLuint fragShader)
 {
    GLuint program = glCreateProgram_func();
 
-   glAttachShader_func(program, fragShader);
-   glAttachShader_func(program, vertShader);
+   assert(vertShader || fragShader);
+
+   if (fragShader)
+      glAttachShader_func(program, fragShader);
+   if (vertShader)
+      glAttachShader_func(program, vertShader);
    glLinkProgram_func(program);
 
    /* check link */



More information about the mesa-commit mailing list