OpenTK GetActiveUniform handle is invalid

0

I'm trying to get all uniforms whithin a GLSL program, but GL.GetActiveUniform is throwing an error :

{System.Runtime.InteropServices.COMException (0x80070006): The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE)) at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode) at System.Runtime.InteropServices.Marshal.FreeHGlobal(IntPtr hglobal) at OpenTK.Graphics.OpenGL.GL.GetActiveUniform(UInt32 program, UInt32 index, Int32 bufSize, Int32& length, Int32& size, ActiveUniformType& type, StringBuilder name)}

Here's my code :

int count = 0;

GL.GetProgram(_shader.id, GetProgramParameterName.ActiveUniforms, out count);

for (uint i = 0; i < count; i++)
{
    System.Text.StringBuilder name = new System.Text.StringBuilder();
    int length = 0,
    size = 0;
    ActiveUniformType uniformType;

    GL.GetActiveUniform((uint)(_shader.id), i, 120, out length, out size, out uniformType, name);
    int location = GL.GetUniformLocation(_shader.id, name.ToString());

    AddUniform(name.ToString().Replace(" ", ""), new Uniform(location, uniformType));
}
c#
glsl
opentk
asked on Stack Overflow Dec 30, 2017 by David Neves • edited Dec 30, 2017 by Rabbid76

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0