DrawCmd addDrawCommand() { DrawCmd cmd = new DrawCmd(); cmd.layer = currentLayer; cmd.clipRect = currentClipRect; cmd.texture = currentTexture; cmd.elementOffset = myIndexCount; cmd.elementCount = 0; cmd.index = myCmdBuffer.Count; myCmdBuffer.Add(cmd); return(cmd); }
void updateLayer() { DrawCmd cmd = currentCommand; int layer = currentLayer; if (cmd != null || (cmd.elementCount != 0 && cmd.layer != layer) || cmd.userRenderCommand != null) { addDrawCommand(); } else { cmd.layer = layer; } }
void updateTexture() { DrawCmd cmd = currentCommand; Texture t = currentTexture; if (cmd != null || (cmd.elementCount != 0 && cmd.texture != t) || cmd.userRenderCommand != null) { addDrawCommand(); } else { cmd.texture = t; } }
public void addCustomRenderCommand(StatelessRenderCommand cmd) { DrawCmd dcmd = currentCommand; if (dcmd == null || dcmd.elementCount != 0 || dcmd.userRenderCommand != null) { dcmd = addDrawCommand(); } dcmd.userRenderCommand = cmd; cmd.renderState.scissorTest.enabled = true; cmd.renderState.scissorTest.rect = dcmd.clipRect; // Force a new command after us (we function this way so that the most common calls AddLine, AddRect, etc. always have a command to add to without doing any check). addDrawCommand(); }
public UiRenderCommand(DrawCmd drawCmd, Matrix4 modelmatrix, VertexBufferObject vbo, IndexBufferObject ibo) : base() { myElementCount = (int)drawCmd.elementCount; myElementOffset = (int)drawCmd.elementOffset; pipelineState = thePipelineState; renderState.scissorTest.enabled = true; renderState.scissorTest.rect = drawCmd.clipRect; renderState.setVertexBuffer(vbo.id, 0, 0, V2T2B4.stride); renderState.setIndexBuffer(ibo.id); renderState.setUniform(new UniformData(0, Uniform.UniformType.Int, 0)); renderState.setUniform(new UniformData(0, Uniform.UniformType.Mat4, modelmatrix)); renderState.setTexture((int)drawCmd.texture.id(), 0, TextureTarget.Texture2D); }
void updateClipRect() { DrawCmd cmd = currentCommand; if (cmd == null || cmd.elementCount != 0 || cmd.userRenderCommand != null) { addDrawCommand(); } else { Vector4 clipRect = currentClipRect; if (myCmdBuffer.Count >= 2 && (myCmdBuffer[myCmdBuffer.Count - 2].clipRect - clipRect).LengthSquared < 0.0001f) { myCmdBuffer.RemoveAt(myCmdBuffer.Count - 1); } else { cmd.clipRect = clipRect; } } }