When I write my SDL2 OpenGL program somewhat like this (using VSync):
SDL_GL_SetSwapInterval(1);
while(isRunning)
{
while(SDL_PollEvent(&e))
{
if(e.type == SDL_Quit)
{
isRunning = false;
}
}
SDL_GL_SwapWindow(window);
}
my CPU usage goes as high as 39%-50% for this single program which actually does nothing
whereas when I pass sleep time after calculating time difference to SDL_Delay() makes my programming to freeze completely with a 'not responding'.
I do not want to use SDL_WaitEvent() because my program will show animation which will run regardless of input events.
is there any equivalent to pygame's which neither blocks input nor the video thread
fpsClock = pygame.time.Clock()
while(True):
pygame.display.update()
fpsClock.tick(60)