deo91's picture

[Error] 'System.AccessViolationException' in OpenTK.dll

Hi guys,
I retrieve sometimes this Error: 'System.AccessViolationException' on " line  GL.BufferData(BufferTarget.ArrayBuffer, new IntPtr(colordata.Length * BlittableValueType.StrideOf(vertices)), colordata, BufferUsageHint.StaticDraw);"


  void LoadHandler(object sender, EventArgs e)
            var vertices = GetVector3();
            if (vertices == null)
                vbo_size = vertices.Length;
                GL.GenBuffers(1, out vbo_id);
                GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_id);
                GL.BufferData(BufferTarget.ArrayBuffer, new IntPtr(vertices.Length * BlittableValueType.StrideOf(vertices)), vertices, BufferUsageHint.StaticDraw);
                // Generate Array Buffer Id
                GL.GenBuffers(1, out vbo_color_id);
                // Bind current context to Array Buffer ID
                GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_color_id);
                // Send data to buffer
                GL.BufferData(BufferTarget.ArrayBuffer, new IntPtr(colordata.Length * BlittableValueType.StrideOf(vertices)), colordata, BufferUsageHint.StaticDraw);

how can I resolve it? colordata lenght is equal to vertices lenght.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Snorkel's picture

Are you sure that that for the second buffer the size in bytes is correct ?
Not sure what BlittableValueType is actually. Also you don't show what type vertices and colordata tables are and what type they contain.

deo91's picture

colordata is an int vector declared as " int[] colordata;" and allocated with same lenght of vertices.

                        colordata = new int[index];
                        var vertices = new Vector3[index];

maybe I should change BlitterableValueType?