OpenTKTutorialContent icon indicating copy to clipboard operation
OpenTKTutorialContent copied to clipboard

Access violation on call of GL.DrawElements in Tutorial 6

Open uzername opened this issue 6 years ago • 1 comments

https://github.com/neokabuto/OpenTKTutorialContent/blob/60e9668c2f283a3d9600d62fd67a30e619e7d9c9/OpenTKTutorial6/OpenTKTutorial6/Game.cs#L104

I am using OpenTK 3.0.1 from official Nuget, and I get access violation (writing attempt to protected memory) error on this line. In tutorial 5 you use GL.DrawArrays and it's fine there

uzername avatar May 28 '19 10:05 uzername

This is sort of an embarrassingly long standing issue. It seems to be something non-deterministic that loves to "fix" itself. I've spent hours trying to figure it out, but it's really inconsistent on when it happens.

Can you try the change I added in the OpenTK 3 PR, https://github.com/neokabuto/OpenTKTutorialContent/pull/13/files#diff-816f14b5ba6b1b047326f50ca21fe968R167 (thanks again for inspiring me to finally upgrade these)? I'm pretty sure I finally (not sure why it took me so long) figured out it's a race condition where the first render code was running before the first update code occasionally (which I thought I had tested for previously with no success, but it seems to work). This if statement just prevents it from trying to render until we know we have some vertices to draw.

neokabuto avatar Jun 02 '19 22:06 neokabuto