Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  Working with multiple textures  (Read 470 times)
0 Members and 1 Guest are viewing this topic.
Offline btschumy

JGO n00b
*

Posts: 30



« on: 2006-07-03 22:18:00 »

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

Offline Ken Russell

JGO Kernel
*****

Posts: 3446
Medals: 3


Java games rock!


« Reply #1 on: 2006-07-04 00:28:15 »

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.
Offline btschumy

JGO n00b
*

Posts: 30



« Reply #2 on: 2006-07-04 09:33:28 »

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.
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.131 seconds with 21 queries.