GLFW "WGL: Failed to find a suitable pixel format"
GLFW "WGL: Failed to find a suitable pixel format"
我正在创建一个游戏引擎,并从简单的openGL窗口创建开始。 我正在使用Visual Studio 2013,并且引擎正在构建为dll。 这是 dll 中初始化 openGL 的代码:
bool AsGraphicsManager::Initialize(AsWindowCreateStruct pWindow)
{
//first create the error handler
glfwSetErrorCallback(error::glfw_error_callback);
//Initialize the library
if (!glfwInit())
return 0;
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
#ifdef _DEBUG
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
#endif /* _DEBUG */
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_SAMPLES, 0);
glfwWindowHint(GLFW_STEREO, GL_TRUE);
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
glfwWindowHint(GLFW_DEPTH_BITS, 16);
mWindow = new AsWindow(pWindow);
//make the first window the current
glfwMakeContextCurrent(mWindow->mWindow);
//make sure to do this to enable new opengl
glewExperimental = GL_TRUE;
//now initialize glew
GLenum res = glewInit();
if (res != GLEW_OK)
{
printf("Error code: %s While Initializing Glew n", glewGetErrorString(res));
return false;
}
//input handler
glfwSetKeyCallback(mWindow->mWindow, input::key_callback);
glfwSetScrollCallback(mWindow->mWindow, input::scroll_callback);
glfwSetMouseButtonCallback(mWindow->mWindow, input::mouse_callback);
glfwSetCursorPosCallback(mWindow->mWindow, input::mouse_position_callback);
//nothing went wrong
return true;
}
AsWindowCreateStruct 是一个结构,定义如下:
struct ASGE_API AsWindowCreateStruct
{
GLushort mHeight;
GLushort mWidth;
GLushort mXPos;
GLushort mYPos;
std::string mWindowTitle;
bool mFullscrean;
AsWindowCreateStruct(GLushort pWindowHeight, GLushort pWindowWidth, GLushort pWindowXPosition, GLushort pWindowYPosition, std::string pWindowTitle, bool pIsFullscrean = false) :
mHeight(pWindowHeight), mWidth(pWindowWidth), mXPos(pWindowXPosition), mYPos(pWindowYPosition), mWindowTitle(pWindowTitle), mFullscrean(pIsFullscrean){}
};
这只充当一些参数以传递到窗口创建中。 mWindow 是 AsWindow 的一个对象。 此类的定义并不重要,但使用的构造函数定义为:
mHeight = pCreateStruct.mHeight;
mWidth = pCreateStruct.mWidth;
mXPos = pCreateStruct.mXPos;
mYPos = pCreateStruct.mYPos;
mWindowTitle = pCreateStruct.mWindowTitle;
mFullscrean = pCreateStruct.mFullscrean;
mWindow = 0;
//now create the window
if (mFullscrean)
{
mWindow = glfwCreateWindow(mHeight, mWidth, mWindowTitle.c_str(), glfwGetPrimaryMonitor(), nullptr);
if (!mWindow)
{
printf("Error initializing Window n");
glfwTerminate();
}
}
else
{
mWindow = glfwCreateWindow(mHeight, mWidth, mWindowTitle.c_str(), nullptr, nullptr);
//this needs to happen before seting window position
if (!mWindow)
{
printf("Error initializing Window n");
glfwTerminate();
}
else
{
//as long as it isn't fullscrean, change the position
glfwSetWindowPos(mWindow, mXPos, mYPos);
}
};
//make the window visible
glfwShowWindow(mWindow);
其中 pCreateStruct 是 AsWindowCreateStruct 的实例。
现在,抛开所有代码不谈,问题是glfwCreateWindow()总是返回0。 我在控制台中收到错误"WGL:找不到合适的像素格式"。 我调试了大约一个小时,并将其追溯到文件中调用的函数 choosePixelFormat wgl_context.c 行 357。 函数定义位于 wgl_context.c 行 144。 这在GLFW 3.0.4中全部完成。 我看过其他类似的文章,它们没有帮助。 我有一台 NVidia GTX 650ti,并且正在使用 Nvidia 的 Geforce 经验来让我的驱动程序保持最新状态。 Windows没有安装它们。 我尝试运行他们在网站上拥有的 GLFW 的简单程序 www.glfw.org 它完美运行。 我很确定这与在 DLL 中运行有关,但我不知道从哪里开始
如果您需要更多信息,我将很高兴。
编辑:
问题是
glfwWindowHint(GL_STEREO, GL_TRUE);
GL_STEREO
不支持输出到多个图形卡。它将交换链中的缓冲区数量增加一倍,以实现立体 3D 渲染(例如,单独的左/右图像)。在某些圈子中,您可能会听到它被称为四边形缓冲。
通常需要Radeon HD 6xxx+消费者GPU或工作站类NV/AMD GPU,以便在Microsoft Windows上的OpenGL中公开功能。在OS X中,您无需昂贵的工作站硬件即可获得它。
据说较新版本的NV驱动程序会在Microsoft Windows的OpenGL中公开此功能。我无法确认这一点,但他们很可能只会为最新的 GPU 启用此功能。否则,为了在Microsoft Windows中的消费级NV卡上获得四边形缓冲,您必须使用D3D。
Doom 3 BFG版可能是NV政策变化的原因,这是第一款使用立体渲染的主要OpenGL游戏。
- Httpfile sendrequest -> format requestbody?
- Clang-Format 不能正确分配函数参数
- "No suitable conversion function from 'std::string' to 'const char *' exists"
- 编译器给出错误:format 指定类型 'float *',但参数的类型'double' [-Wformat]
- 什么 clang-format 相当于 rustfmt 的 indent_style=Block?
- <format> 找不到标头 (C++)
- 函数模板不起作用,出现错误"No suitable user-defined conversion"
- clang-format:IncludeIsMainRegex不起作用
- 如何获得 fmt::format 与wchar_t一起使用?
- 为什么我从 gdbserver 获得"not in executable format: Success",但在 gdb 中一切正常?
- 如何在 C++ 中从 python 做 string.format()
- Clang-Format:重新组合字符串文字
- 特征"Sparse matrix format"示例是否包含错误?
- q致命参数:将 QString 转换为常量字符* 会导致警告"format string is not a string literal"
- 如何将非可变参数值传递给 fmt::format?
- 有没有办法强制对 clang-format/clang-tidy 中的类成员/方法使用 "this->"?
- 告诉Clang-Format忽略布拉格马斯
- 在 CString::Format 中使用 CString 对象
- Microsoft 编辑默认工具栏时的 Visual Studio 'Unknown Bitmap Format'
- GLFW "WGL: Failed to find a suitable pixel format"