Exemplo n.º 1
0
        public override void Activate()
        {
            if (linked == 0 && !triedToLinkAndFailed)
            {
                GL.GetError();

                glProgramHandle = GL.CreateProgram();
                GLES2Config.GlCheckError(this);
#if !AXIOM_NO_GLES2_GLSL_OPTIMIZER
                if (vertexProgram != null)
                {
                    string paramStr = vertexProgram.GLSLProgram.GetParameter["use_optimiser"];
                    if (paramStr == "true" || paramStr.Length == 0)
                    {
                        GLSLESLinkProgramManager.Instance.OptimizeShaderSource(vertexProgram);
                    }
                }
                if (vertexProgram != null)
                {
                    string paramStr = fragmentProgram.GLSLProgram.GetParameter("use_optimiser");
                    if (paramStr == "true" || paramStr.Length == 0)
                    {
                        GLSLESLinkProgramManager.Instance.OptimizeShaderSource(fragmentProgram);
                    }
                }
#endif
                this.CompileAndLink();

                this.ExtractLayoutQualifiers();
                this.BuildGLUniformReferences();
            }
            this._useProgram();
        }
Exemplo n.º 2
0
        internal static void GlClearError()
        {
            var e = (int)OpenGL.GetError();

            if (e != 0)
            {
                LogManager.Instance.Write(string.Format("[GLES2] Ignoring error {0} on stack.", e));
            }
        }
Exemplo n.º 3
0
        public static void GlCheckError(object caller, bool raiseException)
#endif
        {
            var e = OpenGL.GetError();

            if (e != OpenTK.Graphics.ES20.All.None)
            {
                var msg = string.Format("[GLES2] Error {0}: {1} from {2}", (int)e, e, caller.ToString());
                LogManager.Instance.Write(msg);
                if (raiseException)
                {
                    throw new AxiomException(msg);
                }
            }
        }
Exemplo n.º 4
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);
        }