Code Monkey home page Code Monkey logo

rccpp-dearimgui-glfw-example's Introduction

Support our work through GitHub Sponsors or Patreon

Become a Patron

RCC++ Dear ImGui GLFW example with Power Saving

This project adds Runtime Compiled C++ to the Dear ImGui example using the GLFW and OpenGL backend. This enables us to edit the code at runtime and see the results live, without recompiling and restarting the project.

This is a cross platform project using CMake.

Runtime-Compiled C++ (RCC++) is a way to reliably make major changes to C++ code at runtime and see the results immediately. It's aimed at games development but could be useful in any industry where turnaround times are a bottleneck.

github.com/RuntimeCompiledCPlusPlus/RuntimeCompiledCPlusPlus

RCC++ is primarily designed to shorten iteration times in development - developers can build their project, run it, make changes during runtime and see the results in a few seconds.

Short teaser of Runtime Compiled C++ Dear ImGui example running on Linux

Note - you can also find a similar Windows-only example in the devlog post Runtime Compiled C++ Dear ImGui and DirectX11 Tutorial.

Power Saving

To reduce the energy used by Dear Imgui, the application draws the user interface only when there is user input.

Example power saving code in commit

The implementation consists in switching the event handling from polling to waiting for events. A power save variable counts a predefined number of frames after the last input has been received. When the countdown ends the application waits for further events, therefore saving power. If input is received the countdown is reset. This allows the GUI to display input changes and for immediate mode states to propagate.

Though not shown in the example, any graphical application can also track when updates are in progress and temporarily disable power saving (for example by resetting the power save countdown). The example sets the swap interval to 1; if the application sets the swap interval to 0 (for example for low latency gaming), another power saving feature would be to set this to 1 when the user is interacting with the GUI.

Getting the code

The easiest way to get hold of the starter code is to run the following command using a shell you can run git from:

git clone --recursive https://github.com/juliettef/RCCpp-DearImGui-GLFW-example

If you are on Windows you can download git from git-scm.com/download/win and use the right click menu in Windows File Explorer to "Git Bash here" and then run git commands.

This will create the directory RCCpp-DearImGui-GLFW-example and get the latest source code, using the --recursive option to download the RuntimeCompiledCPlusPlus, Dear ImGui and GLFW code, which have been included in the tutorial repository as submodules. If you want to run further git commands from the command line you'll need to cd into the directory:

cd RCCpp-DearImGui-GLFW-example

Alternatively you can use a git GUI program such as Fork to get the code. Most of these will automatically download the git submodules.

If you download the code from GitHub via the "Download ZIP" approach, you'll also need to download the RuntimeCompiledCPlusPlus, Dear ImGui and GLFW into the RuntimeCompiledCPlusPlus, imgui and glfw directories. The correct version can be found by clicking on the RuntimeCompiledCPlusPlus, imgui and glfw folders you see on the front page of the RCCpp-DearImGui-GLFW-example GitHub repository.

Using CMake to create the project

From a command prompt in the RCCpp-DearImGui-GLFW-example directory:

  1. mkdir build
  2. cd build
  3. cmake ..
  4. Either run make all or for Visual Studio open RCCpp-DearImGui-GLFW-example.sln

The RCCpp-DearImGui-GLFW-example Window should open.

rccpp-dearimgui-glfw-example's People

Contributors

dougbinks avatar juliettef avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

rccpp-dearimgui-glfw-example's Issues

Does RCCpp work with DLLs?

I was wondering if this only works with .exe applications or if it also works when the RCCppMainloop.cpp is in a dll

How to update ImGui to latest docking branch?

Hi,

This is very cool, i'd like to use to speed up development of ImGui code for a separate application, but I would like to use the new tables API and the docking branch. Ideally I'd like an easy way to 'turn on / off' the RCCpp code entirely between debug and release, but I don't think that would be easy :)

So, to help with latest ImGui tables and docking, How can I update the ImGui submodule to the latest?

Cheers,

Is the usage of RUNTIME_COMPILER_SOURCEDEPENDENCY_FILE meant as demonstration only?

It seems, the dependencies declared on the imgui file significantly slow down compilation (from 1 to 17 seconds on my machine).
I feel like they're unnecessary and meant to show how the system works, is it the case?
It might be a good idea to add a comment or a mention somewhere in that case. I nearly wrote the project off as unusable because the compilation really felt super slow.

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.