
After discussion with @ocornut, SDL_RenderGeometryRaw() will take floating point colors and conversion from 8-bit color can happen on the application side. We can always add an 8-bit color fast path in the future if we need it on handheld platforms. If you need code to do this in your application, you can use the following: int SDL_RenderGeometryRaw8BitColor(SDL_Renderer *renderer, SDL_Texture *texture, const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, int num_vertices, const void *indices, int num_indices, int size_indices) { int i, retval, isstack; const Uint8 *color2 = (const Uint8 *)color; SDL_FColor *color3; if (num_vertices <= 0) { return SDL_InvalidParamError("num_vertices"); } if (!color) { return SDL_InvalidParamError("color"); } color3 = (SDL_FColor *)SDL_small_alloc(SDL_FColor, num_vertices, &isstack); if (!color3) { return -1; } for (i = 0; i < num_vertices; ++i) { color3[i].r = color->r / 255.0f; color3[i].g = color->g / 255.0f; color3[i].b = color->b / 255.0f; color3[i].a = color->a / 255.0f; color2 += color_stride; color = (const SDL_Color *)color2; } retval = SDL_RenderGeometryRaw(renderer, texture, xy, xy_stride, color3, sizeof(*color3), uv, uv_stride, num_vertices, indices, num_indices, size_indices); SDL_small_free(color3, isstack); return retval; } Fixes https://github.com/libsdl-org/SDL/issues/9009
…
…
…
Simple DirectMedia Layer (SDL) Version 3.0
Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware. It is used by video playback software, emulators, and popular games including Valve's award winning catalog and many Humble Bundle games.
More extensive documentation is available in the docs directory, starting with README.md. If you are migrating to SDL 3.0 from SDL 2.0, the changes are extensively documented in README-migration.md.
Enjoy!
Sam Lantinga (slouken@libsdl.org)
Description
Languages
C
90.3%
Objective-C
3.5%
C++
1.7%
CMake
1.7%
Java
0.8%
Other
1.8%