开发者

How to change a .png output from Python to an OpenGL window output?

I have a Python code whose output is a .png file. What should I do to get the output in an OpenGL window? I searched a few places 开发者_如何转开发and the closest I got to converting an Image was StringIO() but that didn't seem very helpful.


First of all, you need the OpenGL bindings to create an OpenGL window. Try PyOpenGL

The next step is to look at the code. My guess is that some kind of image object is created, then something is drawn onto it and lastly, the image is saved as PNG.

At that point, you need to convert the image data (see the docs for details) into something that PyOpenGL can display. The example at the end of this page should get you started.


If you want something to handle the more complex details you could setup your OpenGL using pygame then use

surface = pygame.image.load(fileobj)

Where fileobj is any object with a 'file-like' interface. You would need to modify the PNG generator to write to this object rather than a real file.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜