我是初學者,所以請裸露在我身邊。我正嘗試使用SFML 2.1,C++和MS Visual Studio Professional 2013將圖像輸出到屏幕上。嘗試將文件加載到紋理時出現意外錯誤。它輸出一大堆隨機字符。我確定它是如何使用Visual Studio配置SFML庫的,或者是否存在代碼問題。有誰能解決這個問題嗎?謝謝。無法使用C++和SFML 2.1加載圖像文件作爲紋理
這裏是什麼樣子,當我運行程序(http://i.stack.imgur.com/uMdLT.png)像截圖:
這是我的代碼:
#include <SFML/Graphics.hpp>
#include <iostream>
#include <string>
using namespace std;
int main() {
sf::RenderWindow window;
window.create(sf::VideoMode(800, 600), "My First SFML Game!"); // initializing
sf::Texture jetTexture;
sf::Sprite jetImage;
// Getting Error here!
if (!jetTexture.loadFromFile("fighter jet.png"))
throw std::runtime_error("Could not load fighter jet.png");
jetImage.setTexture(jetTexture);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.draw(jetImage);
window.display();
}
return 0;
}
對於所有的配置屬性,它們看起來就像這樣:
鏈接器 - >常規(http://i.stack.imgur.com/NZg7P.png):
鏈接器 - >輸入(http://i.stack.imgur.com/1tPaB.png):
**請注意,如果有一天,我也沒有配置SFML庫,然後我會從我的系統說msvcr110d.dll is missing
得到一個錯誤。
編輯:請參閱更新代碼。
我剛剛使用VS Express 2013與你確切的源代碼,我得到了同樣的錯誤!所以它不只是你的機器。我試圖找出它爲什麼會發生! – 2014-10-06 01:28:02
將'fighter jet.png'重命名爲'fighterjet.png',並將其放入Project文件夾和Debug文件夾中,然後嘗試再次運行它。 – Romeo 2014-10-07 10:56:08