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.


Messages - denisonl

Pages: [1]
1
Graphics / Re: Can't load a background
« on: August 29, 2016, 04:32:18 pm »
Thank you very much! I've done it :)

2
Graphics / Re: Can't load a background
« on: August 27, 2016, 04:19:43 pm »
Maybe the "texture.png" doesn't exists (typo ?)
Check the image was correctly loaded with the return value of loadFromFile
File exists, return value of loadFromFile is 1 (true)

3
Graphics / Re: Can't load a background
« on: August 27, 2016, 01:08:06 pm »
I've done what you said, but there is no result. Only black window

#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
int main()
{
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
    sf::Image image;
    image.loadFromFile("texture.png");

    sf::Texture texture;
    texture.update(image);
    sf::Sprite sprite;
    sprite.setTexture(texture);
    while (window.isOpen())
    {
        // Process events
        sf::Event event;
        while (window.pollEvent(event))
        {
            // Close window: exit
            if (event.type == sf::Event::Closed)
                window.close();
        }
       
        // Clear screen
        window.clear();
        window.draw(sprite);
        // Update the window
        window.display();
    }
    return EXIT_SUCCESS;
}

4
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]