LoadTextFile() 공개 정적인 메소드

Loads the named manifest resource as a text string.
public static LoadTextFile ( string textFileName, int stackIndex = 2 ) : string
textFileName string Name of the text file.
stackIndex int
리턴 string
예제 #1
0
        /// <summary>
        /// Gets shader's source code for color coded picking.
        /// </summary>
        /// <param name="shaderType"></param>
        /// <returns></returns>
        private static string GetShaderSource(ShaderType shaderType)
        {
            string result = string.Empty;

            switch (shaderType)
            {
            case ShaderType.VertexShader:
                if (vertexShader == null)
                {
                    vertexShader = ManifestResourceLoader.LoadTextFile(
                        @"OpenGLObjects.ColorCodedPicking.PickingShader.vert");
                }
                result = vertexShader;
                break;

            case ShaderType.FragmentShader:
                if (fragmentShader == null)
                {
                    fragmentShader = ManifestResourceLoader.LoadTextFile(
                        @"OpenGLObjects.ColorCodedPicking.PickingShader.frag");
                }
                result = fragmentShader;
                break;

            default:
                throw new NotImplementedException();
            }

            return(result);
        }
예제 #2
0
        /// <summary>
        /// Gets shader's source code for color coded picking.
        /// </summary>
        /// <param name="shaderType"></param>
        /// <returns></returns>
        private static string GetShaderSource(ShaderType shaderType)
        {
            string result = string.Empty;

            switch (shaderType)
            {
            case ShaderType.VertexShader:
                if (vertexShader == null)
                {
                    vertexShader = ManifestResourceLoader.LoadTextFile(
                        @"HighlightRenderer.Highlight.vert");
                }
                result = vertexShader;
                break;

            case ShaderType.FragmentShader:
                if (fragmentShader == null)
                {
                    fragmentShader = ManifestResourceLoader.LoadTextFile(
                        @"HighlightRenderer.Highlight.frag");
                }
                result = fragmentShader;
                break;

            default:
                throw new NotImplementedException();
            }

            return(result);
        }
예제 #3
0
        /// <summary>
        /// Gets shader's source code for color coded picking.
        /// </summary>
        /// <param name="shaderType"></param>
        /// <returns></returns>
        private static string GetShaderSource(ShaderType shaderType)
        {
            string result = string.Empty;

            switch (shaderType)
            {
            case ShaderType.VertexShader:
                if (vertexShader == null)
                {
                    vertexShader = ManifestResourceLoader.LoadTextFile(
                        @"Resources.Picking.vert");
                }
                result = vertexShader;
                break;

            case ShaderType.FragmentShader:
                if (fragmentShader == null)
                {
                    fragmentShader = ManifestResourceLoader.LoadTextFile(
                        @"Resources.Picking.frag");
                }
                result = fragmentShader;
                break;

            default:
                throw new Exception("Unexpected ShaderType!");
            }

            return(result);
        }
예제 #4
0
        public GLText(
            System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin,
            System.Drawing.Size size, int zNear, int zFar, FontResource fontResource = null, int maxCharCount = 100)
            : base(null, anchor, margin, size, zNear, zFar)
        {
            if (fontResource == null)
            {
                this.fontResource = FontResource.Default;
            }
            else
            {
                this.fontResource = fontResource;
            }

            this.Name = "GLText";
            var shaderCodes = new ShaderCode[2];

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

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

            this.model    = model;
            this.Renderer = renderer;
        }
예제 #5
0
        private static MethodInfo GetOuterComparerMethod <T>()
        {
            Type       type = typeof(T);
            MethodInfo method;

            if (!outerComparerDict.TryGetValue(type, out method))
            {
                string comparer = ManifestResourceLoader.LoadTextFile(@"Resources\SortingHelper.Comparer`1.cs.resource");
                comparer = comparer.Replace("TemplateStructType", type.FullName);
                var codeProvider = new CSharpCodeProvider();
                var option       = new CompilerParameters();
                option.GenerateInMemory = true;
                option.CompilerOptions  = "/unsafe";
                option.ReferencedAssemblies.Add("System.dll");
                option.ReferencedAssemblies.Add("CSharpGL.dll");
                CompilerResults result = codeProvider.CompileAssemblyFromSource(option,
                                                                                comparer);
                Assembly asm                   = result.CompiledAssembly;
                Type     sortingHelper         = asm.GetType("CSharpGL.SortingHelper");
                Type     unmanagedArrayGeneric = typeof(UnmanagedArray <>);
                Type     unmanagedArray        = unmanagedArrayGeneric.MakeGenericType(type);
                method = sortingHelper.GetMethod("Sort", new Type[] { typeof(IntPtr), typeof(int), typeof(int), typeof(Comparer <T>) });

                outerComparerDict.Add(type, method);
            }

            return(method);
        }
        private static MethodInfo GetOrderMethod(Type type)
        {
            MethodInfo method;

            if (!icomparableDict.TryGetValue(type, out method))
            {
                string order = ManifestResourceLoader.LoadTextFile(@"Resources\SortingHelper.Order`1.cs");
                order = order.Replace("TemplateStructType", type.FullName);
                var codeProvider = new CSharpCodeProvider();
                var option       = new CompilerParameters();
                option.GenerateInMemory = true;
                option.CompilerOptions  = "/unsafe";
                option.ReferencedAssemblies.Add("System.dll");
                option.ReferencedAssemblies.Add("CSharpGL.dll");
                CompilerResults result = codeProvider.CompileAssemblyFromSource(option,
                                                                                order);
                Assembly asm           = result.CompiledAssembly;
                Type     sortingHelper = asm.GetType("CSharpGL.SortingHelper");
                method = sortingHelper.GetMethod("Sort", new Type[] { typeof(IntPtr), typeof(int), typeof(int), typeof(bool) });

                icomparableDict.Add(type, method);
            }

            return(method);
        }
예제 #7
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);
        }
예제 #8
0
        public static AxisRenderer Create(int partCount = 24)
        {
            var shaderCodes = new ShaderCode[2];

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

            map.Add("in_Position", Axis.strPosition);
            map.Add("in_Color", Axis.strColor);
            var model    = new Axis(partCount);
            var renderer = new AxisRenderer(model, shaderCodes, map, "position");

            return(renderer);
        }
예제 #9
0
        /// <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 renderer = new Renderer(new Axis(partCount, 0.5f), shaderCodes, map);

            this.Renderer = renderer;
        }
예제 #10
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 map = new CSharpGL.AttributeMap();

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

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

            return(renderer);
        }
예제 #11
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 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);
        }
예제 #12
0
        /// <summary>
        /// Creates a renderer that renders a evaluator(a bezier curve or surface) and its control points.
        /// </summary>
        /// <param name="controlPoints"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static BezierRenderer Create(IList <vec3> controlPoints, BezierType type)
        {
            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 map = new CSharpGL.AttributeMap();

            map.Add("in_Position", Points.strposition);
            var model    = new Points(controlPoints);
            var renderer = new BezierRenderer(controlPoints, type, model, shaderCodes, map, Points.strposition);

            renderer.Lengths       = model.Lengths;
            renderer.WorldPosition = model.WorldPosition;
            renderer.switchList.Add(new PointSizeSwitch(10));

            return(renderer);
        }
예제 #13
0
        /// <summary>
        /// get a bounding box renderer.
        /// </summary>
        /// <param name="lengths">bounding box's length at x, y, z direction.</param>
        /// <param name="originalWorldPosition"></param>
        /// <returns></returns>
        public static BoundingBoxRenderer Create(vec3 lengths, vec3 originalWorldPosition = new vec3())
        {
            var bufferable  = 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 PropertyNameMap();

            map.Add("in_Position", BoundingBoxModel.strPosition);
            var result = new BoundingBoxRenderer(bufferable, shaderCodes, map, new PolygonModeSwitch(PolygonModes.Lines), new PolygonOffsetFillSwitch());

            result.halfLengths           = new vec4(lengths / 2, 1.0f);
            result.OriginalWorldPosition = originalWorldPosition;
            result.ModelMatrix           = glm.translate(mat4.identity(), originalWorldPosition);
            return(result);
        }
예제 #14
0
        /// <summary>
        ///
        /// </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>
        public LabelRenderer(int maxCharCount = 64, int labelHeight = 32, IFontTexture fontTexture = null)
            : base(null, null, null, new BlendSwitch(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.One))
        {
            GLSwitch blendSwitch = this.SwitchList.Find(x => x is BlendSwitch);

            if (blendSwitch == null)
            {
                throw new Exception();
            }
            this.blendSwitch = blendSwitch;

            if (fontTexture == null)
            {
                this.fontTexture = FontTexture.Default;
            }                                          // FontResource.Default; }
            else
            {
                this.fontTexture = fontTexture;
            }

            this.LabelHeight = labelHeight;

            var model = new TextModel(maxCharCount);

            this.bufferable = model;
            this.model      = model;

            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);
            this.shaderCodes = shaderCodes;

            var map = new PropertyNameMap();

            map.Add("in_Position", TextModel.strPosition);
            map.Add("in_UV", TextModel.strUV);
            this.propertyNameMap = map;
        }
예제 #15
0
        /// <summary>
        /// opengl UI for Axis
        /// </summary>
        /// <param name="anchor"></param>
        /// <param name="margin"></param>
        /// <param name="size"></param>
        /// <param name="zNear"></param>
        /// <param name="zFar"></param>
        public GLAxis(
            System.Windows.Forms.AnchorStyles anchor, System.Windows.Forms.Padding margin,
            System.Drawing.Size size, int zNear, int zFar)
            : base(null, anchor, margin, size, zNear, zFar)
        {
            this.Name = "GLAxis";
            var shaderCodes = new ShaderCode[2];

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

            map.Add("in_Position", "position");
            map.Add("in_Color", "color");
            //PickableRenderer renderer = (new Axis()).GetRenderer(shaderCodes, map, "position");
            PickableRenderer renderer = new PickableRenderer(new Axis(), shaderCodes, map, "position");

            this.Renderer = renderer;
        }
예제 #16
0
 static GLPositionColorNode()
 {
     shaderCodes    = new ShaderCode[2];
     shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Position.Color.vert"), ShaderType.VertexShader);
     shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(@"Resources\Position.Color.frag"), ShaderType.FragmentShader);
 }