Thomas
Thomas

Reputation: 2259

SetPixelFormat returns 0 Errorcode 3221684230 (C0070006)

I try to create an openGL context. If I start it on an Radeon GPU, it works fine... but on every nvidia Card I tested it, it crashes.

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();

The variables are:

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...

All drivers are updated and I am using:

NVIDIA NVS 3100M / not working

NVIDIA gtx 780 / not working

AMD Radeon R7 M370 / is working

Intel(R) HD Graphics 530 / is working

thank you in advance

Thomas

Upvotes: 2

Views: 1082

Answers (1)

krOoze
krOoze

Reputation: 13246

MSDN says the the cColorBits is without alpha (though I have seen 32 often there)...

The SetPixelFormat() fails (with a FALSE). And it goes down from there. Examine the Chosen PixelFormat with DescribePixelFormat, to make sure you got something sane.

You can only set Pixel Format once. Make sure you do. Where do you call all this? Safest place is in WM_CREATE handler, I think.

Try this legendary old thing: Nehe OpenGL Window (there are sources at end). It would sure be odd if even that doesn't work. Or you know: do not try to be too smart and use GLFW or similar.

Upvotes: 2

Related Questions