glGenBuffers returns 0xffffffff as buffer name

谁说胖子不能爱 提交于 2019-12-11 07:16:23

问题


I have the following code (OpenglES2.0 on iphone):

glGenBuffers(1, &tmp->m_vbo);

where tmp->m_vbo is unsigned int.

For most of the time tmp->m_vbo is valid and everything works perfect, but sometimes the returned value is 0xffffffff and first time I try to use that vbo will crash in glDrawElements.

Anyone knows what might cause this ?

Thanks.


回答1:


I found the cause: there seemed to be something with the context. I used two threads, a loading thread and the main thread, each with each context (shared data). I had a "current context" value that I was checking before setting the required context (to avoid redundant SetContext calls) and somehow my "current context" value was set to the correct context, but the actual context in EAGLView was not. The fix was to use currentContext from EAGLView for tests instead of my own value.




回答2:


I had the same issue!

In Swift:

func updateContext() {
    if glContext != EAGLContext.currentContext() {
        EAGLContext.setCurrentContext(glContext)
    }
}

Using updateContext() function right before a problem place in code solved my problem.




回答3:


This return value is a -1. You should check GL error after glGenBuffers.



来源:https://stackoverflow.com/questions/21355404/glgenbuffers-returns-0xffffffff-as-buffer-name

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