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

Author Topic: SFML.Net Core???  (Read 13210 times)

0 Members and 1 Guest are viewing this topic.

Balnian

  • Newbie
  • *
  • Posts: 22
    • View Profile
SFML.Net Core???
« on: December 16, 2016, 10:44:53 pm »
Is there a reason that the last release of the binding wasn't made to support Dotnet Core?
With dotnet Core support it would allow cross platform support of the binding.

I was able to convert the current code of the repo to a working Dotnet Core lib in about 20 minutes, i had to change 2 things ( CriticalFinalizerObject of Window/context.cs to a IDisposable and the [Serializable] of Window/LoadingFailedException.cs was removed) and some other small changes like to the basic project file to allow unsafe code...
I would have like to make it available by nuggets but i don't have much experience with doing that and i didn't test the cross platform aspect (but it should work... just swap the CSFML libs for windows for the platform specific ones in the project root)

^ first post hope i don't have to many spelling mistakes   ;D
« Last Edit: December 16, 2016, 10:49:47 pm by Balnian »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
SFML.Net Core???
« Reply #1 on: December 17, 2016, 02:33:19 am »
It's an open source project and we're always looking for people to help out. Feel free to make a pull request with your changes, so they can be discussed in detail.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Balnian

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: SFML.Net Core???
« Reply #2 on: December 23, 2016, 04:09:40 am »
Made my pull request last week   ;D

But i recently hit some problem while trying the binding on Linux (ubuntu 14.04) and it's related to the CSFML librairies... is the linux download ready to use (http://www.sfml-dev.org/download/csfml/ ) like the Windows one or is there something more to do?
If they are ready to use do i need to include all of them? (*.so,*.so.2.3,*.so.2.3.0)
I'm not that use to how linux runtime libraries work so if someone have a little more experience with them i would gladly take the help / knowledge.

8Observer8

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • My website
    • Email
Re: SFML.Net Core???
« Reply #3 on: June 16, 2020, 02:46:53 pm »
SFML.NET supports .NET Core now.

Install VSCode and .NET Core SDK. Follow the instruction: https://code.visualstudio.com/docs/languages/dotnet

Create and an empty folder and go to it:
cd RotatingHelloWorldSfmlDotNetCoreCSharp

Create a new console application by executing this command:
dotnet new console

Install SFML.NET:
dotnet add package SFML.Net --version 2.5.0

Open VSCode by typing the command in the console:
code .

Copy and pasta the code below and run the app using the command:
dotnet run

Program.cs
using System;
using SFML.Window;
using SFML.Graphics;
using SFML.System;

namespace RotatingHelloWorldSfmlDotNetCoreCSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Press ESC key to close window");
            MyWindow window = new MyWindow();
            window.Show();
            Console.WriteLine("All done");
        }
    }

    class MyWindow
    {
        public void Show()
        {
            VideoMode mode = new VideoMode(250, 250);
            RenderWindow window = new RenderWindow(mode, "SFML.NET");

            window.Closed += (obj, e) => { window.Close(); };
            window.KeyPressed +=
                (sender, e) =>
                {
                    Window window = (Window)sender;
                    if (e.Code == Keyboard.Key.Escape)
                    {
                        window.Close();
                    }
                };

            Font font = new Font("C:/Windows/Fonts/arial.ttf");
            Text text = new Text("Hello World!", font);
            text.CharacterSize = 40;
            float textWidth = text.GetLocalBounds().Width;
            float textHeight = text.GetLocalBounds().Height;
            float xOffset = text.GetLocalBounds().Left;
            float yOffset = text.GetLocalBounds().Top;
            text.Origin = new Vector2f(textWidth / 2f + xOffset, textHeight / 2f + yOffset);
            text.Position = new Vector2f(window.Size.X / 2f, window.Size.Y / 2f);

            Clock clock = new Clock();
            float delta = 0f;
            float angle = 0f;
            float angleSpeed = 90f;
           
            while (window.IsOpen)
            {
                delta = clock.Restart().AsSeconds();
                angle += angleSpeed * delta;
                window.DispatchEvents();
                window.Clear();
                text.Rotation = angle;
                window.Draw(text);
                window.Display();
            }
        }
    }
}
 
« Last Edit: June 16, 2020, 03:10:58 pm by 8Observer8 »

unlight

  • Newbie
  • *
  • Posts: 33
    • View Profile
    • Email
Re: SFML.Net Core???
« Reply #4 on: June 20, 2020, 04:30:45 am »
I recently invested a couple hours trying to get an SFML.NET project to build on Linux (I am not a .NET user) and failed. I didn't realise it was this easy. Is it worth adding these instructions to the SFML wiki page?

https://github.com/SFML/SFML/wiki/Tutorials

We could replace the "SFML.Net on OSX" page with "SFML.Net using .NET Core" as it applies to all OS.
« Last Edit: June 20, 2020, 04:33:19 am by unlight »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: SFML.Net Core???
« Reply #5 on: June 20, 2020, 09:37:16 am »
We could replace the "SFML.Net on OSX" page with "SFML.Net using .NET Core" as it applies to all OS.
Note that the nuget package doesn't contain macOS builds, so on macOS you still have to build SFML.NET yourself.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

kazyamof

  • Newbie
  • *
  • Posts: 15
    • View Profile
    • Email
Re: SFML.Net Core???
« Reply #6 on: July 04, 2020, 08:43:27 am »
I've followed the mac os install tutorial and also this video.
https://www.youtube.com/watch?v=WOyp5n2FmZY&lc=UgyynNlOxemLKMHyagt4AaABAg.9ATcJzyNere9AYRGIfGK3m

But can not make it works with .net core after install the nuget packages with Visual Studio, neither with C++ template on XCode.

Error on Visual Studio .NET Core Mac OS:
"Unable to load shared library 'csfml-graphics' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libcsfml-graphics, 1): image not found"

Error on C++ version (running the template app):
dyld: Library not loaded: @rpath/sfml-system.framework/Versions/2.5.1/sfml-system
  Referenced from: /Users/daybson/Library/Developer/Xcode/DerivedData/SFML-hfefftxugsbrbveemutrfjeoeuhy/Build/Products/Debug/SFML.app/Contents/MacOS/SFML
  Reason: no suitable image found.  Did find:
   /Users/daybson/Library/Frameworks/sfml-system.framework/Versions/2.5.1/sfml-system: code signature in (/Users/daybson/Library/Frameworks/sfml-system.framework/Versions/2.5.1/sfml-system) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
   /Library/Frameworks/sfml-system.framework/Versions/2.5.1/sfml-system: code signature in (/Library/Frameworks/sfml-system.framework/Versions/2.5.1/sfml-system) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
   /Library/Frameworks/sfml-system.framework/Versions/2.5.1/sfml-system: stat() failed with errno=1

Balnian

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: SFML.Net Core???
« Reply #7 on: July 16, 2020, 05:22:37 pm »
That's a pretty old thread you revived here 8Observer8  ;D,
I don't want to sound mean but let's not do that anymore it confuse people, like this post was originally because SFML.NET didn't support .Net Core in 2016 (and subsequently me saying I did a PR for it) and now it's slowly transforming into a .Net Core catch all/ debug post/thread. which should be there own standalone post to allow for easier navigation/ answer finding and google indexing of problem/answer

SO PLEASE IF YOU'RE ABOUT TO ADD TO THIS POST CONSIDER CREATING A NEW ONE INSTEAD, CONSIDER THIS ONE CLOSED