2

I am attempting to plot something simple like a triangle using VBO's.

The example code is provided on github here:

https://github.com/dwmkerr/sharpgl/blob/master/source/SharpGL/Samples/WinForms/ModernOpenGLSample/Scene.cs

The following 'using' statements compile for me properly.

using SharpGL;
using SharpGL.SceneGraph;
using SharpGL.VertexBuffers;

My program crashes at this line:

vertexBufferArray.Create(gl);

It gives me the following exception:

An unhandled exception of type 'System.Exception' occurred in SharpGL.dll

Additional information: Extension function glGenVertexArrays not supported

Why would the program compile with the Create() function if one of its dependencies is not supported? What exactly is the best way to determine if the dependency is actually available and how to properly install it?

Timothy Swan
  • 623
  • 3
  • 9
  • 21
  • I'm having the same problem but with the `glCreateShader` function, inside my own project and in the sample project. Did you find any solutions yet? – ColmanJ Dec 27 '14 at 09:20

3 Answers3

0

you can check if the function is supported using openGLControl.OpenGL.IsExtensionFunctionSupported("glGenVertexArrays");

however this will always return false as long as there is no current rendering context (see here). This is what made the exception throw for me and calling the methods later in the application worked for me (note that the examples also gave the same exception).

You can check and see if the rendercontext is set using openGLControl.OpenGL.RenderContextProvider.RenderContextHandle != IntPtr.Zero

ColmanJ
  • 457
  • 2
  • 12
  • 28
0

Check if you have initialized with the proper OpenGL version. Default is 1.0, you can see the available enums in OpenGLVersion.cs

When creating the control, set control.OpenGLVersion property before calling EndInit() If you have problem only with vertex buffer arrays, then also check if RenderContextType is set to NativeWindow (even if you embed an OpenGLControl into a form) to have access to object buffer features.

This two step shall solve your problem.

Cpt Balu
  • 371
  • 3
  • 3
0

I have to set the following property for the SharpGL control in XAML RenderContextType="FBO" to avoid the exceptions.