问题描述
我使用SDL2编写一个raycasting游戏。
绘制地板时,我需要按像素方式调用SDL_RenderCopy。这会导致瓶颈,使帧速率降至10 fps以下。
我正在寻找性能提升,但似乎找不到一些。
I am programming a raycasting game using SDL2.When drawing the floor, I need to call SDL_RenderCopy pixelwise. This leads to a bottleneck which drops the framerate below 10 fps.I am looking for performance boosts but can't seem to find some.
这里是性能下降的粗略概述:
Here's a rough overview of the performance drop:
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.
- LazyFoo示例 -
li>
- 探索银河 -
- LazyFoo Example -http://lazyfoo.net/tutorials/SDL/42_texture_streaming/index.php
- Exploring Galaxy -http://slouken.blogspot.co.uk/2011/02/streaming-textures-with-sdl-13.html
除了调用 SDL_RenderCopy 480,000次的帧总是会杀死你的帧率。
Other than that calling SDL_RenderCopy 480,000 times a frame is always going to kill your framerate.
这篇关于为什么我的SDL2和SDL_RenderCopy在所有像素的双循环中得到不良的性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!