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

Author Topic: Problem with loading an image.  (Read 1475 times)

0 Members and 1 Guest are viewing this topic.

Dread458

  • Newbie
  • *
  • Posts: 3
    • View Profile
Problem with loading an image.
« on: September 18, 2013, 02:14:21 am »
When i try loading an image i get this error.
'SFML.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\atigktxx.dll'
'SFML.exe' (Win32): Loaded 'C:\Windows\SysWOW64\atigktxx.dll'. Cannot find or open the PDB file.
The thread 0x2f3c has exited with code 0 (0x0).
The program '[8956] SFML.exe' has exited with code 0 (0x0).

This is my code.
#include<SFML/Graphics.hpp>
#include<iostream>

using namespace sf;



 
int main()
{

        Texture ptex;
        Sprite pimage;

        ptex.loadFromFile("Player.png");

        pimage.setTexture(ptex);


    RenderWindow Window(VideoMode(800, 600, 32), "Displaying Images");

        int px = 20;
        int py = 20;

        RectangleShape rect1;

        rect1.setSize(Vector2f(50, 50));
        rect1.setPosition(px,py);
        rect1.setOutlineColor(Color::Red);
        rect1.setOutlineThickness(5);
        rect1.setOrigin(25,25);

        RectangleShape shot;

        Clock clock;

        float moveSpeed = 5000.0f;
        float rot = .050f;

    while(Window.isOpen())
    {
                clock.restart();
        Event Event;

                Vector2i mpos = Mouse::getPosition(Window);
               
        while(Window.pollEvent(Event))
        {
            if(Event.type == Event::Closed || Event.key.code == Keyboard::Escape)
                Window.close();
                                        if(Event::MouseMoved)
                        rect1.setPosition(mpos.x,mpos.y);
        }

                if(Keyboard::isKeyPressed(Keyboard::Right))
                        rect1.move(moveSpeed * clock.getElapsedTime().asSeconds(), 0);
                if(Keyboard::isKeyPressed(Keyboard::Left))
                        rect1.move(-moveSpeed * clock.getElapsedTime().asSeconds(), 0);
                if(Keyboard::isKeyPressed(Keyboard::Up))
                        rect1.move(0, -moveSpeed * clock.getElapsedTime().asSeconds());
                if(Keyboard::isKeyPressed(Keyboard::Down))
                        rect1.move(0, moveSpeed * clock.getElapsedTime().asSeconds());
                if(Keyboard::isKeyPressed(Keyboard::D))
                        rect1.rotate(rot);
                if(Keyboard::isKeyPressed(Keyboard::A))
                        rect1.rotate(-rot);

                Window.draw(rect1);
        Window.display();
                Window.clear();
    }
    return 0;
}

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Problem with loading an image.
« Reply #1 on: September 18, 2013, 02:23:33 am »
What this actually compiled? ;D
Event Event;

Don't using namespace sf it makes the code a lot less readable and creates naming issues as seen above.
Also I highly recommend you go and read the official tutorials on SFML and given that you couldn't figure out what's going on and that the posted "error" is actually just a warning, I suggest you learn first how to use your IDE. How your compiler & link & debugger works.

Your issue is most likely that you didn't check the keyboard event properly! You first have to check whether there was a keyboard event and then check it's code.
Pleeeease don't tell me you came from the awful CodingMadeEasy YouTube tutorials... He made that bug in EVERY video among a lot of other issues...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Dread458

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Problem with loading an image.
« Reply #2 on: September 18, 2013, 02:32:37 am »
I did come from those tutorials :P but i did not neglect the SFML reference page. And my problem is not from the events it only happens when i try to load the image.

This is what the command console is giving me, along with beeps.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Problem with loading an image.
« Reply #3 on: September 18, 2013, 02:44:19 am »
Well the issue here is, that using your code, you let the randomness of compiler make the "decision" on the execution of your application aka "undefined behavior". Since the Event is never set, it can contain anything. If you're in luck it will not contain Event.key.code == sf::Keyboard::Escape, if you're not in luck, it will exactly contain that and close your application.

The console output seems really odd. When do you get that?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Dread458

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Problem with loading an image.
« Reply #4 on: September 18, 2013, 02:49:22 am »
I get that whenever I try doing this code.
        Texture ptex;
        Sprite pimage;

        ptex.loadFromFile("Player.png");

        pimage.setTexture(ptex);

It also beeps a bunch if that information helps.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Problem with loading an image.
« Reply #5 on: September 18, 2013, 03:02:55 am »
Well the beeping most probably comes from the bell character that might get printed to the console.

The given code should not produce something like this, thus I guess it's a driver issue. Is your graphics card driver up to date? What OS and what graphics card are you using?

Edit: Having hear of that beeping/console output issue, zsbzsb and I quickly googled the forum and found quite a few similar issues (e.g. here or here). It seems to happen when you mix debug and release modes. Thus read the official tutorials on how to setup and use SFML properly, rather than relying on some vague, faulty and outdated youtube guide. :)
« Last Edit: September 18, 2013, 03:25:33 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/