www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: mownage on March 10, 2014, 08:49:59 pm

Title: Out of memory when adding textures
Post by: mownage on March 10, 2014, 08:49:59 pm
I am new to Jpct-ae and have looked at some projects created by people and they look amazing. Now I want to create something that is amazing too... :)

I can add objects but when I try add the textures, my program runs of of memory...  :'(

Just a snippet of my code:


Code: [Select]

               
world = new World();
world.setAmbientLight(20, 20, 20);

sun = new Light(world);
sun.setIntensity(250, 250, 250);

           TextureManager.getInstance().addTexture("DLC12_Nightwing_AS_Body_D.png", new
        Texture(context.getApplicationContext().getResources().openRawResource(R.raw.nightwing)));
       
        TextureManager.getInstance().addTexture("Equipment_Resonator_01_D.png", new
        Texture(context.getApplicationContext().getResources().openRawResource(R.raw.equip)));   
        TextureManager.getInstance().addTexture("NightWing_Weapons_Darts_D.png", new
        Texture(context.getApplicationContext().getResources().openRawResource(R.raw.weapon)));         
        TextureManager.getInstance().addTexture("DLC12_Nightwing_AS_Head_D.png", new
        Texture(context.getApplicationContext().getResources().openRawResource(R.raw.head)));     
       
                stream = context.getApplicationContext().getResources().openRawResource(R.raw.nw);
                stream2 = context.getApplicationContext().getResources().openRawResource(R.raw.nw2);
       
                thing = Loader.loadOBJ(stream, stream2, 1f);

                thing[0].build();
                cam = world.getCamera();
          world.addObject(thing[0]);         
       

nw is an .obj file that is 2.63mb,
nw2 is a .mtl file that is 615 bytes,
nightwing.jpg is 717kb,
equip.jpg is 189kb,
weapon.jpg is 245kb,
head.jpg is 225kb.


When I don't include the texture files, I can see the model but there are no textures. When I try add the textures (I have looked at the wiki page and it said that it automatically loads them based on the name of the file) I get out of memory yet I don't see these files being that big? I see some crazy stuff that people have created and their graphics are a lot bigger than mine ;o....

Could anyone see the problem that I am experiencing?
Title: Re: Out of memory when adding textures
Post by: Irony on March 10, 2014, 09:10:37 pm
You can't tell what memory a texture will take by looking at the file, which is compressed. Instead, the texture will take height*width*4 (if you have alpha) bytes.
So, make sure to use smaller textures.
Title: Re: Out of memory when adding textures
Post by: mownage on March 10, 2014, 09:16:00 pm
You can't tell what memory a texture will take by looking at the file, which is compressed. Instead, the texture will take height*width*4 (if you have alpha) bytes.
So, make sure to use smaller textures.

I see.. ummm nightwing.jpg is 2048*2048...
equip.jpg is 1024*1024...
weapon is 1024*1024...
head is 2048*1024...

... haha.. I guess that explains why

Thank you very much^^
Title: Re: Out of memory when adding textures
Post by: mownage on March 10, 2014, 09:51:19 pm
Yep, got it working now with textures.

It was 100% due to the size of my images :(. Thank you for the quick help! Really appreciate it