/// <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 BlendFuncSwitch(BlendSrcFactor.SrcAlpha, BlendDestFactor.OneMinusSrcAlpha); var methodBuilder = new RenderMethodBuilder(codes, map, blend); this.RenderUnit = new ModernRenderUnit(model, methodBuilder); this.Initialize(); }
/// <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 BlendFuncSwitch(BlendSrcFactor.SrcAlpha, BlendDestFactor.OneMinusSrcAlpha); 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; }