I'm trying to write "hello world" to an SFML window... i know
If I paste SFML font/text tutorial code in GSpace class, I get the error: "Failed to add a new character to the font: the maximum texture size has been reached"
If I comment all of that out, and copy/paste to Simpulator class it works. If I undo everything, it works. If I copy what just worked into a new sf::Text in GSpace class: "Failed to add.." If I comment out "setStyle" I get "Segmentation fault: 11."
I'm using an old mac version 10.14.6.. I can't use XCode because my computer's so old it won't update, setting up other IDEs seemed as complicated as not using them, so I'm just using the terminal with a makefile.
I know next to nothing about makefiles and compilers. I copied most of what I have just to get things up and running.. It seems like something happens when compiling the Simpulator class, that doesn't happen when compiling the Menu class. Whatever happens when Simpulator is compiled might persist even after changing everything back, so the variables in GSpace suddenly function properly? ..that seems like an error.
Because it's the thing I least understand and, in my mind, the thing most prone to failure, here is my makefile:
SFML_LIB = -I..SFML/lib
SFML_INCLUDE = -I..SFML/include
SFML_FRAMEWORKS = -I..SFML/Frameworks
LIBS= -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio -lsfml-network
CXX = clang++
CXXFLAGS = -std=c++11
Simpulator: main.o Simpulator.o GameSpace.o
$(CXX) $(CXXFLAGS) main.o Simpulator.o GameSpace.o -o Simpulator $(LIBS)
main.o: main.cpp
$(CXX) $(CXXFLAGS) -c $<
Simpulator.o: Source/Simpulator.cpp Header/Simpulator.h
$(CXX) $(CXXFLAGS) -c $<
GameSpace.o: Source/GameSpace.cpp Header/GameSpace.h
$(CXX) $(CXXFLAGS) -c $<
clean:
rm *.o Simpulator
Let me know if I should provide additional code. Thanks for any help!
EDIT:
I've used both Arial.ttf and Tahoma.ttf fonts. The code I'm using is copy/paste from SFML site. This is the declaration in the class header:
sf::Font font;
sf::Text text;
This is in a "load" function:
if (!font.loadFromFile("Arial.ttf"))
{
// error...
}
// select the font
text.setFont(font); // font is a sf::Font
// set the string to display
text.setString("Hello world");
// set the character size
text.setCharacterSize(24); // in pixels, not points!
// set the color
text.setFillColor(sf::Color::Red);
// set the text style
text.setStyle(sf::Text::Bold | sf::Text::Underlined);
If I write this in GSpace, it doesn't work. If I remove it and copy to Simpulator, it works. If I remove it from Simpulator and copy back to GSpace, it works.
EDIT:
I found that as long as Simpulator.cpp is updated and recompiled, I can add a new sf::Text to GSpace with no errors. So if after adding sf::Text code to GSpace, I add "asdf" to Simpulator.cpp, save it, remove it, then save it again, there are no errors.
I edited the make file from:
Simpulator.o: Source/Simpulator.cpp Header/Simpulator.h
$(CXX) $(CXXFLAGS) -c $<
to:
Simpulator.o: Source/Simpulator.cpp Header/Simpulator.h Header/GSpace.h
$(CXX) $(CXXFLAGS) -c $<