sdlxRenderGeometryRaw function render
- Pointer<
SdlRenderer> renderer, - List<
SdlxFPoint> positions, { - Pointer<
SdlTexture> ? texture, - List<
SdlxFColor> ? colors, - List<
SdlxFPoint> ? texCoords, - List<
int> ? indices,
Render a list of triangles, optionally using a texture and indices into the vertex arrays.
Color and alpha modulation is done per vertex (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
\param renderer the rendering context. \param texture (optional) The SDL texture to use. \param xy vertex positions. \param xy_stride byte size to move from one element to the next element. \param color vertex colors (as SDL_FColor). \param color_stride byte size to move from one element to the next element. \param uv vertex normalized texture coordinates. \param uv_stride byte size to move from one element to the next element. \param num_vertices number of vertices. \param indices (optional) An array of indices into the 'vertices' arrays, if NULL all vertices will be rendered in sequential order. \param num_indices number of indices. \param size_indices index size: 1 (byte), 2 (short), 4 (int). \returns true on success or false on failure; call SDL_GetError() for more information.
\threadsafety This function should only be called on the main thread.
\since This function is available since SDL 3.2.0.
\sa SDL_RenderGeometry \sa SDL_SetRenderTextureAddressMode
extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer, SDL_Texture *texture, const float *xy, int xy_stride, const SDL_FColor *color, int color_stride, const float *uv, int uv_stride, int num_vertices, const void *indices, int num_indices, int size_indices)
See also:
Implementation
bool sdlxRenderGeometryRaw(
Pointer<SdlRenderer> renderer,
List<SdlxFPoint> positions, {
Pointer<SdlTexture>? texture,
List<SdlxFColor>? colors,
List<SdlxFPoint>? texCoords,
List<int>? indices,
}) {
if (positions.isEmpty) {
return true;
}
final positionsPointer = positions.callocXy();
Pointer<SdlFColor> colorsPointer = nullptr;
Pointer<Float> texCoordsPointer = nullptr;
Pointer<Int32> indicesPointer = nullptr;
var numIndices = 0;
if (colors != null) {
colorsPointer = colors.calloc();
}
if (texCoords != null) {
texCoordsPointer = texCoords.callocXy();
}
if (indices != null) {
numIndices = indices.length;
indicesPointer = ffi.calloc<Int32>(numIndices);
indicesPointer.asTypedList(numIndices).setAll(0, indices);
}
final result = sdlRenderGeometryRaw(
renderer,
texture ?? nullptr,
positionsPointer,
sizeOf<Float>() * 2,
colorsPointer,
sizeOf<SdlFColor>(),
texCoordsPointer,
sizeOf<Float>() * 2,
positions.length,
indicesPointer.cast<Void>(),
numIndices,
sizeOf<Int32>(),
);
positionsPointer.callocFree();
if (colorsPointer != nullptr) {
colorsPointer.callocFree();
}
if (texCoordsPointer != nullptr) {
texCoordsPointer.callocFree();
}
if (indicesPointer != nullptr) {
indicesPointer.callocFree();
}
return result;
}