I'm using OpenTK, an OpenGL library for C#. I started a project on my main PC(Nvidia video card) and everything was fine. Then I continued it on my laptop(AMD video card) and I got an exception when calling GL.EnableVertexArrayAttrib.
Minimal code for reproduction:
// Create a shader with a `test` attribute int vertexShaderID = GL.CreateShader(ShaderType.VertexShader); GL.ShaderSource(vertexShaderID, "in vec3 test; void main() { gl_Position = vec4(0, 0, 0, 0); }"); GL.CompileShader(vertexShaderID); int fragmentShaderID = GL.CreateShader(ShaderType.FragmentShader); GL.ShaderSource(fragmentShaderID, "void main() { gl_FragColor = vec4(0, 0, 0, 0); }"); GL.CompileShader(fragmentShaderID); int programID = GL.CreateProgram(); GL.UseProgram(programID); GL.AttachShader(programID, vertexShaderID); GL.AttachShader(programID, fragmentShaderID); GL.LinkProgram(programID); // Make a VAO, get the `test` attribute location and enable it int vao = GL.GenVertexArray(); int attrib = GL.GetAttribLocation(programID, "test"); GL.EnableVertexArrayAttrib(vao, attrib); // Throws AccessViolationException on AMD, but not on NVIDIA
I have the latest GPU drivers and latest OpenTK on the Windows 8.1 AMD laptop.
GL.UseProgram
before retrieving the attribute? Let's suppose these questions are solved in a right way. Then it may happen that the attribute "test" can not be retrieved due to the GL linker optimized it out because it's not used. – Ripi2GL.UseProgram
, those are important, I added them. But that doesn't change anything, it still crashes on the AMD laptop. – Gergő Gutyina