コード例 #1
0
ファイル: LabelRenderer.cs プロジェクト: bitzhuwei/CSharpGL
        /// <summary>
        /// Create a label renderer.
        /// </summary>
        /// <param name="maxCharCount">Max char count to display for this label. Careful to set this value because greater <paramref name="maxCharCount"/> means more space ocupied in GPU nemory.</param>
        /// <param name="labelHeight">Label height(in pixels)</param>
        /// <param name="fontTexture">Use which font to render text?</param>
        /// <returns></returns>
        public static LabelRenderer Create(int maxCharCount = 64, int labelHeight = 32, IFontTexture fontTexture = null)
        {
            if (fontTexture == null) { fontTexture = FontTexture.Default; }

            var model = new TextModel(maxCharCount);

            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(
                @"Resources\Label.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(
                @"Resources\Label.frag"), ShaderType.FragmentShader);

            var map = new AttributeMap();
            map.Add("in_Position", TextModel.strPosition);
            map.Add("in_UV", TextModel.strUV);

            var blendState = new BlendState(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.One);

            var renderer = new LabelRenderer(model, shaderCodes, map, blendState);
            renderer.blendState = blendState;
            renderer.fontTexture = fontTexture;
            renderer.LabelHeight = labelHeight;

            return renderer;
        }
コード例 #2
0
 public OrderIndependentTransparencyRenderer(IBufferable model, vec3 lengths,
     string positionName, string normalName)
 {
     {
         var map = new AttributeMap();
         map.Add("position", positionName);
         map.Add("normal", normalName);
         var build_lists = new ShaderCode[2];
         build_lists[0] = new ShaderCode(File.ReadAllText(@"shaders\OIT\build_lists.vert"), ShaderType.VertexShader);
         build_lists[1] = new ShaderCode(File.ReadAllText(@"shaders\OIT\build_lists.frag"), ShaderType.FragmentShader);
         this.buildListsRenderer = new PickableRenderer(model, build_lists, map, positionName);
     }
     {
         var map = new AttributeMap();
         map.Add("position", positionName);
         var resolve_lists = new ShaderCode[2];
         resolve_lists[0] = new ShaderCode(File.ReadAllText(@"shaders\OIT\resolve_lists.vert"), ShaderType.VertexShader);
         resolve_lists[1] = new ShaderCode(File.ReadAllText(@"shaders\OIT\resolve_lists.frag"), ShaderType.FragmentShader);
         this.resolve_lists = new PickableRenderer(model, resolve_lists, map, positionName);
     }
     {
         this.depthTestState = new DepthTestState(false);
         this.cullFaceState = new CullFaceState(false);
     }
     this.ModelSize = lengths;
 }
コード例 #3
0
        public static QuadStripRenderer Create(QuadStripModel model)
        {
            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\QuadStripTexture.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\QuadStripTexture.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();
            map.Add("in_Position", QuadStripModel.position);
            map.Add("in_TexCoord", QuadStripModel.texCoord);

            var renderer = new QuadStripRenderer(model, shaderCodes, map);
            return renderer;
        }
コード例 #4
0
        public static QuadStripColoredRenderer Create(QuadStripColoredModel model)
        {
            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\QuadStripColor.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\QuadStripColor.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();
            map.Add("in_Position", QuadStripColoredModel.position);
            map.Add("in_Color", QuadStripColoredModel.color);

            var renderer = new QuadStripColoredRenderer(model, shaderCodes, map);
            renderer.quadCount = model.quadCount;
            return renderer;
        }
コード例 #5
0
ファイル: LightRenderer.cs プロジェクト: bitzhuwei/CSharpGL
 internal static LightRenderer Create(Teapot model, vec3 lengths, string positionNameInIBufferable)
 {
     var shaderCodes = new ShaderCode[2];
     shaderCodes[0] = new ShaderCode(System.IO.File.ReadAllText(@"shaders\LightRenderer\Light.vert"), ShaderType.VertexShader);
     shaderCodes[1] = new ShaderCode(System.IO.File.ReadAllText(@"shaders\LightRenderer\Light.frag"), ShaderType.FragmentShader);
     var map = new AttributeMap();
     map.Add("in_Position", Teapot.strPosition);
     map.Add("in_Normal", Teapot.strNormal);
     //map.Add("in_Color", Teapot.strColor);
     var renderer = new LightRenderer(model, shaderCodes, map, positionNameInIBufferable);
     renderer.Lengths = lengths;
     return renderer;
 }
コード例 #6
0
 public static CatesianGridRenderer Create(vec3 originalWorldPosition, CatesianGrid grid, Texture codedColorSampler)
 {
     var shaderCodes = new ShaderCode[2];
     shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\HexahedronGrid.vert"), ShaderType.VertexShader);
     shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\HexahedronGrid.frag"), ShaderType.FragmentShader);
     var map = new AttributeMap();
     map.Add("in_Position", CatesianGrid.strPosition);
     map.Add("in_uv", CatesianGrid.strColor);
     var renderer = new CatesianGridRenderer(originalWorldPosition, grid, shaderCodes, map, codedColorSampler);
     renderer.ModelSize = (grid.DataSource.SourceActiveBounds.MaxPosition - grid.DataSource.SourceActiveBounds.MinPosition).Abs();
     renderer.WorldPosition = -grid.DataSource.Position;
     return renderer;
 }
コード例 #7
0
        public static KleinBottleRenderer Create(KleinBottleModel model)
        {
            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\KleinBottleRenderer\KleinBottle.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\KleinBottleRenderer\KleinBottle.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();
            map.Add("in_Position", KleinBottleModel.strPosition);
            map.Add("in_TexCoord", KleinBottleModel.strTexCoord);
            var renderer = new KleinBottleRenderer(model, shaderCodes, map, KleinBottleModel.strPosition);
            renderer.ModelSize = model.Lengths;

            return renderer;
        }
コード例 #8
0
        public static UniformArrayRenderer Create()
        {
            var model = new Teapot();
            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\UniformArrayRenderer\UniformArray.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\UniformArrayRenderer\UniformArray.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();
            map.Add("vPos", Teapot.strPosition);
            map.Add("vColor", Teapot.strColor);
            var renderer = new UniformArrayRenderer(model, shaderCodes, map);
            renderer.ModelSize = model.Size;

            return renderer;
        }
コード例 #9
0
        public static HemisphereLightingRenderer Create()
        {
            var model = new Teapot();
            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\HemisphereLighting\HemisphereLighting.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\HemisphereLighting\HemisphereLighting.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();
            map.Add("inPosition", Teapot.strPosition);
            map.Add("inNormal", Teapot.strNormal);

            var renderer = new HemisphereLightingRenderer(model, shaderCodes, map, Teapot.strPosition);
            renderer.ModelSize = model.Size;
            return renderer;
        }
コード例 #10
0
        private Renderer InitRaycastRenderer()
        {
            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\RaycastVolumeRenderer\raycasting.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\RaycastVolumeRenderer\raycasting.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();
            map.Add("position", RaycastModel.strposition);
            map.Add("boundingBox", RaycastModel.strcolor);
            var raycastRenderer = new Renderer(model, shaderCodes, map);
            raycastRenderer.Initialize();
            raycastRenderer.StateList.Add(new CullFaceState(CullFaceMode.Back, true));

            return raycastRenderer;
        }
コード例 #11
0
        public static GreyFilterRenderer Create()
        {
            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\GreyFilterRenderer\GreyFilter.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\GreyFilterRenderer\GreyFilter.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();
            map.Add("a_vertex", GreyFilterModel.strPosition);
            map.Add("a_texCoord", GreyFilterModel.strTexCoord);
            var model = new GreyFilterModel();
            var renderer = new GreyFilterRenderer(model, shaderCodes, map, new PointSpriteState());
            renderer.ModelSize = model.Lengths;

            return renderer;
        }
コード例 #12
0
ファイル: TextureRenderer.cs プロジェクト: bitzhuwei/CSharpGL
 /// <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;
 }
コード例 #13
0
        public static InnerImageProcessingRenderer Create(string textureFilename = @"Textures\edgeDetection.bmp")
        {
            var model = new ImageProcessingModel();
            ShaderCode[] simpleShader = new ShaderCode[2];
            simpleShader[0] = new ShaderCode(File.ReadAllText(@"shaders\ImageProcessingRenderer\ImageProcessing.vert"), ShaderType.VertexShader);
            simpleShader[1] = new ShaderCode(File.ReadAllText(@"shaders\ImageProcessingRenderer\ImageProcessing.frag"), ShaderType.FragmentShader);
            var propertyNameMap = new AttributeMap();
            propertyNameMap.Add("vert", "position");
            propertyNameMap.Add("uv", "uv");
            var renderer = new InnerImageProcessingRenderer(
                model, simpleShader, propertyNameMap, ImageProcessingModel.strposition);
            renderer.textureFilename = textureFilename;

            return renderer;
        }
コード例 #14
0
        /// <summary>
        /// 根据<see cref="IndexBuffer"/>的具体类型获取一个<see cref="PickableRenderer"/>
        /// </summary>
        /// <param name="model"></param>
        /// <param name="attributeMap"></param>
        /// <param name="positionNameInIBufferable"></param>
        /// <param name="switches"></param>
        /// <returns></returns>
        public static InnerPickableRenderer GetRenderer(
            this IBufferable model,
            AttributeMap attributeMap,
            string positionNameInIBufferable,
            params GLState[] switches)
        {
            if (model == null || attributeMap == null || string.IsNullOrEmpty(positionNameInIBufferable))
            { throw new ArgumentNullException(); }

            AttributeMap map = null;
            foreach (AttributeMap.NamePair item in attributeMap)
            {
                if (item.NameInIBufferable == positionNameInIBufferable)
                {
                    map = new AttributeMap();
                    map.Add(item.VarNameInShader, item.NameInIBufferable);
                    break;
                }
            }
            if (map == null) { throw new Exception(string.Format("No matching variable name in shader for [{0}]", positionNameInIBufferable)); }

            if (model.UsesZeroIndexBuffer())
            {
                return new ZeroIndexRenderer(model, PickingShaderHelper.GetShaderCodes(), map, positionNameInIBufferable, switches);
            }
            else
            {
                return new OneIndexRenderer(model, PickingShaderHelper.GetShaderCodes(), map, positionNameInIBufferable, switches);
            }
        }
コード例 #15
0
ファイル: UIAxis.cs プロジェクト: bitzhuwei/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 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, shaderCodes, map);
            renderer.ModelSize = axis.ModelSize;

            this.Renderer = renderer;
        }
コード例 #16
0
ファイル: TextRenderer.cs プロジェクト: bitzhuwei/CSharpGL
        /// <summary>
        /// Create a text renderer.
        /// </summary>
        /// <param name="maxCharCount">Max char count to display for this label. Careful to set this value because greater <paramref name="maxCharCount"/> means more space ocupied in GPU nemory.</param>
        /// <param name="labelHeight">Label height(in pixels)</param>
        /// <param name="fontTexture">Use which font to render text?</param>
        /// <returns></returns>
        public static TextRenderer Create(int maxCharCount = 64, int labelHeight = 32, IFontTexture fontTexture = null)
        {
            if (fontTexture == null) { fontTexture = FontTexture.Default; }// FontResource.Default; }

            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(
            @"Resources.TextModel.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(
            @"Resources.TextModel.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();
            map.Add("position", TextModel.strPosition);
            map.Add("uv", TextModel.strUV);
            var model = new TextModel(maxCharCount);
            var renderer = new TextRenderer(model, shaderCodes, map);
            renderer.fontTexture = fontTexture;

            return renderer;
        }
コード例 #17
0
 public static SimpleComputeRenderer Create()
 {
     var shaderCodes = new ShaderCode[2];
     shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\SimpleComputeRenderer\compute.vert"), ShaderType.VertexShader);
     shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\SimpleComputeRenderer\compute.frag"), ShaderType.FragmentShader);
     var map = new AttributeMap();
     map.Add("position", SimpleCompute.strPosition);
     return new SimpleComputeRenderer(new SimpleCompute(), shaderCodes, map);
 }
コード例 #18
0
ファイル: GroundRenderer.cs プロジェクト: bitzhuwei/CSharpGL
 public static GroundRenderer Create(GroundModel model)
 {
     var shaderCodes = new ShaderCode[2];
     shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\Ground.vert"), ShaderType.VertexShader);
     shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\Ground.frag"), ShaderType.FragmentShader);
     var map = new AttributeMap();
     map.Add("in_Position", GroundModel.strPosition);
     var renderer = new GroundRenderer(model, shaderCodes, map);
     return renderer;
 }
コード例 #19
0
        public static BasicTessellationNode Create(ObjVNF model)
        {
            var vs       = new VertexShader(renderVert);
            var tc       = new TessControlShader(renderTesc);
            var te       = new TessEvaluationShader(renderTese);
            var fs       = new FragmentShader(renderFrag);
            var provider = new ShaderArray(vs, tc, te, fs);
            var map      = new AttributeMap();

            map.Add("Position_VS_in", ObjVNF.strPosition);
            map.Add("TexCoord_VS_in", ObjVNF.strTexCoord);
            map.Add("Normal_VS_in", ObjVNF.strNormal);
            var builder = new RenderMethodBuilder(provider, map);

            var node = new BasicTessellationNode(model, builder);

            node.ModelSize = model.GetSize();
            node.Initialize();

            return(node);
        }
コード例 #20
0
        public static EZMTextureNode Create(EZMTextureModel model)
        {
            int    boneCount          = model.BoneCount;
            string completeVertexCode = vertexCode.Replace("UNDEFINED_BONE_COUNT", string.Format("{0}", boneCount));
            var    vs    = new VertexShader(completeVertexCode);
            var    fs    = new FragmentShader(fragmentCode);
            var    array = new ShaderArray(vs, fs);
            var    map   = new AttributeMap();

            map.Add("inPosition", EZMTextureModel.strPosition);
            //map.Add("inNormal", EZMTextureModel.strNormal);
            map.Add("inUV", EZMTextureModel.strUV);
            map.Add("inBlendWeights", EZMTextureModel.strBlendWeights);
            map.Add("inBlendIndices", EZMTextureModel.strBlendIndices);
            var builder = new RenderMethodBuilder(array, map);//, new PolygonModeSwitch(PolygonMode.Line));
            var node    = new EZMTextureNode(model, builder);

            node.Initialize();

            return(node);
        }
コード例 #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <param name="position"></param>
        /// <param name="normal"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public static DirectionalLightNode Create(CSharpGL.DirectionalLight light, IBufferSource model, string position, string normal, vec3 size)
        {
            var vs       = new VertexShader(directionalLightVert);
            var fs       = new FragmentShader(directionalLightFrag);
            var provider = new ShaderArray(vs, fs);
            var map      = new AttributeMap();

            map.Add(vPosition, position);
            map.Add(vNormal, normal);
            var builder = new RenderMethodBuilder(provider, map);

            var node = new DirectionalLightNode(model, position, builder);

            node.Light     = light;
            node.ModelSize = size;
            node.Children.Add(new LegacyBoundingBoxNode(size));

            node.Initialize();

            return(node);
        }
コード例 #22
0
        public static SimpleComputeRenderer Create()
        {
            var shaderCodes = new ShaderCode[2];

            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\SimpleComputeRenderer\compute.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\SimpleComputeRenderer\compute.frag"), ShaderType.FragmentShader);
            var provider = new ShaderCodeArray(shaderCodes);
            var map      = new AttributeMap();

            map.Add("position", SimpleCompute.strPosition);
            return(new SimpleComputeRenderer(new SimpleCompute(), provider, map));
        }
コード例 #23
0
        public static FanNode Create(float radius)
        {
            var vs    = new VertexShader(vertexCode);
            var fs    = new FragmentShader(fragmentCode);
            var array = new ShaderArray(vs, fs);
            var map   = new AttributeMap();

            map.Add("inPosition", FanModel.strPosition);
            map.Add("inColor", FanModel.strColor);
            //var depthTestSwitch = new DepthTestSwitch(false);
            //var polygonModeSwitch = new PolygonModeSwitch(PolygonMode.Line);
            var builder = new RenderMethodBuilder(array, map);

            var model = new FanModel(radius);
            var node  = new FanNode(model, builder);

            node.radius = radius;
            node.Initialize();

            return(node);
        }
コード例 #24
0
        public static AccumulationNode Create()
        {
            var model = new Sphere();
            RenderMethodBuilder renderBuilder;
            {
                var vs       = new VertexShader(renderVert);
                var fs       = new FragmentShader(renderFrag);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add("inPosition", Sphere.strPosition);
                map.Add("inColor", Sphere.strColor);
                var blend = new BlendState(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.OneMinusSourceAlpha);
                renderBuilder = new RenderMethodBuilder(provider, map);
            }
            var node = new AccumulationNode(model, renderBuilder);

            node.ModelSize = model.Size;
            node.Initialize();

            return(node);
        }
コード例 #25
0
ファイル: CubeNode.cs プロジェクト: KiwiPapa/some_c_projects
        public static CubeNode Create(Texture texture0, Texture texture1)
        {
            // vertex buffer and index buffer.
            var model = new CubeModel();
            RenderMethodBuilder singleColorBuilder, multiTextureBuilder;
            {
                // vertex shader and fragment shader.
                var vs    = new VertexShader(singleColorVert);
                var fs    = new FragmentShader(singleColorFrag);
                var array = new ShaderArray(vs, fs);
                // which vertex buffer maps to which attribute in shader.
                var map = new AttributeMap();
                map.Add("inPosition", CubeModel.strPosition);
                // build a render method.
                var polygonModeSwitch = new PolygonModeSwitch(PolygonMode.Line);
                var lineWidth         = new LineWidthSwitch(4);
                singleColorBuilder = new RenderMethodBuilder(array, map, polygonModeSwitch, lineWidth);
            }
            {
                // vertex shader and fragment shader.
                var vs    = new VertexShader(multiTextureVert);
                var fs    = new FragmentShader(multiTextureFrag);
                var array = new ShaderArray(vs, fs);
                // which vertex buffer maps to which attribute in shader.
                var map = new AttributeMap();
                map.Add("inPosition", CubeModel.strPosition);
                map.Add("inTexCoord", CubeModel.strTexCoord);
                // build a render method.
                multiTextureBuilder = new RenderMethodBuilder(array, map);
            }
            // create node.
            var node = new CubeNode(model, singleColorBuilder, multiTextureBuilder);

            node.SetTextures(texture0, texture1);
            // initialize node.
            node.Initialize();

            return(node);
        }
コード例 #26
0
        public static BillboardRenderer Create(IBufferable model)
        {
            var shaderCodes = new ShaderCode[2];

            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\billboard.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\billboard.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();

            map.Add("in_Positions", BillboardModel.strPosition);
            var billboardRenderer = new BillboardRenderer(model, shaderCodes, map);

            return(billboardRenderer);
        }
コード例 #27
0
        public static PointSpriteRenderer Create(int particleCount)
        {
            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\PointSprite.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\PointSprite.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();
            map.Add("position", PointSpriteModel.strposition);
            var model = new PointSpriteModel(particleCount);
            var renderer = new PointSpriteRenderer(model, shaderCodes, map, new PointSpriteState());
            renderer.ModelSize = model.Lengths;

            return renderer;
        }
コード例 #28
0
        public static GroundRenderer Create(GroundModel model)
        {
            var shaderCodes = new ShaderCode[2];

            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\Ground.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\Ground.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();

            map.Add("in_Position", GroundModel.strPosition);
            var renderer = new GroundRenderer(model, shaderCodes, map);

            return(renderer);
        }
コード例 #29
0
        public static ShaderToyRenderer Create()
        {
            var model = new Cube();
            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\ShaderToy.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\ShaderToy.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();
            map.Add("in_Position", Cube.strPosition);
            var renderer = new ShaderToyRenderer(model, shaderCodes, map);
            renderer.ModelSize = model.Lengths;

            return renderer;
        }
コード例 #30
0
        public static SimplexNoiseRenderer Create()
        {
            var model = new Sphere(1, 180, 360);
            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\SimplexNoise.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\SimplexNoise.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();
            map.Add("in_Position", Sphere.strPosition);
            var renderer = new SimplexNoiseRenderer(model, shaderCodes, map, Sphere.strPosition);
            renderer.ModelSize = model.Lengths;

            return renderer;
        }
コード例 #31
0
        /// <summary>
        /// 创建CSharpGL认可的模型
        /// </summary>
        /// <param name="flag">0=sp,1=dp,2=model</param>
        /// <param name="path">点云路径</param>
        /// <returns>模型</returns>
        public static Model3DNode Create(int flag, string path)
        {
            IBufferSource model; vec3 size;
            Model3D       m = new Model3D();

            size = m.GetModelSize();
            if (flag == 0)
            {
                m.LoadSparsePC(path);
            }
            else if (flag == 1)
            {
                m.LoadDensePC(path);
            }
            else if (flag == 2)
            {
                m.LoadModel(path);
            }
            model = m;

            string position = Model3D.strPosition;
            string color    = Model3D.strColor;

            var vs       = new VertexShader(vertexCode);
            var fs       = new FragmentShader(fragmentCode);
            var provider = new ShaderArray(vs, fs);
            var map      = new AttributeMap();

            map.Add(inPosition, position);
            map.Add(inColor, color);
            var builder = new RenderMethodBuilder(provider, map);
            var node    = new Model3DNode(model, position, builder);

            node.Initialize();
            node.ModelSize = size;

            return(node);
        }
コード例 #32
0
        public static StaticSlicesNode Create(int sliceCount, Texture texture1D, Texture texture3D)
        {
            var vs    = new VertexShader(vertexCode);
            var fs    = new FragmentShader(fragmentCode);
            var array = new ShaderArray(vs, fs);
            var map   = new AttributeMap();

            map.Add("inPosition", StaticSlicesModel.strPosition);
            map.Add("inTexCoord", StaticSlicesModel.strTexCoord);
            //var depthTestSwitch = new DepthTestSwitch(false);
            //var polygonModeSwitch = new PolygonModeSwitch(PolygonMode.Line);
            var blendSwitch = new BlendSwitch(BlendEquationMode.Add, BlendSrcFactor.SrcAlpha, BlendDestFactor.OneMinusSrcAlpha);
            var builder     = new RenderMethodBuilder(array, map, blendSwitch);

            var model = new StaticSlicesModel(sliceCount);
            var node  = new StaticSlicesNode(model, builder);

            node.texture1D = texture1D;
            node.texture3D = texture3D;
            node.Initialize();

            return(node);
        }
コード例 #33
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static TexturedNode Create(ObjVNFMesh mesh)
        {
            var model = new ObjVNF(mesh);
            RenderMethodBuilder builder;
            {
                var vs       = new VertexShader(vertexCode);
                var fs       = new FragmentShader(fragmentCode);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add("inPosition", ObjVNF.strPosition);
                map.Add("inNormal", ObjVNF.strNormal);
                map.Add("inTexCoord", ObjVNF.strTexCoord);
                builder = new RenderMethodBuilder(provider, map);
            }
            var node = new TexturedNode(model, ObjVNF.strPosition, builder);

            node.ModelSize     = model.GetSize();
            node.WorldPosition = model.GetPosition();

            node.Initialize();

            return(node);
        }
コード例 #34
0
        public static AxisNode Create()
        {
            // vertex buffer and index buffer.
            var model = new AxisModel();
            // vertex shader and fragment shader.
            var vs    = new VertexShader(vertexCode);
            var fs    = new FragmentShader(fragmentCode);
            var array = new ShaderArray(vs, fs);
            // which vertex buffer maps to which attribute in shader.
            var map = new AttributeMap();

            map.Add("inPosition", AxisModel.strPosition);
            map.Add("inColor", AxisModel.strColor);
            // build a render method.
            var builder = new RenderMethodBuilder(array, map, new LineWidthSwitch(5));
            // create node.
            var node = new AxisNode(model, builder);

            // initialize node.
            node.Initialize();

            return(node);
        }
コード例 #35
0
        public static FixedPercentRenderer Create(GroundModel model)
        {
            var shaderCodes = new ShaderCode[2];

            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\FixedPercent.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\FixedPercent.frag"), ShaderType.FragmentShader);
            var provider = new ShaderCodeArray(shaderCodes);
            var map      = new AttributeMap();

            map.Add("in_Position", GroundModel.strPosition);
            var renderer = new FixedPercentRenderer(model, provider, map);

            return(renderer);
        }
コード例 #36
0
        public static CubeNode Create()
        {
            // model provides vertex buffer and index buffer(within an IDrawCommand).
            var model = new CubeModel();
            // vertex shader and fragment shader.
            var vs    = new VertexShader(vertexCode);
            var fs    = new FragmentShader(fragmentCode);
            var array = new ShaderArray(vs, fs);
            // which vertex buffer maps to which attribute in shader.
            var map = new AttributeMap();

            map.Add("inPosition", CubeModel.strPosition);
            map.Add("inColor", CubeModel.strColor);
            // help to build a render method.
            var builder = new RenderMethodBuilder(array, map);
            // create node.
            var node = new CubeNode(model, builder);

            // initialize node.
            node.Initialize();

            return(node);
        }
コード例 #37
0
        public static ShadowVolumeNode Create(IBufferSource model, string position, string normal, vec3 size)
        {
            RenderMethodBuilder ambientBuilder, extrudeBuilder, underLightBuilder;
            {
                var vs    = new VertexShader(ambientVert);
                var fs    = new FragmentShader(ambientFrag);
                var array = new ShaderArray(vs, fs);
                var map   = new AttributeMap();
                map.Add("inPosition", position);
                ambientBuilder = new RenderMethodBuilder(array, map);
            }
            {
                var vs    = new VertexShader(extrudeVert);
                var gs    = new GeometryShader(extrudeGeom);
                var fs    = new FragmentShader(extrudeFrag);
                var array = new ShaderArray(vs, gs, fs);
                var map   = new AttributeMap();
                map.Add("inPosition", position);
                extrudeBuilder = new RenderMethodBuilder(array, map);
            }
            {
                var vs    = new VertexShader(blinnPhongVert);
                var fs    = new FragmentShader(blinnPhongFrag);
                var array = new ShaderArray(vs, fs);
                var map   = new AttributeMap();
                map.Add("inPosition", position);
                map.Add("inNormal", normal);
                underLightBuilder = new RenderMethodBuilder(array, map);
            }

            var node = new ShadowVolumeNode(model, ambientBuilder, extrudeBuilder, underLightBuilder);

            node.Initialize();
            node.ModelSize = size;

            return(node);
        }
コード例 #38
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <param name="position"></param>
        /// <param name="normal"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public static NormalNode Create(IBufferSource model, string position, string texCoord, string normal, vec3 size)
        {
            var builders = new RenderMethodBuilder[2];
            {
                // render model
                var vs       = new VertexShader(vertexShader);
                var fs       = new FragmentShader(fragmentShader);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add(vPosition, position);
                map.Add(vTexCoord, texCoord);
                map.Add(vNormal, normal);
                builders[0] = new RenderMethodBuilder(provider, map);
            }
            {
                // render normal
                var vs       = new VertexShader(normalVertex);
                var gs       = new GeometryShader(normalGeometry);
                var fs       = new FragmentShader(normalFragment);
                var provider = new ShaderArray(vs, gs, fs);
                var map      = new AttributeMap();
                map.Add(vPosition, position);
                map.Add(vNormal, normal);
                builders[1] = new RenderMethodBuilder(provider, map);
            }

            var    node   = new NormalNode(model, position, texCoord, builders);
            string folder = System.Windows.Forms.Application.StartupPath;

            node.TextureSource = new TextureSource(System.IO.Path.Combine(folder, @"superficie.png"));
            node.ModelSize     = size;

            node.Initialize();

            return(node);
        }
コード例 #39
0
ファイル: TextRenderer.cs プロジェクト: ihaiucom/CSharpGL
        /// <summary>
        /// Create a text renderer.
        /// </summary>
        /// <param name="maxCharCount">Max char count to display for this label. Careful to set this value because greater <paramref name="maxCharCount"/> means more space ocupied in GPU nemory.</param>
        /// <param name="labelHeight">Label height(in pixels)</param>
        /// <param name="fontTexture">Use which font to render text?</param>
        /// <returns></returns>
        public static TextRenderer Create(int maxCharCount = 64, int labelHeight = 32, IFontTexture fontTexture = null)
        {
            if (fontTexture == null)
            {
                fontTexture = FontTexture.Default;
            }                                                              // FontResource.Default; }

            var shaderCodes = new ShaderCode[2];

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

            map.Add("position", TextModel.strPosition);
            map.Add("uv", TextModel.strUV);
            var model    = new TextModel(maxCharCount);
            var renderer = new TextRenderer(model, shaderCodes, map);

            renderer.fontTexture = fontTexture;

            return(renderer);
        }
コード例 #40
0
        /// <summary>
        /// Render propeller in modern opengl.
        /// </summary>
        /// <returns></returns>
        public static RectNode Create()
        {
            var vs       = new VertexShader(vertexCode);
            var fs       = new FragmentShader(fragmentCode);
            var provider = new ShaderArray(vs, fs);
            var map      = new AttributeMap();

            map.Add(inPosition, RectModel.strPosition);
            var builder = new RenderMethodBuilder(provider, map);
            var node    = new RectNode(new RectModel(), RectModel.strPosition, builder);

            node.Initialize();

            return(node);
        }
コード例 #41
0
ファイル: LinesRenderer.cs プロジェクト: ihaiucom/CSharpGL
        public static LinesRenderer Create(LinesModel model)
        {
            var shaderCodes = new ShaderCode[2];

            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\Lines.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\Lines.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();

            map.Add("in_Position", LinesModel.position);
            var renderer = new LinesRenderer(model, shaderCodes, map);

            renderer.markerCount = model.markerCount;

            return(renderer);
        }
コード例 #42
0
ファイル: UIText.cs プロジェクト: bitzhuwei/CSharpGL
        /// <summary>
        ///
        /// </summary>
        /// <param name="anchor"></param>
        /// <param name="margin"></param>
        /// <param name="size"></param>
        /// <param name="zNear"></param>
        /// <param name="zFar"></param>
        /// <param name="fontTexture"></param>
        /// <param name="maxCharCount"></param>
        public UIText(
            System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin,
            System.Drawing.Size size, int zNear, int zFar, IFontTexture fontTexture = null, int maxCharCount = 100)
            : base(anchor, margin, size, zNear, zFar)
        {
            if (fontTexture == null)
            { this.fontTexture = FontTexture.Default; }// FontResource.Default; }
            else
            { this.fontTexture = fontTexture; }

            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(
            @"Resources.TextModel.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(
            @"Resources.TextModel.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();
            map.Add("position", TextModel.strPosition);
            map.Add("uv", TextModel.strUV);
            var model = new TextModel(maxCharCount);
            var renderer = new Renderer(model, shaderCodes, map);

            this.textModel = model;
            this.Renderer = renderer;
        }
コード例 #43
0
        public static NodePointNode Create(NodePointModel model)
        {
            var vs    = new VertexShader(vertexCode);
            var fs    = new FragmentShader(fragmentCode);
            var array = new ShaderArray(vs, fs);
            var map   = new AttributeMap();

            map.Add("inPosition", NodePointModel.strPosition);
            var builder = new RenderMethodBuilder(array, map);
            var node    = new NodePointNode(model, builder);

            node.Initialize();

            return(node);
        }
コード例 #44
0
        public static NormalMappingNode Create(IBufferSource model, vec3 size, string position, string texCoord, string normal, string tangent)
        {
            //var model = new NormalMappingModel();
            var vs    = new VertexShader(vertexCode);
            var fs    = new FragmentShader(fragmentCode);
            var array = new ShaderArray(vs, fs);
            var map   = new AttributeMap();

            //map.Add("inPosition", NormalMappingModel.strPosition);
            //map.Add("inTexCoord", NormalMappingModel.strTexCoord);
            //map.Add("inNormal", NormalMappingModel.strNormal);
            //map.Add("inTangent", NormalMappingModel.strTangent);
            map.Add("inPosition", position);
            map.Add("inTexCoord", texCoord);
            map.Add("inNormal", normal);
            map.Add("inTangent", tangent);
            var builder = new RenderMethodBuilder(array, map);
            var node    = new NormalMappingNode(model, builder);

            node.ModelSize = size;
            node.Initialize();

            return(node);
        }
コード例 #45
0
        public static CubeNode Create(Texture texture0, Texture texture1, Texture texture2)
        {
            // vertex buffer and index buffer.
            var model = new CubeModel();
            // vertex shader and fragment shader.
            var vs    = new VertexShader(vertexCode);
            var fs    = new FragmentShader(fragmnetCode);
            var array = new ShaderArray(vs, fs);
            // which vertex buffer maps to which attribute in shader.
            var map = new AttributeMap();

            map.Add("inPosition", CubeModel.strPosition);
            map.Add("inTexCoord", CubeModel.strTexCoord);
            // build a render method.
            var builder = new RenderMethodBuilder(array, map);
            // create node.
            var node = new CubeNode(model, builder);

            node.SetTextures(texture0, texture1, texture2);
            // initialize node.
            node.Initialize();

            return(node);
        }
コード例 #46
0
        /// <summary>
        /// Render propeller in modern opengl.
        /// </summary>
        /// <returns></returns>
        public static LightPositionNode Create()
        {
            var vs       = new VertexShader(vertexCode);
            var fs       = new FragmentShader(fragmentCode);
            var provider = new ShaderArray(vs, fs);
            var map      = new AttributeMap();

            map.Add(inPosition, CubeModel.strPosition);
            var builder = new RenderMethodBuilder(provider, map, new PolygonModeState(PolygonMode.Line), new LineWidthState(3));
            var node    = new LightPositionNode(new CubeModel(), CubeModel.strPosition, builder);

            node.Initialize();

            return(node);
        }
コード例 #47
0
        public static PointSpriteRenderer Create(int particleCount)
        {
            var shaderCodes = new ShaderCode[2];

            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\PointSprite.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\PointSprite.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();

            map.Add("position", PointSpriteModel.strposition);
            var model    = new PointSpriteModel(particleCount);
            var renderer = new PointSpriteRenderer(model, shaderCodes, map, new PointSpriteState());

            renderer.ModelSize = model.Lengths;

            return(renderer);
        }
コード例 #48
0
ファイル: SkyboxNode.cs プロジェクト: nougatchi/dreary
        /// <summary>
        ///
        /// </summary>
        /// <param name="totalBmp"></param>
        /// <returns></returns>
        public static SkyboxNode Create(Bitmap totalBmp)
        {
            var vs       = new VertexShader(vertexCode);
            var fs       = new FragmentShader(fragmentCode);
            var provider = new ShaderArray(vs, fs);
            var map      = new AttributeMap();

            map.Add(inPosition, Skybox.strPosition);
            var builder = new RenderMethodBuilder(provider, map, new CullFaceSwitch(CullFaceMode.Front));
            var model   = new Skybox();
            var node    = new SkyboxNode(model, Skybox.strPosition, totalBmp, builder);

            node.Initialize();
            node.Scale = new vec3(9000000, 9000000, 9000000);
            return(node);
        }
コード例 #49
0
        public static ShaderToyRenderer Create()
        {
            var model       = new Cube();
            var shaderCodes = new ShaderCode[2];

            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\ShaderToy.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\ShaderToy.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();

            map.Add("in_Position", Cube.strPosition);
            var renderer = new ShaderToyRenderer(model, shaderCodes, map);

            renderer.Lengths = model.Lengths;

            return(renderer);
        }
コード例 #50
0
        /// <summary>
        /// Render propeller in modern opengl.
        /// </summary>
        /// <param name="direction"></param>
        /// <returns></returns>
        public static LineNode Create(vec3 direction)
        {
            var vs       = new VertexShader(vertexCode);
            var fs       = new FragmentShader(fragmentCode);
            var provider = new ShaderArray(vs, fs);
            var map      = new AttributeMap();

            map.Add(inPosition, LineModel.strPosition);
            var lineWidthSwitch = new LineWidthSwitch(10);
            var builder         = new RenderMethodBuilder(provider, map, lineWidthSwitch);
            var node            = new LineNode(new LineModel(direction), builder);

            node.Initialize();

            return(node);
        }
コード例 #51
0
        public static SimplexNoiseRenderer Create()
        {
            var model       = new Sphere(1, 180, 360);
            var shaderCodes = new ShaderCode[2];

            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\SimplexNoise.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\SimplexNoise.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();

            map.Add("in_Position", Sphere.strPosition);
            var renderer = new SimplexNoiseRenderer(model, shaderCodes, map, Sphere.strPosition);

            renderer.ModelSize = model.Lengths;

            return(renderer);
        }
コード例 #52
0
ファイル: WaterRenderer.cs プロジェクト: bitzhuwei/CSharpGL
        public static WaterRenderer Create(int waterPlaneLength)
        {
            var model = new WaterPlaneModel(waterPlaneLength);
            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\water\Water.vert.glsl"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\water\Water.frag.glsl"), ShaderType.FragmentShader);
            var map = new AttributeMap();
            map.Add("a_vertex", WaterPlaneModel.strPosition);
            var renderer = new WaterRenderer(model, shaderCodes, map, new FrontFaceState(FrontFaceMode.CCW));
            renderer.waterTextureRenderer = WaterTextureRenderer.Create(waterPlaneLength);
            renderer.backgroundRenderer = WaterBackgroundRenderer.Create(waterPlaneLength);
            renderer.ModelSize = new vec3(waterPlaneLength + 1, waterPlaneLength + 1, waterPlaneLength + 1);
            renderer.waterPlaneLength = waterPlaneLength;

            return renderer;
        }
コード例 #53
0
        /// <summary>
        /// Creates a <see cref="LightPositionNode"/> which displays and updates light's position.
        /// </summary>
        /// <param name="light"></param>
        /// <param name="initAngle"></param>
        /// <returns></returns>
        public static SphereNode Create()
        {
            var model    = new Sphere(1f, 10, 15);
            var vs       = new VertexShader(vertexCode);
            var fs       = new FragmentShader(fragmentCode);
            var provider = new ShaderArray(vs, fs);
            var map      = new AttributeMap();

            map.Add(inPosition, Sphere.strPosition);
            var builder = new RenderMethodBuilder(provider, map, new PolygonModeSwitch(PolygonMode.Line));
            var node    = new SphereNode(model, Sphere.strPosition, builder);

            node.Initialize();

            return(node);
        }
コード例 #54
0
 protected override void DoInitialize()
 {
     {
         IBufferable model = new ParticleModel();
         var shaderCodes = new ShaderCode[2];
         shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\ParticleSimulatorRenderer\particleSimulator.vert"), ShaderType.VertexShader);
         shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\ParticleSimulatorRenderer\particleSimulator.frag"), ShaderType.FragmentShader);
         var map = new AttributeMap();
         map.Add("position", ParticleModel.strPosition);
         var particleRenderer = new ParticleRenderer(model, shaderCodes, map, new DepthTestState(false), new BlendState(BlendingSourceFactor.One, BlendingDestinationFactor.One));
         particleRenderer.Initialize();
         this.particleRenderer = particleRenderer;
     }
     {
         var particleComputeRenderer = new ParticleComputeRenderer(
             this.particleRenderer.PositionBuffer,
             this.particleRenderer.VelocityBuffer);
         particleComputeRenderer.Initialize();
         this.particleComputeRenderer = particleComputeRenderer;
     }
 }
コード例 #55
0
ファイル: SimpleRenderer.cs プロジェクト: bitzhuwei/CSharpGL
 internal static SimpleRenderer Create(IBufferable model, vec3 lengths, string positionNameInIBufferable)
 {
     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 map = new AttributeMap();
     map.Add("in_Position", "position");
     map.Add("in_Color", "color");
     var renderer = new SimpleRenderer(model, shaderCodes, map, positionNameInIBufferable);
     renderer.ModelSize = lengths;
     return renderer;
 }
コード例 #56
0
ファイル: WellRenderer.cs プロジェクト: bitzhuwei/CSharpGL
 public static WellRenderer Create(WellModel model)
 {
     var shaderCodes = new ShaderCode[2];
     shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\Well.vert"), ShaderType.VertexShader);
     shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\Well.frag"), ShaderType.FragmentShader);
     var map = new AttributeMap();
     map.Add("in_Position", WellModel.strPosition);
     map.Add("in_Brightness", WellModel.strBrightness);
     var renderer = new WellRenderer(model, shaderCodes, map);
     return renderer;
 }
コード例 #57
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 map = new AttributeMap();
     map.Add("in_Position", BoundingBoxModel.strPosition);
     var result = new BoundingBoxRenderer(model, shaderCodes, map, new PolygonModeState(PolygonMode.Line), new PolygonOffsetFillState());
     result.ModelSize = lengths;
     return result;
 }
コード例 #58
0
 public static BillboardRenderer Create(IBufferable model)
 {
     var shaderCodes = new ShaderCode[2];
     shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\billboard.vert"), ShaderType.VertexShader);
     shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\billboard.frag"), ShaderType.FragmentShader);
     var map = new AttributeMap();
     map.Add("in_Positions", BillboardModel.strPosition);
     var billboardRenderer = new BillboardRenderer(model, shaderCodes, map);
     return billboardRenderer;
 }
コード例 #59
0
        private static AttributeMap GetMap(BuildInSceneObject buildIn)
        {
            var map = new AttributeMap();

            switch (buildIn)
            {
                case BuildInSceneObject.Cube:
                    map.Add("in_Position", Cube.strPosition);
                    map.Add("in_Color", Cube.strColor);
                    break;

                case BuildInSceneObject.Sphere:
                    map.Add("in_Position", Sphere.strPosition);
                    map.Add("in_Color", Sphere.strColor);
                    break;

                case BuildInSceneObject.Ground:
                    map.Add("in_Position", Ground.strPosition);
                    map.Add("in_Color", Ground.strColor);
                    break;

                case BuildInSceneObject.Axis:
                    map.Add("in_Position", Axis.strPosition);
                    map.Add("in_Color", Axis.strColor);
                    break;

                default:
                    throw new NotImplementedException();
            }

            return map;
        }