OpenGL Vertex Buffer doesn't draw anything in golang

前端 未结 4 1722
忘了有多久
忘了有多久 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:54

    I don't know how the OpenGL bindings to Go look exactly, but I can tell you at least this much:

    The last parameter to glVertexAttribPointer should be the byte offset from the start of the buffer object, so (in your case) 0.

    Note: The C type of that parameter generally should be int, as it's a byte offset. Instead, it's void* for legacy reasons - it used to have a different meaning before VBOs.

    Instead of &f try passing either a literal 0 or, if this doesn't work, a pointer with value equal to 0. How to do that in Go? This is for you to figure out, since I don't grok Go. I told you what OpenGL expects and I hope this much helps.


    Also: For debugging, please check glGetError() often.

提交回复
热议问题