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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Dude234

Pages: [1]
1
DotNet / Async corrupts Font ?
« on: July 24, 2018, 10:19:41 am »
(Using: SFML.NET 2.3)

I'm writing a resource loading screen. And I successfully implemented loading with async/await.
Next step is to display the progression. This is done with SFML.Text.

When starting the async, somehow the Font gets corrupted once. The outcome are missing letters in the Font data. The Font is NOT touched in the async chain!

If I recreate the Font after the async has fired its Tasking, everything seems to be fine. 
There are not multiple Tasks in parallel, but only one at a time.

To me, this looks like the .net threading takes memory that is used by the Font?
I do not claim to have a deep understanding of what is happening here.

Here is my code in very reduced form. I test loading with a lot of 5MB bmps currently.
I'm glad if you guys have some ideas on SFML objects and threading. Are they safe ;D

Font font;
Text text;

ctor(){
font = new Font(); //path
text = new Text();
LoadResourcesAsync();
}

async void LoadResourcesAsync() {
await Load();
}

async Task Load(){
foreach
await Task.Run(() => ); //load stuff and report progress via event
}

void Draw(RenderTarget target) {
text.DisplayedString = currentFile; // or percentage (currentFile is updated via event)
target.Draw(text);
}
 

2
DotNet / Changing Texture does not affect Sprite ?
« on: June 30, 2018, 03:56:03 pm »
Sprite spr = new Sprite();

Texture tex = new Texture("tex1.png");

spr.Texture = tex; // does not matter if inside constructor or prop

tex = new Texture("tex2.png");
 

I expected that changing the texture itself would also change the texture of the Sprite,
because I expected that the texture is referenced and not copied.
I really hope I do this wrong.

Pages: [1]