Example #1
0
        public ImperativeRenderer(
            IBatchContainer container,
            DefaultMaterialSet materials,
            int layer = 0,
            RasterizerState rasterizerState     = null,
            DepthStencilState depthStencilState = null,
            BlendState blendState                     = null,
            SamplerState samplerState                 = null,
            bool worldSpace                           = true,
            bool useZBuffer                           = false,
            bool autoIncrementSortKey                 = false,
            bool autoIncrementLayer                   = false,
            bool lowPriorityMaterialOrdering          = false,
            Sorter <BitmapDrawCall> declarativeSorter = null,
            Tags tags = default(Tags)
            )
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }
            if (materials == null)
            {
                throw new ArgumentNullException("materials");
            }

            Container                   = container;
            Materials                   = materials;
            Layer                       = layer;
            RasterizerState             = rasterizerState;
            DepthStencilState           = depthStencilState;
            BlendState                  = blendState;
            SamplerState                = samplerState;
            UseZBuffer                  = useZBuffer;
            WorldSpace                  = worldSpace;
            AutoIncrementSortKey        = autoIncrementSortKey;
            AutoIncrementLayer          = autoIncrementLayer;
            NextSortKey                 = new DrawCallSortKey(tags, 0);
            Cache                       = new CachedBatches();
            LowPriorityMaterialOrdering = lowPriorityMaterialOrdering;
            DeclarativeSorter           = declarativeSorter;
        }
Example #2
0
        public static StringLayout LayoutString(
            this SpriteFont font, AbstractString text, ArraySegment <BitmapDrawCall>?buffer = null,
            Vector2?position                  = null, Color?color = null, float scale = 1,
            DrawCallSortKey sortKey           = default(DrawCallSortKey),
            int characterSkipCount            = 0, int?characterLimit = null,
            float xOffsetOfFirstLine          = 0, float?lineBreakAtX = null,
            GlyphPixelAlignment alignToPixels = default(GlyphPixelAlignment),
            Dictionary <char, KerningAdjustment> kerningAdjustments = null,
            bool wordWrap = false, char wrapCharacter = '\0'
            )
        {
            var state = new StringLayoutEngine {
                position           = position,
                color              = color,
                scale              = scale,
                sortKey            = sortKey,
                characterSkipCount = characterSkipCount,
                characterLimit     = characterLimit,
                xOffsetOfFirstLine = xOffsetOfFirstLine,
                lineBreakAtX       = lineBreakAtX,
                alignToPixels      = alignToPixels,
                characterWrap      = lineBreakAtX.HasValue,
                wordWrap           = wordWrap,
                wrapCharacter      = wrapCharacter,
                buffer             = buffer.GetValueOrDefault(default(ArraySegment <BitmapDrawCall>))
            };
            var gs = new SpriteFontGlyphSource(font);

            state.Initialize();

            using (state) {
                var segment = state.AppendText(
                    gs, text, kerningAdjustments
                    );

                return(state.Finish());
            }
        }