Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Why is trying to draw multiple global shaders so slow for me?  (Read 1941 times)

0 Members and 1 Guest are viewing this topic.

zombiekiller222

  • Guest
This is my code.
                RenderTexture front = new RenderTexture(Width, Height);
                        RenderTexture back = new RenderTexture(Width, Height);
                        Texture texture = new Texture(Width, Height);
                        texture.Update (window);
                        back.Draw (new Sprite(texture));
                        foreach (Effect effect in ShaderManager.ScreenShaders)
                        {
                                front.Clear ();
                                front.Draw (new Sprite(back.Texture), effect.Shader);
                                front.Display ();
                               
                                RenderTexture temp = front;
                        front = back;
                        back = temp;
                        }
                        back.Display ();
                        window.Draw (new Sprite(back.Texture));

Without it my fps is 120+ and with it it's 5. Why does this happen?

Also, would testing if a sprite's bounding box collides with the screen a quick way to test whether or not to draw it?
« Last Edit: May 12, 2012, 09:58:56 am by Laurent »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Why is trying to draw multiple global shaders so slow for me?
« Reply #1 on: May 12, 2012, 09:59:44 am »
Quote
Without it my fps is 120+ and with it it's 5. Why does this happen?
Probably because you create new RenderTexture and Texture objects every time ;)

Quote
Also, would testing if a sprite's bounding box collides with the screen a quick way to test whether or not to draw it?
Yes.
Laurent Gomila - SFML developer

 

anything