Replaced SDL_UpdateTexture with SDL_LockTexture.
The SDL wiki indicates that this is the preferred way to do this for textures like renderer_texture that are updated often, since it is faster.
This commit is contained in:
parent
5434ce43c4
commit
c323e17c2e
|
@ -2661,12 +2661,12 @@ int game_mainLoop()
|
|||
if ((game.area == MISN_MARS) && (engine.addAliens > -1))
|
||||
{
|
||||
if ((rand() % 5) == 0)
|
||||
// XXX: The originally specified range for x was [800, 100],
|
||||
// Note: The originally specified range for x was [800, 100],
|
||||
// which with the original rrand function caused the result
|
||||
// returned to be `800 + rand() % -699`. Clearly a mistake,
|
||||
// but I'm not entirely sure what the original intention was.
|
||||
// For now, I've set the range to [800, 1500], which
|
||||
// approximately replicates the original's results.
|
||||
// I've set the range to [800, 1500] (modified for screen
|
||||
// width), which approximately replicates the original's results.
|
||||
collectable_add(screen->w + RANDRANGE(0, 700),
|
||||
RANDRANGE(-screen->h / 3, (4 * screen->h) / 3), P_MINE, 25,
|
||||
180 * screen->w / 800 + RANDRANGE(0, 60));
|
||||
|
|
|
@ -30,11 +30,9 @@ SDL_Texture *renderer_texture;
|
|||
|
||||
void renderer_update()
|
||||
{
|
||||
// XXX: The SDL wiki says that SDL_UpdateTexture is slow and shouldn't
|
||||
// be used for textures that are updated often. This should be looked
|
||||
// into.
|
||||
SDL_UpdateTexture(renderer_texture, NULL, screen->pixels, screen->w * 4);
|
||||
SDL_LockTexture(renderer_texture, NULL, &(screen->pixels), &(screen->pitch));
|
||||
SDL_RenderCopy(renderer, renderer_texture, NULL, NULL);
|
||||
SDL_UnlockTexture(renderer_texture);
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue