Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3509 Members - Latest Member: lioneltenel

26. May 2012, 09:12:56 pm
Xith3D CommunityGeneral CategorySupport (Moderator: Marvin Fröhlich)An additional wierd errors
Pages: [1]
Print
Author Topic: An additional wierd errors  (Read 1634 times)
hawkwind
Getting respectable
***
Offline Offline

Posts: 363



View Profile Email
« on: 27. March 2007, 07:57:27 pm »

I have been removing my image handling tools and replacing them with resorcelocater thingies.  A truly strange error is occurring, typically with GIF files.  If I reference an image out of my own image locations it appears in the scene as a grey shaded image, if I place the image under a copy of demo/HUD and reference it there, I get a full color image...any ideas??  In both cases an image is found using the same sequence of calls.  The only difference seems to be the directory it is found in.  Does this make any kinda of sense at all?? Huh
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Online Online

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #1 on: 27. March 2007, 08:15:26 pm »

I have been removing my image handling tools and replacing them with resorcelocater thingies.  A truly strange error is occurring, typically with GIF files.  If I reference an image out of my own image locations it appears in the scene as a grey shaded image, if I place the image under a copy of demo/HUD and reference it there, I get a full color image...any ideas??  In both cases an image is found using the same sequence of calls.  The only difference seems to be the directory it is found in.  Does this make any kinda of sense at all?? Huh

Any getTexture() method of the TextureLoader will always return a valid Texture reference. If the desired Texture could not be found, then a fallback Texture is returned. You can test that, if you call
Code:
Texture tex = TextureLoader.getInstance().getTexture( ... );
System.out.println( "is fallback tex: " + ( tex == TextureLoader.getFallbackTexture() ) );

I've just added a convenience method for this, which you can use, after you changed out:
Code:
System.out.println( "is fallback tex: " + TextureLoader.isFallbackTexture( tex ) );

But now for the solution for yuor problem:
The desired Texture was not found, because you forgot to add an appropriate TextureStreamLocator. The TextureLoader needs to know, where to load Textures from. So you have to add instances of TextureStreamLocator for any location, where to load textures from. The ResourceLocator provides an easy way to do that. Just call
Code:
ResourceLocator resLoc = ResourceLocator.create( "myresfolder" );
resLoc.cerateAndAddTSL( "tex2" ); // where tex2 is a subfolder (or subresource) of "myresfolder"

If you reference your resources by a relative name to the ResuorceLocator's baseURL, then you can simply say
Code:
ResourceLocator resLoc = ResourceLocator.create( "myresfolder" );
resLoc.cerateAndAddTSL(); // The TSL is created for the baseURL

I think, I should add methods to the TextureLoader, that take an URL. Then you could use the TextureLoader without TextureStreamLocators and you could use it similar to the model or shader loaders. I think, this makes sense.

Marvin
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Online Online

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #2 on: 27. March 2007, 08:35:54 pm »

I think, I should add methods to the TextureLoader, that take an URL. Then you could use the TextureLoader without TextureStreamLocators and you could use it similar to the model or shader loaders. I think, this makes sense.

This is done now. Textures can now be loaded directly without any TextureStreamLocator though
Code:
Texture tex = TextureLoader.getInstance().getTexture( resLoc.getResource( "bla.png" ), ... );

I would even consider this as teh preferred way, since it fits better into the whole system of the API.

Marvin
Logged
hawkwind
Getting respectable
***
Offline Offline

Posts: 363



View Profile Email
« Reply #3 on: 27. March 2007, 10:20:07 pm »

I will give this a try the next time I update svn.   I may have misstated though here

Quote
  If I reference an image out of my own image locations it appears in the scene as a grey shaded image,

I was trying to say that my image does show, only as grey shade...not a default image
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Online Online

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #4 on: 27. March 2007, 10:23:37 pm »

I will give this a try the next time I update svn.   I may have misstated though here

Quote
  If I reference an image out of my own image locations it appears in the scene as a grey shaded image,

I was trying to say that my image does show, only as grey shade...not a default image

Is it possible to post this image here?

Marvin
Logged
hawkwind
Getting respectable
***
Offline Offline

Posts: 363



View Profile Email
« Reply #5 on: 27. March 2007, 11:00:53 pm »

later
Logged
hawkwind
Getting respectable
***
Offline Offline

Posts: 363



View Profile Email
« Reply #6 on: 28. March 2007, 12:26:13 am »

compared the color image is the source and the grayish black is what is rendered in a HUD button

http://home.mindspring.com/~hawkwind/img.png

image

http://home.mindspring.com/~hawkwind/key4.png
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Online Online

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #7 on: 28. March 2007, 09:46:25 am »

If I click the images in my browser, both are colored. Is this what you get, too? I will load them in Xith this evening.

Marvin
Logged
'n ddrylliog
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #8 on: 28. March 2007, 02:20:13 pm »

If I click the images in my browser, both are colored. Is this what you get, too? I will load them in Xith this evening.
In the first image, there are two keys. The upper key is in black/white.
Logged
'n ddrylliog
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #9 on: 28. March 2007, 04:24:01 pm »

BTW, I remember having seen a similar bug, that would be great if it was fixed..
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Online Online

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #10 on: 29. March 2007, 12:13:10 am »

I tested the key4.png texture in the HUD3DTest. I replaced line #620 with the following line:
Code:
- Button pipOpener = new Button( 170f, 56f, "Panel-in-Panel" );
+ Button pipOpener = new Button( 170f, 56f, "key4.png", "key4.png", "key4.png", true );

And if worked (screenshot attached). Do you apply the texture a different way?

Marvin
Logged
'n ddrylliog
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #11 on: 29. March 2007, 03:32:45 pm »

You're not using ResourceLocator/Loader, as hawkwind said he has switched to Smiley
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Online Online

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #12 on: 29. March 2007, 04:12:21 pm »

You're not using ResourceLocator/Loader, as hawkwind said he has switched to Smiley

Err. You're right. ,So here is a working version with ResourceLocator (same resulting screenshot). Does this match your situation?
Code:
ResourceLocator resLoc = ResourceLocator.create( "demo/HUD/" );

try
{
    Texture texKey4 = TextureLoader.getInstance().getTexture( resLoc.getResource( "key4.png" ), Texture.RGBA, false );
   
    // add a Button to the HUD to open a Frame with some Panel-in-Panel
    Button pipOpener = new Button( 170f, 56f, texKey4, texKey4, texKey4 );
    pipOpener.setUserObject( "TEST_PIP" );
    pipOpener.addButtonListener( this );
    this.addWidget( pipOpener, 20f, 284f );
}
catch (MalformedURLException e)
{
    e.printStackTrace();
}

Marvin
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic