Why does OpenGL's glDrawArrays() fail with GL_INVALID_OPERATION under Core Profile 3.2, but not 3.3 or 4.2?

喜夏-厌秋 提交于 2019-12-05 11:20:38

I have a wild guess.

As I understand it, all OpenGL calls must happen on the same thread. This restriction does not mix well with goroutines, since the same goroutine can run on different threads at different points in its execution.

To get around this problem, you need to lock your main goroutine (or whatever goroutine's doing OpenGL calls) to its current thread as soon as it starts, before initializing OpenGL.

import "runtime"

func main() {
    runtime.LockOSThread()

    ...
}

The reason you're seeing inconsistent results could be explained by implementation differences.

It's not just DrawArrays, I was mistaken here. Somehow my way of calling glVertexAttribPointer is the problem here: in any strict core profile, whether 3.2 or 4.2... will investigate further. In a 4.2 non-strict context, no problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!