> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ILampArray::GetIndicesForPurposes 方法

> 以符合指定 LampPurposes 的 Lamp 索引填入呼叫端提供的緩衝區；請先使用 GetIndicesCountForPurposes 決定緩衝區大小。

# ILampArray::GetIndicesForPurposes

以支援指定 LampPurposes 集合的 Lamp 索引填入緩衝區。呼叫此方法之前，應先呼叫 [ILampArray::GetIndicesCountForPurposes](/zh-TW/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_getindicescountforpurposes) 取得最大緩衝區大小。

## 語法

```cpp theme={null}
void GetIndicesForPurposes(
    LampPurposes lampPurposes,
    uint32_t lampIndicesCount,
    uint32_t * lampIndices)
```

### 參數

*lampPurposes*
類型：[LampPurposes](/zh-TW/reference/lighting/lamparray/enums/lamppurposes)

所需的 LampPurposes 集合。

*lampIndicesCount*\
類型：uint32\_t

要填入的緩衝區大小。

*lampIndices*  \_Out\_writes\_(lampIndicesCount)
類型：uint32\_t\*

Lamp 索引緩衝區。寫入緩衝區的索引屬於符合 lampPurposes 中所有旗標的 Lamp。

### 傳回值

類型：void

## 備註

下列程式碼示範如何為 ILampArray 上的所有品牌標示 Lamp 設定色彩：

```cpp theme={null}
void UpdateBrandingLamps(ILampArray* lampArray)
{
    // Get the number of Branding lamps
    LampPurposes purposes = LampPurposes::Branding;
    uint32_t indicesCount = lampArray->GetIndicesCountForPurposes(purposes);

    // Allocate and populate a buffer with the indices of those Lamps
    std::vector<uint32_t> indicesBuffer(indicesCount);
    lampArray->GetIndicesForPurposes(purposes, indicesCount, indicesBuffer.data());

    // Set color for all Branding Lamps to red.
    std::vector<LampArrayColor> colorsBuffer(indicesCount);
    for (uint32_t i = 0; i < indicesCount; i++)
    {
        colorsBuffer[i] = { 0xFF /* r */, 0x0 /* g */, 0x0 /* b */, 0xFF /* a */ };
    }

    lampArray->SetColorsForIndices(indicesCount, indicesBuffer.data(), colorsBuffer.data());
}
```

## 需求

**標頭：** LampArray.h

**程式庫：** xgameplatform.lib

**支援的平台：** XBOX One 系列主機和 XBOX Series 主機

## 另請參閱

[照明 API 概觀](/zh-TW/build/core-features/common/lighting/gc-lighting-toc)\
[ILampArray::GetIndicesCountForPurposes](/zh-TW/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_getindicescountforpurposes)\
[ILampArray::SetColorsForIndices](/zh-TW/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_setcolorsforindices)\
[ILampArray](/zh-TW/reference/lighting/lamparray/interfaces/ilamparray/ilamparray)


## Related topics

- [ILampArray::GetIndicesForPurposes](/zh-CN/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_getindicesforpurposes.md)
- [ILampArray::GetIndicesForPurposes method](/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_getindicesforpurposes.md)
- [Método ILampArray::GetIndicesForPurposes](/es/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_getindicesforpurposes.md)
- [ILampArray::GetIndicesCountForPurposes](/zh-CN/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_getindicescountforpurposes.md)
- [ILampArray::GetIndicesCountForPurposes method](/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_getindicescountforpurposes.md)
