我最近开始尝试使用 SFML。由于某种原因,我的简单程序不会呈现窗口。我尝试将所有内容都放入 main 中,以查看我的代码中是否存在与多个文件等有关的错误,但无济于事。
我将启动我的程序,什么都不会出现。
有什么问题?
//main.h
#ifndef MAIN_H
#define MAIN_H
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
#include <iostream>
#include <fstream>
using namespace std;
using namespace sf;
class game
{
    public:
    void startLoop(int SCREEN_W, int SCREEN_H, string SCREEN_NAME);
    void log(const string logging);
    game()
    {
        QUIT = false;
        pendingFile.open("Log.txt", ios::out);
        pendingFile << "---Brain Bread Log---";
    }
    ~game()
    {
        pendingFile.close();
    }
    private:
    bool QUIT;
    ofstream pendingFile;
};
#endif
//main.cpp
#include "main.h"
void game::log(const string logging)
{
    pendingFile << logging;
}
void game::startLoop(int SCREEN_W, int SCREEN_H, string SCREEN_NAME)
{
    Window Game(VideoMode(SCREEN_W, SCREEN_H, 32), SCREEN_NAME);
    while(QUIT == false)
    {
        Game.Display();
    }
}
int main(int argc, char* argv[])
{
    game gameObj;
    gameObj.startLoop(800, 600, "Brain Bread");
    return 0;
}