title: SDL Image display slower then wanted
body: <p>I want to use SDL2 to display a list of rgb values I have in memory to the screen. But my issue is that to update the screen for even a modestly sized image it takes a long time to preform.
  On my laptop the example code takes 11.8 milliseconds to update the screen. Which would mean if you wanted a 60fps output it would only leave 4.2 milliseconds to do everything else.
  Don't know what other method to use to display a image.</p>
  <hr />
  <pre><code>//gcc -Ofast -g &quot;%f&quot; `pkg-config --cflags --libs sdl2` -o SDL_test_3
  #include &lt;SDL2/SDL.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;time.h&gt;
  
  //====---The_General_Use_Variables---====
  unsigned char uc1;
  
  long l1;
  
  float f1;
  float f2;
  float f3;
  float t1;
  float t2;
  
  
  
  
  int main(){
      int sx=1000;
      int sy=700;
      int did_work;
      
      //initilizes SDL
      did_work=SDL_Init(SDL_INIT_VIDEO);
      if (did_work!=0){printf(&quot;Issue_in_SDL_Init\n&quot;);}
  
      //Creates a window
      SDL_Window *window=NULL;
      window = SDL_CreateWindow( &quot;win1&quot;, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, sx, sy, SDL_WINDOW_SHOWN );
  
      //for a window to be on screen you need to be constantly monitering for window events
      SDL_Event windowEvent;
      if (!window){printf(&quot;SDL_CreateWindow_failed\n&quot;);}
  
      //assigned the window a surface
      SDL_Surface *screenSurface;
      screenSurface=SDL_GetWindowSurface(window);
  
      //creates a im_buffer
      unsigned char *im_buffer;im_buffer=malloc(sx*sy*3*sizeof(unsigned char));
      for(l1=0;l1&lt;sx*sy*3;l1++){im_buffer[l1]=0;}
  
      //creates a screensurface with the im_buffer painted on it
      SDL_Surface *im_surface = SDL_CreateRGBSurfaceFrom((void*)im_buffer,
              sx,
              sy,
              24,          // bits per pixel = 24
              sx*3,  // pitch
              0x0000FF,              // red mask
              0x00FF00,              // green mask
              0xFF0000,              // blue mask
              0);
  
      
      //this command copys the im_buffer's window surface to the displayed window surface
      SDL_BlitSurface(im_surface, NULL, screenSurface, NULL);
      SDL_UpdateWindowSurface(window);
      
      //setting up for loop
      int seconds=5;
      t1=clock();
      t1+=CLOCKS_PER_SEC*seconds;
      t2=clock();
      long counter=0;
      
      uc1=0;
      while(t2&lt;t1){
          uc1++;
          counter++;
          SDL_PollEvent(&amp;windowEvent);
          
          for(l1=0;l1&lt;sx*sy*3;l1+=3){im_buffer[l1]=uc1;}
          im_surface=SDL_CreateRGBSurfaceFrom((void*)im_buffer,
              sx,
              sy,
              24,          // bits per pixel = 24
              sx*3,  // pitch
              0x0000FF,              // red mask
              0x00FF00,              // green mask
              0xFF0000,              // blue mask
              0);
          
          SDL_BlitSurface(im_surface, NULL, screenSurface, NULL);
          SDL_UpdateWindowSurface(window);
          
          t2=clock();
          }
      f1=counter;
      f2=seconds;
      printf(&quot;average_fps=%f \n&quot;,f1/f2);
      printf(&quot;frametime=%f \n&quot;,1000*f2/f1);
  }
  </code></pre>
  <hr />