sharpGL in C# wpf cannot generate buffers

1.1k views Asked by At

This simple code gives system exception and I cannot trace it since I cannot make output to console in wpf.

OpenGL gl = new OpenGL();
// OpenGL gl = openGLControl.OpenGL; doesnt change result
uint[] buf = new uint[1];
buf.Initialize();
gl.GenBuffers(1, buf); //commenting this line out, makes the exception vanish

What could cause GenBuffers method to raise the system exception in SharpGL.dll?

Using last version of sharpGL and .Net 4.0 targeted VS2012.

Should I install opengl for C++ and use a wrapper of that in C# ?

1

There are 1 answers

1
Amc_rtty On

I would have posted this as a comment, but I don't have enough rep for that: try setting the RenderContextType to DIBSection, to disable hardware acceleration and see if it still throws the exception.

        uint[] buf = new uint[1];
        buf.Initialize();

        var cn = new OpenGLControl();
        cn.RenderContextType = RenderContextType.DIBSection;
        cn.OpenGL.GenBuffers(1, buf);