[SOLVED] Using materials

Hello,



When experimenting with my very simple app on Android it throws an exception:

[java]

Cannot render mesh without shader bound: java.lang.IllegalStateException[/java]



This only happens when I run on my Android device. It throws no exception in JMP.



This is the offending line, the use of materials:



[java]

box b1 = new box();

m_box1 = b1.Create( this.assetManager, new Vector3f( -4, -1, -1) );

Material mat_lit = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); // << i if I comment out the use of material, it works on Android too.

m_box1.setMaterial(mat_lit); // <<

rootNode.attachChild(m_box1);[/java]



Is ther something I have to do to make sure the material data is copied to the device?



Thanks



Simon

It looks like the shader fails to compile on android. I don’t know why thats should be tho… It seems to workon other phones. Aynway considering the low performance of most android devices, you should probably use Unshaded.j3md anyway.

Well, androiddemo.SimpleTexturedTest works just fine.



I’ll compare the source code.

After cross checking with the source code from SimpleTexturedTest, I deduced that you need to add this line to make lighting.j3md work:

mat_lit.setBoolean("VertexLighting", true);


Wow I solved a problem on my own! :)

PS: Why is the code formatting so bad on this website? I had to use blockquote just to make a " appear
Why is the code formatting so bad on this website? I had to use blockquote just to make a ” appear

Because @erlend_sh updated the site in a haste.