docs: update RHI API docs
This commit is contained in:
@@ -1,10 +1,35 @@
|
||||
# OpenGLRenderTargetView::Bind
|
||||
|
||||
```cpp
|
||||
void Bind() const;
|
||||
void Bind(unsigned int slot = 0);
|
||||
void Bind(unsigned int count, const unsigned int* framebuffers, const int* drawBuffers);
|
||||
```
|
||||
|
||||
绑定渲染目标视图。
|
||||
绑定渲染目标视图作为当前渲染目标。
|
||||
|
||||
**重载 1 参数:**
|
||||
- `slot` - 绑定槽位(预留参数,当前实现中未使用)
|
||||
|
||||
**重载 2 参数:**
|
||||
- `count` - 帧缓冲区数量
|
||||
- `framebuffers` - 帧缓冲区 ID 数组
|
||||
- `drawBuffers` - 对应每个帧缓冲区的绘制缓冲附件
|
||||
|
||||
**行为说明:**
|
||||
- 当 `count` 为 1 时,直接绑定单个帧缓冲区
|
||||
- 当 `count` 大于 1 时,启用多重渲染目标(MRT),依次绑定各帧缓冲区并设置绘制缓冲附件
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
// 单帧缓冲绑定
|
||||
rtv.Bind();
|
||||
|
||||
// 多帧缓冲绑定
|
||||
unsigned int fbos[] = { fbo1, fbo2 };
|
||||
int attachments[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
|
||||
rtv.Bind(2, fbos, attachments);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
|
||||
@@ -2,15 +2,34 @@
|
||||
|
||||
```cpp
|
||||
void Clear(float r, float g, float b, float a);
|
||||
void Clear(float r, float g, float b, float a, float depth, uint8_t stencil);
|
||||
```
|
||||
|
||||
清除渲染目标视图。
|
||||
清除渲染目标视图的颜色缓冲区和可选的深度/模板缓冲区。
|
||||
|
||||
**参数:**
|
||||
**重载 1 参数(仅清除颜色):**
|
||||
- `r` - 红色分量(0.0f - 1.0f)
|
||||
- `g` - 绿色分量(0.0f - 1.0f)
|
||||
- `b` - 蓝色分量(0.0f - 1.0f)
|
||||
- `a` - Alpha 分量(0.0f - 1.0f)
|
||||
|
||||
**重载 2 参数(清除颜色、深度和模板):**
|
||||
- `r` - 红色分量
|
||||
- `g` - 绿色分量
|
||||
- `b` - 蓝色分量
|
||||
- `a` - Alpha 分量
|
||||
- `depth` - 深度值(通常 0.0f 或 1.0f)
|
||||
- `stencil` - 模板值(0-255)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
// 仅清除颜色缓冲
|
||||
rtv.Clear(0.1f, 0.1f, 0.1f, 1.0f);
|
||||
|
||||
// 清除颜色、深度和模板缓冲
|
||||
rtv.Clear(0.1f, 0.1f, 0.1f, 1.0f, 1.0f, 0);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
|
||||
19
docs/api/rhi/opengl/render-target-view/get-height.md
Normal file
19
docs/api/rhi/opengl/render-target-view/get-height.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# OpenGLRenderTargetView::GetHeight
|
||||
|
||||
```cpp
|
||||
int GetHeight() const;
|
||||
```
|
||||
|
||||
获取渲染目标视图的高度(像素)。
|
||||
|
||||
**返回:** `int` - 渲染目标高度
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
int height = rtv.GetHeight();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLRenderTargetView 总览](render-target-view.md) - 返回类总览
|
||||
@@ -1,13 +1,18 @@
|
||||
# OpenGLRenderTargetView::GetWidth / GetHeight
|
||||
# OpenGLRenderTargetView::GetWidth
|
||||
|
||||
```cpp
|
||||
int GetWidth() const;
|
||||
int GetHeight() const;
|
||||
```
|
||||
|
||||
获取渲染目标视图的宽度和高度。
|
||||
获取渲染目标视图的宽度(像素)。
|
||||
|
||||
**返回:** 宽度/高度
|
||||
**返回:** `int` - 渲染目标宽度
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
int width = rtv.GetWidth();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
|
||||
@@ -1,17 +1,28 @@
|
||||
# OpenGLRenderTargetView::Initialize
|
||||
|
||||
```cpp
|
||||
bool Initialize(unsigned int texture, int width, int height);
|
||||
bool Initialize(unsigned int texture, const OpenGLRenderTargetViewDesc& desc);
|
||||
bool Initialize(unsigned int texture, int mipLevel = 0);
|
||||
```
|
||||
|
||||
初始化渲染目标视图。
|
||||
|
||||
**参数:**
|
||||
**重载 1 参数:**
|
||||
- `texture` - OpenGL 纹理 ID
|
||||
- `width` - 宽度
|
||||
- `height` - 高度
|
||||
- `desc` - 渲染目标视图描述
|
||||
|
||||
**返回:** 成功返回 true
|
||||
**重载 2 参数:**
|
||||
- `texture` - OpenGL 纹理 ID
|
||||
- `mipLevel` - mipmap 级别(默认为 0)
|
||||
|
||||
**返回:** `bool` - 成功返回 true,失败返回 false
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
OpenGLRenderTargetView rtv;
|
||||
rtv.Initialize(texture, 0);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
|
||||
@@ -2,26 +2,87 @@
|
||||
|
||||
**命名空间**: `XCEngine::RHI`
|
||||
|
||||
**描述**: OpenGL 渲染目标视图实现。
|
||||
**描述**: OpenGL 渲染目标视图实现,用于将纹理绑定为渲染目标进行渲染输出。
|
||||
|
||||
## 类型定义
|
||||
|
||||
### RenderTargetType
|
||||
|
||||
```cpp
|
||||
enum class RenderTargetType {
|
||||
Texture2D, // 2D 纹理
|
||||
Texture2DArray, // 2D 纹理数组
|
||||
Texture3D, // 3D 纹理
|
||||
TextureCube, // 立方体贴图
|
||||
TextureCubeArray // 立方体贴图数组
|
||||
};
|
||||
```
|
||||
|
||||
### OpenGLRenderTargetViewDesc
|
||||
|
||||
```cpp
|
||||
struct OpenGLRenderTargetViewDesc {
|
||||
RenderTargetType type = RenderTargetType::Texture2D; // 渲染目标类型
|
||||
int mipLevel = 0; // Mip 级别
|
||||
int baseArraySlice = 0; // 数组起始索引
|
||||
int arraySize = 1; // 数组大小
|
||||
int layer = 0; // 层级(用于 3D 纹理)
|
||||
uint32_t format = 0; // 格式
|
||||
};
|
||||
```
|
||||
|
||||
## 公共方法
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| [`Initialize`](initialize.md) | 初始化渲染目标视图 |
|
||||
| [`Initialize`](initialize.md) | 初始化渲染目标视图(2 个重载) |
|
||||
| [`InitializeCubemap`](initialize-cubemap.md) | 初始化立方体贴图渲染目标视图 |
|
||||
| [`Shutdown`](shutdown.md) | 关闭渲染目标视图 |
|
||||
| [`Bind`](bind.md) | 绑定渲染目标视图 |
|
||||
| [`Bind`](bind.md) | 绑定渲染目标视图(2 个重载) |
|
||||
| [`Unbind`](unbind.md) | 解绑渲染目标视图 |
|
||||
| [`Clear`](clear.md) | 清除 |
|
||||
| [`Clear`](clear.md) | 清除(2 个重载) |
|
||||
| [`GetFramebuffer`](get-framebuffer.md) | 获取帧缓冲 |
|
||||
| [`GetTexture`](get-texture.md) | 获取纹理 |
|
||||
| [`GetMipLevel`](get-mip-level.md) | 获取 Mip 级别 |
|
||||
| [`GetWidth`](get-size.md) | 获取宽度 |
|
||||
| [`GetHeight`](get-size.md) | 获取高度 |
|
||||
| [`GetHeight`](get-height.md) | 获取高度 |
|
||||
| [`BindFramebuffer`](bind-framebuffer.md) | 绑定帧缓冲 |
|
||||
| [`UnbindFramebuffer`](unbind-framebuffer.md) | 解绑帧缓冲 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/RHI/OpenGL/OpenGLRenderTargetView.h"
|
||||
|
||||
void RenderToTexture() {
|
||||
OpenGLRenderTargetView rtv;
|
||||
|
||||
// 初始化为 2D 纹理渲染目标
|
||||
if (rtv.Initialize(textureID, 0)) {
|
||||
rtv.Bind();
|
||||
rtv.Clear(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
// 执行渲染...
|
||||
rtv.Unbind();
|
||||
}
|
||||
|
||||
rtv.Shutdown();
|
||||
}
|
||||
|
||||
void RenderToCubemap() {
|
||||
OpenGLRenderTargetView rtv;
|
||||
|
||||
// 初始化为立方体贴图的第一面
|
||||
if (rtv.InitializeCubemap(cubemapID, 0, 0)) {
|
||||
rtv.Bind();
|
||||
rtv.Clear(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
// 执行渲染...
|
||||
rtv.Unbind();
|
||||
}
|
||||
|
||||
rtv.Shutdown();
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGL 后端总览](../overview.md)
|
||||
|
||||
@@ -4,7 +4,20 @@
|
||||
void Shutdown();
|
||||
```
|
||||
|
||||
关闭渲染目标视图。
|
||||
关闭渲染目标视图,释放关联的帧缓冲区资源。此方法会在析构时自动调用,但也可手动调用以提前释放资源。
|
||||
|
||||
**注意:** 此方法仅删除帧缓冲区对象,不会删除关联的纹理对象。
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
OpenGLRenderTargetView rtv;
|
||||
rtv.Initialize(texture, 0);
|
||||
|
||||
// 使用 rtv...
|
||||
|
||||
rtv.Shutdown(); // 释放帧缓冲区资源
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
# OpenGLRenderTargetView::Unbind
|
||||
|
||||
```cpp
|
||||
void Unbind() const;
|
||||
void Unbind();
|
||||
```
|
||||
|
||||
解除绑定渲染目标视图。
|
||||
解除当前渲染目标视图的绑定,将默认帧缓冲区(framebuffer 0)设为当前渲染目标。
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
rtv.Bind();
|
||||
// 执行渲染...
|
||||
rtv.Unbind(); // 解除绑定,恢复默认帧缓冲
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
|
||||
Reference in New Issue
Block a user