SetPixelFormat 返回 0 错误代码 3221684230 (C0070006)

SetPixelFormat returns 0 Errorcode 3221684230 (C0070006)

本文关键字:C0070006 3221684230 错误代码 返回 SetPixelFormat      更新时间:2023-10-16

我尝试创建一个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,以确保你得到了一些理智的东西。

您只能设置一次Pixel Format。确保你这样做。你在哪里称呼这一切?我认为最安全的地方是WM_CREATE处理程序。

试试这个传奇的老东西:Nehe OpenGL Window(最后有源代码)。如果连这样都行不通,那肯定会很奇怪。或者你知道:不要试图太聪明并使用GLFW或类似的东西。