All Projects → Xrysnow → cocos2d-x-imgui

Xrysnow / cocos2d-x-imgui

Licence: MIT license
ImGui for cocos2d-x, with lua binding

Programming Languages

C++
36643 projects - #6 most used programming language
lua
6591 projects

Projects that are alternatives of or similar to cocos2d-x-imgui

Simplerenderengine
Small C++14 render engine
Stars: ✭ 253 (+954.17%)
Mutual labels:  imgui
OverEngine
Tiny little game engine
Stars: ✭ 175 (+629.17%)
Mutual labels:  imgui
imgui
ImGui bindings for Nim via cimgui
Stars: ✭ 117 (+387.5%)
Mutual labels:  imgui
koi
Immediate mode UI for Nim
Stars: ✭ 27 (+12.5%)
Mutual labels:  imgui
FishGUI
FIshGUI is a immediate mode GUI(IMGUI) library, based on NanoVG.
Stars: ✭ 76 (+216.67%)
Mutual labels:  imgui
PrimeXT
Modern SDK for Xash3D FWGS engine, uses PhysX for physics, has advanced OpenGL renderer with a lot of features. Crossplatform, supported Windows/Linux. Based on XashXT and Spirit Of Half-Life.
Stars: ✭ 65 (+170.83%)
Mutual labels:  imgui
Nimgl
NimGL is a Nim library that offers bindings for popular libraries used in computer graphics
Stars: ✭ 218 (+808.33%)
Mutual labels:  imgui
bawr
SVG/Font Icon processing tool for C++
Stars: ✭ 66 (+175%)
Mutual labels:  imgui
kiwi-8
CHIP-8 interpreter for Windows and MacOS
Stars: ✭ 16 (-33.33%)
Mutual labels:  imgui
psobbaddonplugin
Phantasy Star Online Blue Burst Addon Plugin
Stars: ✭ 17 (-29.17%)
Mutual labels:  imgui
roswasm suite
Libraries for compiling C++ ROS nodes to Webassembly using Emscripten
Stars: ✭ 62 (+158.33%)
Mutual labels:  imgui
rapp
Cross-platform entry point library
Stars: ✭ 57 (+137.5%)
Mutual labels:  imgui
godot-action-animation-framework
create animation easy in Godot with GDAction
Stars: ✭ 43 (+79.17%)
Mutual labels:  cocos2d-x
khm.imgui
Imgui core for Kha
Stars: ✭ 16 (-33.33%)
Mutual labels:  imgui
UEImgui
Use imgui in unreal for customize editor
Stars: ✭ 75 (+212.5%)
Mutual labels:  imgui
Imgui Filebrowser
File browser implementation for dear-imgui. C++17 is required.
Stars: ✭ 231 (+862.5%)
Mutual labels:  imgui
odin-imgui
Odin binding for Dear ImGui
Stars: ✭ 37 (+54.17%)
Mutual labels:  imgui
vigilante
🦇 2D pixel-art side-scrolling single-player ARPG
Stars: ✭ 63 (+162.5%)
Mutual labels:  cocos2d-x
luban
你的最佳游戏配置解决方案 {excel, csv, xls, xlsx, json, bson, xml, yaml, lua, unity scriptableobject} => {json, bson, xml, lua, yaml, protobuf(pb), msgpack, flatbuffers, erlang, custom template} data + {c++, java, c#, go(golang), lua, javascript(js), typescript(ts), erlang, rust, gdscript, protobuf schema, flatbuffers schema, custom template} code。
Stars: ✭ 1,660 (+6816.67%)
Mutual labels:  cocos2d-x
ogre-imgui
Now in the main repository as part of Overlay
Stars: ✭ 30 (+25%)
Mutual labels:  imgui

cocos2d-x-imgui

This project is ImGui binding for cocos2d-x, with most things bind to lua.

Currently it works with cocos2d-x 4.0 and ImGui docking branch. Branch v3 can work with cocos2d-x 3.x, but will not be maintained.

How to use

  • Include headers.
#include "CCImGuiLayer.h"
  • Add ImGui layer (usually on top).
std::string layerName = "ImGUILayer";
auto order = INT_MAX;
auto layer = ImGuiLayer::create();
Director::getInstance()->getRunningScene()->addChild(layer, order, layerName);
  • Keep the layer when scene changes.
auto e = Director::getInstance()->getEventDispatcher();
auto detached = false;
e->addCustomEventListener(Director::EVENT_BEFORE_SET_NEXT_SCENE, [&](EventCustom*){
	layer = dynamic_cast<ImGuiLayer*>(Director::getInstance()->getRunningScene()->getChildByName(layerName));
	if (layer) {
		layer->retain();
		layer->removeFromParent();
		detached = true;
	}
});
e->addCustomEventListener(Director::EVENT_AFTER_SET_NEXT_SCENE, [&](EventCustom*){
	if (layer && detached) {
		Director::getInstance()->getRunningScene()->addChild(layer, order, layerName);
		layer->release();
		detached = false;
	}
});
  • Use ImGui.
// enable docking
auto& io = ImGui::GetIO();
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
auto sp = Sprite::create("filename.png");
layer->addChild(sp);
// add ui callbacks
CCIMGUI::getInstance()->addCallback([=](){
	ImGui::Text("Hello, world!");
	// create button with Sprite, auto pushID / popID with texture id
	CCIMGUI::getInstance()->imageButton(sp, ImVec2(0, 0));
}, "hello");
// remove ui callbacks to stop rendering
CCIMGUI::getInstance()->removeCallback("hello");
// add chinese font
io.Fonts->AddFontFromFileTTF("path/to/font.ttf", 16.0f, 0, io.Fonts->GetGlyphRangesChineseFull());
  • Enable lua binding.
#include "lua-bindings/imgui_lua.hpp"
auto L = LuaEngine::getInstance()->getLuaStack()->getLuaState();
luaopen_imgui(L);
  • Use in lua. Note that all functions are start with a lower letter. The lua_doc folder contains docs for lua, just include it to your lua IDE (docs are in EmmyLua format). The lua_src folder contains helpers and wrappers for lua development.
    • Without helper
     local ret, buf, float = nil, '', 0
     imgui.draw = function()
     	-- new window
     	if imgui.begin("Window From Lua") then
     		-- text
     		imgui.text("Hello, World!")
     		-- text button
     		imgui.button("text button")
     		-- input text
     		ret, buf = imgui.inputText("input", buf)
     		-- slider
     		ret, float = imgui.sliderFloat("float", float, 0, 8)
     		-- end window
     		imgui.endToLua()
     	end
     end
     -- check error somewhere
     if imgui.error then
     	error(imgui.error)
     end
    • With helper
     require('imgui.__init__')
     local wi = require('imgui.Widget')
     local im = imgui
     local la = im.on()
     local sp = cc.Sprite:create('filename.png'):setVisible(false)
     la:addChild(sp) -- retain sprite
     local flags = im.WindowFlags.HorizontalScrollbar
     local content = wi.Widget(function()
     	imgui.text("Hello, World!")
     	im.image(sp)
     end)
     la:addChild(wi.Window('Window From Lua', nil, flags)
     	:addChild(content)
     	:addChild(wi.TreeNode('Tree')
     		:addChild(wi.Text('text', cc.c3b(255, 0, 0), 'bullet'))
     		:addChild(im.sameLine)
     		:addChild(wi.Button('button'))
     		:addChild(im.separator)
     		:addChild(wi.Checkbox('checkbox'))
     	)
     )

Thanks

Thanks to all previous works:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].