Shard Detail

imgui-sfml v2.1.0

Crystal bindings to ImGui-SFML

Install & Use

Add the following code to your project's shard.yml under:

dependencies to use in production
- OR -
development_dependencies to use in development

  github: oprypin/crystal-imgui-sfml



Crystal bindings to ImGui-SFML


This library makes it straightforward to
  use Dear ImGui (through its crystal-imgui binding)
  with SFML (through its CrSFML binding).

See the example.

crystal-imgui-sfml does not attempt to serve as a wrapper for all of these, rather it's just the "glue",
and so both crystal-imgui and CrSFML will still be explicit dependencies of your project.

That said, crystal-imgui-sfml does take over some parts of the installation process from crystal-imgui.



First, install SFML.

Then add to your project's shard.yml file:

    github: oprypin/crsfml
    github: oprypin/crystal-imgui
    github: oprypin/crystal-imgui-sfml

Resolve dependencies with Shards:

shards install

During installation this will invoke make to build the C++ wrappers as object files. SFML headers are expected to be available in the default include path.

Building a project

Try the example from inside the folder of crystal-imgui-sfml:

crystal build examples/

Although building the example automatically added the library (bundled with the project) to the search path, running it will require that addition to be done manually:

export LD_LIBRARY_PATH="$(pwd)"

For your own project, crystal-imgui-sfml will be in a subdirectory, so adjust this accordingly:

export LD_LIBRARY_PATH="$(pwd)/lib/imgui-sfml"
printf 'require "crsfml"\nrequire "imgui"\nrequire "imgui-sfml"\n' >>
crystal run

Custom SFML location

If SFML's headers and libraries are not in a path where the compiler would look by default, additional steps are needed.

Before building the extensions (make) you need to configure the include path:

export CXXFLAGS="-I/full/path/to/sfml/include"
export LIBRARY_PATH="/full/path/to/sfml/lib"

More details at CrSFML

crystal-imgui-sfml without Shards

It's also possible to use crystal-imgui-sfml outside of Shards, as with any library. One option is to directly create a symbolic link to crystal-imgui-sfml in your project's lib folder.

mkdir lib
ln -s /full/path/to/crsfml lib/crsfml
ln -s /full/path/to/crystal-imgui lib/imgui
ln -s /full/path/to/crystal-imgui-sfml lib/imgui-sfml

Note, though, that the C bindings inside the crystal-imgui-sfml directory must be additionally built using make.


crystal-imgui-sfml was made by Oleh Prypin. It uses and is based on ImGui-SFML.

crystal-imgui-sfml is licensed under the terms and conditions of the MIT license.