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.


Messages - A_Sentient_Tomato

Pages: [1]
1
Graphics / Re: Do these three features exist?
« on: March 08, 2020, 08:25:18 pm »
An easy way to do this is with a matrix:
let's say you have a center of rotation, C, and an angle of rotation, A.
your shape is made of a bunch of little shapes - you can just apply this transformation to each one.
let's say your shape's vertices are {(x,y), (x1, y1), (x2,y2)}
create a new shape with vertices at {(x-C, y-C), (x1-C, y1-C), (x2-C, y2-C)}
apply the 2D rotation matrix (oh boy how do I format this):
[cos(A)     -sin(A)]
[sin(A)      cos(A)]
to each one of the new shape's vertices and then just add C back to each one.

Apply this to every one of your shapes and they will rotate exactly!

2
Graphics / Error accessing files to load fonts
« on: March 08, 2020, 08:15:40 pm »
Hello. I'm a student using SFML for one of my projects (C++) and this error has been driving me nuts.

I'm trying to load a truetype font using SFML. All other SFML features that I've used so far have been working fine (although none of them involve reading files), but this specific one seems to be failing every time.
I've tried to load the font using loadFromFile() and loadFromStream(). The first returns no error (but the method returns "false") and the latter prints "Failed to load font from stream (failed to create the font face)".

This led me to think that SFML is having trouble reading files from my disk. However, the ttf file is definitely in the working directory - I've checked this by having the program create a file and checking the directory it appears in. The ttf file is also definitely valid (I can open it using other software) and appropriately named.

As part of this project, I've already used another library (pugixml) to read xml files, and have had no trouble reading from the same directory that I am trying to access here, so this doesn't seem to be a permission problem.

Here is the relevant code:



        sf::Font font;
        sf::FileInputStream stream;
        if (!stream.open("arial.ttf")) {
                std::cout << "error\n";
        }

        if (!font.loadFromStream(stream)) {
                std::cout << "error1\n";
        }
        std::ofstream outfile("testfile.txt");

        if (!font.loadFromFile("arial.ttf")) {
                std::cout << "error3\n";
        }

 

All three of these errors are triggered. I've #include'd <SFML\Graphics.hpp> at the top of the file.

Any help would be really appreciated! Thank you in advance!

Pages: [1]