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

Pages: [1]
1
General / Re: Basic sprite problem
« on: December 18, 2014, 04:22:24 am »
I built visual studio new project and used SFML 2.2 version with dynamic linking and now its working somehow  :D

Thanks everyone for help!

2
General / Re: Basic sprite problem
« on: December 18, 2014, 02:12:12 am »
I would say yes, build a new project.  Partly because it might help solve this issue, but also because it's important to understand how to configure your IDE/build system to handle a library.

That process is meant to be a fairly straightforward one.  As tedious and error-prone as it seems, it should become second nature after you've forced yourself to do it properly enough times.  More importantly, you're going to have to do something similar (but not quite the same) every time you add a library to your project.  Someday, you'll want to use more libraries than just SFML, and their tutorials won't be nearly as good as SFML's are.

You right, from now I'll build and reconfigure each and every project.
I did it and the loading function still returns false (img1.png is in every directory in project).
I think you should see this:


Edit: I'm using SFML 2.1, not 2.0 if it matters

3
General / Re: Basic sprite problem
« on: December 18, 2014, 01:47:30 am »
The pdb files are a visual studio thing related to how it handles debugging information.  As far as I know that error should never affect your program's behavior.

Since it's clear the file can't be found for whatever reason, here's the standard blurb you may have seen in the SFML tutorials:
Quote
The loadFromFile function can sometimes fail with no obvious reason. First, check the error message that SFML prints to the standard output (check the console). If the message is unable to open file, make sure that the working directory (which is the directory that any file path will be interpreted relative to) is what you think it is: When you run the application from your desktop environment, the working directory is the executable folder. However, when you launch your program from your IDE (Visual Studio, Code::Blocks, ...) the working directory might sometimes be set to the project directory instead. This can usually be changed quite easily in the project settings.

tl;dr The working directory isn't what you think it is, so put the .png in different places (iirc, it should be the folders called Debug and Release).

I tried to put it in every possible directory in my project and it still doesn't work.
When I made my first program in visual studio I modified the program configurations and all of my other projects are just a copy of the directory of the first project with additional classes.
Should I build new programs and modify them again instead of make copies of older ones?

4
General / Re: Basic sprite problem
« on: December 18, 2014, 01:24:13 am »
Sorry for all the confusion, I deleted the double post before you removed things from here. Everything should be okay now. ;)

This example works fine for me.
Is your graphics driver up-to-date?

Maybe i didn't save my img1.png at the correct place? it saved in the same directory of this .cpp file.
Do you get a message on the console?

No I don't but by the way I'm getting these messages in console when i run any SFML project (alot of lines with different DLLs):
'SFMLDemo.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Cannot find or open the PDB file.
 

Could you try checking the return value for loadFromFile()?  If it failed to load for whatever reason it should return false.
Yeah, i see now its returning false.

5
General / Basic sprite problem
« on: December 18, 2014, 01:01:26 am »
Hello guys, my first post.
I am pretty new in SFML (using 2.0) and I have really basic problem with sprites..
After the problem showed up in big project, I decided to simplify the problem scope to a basic project, and it still doesn't work.
Well, there is my little program:

#include <SFML/Graphics.hpp>
int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML works!");
    sf::Texture texture;
    texture.loadFromFile("img1.png");
    sf::Sprite sprite;
    sprite.setTexture(texture);
    sprite.setPosition(200, 300);

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

        window.clear();
        window.draw(sprite);
        window.display();
    }

    return 0;
}
 

All i see is black screen..
When I'm using sprite.setTextureRect(sf::IntRect(0, 0, 50, 50)); the known white square appears.

Maybe i didn't save my img1.png at the correct place? it saved in the same directory of this .cpp file.

Pages: [1]