1

Accidentally I put a NULL parameter in wglGetPbufferDCARB.

It was something like:

HDC hDC = wglGetPbufferDCARB(NULL);

Unexpectedly this code returned a real hDC! But I did not find anything about it.

Does anyone know where this hDC comes from?

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
Mano-Wii
  • 592
  • 5
  • 19
  • "*this code returned a real hDC*" - I doubt that, since the documentation clearly states that `wglGetPbufferDCARB()` expects a handle returned by `wglCreatePbufferARB()`, and it will fail with an `ERROR_INVALID_HANDLE` error if you pass in an invalid buffer handle. – Remy Lebeau Feb 12 '18 at 07:49
  • But i tested it and it works like a real hdc. (it was possible to create a gl rendering context with it) – Mano-Wii Feb 12 '18 at 13:14
  • There are a number of windows api calls that have documented valid parameters but do not error when passed invalid parameters. Sometimes there is extra functionality behind the parameters that the windows developers might need, but don't want to commit to maintaining. So its best to file the valid DC under "undefined behaviour" and just not make use of it because until this behaviour is documented, it could change in the next version or perhaps even security patch. – Chris Becke Feb 12 '18 at 13:54
  • @Chris Becke, IC. So it can be a feature expected in future releases, but it is now kept hidden! (So better not to use it as it can change) – Mano-Wii Feb 12 '18 at 15:17
  • @Mano-Wii I doubt that PBuffer is ever going to be updated. It has long been superseded by OS-independent framebuffer objects, [see here](https://www.khronos.org/opengl/wiki/Framebuffer_Object). – hidefromkgb Feb 12 '18 at 15:19
  • @hidefromkgb, I even wanted to avoid having to use Pbuffers, but I need to create a DC that supports OpenGL over 1.1. (Another option would be to create a hidden window) – Mano-Wii Feb 12 '18 at 16:23
  • @Mano-Wii can you please state the initial task in the question? Most probably there is a solution that doesn\`t involve PBuffer. – hidefromkgb Feb 12 '18 at 16:25

0 Answers0