mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Added Camera, Renderer, ... and moved example to sandbox
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using GlitchyEngine.Math;
|
||||
|
||||
namespace GlitchyEngine.Renderer
|
||||
{
|
||||
public class Renderer
|
||||
{
|
||||
struct SceneConstants
|
||||
{
|
||||
public Matrix ViewProjection;
|
||||
}
|
||||
|
||||
static GraphicsContext _context;
|
||||
|
||||
static Buffer<SceneConstants> _sceneConstants ~ delete _;
|
||||
|
||||
public static void Init(GraphicsContext context)
|
||||
{
|
||||
_context = context;
|
||||
_sceneConstants = new Buffer<SceneConstants>(_context, .(0, .Constant, .Dynamic, .Write));
|
||||
_sceneConstants.Update();
|
||||
}
|
||||
|
||||
public static void BeginScene(Camera camera)
|
||||
{
|
||||
_sceneConstants.Data.ViewProjection = camera.ViewProjection;
|
||||
_sceneConstants.Update();
|
||||
}
|
||||
|
||||
public static void EndScene(){}
|
||||
|
||||
public static void Submit(GeometryBinding geometry, Effect effect)
|
||||
{
|
||||
effect.Bind(_context);
|
||||
|
||||
effect.PixelShader?.Buffers.TryReplaceBuffer("SceneConstants", _sceneConstants);
|
||||
effect.VertexShader?.Buffers.TryReplaceBuffer("SceneConstants", _sceneConstants);
|
||||
|
||||
geometry.Bind();
|
||||
RenderCommand.DrawIndexed(geometry);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user