creator gfx 各个类的源码解读(4) WebGL2CmdObject
gfx 各个类的源码解读(4) WebGL2CmdObject
WebGL2CmdObject 在 webgl2-commands.ts
WebGL2CmdObject是命令执行的基础类
有五个子类
WebGL2CmdBeginRenderPass
WebGL2CmdBindStates
WebGL2CmdDraw
WebGL2CmdUpdateBuffer
WebGL2CmdCopyBufferToTexture
WebGL2CmdPackage类
对于批量命令的封装,命令的集合
成员变量:
public cmds: CachedArray<WebGL2Cmd> = new CachedArray(1);
public beginRenderPassCmds: CachedArray<WebGL2CmdBeginRenderPass> = new CachedArray(1);
public bindStatesCmds: CachedArray<WebGL2CmdBindStates> = new CachedArray(1);
public drawCmds: CachedArray<WebGL2CmdDraw> = new CachedArray(1);
public updateBufferCmds: CachedArray<WebGL2CmdUpdateBuffer> = new CachedArray(1);
public copyBufferToTextureCmds: CachedArray<WebGL2CmdCopyBufferToTexture> = new CachedArray(1);
WebGL2CmdFuncExecuteCmds函数(device: WebGL2Device, cmdPackage: WebGL2CmdPackage)
根据WebGL2CmdPackage里的命令集合执行命令
代码片段:
for (let i = 0; i < cmdPackage.cmds.length; ++i) {
const cmd = cmdPackage.cmds.array[i];
const cmdId = cmdIds[cmd]++;
switch (cmd) {
case WebGL2Cmd.BEGIN_RENDER_PASS: {
const cmd0 = cmdPackage.beginRenderPassCmds.array[cmdId];
WebGL2CmdFuncBeginRenderPass(device, cmd0.gpuRenderPass, cmd0.gpuFramebuffer, cmd0.renderArea,
cmd0.clearColors, cmd0.clearDepth, cmd0.clearStencil);
break;
}
//........