Giter Site home page Giter Site logo

swiftimgui's Introduction

Swift ImGui

Build Status license
swift-version-compatibility platform-compatibility

swiftimgui-gif

This is a lightweight, auto-generated and thin Swift wrapper around the popular and excellent dear imgui library.
It provides a swifty and -especially - typesafe API. It is easily maintainable and updatable, as well, since it relies heavily on automated code generation.

There are working demo examples, too, provided as part of the library.

๐Ÿš€ Getting Started

These instructions will get your copy of the project up and running on your local machine and provide a code example.

๐Ÿ“‹ Prerequisites

๐Ÿ’ป Installing

Swift ImGui is available for all platforms that support Swift 5.1 and higher and the Swift Package Manager (SPM).

Extend the following lines in your Package.swift file or use it to create a new project.

// swift-tools-version:5.1

import PackageDescription

let package = Package(
    name: "YourPackageName",
    dependencies: [
        .package(url: "https://github.com/ctreffs/SwiftImGui.git", from: "1.78.0")
    ],
    targets: [
        .target(
            name: "YourTargetName",
            dependencies: ["ImGui"])
    ]
)

๐Ÿ“ Code Example

A minimal example is located at Sources/Demos/Minimal/main.swift.
This is an excerpt:

import ImGui

IMGUI_CHECKVERSION()
let ctx = ImGuiCreateContext(nil)
let io = ImGuiGetIO()!

/// Build font atlas
var pixels: UnsafeMutablePointer<UInt8>?
var width: Int32 = 0
var height: Int32 = 0
var bytesPerPixel: Int32 = 0
ImFontAtlas_GetTexDataAsRGBA32(io.pointee.Fonts, &pixels, &width, &height, &bytesPerPixel)

for n in 0..<20 {
    io.pointee.DisplaySize = ImVec2(x: 1920, y: 1080)
    io.pointee.DeltaTime = 1.0 / 60.0
    ImGuiNewFrame()
    var f: Float = 0.0
    ImGuiTextV("Hello, world!")
    ImGuiSliderFloat("float", &f, 0.0, 1.0, nil, 1)
    ImGuiTextV("Application average %.3f ms/frame (%.1f FPS)", 1000.0 / io.pointee.Framerate, io.pointee.Framerate)
    ImGuiShowDemoWindow(nil)
    ImGuiRender()
}

ImGuiDestroyContext(ctx)

๐Ÿ†• Update SwiftImGui

SwiftImGui uses a mutli-stage process to update to the latest imgui version. See HOWTO.md for details.

๐Ÿ’ Help needed

This project needs a lot of love. If you are interested in contributing please feel free to do so!

Things that need to be done among others are:

  • Extend the AutoWrapper to wrap more cimgui functions (currently there are 81 'invalid' functions that will not be wrapped. 799 will be wrapped properly.)
  • Some vector functions are not available via the c interface - see Sources/AutoWrapper/Exceptions.swift
  • Find a solution for manual adjustments in cimgui generator template
  • Write some more tests

๐Ÿท๏ธ Versioning

We use SemVer for versioning. For the versions available, see the releases on this repository.

โœ๏ธ Authors

See also the list of contributors who participated in this project.

๐Ÿ” Licenses

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Original code

Since SwiftImGui is merely a wrapper around imgui it obviously depends on it.
It also makes use of the excellent c-api wrapper cimgui.
Support them if you can!

imgui

(This library is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addition to maintenance and stability there are many desirable features yet to be added. If your company is using dear imgui, please consider reaching out. If you are an individual using dear imgui, please consider supporting the project via Patreon or PayPal.)

Businesses: support continued development via invoiced technical support, maintenance, sponsoring contracts:
ย ย E-mail: contact @ dearimgui dot org

Individuals/hobbyists: support continued maintenance and development via the monthly Patreon:
ย ย Patreon

Individuals/hobbyists: support continued maintenance and development via PayPal:
ย ย PayPal


Dear 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).

Dear ImGui is designed to enable fast iterations and to 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 lacks certain features normally found in more high-level libraries.

Dear ImGui is particularly suited to integration in games engine (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on consoles platforms where operating system features are non-standard.

cimgui

CImGui is a thin c-api wrapper programmatically generated for the excellent C++ immediate mode gui Dear ImGui. All imgui.h functions are programmatically wrapped. Generated files are: cimgui.cpp, cimgui.h for C compilation. Also for helping in bindings creation, definitions.lua with function definition information and structs_and_enums.lua. This library is intended as a intermediate layer to be able to use Dear ImGui from other languages that can interface with C (like D - see D-binding)

โ˜ฎ๏ธ Alternatives

swiftimgui's People

Contributors

ctreffs avatar rukano avatar vyo avatar jmgc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.