2
0

A binding and backend of ImGui to make it render and work correctly with the raylib framework/Library. This is C++ but links with raylib.

#c++ #cpp #raylib #wrapper #binding #imgui #gamedev #ui #gui #dear-imgui #library

Jeffery Myers 3c6986358c add asset browser example 1 жил өмнө
examples 3c6986358c add asset browser example 1 жил өмнө
extras 8c8bf94d58 Upgrade to Font Awesome 6 free. 3 жил өмнө
resources 57e55c3a8f don't auto load fonts for ImGui low level API, add font loading to the low level API example 1 жил өмнө
.gitignore 30cd744e9d Update to current game-premake 1 жил өмнө
LICENSE cfa841f0ec license 3 жил өмнө
README.md a07b514fe2 add low level ImGui backend that matches the other backends. 1 жил өмнө
imgui_impl_raylib.h b02ec0e657 void for empty arguments. 1 жил өмнө
premake-VisualStudio.bat d87331caa0 update to current game-premake system 2 жил өмнө
premake-mingw.bat d87331caa0 update to current game-premake system 2 жил өмнө
premake5 d87331caa0 update to current game-premake system 2 жил өмнө
premake5.exe 7864355e23 add premake 2 жил өмнө
premake5.lua 3c6986358c add asset browser example 1 жил өмнө
premake5.osx d87331caa0 update to current game-premake system 2 жил өмнө
raylib_premake5.lua 3c6986358c add asset browser example 1 жил өмнө
rlImGui.cpp 33878175cd don't assume DRM supports high DPI 1 жил өмнө
rlImGui.h b43ac12dba Add void in empty brackets 1 жил өмнө
rlImGuiColors.h c91d9281ec copyright update 1 жил өмнө

README.md

rlImGui

A Raylib integration with DearImGui

rlImgui provides a backend for Dear ImGui using Raylib.

Building

rlImGui is setup to use premake to generate a static library and examples for Visual Studio 2019. Premake can also be used to generate makefiles for linux. rlImGui can be used as a static library, or by direclty including the files into your game project.

If you wish to use premake, you will need to download the Premake5 executable for your platform from. https://premake.github.io/download

Setup

Using rlImGui in your code is very easy. Once you have included the library, or source files for rlImGui and ImGui in your project, simply do the following.

#include "rlImGui.h"	// include the API header

// before your game loop
rlImGuiSetup(true); 	// sets up ImGui with ether a dark or light default theme

// inside your game loop, between BeginDrawing() and EndDrawing()
rlImGuiBegin();			// starts the ImGui content mode. Make all ImGui calls after this

rlImGuiEnd();			// ends the ImGui content mode. Make all ImGui calls before this

// after your game loop is over, before you close the window

rlImGuiShutdown();		// cleans up ImGui

Examples

There are two example programs in the examples folder.

Simple

This is the most simple use of ImGui in raylib, it just shows the ImGui demo window. image

Editor

This is a more complex example of ImGui, showing how to use raylib 2d and 3d cameras to draw into ImGui windows using render textures. image

Extras

rlImGuiColors.h

This file has a converter to change Raylib colors into ImGui Colors

Font Awesome Icons

Support for Font Awesome 6 https://fontawesome.com/ is built into rlImGui and enabled by default. You can simply #include "extras/IconsFontAwesome6.h" To use the ICON_FA macros for any icon in the free set.

If you wish to disable font awesome support you can #define NO_FONT_AWESOME

Images

Raylib textures can be drawn in ImGui using the following functions

void rlImGuiImage(const Texture *image);
void rlImGuiImageSize(const Texture *image, int width, int height);
void rlImGuiImageSizeV(const Texture* image, Vector2 size);
void rlImGuiImageRect(const Texture* image, int destWidth, int destHeight, Rectangle sourceRect);
void rlImGuiImageRenderTexture(const RenderTexture* image);
void rlImGuiImageRenderTextureFit(const RenderTexture* image, bool center);

bool rlImGuiImageButton(const Texture *image);
bool rlImGuiImageButtonSize(const char* name, const Texture* image, struct ImVec2 size);

C vs C++

ImGui is a C++ library, so rlImGui uses C++ to create the backend and integration with Raylib. The rlImGui.h API only uses features that are common to C and C++, so rlImGui can be built as a static library and used by pure C code. Users of ImGui who wish to use pure C must use an ImGui wrapper, such as [https://github.com/cimgui/cimgui].

Low level API

If you would like more controll over the ImGui Backend, you can use the low level API that is found in imgui_impl_raylib.h. This is API follows the patterns of other ImGui backends and does not do automatic context management. An example of it's use can be found in imgui_style_example.cpp