參考資訊:
https://stackoverflow.com/questions/33304351/sdl2-fast-pixel-manipulation
使用如下程式查找支援的格式:
SDL_RendererInfo info; SDL_GetRendererInfo(renderer, &info); std::cout << "Renderer name: " << info.name << std::endl; std::cout << "Texture formats: " << std::endl; for(Uint32 i=0; i<info.num_texture_formats; i++) { std::cout << SDL_GetPixelFormatName( info.texture_formats[i] ) << std::endl; }
得到如下資訊:
SDL_PIXELFORMAT_ARGB8888 SDL_PIXELFORMAT_ABGR8888 SDL_PIXELFORMAT_RGB888 SDL_PIXELFORMAT_BGR888 SDL_PIXELFORMAT_YV12 SDL_PIXELFORMAT_IYUV SDL_PIXELFORMAT_NV12 SDL_PIXELFORMAT_NV21 SDL_PIXELFORMAT_UNKNOWN
P.S. 司徒這時候才發現,原來SDL_PIXELFORMAT_RGB565並沒有支援,這部分的轉換是由CPU完成,導致效能下降,改成SDL_PIXELFORMAT_ARGB8888後,即可解決問題