OpenTK: что является заменой GL.NamedBufferStorage (...)? - PullRequest
0 голосов
/ 18 февраля 2019

Я использую OpenTK.GLControl из последнего пакета nuget.Я следую этому уроку: http://dreamstatecoding.blogspot.com/2017/02/opengl-4-with-opentk-in-c-part-12-basic.html

Моя видеокарта - Intel® R 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 повышает System.AccessViolationException )

Итак, как мне изменить этот учебник, чтобы получитьэто работает с моей версией OpenGL?Какие функции выбрать вместо?

...