Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - denisonl

Pages: [1]
1
Graphics / [SOLVED]Can't load a background
« on: August 27, 2016, 11:06:11 am »
Hello! I can't load a background for a window. That's my code:

#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>

int main()
{
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
    while (window.isOpen())
    {
        // Process events
        sf::Event event;
        sf::Image image;
        image.loadFromFile("texture.png");

        sf::Texture texture;
        texture.update(image);
        sf::Sprite sprite;
        sprite.setTexture(texture);
        window.draw(sprite);

        while (window.pollEvent(event))
        {
            // Close window: exit
            if (event.type == sf::Event::Closed)
                window.close();
        }

       
        // Clear screen
        window.clear();
        // Update the window
        window.display();
    }
    return EXIT_SUCCESS;
}

What did I do wrong? Thank you

Pages: [1]
anything