示例#1
0
        protected override void OnInitGLProgram(object sender, EventArgs handler)
        {
            //--------------------------------------------------------------------------
            string vs = @"
                attribute vec4 a_position;
                attribute vec2 a_texCoord;
                varying vec2 v_texCoord;
                void main()
                {
                    gl_Position = a_position;
                    v_texCoord = a_texCoord;
                 }	 
                ";

            string fs = @"
                      precision mediump float;
                      varying vec2 v_texCoord;
                      uniform sampler2D s_texture;
                      void main()
                      {
                         gl_FragColor = texture2D(s_texture, v_texCoord);
                      }
                ";

            mProgram = ES2Utils.CompileProgram(vs, fs);
            if (mProgram == 0)
            {
                //return false
            }

            // Get the attribute locations
            mPositionLoc = GL.GetAttribLocation(mProgram, "a_position");
            mTexCoordLoc = GL.GetAttribLocation(mProgram, "a_texCoord");

            // Get the sampler location
            mSamplerLoc = GL.GetUniformLocation(mProgram, "s_texture");

            //// Load the texture
            mTexture = ES2Utils2.CreateSimpleTexture2D();
            GL.ClearColor(0, 0, 0, 0);
            //================================================================================
        }
示例#2
0
        protected override void OnInitGLProgram(object sender, EventArgs handler)
        {
            shaderProgram = new MiniShaderProgram();
            string vs = @"
                attribute vec3 a_position;
                attribute vec2 a_texCoord;
                varying vec2 v_texCoord;
                void main()
                {
                    gl_Position = vec4(a_position[0],a_position[1],0,1);
                    v_texCoord = a_texCoord;
                 }	 
                ";
            string fs = @"
                      precision mediump float;
                      varying vec2 v_texCoord;
                      uniform sampler2D s_texture;
                      void main()
                      {
                         gl_FragColor = texture2D(s_texture, v_texCoord);
                      }
                ";

            if (!shaderProgram.Build(vs, fs))
            {
            }

            //-------------------------------------------

            // Get the attribute locations
            a_position  = shaderProgram.GetAttrV3f("a_position");// GL.GetAttribLocation(mProgram, "a_position");
            a_textCoord = shaderProgram.GetAttrV2f("a_texCoord");
            // Get the sampler location
            s_texture = shaderProgram.GetUniform1("s_texture");
            //// Load the texture
            mTexture = ES2Utils2.CreateSimpleTexture2D();
            GL.ClearColor(0, 0, 0, 0);
            //================================================================================
        }