Skip to content

Commit

Permalink
update gdext example
Browse files Browse the repository at this point in the history
  • Loading branch information
pkdawson committed Apr 25, 2024
1 parent 0ca734b commit 695bd3a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doc/examples/GDExt/project/icon.svg.import
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
Expand All @@ -32,6 +32,6 @@ process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
svg/scale=4.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
4 changes: 4 additions & 0 deletions doc/examples/GDExt/project/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ config/icon="res://icon.svg"

ImGuiRoot="*res://addons/imgui-godot/data/ImGuiRoot.tscn"

[display]

window/subwindows/embed_subwindows=false

[editor_plugins]

enabled=PackedStringArray("res://addons/imgui-godot/plugin.cfg")
4 changes: 4 additions & 0 deletions doc/examples/GDExt/src/example.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "example.h"
#include <godot_cpp/classes/resource_loader.hpp>
#include <imgui-godot.h>

using namespace godot;
Expand All @@ -18,6 +19,7 @@ Example::~Example()
void Example::_ready()
{
ImGui::Godot::SyncImGuiPtrs();
_img = ResourceLoader::get_singleton()->load("res://icon.svg");
}

void Example::_process(double delta)
Expand All @@ -33,5 +35,7 @@ void Example::_process(double delta)
ImGui::Begin("GDExtension Example");
ImGui::DragInt("x", &x);
ImGui::Text("x = %d", x);
ImGui::Separator();
ImGui::Image(_img, {64, 64});
ImGui::End();
}
4 changes: 4 additions & 0 deletions doc/examples/GDExt/src/example.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include <godot_cpp/classes/node.hpp>
#include <godot_cpp/classes/texture2d.hpp>

using namespace godot;

Expand All @@ -16,4 +17,7 @@ class Example : public Node

void _ready() override;
void _process(double delta) override;

private:
Ref<Texture2D> _img;
};

0 comments on commit 695bd3a

Please sign in to comment.