定期在单个图像上加载两个纹理-GLkit openglES [英] Load a two texture for a single image at a regular interval of time - GLkit openglES

查看:53
本文介绍了定期在单个图像上加载两个纹理-GLkit openglES的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的代码将纹理加载到对象上.

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));
}

纹理已正确映射.

我现在需要加载两个纹理.并且纹理应该在规则的时间间隔内更改.是否可以?有人可以指导我如何从这里继续吗?

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?

* 更新:我用Image2加载了另一个带有ldText2函数的纹理.并在每个更新视图"中对其进行更新.现在,我在同一个对象上获得了两个纹理,并且每当调用更新"函数时都会对其进行更改.每次调用更新"功能时,我都会互换Texture1和Texture2.但是问题是时间间隔!我希望它发生的慢.如何为此设置时间间隔? *

*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?*

推荐答案

默认情况下,GLKViewController为您提供了一个动画循环,该循环基于 preferredFramesPerSecond 属性调用更新.(实际使用的速率在 framesPerSecond 属性中).

By default GLKViewController provides you with an animation loop which calls update based on the preferredFramesPerSecond property. (The rate actually used is in the framesPerSecond property).

您可以通过设置首选速率来获得一些控制权,但是如果您希望显示器保持静态超过一秒钟的时间,您更有可能希望关闭动画循环.为此,请将 paused 属性设置为 YES ,并覆盖 resumeOnDidBecomeActive 以返回 NO .然后,您需要确保在适当的时间在视图上调用 display ,方法是显式地执行此操作,或者确保将视图上的 enableSetNeedsDisplay 属性设置为,并使视图无效.

You could gain some control by setting the preferred rate, but you are more likely to want to turn off the animation loop if you want the display to remain static for more than a fraction of a second. To do this, set the paused property to YES, and override resumeOnDidBecomeActive to return NO. You will then need to make sure display gets called on the view at the appropriate times, either by doing so explicitly or by making sure the enableSetNeedsDisplay property on the view is set to YES, and invalidating the view.

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

If you want to keep the animation loop active for other reasons, then Matic Oblak's suggestion of using a delayed selector execution can be applied to either change the texture, or to set a flag to trigger the update method to change the texture.

这篇关于定期在单个图像上加载两个纹理-GLkit openglES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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