Results 1 to 9 of 9

Thread: ImGui pascal bindings

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    ImGui pascal bindings

    Hi, I'm working on pascal bindings for ImGui. It's a small library for immediate mode user interfaces, that's easy to integrate with SDL + OpenGL (and has examples for integrating with other frameworks / rendering APIs).
    This is what the readme says:
    dear imgui (AKA ImGui), is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).

    ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/ debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.

    ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
    I was looking for a simple gui for my OpenGL projects and it is serving me well so far (and it's even quite fun to use).

    The bindings are here: https://github.com/dpethes/imgui-pas
    ImGui is a C++ library, therefore a C wrapper dll is needed for other languages. It wraps the the static methods of ImGui classes as functions, which I had to import first and re-create a static class around them to mimic the original interface. I included a demo that shows how to use the library and includes the cimgui.dll build for Windows 64bit.

    This is how I use it in my model viewer - though I recommend ImGui's project page for way better examples:

    Code:
    procedure DrawGui;
    var
      style: PImGuiStyle;
      file_item: TFileListItem;
      fitem_selected: Boolean = false;
      selected_mesh_name: String;
      selected_item: TFileListItem;
    begin
      ImGui_ImplSdlGL2_NewFrame(g_window);
    
      style := Imgui.GetStyle();
      style^.WindowRounding := 0;
    
      Imgui.Begin_('Mesh');
        if not g_model_loading_failed then begin
            Imgui.Text(g_model_name);
        end else
            Imgui.Text('mesh loading failed :(');
      Imgui.End_;
    
      Imgui.Begin_('Rendering options');
        Imgui.Checkbox('points', @view.opts.points);
        Imgui.Checkbox('wireframe', @view.opts.wireframe);
        Imgui.Checkbox('textures', @view.opts.textures);
        Imgui.Checkbox('vertex colors', @view.opts.vcolors);
        if g_model <> nil then
            if Imgui.Button('Export to obj') then
                g_model.ExportObj('rs_exported.obj');
      Imgui.End_;
    
      selected_mesh_name := EmptyStr;
      Imgui.Begin_('File list');
        //todo filter
        for file_item in g_filelist do begin
            fitem_selected := file_item.name = g_model_name;
            if Imgui.Selectable(file_item.name, fitem_selected) then begin
                selected_mesh_name := file_item.name;
                selected_item := file_item;
            end;
        end;
      Imgui.End_;
    
      if (selected_mesh_name <> EmptyStr) and (selected_mesh_name <> g_model_name) then begin
          try
            LoadMesh(selected_item);
            g_model_name := selected_mesh_name;
            g_model_loading_failed := false;
          except
            g_model_loading_failed := true;
          end;
      end;
    end;
    Last edited by imcold; 30-05-2017 at 05:57 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •