opengl + native sdk, Why "IntegrationGLUT" sample High CPU usage when running
Hello, everyone:
I have tried multiple versions of native SDK + opengl on windows, integrated glud or glfw, x86 or x64, and finally the generated exe has a high CPU usage when it runs.
But after the other samples are compiled, the CPU usage is very, very low, most of the time 0%.
Why is that?
How do I fix this?
I have tried multiple versions of native SDK + opengl on windows, integrated glud or glfw, x86 or x64, and finally the generated exe has a high CPU usage when it runs.
But after the other samples are compiled, the CPU usage is very, very low, most of the time 0%.
Why is that?
How do I fix this?
Re: opengl + native sdk, Why "IntegrationGLUT" sample High CPU usage when running
The IntegrationGLUT example is always using OpenGL while the other examples take by default Direct3D (you can override this with --render GL). For some reasons, your GL driver is disabling vsync, this could be the reason of high cpu usage. You can debug the source code of GLRenderContext, the Init() function take the boolean vsync for enabling vertical sync.
Re: opengl + native sdk, Why "IntegrationGLUT" sample High CPU usage when running
After testing, it is indeed a problem with vsync.The IntegrationGLUT example is always using OpenGL while the other examples take by default Direct3D (you can override this with --render GL). For some reasons, your GL driver is disabling vsync, this could be the reason of high cpu usage. You can debug the source code of GLRenderContext, the Init() function take the boolean vsync for enabling vertical sync.
I switched to GLFW,
add under line code,
Code: Select all
glfwSwapInterval(1);
Thanks very much!
Re: opengl + native sdk, Why "IntegrationGLUT" sample High CPU usage when running
Our GLUT implementation in the IntegrationGLUT sample is already doing:
I assume this was not working on your machine?
Code: Select all
typedef BOOL (WINAPI *PFNWGLSWAPINTERVALEXTPROC)(int);
PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = 0;
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
if (wglSwapIntervalEXT != 0)
{
wglSwapIntervalEXT(1);
}
Re: opengl + native sdk, Why "IntegrationGLUT" sample High CPU usage when running
Yes, this didn't work under GLUT, so I switched to GLFWOur GLUT implementation in the IntegrationGLUT sample is already doing:
I assume this was not working on your machine?Code: Select alltypedef BOOL (WINAPI *PFNWGLSWAPINTERVALEXTPROC)(int); PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = 0; wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); if (wglSwapIntervalEXT != 0) { wglSwapIntervalEXT(1); }
Who is online
Users browsing this forum: Ahrefs [Bot], gvol1 and 2 guests