finetune.md 2.1 KB

Fine Tuning

Base

You can tweak SMGUI by providing some define before you include ui.h.

UI_IMPLEMENTATION

WARN: Only define this after you have included the modules.

Set this if you want to include not just the definitions but the implementation too.

UI_NOAA

Disable anti-aliased lines (eliminates math.h and libm dependency).

UI_MAXEVENTS

Set the maximum number of pending events. If not defined otherwise, defaults to 16.

UI_MAXPOPUPS

Set the maximum number of visible popups. If not defined otherwise, defaults to 16.

UI_BACKEND_INITIALIZED

Set if you want to call glfwInit() / glfwTerminate(), SDL_Init() / SDL_Quit() etc. yourself. This is needed if you want SMGUI to handle multiple windows.

UI_BACKEND_NOFLUSH

Set if you don't want ui_event() to flush the window, and you call glfwSwapBuffers() / SDL_RenderPresent() / etc. yourself. This is needed if you want to draw over the UI layer.

GLFW3

Separately you can tweak the GLFW3 backend by providing some define before you include ui_glfw.h.

By default, this backend is compiled with shaders for OpenGL3.3 core profile with both glad and glew extension loader support.

UI_GLFW_NOSHADER

Use old-school OpenGL API. This works everywhere and requires no extension loader nor shaders. The downside is, that some video card drivers are buggy and break backward compatibility, so you won't be able to use your own shaders either with this option.

UI_GLFW_GLES2

Use shaders, but only OpenGL ES 2.0 (mobile platform variant). For supporting legacy mobiles only, most modern devices have no issues using OpenGL 3.3 core.

UI_GLFW_CUSTOMHOOKS

If you want to use your own GLFW3 hooks, then define this, and also call the backend's hooks from your hooks. For example:

/* set your hook as usual */
glfwSetMouseButtonCallback(ui_getwindow(ctx), my_glfw_mouse);

/* your hook */
void my_glfw_mouse(GLFWwindow *window, int button, int action, int mods)
{
    /* parse what you want */
        /* ... */
    /* at the end also call the ui_glfw's hook */
    ui_glfw_mouse(window, button, action, mods);
}