Imagination PowerVR SDK Blog

Switching Textures used by PFX at runtime.


#1

Hi there,



I’m writing an app that requires my textures to update at regular intervals - perhaps 4 - 8 times per day.



Is there support for dynamically loading a new texture and then updating an active PFX to use the new texture.



If this is possible is there an example of it being done in any of the demos? Most of the demos I’ve seen that switch textures seem to have them all loaded upfront on different texture slots in the PFX. This isn’t possible for me because of size constraints and because I plan for the new texture file to be acquired from the web and updated at run-time.



Any ideas?



Andre.


#2

Hello



During the rendering you can provide your own image (GLuint mytexture for instance ) that can be loaded dynamically or store in an pvr image array.



in your code :

glActiveTexture(GL_TEXTURE0);<br />
glBindTexture(GL_TEXTURE_2D, mytexture);
```<br />
<br />
in the pfx :<br />
UNIFORM sTexture				TEXTURE0<br />
<br />
So as long your texture is binded using glBindTexture you can render it any scheduled time your want.<br />
<br />
<br />
regards<br />
david

#3

Hi David,



I hadn’t thought about just overwriting the texture unit with a new texture like this. So simple!



I’ve done it and it works great, thanks for your help :slight_smile:



Andre.