I recently got into a similar problem with Golang OpenGL bindings, and this question was one of the only links to it that I could find. However, none of the existing answers solved my problem, since the bindings are currently slightly different from each other in 2015 than in 2012.
A solution to my problem that was not yet covered by the existing answers included the gl.BufferData () function, called when the VBO was created.
A sample code in question will look like this:
[...] vertices := []float32{0, 1, 0, -1, -1, 0, 1, -1, 0} [...] gl.BufferData( gl.ARRAY_BUFFER, len(vertices)*4, unsafe.Pointer(&vertices), gl.STATIC_DRAW) [...]
In one of the proposed solutions, it is recommended to change this code approximately like this:
[...] vertices := []float32{0, 1, 0, -1, -1, 0, 1, -1, 0} [...] gl.BufferData( gl.ARRAY_BUFFER, len(vertices)*4, vertices, gl.STATIC_DRAW) [...]
However, the bindings I used had a different function signature used here, and with an error:
cannot use vertices (type []float32) as type unsafe.Pointer in argument to gl.BufferData
The solution that I finally found, and wanted to put here, so that no one else should go through the headache that he was trying to find out, looks like this:
[...] vertices := []float32{0, 1, 0, -1, -1, 0, 1, -1, 0} [...] gl.BufferData( gl.ARRAY_BUFFER, len(vertices)*4,
I also included a commented out option to replace len (vertices) * 4s, which produces exactly the same result, but finds "4" based on the type of the slice (float32 in this case)
Footnote
The links that I used:
github.com/go-gl/gl/all-core/gl
github.com/go-gl/glfw/v3.1/glfw
My OpenGL context was created with these hints: primaryMonitor: = glfw.GetPrimaryMonitor () vidMode: = primaryMonitor.GetVideoMode ()
glfw.WindowHint(glfw.ContextVersionMajor, 3) glfw.WindowHint(glfw.ContextVersionMinor, 3) glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile) glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True) glfw.WindowHint(glfw.RedBits, vidMode.RedBits) glfw.WindowHint(glfw.GreenBits, vidMode.GreenBits) glfw.WindowHint(glfw.BlueBits, vidMode.BlueBits) glfw.WindowHint(glfw.RefreshRate, vidMode.RefreshRate) glfw.WindowHint(glfw.Visible, glfw.False)