Hello,
So I'm getting more and more familiar with sf::RenderTexture. It has REALLY helped with this current project since it requires drawing millions of pixels. I finally got it to run smooth switching to it. What I am concerned about is the texture loading the sf::image being drawn to every frame.
It's running great, as I said, but I'm just wondering if this is 'okay' to do and if not, what would be the appropriate solution? Is loading from the image 'okay', but loading up a new texture from a file different? I'm just curious about the future and if I had more stuff going on it would cause problems.
Thanks
void Worms_Part1::onDraw() {
for (int y = worldMin.y; y <= worldMax.y; ++y) {
for (int x = worldMin.x; x <= worldMax.x; ++x) {
const sf::Vector2i p(x, y);
if (m_map.isInBounds(p)) {
m_image.setPixel(x, y, m_map(p).isLand ? sf::Color(58, 110, 45) : sf::Color(45, 198, 198));
}
}
}
m_renderTexture.clear();
m_texture.loadFromImage(m_image);
m_renderTexture.draw(sf::Sprite(m_texture));
m_renderTexture.display();
m_renderSprite.setTexture(m_renderTexture.getTexture());
window.draw(m_renderSprite);
}