glGenBuffers返回0xffffffff作为缓冲区名称 [英] glGenBuffers returns 0xffffffff as buffer name

查看:173
本文介绍了glGenBuffers返回0xffffffff作为缓冲区名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码(在iPhone上为OpenglES2.0):

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

glGenBuffers(1, &tmp->m_vbo);

其中tmp-> m_vbo是无符号整数.

where tmp->m_vbo is unsigned int.

在大多数情况下,tmp-> m_vbo是有效的,并且一切正常,但是有时返回的值为0xffffffff,而我第一次尝试使用该vbo会在glDrawElements中崩溃.

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 ?

谢谢.

推荐答案

我找到了原因:上下文似乎有些问题.我使用了两个线程,一个加载线程和一个主线程,每个线程都有各自的上下文(共享数据).在设置所需的上下文(以避免重复的SetContext调用)之前,我要检查一个当前上下文"值,并且以某种方式将当前上下文"值设置为正确的上下文,但是EAGLView中的实际上下文不是. 解决方法是使用EAGLView中的currentContext代替我自己的值进行测试.

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.

这篇关于glGenBuffers返回0xffffffff作为缓冲区名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆