【发布时间】: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;
}
【问题讨论】: