Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opengl3+glfw+glad it is error #2806

Closed
bizehao opened this issue Sep 25, 2019 · 3 comments
Closed

opengl3+glfw+glad it is error #2806

bizehao opened this issue Sep 25, 2019 · 3 comments

Comments

@bizehao
Copy link

bizehao commented Sep 25, 2019

I am Chinese,Maybe my English is a little bad. i am sorry
I've been tested.

target_link_libraries(ImguiTest PRIVATE gl3w)
#target_link_libraries(ImguiTest PRIVATE GLEW::GLEW)
#target_link_libraries(ImguiTest PRIVATE glad)

opengl3+glfw+gl3w and opengl3+glfw+glew are Perfect operation,
but opengl3+glfw+glad it is error, and it is show "Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)" and I don't understand
I debug it , it may be glBindSampler() , I Uncertain

@BrutPitt
Copy link

BrutPitt commented Sep 26, 2019

Hi, @bizehao.
You should be a little more specific... so it's hard to help you...

Anyway...
Usually this happens (with glad) when you call a function not present in the declared context profile:
e.g. if you declare a 3.0 GL/GLFW context and then you call a glBindSampler (it belong to OpenGL 3.2) you call a function whose "address / pointer" is not loaded (valid).

In this case (if the case is this) would be enough change the GLFW context initialization from:

    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);

to

    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);

below I add my initialization: it works with GLFW and GLAD

    glfwSetErrorCallback(glfwErrorCallback);

    if (!::glfwInit()) exit(EXIT_FAILURE);

// I use 4.5 context (or 4.1 on APPLE), but you can change it to 3.3 if need it
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
#ifdef APP_REQUIRE_OGL45
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5);
#else
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
#endif
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE);
    glfwWindowHint(GLFW_DOUBLEBUFFER, GL_TRUE);
    
    setGLFWWnd(glfwCreateWindow(GetWidth(), GetHeight(), getWindowTitle(), NULL, NULL));
    if (!getGLFWWnd())
    {
        glfwTerminate();
        exit(EXIT_FAILURE);
    }

    glfwMakeContextCurrent(getGLFWWnd());

    //Init GLAD
    gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);

    glfwSetWindowSizeCallback(getGLFWWnd(), glfwWindowSizeCallback);

    glfwSwapInterval(1);

@bizehao
Copy link
Author

bizehao commented Sep 26, 2019

thank you
I'll try your solution later.
I was going to build a cross-platform system, but there will be a lack of DLL running on Win10. So for the time being, I use directx12 on Windows and the combination of OpenGL + glfw + glew on linux. Thank you very much.

@bizehao
Copy link
Author

bizehao commented Sep 26, 2019

@BrutPitt Change the version of the statement by using your method glad. it is success, Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants