Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="capacity"></param>
        /// <param name="anchor"></param>
        public CtrlLabel(int capacity, GUIAnchorStyles anchor)
            : base(anchor)
        {
            if (capacity < 0)
            {
                throw new ArgumentException("capacity");
            }

            this.Size = new GUISize(20, 20);

            var model = new GlyphsModel(capacity);

            this.labelModel = model;
            var vs    = new VertexShader(vert);
            var fs    = new FragmentShader(frag);
            var codes = new ShaderArray(vs, fs);
            var map   = new AttributeMap();

            map.Add(inPosition, GlyphsModel.position);
            map.Add(inSTR, GlyphsModel.STR);
            var blend         = new BlendSwitch(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.OneMinusSourceAlpha);
            var methodBuilder = new RenderMethodBuilder(codes, map, blend);

            this.RenderUnit = new ModernRenderUnit(model, methodBuilder);

            this.Initialize();
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a billboard in 3D world. Its size is described by Width\Height(in pixels).
        /// </summary>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="capacity">Maximum characters count.</param>
        /// <param name="glyphServer"></param>
        /// <returns></returns>
        public static TextBillboardNode Create(int width, int height, int capacity, GlyphServer glyphServer = null)
        {
            var vs       = new VertexShader(vertexCode);// this vertex shader has no vertex attributes.
            var fs       = new FragmentShader(fragmentCode);
            var provider = new ShaderArray(vs, fs);
            var map      = new AttributeMap();

            map.Add(inPosition, GlyphsModel.position);
            map.Add(inSTR, GlyphsModel.STR);
            var blendState = new BlendSwitch(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.OneMinusSourceAlpha);
            var builder    = new RenderMethodBuilder(provider, map, blendState);
            var node       = new TextBillboardNode(width, height, new GlyphsModel(capacity), builder, glyphServer);

            node.Initialize();
            node.blend = blendState;

            return(node);
        }