So I've been having this weird rendering issue. My game project uses very specific text rendering, which requires me to paste text onto a texture, and then render it as a sprite or another render entity using VertexArrays. Below is one example of how I achieve this:
if (!VContent::FindTexture("player"))
{
sf::RenderTexture renderTex;
renderTex.create(18, 26);
sf::Font font;
VContent::LoadFont("Assets\\lucon.ttf", font);
sf::Text text = sf::Text("@", font, 32);
text.setColor(sf::Color::White);
text.setStyle(sf::Text::Regular);
text.setPosition(0, -7);
renderTex.draw(text);
renderTex.display();
VContent::StoreTexture("player", renderTex.getTexture());
}
VContent by the way, is my content manager, which I use to store and load textures and other copyable assets essentially anywhere in my project. It stores textures like so:
bool VContent::StoreTexture(string name, sf::Texture texture)
{
if (!FindTexture(name))
{
sf::Texture tex(texture);
textureDir.insert(textureDir.begin(), std::pair<string, sf::Texture>(name, tex));
#if _DEBUG
cout << name << " stored." << endl;
#endif
return true;
}
#if _DEBUG
cout << "Error storing texture: " << name << endl;
#endif
return false;
}
Anyway, on my home PC (see left image) it displays like normal with the text being rendered with the correct characters, but when I was testing on another PC (see image right), I was getting incorrect characters and random artefacts.
As far as hardware is concerned, there isn't much difference as they are both have Intel Core iSeries CPU, decent hard drive space and are both relatively high performance machines (although my home PC has a dedicated gaming graphics card, but I haven't discovered if the other PC has one itself).