diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/JobServer.gd b/JobServer.gd new file mode 100644 index 0000000..7b56304 --- /dev/null +++ b/JobServer.gd @@ -0,0 +1,29 @@ +extends HTTPRequest + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + +func GetJob(): + request_completed.connect(_on_request_completed) + request("https://raw.githubusercontent.com/JanGross/job-server/master/jobDefinition.json") + await request_completed + +func _on_request_completed(result, response_code, headers, body): + var json = JSON.parse_string(body.get_string_from_utf8()) + for comp in json["composition"]: + var type = comp["type"] + if type == "text": + var textNode = Label.new() + textNode.text = comp["text"] + var pos = Vector2(float(comp["x"]), float(comp["y"])) + print("Rendering label at %s" % pos) + textNode.set_position(pos) + textNode.set_size(Vector2(float(comp["width"]), float(comp["height"]))) + get_tree().get_root().add_child(textNode) diff --git a/_e2199ab5-ff42-4ddf-8540-1c16e2d7889f.jpeg b/_e2199ab5-ff42-4ddf-8540-1c16e2d7889f.jpeg new file mode 100644 index 0000000..7d915bf Binary files /dev/null and b/_e2199ab5-ff42-4ddf-8540-1c16e2d7889f.jpeg differ diff --git a/_e2199ab5-ff42-4ddf-8540-1c16e2d7889f.jpeg.import b/_e2199ab5-ff42-4ddf-8540-1c16e2d7889f.jpeg.import new file mode 100644 index 0000000..2da45c3 --- /dev/null +++ b/_e2199ab5-ff42-4ddf-8540-1c16e2d7889f.jpeg.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://skthvfx7pq6m" +path="res://.godot/imported/_e2199ab5-ff42-4ddf-8540-1c16e2d7889f.jpeg-fc56a492e359e0a38ad286972df2992f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://_e2199ab5-ff42-4ddf-8540-1c16e2d7889f.jpeg" +dest_files=["res://.godot/imported/_e2199ab5-ff42-4ddf-8540-1c16e2d7889f.jpeg-fc56a492e359e0a38ad286972df2992f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..adc26df --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + diff --git a/icon.svg.import b/icon.svg.import new file mode 100644 index 0000000..5d251c9 --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bwf4bqfk3gtax" +path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/node_2d.tscn b/node_2d.tscn new file mode 100644 index 0000000..6c1c131 --- /dev/null +++ b/node_2d.tscn @@ -0,0 +1,44 @@ +[gd_scene load_steps=5 format=3 uid="uid://dnfydq6205nno"] + +[ext_resource type="Script" path="res://render.gd" id="1_13t8u"] +[ext_resource type="Texture2D" uid="uid://skthvfx7pq6m" path="res://_e2199ab5-ff42-4ddf-8540-1c16e2d7889f.jpeg" id="1_la77t"] +[ext_resource type="Script" path="res://JobServer.gd" id="3_mg2dt"] + +[sub_resource type="LabelSettings" id="LabelSettings_d06ag"] +font_size = 90 +font_color = Color(1, 0, 1, 1) +outline_size = 10 +outline_color = Color(0, 0, 0, 1) +shadow_size = 35 +shadow_color = Color(0, 0, 0, 0.337255) + +[node name="Node2D" type="Node2D"] +script = ExtResource("1_13t8u") + +[node name="Placeholder" type="Sprite2D" parent="."] +position = Vector2(550, 322) +scale = Vector2(0.381836, 0.381836) +texture = ExtResource("1_la77t") + +[node name="Label" type="Label" parent="Placeholder"] +offset_left = -513.309 +offset_top = 209.514 +offset_right = 510.691 +offset_bottom = 499.514 +text = "Test Render" +label_settings = SubResource("LabelSettings_d06ag") +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="tstamp" type="Label" parent="Placeholder"] +offset_left = -505.453 +offset_top = 515.928 +offset_right = 518.547 +offset_bottom = 805.928 +text = "%s" +label_settings = SubResource("LabelSettings_d06ag") +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="JobServerNode" type="HTTPRequest" parent="."] +script = ExtResource("3_mg2dt") diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..c9f94b1 --- /dev/null +++ b/project.godot @@ -0,0 +1,21 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="render-node" +run/main_scene="res://node_2d.tscn" +config/features=PackedStringArray("4.0", "GL Compatibility") +config/icon="res://icon.svg" + +[rendering] + +renderer/rendering_method="gl_compatibility" +renderer/rendering_method.mobile="gl_compatibility" diff --git a/render.gd b/render.gd new file mode 100644 index 0000000..62b1dae --- /dev/null +++ b/render.gd @@ -0,0 +1,30 @@ +extends Node2D + +var counter = 1 +# Called when the node enters the scene tree for the first time. +func _ready(): + pass + await $JobServerNode.GetJob() + await render() + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + +func run_test(): + if counter == 50: + get_tree().quit() + render() + counter += 1 + +func render(): + print("Rendering frame %s" % counter) + var tstamp_label = $Placeholder/tstamp + var tstamp = Time.get_ticks_usec() + tstamp_label.text = str(tstamp) + "\n %s" % counter + await RenderingServer.frame_post_draw + + # Retrieve the captured image. + var img = get_viewport().get_texture().get_image() + + img.save_png("output/test%s.png" % counter)