|
2008 02 27
|
Screenshot
Some sample code for taking a screenshot in an OpenGL app:
First, let us add a Image method to help:
Image grabScreen := method(
data := Sequence clone
width := glutGet(GLUT_WINDOW_WIDTH)
height := glutGet(GLUT_WINDOW_HEIGHT)
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data)
self setDataWidthHeightComponentCount(data, width, height, 4)
self flipY
)
Now we can use it (within a running GL application):
Image clone grabScreen save("screenshot.jpg")
|