C# OpenTK/OpenGL属性名返回乱码

C# OpenTK/OpenGL属性名返回乱码,c#,opengl,graphics,shader,opentk,C#,Opengl,Graphics,Shader,Opentk,我一直在使用OpenTK开发渲染器。我最近发现我不能一次使用多个着色器进行渲染,所以我改变了我的系统。问题是,现在当所有的属性和制服都被加载并放入字典时,它们的名字完全是胡言乱语。这种胡言乱语的一个例子是“ü\b\aÈy7\aÀNU\u0006”(在着色器中称为“vPosition”)。有时“GetActivAttrib”也会作为一个ShaderVariable名称潜入。我已经在这个问题上被困太久了,所以我将感谢任何帮助 以下是加载着色器变量的代码,我确信问题出在这里: publ

我一直在使用OpenTK开发渲染器。我最近发现我不能一次使用多个着色器进行渲染,所以我改变了我的系统。问题是,现在当所有的属性和制服都被加载并放入字典时,它们的名字完全是胡言乱语。这种胡言乱语的一个例子是
“ü\b\aÈy7\aÀNU\u0006”
(在着色器中称为“vPosition”)。有时
“GetActivAttrib”
也会作为一个ShaderVariable名称潜入。我已经在这个问题上被困太久了,所以我将感谢任何帮助

以下是加载着色器变量的代码,我确信问题出在这里:

        public static void GetShaderVariables(int shaderProgramID, int selectedShaderID, Dictionary<string, int> AttributeDictionary, Dictionary<string, int> UniformDictionary, Dictionary<string, int> VBODictionary)
    {
        int shaderVariableLocation;

        int LinkStatus;
        GL.GetProgram(shaderProgramID, GetProgramParameterName.LinkStatus, out LinkStatus);
        if (LinkStatus == 0)
        {
            GL.LinkProgram(shaderProgramID); //Linking the program to the graphics card if its not already connected
        }

        GL.GetProgram(shaderProgramID, GetProgramParameterName.LinkStatus, out LinkStatus);
        if (LinkStatus == 1)
        {
            int VBOID;
            #region Storing all the Attributes of the selected Shader
            int shaderVariableAmount;
            GL.GetProgram(shaderProgramID, GetProgramParameterName.ActiveAttributes, out shaderVariableAmount);

            for (int i = 0; i <= shaderVariableAmount; i++)
            {
                GL.GetActiveAttrib(shaderProgramID, i, textBufferSize, out length, out size, out attributeType, shaderVariableStringBuilder);

                string shaderVariableName = shaderVariableStringBuilder.ToString();
                string VBOStringName = shaderVariableName + "VBO";

                shaderVariableLocation = GL.GetAttribLocation(shaderProgramID, shaderVariableName);
                if (shaderVariableLocation == -1)
                {
                    Console.WriteLine("Shader variable doesnt exist");
                    break;
                }

                GL.GenBuffers(1, out VBOID);

                //Stores the values given that the value is not already present in the Dictionary
                if (!AttributeDictionary.ContainsKey(shaderVariableName))
                    AttributeDictionary.Add(shaderVariableName, shaderVariableLocation);

                if (!VBODictionary.ContainsKey(VBOStringName))
                    VBODictionary.Add(VBOStringName, VBOID);
            }
            #endregion

            #region Storing all the Uniforms of the selected Shader
            shaderVariableAmount = 0;
            GL.GetProgram(shaderProgramID, GetProgramParameterName.ActiveUniforms, out shaderVariableAmount);

            for (int i = 0; i <= shaderVariableAmount; i++)
            {
                GL.GetActiveUniform(shaderProgramID, i, textBufferSize, out length, out size, out uniformType, shaderVariableStringBuilder);
                string shaderUniformVarName = shaderVariableStringBuilder.ToString();

                shaderVariableLocation = GL.GetUniformLocation(shaderProgramID, shaderUniformVarName);

                if (!UniformDictionary.ContainsKey(shaderUniformVarName))
                    UniformDictionary.Add(shaderUniformVarName, shaderVariableLocation);
            }
            #endregion
        }
        else
        {
            Console.Write(GL.GetProgramInfoLog(shaderProgramID));
            GL.GetError();
            throw new System.ArgumentException("Program failed to link");
        }
    }

阅读相关段落。我通读了它,我很快就会将它实现到我的代码中,非常感谢。
#version 330

in vec3 vPosition;
in vec3 vColor;

uniform mat4 modelview;

out vec4 color;



void main()
{
    gl_Position = modelview * vec4(vPosition, 1.0);

    color = vec4(vColor, 0);
}