当我调用glfwCreateWindow
时DllMain
,程序冻结,CPU 使用率降至 0%。
如果我将程序类型从 更改为.dll
并.exe
替换为 ,DllMain
我的代码可以正常工作main
。
这是我的代码的一部分:
BOOL WINAPI DllMain(
HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpReserved)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
{
std::cout << "glfw init failed" << std::endl;
return;
}
std::cout << "1" << std::endl;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
std::cout << "window creation failed" << std::endl;
glfwTerminate();
return;
}
std::cout << "2" << std::endl;
/* Make the window's context current */
glfwMakeContextCurrent(window);
return TRUE;
}
当我运行程序时,会打印 1,但是程序会冻结并且永远不会打印 2。