Пример #1
0
        protected override void UnloadHighLevelImpl()
        {
            if (IsSupported)
            {
                GL.DeleteShader(this.glShaderHandle);
                GLES2Config.GlCheckError(this);

                // TODO : Root.Instance.RenderSystem.Capabilities.HasCapability(Capabilities.SeperateShaderObjects))
                if (false)
                {
                    GL.DeleteProgram(this.glProgramHandle);
                    GLES2Config.GlCheckError(this);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Build the shaders
        /// </summary>
        private int LoadShader(All20 type, string source)
        {
            int shader = GL20.CreateShader(type);

            if (shader == 0)
            {
                throw new InvalidOperationException("Unable to create shader");
            }

            // Load the shader source
            int length = 0;

            GL20.ShaderSource(shader, 1, new string[] { source }, new int[] { source.Length });

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

            int[] compiled = new int[1];
            GL20.GetShader(shader, All20.CompileStatus, compiled);
            if (compiled[0] == 0)
            {
                length = 0;
                GL20.GetShader(shader, All20.InfoLogLength, ref length);
                var log = new StringBuilder(length);
                GL20.GetShaderInfoLog(shader, length, ref length, log);
                Console.WriteLine("GL2" + log.ToString());
                GL20.DeleteShader(shader);

                //length = 0;
                //GL20.GetShader(shader, All20.InfoLogLength, ref length);
                //if (length > 0)
                //{
                //    var log = new StringBuilder(length);
                //    GL20.GetShaderInfoLog(shader, length, ref length, log);
                //    Console.WriteLine("GL2" + log.ToString());
                //}
                //GL20.DeleteShader(shader);
                throw new InvalidOperationException("Unable to compile shader of type : " + type.ToString());
            }

            return(shader);
        }
Пример #3
0
        /// <summary>
        /// Build the shaders
        /// </summary>
        private int LoadShader(ALL20 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, ALL20.CompileStatus, ref compiled);
            if (compiled == 0)
            {
                length = 0;
                GL20.GetShader(shader, ALL20.InfoLogLength, ref length);
                if (length > 0)
                {
                    var log = new StringBuilder(length);
                    GL20.GetShaderInfoLog(shader, length, ref 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);
        }