diff --git a/src/renderer/Renderer.ts b/src/renderer/Renderer.ts index fea9c900..fa5ca8c2 100644 --- a/src/renderer/Renderer.ts +++ b/src/renderer/Renderer.ts @@ -1,9 +1,17 @@ import { RenderCommand } from './RenderCommand'; export class Renderer { - public readonly commandBuffer: RenderCommand[] = []; + private _commandBuffer: RenderCommand[] = []; + + public get commandBuffer(): RenderCommand[] { + return this._commandBuffer; + } public pushRenderCommand(command: RenderCommand): void { - this.commandBuffer.push(command); + this._commandBuffer.push(command); + } + + public endFrame(): void { + this._commandBuffer = []; } } \ No newline at end of file diff --git a/test/renderer/Renderer.test.ts b/test/renderer/Renderer.test.ts index 5b7a8d33..91939940 100644 --- a/test/renderer/Renderer.test.ts +++ b/test/renderer/Renderer.test.ts @@ -16,4 +16,33 @@ describe('renderer/Renderer', () => { expect(renderer.commandBuffer).toContain(renderCommand); }); }); + + describe('.endFrame()', () => { + it.skip('Should execute queued rendering commands', () => { + const renderCommand = { + renderCommandID: RenderCommandID.RC_DrawPrimitive, + primitiveType: PrimitiveType.Rectangle, + position: [0, 0], + size: [0, 0] + }; + + renderer.pushRenderCommand(renderCommand); + renderer.endFrame(); + }) + + it('Should clear the command buffer', () => { + const renderCommand = { + renderCommandID: RenderCommandID.RC_DrawPrimitive, + primitiveType: PrimitiveType.Rectangle, + position: [0, 0], + size: [0, 0] + }; + + renderer.pushRenderCommand(renderCommand); + renderer.endFrame(); + + expect(renderer.commandBuffer).toEqual([]); + + }); + }); }); \ No newline at end of file