bindTexture method

void bindTexture(
  1. UniformSlot slot,
  2. Texture texture, {
  3. SamplerOptions? sampler,
})

Implementation

void bindTexture(
  UniformSlot slot,
  Texture texture, {
  SamplerOptions? sampler,
}) {
  if (sampler == null) {
    sampler = SamplerOptions();
  }

  assert(() {
    if (texture.storageMode == StorageMode.deviceTransient) {
      throw Exception(
        "Textures with StorageMode.deviceTransient cannot be bound to a RenderPass",
      );
    }
    return true;
  }());

  bool success = _bindTexture(
    slot.shader,
    slot.uniformName,
    texture,
    sampler.minFilter.index,
    sampler.magFilter.index,
    sampler.mipFilter.index,
    sampler.widthAddressMode.index,
    sampler.heightAddressMode.index,
  );
  if (!success) {
    throw Exception("Failed to bind texture");
  }
}