当前位置: 首页>>代码示例>>C#>>正文


C# ShaderType.ToString方法代码示例

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


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

示例1: initShader

		public int initShader(ShaderType shaderTypeToUse, string shaderProgram) {
			int shaderID = 0;

			ErrorCode iErrorCodePrior = GL.GetError();
			if ( iErrorCodePrior != ErrorCode.NoError ) {
				throw new Exception ("Warning: An existing problem with the OpenGL state was found. Error code " + iErrorCodePrior.ToString() + ". This means an invalid call was made and not checked for before this part of the program was run.");
			}
			
			shaderID = GL.CreateShader(shaderTypeToUse);
			ErrorCode iErrorCode = GL.GetError();
			if ( iErrorCode != ErrorCode.NoError ) {
				throw new Exception ("There was a problem creating a shader of type " + shaderTypeToUse.ToString() + ". The error was '" + iErrorCode.ToString() + "'.");
			}
			
			if ( 0 == shaderID ) {
				throw new Exception ("There was a problem creating a shader of type " + shaderTypeToUse.ToString() + ". We were unable to query for the GL Error code.");
			}
			
			if ( string.Empty == shaderProgram ) {
				throw new Exception ("The shaderProgram property of ShaderCreate can not be empty. Please review the configuration");	
			}

			GL.ShaderSource(shaderID, shaderProgram);
			ErrorCode iErrorCode2 = GL.GetError();
			
			if ( iErrorCode2 != ErrorCode.NoError ) {
				switch (iErrorCode2) {
					case ErrorCode.InvalidOperation:
						throw new Exception ("Setting the shader source had a problem. The current shader compiler is not supported OR the shader ID, " + shaderID + ", is not a shader object (the handle ID is to something other than a shader.");
					case ErrorCode.InvalidValue:
						throw new Exception ("Setting the shader source had a problem. The shaderID provide, " + shaderID + ", was not generated by OpenGL or the shader program was empty (count of string length was 0). Please contact the developers as this should never happen.");
					default:
						throw new Exception ("Setting the shader source had a problem. . The error was '" + iErrorCode2.ToString() + "'.");
				}
					
			}
			
			GL.CompileShader(shaderID);
			
			string logInfo = GL.GetShaderInfoLog(shaderID);
			
			if ( string.Empty != logInfo ) {
				throw new Exception ("There was a problem compiling a shading program. Problems as follows '" + logInfo + "'. If the code looks fine, are you using the right shader type? For example, maybe you passed fragment code to a vertex shader?");	
			}
			
			return shaderID;
			
		}
开发者ID:interfaceVision,项目名称:monomac,代码行数:48,代码来源:Scene.cs

示例2: 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

示例3: Compile

 public void Compile(string sShader, ShaderType type)
 {
     isLinked = false;
     int shaderObject = GL.CreateShader(type);
     if (0 == shaderObject) throw new ShaderException(type.ToString(), "Could not create shader object", string.Empty, sShader);
     // Compile vertex shader
     GL.ShaderSource(shaderObject, sShader);
     GL.CompileShader(shaderObject);
     int status_code;
     GL.GetShader(shaderObject, ShaderParameter.CompileStatus, out status_code);
     LastLog = GL.GetShaderInfoLog(shaderObject);
     if (1 != status_code)
     {
         throw new ShaderException(type.ToString(), "Error compiling shader", LastLog, sShader);
     }
     GL.AttachShader(m_ProgramID, shaderObject);
     //shaderIDs.Add(shaderObject);
 }
开发者ID:danielscherzer,项目名称:Framework,代码行数:18,代码来源:Shader.cs

示例4: AddShader

 public void AddShader(ShaderType type, String source)
 {
     _shaders[type] = GL.CreateShader(type);
     GL.ShaderSource(_shaders[type], source);
     GL.CompileShader(_shaders[type]);
     if (OnMessage != null) OnMessage(GL.GetShaderInfoLog(_shaders[type]));
     int compileResult;
     GL.GetShader(_shaders[type], ShaderParameter.CompileStatus, out compileResult);
     if (compileResult != 1)
     {
         if (OnMessage != null) OnMessage("Compile Error:" + type.ToString());
     }
     if (OnMessage != null) OnMessage("Compiled");
     GL.AttachShader(Program, _shaders[type]);
 }
开发者ID:veggielane,项目名称:ORTS,代码行数:15,代码来源:ShaderProgram.cs

示例5: Load

        public int Load(SceneNode _node, ShaderType type)
        {
            BaseShader shader = null;
            switch (type)
            {
                case ShaderType.Sky:
                    if (Reference.Viewer.IsDrawSky)
                    {
                        shader = new Sky(Reference.Viewer, ParentNode);
                    }
                    break;

                case ShaderType.Sea:
                    if (Reference.Viewer.IsDrawSea)
                    {
                        if (Reference.Viewer.SeaQuality == Viewer.ShaderLevelType.Low)
                            shader = new Sea(Reference.Viewer, ParentNode);
                    }
                    break;

                case ShaderType.AdvancedSea:
                    if (Reference.Viewer.IsDrawSea)
                    {
                        if (Reference.Viewer.SeaQuality == Viewer.ShaderLevelType.High)
                            shader = new AdvancedSea(Reference.Viewer, ParentNode);
                    }
                    break;

                case ShaderType.Shadow:
                    if (Reference.Viewer.IsDrawSky)
                    {
                    }
                    break;
            }

            int res = -1;
            if (shader != null)
            {
                // Load shader.
                //Reference.Device.FileSystem.WorkingDirectory = Util.ApplicationDataDirectory + @"\media";
                res = shader.Load();
                if (res > 0)
                {
                    if (shaders.ContainsKey(type))
                    {
                        Reference.Log.Debug("[SHADER]: " + type.ToString() + " Read multi.");
                    }
                    else
                    {
                        lock (shaders)
                        {
                            shaders.Add(type, shader);
                        }

                        lock (shaderIndex)
                        {
                            shaderIndex.Add(type, res);
                        }
                    }
                }
                else
                {
                    Reference.Log.Debug("[SHADER]: " + type.ToString() + " Shader don't load.");
                }
            }

            return res;
        }
开发者ID:caocao,项目名称:3di-viewer-rei,代码行数:68,代码来源:ShaderManager.cs

示例6: CompileShader

        protected void CompileShader(ShaderType type, string[] source)
        {
            _shaderId = GL.CreateShader(type);
            int[] lens = new int[source.Length];
            for (int i = 0; i < lens.Length; i++)
                lens[i] = -1;
            GL.ShaderSource(ID, source.Length, source, ref lens[0]);
            GL.CompileShader(ID);

            int status;
            GL.GetShader(ID, ShaderParameter.CompileStatus, out status);
            if (status == 0)
                throw new GraphicsException(
                    String.Format("Error compiling {0} shader: {1}", type.ToString(), GL.GetShaderInfoLog(ID)));
        }
开发者ID:henrikno,项目名称:FastIntroFramework,代码行数:15,代码来源:Shader.cs

示例7: checkCompilationErrors

        private void checkCompilationErrors(int shaderID, ShaderType type)
        {
            int compileStatus = 0;
            GL.GetShader(shaderID, ShaderParameter.CompileStatus, out compileStatus);

            if (compileStatus == COMPILE_ERROR)
            {
                //Shader compilation failed.  Output compilation error to console and throw new exception
                string shaderInfo = String.Empty;
                GL.GetShaderInfoLog(shaderID, out shaderInfo);

                Console.WriteLine(String.Format("ERROR::SHADER: Compile-time error: Type: {0}\n{1}", type.ToString(), shaderInfo));

                throw new ShaderCompilationErrorException(
                    String.Format("Shader #{0} ({1}) failed to compile.  Check debug console for error message.",
                    shaderID, type.ToString()));
            }
        }
开发者ID:minalear,项目名称:Breakout,代码行数:18,代码来源:Shader.cs

示例8: LoadShader

        /// <summary>
        /// Build the shaders
        /// </summary>
        private int LoadShader(ShaderType type, string source)
        {
            int shader = GL20.CreateShader (type);

            if (shader == 0)
                throw new InvalidOperationException (string.Format (
                    "Unable to create shader: {0}", GL20.GetError ())
                );

            // Load the shader source
            int length = 0;
            GL20.ShaderSource (shader, 1, new string[] {source}, (int[])null);

            // Compile the shader
            GL20.CompileShader (shader);

            int compiled = 0;
            GL20.GetShader (shader, ShaderParameter.CompileStatus, out compiled);
            if (compiled == 0) {
                length = 0;
                GL20.GetShader (shader, ShaderParameter.InfoLogLength, out length);
                if (length > 0) {
                    var log = new StringBuilder (length);
                    GL20.GetShaderInfoLog (shader, length, out length, log);
            #if DEBUG
                        Console.WriteLine("GL2" + log.ToString ());
            #endif
                }

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

            return shader;
        }
开发者ID:noxo,项目名称:MonoGame,代码行数:38,代码来源:SpriteBatch.cs


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