• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ShaderType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ShaderType的典型用法代码示例。如果您正苦于以下问题:C# ShaderType类的具体用法?C# ShaderType怎么用?C# ShaderType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ShaderType类属于命名空间,在下文中一共展示了ShaderType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Transform

        /// <summary>
        /// Public translation interface.
        /// Translates the given method to GLSL
        /// </summary>
        /// <param name="s">Shader type definition.</param>
        /// <param name="m">A method representing a shader to translate.</param>
        /// <param name="attr">The shader type as attribute (either FragmentShaderAttribute or VertexShaderAttribute</param>
        /// <param name="type">The shader type as ShaderType</param>
        /// <returns>The translated GLSL shader source</returns>
        public FunctionDescription Transform(TypeDefinition s, MethodDefinition m, CustomAttribute attr,
            ShaderType type)
        {
            if (s == null)
                throw new ArgumentNullException("s");

            if (m == null)
                throw new ArgumentNullException("m");

            if (attr == null)
                throw new ArgumentNullException("attr");

            var ctx = new DecompilerContext(s.Module)
            {
                CurrentType = s,
                CurrentMethod = m,
                CancellationToken = CancellationToken.None
            };

            var d = AstMethodBodyBuilder.CreateMethodBody(m, ctx);

            var glsl = new GlslVisitor(d, attr, ctx);

            _functions.UnionWith(glsl.Functions);

            var entry = (bool)attr.ConstructorArguments.FirstOrDefault().Value;
            var sig = entry ? "void main()" : GlslVisitor.GetSignature(m);

            var code = glsl.Result;
            var desc = new FunctionDescription(entry ? "main" : Shader.GetMethodName(m), sig + code, entry, type);

            _dependencies.UnionWith(glsl.Dependencies);

            return desc;
        }
开发者ID:mono-soc-2011,项目名称:SLSharp,代码行数:44,代码来源:GlslTransform.cs


示例2: compileShader

        public static int compileShader(ShaderType shaderType, String shaderSource)
        {
            int shaderHandle = GL.CreateShader(shaderType);

            if (shaderHandle != 0)
            {
                // Pass in the shader source.
                GL.ShaderSource(shaderHandle, shaderSource);

                // Compile the shader.
                GL.CompileShader(shaderHandle);

                // Get the compilation status.
                int[] compileStatus = new int[1];
                GL.GetShader(shaderHandle,ShaderParameter.CompileStatus, compileStatus);

                // If the compilation failed, delete the shader.
                if (compileStatus[0] == 0)
                {
                    string shaderInfoLog = GL.GetShaderInfoLog(shaderHandle);
                    MessageBox.Show("Error creating shader: " + shaderInfoLog);
                    GL.DeleteShader(shaderHandle);
                    shaderHandle = 0;
                }
            }

            if (shaderHandle == 0)
            {
                 MessageBox.Show("Error creating shader.");
            }

            return shaderHandle;
        }
开发者ID:j1s1e1,项目名称:GlslMonoOpenTkExamples,代码行数:33,代码来源:Shader.cs


示例3: OnGUI

	void OnGUI() {
		const int height = 20;
		int width = (int)position.width;// -16;
		
		pmdFile = EditorGUI.ObjectField(
			new Rect(0, 0, width, height), "PMD File" , pmdFile, typeof(Object), false);
		
		// シェーダの種類
		shader_type = (ShaderType)EditorGUI.EnumPopup(new Rect(0, height, width, height), "Shader Type", shader_type);

		// 剛体を入れるかどうか
		rigidFlag = EditorGUI.Toggle(new Rect(0, height * 2, width / 2, height), "Rigidbody", rigidFlag);

		// Mecanimを使うかどうか
		use_mecanim = EditorGUI.Toggle(new Rect(0, height * 3, width / 2, height), "Use Mecanim", use_mecanim);

		// IKを使うかどうか
		use_ik = EditorGUI.Toggle(new Rect(0, height * 4, width / 2, height), "Use IK", use_ik);
		
		int buttonHeight = height * 5;
		if (pmdFile != null) {
			if (GUI.Button(new Rect(0, buttonHeight, width / 2, height), "Convert")) {
				new PMDLoaderScript(pmdFile, shader_type, rigidFlag, use_mecanim, use_ik);
				pmdFile = null;		// 読み終わったので空にする 
			}
		} else {
			EditorGUI.LabelField(new Rect(0, buttonHeight, width, height), "Missing", "Select PMD File");
		}
	}
开发者ID:NektariosP,项目名称:unity-opencv-android,代码行数:29,代码来源:PMDLoaderWindow.cs


示例4: ShaderException

 public ShaderException(string message, string shaderLog, string shaderSource, ShaderType shaderType)
     : base(message)
 {
     ShaderLog = shaderLog;
     ShaderSource = shaderSource;
     ShaderType = shaderType;
 }
开发者ID:EdgeWorks-Games,项目名称:DeferVox,代码行数:7,代码来源:ShaderExceptions.cs


示例5: FromFile

        public static Shader FromFile(ShaderType type, string fileName)
        {
            Shader shader = new Shader(type, string.Empty);
            shader.LoadSource(fileName);

            return shader;
        }
开发者ID:Grimston,项目名称:ezterrain,代码行数:7,代码来源:Shader.cs


示例6: CompileShaderObject

		protected int CompileShaderObject(ShaderType type, string name)
		{
			string ext = type == ShaderType.VertexShader ? "vert" : "frag";
			string filename = "glsl{0}{1}.{2}".F(Path.DirectorySeparatorChar, name, ext);
			string code;
			using (var file = new StreamReader(GlobalFileSystem.Open(filename)))
				code = file.ReadToEnd();

			var shader = GL.CreateShader(type);
			ErrorHandler.CheckGlError();
			GL.ShaderSource(shader, code);
			ErrorHandler.CheckGlError();
			GL.CompileShader(shader);
			ErrorHandler.CheckGlError();
			int success;
			GL.GetShader(shader, ShaderParameter.CompileStatus, out success);
			ErrorHandler.CheckGlError();
			if (success == (int)All.False)
			{
				int len;
				GL.GetShader(shader, ShaderParameter.InfoLogLength, out len);
				var log = new StringBuilder(len);
				unsafe
				{
					GL.GetShaderInfoLog(shader, len, null, log);
				}

				Log.Write("graphics", "GL Info Log:\n{0}", log.ToString());
				throw new InvalidProgramException("Compile error in shader object '{0}'".F(filename));
			}

			return shader;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:33,代码来源:Shader.cs


示例7: GetShaderSource

        /// <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.Highlight.vert");
                    }
                    result = vertexShader;
                    break;
                case ShaderType.FragmentShader:
                    if (fragmentShader == null)
                    {
                        fragmentShader = ManifestResourceLoader.LoadTextFile(@"Resources.Highlight.frag");
                    }
                    result = fragmentShader;
                    break;
                default:
                    throw new NotImplementedException();
            }

            return result;
        }
开发者ID:chantsunman,项目名称:CSharpGL,代码行数:31,代码来源:HighlightShaderHelper.cs


示例8: CompileShader

        public static int CompileShader(ShaderType type, string source)
        {
            int shader = GL.CreateShader(type);
            GL.ShaderSource(shader, source);
            GL.CompileShader(shader);
            int compileResult;
            GL.GetShader(shader, ShaderParameter.CompileStatus, out compileResult);
            if (compileResult == 0)
            {
                int infoLogLength;
                GL.GetShader(shader, ShaderParameter.InfoLogLength, out infoLogLength);
                string infolog;
                GL.GetShaderInfoLog(shader, out infolog);
                GL.DeleteShader(shader);
                //std::vector<GLchar> infoLog(infoLogLength);
                //glGetShaderInfoLog(shader, infoLog.size(), NULL, &infoLog[0]);

                //std::cerr << "shader compilation failed: " << &infoLog[0];

                //glDeleteShader(shader);
                shader = 0;
            }

            return shader;
        }
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:25,代码来源:ES2Utils.cs


示例9: ShaderFile

 public ShaderFile(ShaderType type, string filename, string friendlyName)
     : base(type)
 {
     this.filename = filename;
     this.friendlyName = friendlyName;
     this.fileWatcher = new FileModifiedWatcher(filename);
 }
开发者ID:corefan,项目名称:awgraphics,代码行数:7,代码来源:ShaderFile.cs


示例10: CreateShader

 public int CreateShader(ShaderType shaderType)
 {
     GraphicsContext.Assert();
     int shader = GL.CreateShader(shaderType);
     OpenGlErrorHelper.CheckGlError();
     return shader;
 }
开发者ID:rmckirby,项目名称:XogoEngine,代码行数:7,代码来源:ShaderAdapter.cs


示例11: CreateShader

 public static int CreateShader(string shaderSource, ShaderType type){
   int shaderHandle = GL.CreateShader( type );
   GL.ShaderSource( shaderHandle, shaderSource );
   GL.CompileShader( shaderHandle );
   Console.WriteLine(GL.GetShaderInfoLog(shaderHandle));
   return shaderHandle;
 }
开发者ID:dgopena,项目名称:Starter3D.Base,代码行数:7,代码来源:OpenGLHelper.cs


示例12: Shader

        /// <summary>
        /// Creates a shader from a string of shader source code.
        /// </summary>
        /// <param name="shaderCode">The source code for the shader.</param>
        /// <param name="shaderType">Same as the argument to glCreateShader. For example ShaderType.VertexShader
        ///                          or ShaderType.FragmentShader.</param>
        public Shader(string shaderCode, ShaderType shaderType)
        {
            _object = 0;
            _refCount = 0;

            //create the shader object
            _object = GL.CreateShader(shaderType);
            if (_object == 0)
                throw new Exception("glCreateShader failed");

            //set the source code
            GL.ShaderSource(_object, shaderCode);

            // compile
            GL.CompileShader(_object);

            // throw exception if compile error occurred
            int status;
            GL.GetShader(_object, ShaderParameter.CompileStatus, out status);
            if (status == 0) {
                string msg = "Compile failure in shader: ";

                string strInfoLog;
                GL.GetShaderInfoLog((int)_object, out strInfoLog);
                msg += strInfoLog;

                GL.DeleteShader(_object);
                _object = 0;
                throw new Exception(msg);
            }

            _refCount = 1;
        }
开发者ID:remy22,项目名称:opengl-series-csharp,代码行数:39,代码来源:Shader.cs


示例13: ShaderBuilder

        /// <summary>
        /// Constructor to create a new ShaderBuilder instance.
        /// </summary>
        /// <param name="type">The shader type to generate the source for</param>
        /// <param name="twoDimensional">If true, some helper code for two dimensional shaders will be included</param>
        /// <param name="parent">Previous shader in the pipeline (if any)</param>
        public ShaderBuilder(ShaderType type, bool twoDimensional, ShaderBuilder parent = null)
        {
            Type = type;
            _twoDimensional = twoDimensional;

            // Prepare an empty list of OpenGL extensions
            _extensions = new List<String>();

            // Set up variable lists
            _uniforms = new List<ShaderVariable>();
            _attribs = new List<ShaderVariable>();
            _varyings = new List<ShaderVariable>();

            if (type == ShaderType.VertexShader && twoDimensional) {
                AddUniform(ShaderVarType.Vec2, "screen_resolution");
            }

            // If the builder is given a parent, copy any outputs
            // from that shader as inputs for this one
            if (parent != null) {
                foreach (var vary in parent._varyings) {
                    AddVarying(vary.Type, vary.Identifier);
                }
            }

            Logic = "";

            // Default fragment colour output variable identifier
            FragOutIdentifier = "out_colour";
        }
开发者ID:Metapyziks,项目名称:ComputerGraphicsCoursework,代码行数:36,代码来源:ShaderBuilder.cs


示例14: CreateCompiledSubShader

		private static int CreateCompiledSubShader(ShaderType shaderType, string subShaderCode)
		{
			uint shaderHandle = GLCore.CreateShader(shaderType);
			GLHelper.ShaderSource(shaderHandle, subShaderCode.Replace("precision mediump float;", ""));
			GLCore.CompileShader(shaderHandle);
			return (int)shaderHandle;
		}
开发者ID:whztt07,项目名称:DeltaEngine,代码行数:7,代码来源:OpenGLShader.cs


示例15: CompileShader

        public static bool CompileShader(ShaderType type, string file, out int shader)
        {
            string src = System.IO.File.ReadAllText(file);
            shader = GL.CreateShader(type);
            GL.ShaderSource(shader, 1, new string[] { src }, (int[])null);
            GL.CompileShader(shader);
            #if DEBUG
            int logLength = 0;
            GL.GetShader (shader, ShaderParameter.InfoLogLength, out logLength);
            if (logLength > 0)
            {
                var infoLog = new System.Text.StringBuilder ();
                GL.GetShaderInfoLog (shader, logLength, out logLength, infoLog);
                Console.WriteLine ("Shader compile log:\n{0}", infoLog);
            }
            #endif
            int status = 0;
            GL.GetShader(shader, ShaderParameter.CompileStatus, out status);
            if (status == 0)
            {
                GL.DeleteShader(shader);
                return false;
            }

            return true;
        }
开发者ID:jfoshee,项目名称:MonoTouch-Playground,代码行数:26,代码来源:ShaderUtilities.cs


示例16: LoadShader

        int LoadShader(ShaderType type, string source)
        {
            int shader = GL.CreateShader(type);
            if (shader == 0)
                throw new InvalidOperationException("Unable to create shader");

            int length = 0;
            GL.ShaderSource(shader, 1, new string[] { source }, (int[])null);
            GL.CompileShader(shader);

            int compiled = 0;
            GL.GetShader(shader, ShaderParameter.CompileStatus, out compiled);
            if (compiled == 0)
            {
                length = 0;
                GL.GetShader(shader, ShaderParameter.InfoLogLength, out length);
                if (length > 0)
                {
                    var log = new StringBuilder(length);
                    GL.GetShaderInfoLog(shader, length, out length, log);
                    Console.WriteLine("Couldn't compile shader: " + log.ToString());
                }

                GL.DeleteShader(shader);
                throw new InvalidOperationException("Unable to compile shader of type : " + type.ToString());
            }

            return shader;
        }
开发者ID:gatm50,项目名称:monoberry,代码行数:29,代码来源:ExampleGLTriangle.cs


示例17: Shader

        internal Shader(ShaderType type, string filename)
        {
            Type = type;
            Filename = filename;

            Handle = GL.CreateShader(Type);
        }
开发者ID:org-itbiz,项目名称:ObjParserNet,代码行数:7,代码来源:Shader.cs


示例18: ReadShader

 public static string ReadShader(string path, ShaderType type)
 {
     string extension = string.Empty;
     switch (type)
     {
         case ShaderType.FragmentShader:
             extension = ".frag";
             break;
         case ShaderType.VertexShader:
             extension = ".vert";
             break;
         case ShaderType.GeometryShader:
             extension = ".geom";
             break;
         case ShaderType.TessEvaluationShader:
             extension = ".tess";
             break;
         case ShaderType.TessControlShader:
             extension = ".tctrl";
             break;
         case ShaderType.ComputeShader:
             extension = ".comp";
             break;
     }
     string output = File.ReadAllText(Directory.GetCurrentDirectory() + "/" + path + extension);
     return output;
 }
开发者ID:Inspix,项目名称:Learning-OpenGL,代码行数:27,代码来源:FileUtils.cs


示例19: Shader

        public Shader(string name, string file, ShaderType type)
        {
            this.ShaderName = name;
            this.ShaderFile = file;

            switch (type)
            {
            case ShaderType.VertexShader:
                this.HasVertexShader = true;
                break;
            case ShaderType.FragmentShader:
                this.HasFragmentShader = true;
                break;
            case ShaderType.GeometryShader:
                this.HasGeometryShader = true;
                break;
            case ShaderType.TessControlShader:
                this.HasTessControlShader = true;
                break;
            case ShaderType.TessEvaluationShader:
                this.HasTessEvaluationShader = true;
                break;
            case ShaderType.ComputeShader:
                this.HasComputeShader = true;
                break;
            }
        }
开发者ID:CM12000,项目名称:Legends-of-Arcodia,代码行数:27,代码来源:Shader.cs


示例20: Load

 public void Load(string path, ShaderType type, string version = "")
 {
     var source = IO.ASCIIFileHelper.ReadFileToEnd(path);
     source = version + "\n" + source;
     var name = Path.GetFileNameWithoutExtension(path);
     Load(source, name, type);
 }
开发者ID:opcon,项目名称:Substructio,代码行数:7,代码来源:Shader.cs



注:本文中的ShaderType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ShadingState类代码示例发布时间:2022-05-24
下一篇:
C# ShaderStageType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap