开发者

Im using SDL and my program use CPU a lot

开发者 https://www.devze.com 2023-01-22 19:23 出处:网络
how can I u开发者_如何学编程se graphic card instead of CPU when I call SDL functions?You cannot, SDL is only a software renderer. However, you can use SDL to create a window, catch events and then you

how can I u开发者_如何学编程se graphic card instead of CPU when I call SDL functions?


You cannot, SDL is only a software renderer. However, you can use SDL to create a window, catch events and then you can perform your drawing using OpenGL.

If your program is eating 100 % CPU, make sure that you limit the FPS correctly (by adding SDL_Delay to the main loop).


If possible, you can use SDL2.0.
That supports Full 3D hardware acceleration using SDL1.2 similar functions.

http://wiki.libsdl.org/MigrationGuide


In SDL 2.0, create your renderer with SDL_RENDERER_ACCELERATED and SDL_RENDERER_PRESENTVSYNC flags. First one implies hardware acceleration when possible, and second limits your program to run 60(depends on monitor's refresh rate) fps at most, thus freeing CPU from continuous work.

0

精彩评论

暂无评论...
验证码 换一张
取 消