setWrap() causes nullpointerexception?

I have a class for bump textures and I created a method to set all the texture’s their WrapMode at once but whenever I try to set the wrapmode of a texture I get a NullPointerException on the line where :setWrap() is called. What am I doing wrong?


[java]Caused by: java.lang.NullPointerException

at CantThinkOfName.BumpTexture.setWrapMode(

at CantThinkOfName.BumpTexture.<init>(

at Testing.PreMadeBumpTextures.<init>(

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(

at java.lang.reflect.Constructor.newInstance([/java]

BumpTexture Class:

[java]public class BumpTexture{

private Texture DiffuseMap;

private Texture NormalMap;

private Texture GlowMap;

private Texture SpecularMap;

public _Texture(){



public Texture getDiffuseMap(){return DiffuseMap;}

public void setDiffuseMap(Texture map){DiffuseMap = map;}

public Texture getNormalMap(){return NormalMap;}

public void setNormalMap(Texture map){NormalMap = map;}

public Texture getGlowMap(){return GlowMap;}

public void setGlowMap(Texture map){GlowMap = map;}

public Texture getSpecularMap(){return SpecularMap;}

public void setSpecularMap(Texture map){SpecularMap = map;}

private void setWrapMode(WrapMode mode){

this.DiffuseMap.setWrap(mode); // this line causes the nullpointer






That probably means DiffuseMap is null, How do you initialize it?

1 Like

Ugh, the switch from scripting to programming isn’t as easy as I’d hoped, I just keep making mistakes like this.

Well thank you very much :smiley:

Btw is there any documentary on texture wrapping? Im trying to tile my textures but I can’t find anything on the wiki regarding the subject.

mhh don’t know if there is for this particular matter, but usually, if you want to repeat your texture, let’s say 10 times, you have to set the wrap mode to wrap (like you did), and scale the texture coordinates by 0,1.

For this use mesh.scaleTextureCoordinates(new Vector2f(uScale,vScale));

1 Like