Files
XCSDD/docs/api/rhi/opengl/command-list/opengl-methods.md
ssdfasd 58a83f445a fix: improve doc link navigation and tree display
- Fix link resolution with proper relative/absolute path handling
- Improve link styling with underline decoration
- Hide leaf nodes from tree, only show directories
- Fix log file path for packaged app
2026-03-19 12:44:08 +08:00

10 KiB
Raw Blame History

OpenGLCommandList - OpenGL 特有方法

以下是 OpenGLCommandList 中 OpenGL 特有的底层逃逸方法。这些方法不存在于 RHI 抽象接口中,用于需要直接操作 OpenGL 状态的高级场景。

顶点缓冲区OpenGL 逃逸)

SetVertexBuffer (GL uint)

void SetVertexBuffer(unsigned int buffer, size_t offset, size_t stride)

直接使用 OpenGL buffer ID 设置顶点缓冲区。

SetVertexBuffers (GL uint)

void SetVertexBuffers(unsigned int startSlot, unsigned int count, const unsigned int* buffers, const size_t* offsets, const size_t* strides)

批量设置顶点缓冲区。

SetIndexBuffer (GL uint)

void SetIndexBuffer(unsigned int buffer, unsigned int type)
void SetIndexBuffer(unsigned int buffer, unsigned int type, size_t offset)

直接设置索引缓冲区。

顶点数组

BindVertexArray

void BindVertexArray(unsigned int vao)
void BindVertexArray(unsigned int vao, unsigned int indexBuffer, unsigned int indexType)

绑定 VAO可同时设置索引缓冲区。

UseShader

void UseShader(unsigned int program)

使用 shader program。

视口与裁剪

SetViewport (int)

void SetViewport(int x, int y, int width, int height)

使用整数参数设置视口。

SetViewport (float)

void SetViewport(float x, float y, float width, float height, float minDepth, float maxDepth)

使用浮点参数设置视口。

SetViewports

void SetViewports(unsigned int count, const float* viewports)

批量设置视口6 个浮点值 per viewport: x, y, width, height, minDepth, maxDepth

SetScissor

void SetScissor(int x, int y, int width, int height)

设置裁剪矩形。

SetScissorRects

void SetScissorRects(unsigned int count, const int* rects)

批量设置裁剪矩形4 个整数值 per rect: x, y, width, height

EnableScissorTest

void EnableScissorTest(bool enable)

启用/禁用裁剪测试。

深度测试

EnableDepthTest

void EnableDepthTest(bool enable)

启用/禁用深度测试。

EnableDepthWrite

void EnableDepthWrite(bool enable)

启用/禁用深度写入。

SetDepthFunc

void SetDepthFunc(unsigned int func)

设置深度比较函数GL_NEVER, GL_LESS, GL_EQUAL, etc.)。

模板测试

EnableStencilTest

void EnableStencilTest(bool enable)

启用/禁用模板测试。

SetStencilFunc

void SetStencilFunc(unsigned int func, int ref, unsigned int mask)

设置模板测试函数。

SetStencilOp

void SetStencilOp(unsigned int fail, unsigned int zfail, unsigned int zpass)

设置模板操作。

混合

EnableBlending

void EnableBlending(bool enable)

启用/禁用混合。

SetBlendFunc

void SetBlendFunc(unsigned int src, unsigned int dst)

设置混合函数。

SetBlendFuncSeparate

void SetBlendFuncSeparate(unsigned int srcRGB, unsigned int dstRGB, unsigned int srcAlpha, unsigned int dstAlpha)

分别设置 RGB 和 Alpha 的混合函数。

SetBlendEquation

void SetBlendEquation(unsigned int mode)

设置混合方程。

SetBlendColor

void SetBlendColor(float r, float g, float b, float a)

设置混合因子颜色。

光栅化

EnableCulling

void EnableCulling(bool enable)

启用/禁用面剔除。

SetCullFace

void SetCullFace(unsigned int face)

设置剔除面GL_FRONT, GL_BACK, GL_FRONT_AND_BACK

SetFrontFace

void SetFrontFace(unsigned int face)

设置正面方向GL_CW, GL_CCW

SetPolygonMode

void SetPolygonMode(unsigned int mode)

设置多边形模式GL_POINT, GL_LINE, GL_FILL

SetPolygonOffset

void SetPolygonOffset(float factor, float units)

设置多边形偏移。

SetPrimitiveType

void SetPrimitiveType(PrimitiveType type)

设置图元类型。

绘制OpenGL 类型)

Draw (PrimitiveType)

void Draw(PrimitiveType type, unsigned int vertexCount, unsigned int startVertex)

绘制非索引图元。

DrawInstanced

void DrawInstanced(PrimitiveType type, unsigned int vertexCount, unsigned int instanceCount, unsigned int startVertex, unsigned int startInstance)

实例化绘制。

DrawIndexed (PrimitiveType)

void DrawIndexed(PrimitiveType type, unsigned int indexCount, unsigned int startIndex, int baseVertex)

绘制索引图元。

DrawIndexedInstanced

void DrawIndexedInstanced(PrimitiveType type, unsigned int indexCount, unsigned int instanceCount, unsigned int startIndex, int baseVertex, unsigned int startInstance)

实例化索引绘制。

DrawIndirect

void DrawIndirect(PrimitiveType type, unsigned int buffer, size_t offset, unsigned int drawCount, unsigned int stride)

间接绘制。

DrawIndexedIndirect

void DrawIndexedIndirect(PrimitiveType type, unsigned int buffer, size_t offset, unsigned int drawCount, unsigned int stride)

间接索引绘制。

MultiDrawArrays

void MultiDrawArrays(PrimitiveType type, const int* first, const int* count, unsigned int drawCount)

多重绘制。

MultiDrawElements

void MultiDrawElements(PrimitiveType type, const int* count, unsigned int type_, const void* const* indices, unsigned int drawCount)

多重索引绘制。

计算着色器

DispatchIndirect

void DispatchIndirect(unsigned int buffer, size_t offset)

间接分发计算着色器。

DispatchCompute

void DispatchCompute(unsigned int x, unsigned int y, unsigned int z, unsigned int groupX, unsigned int groupY, unsigned int groupZ)

分发计算着色器(带参数)。

内存屏障

MemoryBarrier

void MemoryBarrier(unsigned int barriers)

设置内存屏障。

TextureBarrier

void TextureBarrier()

纹理屏障。

纹理绑定

BindTexture

void BindTexture(unsigned int target, unsigned int unit, unsigned int texture)

绑定纹理到纹理单元。

BindTextures

void BindTextures(unsigned int first, unsigned int count, const unsigned int* textures)

批量绑定纹理。

BindSampler

void BindSampler(unsigned int unit, unsigned int sampler)

绑定采样器。

BindSamplers

void BindSamplers(unsigned int first, unsigned int count, const unsigned int* samplers)

批量绑定采样器。

BindImageTexture

void BindImageTexture(unsigned int unit, unsigned int texture, int level, bool layered, int layer, unsigned int access, unsigned int format)

绑定为 image texture。

缓冲区绑定

BindBufferBase

void BindBufferBase(unsigned int target, unsigned int index, unsigned int buffer)

绑定到固定 binding point。

BindBufferRange

void BindBufferRange(unsigned int target, unsigned int index, unsigned int buffer, size_t offset, size_t size)

绑定到范围 binding point。

OpenGL 状态

Enable / Disable

void Enable(unsigned int cap)
void Disable(unsigned int cap)
void Enablei(unsigned int cap, unsigned int index)
void Disablei(unsigned int cap, unsigned int index)

启用/禁用 GL capability。

Uniform 设置

SetUniform1i / SetUniform1f

void SetUniform1i(int location, int v)
void SetUniform1f(int location, float v)

SetUniform2f

void SetUniform2f(int location, float x, float y)

SetUniform3f

void SetUniform3f(int location, float x, float y, float z)

SetUniform4f

void SetUniform4f(int location, float x, float y, float z, float w)

SetUniform1fv / SetUniform2fv / SetUniform3fv / SetUniform4fv

void SetUniform1fv(int location, int count, const float* v)
void SetUniform2fv(int location, int count, const float* v)
void SetUniform3fv(int location, int count, const float* v)
void SetUniform4fv(int location, int count, const float* v)

SetUniformMatrix4fv

void SetUniformMatrix4fv(int location, int count, bool transpose, const float* v)

Shader 程序

UseProgram

void UseProgram(unsigned int program)

使用 program。

BindFragDataLocation

void BindFragDataLocation(unsigned int program, unsigned int colorNumber, const char* name)
void BindFragDataLocationIndexed(unsigned int program, unsigned int colorNumber, unsigned int index, const char* name)

设置颜色输出绑定。

查询

BeginQuery / EndQuery

void BeginQuery(unsigned int target, unsigned int id)
void EndQuery(unsigned int target)

开始/结束查询。

GetQueryObjectiv / GetQueryObjectuiv

void GetQueryObjectiv(unsigned int id, unsigned int pname, int* params)
void GetQueryObjectuiv(unsigned int id, unsigned int pname, unsigned int* params)

获取查询结果。

Framebuffer 操作

ReadPixels

void ReadPixels(int x, int y, int width, int height, unsigned int format, unsigned int type, void* data)

读取像素。

BlitFramebuffer

void BlitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, unsigned int mask, unsigned int filter)

Blit 帧缓冲区。

CopyImageSubData

void CopyImageSubData(unsigned int srcName, unsigned int srcTarget, int srcLevel, int srcX, int srcY, int srcZ, unsigned int dstName, unsigned int dstTarget, int dstLevel, int dstX, int dstY, int dstZ, int width, int height, int depth)

复制图像子数据。

InvalidateFramebuffer

void InvalidateFramebuffer(unsigned int target, unsigned int count, const unsigned int* attachments)
void InvalidateSubFramebuffer(unsigned int target, unsigned int count, const unsigned int* attachments, int x, int y, int width, int height)

使帧缓冲区失效。

调试

PushDebugGroup / PopDebugGroup

void PushDebugGroup(unsigned int source, unsigned int id, int length, const char* message)
void PopDebugGroup()

推送/弹出调试组。