Данный SDL_Renderer
будет поддерживать хотя бы один SDL_PixelFormatEnum
;Другие форматы будут работать, но могут повлечь за собой штраф за конвертацию при создании и / или использовании.
Используйте SDL_GetRendererInfo()
для заполнения SDL_RendererInfo
и используйте один из форматов в SDL_RendererInfo::texture_formats
(из здесь ):
SDL_RendererInfo info;
SDL_GetRendererInfo( renderer, &info );
cout << "Renderer name: " << info.name << endl;
cout << "Texture formats: " << endl;
for( Uint32 i = 0; i < info.num_texture_formats; i++ )
{
cout << SDL_GetPixelFormatName( info.texture_formats[i] ) << endl;
}
Назад, когда я запустил, что оба бэкэнда DirectX и OpenGL поддерживали SDL_PIXELFORMAT_ARGB8888
.
Двойная проверка кода SDL через git grep -A 25 SDL_RenderDriver
Я думаю, что первый texture_formats
является «предпочтительным» форматом:
SDL_render_d3d.c:SDL_RenderDriver D3D_RenderDriver = {
SDL_render_d3d.c- D3D_CreateRenderer,
SDL_render_d3d.c- {
SDL_render_d3d.c- "direct3d",
SDL_render_d3d.c- (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
SDL_render_d3d.c- 1,
SDL_render_d3d.c- {SDL_PIXELFORMAT_ARGB8888},
SDL_render_d3d.c- 0,
SDL_render_d3d.c- 0}
--
SDL_render_d3d11.c:SDL_RenderDriver D3D11_RenderDriver = {
SDL_render_d3d11.c- D3D11_CreateRenderer,
SDL_render_d3d11.c- {
SDL_render_d3d11.c- "direct3d11",
SDL_render_d3d11.c- (
SDL_render_d3d11.c- SDL_RENDERER_ACCELERATED |
SDL_render_d3d11.c- SDL_RENDERER_PRESENTVSYNC |
SDL_render_d3d11.c- SDL_RENDERER_TARGETTEXTURE
SDL_render_d3d11.c- ), /* flags. see SDL_RendererFlags */
SDL_render_d3d11.c- 6, /* num_texture_formats */
SDL_render_d3d11.c- { /* texture_formats */
SDL_render_d3d11.c- SDL_PIXELFORMAT_ARGB8888,
SDL_render_d3d11.c- SDL_PIXELFORMAT_RGB888,
SDL_render_d3d11.c- SDL_PIXELFORMAT_YV12,
SDL_render_d3d11.c- SDL_PIXELFORMAT_IYUV,
SDL_render_d3d11.c- SDL_PIXELFORMAT_NV12,
SDL_render_d3d11.c- SDL_PIXELFORMAT_NV21
SDL_render_d3d11.c- },
SDL_render_d3d11.c- 0, /* max_texture_width: will be filled in later */
SDL_render_d3d11.c- 0 /* max_texture_height: will be filled in later */
SDL_render_d3d11.c- }
SDL_render_d3d11.c-};
--
SDL_render_metal.m:SDL_RenderDriver METAL_RenderDriver = {
SDL_render_metal.m- METAL_CreateRenderer,
SDL_render_metal.m- {
SDL_render_metal.m- "metal",
SDL_render_metal.m- (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
SDL_render_metal.m- 6,
SDL_render_metal.m- {
SDL_render_metal.m- SDL_PIXELFORMAT_ARGB8888,
SDL_render_metal.m- SDL_PIXELFORMAT_ABGR8888,
SDL_render_metal.m- SDL_PIXELFORMAT_YV12,
SDL_render_metal.m- SDL_PIXELFORMAT_IYUV,
SDL_render_metal.m- SDL_PIXELFORMAT_NV12,
SDL_render_metal.m- SDL_PIXELFORMAT_NV21
SDL_render_metal.m- },
SDL_render_metal.m- 0, 0,
SDL_render_metal.m- }
SDL_render_metal.m-};
--
SDL_render_gl.c:SDL_RenderDriver GL_RenderDriver = {
SDL_render_gl.c- GL_CreateRenderer,
SDL_render_gl.c- {
SDL_render_gl.c- "opengl",
SDL_render_gl.c- (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
SDL_render_gl.c- 1,
SDL_render_gl.c- {SDL_PIXELFORMAT_ARGB8888},
SDL_render_gl.c- 0,
SDL_render_gl.c- 0}
SDL_render_gl.c-};
--
SDL_render_gles.c:SDL_RenderDriver GLES_RenderDriver = {
SDL_render_gles.c- GLES_CreateRenderer,
SDL_render_gles.c- {
SDL_render_gles.c- "opengles",
SDL_render_gles.c- (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
SDL_render_gles.c- 1,
SDL_render_gles.c- {SDL_PIXELFORMAT_ABGR8888},
SDL_render_gles.c- 0,
SDL_render_gles.c- 0
SDL_render_gles.c- }
SDL_render_gles.c-};
--
SDL_render_gles2.c:SDL_RenderDriver GLES2_RenderDriver = {
SDL_render_gles2.c- GLES2_CreateRenderer,
SDL_render_gles2.c- {
SDL_render_gles2.c- "opengles2",
SDL_render_gles2.c- (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
SDL_render_gles2.c- 4,
SDL_render_gles2.c- {
SDL_render_gles2.c- SDL_PIXELFORMAT_ARGB8888,
SDL_render_gles2.c- SDL_PIXELFORMAT_ABGR8888,
SDL_render_gles2.c- SDL_PIXELFORMAT_RGB888,
SDL_render_gles2.c- SDL_PIXELFORMAT_BGR888
SDL_render_gles2.c- },
SDL_render_gles2.c- 0,
SDL_render_gles2.c- 0
SDL_render_gles2.c- }
SDL_render_gles2.c-};
--
SDL_render_psp.c:SDL_RenderDriver PSP_RenderDriver = {
SDL_render_psp.c- .CreateRenderer = PSP_CreateRenderer,
SDL_render_psp.c- .info = {
SDL_render_psp.c- .name = "PSP",
SDL_render_psp.c- .flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE,
SDL_render_psp.c- .num_texture_formats = 4,
SDL_render_psp.c- .texture_formats = { [0] = SDL_PIXELFORMAT_BGR565,
SDL_render_psp.c- [1] = SDL_PIXELFORMAT_ABGR1555,
SDL_render_psp.c- [2] = SDL_PIXELFORMAT_ABGR4444,
SDL_render_psp.c- [3] = SDL_PIXELFORMAT_ABGR8888,
SDL_render_psp.c- },
SDL_render_psp.c- .max_texture_width = 512,
SDL_render_psp.c- .max_texture_height = 512,
SDL_render_psp.c- }
SDL_render_psp.c-};
--
SDL_render_sw.c:SDL_RenderDriver SW_RenderDriver = {
SDL_render_sw.c- SW_CreateRenderer,
SDL_render_sw.c- {
SDL_render_sw.c- "software",
SDL_render_sw.c- SDL_RENDERER_SOFTWARE | SDL_RENDERER_TARGETTEXTURE,
SDL_render_sw.c- 8,
SDL_render_sw.c- {
SDL_render_sw.c- SDL_PIXELFORMAT_ARGB8888,
SDL_render_sw.c- SDL_PIXELFORMAT_ABGR8888,
SDL_render_sw.c- SDL_PIXELFORMAT_RGBA8888,
SDL_render_sw.c- SDL_PIXELFORMAT_BGRA8888,
SDL_render_sw.c- SDL_PIXELFORMAT_RGB888,
SDL_render_sw.c- SDL_PIXELFORMAT_BGR888,
SDL_render_sw.c- SDL_PIXELFORMAT_RGB565,
SDL_render_sw.c- SDL_PIXELFORMAT_RGB555
SDL_render_sw.c- },
SDL_render_sw.c- 0,
SDL_render_sw.c- 0}
SDL_render_sw.c-};
--
SDL_DirectFB_render.c:SDL_RenderDriver DirectFB_RenderDriver = {
SDL_DirectFB_render.c- DirectFB_CreateRenderer,
SDL_DirectFB_render.c- {
SDL_DirectFB_render.c- "directfb",
SDL_DirectFB_render.c- (SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
SDL_DirectFB_render.c- /* (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
SDL_DirectFB_render.c- SDL_TEXTUREMODULATE_ALPHA),
SDL_DirectFB_render.c- (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND |
SDL_DirectFB_render.c- SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
SDL_DirectFB_render.c- (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST |
SDL_DirectFB_render.c- SDL_SCALEMODE_SLOW | SDL_SCALEMODE_BEST), */
SDL_DirectFB_render.c- 0,
SDL_DirectFB_render.c- {
SDL_DirectFB_render.c- /* formats filled in later */
SDL_DirectFB_render.c- },
SDL_DirectFB_render.c- 0,
SDL_DirectFB_render.c- 0}
SDL_DirectFB_render.c-};