Skip to content

Moxibyte/wxPack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

wxPack

This repo hosts the source of multiple sources that extend wxWidgets upon features that I needed for some of my projects.

  • wxD3D12 DirectX 12 integration. Allows creation of frame with a swap chain and automatic serving. Also provides ImGUI integration for the frame in question. (Requires full ImPack folder!)
  • wxPLOT Provides easy access to full frame plots using ImPlot
  • wxFA Provides fontawesome (free) access via wxArtProvider. Requires the fontawesome data folder as subfolder next to executable or in the working dir. You can swap in fontawesome pro with minor modifications.

Integration

wxApp integration

Initialization

// D3D12
#if defined(DEBUG) // Use your debug define of choice
wxD3D12System::Get().EnableDebugLayer();
#endif
bool success = wxD3D12System::Get().Initialize();

// Fontawesome
wxArtProvider::Push(new wxFAArtProvider());

Shutdown

// D3D12
wxD3D12System::Get().Shutdown();

D3D12 Callback

void OnDraw(ID3D12GraphicsCommandList* cmdList)
{
    // TODO: Implement DirectX 12 draw calls
}

auto* CreateFrame()
{
    auto* frame = new wxFrame(nullptr, wxID_ANY, "wxD3D12Window Example", wxDefaultPosition, wxSize(800, 600));
    auto* vbox = new wxBoxSizer(wxVERTICAL);

    auto* window = new wxD3D12Window(frame);
    window->SetD3D12Handler(&OnDraw);

    wxButton* btn1 = new wxButton(frame, wxID_ANY, "Button 1");
    wxButton* btn2 = new wxButton(frame, wxID_ANY, "Button 2");

    // add to sizer
    vbox->Add(window, 1, wxEXPAND | wxALL, 5);
    vbox->Add(btn1, 0, wxEXPAND | wxALL, 5);
    vbox->Add(btn2, 0, wxEXPAND | wxALL, 5);

    frame->SetSizer(vbox);
    frame->Show();
    return frame;
}

ImGui Callback

void OnImGui()
{
    ImGui::ShowDemoWindow();
}

auto* CreateFrame()
{
    auto* frame = new wxFrame(nullptr, wxID_ANY, "wxD3D12Window Example", wxDefaultPosition, wxSize(800, 600));
    auto* vbox = new wxBoxSizer(wxVERTICAL);

    auto* window = new wxD3D12Window(frame);
    window->SetImGuiHandler(&OnImGui);

    wxButton* btn1 = new wxButton(frame, wxID_ANY, "Button 1");
    wxButton* btn2 = new wxButton(frame, wxID_ANY, "Button 2");

    // add to sizer
    vbox->Add(window, 1, wxEXPAND | wxALL, 5);
    vbox->Add(btn1, 0, wxEXPAND | wxALL, 5);
    vbox->Add(btn2, 0, wxEXPAND | wxALL, 5);

    frame->SetSizer(vbox);
    frame->Show();
    return frame;
}

ImPlot Callback

void OnPlot()
{
    if (ImPlot::BeginPlot("Plot", ImVec2(-1, -1))) // The -1, -1 is important to have "fullscreen"/"fullframe" plots
    {
        // TODO: Plot code

        ImPlot::EndPlot();
    }
}

auto* CreateFrame()
{
    auto* frame = new wxFrame(nullptr, wxID_ANY, "wxPLOTWindow Example", wxDefaultPosition, wxSize(800, 600));
    auto* vbox = new wxBoxSizer(wxVERTICAL);

    auto* window = new wxPLOTWindow(frame);
    window->SetImPlotHandler(&OnPlot);

    auto* btn1 = new wxButton(frame, wxID_ANY, "Button 1");
    auto* btn2 = new wxButton(frame, wxID_ANY, "Button 2");

    // add to sizer
    vbox->Add(window, 1, wxEXPAND | wxALL, 5);
    vbox->Add(btn1, 0, wxEXPAND | wxALL, 5);
    vbox->Add(btn2, 0, wxEXPAND | wxALL, 5);

    frame->SetSizer(vbox);
    frame->Show();
    return frame;
}

Fontawesome

wxFrame* CreateFrame(wxWindow* parent = nullptr)
{
    auto* frame = new wxFrame(parent, wxID_ANY, "Two Buttons");
    auto* sizer = new wxBoxSizer(wxVERTICAL);
    auto* btnInfo = new wxButton(frame, wxID_ANY, "Info");
    auto* btnExit = new wxButton(frame, wxID_ANY, "Exit");

    btnInfo->SetBitmap(wxArtProvider::GetBitmap("fa-circle-info#5A5A5A", wxART_OTHER, wxSize(24, 24)));
    btnExit->SetBitmap(wxArtProvider::GetBitmap("fa-door-open#FF5555", wxART_OTHER, wxSize(24, 24)));

    sizer->Add(btnInfo, 0, wxALL | wxEXPAND, 5);
    sizer->Add(btnExit, 0, wxALL | wxEXPAND, 5);

    frame->SetSizerAndFit(sizer);
    frame->Show();
    return frame;
}

Requirements (conan; requires external integration)

def requirements(self):
    self.requires("fmt/11.2.0")             # String formatting
    self.requires("boost/1.88.0")           # Utils
    self.requires("opencv/4.11.0")          # Image rescaling 
    self.requires("wxwidgets/3.2.8")        # UI
    self.requires("freetype/2.13.3")        # Font Engine
    self.requires("reflect-cpp/0.18.0")     # Reflection (struct to/from file)

def configure(self):
    self.options["boost"].filesystem_use_std_fs = True
    self.options["reflect-cpp"].with_yaml = True

Note: More recent version will probably work. But this is the "tests" versions. Additional options can be supplied. But the ones at the top are required.

Include path and linking

The following includes MUST work:

  • Direct imgui includes. So everything thats in the ImPack folder. Like #include <imgui.h>
  • Indirect wx** includes. So #include <wxD3D12/wxD3D12Window.h> and #include <wxFA/wxFAArtProvider.h> should work.

You can include the headers and source directly into your code or build it as a own shared or static lib (static lib has been testes. Shared not!)

External code a resources (direct copy)

  • FontAwesome Copyright (c) 2024 Fonticons, Inc. (https://fontawesome.com)
  • ImGUI Copyright (c) 2014-2025 Omar Cornut (MIT; See ImGUI files for more information)
  • ImPlot Copyright (c) 2023 Evan Pezent (MIT; See ImPlot files for more information)
  • ImPlot3D Copyright (c) 2024-2025 Breno Cunha Queiroz (MIT; See ImPlot3D files for more information)

About

Starter code for wxWidgets with D3D12, ImGui, ImPlot, ImPlot3D and FontAwesome (free)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published