SFML community forums

Help => Graphics => Topic started by: HardCoded on May 18, 2014, 09:44:40 am

Title: [SFML.Net] SFML.Graphics.Font no textures loading.
Post by: HardCoded on May 18, 2014, 09:44:40 am
Okay, so, I downloaded SFML.Net and got to some basic stuff first and drew a circle on a RenderWindow easily. Then, I tried Text and got stuck.

Basically, I've tried two custom fonts and the default Arial font from the system fonts folder without success. I think I know what's wrong but I don't know what's causing it.

I have attached a screenshot of the source code. f.myTextures.Count is always zero for some reason. And that means I can't draw any text.. But I don't know *why* it isn't getting any textures.

public void run () {
    Font f = new Font("res/font/arial.ttf");
}
Title: Re: [SFML.Net] SFML.Graphics.Font no textures loading.
Post by: Laurent on May 18, 2014, 10:01:22 am
Please write a complete and minimal example that reproduces the problem.
Title: Re: [SFML.Net] SFML.Graphics.Font no textures loading.
Post by: HardCoded on May 18, 2014, 11:43:17 am
What I posted is the exact thing I have.
using SFML.Graphics;

namespace AI_CTF {
        class Program {
                static void Main (string[] args) {
                        Font f = new Font("res/font/arial.ttf");
                }
        }
}

If it helps, I've used both the 64 and 32 bit versions of SFML.Net 2.1 and set the build target accordingly but both get me zero textures on the font.
Title: Re: [SFML.Net] SFML.Graphics.Font no textures loading.
Post by: G. on May 18, 2014, 12:28:41 pm
Isn't there a way to check if it's correctly loaded?
Title: Re: [SFML.Net] SFML.Graphics.Font no textures loading.
Post by: HardCoded on May 18, 2014, 01:22:32 pm
SFML.Net 2.0 64 and 32 bit show zero textures on fonts loaded, too.
using System;
using SFML.Graphics;
using SFML.Window;

namespace AI_CTF {
        class Program {
                static void Main (string[] args) {
                        RenderWindow rw = new RenderWindow(
                                VideoMode.DesktopMode,
                                "RenderWindow"
                        );
                        Font f = new Font("res/font/arial.ttf");
                        Text t = new Text("Text", f);

                        rw.Closed += (object sender, EventArgs e) => {
                                rw.Close();
                        };
                        while (rw.IsOpen()) {
                                rw.DispatchEvents();
                                rw.Clear();
                                t.Draw(rw, new RenderStates());
                                rw.Display();
                        }
                }
        }
}

@G, I duno. I would think it would've thrown an exception if it couldn't load a library =/
Title: Re: [SFML.Net] SFML.Graphics.Font no textures loading.
Post by: Nexus on May 18, 2014, 01:30:37 pm
t.Draw(rw, new RenderStates());
This doesn't work as expected. C# default-constructs structs by zeroing all entries. You want to use the RenderStates.Default constant.
Title: Re: [SFML.Net] SFML.Graphics.Font no textures loading.
Post by: HardCoded on May 18, 2014, 02:01:05 pm
I..
Umm..
Oh. My. God.

Thank you very much, sir  :-[

Err, still. I know that assuming that myTextures refers to the textures in a font is being evil because assuming the value of private members isn't reliable. But why is the count zero for it? What's it really for? o.0