sdlxRenderGeometryRaw function render

bool sdlxRenderGeometryRaw(
  1. Pointer<SdlRenderer> renderer,
  2. List<SdlxFPoint> positions, {
  3. Pointer<SdlTexture>? texture,
  4. List<SdlxFColor>? colors,
  5. List<SdlxFPoint>? texCoords,
  6. 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;
  }
  return ffi.using((arena) {
    // 各ポインタを arena で一括管理
    final positionsPointer = positions.toNativeXy(arena);
    final colorsPointer = colors?.toNative(arena) ?? nullptr;
    final texCoordsPointer = texCoords?.toNativeXy(arena) ?? nullptr;

    Pointer<Void> indicesPointer = nullptr;
    var numIndices = 0;
    if (indices != null) {
      numIndices = indices.length;
      final nativeIndices = arena<Int32>(numIndices);
      nativeIndices.asTypedList(numIndices).setAll(0, indices);
      indicesPointer = nativeIndices.cast<Void>();
    }

    return sdlRenderGeometryRaw(
      renderer,
      texture ?? nullptr,
      positionsPointer,
      sizeOf<Float>() * 2,
      colorsPointer,
      sizeOf<SdlFColor>(),
      texCoordsPointer,
      sizeOf<Float>() * 2,
      positions.length,
      indicesPointer,
      numIndices,
      sizeOf<Int32>(),
    );
  });
}