【问题标题】:SFML Only Works in Debug ModeSFML 仅在调试模式下工作
【发布时间】:2013-07-21 11:45:51
【问题描述】:

我正在尝试在 Visual Studio 2012 中运行这个简单的 SFML C++ 程序。它在调试模式下运行良好,但只要我使用非调试库和 DLL,程序就会在第一行引发访问冲突异常的代码。如果我删除分配(以及分配的依赖项),然后运行 ​​'sf::VideoMode::getFullscreenModes();'它工作正常。

我有动态链接库。

#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>
#include <iostream>

int main(int argCount, char** argVector) {
    std::vector<sf::VideoMode> vm = sf::VideoMode::getFullscreenModes(); // Access Violation in Non-Debug Mode

    sf::VideoMode videoMode;
    for(unsigned i = 0; i < vm.size(); i++) {
        if(vm[i].isValid()) {
            videoMode = vm[i];
            break;
        }
        std::cout << "Invalid VideoMode: " << i << std::endl;
    }
    sf::Window window(videoMode, "SFML OpenGL", sf::Style::Fullscreen);
    glClearDepth(0.5F);
    glOrtho(0, 1, 0, 1, 0, 1);
    std::cout << glGetError();
    glColor3f(0, 1, 0);
    {
        glBegin(GL_QUADS);
        glVertex3i(0, 0, 0);
        glVertex3i(0, 1, 0);
        glVertex3i(1, 1, 0);
        glVertex3i(1, 0, 0);
        glEnd();
    }

    window.display();
    while(window.isOpen()) {}
    return 0;
}

【问题讨论】:

    标签: c++ window sfml


    【解决方案1】:

    简短回答:您不能混合调试/发布二进制文件。

    引用 Visual Studio 的官方 SFML 教程:

    链接到与配置匹配的库很重要:“sfml-xxx-d.lib”用于调试,“sfml-xxx.lib”用于发布。混合不当可能会导致崩溃。

    它是红色的here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多