我尝试创建一个 openGL 上下文。 如果我在 Radeon GPU 上启动它,它工作正常......但在我测试过的每张 nvidia 卡上,它都会崩溃。
m_hWindowHandleToDevice = GetDC(hWnd);
m_PixelFormat = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, //Flags
PFD_TYPE_RGBA, //The kind of framebuffer. RGBA or palette.
32, //Colordepth of the framebuffer.
0, 0, 0, 0, 0, 0,
0,
0,
0,
0, 0, 0, 0,
24, //Number of bits for the depthbuffer
8, //Number of bits for the stencilbuffer
0, //Number of Aux buffers in the framebuffer.
PFD_MAIN_PLANE,
0,
0, 0, 0
};
int PixelFormatHandle = ChoosePixelFormat(m_hWindowHandleToDevice, &m_PixelFormat);
BOOL bPixelFormatOK = SetPixelFormat(m_hWindowHandleToDevice, PixelFormatHandle, &m_PixelFormat);
DWORD nLastError = GetLastError();
m_hOpenGLContext = wglCreateContext(m_hWindowHandleToDevice);
nLastError = GetLastError();
变量是:
PixelFormatHandle = 9 bPixelFormatOK = 0 nLastError (first time) = 3221684230 nLastError (at the end) = 2000 //ERROR_INVALID_PIXEL_FORMAT m_hOpenGLContext = 0 m_hWindowHandleToDevice = 670115fb //so it is set...
所有驱动程序均已更新,我正在使用:
NVIDIA NVS 3100M / not working NVIDIA gtx 780 / not working AMD Radeon R7 M370 / is working Intel(R) HD Graphics 530 / is working
提前谢谢
托马斯
最佳答案
MSDN 说 cColorBits
没有 alpha(尽管我经常在那里看到 32)...
SetPixelFormat()
失败(返回 FALSE)。它从那里开始下降。使用 DescribePixelFormat
检查Chosen
PixelFormat
,以确保您得到了合理的结果。
您只能设置像素格式
一次。确保你这样做。
你把这一切称为哪里?我认为最安全的地方是 WM_CREATE 处理程序。
试试这个传说中的老东西:Nehe OpenGL Window (最后有来源)。 如果连这个都不起作用,那就太奇怪了。或者你知道:不要试图变得太聪明并使用 GLFW 或类似的东西。
关于c++ - SetPixelFormat 返回 0 错误代码 3221684230 (C0070006),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36794641/