Author Topic: Problem Loading Texture  (Read 1559 times)

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Problem Loading Texture
« on: August 19, 2011, 09:14:38 pm »
Texture texture = new Texture(BitmapHelper.rescale(BitmapHelper.convert(R.drawable.andersondiffuse), 128, 128)) doesn't seem to work. I have an image named andersondiffuse.png in each of my three res\drawable directories. The Android docs say I'm doing it right (http://developer.android.com/guide/topics/resources/drawable-resource.html#Bitmap). What gives?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: Problem Loading Texture
« Reply #1 on: August 19, 2011, 09:43:37 pm »
And the exact problem is... ???

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: Problem Loading Texture
« Reply #2 on: August 19, 2011, 10:08:43 pm »
It didn't compile. But I fixed an issue whereby the R.java wasn't being re-generated and it worked, thanks. Now I'm having trouble loading the model (what path do I pass to FileInputStream for a OBJ file at res/drawable-hdpi?). Thanks in advance.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: Problem Loading Texture
« Reply #3 on: August 19, 2011, 10:21:57 pm »
Don't put your resources into drawable. Put it into raw (you might have to create that) or assets instead. You are just doing unnecessary  scaling and conversions this way.

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: Problem Loading Texture
« Reply #4 on: August 19, 2011, 10:23:21 pm »
OK, good advice, but then how do I reference that programmatically? How would I load anderson.obj from res/raw/anderson.obj?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: Problem Loading Texture
« Reply #5 on: August 19, 2011, 10:29:50 pm »
Just like

Code: [Select]
res.openRawResource(R.raw.anderson)

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: Problem Loading Texture
« Reply #6 on: August 19, 2011, 10:52:14 pm »
Thanks a lot.

Offline stownshend

  • byte
  • *
  • Posts: 25
    • View Profile
Re: Problem Loading Texture
« Reply #7 on: August 20, 2011, 02:33:45 am »
And if you use the asset folder it's just:

Code: [Select]
// Create a stream to grab the data from the 3DS model file.
AssetManager.AssetInputStream inStream = (AssetInputStream) assetManager.open(fileName);

// Insert all of the models from the file into an array of Object3D's.
tempObjects = Loader.load3DS(inStream, 1.0f);