示例#1
0
        /// <summary>
        /// Initialise the shader
        /// </summary>
        public void Initialise()
        {
            try
            {
                string fs;
                EmbeddedResourceHelper.GetEmbeddedFileAsString(Assembly.GetExecutingAssembly(), "textureshader.frag", out fs);

                string vs;
                EmbeddedResourceHelper.GetEmbeddedFileAsString(Assembly.GetExecutingAssembly(), "textureshader.vert", out vs);

                base.Initialise(fs, vs);

                // get attribute locations
                VertexAttribLocation       = GL.GetAttribLocation(m_Program, "aVert");
                TextureCoordAttribLocation = GL.GetAttribLocation(m_Program, "aTexCoord");

                // get uniform locations
                ProjectionMatrixLocation = GL.GetUniformLocation(m_Program, "uProjection_matrix");
                ModelViewMatrixLocation  = GL.GetUniformLocation(m_Program, "uModelview_matrix");

                // get the texture sampler location
                TextureSlotLocation = GL.GetUniformLocation(m_Program, "uTexSlot0");
            }
            catch (ShaderException se)
            {
                System.Diagnostics.Debug.WriteLine(se.Message);
            }
        }