Author Topic: Texture lost  (Read 2125 times)

Offline gamenewer

  • long
  • ***
  • Posts: 171
    • View Profile
Texture lost
« on: January 19, 2015, 11:08:57 am »
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 ! :)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Texture lost
« Reply #1 on: January 19, 2015, 12:44:03 pm »
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.

Offline gamenewer

  • long
  • ***
  • Posts: 171
    • View Profile
Re: Texture lost
« Reply #2 on: January 19, 2015, 12:53:58 pm »
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...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Texture lost
« Reply #3 on: January 19, 2015, 01:25:32 pm »
Not sure what you mean...what is the "transparent clamping texture".

Offline gamenewer

  • long
  • ***
  • Posts: 171
    • View Profile
Re: Texture lost
« Reply #4 on: January 19, 2015, 01:36:55 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Texture lost
« Reply #5 on: January 19, 2015, 01:45:44 pm »
And that texture comes from inside of jPCT-AE or is it external?

Offline gamenewer

  • long
  • ***
  • Posts: 171
    • View Profile
Re: Texture lost
« Reply #6 on: January 19, 2015, 01:51:22 pm »
Texture comes not inside of jPCT-AE , it created by myself.

Offline gamenewer

  • long
  • ***
  • Posts: 171
    • View Profile
Re: Texture lost
« Reply #7 on: January 19, 2015, 01:54:37 pm »
Texture tx = new Texture(1,1);
int exid= externTexGen();
tx.setExternalId(exid, GL10.GL_TEXTURE_2D);
....

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Texture lost
« Reply #8 on: January 19, 2015, 08:01:27 pm »
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?

Offline gamenewer

  • long
  • ***
  • Posts: 171
    • View Profile
Re: Texture lost
« Reply #9 on: January 20, 2015, 04:04:35 am »
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.



« Last Edit: January 20, 2015, 07:20:02 am by gamenewer »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Texture lost
« Reply #10 on: January 20, 2015, 07:39:23 am »
You can use this constructor

Code: [Select]
Texture(int width, int height, RGBColor col)

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

Offline gamenewer

  • long
  • ***
  • Posts: 171
    • View Profile
Re: Texture lost
« Reply #11 on: January 20, 2015, 12:01:10 pm »
Thank you very much !  :)

Offline gamenewer

  • long
  • ***
  • Posts: 171
    • View Profile
Re: Texture lost
« Reply #12 on: January 20, 2015, 05:03:07 pm »
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 !

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Texture lost
« Reply #13 on: January 20, 2015, 05:35:59 pm »
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?

Offline gamenewer

  • long
  • ***
  • Posts: 171
    • View Profile
Re: Texture lost
« Reply #14 on: January 21, 2015, 01:44:20 am »
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.