Results 1 to 9 of 9

Thread: ImGui pascal bindings

  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.

  2. #2
    Examples look interesting, is it possible to make scaled container with it? Like a grid with ui elements on it that you can 'zoom' in and out.

  3. #3
    Not sure what you mean. There are columns (rather than grids) and they can contain ui elements, see Colums or Layouts in the original ShowTestWindow (uncomment line ImGui.ShowTestWindow() in ImGuiDemo.lpr). You can adjust font size per window through SetWindowFontScale, or scale the whole ui through DisplayFramebufferScale, but I don't think you can scale just part of the UI.

  4. #4
    Updated to newest imgui 1.50 and added Windows 32/64bit Debug/Release builds of cimgui so it's easier to start using it on Windows.

  5. #5
    Nice! I'll look more into this once I'm done with my randon name generator.

  6. #6
    That's awsome. I'll definitivly look into this. Keep up the good work!

    EDIT: There is a lack of good and SDL2 compatible GUI bindings.

  7. #7
    Updated to imgui 1.52, I have fallen a bit behind.

  8. #8
    Can you please share also imgui dll's?

  9. #9
    Sure! Updated to Imgui 1.53, dll's are in the demo package: https://github.com/dpethes/imgui-pas/releases
    Last edited by imcold; 23-06-2018 at 06:56 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
  •