SFML community forums

Bindings - other languages => DotNet => Topic started by: Spodi on November 13, 2010, 07:38:45 pm

Title: Using CurrentView
Post by: Spodi on November 13, 2010, 07:38:45 pm
Unless I am missing something here, the following should update the view before each draw:

Code: [Select]
using System;
using SFML.Graphics;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var rw = new RenderWindow(new SFML.Window.VideoMode(800, 600), "Test"))
            {
                Shape sh = Shape.Rectangle(new FloatRect(8,8,32,32), Color.Green);

                while (rw.IsOpened())
                {
                    rw.DispatchEvents();
                    rw.CurrentView.Reset(new FloatRect(0, 0, rw.Width, rw.Height));
                    // rw.CurrentView = rw.CurrentView;
                    rw.Draw(sh);
                    rw.Display();
                }
            }
        }
    }
}


But the changes made to CurrentView don't actually take affect until you do a hack like I have above in the commented-out line. If you leave that line commented out, CurrentView.Reset() appears to have no affect. Adding the commented out line, the view is resized as expected.
Title: Using CurrentView
Post by: Laurent on November 13, 2010, 08:27:45 pm
That's right, the semantics of the views have changed in SFML 2. I need to modify the .Net classes accordingly.
Title: Using CurrentView
Post by: Laurent on November 14, 2010, 04:23:44 pm
It's fixed. CurrentView has been replaced with GetView() and SetView(), so it's now obvious that you need to call SetView to apply the modifications.