一些(随机)纹理在OpenGL中呈现倒置?

时间:2012-03-20 02:22:14

标签: xcode opengl-es-2.0 textures glkit

我在Objective-C中使用GLKit(OpenGL ES2)来制作iPhone游戏。

我对此没有很多经验,所以如果我做错了什么就不会让我感到惊讶,但是我正在生成一堆对象,这些对象大致相同。实际上我正在为它们使用一个类,并且只是创建了更多类的实例来创建更多的对象,但不知何故,一些对象的纹理被颠倒了。

我看不出这是怎么回事,因为它是用于所有对象的相同代码,其中一些是正确的,有些则不正确。

非常感谢任何帮助/想法。

2 个答案:

答案 0 :(得分:0)

检查[UIImage imageOrientation]属性以查看图像是否被翻转。可能是one of these values

UIImageOrientationUp
UIImageOrientationDown
UIImageOrientationLeft
UIImageOrientationRight
UIImageOrientationUpMirrored
UIImageOrientationDownMirrored
UIImageOrientationLeftMirrored
UIImageOrientationRightMirrored

答案 1 :(得分:0)

事实证明,这是因为没有反复使用纹理,而是每次需要时重新生成纹理。

总而言之,最好只生成纹理一次并重复使用它,因此解决方案就是这样做。