SFML / SFML.Net

Official binding of SFML for .Net languages

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Texture.Update(Texture, uint, uint) not found?

hawkerm opened this issue · comments

Tried to use the Texture.Update method to update from another texture, but got a C++ exception about missing entry point:

Exception thrown: 'System.EntryPointNotFoundException' in SFML.Graphics.dll
An unhandled exception of type 'System.EntryPointNotFoundException' occurred in SFML.Graphics.dll
Unable to find an entry point named 'sfTexture_updateFromTexture' in DLL 'csfml-graphics'.

public void Update(Texture texture, uint x, uint y)
{
sfTexture_updateFromTexture(CPointer, texture.CPointer, x, y);
}

(Also looks like the overload without the x, y values and just taking the Texture directly is missing?)

image

Using NuGet package 2.5.0.

Code:

RenderTexture buff1 = new(800, 600);
Texture buff2 = new(800, 600);

// ... Draw stuff to buff1 ...

buff2.Update(buff1.Texture, 0, 0); // Fails

I was creating a whole new Texture each time before (which works), but is eating memory and causing issues with Garbage Collection:

Sprite buff2Sprite = new();

buff2Sprite.Texture = new Texture(buff1.Texture);

Is there some other way I should be doing this operation?

Looking at the exports of csfml-Graphics.dll, copied to the bin folder, it looks like the method is just missing from the C++ version directly?

> dumpbin csfml-Graphics.dll /EXPORTS
...
        385  180 0000AC20 sfTexture_swap
        386  181 0000AC30 sfTexture_updateFromImage
        387  182 0000AC40 sfTexture_updateFromPixels
        388  183 0000AC50 sfTexture_updateFromRenderWindow
        389  184 0000AC50 sfTexture_updateFromWindow
        390  185 00006AF0 sfTouch_getPositionRenderWindow
...

I downloaded the newer 2.5.1 CSFML package and checked those binaries, and the method appears to be there:

        387  182 0000A710 sfTexture_swap
        388  183 0000A720 sfTexture_updateFromImage
        389  184 0000A730 sfTexture_updateFromPixels
        390  185 0000A740 sfTexture_updateFromRenderWindow
        391  186 0000A750 sfTexture_updateFromTexture
        392  187 0000A740 sfTexture_updateFromWindow
        393  188 000065E0 sfTouch_getPositionRenderWindow

So it looks like SFML.NET needs to update to the newer 2.5.1 CSFML package version.

I tested copying the CSFML 2.5.1 dlls over to the bin folder of my output and was able to run with the existing SFML.NET code as-is. So, updating the dependency for the NuGet packages should be all that's required. (I'm not sure how to force the dependency to be used as a bypass in my project file as a work-around though...)

Should just be a matter of updating this to 2.5.1:

<Version>2.5.0</Version>

Testing this also helped me validate that updating the texture with this method resolved my memory issue and everything was stable with the effect I'm doing, so this is important for unblocking me from working on my game. Thanks!

You should, btw, be able to just use the CSFML 2.5.1 NuGet by directly referencing the wanted version instead of relying on the SFML.NET package to implicitly include CSFML 2.5.0.

However this does indeed require a fix, like the one you provided (even though I'm not sure about the whole version management 😄 )

Thanks @eXpl0it3r, I did try just adding a reference to CSFML directly for 2.5.1, but then it complained about the project type; so I must be missing something. Will poke around a bit more later today.

Was just thinking the same thing that you may want to decouple the CSFML version from the SFML.NET version (though I do like that the main version is the same, but being able to have SFML.NET at 2.5.1.33 but using CSFML 2.5.1 for instance still.)

The version has been decoupled in the build and a new SFML.Net NuGet package will be released soon. See #228 for more details.

The issue itself was fixed with SFML/CSFML#142