简体   繁体   English

加载纹理SFML导致程序崩溃

[英]Loading texture SFML causes program to crash

I'm trying to load an sf::Texture, but every time I run the program, my computer starts beeping (no joke), and the command prompt outputs a bunch of characters that look like ancient Egyptian hieroglyphics. 我正在尝试加载sf :: Texture,但是每次运行该程序时,我的计算机都会开始发出哔哔声(没有笑话),并且命令提示符下会输出一堆看起来像古埃及象形文字的字符。 Relevant code: 相关代码:

#pragma once

#include "SFML/Graphics.hpp"

class TextureLoader {
public:
    sf::Texture runway;

    ~TextureLoader(){}

    TextureLoader() {
        runway.loadFromFile("Runway.png");
    }
};

Runway.png does exist, because I've tested creating an ifstream and it loads the image fine. Runway.png确实存在,因为我已经测试过创建ifstream并可以很好地加载图像。

The debugger complains of an "Access violation reading location", but the location changes each time and I've never been able to find the memory space it points to in the debugger. 调试器抱怨“访问冲突读取位置”,但是该位置每次都会更改,而我却从未在调试器中找到它指向的内存空间。 Every object appears to be fine except for the texture. 除纹理外,每个对象看起来都很好。

You are mixing debug/release version of SFML libraries with your program's debug/release version. 您正在将SFML库的调试/发布版本与程序的调试/发布版本混合在一起。 If your program is debug, use debug libraries of SFML, if your program is in release version, use release version of SFML. 如果您的程序是调试的,请使用SFML的调试库;如果您的程序是发行版,请使用SFML的发行版。

People who are still figuring out how to set the project settings, please do as follows (note the "-d" for debug): 仍在弄清楚如何设置项目设置的人,请执行以下操作(请注意“ -d”进行调试):

调试设置

发布设定 x86对于x32

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM