C++ 窗口拒绝渲染
我最近开始尝试使用SFML。由于某种原因,我的简单程序不会渲染窗口。我试着把所有的东西都放到main中,看看我的代码中是否有一个与多个文件有关的错误,但是没有用 我将启动我的程序,但不会显示任何内容 有什么问题吗C++ 窗口拒绝渲染,c++,sfml,C++,Sfml,我最近开始尝试使用SFML。由于某种原因,我的简单程序不会渲染窗口。我试着把所有的东西都放到main中,看看我的代码中是否有一个与多个文件有关的错误,但是没有用 我将启动我的程序,但不会显示任何内容 有什么问题吗 //main.h #ifndef MAIN_H #define MAIN_H #include <SFML/Audio.hpp> #include <SFML/Graphics.hpp> #include <SFML/Window.hpp> #in
//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;
}
//main.h
#ifndef MAIN_H
#定义主
#包括
#包括
#包括
#包括
#包括
#包括
使用名称空间std;
使用名称空间sf;
班级游戏
{
公众:
void startoop(int SCREEN\u W、int SCREEN\u H、string SCREEN\u NAME);
无效日志(常量字符串日志);
游戏()
{
退出=错误;
open(“Log.txt”,ios::out);
pendingFile我尝试了你的代码,它的行为完全符合我的预期-也就是说,弹出一个带有黑色主体的无图标窗口,它不响应事件。这就是你得到的吗?如果不是,你可能需要重建SFML
您可能希望尝试引入事件处理,使您的StartOOP看起来更像这样:
void game::startLoop(int SCREEN_W, int SCREEN_H, string SCREEN_NAME)
{
// Init stuff
while (Game.IsOpened())
{
sf::Event newEvent;
while (Game.GetEvent(newEvent))
{
// Process event
}
// Do graphics stuff
Game.Display();
}
}
1.)感谢关于循环的提示!和2.)我将尝试重新下载SFML。我想我将打开一个新问题,因为我已经将问题归结为一个错误。不过,谢谢。