Beispiel #1
0
        public Renderer()
        {
            if (Instance != null)
            {
                throw CargoEngineException.Create("multiple instances of renderer");
            }
            Instance = this;

            DeviceCreationFlags devFlags = 0;

#if DEBUG
            devFlags |= DeviceCreationFlags.Debug;
#endif
            Device = new Device(SharpDX.Direct3D.DriverType.Hardware, devFlags);

            ImmPipeline = new RenderPipeline(Device.ImmediateContext);

            inputLayouts = new Dictionary <int, InputLayout>();

            for (var i = 0; i < NUM_THREADS; i++)
            {
                var pipeline = new RenderPipeline(Device);
                deferredPipelines[i] = pipeline;
            }

            Shaders = new ShaderLoader(this);
        }
Beispiel #2
0
 public void Apply(RenderPipeline pipeline)
 {
     UpdateBuffers();
     pipeline.InputAssembler.PrimitiveTopology = (PrimitiveTopology)Topology;
     pipeline.InputAssembler.IndexBuffer       = indexBuffer;
     pipeline.InputAssembler.IndexBufferFormat = indexBufferFormat;
     pipeline.InputAssembler.VertexBuffer.SetStates(0, buffers.ToArray());
     pipeline.InputAssembler.InputElements = InputElements;
 }
Beispiel #3
0
 public abstract void Render(RenderPipeline pipeline);
Beispiel #4
0
        public void Deactivate(RenderPipeline pipeline)
        {
            var rts = new RenderTargetView[RenderTargets.Count];

            pipeline.DevContext.OutputMerger.SetRenderTargets(null, rts);
        }