Created
September 4, 2011 23:08
-
-
Save mantognini/1193685 to your computer and use it in GitHub Desktop.
RenderTexture fait des images residuelles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <SFML/Graphics.hpp> | |
| #include <SFML/Audio.hpp> | |
| #include "ResourcePath.hpp" | |
| int main (int argc, const char * argv[]) | |
| { | |
| // Create the main window | |
| sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window"); | |
| //creation d'une texture et du sprite qui la dessine | |
| sf::RenderTexture rTx; | |
| rTx.Create(200, 200); | |
| rTx.Clear(); | |
| rTx.Draw(sf::Shape::Circle(100, 100, 100, sf::Color::Red)); | |
| rTx.Display(); | |
| sf::Sprite spr[2]; | |
| spr[0].SetTexture(rTx.GetTexture()); | |
| //C'est important le fait que cette texture soit cree avant les que les autres, si elle est cree apres le bug disparais | |
| window.SetActive(); | |
| // Load a sprite to display | |
| sf::Texture texture; | |
| if (!texture.LoadFromFile(ResourcePath() + "cute_image.jpg")) | |
| return EXIT_FAILURE; | |
| sf::Sprite sprite(texture); | |
| // Create a graphical text to display | |
| sf::Font font; | |
| if (!font.LoadFromFile(ResourcePath() + "sansation.ttf")) | |
| return EXIT_FAILURE; | |
| sf::Text text("Hello SFML", font, 50); | |
| text.SetColor(sf::Color::Black); | |
| while (window.IsOpened()) | |
| { | |
| // Process events | |
| sf::Event event; | |
| while (window.PollEvent(event)) | |
| { | |
| // Close window : exit | |
| if (event.Type == sf::Event::Closed) | |
| window.Close(); | |
| // Escape pressed : exit | |
| if (event.Type == sf::Event::KeyPressed && event.Key.Code == sf::Keyboard::Escape) | |
| window.Close(); | |
| } | |
| window.Clear(); | |
| window.Draw(sprite); | |
| //Peu importe dessiner ça avant ou apres, le bug est la | |
| window.Draw(spr[0]); | |
| window.Draw(text); | |
| window.Display(); | |
| } | |
| return EXIT_SUCCESS; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment