I am having a problem in loading texture(an IMAGE).....?...need help

protected void simpleInitGame()

{

Box b1;

Vector3f v1=new Vector3f(-5,2,0);

Vector3f v2=new Vector3f(3,8,2);

b1=new Box("box",v1,v2);

Texture texture = TextureManager.loadTexture(

                PingPong.class.getClassLoader().getResource(

                "D:/JME/Programs/Images/Winter.jpg"),

                Texture.MM_LINEAR_LINEAR,

                Texture.FM_LINEAR);

  TextureState ts = display.getRenderer().createTextureState();

  ts.setEnabled(true);

  ts.setTexture(texture);



  b1.setRenderState(ts);



rootNode.attachChild(b1);

}



this is the code i have written to display an image called Winter.jpg over the box…but it isn't diplaying…

over box…an default image is getting displayed and missing texture is written over it…



so please help me…i am new to jme…just strated …



my image is in d:/JME/Images/Winter.jpg…

Try a b1.updateRenderstate() after b1.setRenderState(ts)



snare

If you are getting the resource from the classLoader im almost sure that you cant put a absolute URL.

Try to place the file into the JavaSource dir and then refer to that starting from that point.

Ex.:

src/com.mycompany.mygame.MyLoaderClass



Put the file in a folder src/textures/



And on the code put the following URL: "textures/Winter.jpg"



If you dont want to copy the file, use another way of retrieving the URL from the file besides getClassLoader.getResource.

well i tried  b1.updateRenderState() after b1.setRenderState(ts)…but it didn't work…still that default image is getting rendered…

I think when you use getClassLoader(), it sets the URL path to where your project root is, so if your project is in D:/JME, you'd just want to use



getClassLoader().getResource("Programs/Images/Winter.jpg");



instead of the whole path

If your image is in "d:/JME/Images/Winter.jpg" then you have typed wrong in your code as it says "D:/JME/Programs/Images/Winter.jpg". Remove the "Programs" and try.

i am reeally sory i stated the image path wrongly…

my class file is in …D:/JME/Programs/Myclass.class…

and my winter.jpg file is in D:/JME/Programs/Images/winter.jpg…



i tried all the measures that u all advices…but am still facing the same problem…

In command prompt a WARNING comes saying "error loading image…url is null…"…

and a default texture gets rendered saying " Missing Texture"…

my image was in d:/JME/Programs/Images folder…

and my class was in d:/JME/Programs…



so i gave a path "Images/winter.jpg" in my program…and its working…now images is getting rendered over the box…



thanks everyone for their advice…