打开SFML窗口会导致内存读取错误 [英] Opening SFML window gives memory read error

查看:170
本文介绍了打开SFML窗口会导致内存读取错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图打开一个SFML窗口,但每次启动它说访问冲突读取位置:0xCCCCCCC0。错误发生在init()方法中。相关代码:

I'm trying to open a SFML window, but every time it is launched it says "Access violation reading location: 0xCCCCCCC0." The error is occuring in the init() method. Relevant code:

class AirportGame {
private:
    sf::RenderWindow window;
public:
    void init();
    int run();

/

void AirportGame::init() {
    window.create(sf::VideoMode(800, 600), "SFML window");
}

int AirportGame::run() {
    init();

    while (window.isOpen()) {
        sf::Event event;

        while (window.pollEvent(event)) {
            if (event.type == sf::Event::Closed) {
                window.close();
            }
        }
    }

    return 0;
}

int main() {
    AirportGame* app = new AirportGame();
    return app->run();
}

它发生在init之后的某个时刻,因为实际的窗口是打开的。在调试器中没有提到0xCCCCCC0。

It happens sometime after init, because the actual window is open. There is no mention in the debugger of 0xCCCCCC0.

推荐答案

修复了它!

在C ++预处理器下,我将定义设置为SFML_STATIC,而不是SFML_DYNAMIC

Turns out under the C++ pre-processor I set the definition to SFML_STATIC instead of SFML_DYNAMIC

这篇关于打开SFML窗口会导致内存读取错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆