And*_*scu 10 iphone opengl-es opengl-es-2.0 ios5 glkit
我正在使用GLKit制作一个使用OpenGL ES 2.0的iPhone应用程序.我正在使用GLKTextureLoader同步加载纹理.
问题是对于某种纹理,它无法在第一次加载它.它给出了这个错误:
The operation couldn’t be completed. (GLKTextureLoaderErrorDomain error 8.)
对于此错误代码,Apple文档说明如下:
GLKTextureLoaderErrorUncompressedTextureUpload
An uncompressed texture could not be uploaded.
Available in iOS 5.0 and later.
Declared in GLKTextureLoader.h.
Run Code Online (Sandbox Code Playgroud)
(不是很多).
当opengl上下文处于某种繁忙状态或类似的情况时,我可以尝试加载纹理吗?
笔记:
欢迎任何想法,谢谢
编辑:
更多信息:
opengl上下文在我的所有屏幕之间共享.我这样做是为了让我的着色器和纹理在屏幕之间加载.
当我进入第二个屏幕时,会发生上述问题.在第一个屏幕中,我绘制没有问题的纹理东西(尽管其他纹理).
当我在游戏世界中加载我的内容(游戏实体)时,会发生上述问题.每个实体都尝试加载纹理.我有一个简单的缓存系统,只加载一次纹理,然后为所有其他实体返回相同的id.我在一种方法中同步加载实体.第一个实体无法加载纹理然后是第二个并且成功,然后第三个实体获得缓存的ID.
我正在调用加载实体方法,viewDidAppear并且我尝试在加载任何实体之前添加睡眠2秒但没有任何改变.
编辑:
纹理加载代码:
- (GLKTextureInfo *)loadTextureAtPath:(NSString*)path ofType:(NSString*)type withKey:(NSString *)key
{
GLKTextureInfo* tex;
tex = [self textureWithKey:key];
if (tex)
return tex;
NSDictionary * options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO],
GLKTextureLoaderOriginBottomLeft,
nil];
NSError * error;
NSString *bundlepath = [[NSBundle mainBundle] pathForResource:path ofType:type];
tex = [GLKTextureLoader textureWithContentsOfFile:bundlepath options:options error:&error];
if (tex == nil)
DLOG_LOCAL(@"Error loading texture: %@", [error localizedDescription]);
else
[textures setObject:tex forKey:key];
return tex;
}
Run Code Online (Sandbox Code Playgroud)
小智 31
我也得到了
The operation couldn’t be completed. (GLKTextureLoaderErrorDomain error 8.)
Run Code Online (Sandbox Code Playgroud)
在运行时晚期加载纹理时,几个先前的纹理已成功加载到发射之前.我能够通过在调用之前插入以下代码行来解决问题GLKTextureLoader:
NSLog(@"GL Error = %u", glGetError());
Run Code Online (Sandbox Code Playgroud)
果然,GL报告了一个错误,但它并没有要求我解决错误才能GLKTextureLoader工作.仅仅获得GL错误就足够了.
| 归档时间: |
|
| 查看次数: |
8360 次 |
| 最近记录: |