multi texture objects & Texture.keepPixelData(..)

Started by raft, August 10, 2010, 02:32:54 PM

Previous topic - Next topic

EgonOlsen

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).

raft

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

EgonOlsen

#17
Quote from: raft on August 11, 2010, 09:54:31 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?

EgonOlsen

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...!?

raft

Quote from: EgonOlsen on August 11, 2010, 10:12:20 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

QuoteonRetainNonConfigurationInstanceLongestMethodNameInTheWorld()-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.

QuoteSo 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

raft

Quote from: EgonOlsen 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...!?

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

EgonOlsen

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.

raft

may it be deactivated in code somehow? i didn't see a difference. and nothing logged as creating mipMap textures.

EgonOlsen

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...

raft

Quote from: EgonOlsen on August 11, 2010, 11:01:48 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

EgonOlsen

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