Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chaosddp/imgui-gdscript
Use imgui in gdscript with GDNative binding.
https://github.com/chaosddp/imgui-gdscript
Last synced: about 2 months ago
JSON representation
Use imgui in gdscript with GDNative binding.
- Host: GitHub
- URL: https://github.com/chaosddp/imgui-gdscript
- Owner: chaosddp
- License: mit
- Created: 2020-12-24T11:01:43.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-27T07:25:59.000Z (about 4 years ago)
- Last Synced: 2024-10-26T10:19:07.450Z (4 months ago)
- Language: C++
- Size: 1.36 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Use imgui in gdscript with GDNative binding for Godot 3.2.x.
## How to build
1. Before building, make sure the sub-modules are ready.
```bash
git submodule update --init --recursive
```2. Build godot-cpp:
```bash
scons platform="platform" generate_bindings=yes bits=64 target=release -j"cpu core"
```3. Build imgui-gdscript
```bash
scons platform="platform" target=release
```## How to use
The libary will output into dist folder, copy all dist/bin to your project root.
```gdscript
extends Node2D
# image we will show later
export var image1: Texture
# id we use to identify an images added to imgui, we use this to show images
var image1_id: int
var imgui: ImGui# helper class that wrap raw imgui instance that provide convenient way to construct widgets (with default parameters)
var helper: ImGuiHelpervar show_demo_window:= false
func _ready():
imgui = ImGui.new()# DO add as a child
add_child(imgui)
# helper
helper = ImGuiHelper.new(imgui)if image1:
# add to imgui
image1_id = helper.add_image(image1)func _process(_delta):
# set style to light, default is dark
helper.style_color(helper.StyleColor.LIGHT)helper.new_frame()
# NOTE:
# not sure why we have to create a window before showing demo window, or it will crash
helper.begin("Hello")
if image1:
if helper.button("toggle demo window"):
show_demo_window = !show_demo_window
# use helper to provide default parameters
helper.image(image1_id, image1.get_size())
helper.end()
if show_demo_window:
helper.show_demo_window()
imgui.render()
```NOTE:
Only tested on Windows.