当我在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永远不会被打印。
发布于 2022-01-24 17:48:57
有一个非常,您可以在DllMain中做的事情非常有限,如详细的这里。
你得想办法把电话推迟到GLFW。也许对DLL的显式初始化调用是可行的。
https://stackoverflow.com/questions/70837661
复制相似问题