Why do I get bad performance with SDL2 and SDL_RenderCopy inside a double for loop over all pixels?

帅比萌擦擦* 提交于 2019-11-29 11:10:58

You should probably be using texture streaming for this. Basically you will create an SDL_Texture of type SDL_TEXTUREACCESS_STREAMING and then each frame you 'lock' the texture, update the pixels that you require then 'unlock' the texture again. The texture is then rendered in a single SDL_RenderCopy call.

Other than that calling SDL_RenderCopy 480,000 times a frame is always going to kill your framerate.

frkk

You are calling SDL_RenderCopy() in each frame so 600 * 800 = 480 000 times! It is normal for performance to drop.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!