diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-04-12 18:58:05 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-04-12 18:58:05 -0300 |
commit | f9906eeac8d97e9b495ce7dae24d6820313d4291 (patch) | |
tree | f2227fbddc6ccf9c1cc43f2741265a34107c30b8 /demos/viewport/screen_capture | |
parent | 3e20391bf607dc7c452b056854aed4a8c99ba0f6 (diff) |
-Fixed screen capture for viewports, added a screen capture demo, fixes #1529
Diffstat (limited to 'demos/viewport/screen_capture')
-rw-r--r-- | demos/viewport/screen_capture/engine.cfg | 8 | ||||
-rw-r--r-- | demos/viewport/screen_capture/mountains.png | bin | 0 -> 927435 bytes | |||
-rw-r--r-- | demos/viewport/screen_capture/screen_capture.gd | 27 | ||||
-rw-r--r-- | demos/viewport/screen_capture/screen_capture.scn | bin | 0 -> 1977 bytes |
4 files changed, 35 insertions, 0 deletions
diff --git a/demos/viewport/screen_capture/engine.cfg b/demos/viewport/screen_capture/engine.cfg new file mode 100644 index 0000000000..b25ed8258e --- /dev/null +++ b/demos/viewport/screen_capture/engine.cfg @@ -0,0 +1,8 @@ +[application] + +name="Screen Capturing" +main_scene="res://screen_capture.scn" + +[display] + +stretch_mode="2d" diff --git a/demos/viewport/screen_capture/mountains.png b/demos/viewport/screen_capture/mountains.png Binary files differnew file mode 100644 index 0000000000..b8435bb1a8 --- /dev/null +++ b/demos/viewport/screen_capture/mountains.png diff --git a/demos/viewport/screen_capture/screen_capture.gd b/demos/viewport/screen_capture/screen_capture.gd new file mode 100644 index 0000000000..69f16fa498 --- /dev/null +++ b/demos/viewport/screen_capture/screen_capture.gd @@ -0,0 +1,27 @@ + +extends Control + +# member variables here, example: +# var a=2 +# var b="textvar" + +func _ready(): + # Initialization here + pass + + + + +func _on_button_pressed(): + get_viewport().queue_screen_capture() + #let two frames pass to make sure the screen was aptured + yield(get_tree(),"idle_frame") + yield(get_tree(),"idle_frame") + #retrieve the captured image + var img = get_viewport().get_screen_capture() + #create a texture for it + var tex = ImageTexture.new() + tex.create_from_image(img) + #set it to the capture node + get_node("capture").set_texture(tex) + pass # replace with function body diff --git a/demos/viewport/screen_capture/screen_capture.scn b/demos/viewport/screen_capture/screen_capture.scn Binary files differnew file mode 100644 index 0000000000..d204e3b67e --- /dev/null +++ b/demos/viewport/screen_capture/screen_capture.scn |