Coder Social home page Coder Social logo

bsfimgui's Introduction

Bsf Dear-Imgui Plugin

A submodule plugin of the bsf library. It's meant to be built as a cmake dependency of bsf. It is meant for fast prototyping of editor features and gamedev tools. It is not meant to be used as an in-game UI or as a replacement for the bsf gui library. While imgui has low overhead and a simple api, it's not meant for more complex guis. Need to have a custom scene editor? Yes use imgui. Need to render out a 3d interface for your spaceship cockpit? Don't use imgui. More thoughts can be found on this gist.

Features

  • Implements dear-imgui library for fast dev prototyping
  • Integrates with ImGuizmo library for 3d gizmo editing of bsf scene objects.
  • Renders on core thread while the imgui interface can be built on the simulation thread

bsfImguiScreenshot

Usage

Usage is simple, just select the plugin as part of the bsf cmake options. The plugin can be manually loaded as a dynamic plugin.

DynLib* imguiPlugin = nullptr;
Application::instance().loadPlugin("bsfImgui", &imguiPlugin);
Application::instance().runMainLoop();
Application::instance().unloadPlugin(imguiPlugin);

See BsImgui_test.cpp file for example of how imgui can be drawn as part of the main thread components.

#include "imgui.h"
#include "BsImgui.h"
#include "BsImGuizmo.h"
class DemoUI : public Component {
public:
	DemoUI(const HSceneObject& parent)
		: Component(parent)
	{
		setFlag(ComponentFlag::AlwaysRun, true);
		setName("DemoUI");
	}

	void update() override {
		Component::update();
		demoImguiUI();
	}
};

class DemoEditTransform : public Component {
	// keep a modifiable reference to the scene object.
	HSceneObject mParent;
public:
	DemoEditTransform(HSceneObject parent)
		: Component(parent), mParent(parent)
	{
		setFlag(ComponentFlag::AlwaysRun, true);
		setName("DemoEditTransform");
	}

	void update() override {
		Component::update();
		Transform transform = mParent->getLocalTransform();

    ImGui::Begin("Transform example");    
			EditTransform(transform, gSceneManager().getMainCamera());
		ImGui::End();
		ManipulateTransform(transform, gSceneManager().getMainCamera());
		auto& so = SO();
		so->setLocalTransform(transform);
	}	
};

TODO

  • try out imgui docking branch demo
  • add useful widgets and bsf utilities to the repository as the plugin is adopted and used.

bsfimgui's People

Contributors

pgruenbacher avatar pgruenbacher-tsus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bsfimgui's Issues

Build error, virtual method signature for BSF master changed

Hello, the virtual method signatures you overwrote have changed.
You should look into your check() and render() methods compared to the ones in the master branch of bsf.

Here are the new ones:

RendererExtensionRequest check(const ct::Camera& camera) override;

void render(const ct::Camera& camera, const ct::RendererViewContext& viewContext) override;

Otherwise your plugin won't compile anymore.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.