SFML community forums

Bindings - other languages => DotNet => Topic started by: zombiekiller222 on May 12, 2012, 09:11:28 am

Title: Why is trying to draw multiple global shaders so slow for me?
Post by: zombiekiller222 on May 12, 2012, 09:11:28 am
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?
Title: Re: Why is trying to draw multiple global shaders so slow for me?
Post by: Laurent 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.