Go to file
SweetId 54c43c7600 Fix examples compilation 2024-02-22 17:27:43 -05:00
examples Fix examples compilation 2024-02-22 17:27:43 -05:00
include/NazaraImgui split NazaraImgui.hpp into multiples files to speed up compilation 2023-11-24 16:03:56 +05:30
src/NazaraImgui Merge pull request #1 from SirLynix/renderer-fixes 2024-02-22 17:25:28 -05:00
.gitattributes add gitattributes/gitignore files 2022-07-30 13:48:56 +02:00
.gitignore ignore imgui.ini file 2023-11-24 16:05:33 +05:30
LICENSE add licence text 2022-07-30 14:38:16 +02:00
README.md add README.md 2022-07-30 15:06:29 +02:00
xmake.lua Update for latest Nazara version 2024-02-12 15:47:28 +01:00

README.md

Nazara Imgui

Nazara Imgui is a Nazara Engine module that integrates Imgui features into the Engine.

You can use it in any kind of commercial and non-commercial applications without any restriction (MIT license).

Authors

Sid - main developper

How to Use

// Add NazaraImgui.hpp to your includes
#include <NazaraImgui/NazaraImgui.hpp>

// main.cpp
{
    // Add Nz::Imgui to the modules list
    Nz::Modules<Nz::Graphics, Nz::Imgui,...> nazara;

    // Create and init renderwindow
    Nz::RenderWindow window;


    // Once window is created, init Imgui instance
    // This will load shaders, create graphic pipeline, install event handlers, ...
    Nz::Imgui::Instance()->Init(window);

    // [...]
    float value = 0.f; // for ImGui::SliderFloat
    float color[] = { 1,0,0,1 }; // for ImGui::ColorPicker4

    // for ImGui::Image
    Nz::TextureParams texParams;
    texParams.renderDevice = device;
    texParams.loadFormat = Nz::PixelFormat::RGBA8;
    std::shared_ptr<Nz::Texture> logo = Nz::Texture::LoadFromFile("MyImage.png", texParams);

    Nz::Clock updateClock;
    while(window.IsOpen())
    {
        // ProcessEvent will send events to imgui
        window.ProcessEvents();

        Nz::RenderFrame frame = window.AcquireFrame();
        if (!frame)
        {
            std::this_thread::sleep_for(std::chrono::milliseconds(1));
            continue;
        }

        // Call update on the instance
        Nz::Imgui::Instance()->Update(window, updateClock.GetSeconds());

        // Then use standard imgui functions
        ImGui::Begin("MyWindow");

        ImGui::SliderFloat("Value", &value, 0, 10);
        
        // display a Nz::Texture
        ImGui::Image(logo.get());

        ImGui::ColorPicker4("Color", color, ImGuiColorEditFlags_PickerHueWheel | ImGuiColorEditFlags_DisplayRGB);
        
        ImGui::End();

        // Before presenting frame, render imgui
        Nz::Imgui::Instance()->Render(window, frame);
        frame.Present();

        updateClock.Restart();
    }
}

Contribute

Don't hesitate to contribute to Nazara Engine by:
  • Extending the wiki
  • Submitting a patch to GitHub
  • Post suggestions/bugs on the forum or the GitHub tracker
  • Fork the project on GitHub and push your changes
  • Talking about Nazara Engine to other people, spread the word!
  • Doing anything else that might help us

Discord