Loading texture ? - SFML 2.1 - VS2013

after a couple of years of inactivity, I am trying to learn how to use SFML.net with vs2013. (as XNA is discontinued, I had to learn something new).

I am struggling to do a very simple texture loading. Here is what I did :

  • Created a new windows console solution.
  • loaded SFML (via Nugget PM)
  • Created a resources folder (Project settings)
  • loaded a basic texture in this resource folder

The program loads the texture, creates a sprite with this texture, positions it and draws it. Should be a gentle start right ? Except that it gives me an error saying that the texture cannot be loaded.

(PS : SFML seems to be a very good library in C++ but the documentation is very poor in other languages to my point of view)

Here is the (very simple) code :

using SFML.Graphics;
using SFML.Window;
using SFML.Audio;
using System;

namespace SFMLApplication1
{
    public static class Program
    {
        private static readonly Color CornflowerBlue = new Color(100, 149, 237);
        public static void Main(string[] args)
        {
            RenderWindow window = new RenderWindow(new VideoMode(1280, 720), "SFML Window");
            window.Closed += (sender, eventArgs) => window.Close();

            while (window.IsOpen())
            {
                window.DispatchEvents();
                // TODO: Insert Update Code Here
                Texture playertxr = new Texture("sonic.png");
                Sprite playerspr = new Sprite(playertxr);
                playerspr.Position = new Vector2f(200, 400);
                window.Clear(CornflowerBlue);
                // TODO: Insert Draw Code Here
                window.Draw(playerspr);
                window.Display();
            }
        }
    }
}

Answers


Need Your Help

Array/Data Changes

php arrays function explode dynamic-arrays

I am developing a clan website: piratesofpopulous.comli.com/

Error trying to open DB in SQLite (iOS)

iphone ios objective-c sqlite sqlite3

Am making an iOS apps with an embedded SQLite database. So I make my DB in a SQLite administrator and drag it to my Xcode project, like in the tutorial says.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.