Allocate textures after the window is open
Yeah there can be some issues with allocating the texture before the window creation, but I don't think I've ever had the problem with VS...
Anyways, you should really use more whitespaces. Your code is nearly unreadable to a normal programmer, e.g. something like this:
#include <SFML/graphics.hpp>
int main()
{
sf::RenderWindow app(sf::VideoMode(640,480), "test");
sf::Texture img;
if(!img.loadFromFile("bg.png"))
{
std::cout << "load error";
}
sf::Sprite bg(img, true);
while(app.isOpen())
{
sf::Event x;
while(app.pollEvent(x))
{
if(x.type==sf::Event::Closed)
{
app.close();
}
}
app.clear(sf::Color(0, 0, 0, 0));
app.draw(bg);
app.display();
}
}
Note: I removed the
sf::Rect<int> to make sure you're not specifying a wrong position there.
Also you should always start with an empty project, thus you wouldn't need stdafx.