예제 #1
0
        protected override string DumpShaderCode()
        {
            StringBuilder builder = new StringBuilder();

            GeometryCSShaderCode shaderCode = this.shaderCode as GeometryCSShaderCode;
            Type shaderCodeType             = shaderCode.GetType();

            // #version 150 core
            GLSLVersionAttribute versionAttribute = shaderCodeType.GetCustomAttribute <GLSLVersionAttribute>();

            if (versionAttribute != null)
            {
                this.Version = versionAttribute.Version;
            }
            switch (this.Version)
            {
            case GLSLVersion.v150:
                builder.AppendLine("#version 150 core");
                break;

            default:
                builder.AppendLine("#version this is not implemented in CSSL2GLSL!");
                break;
            }
            builder.AppendLine();

            // layout (triangles) in;
            // layout (triangle_strip, max_vertices = 11) out;
            builder.AppendLine(string.Format("layout ({0}) in;", shaderCode.LayoutIn));
            builder.AppendLine(string.Format("layout ({0}, max_vertices = {1}) out;",
                                             shaderCode.LayoutOut, shaderCode.max_vertices));
            builder.AppendLine();

            foreach (var field in shaderCodeType.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic))
            {
                foreach (var attr in field.GetCustomAttributes <QualifierAttribute>())
                {
                    var    semanticField = new SemanticField(attr, field.FieldType, field.Name, this.shaderCode);
                    string fieldCode     = semanticField.Dump();
                    builder.AppendLine(fieldCode);
                }
            }
            builder.AppendLine();

            builder.Append(this.SearchMainFunction(fullname));
            builder.AppendLine();

            return(builder.ToString());
        }
예제 #2
0
        protected override string DumpShaderCode()
        {
            StringBuilder builder = new StringBuilder();

            GLSLVersionAttribute versionAttribute = this.shaderCode.GetType().GetCustomAttribute <GLSLVersionAttribute>();

            if (versionAttribute != null)
            {
                this.Version = versionAttribute.Version;
            }
            switch (this.Version)
            {
            case GLSLVersion.v150:
                builder.AppendLine("#version 150 core");
                break;

            default:
                builder.AppendLine("#version this is not implemented in CSSL2GLSL!");
                break;
            }
            builder.AppendLine();

            foreach (var field in this.shaderCode.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic))
            {
                foreach (var attr in field.GetCustomAttributes <QualifierAttribute>())
                {
                    var    semanticField = new SemanticField(attr, field.FieldType, field.Name, shaderCode);
                    string fieldCode     = semanticField.Dump();
                    builder.AppendLine(fieldCode);
                }
            }
            builder.AppendLine();

            builder.Append(this.SearchMainFunction(fileGroup.MainFile));
            builder.AppendLine();

            return(builder.ToString());
        }