Windowless OpenGL

后端 未结 5 1320
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-23 20:34

I would like to have a windowless OpenGL context (on both GNU/linux with Xorg and Windows). I\'m not going to render anything but only call functions like glGetString<

5条回答
  •  离开以前
    2020-12-23 21:14

    One of the things I have done - which is admittedly a bit of a hack - to avoid the overhead of creating my own GL window - is to leverage open process windows.

    The key to understanding OpenGL is this: All you needs to create a GL context with the call to wglCreateContext is a valid DC.

    There's NOTHING in the documentation which says it has to be one you own.

    For testing this out, I popped up Worlds Of Warcraft, and leveraging SPY++ to obtain a window handle, I then manually plugged that handle into a call to GetDC, which returns a valid Device Context, and from there, I ran the rest of my GL code like normal.

    No GL window creation of my own.

    Here's what happened when I did this with both Worlds of Warcraft and Star Trek Online https://universalbri.wordpress.com/2015/06/05/experiment-results

    So to answer your question, YES you do need a window, but there's nothing in the documentation which states that window needs to be owned by you.

    Now be advised: I couldn't get this method to provide valid visual output using the desktop window, but I was able to successfully create a DC using getDeskTopWindow API for the HWND and then a call to GetDC. So if there's non visual processing you want to use OpenGL for - let me know what you're doing, i am curious, and if you DO happen to get the GetDesktopWindow method working with the visuals - PLEASE repost on this thread what you did.

    Good luck.

    And don't let anyone tell you it can't be done.

    When there's a will there's a way.

提交回复
热议问题