Пример #1
0
        public void SetSampler(LeaSamplerState sampler, int slot, ShaderType shaderType)
        {
            switch (shaderType)
            {
            case ShaderType.VertexShader:
                GetVertexShader().SetTextureSampler(sampler.NativeSampler, slot);
                break;

            case ShaderType.PixelShader:
                GetPixelShader().SetTextureSampler(sampler.NativeSampler, slot);
                break;

            default:
                throw new Exception("ShaderStage not supporter yet");
            }
        }
Пример #2
0
        public SpriteBatcher(GraphicsDevice graphicsDevice, int maxBatchSize)
        {
            this.graphicsDevice = graphicsDevice;
            this.maxBatchSize   = maxBatchSize;

            spriteList = new List <SpriteInfo>();
            fontVertex = new FontVertex[maxBatchSize];

            renderBatches = new List <RenderBatchInfo>();

            vertexBuffer = new VertexBuffer(graphicsDevice, BufferUsage.Dynamic);
            vertexBuffer.SetData(fontVertex);

            sampler = new LeaSamplerState();
            sampler.GenerateSamplers(graphicsDevice);

            CreateEffect();
            CreateBlendSates();

            effect.SetVariable("textureAtlasResWidthHeight", "startUp", 512, ShaderType.GeometryShader);
            effect.SetSampler(sampler, 0, ShaderType.PixelShader);
        }