コード例 #1
0
ファイル: ModelMesh.cs プロジェクト: ElonGame/OpenSAGE
        internal void BuildRenderList(RenderList renderList, RenderInstanceData instanceData, MeshEffect effect)
        {
            var uniquePipelineStates = MaterialPasses
                                       .SelectMany(x => x.MeshParts.Select(y => y.PipelineStateHandle))
                                       .Distinct()
                                       .ToList();

            foreach (var pipelineStateHandle in uniquePipelineStates)
            {
                var filteredMaterialPasses = MaterialPasses
                                             .Where(x => x.MeshParts.Any(y => y.PipelineStateHandle == pipelineStateHandle))
                                             .ToList();

                if (filteredMaterialPasses.Count > 0)
                {
                    renderList.AddRenderItem(new InstancedRenderItem(
                                                 instanceData,
                                                 effect,
                                                 pipelineStateHandle,
                                                 (commandEncoder, e, h, _) =>
                    {
                        Draw(
                            commandEncoder,
                            effect,
                            h,
                            filteredMaterialPasses,
                            instanceData);
                    }));
                }
            }
        }
コード例 #2
0
ファイル: SpriteComponent.cs プロジェクト: ElonGame/OpenSAGE
        internal override void BuildRenderList(RenderList renderList)
        {
            renderList.AddRenderItem(new RenderItem(
                                         this,
                                         _effect,
                                         _pipelineStateHandle,
                                         (commandEncoder, effect, pipelineStateHandle, instanceData) =>
            {
                _effect.SetTexture(Texture);
                _effect.SetMipMapLevel(SelectedMipMapLevel);

                _effect.Apply(commandEncoder);

                commandEncoder.Draw(PrimitiveType.TriangleList, 0, 3);
            }));
        }
コード例 #3
0
        internal override void BuildRenderList(RenderList renderList)
        {
            renderList.AddRenderItem(new RenderItem(
                                         this,
                                         _terrainEffect,
                                         _pipelineStateHandle,
                                         (commandEncoder, effect, pipelineStateHandle, instanceData) =>
            {
                effect.Apply(commandEncoder);

                commandEncoder.SetVertexBuffer(0, _vertexBuffer);

                commandEncoder.DrawIndexed(
                    PrimitiveType.TriangleList,
                    _indexBuffer.ElementCount,
                    _indexBuffer,
                    0);
            }));
        }