This is a software renderer for Dear ImGui. I built it not out of a specific need, but because it was fun

Dear ImGui software renderer

This is a software renderer for Dear ImGui. I built it not out of a specific need, but because it was fun. The goal was to get something accurate and decently fast in not too many lines of code. It renders a complex GUI in 1-10 milliseconds on a modern laptop.

What it is:

As the name implies, this is a software renderer for ImGui. It does not handle any windows or input. In the supplied example I use SDL2 for that.

How to use it

Just copy imgui_sw.hpp and imgui_sw.cpp. There are no other dependencies beside Dear ImGui. Requires C++11.

How to test it

git clone https://github.com/emilk/imgui_software_renderer.git
cd imgui_software_renderer
git submodule update --init --recursive
./build_and_run.sh

For the example to work you will need to have SDL2 on your system.

Example:

This renders in 7 ms on my MacBook Pro:

Software rendered

Alternatives

There is another software rasterizer for ImGui (which I did not know about when I wrote mine) at https://github.com/sronsse/imgui/tree/sw_rasterizer_example/examples/sdl_sw_example. I have not compared the two (yet).

Future work:

  • We do not yet support painting with any other texture than the default font texture.
  • Optimize rendering of gradient rectangles (common for color pickers)
  • Compare my software renderer to the one by @sronsse

License:

This software is dual-licensed to the public domain and under the following license: you are granted a perpetual, irrevocable license to copy, modify, publish, and distribute this file as you see fit.

Owner
Emil Ernerfeldt
Rust coder, and creator of egui. Has worked with physics simulation, games, 3D scanning and cyber security.
Emil Ernerfeldt
Comments
  • Unable to clone your repository using your documentation

    Unable to clone your repository using your documentation

    I'm unable to clone your repo using git clone [email protected]:emilk/imgui_sw.git I got an error relative to user rights (not able to clone).

    git clone [email protected]:emilk/imgui_sw.git
    Clonage dans 'imgui_sw'...
    The authenticity of host 'github.com (192.30.253.112)' can't be established.
    RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.
    Permission denied (publickey).
    fatal: Could not read from remote repository.
    Please make sure you have the correct access rights
    and the repository exists.
    

    So I suggest to change your documentation line by : git clone https://github.com/emilk/imgui_software_renderer.git

    I'vve an issue with the submodule init too:

     git submodule update --init --recursive
    Sous-module 'third_party/emath' ([email protected]:emilk/emath.git) enregistré pour le chemin 'third_party/emath'
    Sous-module 'third_party/emilib' ([email protected]:emilk/emilib.git) enregistré pour le chemin 'third_party/emilib'
    Sous-module 'third_party/imgui' ([email protected]:ocornut/imgui.git) enregistré pour le chemin 'third_party/imgui'
    Sous-module 'third_party/stb' ([email protected]:nothings/stb.git) enregistré pour le chemin 'third_party/stb'
    Clonage dans 'third_party/emath'...
    Permission denied (publickey).
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    fatal: Le clonage de '[email protected]:emilk/emath.git' dans le chemin de sous-module 'third_party/emath' a échoué
    
  • add <algorithm>

    add

    otherwise it will not compile using MSVC for me. and checking with cppreference I don't really understand why it works using clang the way it is right now:

    https://en.cppreference.com/w/cpp/algorithm/max

    also thanks for providing this sw renderer. it is super awesome :D

  • Out of bounds access in paint_uniform_rectangle

    Out of bounds access in paint_uniform_rectangle

    I put together the imgui demo containing ImGui::ShowDemoWindow() (the same imgui commit contained in third_party) with this software renderer, and had a consistent crash when opening Widgets, Color/Picker Widgets in the demo window. The Windows 10 window size was 889x528. The position and size of the demo window (as reported by imgui.ini): [Window][ImGui Demo] Pos=75,38 Size=691,3418 Collapsed=0

    I believe I traced the issue to this line: https://github.com/emilk/imgui_software_renderer/blob/e942aca8f4352471217e0041c6c0d35f45a07fc2/src/imgui_sw.cpp#L239 max_y_i and min_y_i were both 528. That would prevent the for loops from drawing a row, but the last_target_pixel line still accessed memory beforehand. To fix, I set last_target_pixel to 0, as was done here: https://github.com/emilk/imgui_software_renderer/blob/e942aca8f4352471217e0041c6c0d35f45a07fc2/src/imgui_sw.cpp#L432

    Apologies if a pull request might have been preferred. I was not sure if I should do so unsolicited.

    Thanks for putting this together, it has been a massive help for a certain project of mine

  • Ideas or hints to implement custom image loading in imgui_sw?

    Ideas or hints to implement custom image loading in imgui_sw?

    Hi, i modified the original source code of this software renderer for imgui to run in the recent stable version of Dear ImGui and using the Allegro 4.2.2 for a retro project, the repository README claims the code can't load textures that are not the font textures from ImGUI, there's a way to implement those?, basically i'm lost.

    P.D: This code was compared with sronsse code, using both Allegro 4.2.2, sronsse runs slightly faster but it has visual glitches or limitations when using color wheels or gradient pickers where this code excels at.

    Fun Fact: i ran this code in MS-DOS, in a real retro machine a Pentium III Toshiba Satellite laptop, it ran somewhat decently, used the VESA 2.0 800x600 mode, for the 32-bit color support.

  • Update to latest imgui

    Update to latest imgui

    Is it feasible to upgrade this code against latest imgui? I'd love to use this for a project of mine but it's 2 years old at this point. Granted, it runs fine on that older version but I don't want to start out on a known out of date version of imgui. Thanks!

  • Update .gitmodules to use https

    Update .gitmodules to use https

    Hi @emilk , I know that this repo has been silent for a long time, but it would make life a lot easier for me, if we could switch to https in gitmodules file as well (which was changed, yet only in the documentation in #1 ).

A simple C++ ImGui loader base you can use for all your projects that need a login / register page.
A simple C++ ImGui loader base you can use for all your projects that need a login / register page.

C++ Loader Base ??️ What is this? ⚡ This is a very simple base I made for projects that require a login / register page that use ImGui. ??️ Screenshot

Jul 23, 2022
Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies

Dear ImGui (This library is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addit

Aug 16, 2022
Advanced 2D Plotting for Dear ImGui
Advanced 2D Plotting for Dear ImGui

ImPlot ImPlot is an immediate mode, GPU accelerated plotting library for Dear ImGui. It aims to provide a first-class API that ImGui fans will love. I

Aug 8, 2022
Real-time GUI layout creator/editor for Dear ImGui
Real-time GUI layout creator/editor for Dear ImGui

ImStudio Real-time GUI layout creator/editor for Dear ImGui Inspired by Code-Building/ImGuiBuilder Features Drag edit Property edit Covers most of the

Aug 15, 2022
Dear ImGui prototyping wrapper.

LabImGui Prototyping framework LabImGui wraps up creating a window, GL bindings, and a full screen docking set up with ImGui so that all of the boiler

Dec 2, 2021
An integrated information center created with dear ImGui using modern C++ design / coding style.

ImGui info-center Introduction An integrated notification and information center created with dear ImGui. Interfaces and variables are designed under

Jul 20, 2022
Addon widgets for GUI library Dear ImGui.
Addon widgets for GUI library Dear ImGui.

ImGui-Addons Addon widgets for GUI library Dear ImGui. File Dialog A simple cross-platform file dialog that uses dirent interface for reading director

Aug 8, 2022
A permissively licensed markdown single-header library for Dear ImGui.
A permissively licensed markdown single-header library for Dear ImGui.

Support development of imgui_markdown through GitHub Sponsors or Patreon imgui_markdown Markdown For Dear ImGui A permissively licensed markdown singl

Aug 13, 2022
Window and GUI system based on Dear ImGui from OCornut
Window and GUI system based on Dear ImGui from OCornut

ImWindow Window and GUI system based on ImGui from OCornut. Include docking/floating window, multi window and multi render support. Platform Actually

Aug 2, 2022
Nice things to use along dear imgui
Nice things to use along dear imgui

Mini hexadecimal editor! Right-click for option menu. Features: Keyboard controls. Read-only mode. Optional Ascii display. Optional HexII display. Goto address. Highlight range/function. Read/Write handlers.

Aug 7, 2022
This is a thin c-api wrapper programmatically generated for the excellent C++ immediate mode gui Dear ImGui.

cimgui This is a thin c-api wrapper programmatically generated for the excellent C++ immediate mode gui Dear ImGui. All imgui.h functions are programm

Jul 5, 2021
Immediate mode 3D gizmo for scene editing and other controls based on Dear Imgui
Immediate mode 3D gizmo for scene editing and other controls based on Dear Imgui

ImGuizmo Latest stable tagged version is 1.83. Current master version is 1.84 WIP. What started with the gizmo is now a collection of dear imgui widge

Aug 11, 2022
Sample Unreal Engine 5.0.1 C++ Project That Incorporates Dear ImGui

UE5 With Dear ImGui A sample Unreal Engine 5.0.1 C++ project that incorporates the Dear ImGui graphical user interface library. YouTube Tutorial This

Jul 29, 2022
Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.
Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.

libui: a portable GUI library for C This README is being written. Status It has come to my attention that I have not been particularly clear about how

Aug 15, 2022
Simple ImGui external base. Uses ImGui DX9.
Simple ImGui external base. Uses ImGui DX9.

ImGui External Base ??️ What is this? ⚡ Hello all! I used to use noteffex's loader base for all my external ImGui projects. I got bored of using this

Jun 29, 2022
An addon of imgui for supporting docks in the imgui's window
An addon of imgui for supporting docks in the imgui's window

An addon of imgui for support dock in the window

Aug 3, 2022
Lets try out a few ways to easily create a modern Win32 UI app

UI-Experiments Lets try out a few ways to easily create a modern Win32 UI app This is a VS2019 solution with a handful of single projects, each one tr

Dec 6, 2021
[WIP] Demo of a minimal but functional Dawn-based WebGPU client and server

dawn client-server example The goal of this demo is to create a minimal but functional Dawn-based WebGPU client and server with the following traits:

Nov 20, 2021
GPU Accelerated C++ User Interface, with WYSIWYG developing tools, XML supports, built-in data binding and MVVM features.

GacUI GPU Accelerated C++ User Interface, with WYSIWYG developing tools, XML supports, built-in data binding and MVVM features. Read the LICENSE first

Aug 8, 2022