Texture lost

Started by gamenewer, January 19, 2015, 11:08:57 AM

Previous topic - Next topic

gamenewer

Hello Egon , I created texture by myself  and use setExternalId to set texture id, when  app pause and reactive , the texture lost ,  how to resove this problem?  Thank you ! :)

EgonOlsen

If you are creating a texture out of the engine's scope, you have to make sure to upload it again after a context loss. So in this case, you have to reupload the texture in onResume and set the new ID.

gamenewer

Yes , I reupload the texture and it worked !  But is seems a little something  wrong , at the first  , the transparent  clamping texture shows ok, but when reload texture ,  there are a thick black line around the texture.  I don't know why...

EgonOlsen

Not sure what you mean...what is the "transparent clamping texture".

gamenewer

Sorry , A plane set with a transparent  texture , at it's top , show a thick  black line ,  I'm sure  set the clamping by  GL_CLAMP_TO_EDGE.

EgonOlsen

And that texture comes from inside of jPCT-AE or is it external?

gamenewer

Texture comes not inside of jPCT-AE , it created by myself.

gamenewer

Texture tx = new Texture(1,1);
int exid= externTexGen();
tx.setExternalId(exid, GL10.GL_TEXTURE_2D);
....

EgonOlsen

If it's external, jPCT-AE doesn't do anything with that texture except for binding it for rendering. Maybe you are not setting it up correctly. How are you setting the actual content of that texture?

gamenewer

#9
I am so sorry , it's my mistake set . Now it's ok.

Could you add a new construct for texture that use extern glID to save memory  ?  like   Texture(int glid , int gltarget)  it only use glid and target.




EgonOlsen

You can use this constructor


Texture(int width, int height, RGBColor col)


and set null as col. That way, the creation of the internal int[]-array will be omitted.

gamenewer

Thank you very much !  :)

gamenewer

sorry , I have another question , when i set
                gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
               gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);

the texture shows ok , but when I  set
                gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,GL10.GL_LINEAR_MIPMAP_LINEAR);
                gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER,GL10.GL_LINEAR);
                gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL11.GL_GENERATE_MIPMAP, GL10.GL_TRUE);

the texture become white  , How can  i do  mipmap ? thank you !

EgonOlsen

That's all for the external texture, i guess? May i ask what's the purpose of all this is? The option to redirect a texture to an external source was meant to be used for textures filled by the camera or the media player. But for those textures, mip maps make no sense and won't even work. For almost all other textures, there's no point in making them external. So...why?

gamenewer

To save JVM memory, I  upload the texture data to GPU and then release the bitmap, not keep data in JVM, by this way can add more textures. My app should run on most device like JVM is 32M.