2013-10-03 77 views
0

我最近開始使用Visual Studio Studio 2012 C++的庫SFML。有線程錯誤的SFML程序

這一切都工作得很好,直到我開始使用自定義字體,然後這些消息彈出並沒有什麼工作:

'Graphics test.exe' (Win32): Loaded 'C:\Users\Oliver Bolt\Documents\Visual Studio 2012\Projects\Graphics test\Debug\Graphics test.exe'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Program Files\AVAST Software\Avast\snxhk.dll'. Cannot find or open the PDB file. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\opengl32.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\lpk.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\usp10.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\glu32.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ddraw.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dciman32.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\setupapi.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\oleaut32.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\devobj.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dwmapi.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmm.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp110d.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr110d.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\nvinit.dll'. Cannot find or open the PDB file. 
'Graphics test.exe' (Win32): Loaded 'C:\Program Files (x86)\NVIDIA Corporation\coprocmanager\_etoured.dll'. Cannot find or open the PDB file. 
'Graphics test.exe' (Win32): Loaded 'C:\Program Files (x86)\NVIDIA Corporation\coprocmanager\Nvd3d9wrap.dll'. Cannot find or open the PDB file. 
'Graphics test.exe' (Win32): Loaded 'C:\Program Files (x86)\NVIDIA Corporation\coprocmanager\nvdxgiwrap.dll'. Cannot find or open the PDB file. 
'Graphics test.exe' (Win32): Loaded 'C:\PROGRA~2\OPTIMI~1\OPTPRO~1.DLL'. Module was built without symbols. 
'Graphics test.exe' (Win32): Unloaded 'C:\PROGRA~2\OPTIMI~1\OPTPRO~1.DLL' 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\uxtheme.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ig7icd32.dll'. Cannot find or open the PDB file. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\igdusc32.dll'. Cannot find or open the PDB file. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\version.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\version.dll' 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dinput.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\hid.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\wintrust.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\crypt32.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msasn1.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Symbols loaded. 
'Graphics test.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\ole32.dll' 
The thread 0xed8 has exited with code 0 (0x0). 
The thread 0x131c has exited with code 0 (0x0). 
The thread 0x105c has exited with code 0 (0x0). 
The thread 0x19e8 has exited with code 0 (0x0). 
The thread 0xeb4 has exited with code 0 (0x0). 
The thread 0x187c has exited with code 0 (0x0). 
The thread 0x1c78 has exited with code 0 (0x0). 
The thread 0x480 has exited with code 0 (0x0). 
The thread 0x1244 has exited with code 0 (0x0). 
The program '[4124] Graphics test.exe' has exited with code 0 (0x0). 

造成這些錯誤的程序:

#include <SFML\System.hpp> 
#include <SFML\Graphics.hpp> 
#include <ctime> 
#include <sstream> 

using namespace sf; 
using namespace std; 

int main() 
{ 
    VideoMode videoMode(320, 240); 
    RenderWindow window(videoMode, "Plus or minus"); 

    Font font; 
    if (!font.loadFromFile("TOMB.TTF")) 
    { 
     return EXIT_FAILURE; 
    } 

    Text title("Plus Or Minus", font, 20); 
    title.setPosition(10, 10); 
    title.setColor(Color::White); 

    Text question("What is your guess ?",font,20); 
    question.setPosition(5,30); 
    question.setColor(Color::White); 

    Text enter("", font, 20); 
    enter.setPosition(5, 50); 
    enter.setColor(Color::Green); 
    String textEntered; 
    int numEntered = 0; 

    Text status("", font, 16); 
    status.setPosition(100, 50); 
    status.setColor(Color::Yellow); 
    stringstream out(""); 

    Text won("You have discovered\n the secret number\n in less than 10 tries,\n well played !", font, 20); 
    won.setPosition(5, 70); 
    won.setColor(Color::Green); 

    Text lost("You have failed to\n discover the secret\n number in less than\n 10 tries, better \nluck next time!", font, 20); 
    lost.setPosition(5, 70); 
    lost.setColor(Color::Red); 

    srand(static_cast<unsigned int> (time(NULL))); 

    int secretNumber = rand() % 100; 

    bool isGameOn = true; 
    bool playerWon = false; 
    int tryNumber = 0; 

    while (window.isOpen()) 
    { 
     window.clear(); 
     window.draw(title); 
     if (isGameOn) 
     { 
      window.draw(question); 
      window.draw(enter); 
      window.draw(status); 
     } 
     else 
     { 
      if (playerWon) 
      { 
       window.draw(won); 
      } 
      else 
      { 
       window.draw(lost); 
      } 
     } 

     window.display(); 

     Event event; 
     while (window.pollEvent(event)) 
     { 
      if ((event.type == Event::Closed) || ((event.type == Event::KeyPressed) && (event.key.code == Keyboard::Escape))) 
      { 
       window.close(); 
      } 

      if (event.type == Event::TextEntered) 
      { 
       char c = static_cast<char> (event.text.unicode); 
       if (c >= '0' && c <= '9') 
       { 
        textEntered += event.text.unicode; 
        enter.setString(textEntered); 
       } 
       else if (c == '\r') 
       { 
        tryNumber++; 

        stringstream in(enter.getString()); 
        in >> numEntered; 

        if (numEntered > secretNumber) 
        { 
         out << tryNumber; 
         out << ". "; 
         out << numEntered; 
         out << ": Minus" << endl; 
         status.setString(out.str()); 
        } 
        if (numEntered < secretNumber) 
        { 
         out << tryNumber; 
         out << ". "; 
         out << numEntered; 
         out << ": Plus" << endl; 
         status.setString(out.str()); 
        } 
        if (numEntered == secretNumber) 
        { 
         playerWon = true; 
         status.setString(""); 
         isGameOn = false; 
        } 
        if (tryNumber > 10) 
        { 
         playerWon = false; 
         status.setString(""); 
         isGameOn = false; 
        } 
        textEntered = ""; 
       } 
      } 
     } 
     return EXIT_SUCCESS; 
    } 
} 

我已搜查周圍,​​但我真的沒有找到這個問題的答案,會很感激,如果有人能幫我解決這個問題! :)

問候

FreeSirenety

回答

1

你必須在你的while (window.isOpen()) { ... }循環結束一個return聲明。 所以循環只運行一次。

+1

哦,非常感謝,沒有看到xD – FreeSirenety