Working with multiple textures

I’m a little confused about how you work with multiple texture objects.

If I create several texture objects using;

URL url = c1.getResource( “com/thinkastronomy/galaxyin3d/star.gif” );
starTexture = TextureIO.newTexture( url, false, “gif” );

url = c1.getResource( “com/thinkastronomy/galaxyin3d/Spitzer_Color_Texture.jpg” );
galaxyTexture = TextureIO.newTexture( url, false, “jpg” );

url = c1.getResource( “com/thinkastronomy/galaxyin3d/particle.png” );
particleTexture = TextureIO.newTexture( url, false, “png” );

What I don’t understand is when to call texture.bind() and texture.enable() or texture.disable() when using these.

I’ve tried binding them right before use, but this sometimes gives the wrong texture being used. If I call enable() after the bind() I sometimes get nothing at all drawn. Can someone give me the rules for how to intersperse different textures when drawing?

        url = c1.getResource( "com/thinkastronomy/galaxyin3d/GalacticCore-2.png" );
        coreTexture = TextureIO.newTexture( url, false, "png" );

In theory you should call enable(), bind(), and disable() for each texture object in that order, with the geometry being drawn between the bind() and disable() calls. In practice you should probably be able to call enable() on one of the textures at the beginning, call bind() repeatedly on multiple textures, and call disable() when you’re done rendering textured geometry.

Thank you, that does indeed work for me. My problem was compounded by the fact that I accidentally created one of the textures as 64x63 pixels rather than 64x64. Not being a multiple of 32, it of course didn’t draw.