Removed the built-in default font
This commit is contained in:
parent
a3357d9c10
commit
a0c1f5f50f
9 changed files with 53 additions and 14752 deletions
|
@ -5,6 +5,7 @@
|
|||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
|
||||
|
@ -19,6 +20,11 @@ public :
|
|||
{
|
||||
}
|
||||
|
||||
static void setFont(const sf::Font& font)
|
||||
{
|
||||
s_font = &font;
|
||||
}
|
||||
|
||||
const std::string& getName() const
|
||||
{
|
||||
return m_name;
|
||||
|
@ -43,7 +49,7 @@ public :
|
|||
}
|
||||
else
|
||||
{
|
||||
sf::Text error("Shader not\nsupported");
|
||||
sf::Text error("Shader not\nsupported", getFont());
|
||||
error.setPosition(320.f, 200.f);
|
||||
error.setCharacterSize(36);
|
||||
target.draw(error, states);
|
||||
|
@ -58,6 +64,12 @@ protected :
|
|||
{
|
||||
}
|
||||
|
||||
static const sf::Font& getFont()
|
||||
{
|
||||
assert(s_font != NULL);
|
||||
return *s_font;
|
||||
}
|
||||
|
||||
private :
|
||||
|
||||
// Virtual functions to be implemented in derived effects
|
||||
|
@ -69,6 +81,8 @@ private :
|
|||
|
||||
std::string m_name;
|
||||
bool m_isLoaded;
|
||||
|
||||
static const sf::Font* s_font;
|
||||
};
|
||||
|
||||
#endif // EFFECT_HPP
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include <cmath>
|
||||
|
||||
|
||||
const sf::Font* Effect::s_font = NULL;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// "Pixelate" fragment shader
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -87,6 +89,7 @@ public :
|
|||
"Mauris ultricies dolor sed massa convallis sed aliquet augue fringilla.\n"
|
||||
"Duis erat eros, porta in accumsan in, blandit quis sem.\n"
|
||||
"In hac habitasse platea dictumst. Etiam fringilla est id odio dapibus sit amet semper dui laoreet.\n");
|
||||
m_text.setFont(getFont());
|
||||
m_text.setCharacterSize(22);
|
||||
m_text.setPosition(30, 20);
|
||||
|
||||
|
@ -268,6 +271,12 @@ int main()
|
|||
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Shader");
|
||||
window.setVerticalSyncEnabled(true);
|
||||
|
||||
// Load the application font and pass it to the Effect class
|
||||
sf::Font font;
|
||||
if (!font.loadFromFile("resources/sansation.ttf"))
|
||||
return EXIT_FAILURE;
|
||||
Effect::setFont(font);
|
||||
|
||||
// Create the effects
|
||||
std::vector<Effect*> effects;
|
||||
effects.push_back(new Pixelate);
|
||||
|
@ -288,11 +297,6 @@ int main()
|
|||
textBackground.setPosition(0, 520);
|
||||
textBackground.setColor(sf::Color(255, 255, 255, 200));
|
||||
|
||||
// Load the messages font
|
||||
sf::Font font;
|
||||
if (!font.loadFromFile("resources/sansation.ttf"))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
// Create the description text
|
||||
sf::Text description("Current effect: " + effects[current]->getName(), font, 20);
|
||||
description.setPosition(10, 530);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue