Esempio n. 1
0
        public void Flush()
        {
            if (nv > 0)
            {
                shader.SetTexture("DiffuseTexture", currentSheet.Texture);
                shader.Render(() =>
                {
                    var vb = renderer.GetTempVertexBuffer();
                    vb.SetData(vertices, nv);
                    renderer.DrawBatch(vb, 0, nv, PrimitiveType.QuadList);
                });

                nv           = 0;
                currentSheet = null;
            }
        }
Esempio n. 2
0
 public RgbaColorRenderer(Renderer renderer, IShader shader)
 {
     this.renderer = renderer;
     this.shader   = shader;
     vertices      = new Vertex[renderer.TempBufferSize];
     renderAction  = () => renderer.DrawBatch(vertices, nv, PrimitiveType.TriangleList);
 }
Esempio n. 3
0
 public SpriteRenderer(Renderer renderer, IShader shader)
 {
     this.renderer = renderer;
     this.shader   = shader;
     vertices      = new Vertex[renderer.TempBufferSize];
     renderAction  = () => renderer.DrawBatch(vertices, nv, PrimitiveType.QuadList);
 }
Esempio n. 4
0
 public void DrawVertexBuffer(IVertexBuffer <Vertex> buffer, int start, int length, PrimitiveType type, Sheet sheet, BlendMode blendMode)
 {
     shader.SetTexture("DiffuseTexture", sheet.GetTexture());
     renderer.Device.SetBlendMode(blendMode);
     shader.Render(() => renderer.DrawBatch(buffer, start, length, type));
     renderer.Device.SetBlendMode(BlendMode.None);
 }
Esempio n. 5
0
        public void Flush()
        {
            if (nv > 0)
            {
                for (var i = 0; i < ns; i++)
                {
                    shader.SetTexture("Texture{0}".F(i), sheets[i].GetTexture());
                    sheets[i] = null;
                }

                renderer.Context.SetBlendMode(currentBlend);
                shader.PrepareRender();
                renderer.DrawBatch(vertices, nv, PrimitiveType.TriangleList);
                renderer.Context.SetBlendMode(BlendMode.None);

                nv = 0;
                ns = 0;
            }
        }
Esempio n. 6
0
 public LineRenderer(Renderer renderer, IShader shader)
 {
     this.renderer = renderer;
     this.shader   = shader;
     vertices      = new Vertex[renderer.TempBufferSize];
     renderAction  = () =>
     {
         renderer.SetLineWidth(LineWidth);
         renderer.DrawBatch(vertices, nv, PrimitiveType.LineList);
     };
 }
Esempio n. 7
0
        public void Flush()
        {
            if (nv > 0)
            {
                shader.Render(() =>
                {
                    var vb = renderer.GetTempVertexBuffer();
                    vb.SetData(vertices, nv);
                    renderer.DrawBatch(vb, 0, nv, PrimitiveType.QuadList);
                });

                nv = 0;
            }
        }
Esempio n. 8
0
        void Render(
            VoxelRenderData renderData,
            float[] t, float[] lightDirection,
            float[] ambientLight, float[] diffuseLight,
            float colorPaletteTextureMidIndex, float normalsPaletteTextureMidIndex)
        {
            shader.SetTexture("DiffuseTexture", renderData.Sheet.GetTexture());
            shader.SetVec("PaletteRows", colorPaletteTextureMidIndex, normalsPaletteTextureMidIndex);
            shader.SetMatrix("TransformMatrix", t);
            shader.SetVec("LightDirection", lightDirection, 4);
            shader.SetVec("AmbientLight", ambientLight, 3);
            shader.SetVec("DiffuseLight", diffuseLight, 3);

            shader.Render(() => renderer.DrawBatch(Game.ModData.VoxelLoader.VertexBuffer, renderData.Start, renderData.Count, PrimitiveType.QuadList));
        }
Esempio n. 9
0
        void Render(VoxelRenderData renderData,
                    float[] t, float[] lightDirection,
                    float[] ambientLight, float[] diffuseLight,
                    int colorPalette, int normalsPalette)
        {
            shader.SetTexture("DiffuseTexture", renderData.Sheet.Texture);
            shader.SetVec("PaletteRows", (colorPalette + 0.5f) / HardwarePalette.MaxPalettes,
                          (normalsPalette + 0.5f) / HardwarePalette.MaxPalettes);
            shader.SetMatrix("TransformMatrix", t);
            shader.SetVec("LightDirection", lightDirection, 4);
            shader.SetVec("AmbientLight", ambientLight, 3);
            shader.SetVec("DiffuseLight", diffuseLight, 3);

            shader.Render(() => renderer.DrawBatch(Game.modData.VoxelLoader.VertexBuffer, renderData.Start, renderData.Count, PrimitiveType.QuadList));
        }
Esempio n. 10
0
        public void Flush()
        {
            if (nv > 0)
            {
                shader.Render(() =>
                {
                    var vb = renderer.GetTempVertexBuffer();
                    vb.SetData(vertices, nv);
                    renderer.SetLineWidth(LineWidth * Game.viewport.Zoom);
                    renderer.DrawBatch(vb, 0, nv, PrimitiveType.LineList);
                });

                nv = 0;
            }
        }
Esempio n. 11
0
 public void Flush()
 {
     if (nv > 0)
     {
         renderer.Device.SetBlendMode(BlendMode.Alpha);
         shader.Render(() =>
         {
             var vb = renderer.GetTempVertexBuffer();
             vb.SetData(vertices, nv);
             renderer.SetLineWidth(LineWidth);
             renderer.DrawBatch(vb, 0, nv, PrimitiveType.LineList);
         });
         renderer.Device.SetBlendMode(BlendMode.None);
         nv = 0;
     }
 }
        void Render(
            ModelRenderData renderData,
            IModelCache cache,
            float[] t, float[] lightDirection,
            float[] ambientLight, float[] diffuseLight,
            float colorPaletteTextureMidIndex, float normalsPaletteTextureMidIndex)
        {
            shader.SetTexture("DiffuseTexture", renderData.Sheet.GetTexture());
            shader.SetVec("PaletteRows", colorPaletteTextureMidIndex, normalsPaletteTextureMidIndex);
            shader.SetMatrix("TransformMatrix", t);
            shader.SetVec("LightDirection", lightDirection, 4);
            shader.SetVec("AmbientLight", ambientLight, 3);
            shader.SetVec("DiffuseLight", diffuseLight, 3);

            shader.PrepareRender();
            renderer.DrawBatch(cache.VertexBuffer, renderData.Start, renderData.Count, PrimitiveType.TriangleList);
        }