我正在使用来自最新nuget包的OpenTK.GLControl。我正在学习本教程:http://dreamstatecoding.blogspot.com/2017/02/opengl-4-with-opentk-in-c-part-12-basic.html
我的视频卡是Intel®HD Graphics 530,要使用的OpenGL是3.2(我可以在着色器中指定3.3版本)
以下行会导致问题:
namespace WindowsForms3D.Components.Renderables
{
public class ColoredRenderObject : ARenderable
{
public ColoredRenderObject(ColoredVertex[] vertices, int program)
: base(program, vertices.Length)
{
// create first buffer: vertex
GL.NamedBufferStorage(
Buffer,
ColoredVertex.Size * vertices.Length, // the size needed by this buffer
vertices, // data to initialize with
BufferStorageFlags.MapWriteBit); // at this point we will only write to the buffer
GL.VertexArrayAttribBinding(VertexArray, 0, 0);
GL.EnableVertexArrayAttrib(VertexArray, 0);
GL.VertexArrayAttribFormat(
VertexArray,
0, // attribute index, from the shader location = 0
4, // size of attribute, vec4
VertexAttribType.Float, // contains floats
false, // does not need to be normalized as it is already, floats ignore this flag anyway
0); // relative offset, first item
GL.VertexArrayAttribBinding(VertexArray, 1, 0);
GL.EnableVertexArrayAttrib(VertexArray, 1);
GL.VertexArrayAttribFormat(
VertexArray,
1, // attribute index, from the shader location = 1
4, // size of attribute, vec4
VertexAttribType.Float, // contains floats
false, // does not need to be normalized as it is already, floats ignore this flag anyway
16); // relative offset after a vec4
// link the vertex array and buffer and provide the stride as size of Vertex
GL.VertexArrayVertexBuffer(VertexArray, 0, Buffer, IntPtr.Zero, ColoredVertex.Size);
}
}
}
GL.NamedBufferStorage
导致System.AccessViolationException;我了解这是由于opengl版本较旧(如此处OpenTK.Core - GL.NamedBufferStorage raises System.AccessViolationException所示)
那么,如何修改本教程以使其与我的OpenGL版本一起使用?可以选择什么功能呢?