Пример #1
0
 public void Dispose()
 {
     Commands.Dispose();
     ColorPipeline.Dispose();
     TransformPipeline.Dispose();
     ParameterBuffer.Dispose();
     ScreenCoordsBuffer.Dispose();
     WorldVertexBuffer.Dispose();
     VertexBuffer.Dispose();
 }
Пример #2
0
 /// <summary> Called before Render (normally by RenderList::Render) to set up data for the render.
 /// currentstate may be null, meaning, don't apply
 /// RenderState may be null, meaning don't change</summary>
 public void Bind(GLRenderState currentstate, IGLProgramShader shader, GLMatrixCalc matrixcalc)
 {
     if (currentstate != null && RenderState != null)    // if either null, it means the last render state applied is the same as our render state, so no need to apply
     {
         currentstate.ApplyState(RenderState);           // else go to this state
     }
     VertexArray?.Bind();                                // give the VA a chance to bind to GL
     RenderData?.Bind(this, shader, matrixcalc);         // optional render data supplied by the user to bind
     ElementBuffer?.BindElement();                       // if we have an element buffer, give it a chance to bind
     IndirectBuffer?.BindIndirect();                     // if we have an indirect buffer, give it a chance to bind
     ParameterBuffer?.BindParameter();                   // if we have a parameter buffer, give it a chance to bind
 }
Пример #3
0
 public async Task Draw(Framebuffer target)
 {
     ParameterBuffer.Update(new Parameters(Transform3D.Identity, Spatial.CameraTransform));
     Commands.Submit(x =>
     {
         x.SetPipeline(TransformPipeline);
         x.Dispatch((uint)VertexBuffer.Length, 1, 1);
     });
     Commands.Submit(x =>
     {
         x.SetFramebuffer(target);
         var sfWidth  = Graphics.Device.SwapchainFramebuffer.Width;
         var sfHeight = Graphics.Device.SwapchainFramebuffer.Height;
         x.SetViewport(0, sfWidth > sfHeight
             ? new Viewport(0, -(sfWidth - sfHeight) / 2f, sfWidth, sfWidth, 0, 1)
             : new Viewport(-(sfHeight - sfWidth) / 2f, 0, sfHeight, sfHeight, 0, 1));
         x.SetPipeline(ColorPipeline);
         x.SetVertexBuffer(FaceBuffer);
         x.Draw((uint)FaceBuffer.Length * 3);
     });
 }