iphone - OpenGL ES - glImageProcessing - 移除纹理

标签 iphone objective-c c opengl-es

我正在使用 glImageProcessing来自 Apple 的示例,用于执行一些过滤操作。但是,我希望能够将新图像加载到纹理中。

目前,该示例使用以下行加载图像:

loadTexture("Image.png", &Input, &renderer); 

(我已对其进行修改以接受实际的 UIImage):

loadTexture(image, &Input, &renderer);

但是,在测试如何重绘新图像时,我尝试实现(在 Imaging.c 中):

loadTexture(image, &Input, &renderer);
loadTexture(newImage, &Input, &renderer);

示例应用程序在以下行崩溃:

CFDataRef data = CGDataProviderCopyData(CGImageGetDataProvider(CGImage)); 

在 Texture.c 中

我也尝试通过

删除事件纹理
loadTexture(image, &Input, &renderer);
glDeleteTextures(GL_TEXTURE_2D, 0);
loadTexture(newImage, &Input, &renderer);

这也失败了。

有谁知道如何从 opengl es 界面中删除图像/纹理以便我可以加载新图像???

注意:在 Texture.c 中,苹果声明“此函数的调用者负责删除 GL 纹理对象。”我想这就是我要问的方法。 Apple 似乎没有提供任何线索 ;-)

另请注意:我在很多地方看到过这个问题,但似乎没有人有答案。我相信其他人也会感谢有关此主题的一些帮助!非常感谢!

干杯, 布雷特

最佳答案

您在第二种情况下错误地使用了 glDeleteTextures()。该函数的第一个参数是您希望删除多少纹理,第二个参数是纹理名称数组(或指向单个纹理名称的指针)。您需要执行以下操作:

glDeleteTextures(1, &textureName);

其中 textureName 是创建时获得的纹理名称。看起来该值存储在传递给 loadTexture() 的图像结构的 texID 组件中。

这并不能完全解释您看到的崩溃,这似乎是您输入图像的内存管理问题(可能是一个自动释放的对象,在您访问其 CGImage 组件之前被丢弃)。

关于iphone - OpenGL ES - glImageProcessing - 移除纹理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6612983/

相关文章:

ios - Xcode 6.3 上架构 x86_64 的 undefined symbol

ios - 添加到 NSMutableDictionary 而不替换相似的键

c - 该行有多个标记错误

python - Python 中的希尔伯特变换?

iphone - `[[[UIApplication sharedApplication] keyWindow] addSubview:` 底部留有空间

iOS:SWRevealViewController 和多个 NavigationControllers

android - 如何在 Ionic For IOS 中点击通话?

iphone - 如何格式化没有科学记数法或小数的数字

c - 无法在 C 中打印数组值

iphone - NS未知异常: this class is not key value coding-compliant for the key piewTextField