CreateLight method

LightC CreateLight(
  1. int type,
  2. Vector3C position,
  3. Vector3C target,
  4. ColorC color,
  5. ShaderC shader,
)

Create a light and get its shader locations

Implementation

LightC CreateLight(
  int type,
  Vector3C position,
  Vector3C target,
  ColorC color,
  ShaderC shader,
) {
  final light = calloc<LightC>();
  light.ref.enabled = true;
  light.ref.type = type;
  light.ref.position = position;
  light.ref.target = target;
  light.ref.color = color;

  int index = _lights.length;
  light.ref.enabledLoc = _coreFfi.GetShaderLocation(
    shader, $.String$.Value("lights[$index].enabled").asNativePointer(),
  );
  light.ref.typeLoc = _coreFfi.GetShaderLocation(
    shader, $.String$.Value("lights[$index].type").asNativePointer(),
  );
  light.ref.positionLoc = _coreFfi.GetShaderLocation(
    shader, $.String$.Value("lights[$index].position").asNativePointer(),
  );
  light.ref.targetLoc = _coreFfi.GetShaderLocation(
    shader, $.String$.Value("lights[$index].target").asNativePointer(),
  );
  light.ref.colorLoc = _coreFfi.GetShaderLocation(
    shader, $.String$.Value("lights[$index].color").asNativePointer(),
  );

  UpdateLightValues(shader, light.ref);

  _lights.add(light);

  return light.ref;
}