Author Topic: multi texture objects & Texture.keepPixelData(..)  (Read 5418 times)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #15 on: August 11, 2010, 09:36:02 pm »
That's fine. It's printed out once for each compiled sub part.

BTW: Can you give a brief overview of what exactly you are doing when the surface gets recreated? It seems to work better than my approaches in the past (which was why i ditched the idea).

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #16 on: August 11, 2010, 09:54:31 pm »
sure :)

  • basicly i create a new FrameBuffer. if one already exists, i first dispose it. if i recall correctly this part is taken your demo
  • all my textures has keepPixelData set to true, so they can be automatically recovered by jPCT
  • there is a chance that Android creates a new instance of the Activity. i override onRetainNonConfigurationInstance() and return the Activity instance. onCreate(), i re-get it with getLastNonConfigurationInstance(). if not null i copy all game and gui elements from that, o/w load textures and similar stuff

and, not sure it's still so but in your demo you were using a pause mechanism for renderer. i found that unnecessary. simply calling GLView.onPause() and GLView.onResume() do the trick

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #17 on: August 11, 2010, 10:12:20 pm »
there is a chance that Android creates a new instance of the Activity.
Thanks. That happened to me all the time and i wasn't aware of that onRetainNonConfigurationInstanceLongestMethodNameInTheWorld()-thingy... ;D

Edit: So most things like Textures, Object3Ds etc. are attributes of the Activity and not of the implementation of GLSurfaceView.Renderer, i assume? Or does it survive the pause and just creates a new gl context?
« Last Edit: August 11, 2010, 10:16:17 pm by EgonOlsen »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #18 on: August 11, 2010, 10:31:43 pm »
Another, not really related question: Does mip mapping actually work on your N1? I'm still not sure if my phone just can't do it or if it's an implementation error on my side that everything becomes white that tries to use it...!?

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #19 on: August 11, 2010, 10:38:21 pm »
That happened to me all the time..
I've discovered a strange behaviour. maybe helps. when my activity is on front and phone goes to sleep, activity is paused, stopped, destroyed, a new one is created and it's paused. docs says, if a configuration change happens and activity does not support the change, a new instance is created. this may be the reason. when phone wakes up a third instance is created

Quote
onRetainNonConfigurationInstanceLongestMethodNameInTheWorld()-thingy... ;D
hahaha ;D

docs say call of this method is not guaranteed so maybe storing last instance in a static field may be the best.

Quote
So most things like Textures, Object3Ds etc. are attributes of the Activity and not of the implementation of GLSurfaceView.Renderer, i assume? Or does it survive the pause and just creates a new gl context?
yes, they are attributes of activity not renderer. i always create a new renderer onCreate() but i believe the last one may be reused. this may be even better since the last one still holds a FrameBuffer

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #20 on: August 11, 2010, 10:39:22 pm »
Another, not really related question: Does mip mapping actually work on your N1? I'm still not sure if my phone just can't do it or if it's an implementation error on my side that everything becomes white that tries to use it...!?

how can i test it ? there in no such option in Config for AE version.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #21 on: August 11, 2010, 10:42:58 pm »
You can enable it on each texture by calling setMipmap(true). My phone (as well as the G1) seem to support a kind of ES 1.0/1.1 hybrid where the actually gl instance is 1.1 but doesn't support everything. The N1, however, actually should.

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #22 on: August 11, 2010, 10:52:42 pm »
may it be deactivated in code somehow? i didn't see a difference. and nothing logged as creating mipMap textures.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #23 on: August 11, 2010, 11:01:48 pm »
It won't be logged and it's not deactived. So if you see some textures, they should actually be using mip mapping. It may not be noticable depending on the texture though. At least it's not all white like on my phone...

Offline raft

  • quad
  • ******
  • Posts: 1966
    • View Profile
    • http://www.aptalkarga.com
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #24 on: August 11, 2010, 11:06:28 pm »
It may not be noticable depending on the texture though.
right, most textures are plain color at the moment.

cool, then it works on N1 ;D

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: multi texture objects & Texture.keepPixelData(..)
« Reply #25 on: August 11, 2010, 11:28:36 pm »
Got it working on my phone to a degree too by creating the mip maps in code. But it only seems to work on 32bit textures (everything goes crazy if i try to use it on 16bpp ones...) and even then, the mip map implementation looks actually worse than what we did with the software renderer once... :P