/// <summary> /// opengl UI for Cursor. /// Note: put this as the last one of <see cref="SceneRootUI"/>'s children. /// </summary> /// <param name="focalPoint">in percentage(0.00 ~ 1.00).<paramref name="focalPoint"/>.X ranges from 0(left) to 1(right). <paramref name="focalPoint"/>.Y ranges from 0(bottom) to 1(top).</param> /// <param name="size"></param> /// <param name="cursorBitmap"></param> public UICursor(PointF focalPoint, Size size, string cursorBitmap = "") : base(AnchorStyles.Left | AnchorStyles.Top, new Padding(0, 0, 0, 0), size, -Math.Max(size.Width, size.Height), Math.Max(size.Width, size.Height)) { this.FocalPoint = focalPoint; TextureRenderer renderer = TextureRenderer.Create(cursorBitmap); renderer.StateList.Add(new BlendState(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.OneMinusSourceAlpha)); this.Renderer = renderer; }
/// <summary> /// Gets a renderer that renders a bitmap in a square. /// </summary> /// <param name="bitmapFilename"></param> /// <returns></returns> public static TextureRenderer Create(string bitmapFilename = "") { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.SquareRenderer.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.SquareRenderer.frag"), ShaderType.FragmentShader); var map = new AttributeMap(); map.Add("in_Position", Square.strPosition); map.Add("in_TexCoord", Square.strTexCoord); var model = new Square(); var renderer = new TextureRenderer(model, shaderCodes, map, Square.strPosition); renderer.bitmapFilename = bitmapFilename; return renderer; }
/// <summary> /// Gets a renderer that renders a bitmap in a square. /// </summary> /// <param name="bitmapFilename"></param> /// <returns></returns> public static TextureRenderer Create(string bitmapFilename = "") { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.SquareRenderer.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile( @"Resources.SquareRenderer.frag"), ShaderType.FragmentShader); var map = new AttributeMap(); map.Add("in_Position", Square.strPosition); map.Add("in_TexCoord", Square.strTexCoord); var model = new Square(); var renderer = new TextureRenderer(model, shaderCodes, map, Square.strPosition); renderer.bitmapFilename = bitmapFilename; return(renderer); }