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

Author Topic: [SOLVED][SFML-2.0-rc][VC++2008] sf::Texture.loadFromFile problems  (Read 4197 times)

0 Members and 1 Guest are viewing this topic.

AndrewB

  • Newbie
  • *
  • Posts: 33
    • View Profile
Hi everyone,

I'm using VC++ 2008 with the SFML 2.0 release candidate.

I have just started using the SFML SDK today and I'm slowly familiarizing myself with the smaller components of the graphics library first.

The problem I'm running into is when I try to debug my program (source below) it can't seem to locate local files on my hard drive. When I run the .exe created in the debug directory however, it is able to load the texture file perfectly fine.

Example of debugging:


When I run the compiled exe directly:


And my source code:
#include <vector>

#include <SFML/Graphics.hpp>

const sf::Color kvoid_color(40, 40, 40, 255);

int main() {
  sf::RenderWindow window(sf::VideoMode(800, 600), "Profound Seeker");
  window.setVerticalSyncEnabled(true);

  sf::Texture grass_texture;
  grass_texture.loadFromFile("Resources/grass_tile.bmp");
 
  sf::Sprite grass_sprite;
  grass_sprite.setTexture(grass_texture);
  grass_sprite.setTextureRect(sf::IntRect(0, 0, 40, 40));
  grass_sprite.move(100, 100);
  //grass_sprite.rotate(23.f);

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

    window.clear(kvoid_color);
    window.draw(grass_sprite);
    window.display();
  }; // while while window.isOpen()

  return 0;
}; // int main

Thanks to all who can help!
« Last Edit: August 06, 2012, 03:26:33 pm by AndrewB »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: [SFML-2.0-rc][VC++2008] sf::Texture.loadFromFile problems
« Reply #1 on: August 06, 2012, 03:22:28 pm »
When you run from the IDE, the working directory is not set to the executable directory (like it is when you run it from the explorer), it is instead set to the project directory. You can change it in the project settings, under "Debugging" > "Working directory". Set it to $(TargetDir).
Laurent Gomila - SFML developer

AndrewB

  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: [SFML-2.0-rc][VC++2008] sf::Texture.loadFromFile problems
« Reply #2 on: August 06, 2012, 03:26:16 pm »
Thanks again Laurent!

How are you able to keep up with all of these support threads AND develop SFML at the same time?!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: [SOLVED][SFML-2.0-rc][VC++2008] sf::Texture.loadFromFile problems
« Reply #3 on: August 06, 2012, 03:33:05 pm »
Quote
How are you able to keep up with all of these support threads AND develop SFML at the same time?!
I'm not: SFML 2.0 is still stuck in RC instead of being officially released ;D
Laurent Gomila - SFML developer

AndrewB

  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: [SOLVED][SFML-2.0-rc][VC++2008] sf::Texture.loadFromFile problems
« Reply #4 on: August 06, 2012, 03:36:28 pm »
Oh, may I ask why it's stuck in RC?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: [SOLVED][SFML-2.0-rc][VC++2008] sf::Texture.loadFromFile problems
« Reply #5 on: August 06, 2012, 03:40:28 pm »
I have to finish the tutorials before I can release the final version. And I'm progressing really slowly on them.
Laurent Gomila - SFML developer