开发者

How to PyOpengl or pyglet to draw on top of desktop?

I'm writing an application that is looking to draw basic polygons and ellipses on the Windows 7 desktop using OpenGL. According to this 开发者_StackOverflowprevious question, this is possibly by getting the window handle to the desktop, which I know how to do. Draw OpenGL on the windows desktop without a window

However, I've got two questions:

  1. Where do you actually tell OpenGL what window to draw to? I've been looking through nehe example 1, and I simply can't figure out where exactly it's passing openGL the hwnd. Do I give openGL a window handle or a device context?

  2. Is it possible to do this using PyOpenGL or Pyglet? Or would I have to write it in C, then wrap the code in ctypes?


Trying to do OpenGL on another process' window is a really, really bad idea! For OpenGL to work it needs to set the window's pixel format. However the pixel format of a window can be set only once, so doing this on a foreign window is a recipe for disaster.

The proper way to do this, but it's slow like nothing else is to use a PBuffer, which has it's own off screen HDC, render to this PBuffer and BitBlt from the PBuffer to the target window. I've never implemented this myself though, so I can't tell you how well this works first hand. But it sounds like an interesting thing to try, so maybe I'm doing that next time I boot Windows on my machine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜