示例#1
0
    public void DrawRectangle(Span <Vertex2d> corners,
                              ITexture texture,
                              ITexture mask             = null,
                              SamplerType2d samplerType = SamplerType2d.CLAMP,
                              bool blending             = true)
    {
        var samplerState = getSamplerState(samplerType);

        if (texture != null && mask != null)
        {
            Trace.Assert(blending);
            _device.SetMaterial(texturedWithMaskMaterial);
            _device.SetSamplerState(0, samplerState);
            _device.SetSamplerState(1, samplerState);
            _device.SetTexture(0, texture);
            _device.SetTexture(1, mask);
        }
        else if (texture != null)
        {
            if (blending)
            {
                _device.SetMaterial(texturedMaterial);
            }
            else
            {
                _device.SetMaterial(texturedWithoutBlendingMaterial);
            }

            _device.SetSamplerState(0, samplerState);
            _device.SetTexture(0, texture);
        }
        else
        {
            _device.SetMaterial(untexturedMaterial);
        }

        DrawRectangle(corners);

        if (texture != null)
        {
            _device.SetTexture(0, Textures.InvalidTexture);
        }

        if (mask != null)
        {
            _device.SetTexture(1, Textures.InvalidTexture);
        }
    }
示例#2
0
    private void BindQuadMaterial(IGameViewport viewport, PackedLinearColorA color, ITexture texture)
    {
        _device.SetMaterial(_quadMaterial);

        Shape3dGlobals globals;

        globals.viewProj = viewport.Camera.GetViewProj();
        globals.colors   = color.ToRGBA();

        _device.SetVertexShaderConstants(0, ref globals);

        _device.SetTexture(0, texture);
    }