Application slows down the first time a texture appears

I’m building a photo gallery app. In the app a set of images are loaded as textures, and usually shown one by one. When each new image enters the screen the app slows down a bit. When all images have been shown once everything works smoothly.

I assume the problem is that Panda is not uploading the images to the graphic card memory until they appear on screen for the first time. How can I force Panda to prepare the image immediately after loading it?

I noticed there is a prepare method in the Texture class, but if that’s what I should use, I don’t know where to get the PreparedGraphicsObjects to pass as parameter.

Thanks

Coincidentally, I was just answering a question in another thread about this method. But the call you need is NodePath.prepareScene(), and you pass it the GSG from your window. It’s described here in the FAQ.

David

Thanks, it works much better now.

There is still a small delay the first time I show all pictures at once. Any idea why that might be? It’s not a show stopper like it was before, but I would like to learn what Panda is doing behind the scenes. I’m going through the source code but I haven’t been able to figure it out.

It might be the vertex buffers. There’s a small bug in prepareScene(), in that it doesn’t pre-upload the vertex buffers in the 1.7.2 version, only the textures. I just committed a fix that should be available in tomorrow’s buildbot release if you’d care to try that out.

David