Author Topic: Loading generic texture in an Applet  (Read 2780 times)

Offline Tornado7

  • byte
  • *
  • Posts: 45
    • View Profile
Loading generic texture in an Applet
« on: June 08, 2004, 11:32:42 am »
Hi Egon,

as you know Iím loading texture in this way:

Code: [Select]
texMan.addTexture("car1.jpg",new Texture(getDocumentBase(),"textures/car1.jpg"));

in my applet context. Considering that Iím using now a certificate, so I can access to the local filesystem, Iíd like to load texture in a generic way using a for cycle (as you do in fps) :

Code: [Select]

File dir=new File("textures");
       String[] files=dir.list();
        for (int i=0; i<files.length; i++) {
         String name=files[i];
         if (name.endsWith(".jpg")) {
            texMan.addTexture(name, new Texture("textures"+File.separator+name));
         }
       }


but, when I run the applet the Java console says:

Code: [Select]

java.lang.NullPointerException
at ThreeDSimApplet.init(ThreeDSimApplet.java:238)
at sun.applet.AppletPanel.run(AppletPanel.java:348)
at java.lang.Thread.run(Thread.java:536)


thereís another way to load texture in a generic way in my context? Bye and thanks

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Loading generic texture in an Applet
« Reply #1 on: June 08, 2004, 04:44:11 pm »
The exception happens somewhere in your code. What exactly is in line 238?

Offline Tornado7

  • byte
  • *
  • Posts: 45
    • View Profile
Loading generic texture in an Applet
« Reply #2 on: June 08, 2004, 05:17:15 pm »
Line 238 is:

Code: [Select]
for (int i=0; i<files.length; i++) {

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Loading generic texture in an Applet
« Reply #3 on: June 08, 2004, 10:10:46 pm »
That means that files is null, which means that dir.list() returns null, which means that your "textures"-directory doesn't exist. At least not there where you expect it to be. Try the complete path (i.e. "c:\blah\blubb\...\textures" or similar) and see if that works.

Offline Tornado7

  • byte
  • *
  • Posts: 45
    • View Profile
Loading generic texture in an Applet
« Reply #4 on: June 09, 2004, 02:42:26 pm »
Ok, it works using slash. Bye and thanks  :D