OpenGL Vertex Buffer doesn't draw anything in golang

前端 未结 4 1751
忘了有多久
忘了有多久 2021-01-03 05:52

I tried to use this tutorial with Golang: http://www.opengl-tutorial.org/beginners-tutorials/tutorial-2-the-first-triangle/ The go-version opens the window and makes the bac

4条回答
  •  没有蜡笔的小新
    2021-01-03 06:37

    I had the same problem and I managed to fix it after looking at your post, so first of all thanks a lot.

    I managed to display a triangle by using the work branch of banthar bindings with this call to AttribPointer:

    vertexAttrib.AttribPointer(
            3,     // size
            gl.FLOAT, //type
            false, // normalized?
            0,     // stride
            nil) // array buffer offset
    

    and by passing the size in bytes to BufferData.

    [...]
    data := []float32{0, 1, 0, -1, -1, 0, 1, -1, 0}
    [...]
    gl.BufferData(gl.ARRAY_BUFFER, len(data)*4, data, gl.STATIC_DRAW)
    [...]
    

    There is probably a better way to pass the right length.

提交回复
热议问题