> ## 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

> ILampArray::GetIndicesForPurposes

# ILampArray::GetIndicesForPurposes

填充支持给定 LampPurposes 集合的 Lamp 索引缓冲区。在调用此方法之前，应通过调用 [ILampArray::GetIndicesCountForPurposes](/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_getindicescountforpurposes) 获取最大缓冲区大小。

## 语法

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

### 参数

*lampPurposes*
类型：[LampPurposes](/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 概览](/build/core-features/common/lighting/gc-lighting-toc)\
[ILampArray::GetIndicesCountForPurposes](/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_getindicescountforpurposes)\
[ILampArray::SetColorsForIndices](/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_setcolorsforindices)\
[ILampArray](/reference/lighting/lamparray/interfaces/ilamparray/ilamparray)


## Related topics

- [ILampArray::GetIndicesCountForPurposes](/zh-CN/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_getindicescountforpurposes.md)
- [LampPurposes 枚举](/zh-CN/reference/lighting/lamparray/enums/lamppurposes.md)
- [ILampArray::SetColorsForIndices](/zh-CN/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_setcolorsforindices.md)
- [ILampArray::GetLampArrayKind](/zh-CN/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_getlamparraykind.md)
- [ILampArray::GetLampInfo](/zh-CN/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_getlampinfo.md)
