Giter VIP home page Giter VIP logo

imguiscene's Introduction

ImGuiScene

A simple ibrary that wraps everything necessary to add ImGui support to a C# project. This is mainly useful inside a dll that is injected into a game or similar process, in order to provide a simple transparent overlay where ImGui controls can be trivially created. It can also be used as a standalone application for prototyping or testing ImGui scenes etc.

ImGui integration is done with ImGui.NET, while window creation and events use SDL2-CS. The semi-official ImGui backend implementations for SDL, DX11, and OpenGL3 were ported as directly as possible to SDL2-CS, SharpDX and OpenGL.NET. The C++ sources for those implementations are extremely messy and poor as-is, and currently no effort has been made to clean them up for C#, or to impose reasonable code design on them. They do work for now, and hopefully I can improve on them later.

How to use

There are two main ways of using ImGuiScene in your project:

  • As regular references (recommended):
    • Do a recursive clone of this project
    • Build it
    • Add the 3 output dlls (ImGuiScene.dll, SDL2-CS.dll and ImGui.NET.dll) as references in your project
  • As a submodule:
    • Create your project and git repo
    • Add this project as a submodule
    • Do a recursive submodule init to pull in dependencies
    • Add the solution from this project to your solution (Add existing project, change filter to sln)
      • This pulls in all the subprojects necessary to build
    • Add the ImGuiScene, ImGui.NET-472, and SDL2-CS projects as project references in your project
      • ImGuiSceneTest can be deleted from your project, or just ignored

Usage Note

You may need to ensure "Prefer 32-bit" is disabled for your project if you use the AnyCPU target. This is due to the version of the native dlls that are included; I will look into providing a 32-bit version as well in the future.

Simple example application

This is the simplest example, which just creates a transparent ('hidden') fullscreen window that renders the default ImGui demo window. More control can be had by directly creating a SimpleImGuiScene from its constructor, and/or by modifying properties on the scene object.

static void Main(string[] args)
{
    using (var scene = SimpleImGuiScene.CreateOverlay(RendererFactory.RendererBackend.DirectX11))
    {
        // Any ImGui code can be put into methods attached to OnBuildUI and will work as expected
        // Virtually all actual application logic will be inside these handlers
        scene.OnBuildUI += ImGui.ShowDemoWindow;

        // This blocks until a specified key is pressed.  Since we didn't override it in CreateOverlay(), it defaults to escape.
        // You can alternatively call scene.Update() in a loop, but you are then responsible for checking quit conditions.
        // Because this blocks, you will typically want to put your scene in a thread if you are using an injected application.
        scene.Run();
    }
}

imguiscene's People

Contributors

ff-meli avatar lmcintyre avatar goaaats avatar soreepeong avatar daemitus avatar

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.