I have a draw function inspired from this answer:
def draw():
print(gpu.state.viewport_get())
framebuffer = gpu.state.active_framebuffer_get()
viewport_info = gpu.state.viewport_get()
width = viewport_info[2]
height = viewport_info[3]
framebuffer_image.scale(width, height)
pixelBuffer = framebuffer.read_color(0, 0, width, height, 4, 0, 'FLOAT')
pixelBuffer.dimensions = width * height * 4
framebuffer_image.pixels.foreach_set(pixelBuffer)
and I'm trying to force redraw it once
_handle_3d = bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'PRE_VIEW')
#some code here to force invoke
bpy.types.SpaceView3D.draw_handler_remove(_handle_3d, 'WINDOW')
The reason I'm doing this is because when I use draw_handler_add it gives:
but when I directly use draw() it gives the entire window:


bpy.ops.wm.redraw_timerinvokes the function while the script is being executed? Is there any work around that? – cak3_lover Sep 19 '22 at 21:10