Hello I I ran into a bug called Frame Not in Module under Release when I was using VS2019. It’s OK when I was trying to build it under Debug.
I’m using GLFW3 and glad with derect_state_access and debug_output. Actually I dont think this is the problem. I fought with this bug line by line and I’m sure I found it. Howerver I cannot solve it.
It’s OK when I worte these lines in main function:
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
//constexpr unsigned int width = 1000;
//constexpr unsigned int height = 1000;
GLFWwindow *window = glfwCreateWindow(width, height, "a random name", nullptr, nullptr);
assert(m_window != nullptr);
glfwMakeContextCurrent(window);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
asset(gladLoadGLLoader((GLADloadproc)glfwGetProcAddress));
#ifdef _DEBUG
glEnable(GL_DEBUG_OUTPUT);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
glDebugMessageCallback(debug_message_callback, nullptr);
#endif
glEnable(GL_DEPTH_TEST);
These code are just initializing a window that would be used in my project. It’s OK.
But when I was trying to encapsulate these code, strange things happened.
void Window::init(){
glfwInit();
//OpenGL 4.5
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
m_window = glfwCreateWindow(m_screen_width, m_screen_height, "myname", nullptr, nullptr);
//m_window not nullptr
assert(m_window != nullptr);
glfwMakeContextCurrent(m_window);
/*
* glfwSetWindowUserPointer
* glfwGetWindowUserPointer
* set -> get
* used in callback functions
*/
glfwSetWindowUserPointer(m_window, this);
//callback functions
//framebuffer size callback
auto framebuffer_size_callback = [](GLFWwindow* window, int width, int height) {
glViewport(0, 0, width, height);
};
glfwSetFramebufferSizeCallback(m_window, framebuffer_size_callback);
glfwSetInputMode(m_window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
//check glad
assert(gladLoadGLLoader((GLADloadproc)glfwGetProcAddress));
....
}
and this will be called in constructor of class Window.
Window::Window()
{
...
init();
...
}
auto window = std::make_unique<Window>(...);
These code are just not in main function and I checked that I didn’t miss anything. Then whatever I do I ran into a bug called Frame Not in Module under Release. I tried like some simple openGL api like glGenFramebuffers, there will always be:
Exception thrown at 0x0000000000000000 in test.exe: 0xC0000005: Access violation executing location 0x0000000000000000.
This is strange because I found guys in github wrote similar code and it’s just OK. I build my whole project under Debug and it works well.