0

I used the below code to load the texture on a object.

- (void)ldText:(UIImage *)Image
{
    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D, texture);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    CGImageRef cgImage = Image.CGImage;
    float Width = CGImageGetWidth(cgImage);
    float Height = CGImageGetHeight(cgImage);
    CFDataRef data = CGDataProviderCopyData(CGImageGetDataProvider(cgImage));

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, CFDataGetBytePtr(data));
}

The texture is getting mapped properly.

I need to load two textures now. And the textures should get changed at regular interval of time. Is it possible? Can Some one guide me how to proceed from here?

*Update: I loaded another texture with Image2, with the function ldText2. And updating it in each "update view". Now I get two textures on the same object and getting changed whenever the "update" function is called. I interchange the texture1 and texture2 each time when the "Update" function is called. But the problem is time interval! I want it to happen slow. How to set a time interval for this?*

4

1 回答 1

0

默认情况下,GLKViewController 为您提供一个动画循环,它根据preferredFramesPerSecond属性调用更新。(实际使用的价格在framesPerSecond属性中)。

您可以通过设置首选速率获得一些控制,但如果您希望显示保持静止超过几分之一秒,则更有可能想要关闭动画循环。为此,请将paused属性设置为YES,然后覆盖resumeOnDidBecomeActive以返回NO。然后,您需要确保display在适当的时间在视图上调用,方法是明确地这样做,或者确保enableSetNeedsDisplay视图上的属性设置为YES,并使视图无效。

如果您出于其他原因想要保持动画循环处于活动状态,则可以应用 Matic Oblak 使用延迟选择器执行的建议来更改纹理,或者设置一个标志来触发更新方法来更改纹理。

于 2013-05-12T07:20:17.430 回答