WinGdi SetPixelFormat failure and returns 0xFFFFFFFF


i am trying to attach window to opengl (wglCreateContext) but before doing it, i need to set a pixel format for it. ChoosePixelFormat succeeds but SetPixelFormat returns always 0xFFFFFFFF (-1). Calling GetLastError returns 0 (success) so i am confused about what is wrong. MSDN says that SetPixelFormat should return only 0 or 1 (not -1). Im doing it in asm but here is pseudo c code:

hdc = GetDC(CreateWindowExA(0, "edit", 0, WS_POPUP | WS_MAXIMIZE | WS_VISIBLE, 0, 0, 0, 0, 0, 0, 0, 0)); //window is successfully created
SetPixelFormat(hdc, ChoosePixelFormat(hdc, ppfd), ppfd); //ChoosePixelFormat returns 7
//returned value is -1
//GetLastError returns 0
wglMakeCurrent(hdc, wglCreateContext(hdc)); //both fails and GetLastError = 0x7D0 (The pixel format is invalid)

its based on reverse engineering so the pixel format descriptor is in bytes, sorry:

db 0x28,0x00,0x01,0x00,0x25,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00

Thank you for any help

--EDIT: The pixel format descriptor rewrited to c:

::memset(ppfd, 0x0, 0x28);
ppfd->nSize = 0x28;
ppfd->nVersion = 1;
ppfd->iPixelType = 0x0;
ppfd->cColorBits = 32;
ppfd->cDepthBits = 16;
asked on Stack Overflow Nov 1, 2019 by Segy • edited Nov 1, 2019 by Segy

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0