41 lines
1.2 KiB
C#

using System;
using System.Drawing;
using System.Numerics;
using SlatedGameToolkit.Framework.Exceptions;
using SlatedGameToolkit.Framework.Graphics.Programs;
using SlatedGameToolkit.Framework.Graphics.Textures;
namespace SlatedGameToolkit.Framework.Graphics.Render
{
public class Renderer : IDisposable
{
private Batch batch;
private Texture currentTexture;
public Renderer(Batch batch) {
this.batch = batch;
}
public Renderer(Camera camera, GLShaderProgram program, uint BatchVertexSize = 4096) {
this.batch = new Batch(camera, program, BatchVertexSize);
}
public void Dispose()
{
batch.Dispose();
}
public void Queue(IRenderable renderable, Matrix4x4 modelsMatrix) {
if (renderable.Texture != currentTexture) {
if (batch.Batching) batch.End();
currentTexture = renderable.Texture;
batch.Begin(currentTexture, modelsMatrix);
}
batch.Add(renderable, renderable.Color);
}
public void Render() {
if (batch.Batching) batch.End();
}
}
}