Skip to main content
added 145 characters in body
Source Link
Jon
  • 3.7k
  • 1
  • 14
  • 23

You need to move all the SDL functions out of the compound for loop.

for 
{ 
 for
 {
   pixels[y*width+x] = argb;}}
   //Update allUpdating pixelthem valuesall at once should be fine
   //ThenNothing else can happen while this is running
 }
}
//Update entire array at once, then...
SDL_UpdateTexture(texture, NULL, pixels, width * 4); //Copy entire array only once
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);

You need to move all the SDL functions out of the compound for loop.

for{for{pixels[y*width+x] = argb;}} //Update all pixel values at once
//Then...
SDL_UpdateTexture(texture, NULL, pixels, width * 4); //Copy entire array only once
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);

You need to move all the SDL functions out of the compound for loop.

for 
{ 
 for
 {
   pixels[y*width+x] = argb;
   //Updating them all at once should be fine
   //Nothing else can happen while this is running
 }
}
//Update entire array at once, then...
SDL_UpdateTexture(texture, NULL, pixels, width * 4); //Copy entire array only once
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);
Source Link
Jon
  • 3.7k
  • 1
  • 14
  • 23

You need to move all the SDL functions out of the compound for loop.

for{for{pixels[y*width+x] = argb;}} //Update all pixel values at once
//Then...
SDL_UpdateTexture(texture, NULL, pixels, width * 4); //Copy entire array only once
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);