KlaxXxon's picture

GL.GenBuffers throws null object exception

Hi,

I'm trying to get vertex buffers working, but I can't get even beyond GenBuffers.
private int vertexBufferHandle;
.
.
.

GL.GenBuffers(1, out this.vertexBufferHandle);
 
            GL.BindBuffer(BufferTarget.ArrayBuffer, this.vertexBufferHandle);
 
            GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(vertices.Length * 6 * sizeof(float)), vertices, BufferUsageHint.StaticDraw);

The GenBuffers call throws NullReferenceException.

Thanks for help.


Comments

Comment viewing options

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

GenBuffers was introduced in OpenGL 1.5. Check that your drivers support 1.5 before using it:

string version = GL.GetString(StringName.Version);
 
if (version >= "1.5")
{
    ...
}