Fix Helper methods to use out Strings

This commit is contained in:
Fraser Waters 2017-07-27 12:21:21 +01:00
parent c395841b34
commit 62a2db426f
4 changed files with 38 additions and 54 deletions

View file

@ -175,10 +175,10 @@ namespace OpenTK.Graphics.ES20
{ {
int length; int length;
GetProgram(program, GetProgramParameterName.ActiveAttributeMaxLength, out length); GetProgram(program, GetProgramParameterName.ActiveAttributeMaxLength, out length);
StringBuilder sb = new StringBuilder(length == 0 ? 1 : length * 2); string str;
GetActiveAttrib(program, index, sb.Capacity, out length, out size, out type, sb); GetActiveAttrib(program, index, length == 0 ? 1 : length * 2, out length, out size, out type, out str);
return sb.ToString(); return str;
} }
public static string GetActiveUniform(int program, int uniformIndex, out int size, out ActiveUniformType type) public static string GetActiveUniform(int program, int uniformIndex, out int size, out ActiveUniformType type)
@ -186,9 +186,9 @@ namespace OpenTK.Graphics.ES20
int length; int length;
GetProgram(program, GetProgramParameterName.ActiveUniformMaxLength, out length); GetProgram(program, GetProgramParameterName.ActiveUniformMaxLength, out length);
StringBuilder sb = new StringBuilder(length == 0 ? 1 : length); string str;
GetActiveUniform(program, uniformIndex, sb.Capacity, out length, out size, out type, sb); GetActiveUniform(program, uniformIndex, length == 0 ? 1 : length, out length, out size, out type, out str);
return sb.ToString(); return str;
} }
public static void ShaderSource(Int32 shader, System.String @string) public static void ShaderSource(Int32 shader, System.String @string)
@ -218,9 +218,7 @@ namespace OpenTK.Graphics.ES20
info = String.Empty; info = String.Empty;
return; return;
} }
StringBuilder sb = new StringBuilder(length * 2); GL.GetShaderInfoLog((UInt32)shader, length * 2, &length, out info);
GL.GetShaderInfoLog((UInt32)shader, sb.Capacity, &length, sb);
info = sb.ToString();
} }
} }
@ -241,9 +239,7 @@ namespace OpenTK.Graphics.ES20
info = String.Empty; info = String.Empty;
return; return;
} }
StringBuilder sb = new StringBuilder(length * 2); GL.GetProgramInfoLog((UInt32)program, length * 2, &length, out info);
GL.GetProgramInfoLog((UInt32)program, sb.Capacity, &length, sb);
info = sb.ToString();
} }
} }

View file

@ -175,10 +175,10 @@ namespace OpenTK.Graphics.ES30
{ {
int length; int length;
GetProgram(program, ES30.GetProgramParameterName.ActiveAttributeMaxLength, out length); GetProgram(program, ES30.GetProgramParameterName.ActiveAttributeMaxLength, out length);
StringBuilder sb = new StringBuilder(length == 0 ? 1 : length * 2); string str;
GetActiveAttrib(program, index, sb.Capacity, out length, out size, out type, sb); GetActiveAttrib(program, index, length == 0 ? 1 : length * 2, out length, out size, out type, out str);
return sb.ToString(); return str;
} }
public static string GetActiveUniform(int program, int uniformIndex, out int size, out ActiveUniformType type) public static string GetActiveUniform(int program, int uniformIndex, out int size, out ActiveUniformType type)
@ -186,9 +186,9 @@ namespace OpenTK.Graphics.ES30
int length; int length;
GetProgram(program, ES30.GetProgramParameterName.ActiveUniformMaxLength, out length); GetProgram(program, ES30.GetProgramParameterName.ActiveUniformMaxLength, out length);
StringBuilder sb = new StringBuilder(length == 0 ? 1 : length); string str;
GetActiveUniform(program, uniformIndex, sb.Capacity, out length, out size, out type, sb); GetActiveUniform(program, uniformIndex, length == 0 ? 1 : length, out length, out size, out type, out str);
return sb.ToString(); return str;
} }
public static void ShaderSource(Int32 shader, System.String @string) public static void ShaderSource(Int32 shader, System.String @string)
@ -218,9 +218,7 @@ namespace OpenTK.Graphics.ES30
info = String.Empty; info = String.Empty;
return; return;
} }
StringBuilder sb = new StringBuilder(length * 2); GL.GetShaderInfoLog((UInt32)shader, length * 2, &length, out info);
GL.GetShaderInfoLog((UInt32)shader, sb.Capacity, &length, sb);
info = sb.ToString();
} }
} }
@ -241,9 +239,7 @@ namespace OpenTK.Graphics.ES30
info = String.Empty; info = String.Empty;
return; return;
} }
StringBuilder sb = new StringBuilder(length * 2); GL.GetProgramInfoLog((UInt32)program, length * 2, &length, out info);
GL.GetProgramInfoLog((UInt32)program, sb.Capacity, &length, sb);
info = sb.ToString();
} }
} }

View file

@ -1889,10 +1889,10 @@ namespace OpenTK.Graphics.OpenGL
{ {
int length; int length;
GetProgram(program, OpenTK.Graphics.OpenGL.GetProgramParameterName.ActiveAttributeMaxLength, out length); GetProgram(program, OpenTK.Graphics.OpenGL.GetProgramParameterName.ActiveAttributeMaxLength, out length);
StringBuilder sb = new StringBuilder(length == 0 ? 1 : length * 2); string str;
GetActiveAttrib(program, index, sb.Capacity, out length, out size, out type, sb); GetActiveAttrib(program, index, length == 0 ? 1 : length * 2, out length, out size, out type, out str);
return sb.ToString(); return str;
} }
/// <summary> /// <summary>
@ -1919,9 +1919,9 @@ namespace OpenTK.Graphics.OpenGL
int length; int length;
GetProgram(program, OpenTK.Graphics.OpenGL.GetProgramParameterName.ActiveUniformMaxLength, out length); GetProgram(program, OpenTK.Graphics.OpenGL.GetProgramParameterName.ActiveUniformMaxLength, out length);
StringBuilder sb = new StringBuilder(length == 0 ? 1 : length); string str;
GetActiveUniform(program, uniformIndex, sb.Capacity, out length, out size, out type, sb); GetActiveUniform(program, uniformIndex, length == 0 ? 1 : length, out length, out size, out type, out str);
return sb.ToString(); return str;
} }
/// <summary> /// <summary>
@ -1941,10 +1941,10 @@ namespace OpenTK.Graphics.OpenGL
{ {
int length; int length;
GetProgram(program, OpenTK.Graphics.OpenGL.GetProgramParameterName.ActiveUniformMaxLength, out length); GetProgram(program, OpenTK.Graphics.OpenGL.GetProgramParameterName.ActiveUniformMaxLength, out length);
StringBuilder sb = new StringBuilder(length == 0 ? 1 : length * 2); string str;
GetActiveUniformName(program, uniformIndex, sb.Capacity, out length, sb); GetActiveUniformName(program, uniformIndex, length == 0 ? 1 : length * 2, out length, out str);
return sb.ToString(); return str;
} }
/// <summary> /// <summary>
@ -1964,10 +1964,10 @@ namespace OpenTK.Graphics.OpenGL
{ {
int length; int length;
GetProgram(program, OpenTK.Graphics.OpenGL.GetProgramParameterName.ActiveUniformBlockMaxNameLength, out length); GetProgram(program, OpenTK.Graphics.OpenGL.GetProgramParameterName.ActiveUniformBlockMaxNameLength, out length);
StringBuilder sb = new StringBuilder(length == 0 ? 1 : length * 2); string str;
GetActiveUniformBlockName(program, uniformIndex, sb.Capacity, out length, sb); GetActiveUniformBlockName(program, uniformIndex, length == 0 ? 1 : length * 2, out length, out str);
return sb.ToString(); return str;
} }
/// <summary> /// <summary>
@ -2027,9 +2027,7 @@ namespace OpenTK.Graphics.OpenGL
info = String.Empty; info = String.Empty;
return; return;
} }
StringBuilder sb = new StringBuilder(length * 2); GL.GetShaderInfoLog((UInt32)shader, length * 2, &length, out info);
GL.GetShaderInfoLog((UInt32)shader, sb.Capacity, &length, sb);
info = sb.ToString();
} }
} }
@ -2070,9 +2068,7 @@ namespace OpenTK.Graphics.OpenGL
info = String.Empty; info = String.Empty;
return; return;
} }
StringBuilder sb = new StringBuilder(length * 2); GL.GetProgramInfoLog((UInt32)program, length * 2, &length, out info);
GL.GetProgramInfoLog((UInt32)program, sb.Capacity, &length, sb);
info = sb.ToString();
} }
} }

View file

@ -246,10 +246,10 @@ namespace OpenTK.Graphics.OpenGL4
{ {
int length; int length;
GetProgram(program, OpenGL4.GetProgramParameterName.ActiveAttributeMaxLength, out length); GetProgram(program, OpenGL4.GetProgramParameterName.ActiveAttributeMaxLength, out length);
StringBuilder sb = new StringBuilder(length == 0 ? 1 : length * 2); string str;
GetActiveAttrib(program, index, sb.Capacity, out length, out size, out type, sb); GetActiveAttrib(program, index, length == 0 ? 1 : length * 2, out length, out size, out type, out str);
return sb.ToString(); return str;
} }
public static string GetActiveUniform(int program, int uniformIndex, out int size, out ActiveUniformType type) public static string GetActiveUniform(int program, int uniformIndex, out int size, out ActiveUniformType type)
@ -257,9 +257,9 @@ namespace OpenTK.Graphics.OpenGL4
int length; int length;
GetProgram(program, OpenGL4.GetProgramParameterName.ActiveUniformMaxLength, out length); GetProgram(program, OpenGL4.GetProgramParameterName.ActiveUniformMaxLength, out length);
StringBuilder sb = new StringBuilder(length == 0 ? 1 : length); string str;
GetActiveUniform(program, uniformIndex, sb.Capacity, out length, out size, out type, sb); GetActiveUniform(program, uniformIndex, length == 0 ? 1 : length, out length, out size, out type, out str);
return sb.ToString(); return str;
} }
public static void ShaderSource(Int32 shader, System.String @string) public static void ShaderSource(Int32 shader, System.String @string)
@ -289,9 +289,7 @@ namespace OpenTK.Graphics.OpenGL4
info = String.Empty; info = String.Empty;
return; return;
} }
StringBuilder sb = new StringBuilder(length * 2); GL.GetShaderInfoLog((UInt32)shader, length * 2, &length, out info);
GL.GetShaderInfoLog((UInt32)shader, sb.Capacity, &length, sb);
info = sb.ToString();
} }
} }
@ -312,9 +310,7 @@ namespace OpenTK.Graphics.OpenGL4
info = String.Empty; info = String.Empty;
return; return;
} }
StringBuilder sb = new StringBuilder(length * 2); GL.GetProgramInfoLog((UInt32)program, length * 2, &length, out info);
GL.GetProgramInfoLog((UInt32)program, sb.Capacity, &length, sb);
info = sb.ToString();
} }
} }