OpenGL Vertex Buffer Issue in Go
In an attempt to display a triangle using OpenGL in Go, a user encountered a problem where the vertex buffer failed to render the shape. The Go code was derived from a tutorial, but unlike its C counterpart, it did not produce any output.
Cause of the Problem
The root cause of the issue lay in the arguments passed to vertexAttrib.AttribPointer(). Specifically, the user had incorrectly specified (void*)0 as the array buffer offset. This resulted in the application failing to find the vertex data.
Solution
To rectify the problem, the user switched to the work branch of the banthar bindings and made the following adjustments:
vertexAttrib.AttribPointer(
3, // size
gl.FLOAT, //type
false, // normalized?
0, // stride
nil) // array buffer offset
data := []float32{0, 1, 0, -1, -1, 0, 1, -1, 0}
[...]
gl.BufferData(gl.ARRAY_BUFFER, len(data)*4, data, gl.STATIC_DRAW)
[...]
Additional Notes
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3