www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: lawless_c on June 03, 2016, 06:24:54 pm

Title: Texture switching
Post by: lawless_c on June 03, 2016, 06:24:54 pm
Is it possible to swap texture name assignments and texture info's while running a game?



eg assign like this

TextureManager m;
Texture tex1;
Texture tex2;


m.addTexture( "textureA ", tex1) ;
m.addTexture( "textureB", tex2) ;


//Then swap them ?


m.addTexture( "textureA", tex2) ;
m.addTexture( "textureB", tex1) ;


Maybe with a 3rd texture as temporary holder.
Title: Re: Texture switching
Post by: EgonOlsen on June 04, 2016, 12:37:19 am
That wouldn't swap textures on the objects...there's a replaceTexture()-method that can be used for that. But the actual question is: Why would you want to swap textures? It might be a better idea to do that on the objects and not in the manager.
Title: Re: Texture switching
Post by: lawless_c on June 05, 2016, 12:22:29 am
Just experimenting with some way of post processing, i wanted to rapidly switch between two.

Basically im creating a world with the textured object in it , using the object shader to perform a process on the shader that writes a result back to the same texture via the framebuffer.


I can't find the replaceTexture method  :-[
Title: Re: Texture switching
Post by: EgonOlsen on June 05, 2016, 07:56:10 pm
It's in the TextureManager... ???
Title: Re: Texture switching
Post by: lawless_c on June 17, 2016, 02:23:21 am
 
Would something like this work? to swap between two textures every time the function is called?

<code>
  private void swapTexture()
    {

        Temp = texture;
        texture=texture2;
        texture2=Temp;
        tm.replaceTexture("my_little_texture", texture2);
    }

</code>
Title: Re: Texture switching
Post by: EgonOlsen on June 17, 2016, 09:11:32 am
It should.
Title: Re: Texture switching
Post by: lawless_c on June 20, 2016, 01:37:11 pm
I'm an idiot  ;D .

I was using the texture swapping as i wanted to avoid writing to a texture while simultaneously reading from it... completely unnecessary as the frame-buffer does the drawing first then outputs the result to the texture..

swapping them was also a very slow operation
Title: Re: Texture switching
Post by: EgonOlsen on June 20, 2016, 01:43:42 pm
swapping them was also a very slow operation
Yes, because it may trigger a new texture upload.