Texture switching

Started by lawless_c, June 03, 2016, 06:24:54 PM

Previous topic - Next topic

lawless_c

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.

EgonOlsen

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.

lawless_c

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  :-[

EgonOlsen

It's in the TextureManager... ???

lawless_c

 
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>

EgonOlsen


lawless_c

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

EgonOlsen

Quote from: lawless_c on June 20, 2016, 01:37:11 PM
swapping them was also a very slow operation
Yes, because it may trigger a new texture upload.