fix: encapsulate OpenGL types in VertexAttribute to eliminate raw GL API usage in tests
- Add VertexAttributeType and VertexAttributeNormalized enums in OpenGLVertexArray.h - Add ToGLAttributeType() converter in OpenGLVertexArray.cpp - Remove glActiveTexture() call from quad test (already handled by texture.Bind()) - Remove #include <glad/glad.h> from triangle test - Update unit tests to use encapsulated enums All three OpenGL integration tests (minimal, triangle, quad) pass with 0% pixel difference.
This commit is contained in:
@@ -1,89 +0,0 @@
|
||||
# AudioClip
|
||||
|
||||
**命名空间**: `XCEngine::Resources`
|
||||
|
||||
**类型**: `class`
|
||||
|
||||
**描述**: 音频片段资源类,管理音频样本数据、格式信息和播放参数。
|
||||
|
||||
## 概述
|
||||
|
||||
`AudioClip` 是 XCEngine 中的音频资源类,继承自 `IResource`。它管理音频的原始样本数据、采样率、通道数、位深度、时长、格式类型和播放参数。AudioClip 支持 WAV、OGG、MP3、FLAC 等多种音频格式,可用于音效、音乐、语音和环境音等不同用途。
|
||||
|
||||
## 公共方法
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| [`AudioClip`](audio-clip.md) | 构造函数 |
|
||||
| [`~AudioClip`](dtor.md) | 析构函数 |
|
||||
| [`GetType`](get-type.md) | 获取资源类型 |
|
||||
| [`GetName`](get-name.md) | 获取音频名称 |
|
||||
| [`GetPath`](get-path.md) | 获取音频路径 |
|
||||
| [`GetGUID`](get-guid.md) | 获取全局唯一标识符 |
|
||||
| [`IsValid`](is-valid.md) | 检查音频是否有效 |
|
||||
| [`GetMemorySize`](get-memory-size.md) | 获取内存大小 |
|
||||
| [`Release`](release.md) | 释放音频资源 |
|
||||
| [`SetAudioData`](setaudiodata.md) | 设置音频数据 |
|
||||
| [`GetAudioData`](get-audio-data.md) | 获取音频数据 |
|
||||
| [`SetSampleRate`](set-sample-rate.md) | 设置采样率 |
|
||||
| [`GetSampleRate`](get-sample-rate.md) | 获取采样率 |
|
||||
| [`SetChannels`](set-channels.md) | 设置通道数 |
|
||||
| [`GetChannels`](get-channels.md) | 获取通道数 |
|
||||
| [`SetBitsPerSample`](set-bits-per-sample.md) | 设置位深度 |
|
||||
| [`GetBitsPerSample`](get-bits-per-sample.md) | 获取位深度 |
|
||||
| [`SetDuration`](set-duration.md) | 设置时长 |
|
||||
| [`GetDuration`](get-duration.md) | 获取时长 |
|
||||
| [`SetAudioFormat`](set-audio-format.md) | 设置音频格式 |
|
||||
| [`GetAudioFormat`](get-audio-format.md) | 获取音频格式 |
|
||||
| [`SetAudioType`](set-audio-type.md) | 设置音频类型 |
|
||||
| [`GetAudioType`](get-audio-type.md) | 获取音频类型 |
|
||||
| [`SetIs3D`](set-is-3d.md) | 设置是否为 3D 音频 |
|
||||
| [`Is3D`](is-3d.md) | 检查是否为 3D 音频 |
|
||||
| [`SetLoop`](set-loop.md) | 设置是否循环播放 |
|
||||
| [`IsLoop`](is-loop.md) | 检查是否循环播放 |
|
||||
| [`GetRHIResource`](get-rhi-resource.md) | 获取 RHI 音频缓冲区 |
|
||||
| [`SetRHIResource`](set-rhi-resource.md) | 设置 RHI 音频缓冲区 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include "Resources/AudioClip.h"
|
||||
#include "Resources/ResourceManager.h"
|
||||
#include "Resources/ResourceFileSystem.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
AudioClip* CreateExplosionSound() {
|
||||
AudioClip* clip = new AudioClip();
|
||||
|
||||
auto wavData = ResourceFileSystem::Get().ReadResource("sounds/explosion.wav");
|
||||
clip->SetAudioData(wavData);
|
||||
clip->SetSampleRate(44100);
|
||||
clip->SetChannels(2);
|
||||
clip->SetBitsPerSample(16);
|
||||
clip->SetDuration(1.5f);
|
||||
clip->SetAudioFormat(AudioFormat::WAV);
|
||||
clip->SetAudioType(AudioType::SoundEffect);
|
||||
clip->SetLoop(false);
|
||||
clip->SetIs3D(false);
|
||||
|
||||
return clip;
|
||||
}
|
||||
|
||||
void PlaySoundEffect() {
|
||||
ResourceHandle<AudioClip> sfx = ResourceManager::Get().Load<AudioClip>("sounds/explosion.wav");
|
||||
|
||||
if (sfx->IsValid()) {
|
||||
uint32_t sampleRate = sfx->GetSampleRate();
|
||||
float duration = sfx->GetDuration();
|
||||
bool loop = sfx->IsLoop();
|
||||
AudioFormat format = sfx->GetAudioFormat();
|
||||
AudioType type = sfx->GetAudioType();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [IResource](../iresource/iresource.md) - 资源基类
|
||||
- [Resources](../resources.md) - 资源模块总览
|
||||
Reference in New Issue
Block a user