GithubHelp home page GithubHelp logo

sfml / sfml.net Goto Github PK

View Code? Open in Web Editor NEW
509.0 33.0 87.0 9.36 MB

Official binding of SFML for .Net languages

Home Page: https://www.sfml-dev.org

License: Other

C# 99.83% PowerShell 0.10% Shell 0.07%
sfml dotnet multimedia audio graphics opengl crossplatform hacktoberfest

sfml.net's Introduction

SFML.Net - Simple and Fast Multimedia Library for .Net

SFML is a simple, fast, cross-platform and object-oriented multimedia API. It provides access to windowing, graphics, audio and network. It is originally written in C++, and this project is its official binding for .Net languages (C#, VB, ...).

Authors

Download

You can get the latest official release on NuGet or on the SFML website. You can also get the current development version from the git repository.

Learn

There is no tutorial for SFML.Net, but since it's a binding you can use the C++ resources:

Of course, you can also find the SFML.Net API documentation in the SDK.

Dependencies

The NuGet package of SFML.Net comes with all dependencies, including native CSFML and SFML libraries for most platforms.

For unsupported platforms or non-NuGet sources, you must have a copy of CSFML. CSFML can be compiled from source or downloaded from the official release page. Also note that since CSFML depends on the main SFML project you also need all SFML runtime dependencies.

Another dependency is the OpenTK library. This is required by the examples to run correctly. It is not required unless you plan on running the example programs that are included.

Contribute

SFML and SFML.Net are open-source projects, and they need your help to go on growing and improving. Don't hesitate to post suggestions or bug reports on the forum or post new bugs/features requests on the issue tracker. You can even fork the project on GitHub, maintain your own version and send us pull requests periodically to merge your work.

sfml.net's People

Contributors

ashleydavies avatar atomcrafty avatar dabbertorres avatar davipb avatar deathbeam avatar demoxinmc avatar dsoronda avatar expl0it3r avatar goz3rr avatar isurakka avatar laurentgomila avatar madpew avatar marioalexsan avatar marioliebisch avatar myrup avatar negative-seven avatar neokabuto avatar nidaegwyn avatar nulldg avatar rosst0pher avatar sinshu avatar slko avatar szotp avatar zsbzsb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sfml.net's Issues

about this project

Have you considered using a tool like SWIG to automatically generate the .Net bindings?

Font Unload Bug

My friend was testing a project I made and he seems to get this "Access Violation" issue when we try to Null or .Dispose() a font object.

Stack Trace:
at SFML.Graphics.Font.sfFont_destroy(IntPtr CPointer)
at SFML.Graphics.Font.Destroy(Boolean disposing)
at SFML.ObjectBase.Dispose(Boolean disposing)
at SFML.ObjectBase.Dispose()
at Asreyion.Media.Resources.FontResource.Destroy()
at Asreyion.Media.Resources.FontResource.Dispose()
at Asreyion.Media.Resources.FontResource.Finalize()

Joystick static methods appear to not be working correctly

Whenever I press a button with my controller, the e.JoystickId that gets passed in when subscribing to JoystickButtonPressed is always 0. That is fine, however, if I call Joystick.IsConnected(0) it will always return false, as if the Joystick isn't plugged in. I noticed this because Joystick.IsButtonPressed() was always returning false for me whenever I would pass in the JoystickId along with the button that was just pressed. Am I doing something wrong or is this a known issue?

DLL mapping for SFML.net is not working in Linux

I have a latest official version of SFML.Net from the site (2.2, 64-bit) and a (C)SFML libraries installed from the Ubuntu repository. I have the following DLL mapping config:

<configuration>
    <dllmap dll="csfml-graphics-2" target="libcsfml-graphics.so.2"/>
    <dllmap dll="csfml-window-2" target="libcsfml-window.so.2.3"/>
</configuration

When trying to start a program I gen an error:

System.DllNotFoundException: libcsfml-graphics.so.2
  at at (wrapper managed-to-native) SFML.Graphics.RenderWindow:sfRenderWindow_createUnicode (SFML.Window.VideoMode,intptr,SFML.Window.Styles,SFML.Window.ContextSettings&)
  at SFML.Graphics.RenderWindow..ctor (SFML.Window.VideoMode mode, System.String title, SFML.Window.Styles style, SFML.Window.ContextSettings settings) [0x00043] in <7c7f42323ce84ef6957e114ed6eaff0f>:0
  at SFML.Graphics.RenderWindow..ctor (SFML.Window.VideoMode mode, System.String title) [0x0000b] in <7c7f42323ce84ef6957e114ed6eaff0f>:0
  at SFML.Net_Test.Program.Main () [0x00001] in /home/yashrk/src/education/csharp/SFML_01_simple_test/SFML_simple_test/Program.cs:14

I tried to add full path to .so files to DLL mapping files, with no luck.

Ubuntu 16.04, libcsfml version is 2.3-2build1.

ConvexShape constructor bug

Creating a ConvexShape with the point count in the constructor argument doesn't set the point count correctly.

Fix:
ConvexShape.cs line 36 change this

PointCount = PointCount;

to

PointCount = pointCount;

SoundRecorder.DefaultDevice crashes program when used

Any attempts to use SoundRecorder.DefaultDevice (even as a watch while debugging) instantly crash the simple console program I'm working on. SoundRecorder.IsAvailable returns true, and I can use the strings in SoundRecorder.AvailableDevices without crashing the program. Output after the crash doesn't provide anything useful, but I'd be willing to compile a debug version of the SFML.NET libraries and post more info if no one can replicate this.

Currently using the most recent 64-bit release of SFML.NET in VS Express 2013 on a computer running Win7.

Small typo in docs

On the Welcome page of the SFML.Net documentation, the game loop has while(window.isOpened()). This should be while (window.isOpen()). Not a huge deal, but if someone is using that Welcome page code as a tester, they need to constantly fix that anytime they copy/paste.

Modern coding standards

I think that moving to modern C# coding standards in SFML.Net source would be good step to do. If you would like to @LaurentGomila, I can refactor entire SFML.Net source. Example of refactored Transformable class is below: https://github.com/LaurentGomila/SFML.Net/blob/master/src/Graphics/Transformable.cs

using System;
using SFML.Window;

namespace SFML
{
    namespace Graphics
    {
        ////////////////////////////////////////////////////////////
        /// <summary>
        /// Decomposed transform defined by a position, a rotation and a scale
        /// </summary>
        /// <remarks>
        /// A note on coordinates and undistorted rendering:
        /// By default, SFML (or more exactly, OpenGL) may interpolate drawable objects
        /// such as sprites or texts when rendering. While this allows transitions
        /// like slow movements or rotations to appear smoothly, it can lead to
        /// unwanted results in some cases, for example blurred or distorted objects.
        /// In order to render a SFML.Graphics.Drawable object pixel-perfectly, make sure
        /// the involved coordinates allow a 1:1 mapping of pixels in the window
        /// to texels (pixels in the texture). More specifically, this means:
        /// * The object's position, origin and scale have no fractional part
        /// * The object's and the view's rotation are a multiple of 90 degrees
        /// * The view's center and size have no fractional part
        /// </remarks>
        ////////////////////////////////////////////////////////////
        public class Transformable : ObjectBase
        {
            ////////////////////////////////////////////////////////////
            /// <summary>
            /// Default constructor
            /// </summary>
            ////////////////////////////////////////////////////////////
            public Transformable() :
                base(IntPtr.Zero)
            {
            }

            ////////////////////////////////////////////////////////////
            /// <summary>
            /// Construct the transformable from another transformable
            /// </summary>
            /// <param name="transformable">Transformable to copy</param>
            ////////////////////////////////////////////////////////////
            public Transformable(Transformable transformable) :
                base(IntPtr.Zero)
            {
                _origin = transformable.Origin;
                _position = transformable.Position;
                _rotation = transformable.Rotation;
                _scale = transformable.Scale;
            }

            ////////////////////////////////////////////////////////////
            /// <summary>
            /// Position of the object
            /// </summary>
            ////////////////////////////////////////////////////////////
            public Vector2f Position
            {
                get
                {
                    return _position;
                }
                set
                {
                    _position = value;
                    _transformNeedUpdate = true;
                    _inverseNeedUpdate = true;
                }
            }

            ////////////////////////////////////////////////////////////
            /// <summary>
            /// Rotation of the object
            /// </summary>
            ////////////////////////////////////////////////////////////
            public float Rotation
            {
                get
                {
                    return _rotation;
                }
                set
                {
                    _rotation = value;
                    _transformNeedUpdate = true;
                    _inverseNeedUpdate = true;
                }
            }

            ////////////////////////////////////////////////////////////
            /// <summary>
            /// Scale of the object
            /// </summary>
            ////////////////////////////////////////////////////////////
            public Vector2f Scale
            {
                get
                {
                    return _scale;
                }
                set
                {
                    _scale = value;
                    _transformNeedUpdate = true;
                    _inverseNeedUpdate = true;
                }
            }

            ////////////////////////////////////////////////////////////
            /// <summary>
            /// The origin of an object defines the center point for
            /// all transformations (position, scale, rotation).
            /// The coordinates of this point must be relative to the
            /// top-left corner of the object, and ignore all
            /// transformations (position, scale, rotation).
            /// </summary>
            ////////////////////////////////////////////////////////////
            public Vector2f Origin
            {
                get
                {
                    return _origin;
                }
                set
                {
                    _origin = value;
                    _transformNeedUpdate = true;
                    _inverseNeedUpdate = true;
                }
            }

            ////////////////////////////////////////////////////////////
            /// <summary>
            /// The combined transform of the object
            /// </summary>
            ////////////////////////////////////////////////////////////
            public Transform Transform
            {
                get
                {
                    if (myTransformNeedUpdate)
                    {
                        myTransformNeedUpdate = false;

                        var angle  = -_rotation * 3.141592654F / 180.0F;
                        var cosine = (float)Math.Cos(angle);
                        var sine   = (float)Math.Sin(angle);
                        var sxc    = _scale.X * cosine;
                        var syc    = _scale.Y * cosine;
                        var sxs    = _scale.X * sine;
                        var sys    = _scale.Y * sine;
                        var tx     = -_origin.X * sxc - myOrigin.Y * sys + myPosition.X;
                        var ty     =  _origin.X * sxs - myOrigin.Y * syc + myPosition.Y;

                        myTransform = new Transform( sxc,  sys,   tx,
                                                    -sxs,  syc,   ty,
                                                    0.0F, 0.0F, 1.0F);
                    }
                    return myTransform;
                }
            }

            ////////////////////////////////////////////////////////////
            /// <summary>
            /// The combined transform of the object
            /// </summary>
            ////////////////////////////////////////////////////////////
            public Transform InverseTransform
            {
                get
                {
                    if (myInverseNeedUpdate)
                    {
                        myInverseTransform = Transform.GetInverse();
                        myInverseNeedUpdate = false;
                    }
                    return myInverseTransform;
                }
            }

            ////////////////////////////////////////////////////////////
            /// <summary>
            /// Construct the object from its internal C pointer
            /// </summary>
            /// <param name="cPointer">Pointer to the object in the C library</param>
            ////////////////////////////////////////////////////////////
            protected Transformable(IntPtr cPointer) :
                base(cPointer)
            {
            }

            ////////////////////////////////////////////////////////////
            /// <summary>
            /// Handle the destruction of the object
            /// </summary>
            /// <param name="disposing">Is the GC disposing the object, or is it an explicit call ?</param>
            ////////////////////////////////////////////////////////////
            protected override void Destroy(bool disposing)
            {
                // Does nothing, this instance is either pure C# (if created by the user)
                // or not the final object (if used as a base for a drawable class)
            }

            private Vector2f  _origin              = new Vector2f(0, 0);
            private Vector2f  _position            = new Vector2f(0, 0);
            private float     _rotation            = 0;
            private Vector2f  _scale               = new Vector2f(1, 1);
            private Transform _transform;
            private Transform _inverseTransform;
            private bool      _transformNeedUpdate = true;
            private bool      _inverseNeedUpdate   = true;
        }
    }
}

Release 2.2

Todo list before we can release 2.2. CSFML now has the required changes so all that is required now is to now implement them in SFML.NET.

-=SFML.NET=-

window focus has/request #94
underline position/thickness #95
font info #96
joystick info #97
sound recorder start/bool return #99
sound recorder devices #99
sensor api #102
touch api #102
sensor and touch events #102
color int constructor SFML/SFML#722 - after 2.2

RenderWindow doesn't update its View correctly

Calling RenderWindow.GetView and changing its state doesn't actually change the state drawing uses until you call RenderWindow.SetView.

Therefore changing the state of View and then calling RenderWindow.GetView returns incorrect state until you call SetView.

Example:

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

class Program
{
    static void Main(string[] args)
    {
        RenderWindow rw = new RenderWindow(new VideoMode(800u, 600u), "View Example");
        View view = rw.GetView();

        view.Center = new Vector2f(0f, 0f);

        Console.WriteLine("Window center: " + rw.GetView().Center); // Output: 0, 0 like it should be.

        //rw.SetView(view); // Uncommenting this makes it work like it should.

        while (rw.IsOpen())
        {
            rw.Clear();
            rw.DispatchEvents();

            // If SetView is commented the circle is actually drawn at top left corner.
            // The output tells us that the center should be at 0, 0 but it isn't until we call SetView
            rw.Draw(new CircleShape(32f, 16u));

            rw.Display();
        }
    }
}

I'm fairly sure the same thing happens with RenderTexture.

Impossible to draw something

I just tried to run this simple example :

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

class MainClass
{
    static void Main(string[] args)
    {
        RenderWindow w = new RenderWindow(new VideoMode(640,480,32),"SFML TEST");

        Texture texture = new Texture("test.png");
        Sprite sprite = new Sprite(texture);

        while (w.IsOpen())
        {
            w.Clear();
            w.Draw(sprite);             
            w.Display();
        }
    }
}

An got the exception :

Unhandled Exception: System.EntryPointNotFoundException: sfTransform_create
  at (wrapper managed-to-native) SFML.Graphics.Transform:sfTransform_create ()
  at SFML.Graphics.Transform..ctor () [0x00000] in <filename unknown>:0 
  at SFML.Graphics.Transform.get_Identity () [0x00000] in <filename unknown>:0 
  at SFML.Graphics.RenderStates.get_Default () [0x00000] in <filename unknown>:0 
  at SFML.Graphics.RenderWindow.Draw (Drawable drawable) [0x00000] in <filename unknown>:0 
  at MainClass.Main (System.String[] args) [0x00039] in /home/bapt/SFML/test/Main.cs:18 
[ERROR] FATAL UNHANDLED EXCEPTION: System.EntryPointNotFoundException: sfTransform_create
  at (wrapper managed-to-native) SFML.Graphics.Transform:sfTransform_create ()
  at SFML.Graphics.Transform..ctor () [0x00000] in <filename unknown>:0 
  at SFML.Graphics.Transform.get_Identity () [0x00000] in <filename unknown>:0 
  at SFML.Graphics.RenderStates.get_Default () [0x00000] in <filename unknown>:0 
  at SFML.Graphics.RenderWindow.Draw (Drawable drawable) [0x00000] in <filename unknown>:0 
  at MainClass.Main (System.String[] args) [0x00039] in /home/bapt/SFML/test/Main.cs:18 

Additional informations :

  • SFML 2.0, downloaded from website
  • Running with Mono
  • Only the line "w.Draw(sprite);" causes the exception
  • I can't draw shapes too

RenderWindow to .Net's BitMap

is it possible to copy output from SFML.Graphics.RenderWindow to System.Drawing.Bitmap?
try to display the output in pictureBox or like components.

View class incorrect GetCenter import

View class has incorrect GetCenter import or the C version is wrong. The C version doesn't contain GetCenterX and GetCenterY. Only GetCenter.

Edit: There is similar problem with ConvexShape GetPoint method.

(Minor, with fix) Transform.ToString() produces wrong results

Transform::ToString()
return "[Transform]" +
" Matrix(" +
m00 + ", " + m01 + ", " + m02 +
m10 + ", " + m11 + ", " + m12 +
m20 + ", " + m21 + ", " + m22 +
")";

actually produces a wrong string value, that does (m02 + m10).ToString() etc. operation.

Should instead be like:
return string.Format("[Transform] Matrix({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8})", m00, m01, m02, m10, m11, m12, m20, m21, m22);

Use OpenTK for OpenGL integration and such rather than Tao

Tao is not currently maintained, and was sort of nasty to work with to begin with. OpenTK is a much nicer OpenGL binding that is actively maintained and wraps OpenGL calls in a nicer C#-ish style.

This is pretty much a feature request. If anyone's interested I'd be willing to help port it over; it shouldn't be hard.

NuGet packages?

Are there plans for a nuget package?
If so, there could be actually two, one for the bindings and another one for the dependencies.

SFML.Graphics.Text GetGlobalBounds "External component has thrown an exception."

Sometimes when I try to get the Global Bounds of a Text object i get a SEHException:
An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in sfmlnet-graphics-2.dll
Additional information: External component has thrown an exception.

This is not a one of exception, i can run my game for some time and get this exception, when I do the characters drawn on screen turns into white squares, and the exception crashes the game.

RenderTexture not clearing on Clear()

As discussed here:

http://en.sfml-dev.org/forums/index.php?topic=9350.msg106496#msg106496

Key issue appears to be that RenderTexture.Clear() is not reflected in subsequent Draw() calls unless the target it is being drawn to has something else drawn to it afterwards.

I've set up a spike project to more clearly illustrate the issue based on the examples provided in the aforementioned SFML forum thread. See:

https://github.com/nathanchere/Spikes_SfmlRenderTexture

(There is also a compiled / redistributable version available here if you just want to see the issue first-hand without building for yourself)

Demo

Because the first two render modes in that spike are based on reports of the same core issue in C++ projects I'm fairly confident it's an SFML issue but I haven't had a chance to go set up a C++ project to confirm yet, nor to go through the SFML code to see how RenderTexture works, hence opening a ticket on SFML.Net instead. My uneducated guess (without having looked into the underlying code yet) is that it's using some kind of double-buffering optimisation and is only rendering explicitly invalidated regions on Draw() calls.

As a work-around for anyone else reading this before a fix is found, you can do the following to force a full render of the RenderTexture on Draw with relatively minimal overhead:

// keep this somewhere within scope of your render method:
var renderHack = new RectangleShape(new Vector2f(0,0)){ FillColor = new Color(0,0,0,0) }

// then change this (or your equivalent):
_target.Draw(_renderTexture);:
_targetDisplay();

// to this:
_target.Draw(_renderTexture);:
_target.Draw(renderHack);
_targetDisplay();

Let the CLR know how much memory you use

Currently the garbage collector thinks that e.g. an Image is just the size of one IntPtr big, although it might occupy several MBs of memory. This is not optimal. You can read the following in the MSDN Library:

In determining when to schedule garbage collection, the runtime takes into account how much managed memory is
allocated. If a small managed object allocates a large amount of unmanaged memory, the runtime takes into account only the
managed memory, and thus underestimates the urgency of scheduling garbage collection.

To solve this problem you should use GC.AddMemoryPressure (and of course GC.RemoveMemoryPressure).

Window.IsOpen should be a property

It definitely looks like something that should be a property.
Is there any particular reason that it's not?

Here's a quick fix:

// Window.cs
public virtual bool IsOpen
{
    get { return sfWindow_isOpen(CPointer); }
}

// RenderWindow.cs
public override bool IsOpen
{
    get { return sfRenderWindow_isOpen(CPointer); }
}

Remove extlibs folder

Considering all the changes that are constantly happening it is difficult to keep the extlibs up to date. I think in order to keep this more consistent with the CSFML project we should remove the extlibs folder and allow users to get CSFML themselves. This would increase cross platform support as we won't need to provide builds in the actual repository for every single platform (which we don't already).

It would also remove confusion when people download the updated SFML.NET repository and then it doesn't work with the provided extlibs. It would be simpler to mention in the readme that you must get CSFML (either by compiling or downloading a CSFML release) in order to use SFML.NET.

Of course this wouldn't affect packaged releases as we would still include compiled SFML/CSFML in those packages.

Error building SFML project using NuGet version on MonoDevelop on Linux

Hello,
I've been having difficulties building a demo very simple SFML test project on Linux using MonoDevelop and tha version of SFML provided by the NuGet package manager. I don't know if you are responsible for maintaining that package, so I apologize in advance if it isn't the case.

The version of the SFML package provided by NuGet is 2.1.5
I'm using MonoDevelop version 5.0.1 on Arch Linux (kernel version 3.17.4) x86_64. The sfml and csfml packages are installed.

When trying to compile my text project, I get an error message saying "Build failed. See the build logs for details.".

This is the content of the build log;

Building: SFMLTest (Debug|x86)

Build started 12/4/2014 7:58:04 AM.
__________________________________________________
Project "/home/duane/Programming/C#/SFMLTest/SFMLTest/SFMLTest.csproj" (Build target(s)):

        Target PrepareForBuild:
            Configuration: Debug Platform: x86

        Target CopyFilesMarkedCopyLocal:
            Copying file from '/home/duane/Programming/C#/SFMLTest/packages/SFML.Net.2.1.5/lib/sfmlnet-audio-2.dll' to '/home/duane/Programming/C#/SFMLTest/SFMLTest/bin/Debug/sfmlnet-audio-2.dll'
            Copying file from '/home/duane/Programming/C#/SFMLTest/packages/SFML.Net.2.1.5/lib/sfmlnet-graphics-2.dll' to '/home/duane/Programming/C#/SFMLTest/SFMLTest/bin/Debug/sfmlnet-graphics-2.dll'
            Copying file from '/home/duane/Programming/C#/SFMLTest/packages/SFML.Net.2.1.5/lib/sfmlnet-window-2.dll' to '/home/duane/Programming/C#/SFMLTest/SFMLTest/bin/Debug/sfmlnet-window-2.dll'

        Target GenerateSatelliteAssemblies:
        No input files were specified for target GenerateSatelliteAssemblies, skipping.

        Target CoreCompile:
            Tool /usr/lib/mono/4.5/mcs.exe execution started with arguments: /noconfig /debug:full /debug+ /optimize- /out:obj/x86/Debug/SFMLTest.exe Program.cs Properties/AssemblyInfo.cs obj/x86/Debug/.NETFramework,Version=v4.0.AssemblyAttribute.cs /target:exe /define:DEBUG /nostdlib /platform:x86 /reference:/usr/lib/mono/4.0/System.dll /reference:../packages/SFML.Net.2.1.5/lib/sfmlnet-audio-2.dll /reference:../packages/SFML.Net.2.1.5/lib/sfmlnet-graphics-2.dll /reference:../packages/SFML.Net.2.1.5/lib/sfmlnet-window-2.dll /reference:/usr/lib/mono/4.0/System.Core.dll /reference:/usr/lib/mono/4.0/mscorlib.dll /warn:4

        Target CopyToOutput:
            Build for Baseclass.Contrib.Nuget.Output.1.0.7:
    : error : Error initializing task UnzipNuspec: Not registered task UnzipNuspec.
    : error : Error building target CopyToOutput: Object reference not set to an instance of an object

    ---------------------- Done ----------------------

    Build failed. MSBuild operation failed
    Build: 1 error, 0 warnings

With a little Google-fu I was able to find that little thread on Stack Overflow however it seems that the method suggested to fix this issue doesn't work.

If I've missed any step or failed to provide you with important information, please tell me.

I'd be really grateful if you guys could provide me with any help.

Vector2i and Vector2f operator overloads

Both classes lack a Vector * Vector and Vector / Vector operator overload, you can only multiply or divide by a float, which becomes frustating after a while since you can't directly change X or Y from Drawables and have to re-create the vector.

"Window not being focused when rendering space clicked." Issue Work Around

I was playing around in C# for a fix to this and came up with the following work around. Maybe the repository owner could implement this inside the SFML.Net library until the issue is fixed.

I am not sure on how to post the code bits with markdown so I will just link to my commit that I made the work around for this issue in: https://github.com/XerShade/XS.Scar.Engine/commit/15de0dd8a3e87a8ab42dacd5c59bbd987fe1df58

Hope this helps anyone who has the issue.

No entry point for sfKeyboard_IsKeyDown in csfml-window-2.dll

I wanted to try SFML2 but the Keyboard.IsKeyDown( Key key ) function only reports the given message that no entry point for the called c function could be found.

I use the x86 libs i compiled as i have only the Express Version which doesn't seem to allow x64 compilations.

ConvexShape's update

ConvexShape won't get updated until setPointCount is called.

using SFML.Graphics;
using SFML.Window;

class Program
{
    static void Main(string[] args)
    {
        var window = new RenderWindow(new VideoMode(800, 600), "Test");
        window.Closed += (s, a) => window.Close();
        while (window.IsOpen())
        {
            window.Clear();
            var convex = new ConvexShape(4);
            convex.SetPoint(0, new Vector2f(0, 0));
            convex.SetPoint(1, new Vector2f(100, 0));
            convex.SetPoint(2, new Vector2f(100, 100));
            convex.SetPoint(3, new Vector2f(0, 100));
            //convex.SetPointCount(4);

            window.Draw(convex); //won't draw anything
            window.Display();
            window.DispatchEvents();
        }
    }
}

Also it would be cool to have setPoints(params Vector2f[] vectors) method, to feed shape with whole array.

Memory leak

Seems Texture resources aren't being cleaned up unless Dispose(true) is called explicitly.

The following leaks (see http://en.sfml-dev.org/forums/index.php?topic=12248.15):

var renderWindow = new RenderWindow(new SFML.Window.VideoMode(200, 200), "I'm a leaker");
while (true)
{
var texture = new Texture("nonprogressive.jpg");
var sprite = new Sprite(texture);
renderWindow.Draw(sprite);
renderWindow.Display();
renderWindow.DispatchEvents();
GC.Collect();
}

wrong FloatRect returned with Text.GetGlobalBounds()

Under Linux and Mono I've a severe issue. I'm trying to get the object globalbounds but it returns the wrong top/left value.
I've tested this with :

using System;

using SFML.Graphics;
using SFML.Window;

namespace TestGlobalBounds
{
    public class Program
    {
        private RenderWindow win;
        private Text text;

        public Program ()
        {
            win = new RenderWindow(new VideoMode(800,600), "Hello world");
            text = new Text ("Hello world");
            text.Position = new Vector2f(100,100);
            Console.WriteLine (text.GetGlobalBounds());
        }

        public static void Main( string[] args)
        {
            Program prog = new Program();
        }
    }
}

With this result : [FloatRect] Left(1) Top(7) Width(145) Height(24)

So I wrote the same program directly in C with the good result : 107.000000:101.000000:145.000000:24.000000

The same issue occurred with Sprite object.

It seems to be the interface between C# and C whose do its job wrong.

I will search if this issue occurred under Windows and try to fix the issue.

Crash on exit in ATI DLL

I'm getting a crash on exit in atioglxx.dll if I create a Text instance that specifies a non-empty string in the constructor along with the font it will be using. I also crash on exit if I specify an empty string alone without specifying a font.

// Works fine:
LoadingText = new Text("", DefaultFont);
LoadingText.CharacterSize = 32;
LoadingText.DisplayedString = "Loading...";

// Works fine:
LoadingText = new Text();
LoadingText.CharacterSize = 32;
LoadingText.Font = DefaultFont;
LoadingText.DisplayedString = "Loading...";

// Crash:
LoadingText = new Text("Loading...", DefaultFont);
LoadingText.CharacterSize = 32;

// Crash:
LoadingText = new Text();
LoadingText.CharacterSize = 32;
LoadingText.DisplayedString = "Loading...";

Note that these crashes occur even if I don't render anything.

Edit: After some thought, it seems that the issue is a result of setting a text string before setting the font, which is what happens in the to crash cases. This does seem to be related to the default font lifetime crash then. I'll close the issue then.

SFML.Graphics.PrimitiveType

Is it possible to consider renaming this enum to something else? Its currently an ambiguous reference to OpenTK.Graphics.OpenGL.PrimitiveType which is used for describing the draw method.

EDIT: To be clear this throws an error for ambiguous reference when having a using statement for both OpenTK.Graphics.OpenGL and SFML.Graphics.

            GL.DrawArrays(PrimitiveType.Triangles, 0, 3);

Memory Leak

Seems Texture resources aren't being cleaned up unless Dispose(true) is called explicitly.

The following leaks (see http://en.sfml-dev.org/forums/index.php?topic=12248.15 ):

var renderWindow = new RenderWindow(new SFML.Window.VideoMode(200, 200), "I'm a leaker");
while (true)
{
var texture = new Texture("nonprogressive.jpg");
var sprite = new Sprite(texture);
renderWindow.Draw(sprite);
renderWindow.Display();
renderWindow.DispatchEvents();
GC.Collect();
}

unhandled exception smflnet-window-2

Hello, I am trying to use SFML with C# but when I run the program I get:

An unhandled exception of type 'System.BadImageFormatException' occurred in mscorlib.dll

Additional information: Could not load file or assembly 'sfmlnet-window-2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Thanks a lot, Flori

RenderTexture.Draw(Text) Error

hey,
i found an error while trying to draw a SFML.Text to a rendertexture.
If you draw a sprite with this texture, the characters are upside down:
http://www.myimg.de/?img=sfmlchars61b4f.png

Here is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SFML.Window;
using SFML.Graphics;

namespace DrawTextToRenderTexture
{
class Program
{

    static RenderWindow rwin;
    static Sprite spTex;
    static void Main(string[] args)
    {
        rwin = new RenderWindow(new VideoMode(800, 600), "Draw TExt");
        Text txt = new Text("abcdefghijklmnopqrstuvqxyz", new Font("C:\\Windows\\Fonts\\Arial.ttf"), 14);
        txt.Position = new Vector2f(0, 0);
        RenderTexture rTex = new RenderTexture((uint)txt.GetLocalBounds().Width, (uint)txt.GetLocalBounds().Height + 10);
        rTex.Draw(txt);
        spTex = new Sprite(rTex.Texture);
        spTex.Position = new Vector2f(100, 100);
        while (rwin.IsOpen())
        {
            rwin.SetActive();
            rwin.Clear();
            rwin.DispatchEvents();
            rwin.Draw(spTex);
            rwin.Display();
        }
    }


}

}

System.AccessViolationException

When calling Draw(renderTarget, renderState) (Sprite.cs Lines 164-177) I keep getting:

An unhandled exception of type 'System.AccessViolationException' occurred in sfmlnet-graphics-2.dll

Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Is this due to the OpenTK Changes?

AccessViolation GL.TexImage2D

I've tried searching here and on the SFML forums for help here but I couldn't come up with anything. I get an access violation running the OpenGL example at the following code on TexImage2D.

        using (Image image = new Image("resources/texture.jpg"))
        {
            GL.GenTextures(1, out texture);
            GL.BindTexture(TextureTarget.Texture2D, texture);
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)image.Size.X, (int)image.Size.Y, 0, PixelFormat.Rgba, PixelType.UnsignedByte, image.Pixels);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
        }
  • I have copied all csfml 2.2 (I also tried 2.1 and 2.0) x86 DLLs to the project folder of OpenGL example since this is where its output directory is.
  • I have built the vs2008 solution so that all the DLLs are in lib/x86
  • I have OpenTK 1.1 installed and verified its being copied to the OpenGL output folder as expected. OpenTK DLL properties are 1.1.1599.6049.
  • I verified that Image.Pixels was loaded correctly with real data.
  • GenTextures is returning a valid value as well.

Not really sure what to do at this point, I haven't made any changes to anything code wise and just wanted to mess with the examples.

Vector conversion

Currently the constructors used to convert between the various SFML.Window.Vector types are not present in the API. They should probably be added to the body of the class or as extension methods. Adding conversions to the System.Drawing.Size structs should be considered as well, since the conversion process would be relatively straightforward and this would tie SMFL to the built-in C# libraries in a sensible manner.

No Shape class?

This version doesn't have the Shape class from which the default shapes inherit from but the C++ version does. Can you add it?

VertexArray[i].Color is illegal

Hello everyone,

In C++ SFML, it is possible to do the following

sf::VertexArray quad(sf::Quads, 4);
quad[0].position = sf::Vector2f(10, 10);
quad[1].position = sf::Vector2f(110, 10);
quad[2].position = sf::Vector2f(110, 110);
quad[3].position = sf::Vector2f(10, 110);

Sadly, the equivalent C# code doesn't work :

var quad = new VertexArray(PrimitiveType.Quads, 4);
quad[0].Position = new Vector2f(10, 10);
quad[1].Position = new Vector2f(110, 10);
quad[2].Position = new Vector2f(110, 110);
quad[3].Position = new Vector2f(10, 110);

The following gives "Cannot modify the return value in SFML.Graphics.VertexArray.this[uint] because it is not a variable".

Is there any way around this issue ? This sounds like a problem coming from the C# language itself, and not really the SFML library, but it felt necessary to raise the issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.