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  
  TextureIO.newTexture with remote (http) files  (Read 760 times)
0 Members and 1 Guest are viewing this topic.
Offline loicus

JGO n00b
*

Posts: 10



« on: 2011-11-13 02:57:48 »

Hi all,

I am trying to create a new tecture from a remove file on the net with the following code snippet,

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
              try {
                 System.out.println("Getting the URL\n");
                 URL url = new URL("http://people.na.infn.it/~carrillo/rpc/frog/crop/637566997.png");        
                 System.out.println("Getting the Texture\n");                
                  texture = TextureIO.newTexture(url, false, "png");
              }
              catch (IOException exc) {
                  exc.printStackTrace();
                  System.exit(1);
              }        


but its basically stuck for ever at the newTexture line...

Same code with local file works like a charm...
And the URL is fine and I am getting the image instataniously in my web browser, so...
What did I miss?


Thanks,
Loic

Offline gouessej

JGO Kernel
*****

Posts: 3560
Medals: 30


TUER


« Reply #1 on: 2011-11-13 05:41:07 »

Hi

Which version of JOGL do you use? It is strange as I used com.jogamp.opengl.util.texture.TextureIO several times in such a case and it was working.

Julien Gouesse
Offline loicus

JGO n00b
*

Posts: 10



« Reply #2 on: 2011-11-13 05:43:48 »

I am using jogl-2.0
But it is good to hear that it is suppose to work ;-)

Games published by our own members! Go get 'em!
Offline gouessej

JGO Kernel
*****

Posts: 3560
Medals: 30


TUER


« Reply #3 on: 2011-11-13 05:46:53 »

Please can you try to load the image without JOGL just to check if the problem really comes from it? Use Class.getResourceAsStream(), check its return value isn't null.

Julien Gouesse
Offline loicus

JGO n00b
*

Posts: 10



« Reply #4 on: 2011-11-13 05:56:22 »

when I do:
InputStream stream = jfrog.Common.class.getResourceAsStream("http://people.na.infn.it/~carrillo/rpc/frog/crop/637566997.png");
I get a stram that is equal to null... but I can't understand why, since the url is ok in my browser...
Can it be because of the tilde ("~") ?

I also tried this:
InputStream stream = new URL("http://people.na.infn.it/~carrillo/rpc/frog/crop/637566997.png").openStream();
but it get stuck for ever again...

any advice?
Loic
Offline loicus

JGO n00b
*

Posts: 10



« Reply #5 on: 2011-11-13 09:25:38 »

Nevermind....
I made it working:

              try {
                 URL url = new URL("http://people.na.infn.it/~carrillo/rpc/frog/crop/637566997.png");
                 if(url!=null)texture = TextureIO.newTexture(url, false, "png");                 
              }
              catch (IOException exc) {
                 System.out.printf("Texture not found");
              }
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.142 seconds with 21 queries.