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

Author Topic: [SFML.Net] SFML.Graphics.Font no textures loading.  (Read 2672 times)

0 Members and 1 Guest are viewing this topic.

HardCoded

  • Newbie
  • *
  • Posts: 23
    • View Profile
[SFML.Net] SFML.Graphics.Font no textures loading.
« 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");
}
« Last Edit: May 18, 2014, 09:46:17 am by HardCoded »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: [SFML.Net] SFML.Graphics.Font no textures loading.
« Reply #1 on: May 18, 2014, 10:01:22 am »
Please write a complete and minimal example that reproduces the problem.
Laurent Gomila - SFML developer

HardCoded

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: [SFML.Net] SFML.Graphics.Font no textures loading.
« Reply #2 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.
« Last Edit: May 18, 2014, 12:08:16 pm by HardCoded »

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: [SFML.Net] SFML.Graphics.Font no textures loading.
« Reply #3 on: May 18, 2014, 12:28:41 pm »
Isn't there a way to check if it's correctly loaded?

HardCoded

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: [SFML.Net] SFML.Graphics.Font no textures loading.
« Reply #4 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 =/

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: [SFML.Net] SFML.Graphics.Font no textures loading.
« Reply #5 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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

HardCoded

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: [SFML.Net] SFML.Graphics.Font no textures loading.
« Reply #6 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
« Last Edit: May 18, 2014, 02:07:02 pm by HardCoded »