I am looking for a way to capture just a portion of the screen in the game engine. I was using the built-in render.makeScreenshot(path)
, which only captures a full-screen PNG.
I am exploring the following approach but have no idea how to save the list data into an image format. Any help would be appreciated.
from bgl import *
def captureCropped(posX, posY, sizeX, sizeY):
buf = Buffer(GL_BYTE, [sizeX,sizeY,3])
glReadPixels(posX,posY,sizeX,sizeY,GL_RGB,GL_BYTE,buf)
... #now what do I do with buf?