コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static IShaderProgramProvider GetPickingShaderProgramProvider()
        {
            var shaderCodes = new ShaderCode[2];

            shaderCodes[0] = new ShaderCode(GetShaderSource(ShaderType.VertexShader), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(GetShaderSource(ShaderType.FragmentShader), ShaderType.FragmentShader);
            var provider = new ShaderCodeArray(shaderCodes);

            return(provider);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="buildIn"></param>
        /// <returns></returns>
        public static SceneObject GetBuildInSceneObject(BuildInSceneObject buildIn)
        {
            var shaderCodes = new ShaderCode[2];

            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\BuildInSceneObject.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\BuildInSceneObject.frag"), ShaderType.FragmentShader);
            var          provider = new ShaderCodeArray(shaderCodes);
            IBufferable  model    = GetModel(buildIn);
            AttributeMap map      = GetMap(buildIn);
            vec3         lengths  = GetLengths(buildIn);
            var          renderer = new BuildInRenderer(lengths, model, provider, map);
            //renderer.Initialize();

            SceneObject obj = renderer.WrapToSceneObject();

            return(obj);
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static PointsRenderer Create(Points model)
        {
            var shaderCodes = new ShaderCode[2];

            shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Points.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Points.frag"), ShaderType.FragmentShader);
            var provider = new ShaderCodeArray(shaderCodes);
            var map      = new CSharpGL.AttributeMap();

            map.Add("in_Position", Points.strposition);
            var renderer = new PointsRenderer(model, provider, map, Points.strposition);

            renderer.ModelSize     = model.Lengths;
            renderer.WorldPosition = model.WorldPosition;
            renderer.stateList.Add(new PointSizeState(10));

            return(renderer);
        }
コード例 #4
0
        /// <summary>
        /// get a bounding box renderer.
        /// </summary>
        /// <param name="lengths">bounding box's length at x, y, z direction.</param>
        /// <returns></returns>
        public static BoundingBoxRenderer Create(vec3 lengths)
        {
            var model       = new BoundingBoxModel(lengths);
            var shaderCodes = new ShaderCode[2];

            shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(
                                                @"Resources\BoundingBox.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(
                                                @"Resources\BoundingBox.frag"), ShaderType.FragmentShader);
            var provider = new ShaderCodeArray(shaderCodes);
            var map      = new AttributeMap();

            map.Add("in_Position", BoundingBoxModel.strPosition);
            var result = new BoundingBoxRenderer(model, provider, map, new PolygonModeState(PolygonMode.Line), new PolygonOffsetFillState());

            result.ModelSize = lengths;
            return(result);
        }
コード例 #5
0
        /// <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 provider = new ShaderCodeArray(shaderCodes);
            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, provider, map, Square.strPosition);

            renderer.bitmapFilename = bitmapFilename;
            return(renderer);
        }
コード例 #6
0
ファイル: UIAxis.cs プロジェクト: wangrui523/CSharpGL
        /// <summary>
        /// opengl UI for Axis
        /// </summary>
        /// <param name="anchor"></param>
        /// <param name="margin"></param>
        /// <param name="size"></param>
        /// <param name="partCount">24 as default.</param>
        public UIAxis(
            System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin,
            System.Drawing.Size size, int partCount = 24)
            : base(anchor, margin, size, -Math.Max(size.Width, size.Height), Math.Max(size.Width, size.Height))
        {
            var shaderCodes = new ShaderCode[2];

            shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Simple.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Simple.frag"), ShaderType.FragmentShader);
            var provider = new ShaderCodeArray(shaderCodes);
            var map      = new AttributeMap();

            map.Add("in_Position", Axis.strPosition);
            map.Add("in_Color", Axis.strColor);
            var axis     = new Axis(partCount, 0.5f);
            var renderer = new Renderer(axis, provider, map);

            renderer.ModelSize = axis.ModelSize;

            this.Renderer = renderer;
        }