public void ProcessRenderCommands() { while (_renderCommands.Count > 0) { var c = _renderCommands.Dequeue(); switch (c.Type) { case RenderCommandType.RenderMesh: { GL.BindVertexArray(_vao); var command = (DrawElementsBaseVertexCommand)c; command.Shader.Use(); testShader.SetMaterial("material", command.DataPointer.MeshMaterial); testShader.SetMat4("model", command.Transform.ModelMatrix); testShader.SetMat4("view", view); testShader.SetMat4("projection", projection); testShader.SetMat4("mvp", command.Transform.ModelMatrix * view * projection); vertexBuffer.Bind(); GL.BindBuffer(BufferTarget.ElementArrayBuffer, _eboIndices); GL.DrawElementsBaseVertex(PrimitiveType.Triangles, command.DataPointer.Count, DrawElementsType.UnsignedInt, (IntPtr)0, command.DataPointer.Start); vertexBuffer.Unbind(); FreeRenderCommand(command); GL.BindVertexArray(0); break; } case RenderCommandType.RenderText: { var command = (RenderTextCommand)c; fontRenderer.RenderText(textShader, command.Text, command.X, command.Y, 1.0f, command.Color); FreeRenderCommand(command); break; } case RenderCommandType.RenderUIShape: { var command = (RenderUIShapeCommand)c; uiRenderer.RenderShape(uiShader, command.Shape); FreeRenderCommand(command); break; } } } }
private void Rebuild() { // rebuild VertexBuffer.Dispose(ref bufferText); if (string.IsNullOrEmpty(text)) { return; } f.BeginBatch(); if (!EnableShadow) { f.RenderText(text, Position.X, Position.Y); } else { f.RenderTextShadow(Color, text, Position.X, Position.Y); } f.StopBatch(); bufferText = t.GetVertexBuffer(); }