opengl3+glfw+glad it is error #2806

Closed
opened 2019-09-25 15:13:07 +00:00 by bizehao · 3 comments
bizehao commented 2019-09-25 15:13:07 +00:00 (Migrated from github.com)

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

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 commented 2019-09-26 01:15:44 +00:00 (Migrated from github.com)

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);
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: ``` cpp glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); ``` to ``` cpp glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); ``` below I add my initialization: it works with GLFW and GLAD ```cpp 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 commented 2019-09-26 03:19:14 +00:00 (Migrated from github.com)

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.

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 commented 2019-09-26 05:52:52 +00:00 (Migrated from github.com)

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

@BrutPitt Change the version of the statement by using your method glad. it is success, Thank you.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#2806
No description provided.