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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - awr

Pages: [1]
1
Window / Significant memory leak in SFML when creating multiple windows
« on: November 14, 2013, 03:05:38 pm »
I'm using SFML in a scenario where I need to spawn multiple windows (never simultaneously). SFML is being used inside a video player control inside a wider application and whenever a user goes to play a video, a new SFML window is created.

However, this seems to create a memory leak and I suspect it might be related to opengl contexts being created. I've attached both a C# and C++ version to demonstrate the issue.

private RenderWindow SFMLWindow = null;
private void RenderLoop()
        {
            //SFMLWindow = new RenderWindow(new VideoMode(400, 300), "SFML doesn't work(s)");    
 
            while(true)
            {
                SFMLWindow = new RenderWindow(new VideoMode(800, 600), "hello");
                SFML.Graphics.Texture texture = new Texture(1920, 1080);
                SFML.Graphics.Sprite sprite = new Sprite(texture);
                SFMLWindow.Draw(sprite);
                SFMLWindow.Display();
                SFMLWindow.Clear();

                System.Threading.Thread.Sleep(1000);

                SFMLWindow.Close();
                SFMLWindow.Dispose();

                System.Threading.Thread.Sleep(1000);

                texture.Dispose();
                sprite.Dispose();
            }
     }
 


int _tmain(int argc, _TCHAR* argv[])
{
        sf::RenderWindow window;

        while (true)
        {
                window.create(sf::VideoMode(800, 600), "leak");
                sf::Texture texture;           
                texture.create(1920, 1080);
                sf::Sprite sprite(texture);
                window.draw(sprite);
                window.display();
               
                Sleep(1000);

                window.clear();
                window.close();

                Sleep(1000);
        }
}
 

2
Hi,

I was running a test on two of my machines with the following specs:

Machine 1 (laptop - set to Maximum Performance):
Intel I5-2520M @ 2.50GHz
4GB ram
Intel HD graphics 3000 @ 650MHz
Windows 7
750

Machine 2 (desktop):
Intel i5-760 @ 2.7GHz
Nvidia GTX 260
4GB ram
12000

Machine 3 (desktop):
Intel I5-3350P @ 3.1GHz
6GB ram
NVIDIA GeForce GT 730M
Windows 8
48000

The test was:
Load an image (1200x600) from disk into an sf::Image.
then, in a while loop:
 On every iteration, create an sf::texture from the image
Repeat as fast as possible.

I ran each test for 20 seconds and the results were:
Machine 1: 750 iterations
Machine 2: 12000 iterations
Machine 3: 48000 iterations

Note that I'm not actually drawing anything to the screen. Drawing to the screen didn't have an impact on machine 1's performance, while it reduced machine 2 to 8000 and machine 3's down to about 15000.

Each image is 2.74MB. So essentially, machine 1 was only able to transfer 100MB per second from the CPU to the GPU (or an average of 37.5 textures per second - or 27 ms per texture), whereas machine 3 was transferring 6.5GB per second (2400 textures per second - < 1ms per texture ).

That seems ridiculously slow for the Intel HD Graphics. I was expecting some slow down on the laptop but not so dramatic a difference. Is there anything that could be contributing to this? It just seems ridiculously slow for a circa 2011 machine - I get better performance using .NET and picture boxes to do the rendering.

3
DotNet / Can't resize the view
« on: October 10, 2013, 02:34:29 am »
Hi all,

I'm having trouble getting the view to work correctly in SFML.Net. It seems that it should be relatively straight forward but no matter what I try, I can't get it work properly.

What I want is:http://www.sfml-dev.org/forums/Themes/ds-natural_20/images/bbc/pre.gif
Embed the render window in a .NET picturebox (this works fine)
Display an image that takes up the entirety of the picture box (this also works fine initially) and is centred in the image box
Upon resizing the picturebox (or form), have the image resize with it. I managed to get this to work when shrinking the picture box, but it doesn't work correctly when making it larger (the view area doesn't change).

My code is (this doesn't work but I don't see what's wrong with it):
// initialise SFML:
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            if (SFMLWindow != null)
                return;
            pictureBox2.Show();
            SFMLWindow = new RenderWindow(pictureBox2.Handle);

            view = new SFML.Graphics.View(new FloatRect(0, 0, this.ClientSize.Width, this.ClientSize.Height));
            SFMLWindow.SetView(view);
            RenderLoop();
        }

private void RenderLoop()
        {            
            SFML.Graphics.Image image3 = new SFML.Graphics.Image("testimage.bmp");                          
            int i = 0;
           
            while (FormOpen)
            {
             
                view = new SFML.Graphics.View(new Vector2f(pictureBox2.ClientSize.Width / 2, pictureBox2.ClientSize.Height / 2), new Vector2f(pictureBox2.ClientSize.Width, pictureBox2.ClientSize.Height));
               
               
                SFMLWindow.SetView(view);
// i intentionally create a new sprite each time round as the application is for a video player, which would need a new sprite to be made for each frame
                Sprite testsprite = new Sprite(new Texture(image3));
                testsprite.Texture.Smooth = true;

                testsprite.Scale = new Vector2f((float) this.ClientSize.Width / testsprite.Texture.Size.X, (float) this.ClientSize.Height / testsprite.Texture.Size.Y);

                Console.WriteLine(SFMLWindow.Size);

                Application.DoEvents(); // Required for the form controls to respond
                SFMLWindow.Clear(SFML.Graphics.Color.White);
                SFMLWindow.Draw(testsprite);
 
                //Do your drawing code here
                SFMLWindow.Display();              
                testsprite.Texture.Dispose();
                testsprite.Dispose();
                System.Threading.Thread.Sleep(80);
            }
        }

It doesn't work. Note that even changing the size of the window manually, using
size = new Vector2u((uint)pictureBox2.ClientSize.Width, (uint)pictureBox2.ClientSize.Height);
                SFMLWindow.Size = size;

doesn't work. When I log the size, its always the form's initial size.

Not sure what the issue is. I've used opengl before with Android and had very few issues with getting the view to do what I want. This seems like it should be quite straight forward...

Pages: [1]