# RHIFramebuffer::Initialize 初始化帧缓冲对象。 ```cpp virtual bool Initialize( class RHIRenderPass* renderPass, uint32_t width, uint32_t height, uint32_t colorAttachmentCount, RHIResourceView** colorAttachments, RHIResourceView* depthStencilAttachment ) = 0; ``` 根据指定的渲染通道和附件配置,创建并初始化帧缓冲对象。 **参数:** - `renderPass` - 关联的渲染通道对象 - `width` - 帧缓冲宽度(像素) - `height` - 帧缓冲高度(像素) - `colorAttachmentCount` - 颜色附件数量 - `colorAttachments` - 颜色附件资源视图数组 - `depthStencilAttachment` - 深度模板附件资源视图,可为 `nullptr` **返回:** `bool` - 初始化成功返回 `true`,失败返回 `false` **线程安全:** ❌ **注意:** - `width` 和 `height` 必须大于 0 - `colorAttachments` 数组长度必须与 `colorAttachmentCount` 匹配 - 所有附件的尺寸必须与指定的 `width`、`height` 一致 - 帧缓冲创建后,其尺寸不可更改,需调用 `Shutdown` 后重新初始化 **示例:** ```cpp // 创建带有颜色和深度附件的帧缓冲 RHIResourceView* colorViews[1] = { colorRTView }; RHIResourceView* depthView = depthStencilView; bool success = framebuffer->Initialize( renderPass, 1920, 1080, 1, colorViews, depthView ); ```