sdl-2

SDL_PollEvent() stuttering while idle?

不羁岁月 提交于 2019-11-26 16:37:31
问题 I've cobbled together a very basic game loop in C++ using SDL2, and I've noticed that every few seconds, SDL_PollEvent seems to be unusually slow, even when nothing is happening. I sent my deltaTime to console every loop, and its about 100ms difference on the cycles that SDL_PollEvent is lagging. I've already confirmed that it's something with this function by moving my timers around, but I'm not sure where to diagnose the issue further. My loop: while (!quit) { uint32_t startTime = SDL

Difference between surface and texture (SDL / general)

 ̄綄美尐妖づ 提交于 2019-11-26 15:22:50
问题 Can anyone explain to me in simple words what is the difference between texture and surface? I saw it used in SDL2 as SDL_Surface and SDL_Texture . SDL_Texture is created from SDL_Surface which in turn is created from image/bitmap. Both are collection of pixels. But I do not see the main difference between them (has to do something with GPU?) I tried to google it but all explanations I found were too complex to understand them without digging deeper into computer graphics stuff. 回答1:

SDL2: Fast Pixel Manipulation

谁都会走 提交于 2019-11-26 13:52:51
问题 I want to draw pixels on the monitor which change frequently after certain parameters. E.G. if a Red and Green Pixel collide, they would both vanish, etc. In every frame I have to manipulate about 100 - 1000 pixels. I have a multi-threaded approach here, which wont give me 30FPS (what I want). Currently I store a Pixel array in the RAM which contains all Pixels and have a SDL_Surface . When a pixel in the array changes, it gets changed in the Surface too and is then after all manipulation is