cococry / leif

Minimal, configurable & GPU accelerated Immediate Mode UI Library written with modern OpenGL
836 stars 36 forks source link

[LEIF ERROR]: Failed to reallocate memory for stack datastructure. #24

Closed alisherabdimuminov closed 1 month ago

alisherabdimuminov commented 2 months ago

I have a this code

#include <GL/gl.h>
#include <GLFW/glfw3.h>
#include <leif/leif.h>

int main() {
    glfwInit();

    GLFWwindow* window = glfwCreateWindow(1280, 720, "Todo", NULL, NULL);

    glfwMakeContextCurrent(window);

    while (!glfwWindowShouldClose(window))
    {
        glClear(GL_COLOR_BUFFER_BIT);
        glClearColor(0.1f, 0.1f, 0.1f, 1.0f);

        lf_begin();
        // lf_text("Salom");
        lf_end();

        glfwPollEvents();
        glfwSwapBuffers(window);
    }

    glfwDestroyWindow(window);
    glfwTerminate();
    return 0;
}

and I compile gcc -o todo main.c -lglfw -lGL -lleif -lclipboard -lxcb -lm and run ./todo it. I came across bug like

[LEIF ERROR]: Failed to reallocate memory for stack datastructure.
Segmentation fault (core dumped)

how to fix it?

FilipyTav commented 2 months ago

You forgot to initialize leif after glfwMakeContextCurrent().

lf_init_glfw(uint32_t display_width, uint32_t display_height, void* glfw_window);
alisherabdimuminov commented 2 months ago

Yeah, thanks bro!