Hi eveyrone,
Sorry in advance as I'm not sure if it is the right place to ask that kind of question...
Anyway, I'm currently facing a problem I can't explain and it might (unless I'm wrong) actually be a bug within the sfml.
long story short, code + result:
code:#include <SFML/Graphics.hpp>
void dump_texture(sf::RenderWindow& rwindow, const sf::Vector2f& pos, sf::Texture& tex);
int main()
{
//
// INIT
// Create the main window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
// Load a sprite to display
sf::Texture texture;
if (!texture.loadFromFile("cute_image.jpeg"))
return EXIT_FAILURE;
sf::Sprite sprite(texture);
// scale to match a 200x200 size
sf::Vector2u tsize = texture.getSize();
sprite.scale(200.0f/tsize.x, 200.0f/tsize.y);
// INIT
//
// Start the game loop
while (window.isOpen())
{
//
// EVENTS
sf::Event event;
while (window.pollEvent(event))
{
// Close window: exit
if (event.type == sf::Event::Closed)
window.close();
}
// EVENTS
//
//
// RENDER
window.clear();
dump_texture(window, sf::Vector2f(200,0), texture);
window.draw(sprite);
dump_texture(window, sf::Vector2f(400,0), texture);
window.display();
// RENDER
//
}
return EXIT_SUCCESS;
}
void dump_texture(sf::RenderWindow& rwindow, const sf::Vector2f& pos, sf::Texture& tex)
{
sf::Texture::bind(&tex);
sf::Vertex vertices[] =
{
sf::Vertex(sf::Vector2f(pos.x+ 0, pos.y+ 0), sf::Color::White, sf::Vector2f(0,0)),
sf::Vertex(sf::Vector2f(pos.x+ 0, pos.y+200), sf::Color::White, sf::Vector2f(0,1)),
sf::Vertex(sf::Vector2f(pos.x+200, pos.y+200), sf::Color::White, sf::Vector2f(1,1)),
sf::Vertex(sf::Vector2f(pos.x+200, pos.y+ 0), sf::Color::White, sf::Vector2f(1,0))
};
rwindow.draw(vertices, 4, sf::Quads);
sf::Texture::bind(NULL);
}
resulthttps://drive.google.com/open?id=0BxUZ1JUO9QAbakJyWVhZWkZZRlUBasically the sprite seems to "disable" the opengl texture2d state... which would make the second call to dump_texture to fail?
Any idea?