raygui

repository·master·Indexed 26 days ago

https://github.com/raysan5/raygui

A simple, immediate-mode GUI library designed for tools development. Intended as an auxiliary module for raylib but adaptable to other engines, raygui is provided as a single-file header-only library. It supports custom styles via GuiLoadStyle(), a built-in set of 512 icons, and can be built using CMake or as a shared/dynamic library for Windows, Linux, and macOS.

Tokens
3.6K
Snippets
2
Records
24
Agent score
89%

What's inside raygui

  1. Apply the Cyber style to raygui

    master

    The cyber style can be integrated into a raygui application using several different methods depending on your project requirements. Choose the format that best fits your build process:

    • Embedded C code: Use style_cyber.h for a self-contained, embeddable style that includes font data directly in your source code.
    • Binary style file: Use style_cyber.rgs (for raygui 4.0+) which contains compressed font data (recs, glyphs).
    • Text style file: Use style_cyber.txt.rgs if you prefer a text-based format, but note that this requires you to provide an external font.
    • Legacy binary file: Use style_cyber.old.rgs for raygui 3.x projects (contains uncompressed font data).
    • Image-embedded data: Use style_cyber.png, which contains the binary .rgs file data within an rGSf chunk.
  2. Embed raygui styles in code using .h files

    master

    If you prefer not to ship external .rgs files, you can embed styles directly into your source code. raygui provides .h files for every style which contain all required style and font data. To use this method:

    1. Add the specific style's .h file to your project.
    2. Call the initialization function specified within that header file.
  3. Apply the 'bluish' style to a raygui application

    master

    The 'bluish' style can be integrated into a raygui application using several different file formats depending on your project requirements. Choose the format that best fits your build process:

    • style_bluish.h: Best for embedded applications. This is a self-contained C header file that includes the style and font data as code.
    • style_bluish.rgs: A binary style file (compatible with raygui 4.0) that includes compressed font data (recs, glyphs).
    • style_bluish.txt.rgs: A text-based style file. Note that this version does not include font data and requires you to provide an external font.
    • style_bluish.old.rgs: A binary style file for older versions (raygui 3.x) with uncompressed font data.
    • style_bluish.png: A style table image that contains the binary rgs file data within an rGSf chunk.
  4. Integrate raygui as a header-only library

    master

    raygui is a single-file header-only library. To use it in your C/C++ project, include raygui.h.

    Crucial: You must define RAYGUI_IMPLEMENTATION in exactly one compilation unit before including the header to include the function definitions. In all other modules that need to use raygui, include raygui.h without defining RAYGUI_IMPLEMENTATION.

    #include "raylib.h"
    
    #define RAYGUI_IMPLEMENTATION
    #include "raygui.h"
    
    int main() {
        // Your code here
        return 0;
    }
  5. Build raygui as a shared/dynamic library

    master

    If you need to create bindings or use a shared version of the library, you can build it as a DLL or SO. Note that for Windows (MSVC), you should use the "Developer Command Prompt for VS 2022" to ensure cl is accessible.

    Windows (MinGW, GCC)

    copy src/raygui.h src/raygui.c
    gcc -o src/raygui.dll src/raygui.c -shared -DRAYGUI_IMPLEMENTATION -DBUILD_LIBTYPE_SHARED -static-libgcc -lopengl32 -lgdi32 -lwinmm -Wl,--out-implib,src/librayguidll.a

    Windows (MSVC)

    copy src\raygui.h src\raygui.c
    cl /O2 /I<RELATIVE_PATH_TO_RAYLIB_INCLUDE_DIR> /D_USRDLL /D_WINDLL /DRAYGUI_IMPLEMENTATION /DBUILD_LIBTYPE_SHARED src/raygui.c /LD /Feraygui.dll /link /LIBPATH <RELATIVE_PATH_TO_RAYLIB_IMPORT_LIBRARY> msvcrt.lib winmm.lib gdi32.lib user32.lib shell32.lib /subsystem:windows /machine:x64

    Linux (GCC)

    mv src/raygui.h src/raygui.c
    gcc -o raygui.so src/raygui.c -shared -fpic -DRAYGUI_IMPLEMENTATION -lraylib -lGL -lm -lpthread -ldl -lrt -lX11
    mv src/raygui.c src/raygui.h

    Mac (clang)

    cp src/raygui.h src/raygui.c
    brew install raylib
    gcc -o raygui.dynlib src/raygui.c -shared -fpic -DRAYGUI_IMPLEMENTATION -framework OpenGL -lm -lpthread -ldl $(pkg-config --libs --cflags raylib)
  6. Build raygui using CMake

    master

    To build raygui using the provided CMake definition files, navigate to the projects/CMake directory and follow the standard CMake build workflow: create a build directory, run cmake pointing to the source, and then compile using make.

    cd projects/CMake
    mkdir build
    cd build
    cmake ..
    make
  7. Apply the Cherry style to a raygui application

    master

    The Cherry style can be integrated into your raygui project using several different file formats depending on your requirements for portability, ease of use, or file size. Choose one of the following methods:

    • Embeddable C header (Recommended for simplicity): Use style_cherry.h to include the style directly in your code. This is self-contained and includes the necessary font data.
    • Binary style file (raygui 4.0+): Use style_cherry.rgs. This is a compressed binary file containing both style records and font glyphs.
    • Text style file: Use style_cherry.txt.rgs. This contains only text-based style data and requires you to provide an external font.
    • Legacy binary style file (raygui 3.x): Use style_cherry.old.rgs. This is an uncompressed binary file containing style records and font glyphs.
    • Image-embedded style: Use style_cherry.png. The binary rgs data is embedded within the rGSf chunk of the PNG image.
  8. Use raygui icons in controls

    master

    raygui includes a built-in set of 512 icons (16x16 pixels, 1-bit). You can display icons in any control by prefixing the icon ID to the text using the #iconId# format.

    Alternatively, use the GuiIconText() function to automatically prefix the icon using a clear identifier defined in raygui.h.

  9. Apply raygui styles using .rgs files

    master
    To apply a custom UI style to your raygui application, call the GuiLoadStyle() function during initialization. You must pass the path to the .rgs file. These files are binary and contain the necessary font data (glyphs data and glyph atlas image data) required for the style to function.
  10. Apply the ashes style to raygui

    master

    The ashes style can be integrated into a raygui application using several different file formats depending on your project requirements. Choose the format that best fits your deployment strategy:

    • Self-contained (Recommended for easy embedding): Use style_ashes.h to embed the style directly as code. This is self-contained and includes the necessary font data.
    • Binary (raygui 4.0+): Use style_ashes.rgs. This is a binary file with compressed font data (recs, glyphs).
    • Text-based: Use style_ashes.txt.rgs. This is a text style file that does not include font data; you must provide an external font manually.
    • Legacy Binary (raygui 3.x): Use style_ashes.old.rgs. This is a binary file with uncompressed font data.
    • Image-embedded: Use style_ashes.png. This style table image contains an rGSf chunk which holds the binary rgs file data.
  11. Apply the dark style to a raygui application

    master

    You can integrate the 'dark' style into your raygui project using several different methods depending on your requirements for portability, file size, or ease of use.

    Choose one of the following files:

    • style_dark.h: Best for ease of use. It is a self-contained C header file that embeds the style and font data directly into your code.
    • style_dark.rgs: A binary style file (compatible with raygui 4.0) that includes compressed font data.
    • style_dark.txt.rgs: A text-based style file that does not include font data; you must provide an external font.
    • style_dark.old.rgs: A binary style file for older versions (raygui 3.x) with uncompressed font data.
    • style_dark.png: A style table image that contains the binary rgs data within an rGSf chunk.