
[Error] 'System.AccessViolationException' in OpenTK.dll
Posted Sunday, 14 October, 2012 - 16:12 by deo91 inHi guys,
I retrieve sometimes this Error: 'System.AccessViolationException' on " line GL.BufferData(BufferTarget.ArrayBuffer, new IntPtr(colordata.Length * BlittableValueType.StrideOf(vertices)), colordata, BufferUsageHint.StaticDraw);"
mycode:
void LoadHandler(object sender, EventArgs e) { var vertices = GetVector3(); if (vertices == null) { this.Close(); } else { GL.Enable(EnableCap.DepthTest); 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.


Comments
Re: [Error] 'System.AccessViolationException' in OpenTK.dll
Are you sure that that for the second buffer the size in bytes is correct ?
Not sure what
BlittableValueTypeis actually. Also you don't show what type vertices and colordata tables are and what type they contain.Re: [Error] 'System.AccessViolationException' in OpenTK.dll
colordata is an int vector declared as " int[] colordata;" and allocated with same lenght of vertices.
maybe I should change
BlitterableValueType? http://en.wikipedia.org/wiki/Blittable_types