Merge commit 'origin/master' into gallium-0.2
[mesa.git] / src / mesa / shader / shader_api.c
index 854f8bfdaa61c215edf03c8a46cefe5980a12cf1..266ecc4ef212fa159df45744a5dc5a96182298d7 100644 (file)
@@ -47,7 +47,7 @@
 #include "shader/shader_api.h"
 #include "shader/slang/slang_compile.h"
 #include "shader/slang/slang_link.h"
-
+#include "glapi/dispatch.h"
 
 
 #ifndef GL_PROGRAM_BINARY_LENGTH_OES
@@ -455,7 +455,13 @@ _mesa_attach_shader(GLcontext *ctx, GLuint program, GLuint shader)
    n = shProg->NumShaders;
    for (i = 0; i < n; i++) {
       if (shProg->Shaders[i] == sh) {
-         /* already attached */
+         /* The shader is already attched to this program.  The
+          * GL_ARB_shader_objects spec says:
+          *
+          *     "The error INVALID_OPERATION is generated by AttachObjectARB
+          *     if <obj> is already attached to <containerObj>."
+          */
+         _mesa_error(ctx, GL_INVALID_OPERATION, "glAttachShader");
          return;
       }
    }
@@ -919,24 +925,15 @@ _mesa_get_attached_shaders(GLcontext *ctx, GLuint program, GLsizei maxCount,
 static GLuint
 _mesa_get_handle(GLcontext *ctx, GLenum pname)
 {
-#if 0
-   GET_CURRENT_CONTEXT(ctx);
-
-   switch (pname) {
-   case GL_PROGRAM_OBJECT_ARB:
-      {
-         struct gl2_program_intf **pro = ctx->Shader.CurrentProgram;
-
-         if (pro != NULL)
-            return (**pro)._container._generic.
-               GetName((struct gl2_generic_intf **) (pro));
-      }
-      break;
-   default:
+   GLint handle = 0;
+   
+   if (pname == GL_PROGRAM_OBJECT_ARB) {
+      CALL_GetIntegerv(ctx->Exec, (GL_CURRENT_PROGRAM, &handle));
+   } else {
       _mesa_error(ctx, GL_INVALID_ENUM, "glGetHandleARB");
    }
-#endif
-   return 0;
+
+   return handle;
 }