raysan5 / raygui

A simple and easy-to-use immediate-mode gui library
zlib License
3.47k stars 298 forks source link

can i use raygui in a vulkan game engine #289

Closed MajidAbdelilah closed 1 year ago

MajidAbdelilah commented 1 year ago

hi! i hope you are doing good i was wondering is it possible to use raygui in my vulkan game engine editor and if so

thanks in advance;

raysan5 commented 1 year ago

@MajidAbdelilah technically it's possible RAYGUI_STANDALONE mode was created for that pourpose... but it has not been done before so it could require some work or even some change to the library to accomodate that option. Afaik, raygui has been mainly used with raylib and it is the default backend.

To use in conjunction with other libraries, you must provide an external set of functions that are required by raygui, basically input functionality and drawing funtionality (rectangles and fonts).

Those are the functions that need to be provided externally (listed on raygui.h):

//----------------------------------------------------------------------------------
// Standalone Mode Functions Declaration
//
// NOTE: raygui depend on some raylib input and drawing functions
// To use raygui as standalone library, below functions must be defined by the user
//----------------------------------------------------------------------------------
#define KEY_RIGHT           262
#define KEY_LEFT            263
#define KEY_DOWN            264
#define KEY_UP              265
#define KEY_BACKSPACE       259
#define KEY_ENTER           257

#define MOUSE_LEFT_BUTTON     0

// Input required functions
//-------------------------------------------------------------------------------
static Vector2 GetMousePosition(void);
static float GetMouseWheelMove(void);
static bool IsMouseButtonDown(int button);
static bool IsMouseButtonPressed(int button);
static bool IsMouseButtonReleased(int button);

static bool IsKeyDown(int key);
static bool IsKeyPressed(int key);
static int GetCharPressed(void);         // -- GuiTextBox(), GuiValueBox()
//-------------------------------------------------------------------------------

// Drawing required functions
//-------------------------------------------------------------------------------
static void DrawRectangle(int x, int y, int width, int height, Color color);        // -- GuiDrawRectangle(), GuiDrawIcon()
static void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4); // -- GuiColorPicker()
//-------------------------------------------------------------------------------

// Text required functions
//-------------------------------------------------------------------------------
static Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int glyphCount); // -- GuiLoadStyle()
static Font GetFontDefault(void);                           // -- GuiLoadStyleDefault()
static Texture2D LoadTextureFromImage(Image image);         // -- GuiLoadStyle()
static void SetShapesTexture(Texture2D tex, Rectangle rec); // -- GuiLoadStyle()
static char *LoadFileText(const char *fileName);            // -- GuiLoadStyle()
static const char *GetDirectoryPath(const char *filePath);  // -- GuiLoadStyle()
//-------------------------------------------------------------------------------
MajidAbdelilah commented 1 year ago

thank you for the information i have found cimgui which is a port of imgui for c and imgui already have support for vulkan but none the less thank you so much for the effort i appreciate it 😄️