Giter Club home page Giter Club logo

Comments (12)

AsynchronousAI avatar AsynchronousAI commented on June 15, 2024

I tried to do some tests and this is what I changed luaopen_moonglfx

#include <stdio.h>

LUAMOD_API int luaopen_moonglfw(lua_State *L)
/* Lua calls this function to load the module */
    {
    printf("opening moonglfw\n");
    moonglfw_L = L;

    moonglfw_utils_init(L);

    printf("posting enums and getproc\n");
    lua_newtable(L); /* the glfw table */
    moonglfw_open_enums(L);
    moonglfw_open_getproc(L);
    AddVersions(L);

    /* Do not include hats in glfwGetJoystickButtons() if version >= 3.3.0 */
    printf("glfwInitHint\n");
    if(checkminversion(3, 3, 0))
        glfw.InitHint(GLFW_JOYSTICK_HAT_BUTTONS, GLFW_FALSE);

    if(glfw.Init() != GL_TRUE)
        {
        const char *descr;
        glfw.GetError(&descr);
        if(descr) return luaL_error(L, descr);
        return luaL_error(L, "glfwInit() failed");
        }
    atexit(AtExit);
    glfw.SetErrorCallback(errorCallback);

    /* add glfw functions: */
    printf("adding functions\n");
    luaL_setfuncs(L, Functions, 0);
    printf("adding modules\n");
    moonglfw_open_window(L); printf("window\n");
    moonglfw_open_hint(L); printf("hint\n");
    moonglfw_open_monitor(L); printf("monitor\n");
    moonglfw_open_callbacks(L); printf("callbacks\n");
    moonglfw_open_input(L); printf("input\n"); 
    moonglfw_open_context(L); printf("context\n");
    moonglfw_open_vulkan(L); printf("vulkan\n");
    moonglfw_open_native(L); printf("native\n");

    return 1;
    }

It prints everything including "native" so idk where the issue is.

from moonglfw.

AsynchronousAI avatar AsynchronousAI commented on June 15, 2024

I did some more debugging this is causing the error:

if(checkminversion(3, 3, 0))
        glfw.InitHint(GLFW_JOYSTICK_HAT_BUTTONS, GLFW_FALSE);

    if(glfw.Init() != GL_TRUE)
        {
        const char *descr;
        glfw.GetError(&descr);
        if(descr) return luaL_error(L, descr);
        return luaL_error(L, "glfwInit() failed");
        }
    atexit(AtExit);
    glfw.SetErrorCallback(errorCallback);

from moonglfw.

AsynchronousAI avatar AsynchronousAI commented on June 15, 2024

I did even more debugging and the error is in glfw.Init

from moonglfw.

stetre avatar stetre commented on June 15, 2024

Is the segmentation fault within the glfw.Init call, or in the error section that follows?

(Unfortunately I don't have a MacOS system so I can't try it myself)

from moonglfw.

AsynchronousAI avatar AsynchronousAI commented on June 15, 2024

Is the segmentation fault within the glfw.Init call, or in the error section that follows?

(Unfortunately I don't have a MacOS system so I can't try it myself)

I tried recompiling with the error section commented and just a printf("fail"). It still created a segmentation fault.

from moonglfw.

stetre avatar stetre commented on June 15, 2024

Ok, then the segv is likely occurring within glfw.Init, unless for some reason the function pointer itself wasn't loaded properly.

First of all, did the build process go smoothly, with the -DMACOS in place?

from moonglfw.

AsynchronousAI avatar AsynchronousAI commented on June 15, 2024

Yes, Building went well without any errors. The glfw.dylib is located in the cwd and I got it from the official website for the correct architecture.

from moonglfw.

AsynchronousAI avatar AsynchronousAI commented on June 15, 2024

unless for some reason the function pointer itself wasn't loaded properly.

This appears to be the error, If I am correct the Init function is in getproc.c?

from moonglfw.

stetre avatar stetre commented on June 15, 2024

The function pointer stored in glfw.Init is loaded in getproc.c at line 95, using the dlsym function (GET macro defined at line 69). dlsym should return either the valid pointer to glfwInit, or NULL on error. The latter case is guarded against, so either dlsym returns garbage (is it likely? I doubt), or the segv is actually within the glfwInit() call.

from moonglfw.

AsynchronousAI avatar AsynchronousAI commented on June 15, 2024

The problem is inside the glfw.Init function:

if(glfw.Init)
        printf("GLFW version: %s\n", glfw.GetVersionString());
else
        return luaL_error(L, "failed to load the GLFW library");

Outputs GLFW version: 3.3.8 Cocoa NSGL EGL OSMesa dynamic and then Segmentation fault: 11.

I added the code above the glfw.Init call in main.c

from moonglfw.

stetre avatar stetre commented on June 15, 2024

This just shows that glfw.Init is not NULL, which was already guarded against, but it does not guarantee that it is a meaningful function pointer.

Anyway, this puts the segv out of my reach, unfortunately. What I would do now is to try installing GLFW using brew (as opposed to using the downloaded glfw.dylib), following these instructions kindly provided by another MacOS user.

from moonglfw.

AsynchronousAI avatar AsynchronousAI commented on June 15, 2024

Thanks for help.

from moonglfw.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.