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.
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.
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.
This return value is a -1. You should check GL error after glGenBuffers
.