55from demosys .conf import settings
66
77
8- def create (format = 'png' ):
8+ def create (window , format = 'png' ):
99 """
1010 Create a screenshot
1111 :param format: formats supported by PIL (png, jpeg etc)
@@ -20,11 +20,15 @@ def create(format='png'):
2020 else :
2121 print ("SCREENSHOT_PATH {} does not exist. Using cwd as fallback" .format (settings .SCREENSHOT_PATH ))
2222
23- x , y , width , height = GL .glGetIntegerv (GL .GL_VIEWPORT )
23+ # x, y, width, height = GL.glGetIntegerv(GL.GL_VIEWPORT)
24+ # print("Screenshot viewport:", x, y, width, height)
25+ # FIXME: Snap to viewport
26+ print ("Screenshot viewport:" , window .buffer_width , window .buffer_height )
2427 GL .glPixelStorei (GL .GL_PACK_ALIGNMENT , 1 )
25- data = GL .glReadPixels (x , y , width , height , GL .GL_RGB , GL .GL_UNSIGNED_BYTE )
2628
27- image = Image .frombytes ("RGB" , (width , height ), data )
29+ data = GL .glReadPixels (0 , 0 , window .buffer_width , window .buffer_height , GL .GL_RGB , GL .GL_UNSIGNED_BYTE )
30+
31+ image = Image .frombytes ("RGB" , (window .buffer_width , window .buffer_height ), data )
2832 image = image .transpose (Image .FLIP_TOP_BOTTOM )
2933 name = "{}.{}" .format (datetime .now ().strftime ("%Y-%m-%d-%H-%M-%S" ), format )
3034 image .save (os .path .join (dest , name ), format = format )
0 commit comments