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 - jackoi

Pages: [1]
1
Graphics / Re: SFML don't load image from file to texture
« on: March 17, 2013, 04:10:35 pm »
Error it's here:
if (!background.loadFromFile("tlo.png"))
everything is linked correctly, im using libraries and dll's form VS2010.
here its a error:


x = 0, y = 0, m_texure = 0
nothing loaded :(

2
Graphics / SFML don't load image from file to texture
« on: March 17, 2013, 03:42:37 pm »
Hello,
I have problem with loading image from file to texture, when I'm trying to load texture as in the tutorial I get error (Segmentation fault) and program is stopped, in console I have a lot strange objects, and SFML window are white. When I try system("dir") I see that the file "tlo.png" is in the right directory. I'm using Visual Studio 2012, and without Texture and Sprite classes, program compile correctly without errors. Thanks for help with that strange problem.
Here is my code:
#include <SFML/Graphics.hpp>

#include <iostream>

using namespace sf;

int main() {
        RenderWindow window( VideoMode( 800, 600, 32 ), "SFML");

        system("dir");

        Texture background;
       
        if (!background.loadFromFile("tlo.png")) // tlo.png 800x600
                return EXIT_FAILURE;

        Sprite sprite(background);
       

        CircleShape circle;
        circle.setFillColor(Color(255, 0, 0));
        circle.setRadius(50);
        circle.setOutlineThickness(1);
        circle.setOutlineColor(Color(255, 255, 255));
        circle.setPosition(-50, -50);

        RectangleShape rect;
        rect.setFillColor(Color(0, 0, 255));
        rect.setSize(Vector2f(64, 64));
        rect.setPosition(Vector2f(-32, -32));

        View view(Vector2f(0.0f, 0.0f), Vector2f(800, 600));
        window.setView(view);

        while(window.isOpen()) {
                Event event;

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

                        if(event.type == Event::KeyPressed && event.key.code == Keyboard::Right) {
                                circle.setPosition(circle.getPosition().x + 2, circle.getPosition().y);
                        }

                        if(event.type == Event::KeyPressed && event.key.code == Keyboard::Left) {
                                circle.setPosition(circle.getPosition().x - 2, circle.getPosition().y);
                        }

                        if(event.type == Event::KeyPressed && event.key.code == Keyboard::Up) {
                                circle.setPosition(circle.getPosition().x, circle.getPosition().y - 2);
                        }

                        if(event.type == Event::KeyPressed && event.key.code == Keyboard::Down) {
                                circle.setPosition(circle.getPosition().x, circle.getPosition().y + 2);
                        }
                }

                window.clear();
                window.draw(sprite);
                window.draw(circle);
                window.draw(rect);

                window.display();
        }

        return 0;
}

Pages: [1]