Files
XCEngine/docs/api/rhi/opengl/device/create-swap-chain.md
ssdfasd b414bc5326 refactor(docs): Fix broken links across multiple modules
Fixed broken references:
- texture-import-settings: Fix 16 files referencing wrong overview filename
- math/rectint: Fix 9 method links (rectint-* → get*, contains, intersects)
- rhi/opengl/device: Fix 8 cross-references (opengl-* → */**)
- resources/mesh: Fix meshsection and vertexattribute links
- rhi/d3d12/sampler: Fix RHISampler reference path
- math/vector3: Fix projectonplane → project-on-plane
- rhi/opengl/command-list: Remove broken ClearFlag enum ref
- rhi/opengl/device: Create 2 new method docs (MakeContextCurrent, GetNativeContext)
- rhi/device: Fix device-info types reference

All 0 broken references remaining.
2026-03-26 02:41:00 +08:00

1.3 KiB

OpenGLDevice::CreateSwapChain

RHISwapChain* CreateSwapChain(const SwapChainDesc& desc) override

创建 OpenGL 交换链对象。

详细描述

创建与设备窗口关联的交换链,用于管理前后缓冲区的交换。

交换链行为

  • 使用窗口的当前尺寸初始化交换链
  • 通过 SwapBuffers() 执行缓冲区交换
  • 交换链与 GLFW 窗口 (m_window) 关联

参数

  • desc - 交换链描述符

SwapChainDesc 字段

字段 描述
width 缓冲区宽度
height 缓冲区高度

返回值

RHISwapChain* - 创建的交换链指针

注意事项

  • 如果 m_windownullptr,交换链创建失败
  • 返回的交换链对象归调用者所有,需自行管理生命周期
  • 交换链尺寸应与窗口尺寸匹配

示例

SwapChainDesc swapDesc;
swapDesc.width = 1280;
swapDesc.height = 720;

RHISwapChain* swapChain = device.CreateSwapChain(swapDesc);

// 在渲染循环中使用
while (!device.ShouldClose()) {
    device.PollEvents();
    renderScene();
    device.SwapBuffers();
}

相关文档