             }
         }
         draw_background(renderer, w, h);
-        SDL_RenderCopy(renderer, texture, NULL, NULL);
+        SDL_RenderCopy(renderer, img_texture, NULL, NULL);
         SDL_RenderPresent(renderer);
 
         SDL_Delay(100);
     }
 
     SDL_FreeSurface(img_surface);
-    SDL_DestroyTexture(texture);
+    SDL_DestroyTexture(img_texture);
     SDL_DestroyWindow(window);
     SDL_DestroyRenderer(renderer);
     SDL_Quit();


    printf("*** Time: %f\n", (float)(clock() - clk) / CLOCKS_PER_SEC);

    texture = SDL_CreateTextureFromSurface(renderer, img_surface);
    if (!texture)
    {
        fprintf(stderr, "Couldn't create texture from surface!\n");
        return -1;
    }
    SDL_QueryTexture(texture, NULL, NULL, &w, &h);

    SDL_SetWindowTitle(window, img_name);
    SDL_SetWindowSize(window, w, h);

        fprintf(stderr, "Failed to load %s.\n", img_name);
        return -3;
    }
    w = img_surface->w;
    h = img_surface->h;

    clk = clock();

    size = w * h * sizeof(uint32_t);
    cudaMalloc((void**)&dev_buf, size);

    cudaMemcpy(dev_buf, img_surface->pixels, size, cudaMemcpyHostToDevice);

    block_per_grid.x = w / thrd_per_block.x;
    block_per_grid.y = h / thrd_per_block.y;
    monochrome<<<block_per_grid, thrd_per_block, 0>>>(dev_buf, w, h);
    cudaDeviceSynchronize();

    cudaMemcpy(img_surface->pixels, dev_buf, size, cudaMemcpyDeviceToHost);
