コード例 #1
0
        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;
                }
                }
            }
        }
コード例 #2
0
ファイル: Label.cs プロジェクト: 67-6f-64/HelloWorld
 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();
 }