From 3f3237a822617f644d1e9e257f56e44b2adb185d Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Tue, 6 Oct 2009 08:29:12 +0000 Subject: [PATCH] Added GetActiveAttrib, GetActiveUniform, GetActiveUniformName and GetActiveUniformBlockName overloads that return strings. Fixes issue [#1213]: "[GL] let GetUniformName() return String". --- Source/OpenTK/Graphics/OpenGL/GLHelper.cs | 64 +++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/Source/OpenTK/Graphics/OpenGL/GLHelper.cs b/Source/OpenTK/Graphics/OpenGL/GLHelper.cs index af662e68..a7a8ecb6 100644 --- a/Source/OpenTK/Graphics/OpenGL/GLHelper.cs +++ b/Source/OpenTK/Graphics/OpenGL/GLHelper.cs @@ -663,6 +663,68 @@ namespace OpenTK.Graphics.OpenGL #endregion + #region Shaders + + #region GetActiveAttrib + + public static string GetActiveAttrib(int program, int index, out int size, out ActiveAttribType type) + { + int length; + GetProgram(program, OpenTK.Graphics.OpenGL.ProgramParameter.ActiveAttributeMaxLength, out length); + + StringBuilder sb = new StringBuilder(length == 0 ? 1 : length); + GetActiveAttrib(program, index, sb.Length, out length, out size, out type, sb); + return sb.ToString(); + } + + #endregion + + #region GetActiveUniform + + public static string GetActiveUniform(int program, int uniformIndex, out int size, out ActiveUniformType type) + { + int length; + GetProgram(program, OpenTK.Graphics.OpenGL.ProgramParameter.ActiveUniformMaxLength, out length); + + StringBuilder sb = new StringBuilder(length == 0 ? 1 : length); + GetActiveUniform(program, uniformIndex, sb.Length, out length, out size, out type, sb); + return sb.ToString(); + } + + #endregion + + #region GetActiveUniformName + + public static string GetActiveUniformName(int program, int uniformIndex) + { + int length; + GetProgram(program, OpenTK.Graphics.OpenGL.ProgramParameter.ActiveUniformMaxLength, out length); + if (length == 0) + return String.Empty; + + StringBuilder sb = new StringBuilder(length); + GetActiveUniformName(program, uniformIndex, sb.Length, out length, sb); + return sb.ToString(); + } + + #endregion + + #region GetActiveUniformBlockName + + public static string GetActiveUniformBlockName(int program, int uniformIndex) + { + int length; + GetProgram(program, OpenTK.Graphics.OpenGL.ProgramParameter.ActiveUniformBlockMaxNameLength, out length); + if (length == 0) + return String.Empty; + + StringBuilder sb = new StringBuilder(length); + GetActiveUniformBlockName(program, uniformIndex, sb.Length, out length, sb); + return sb.ToString(); + } + + #endregion + #region public static void ShaderSource(Int32 shader, System.String @string) public static void ShaderSource(Int32 shader, System.String @string) @@ -739,6 +801,8 @@ namespace OpenTK.Graphics.OpenGL #endregion + #endregion + #region public static void PointParameter(PointSpriteCoordOriginParameter param) ///