Ejemplo n.º 1
0
        public void OnSurfaceCreated(IGL10 gl, EGLConfig config)
        {
            // GL configurations
            int bonenum = 48;

            GLES20.GlGetIntegerv(GLES20.GlMaxTextureSize, mTexSize, 0);
            ShellViewModel.MaxBone = bonenum;
            mNpot = hasExt("GL_OES_texture_npot");

            // initialize
            GLES20.GlClearColor(0, 0, 0, 1);
            GLES20.GlEnable(GLES20.GlDepthTest);
            GLES20.GlEnable(GLES20.GlBlend);
            checkGlError("GlEnable");

            // GLUtils.texImage2D generates premultiplied-alpha texture. so we use GL_ONE instead of GL_ALPHA
            GLES20.GlBlendFunc(GL10.GlOne, GL10.GlOneMinusSrcAlpha);
            GLES20.GlDepthFunc(GLES20.GlLequal);
            GLES20.GlFrontFace(GLES20.GlCw);
            checkGlError("GlMiscSettings");

            // shader programs
            mGLSL = new Dictionary <String, GLSL>();

            mGLSL.Add("builtin:default",
                      new GLSL(String.Format(Util.ReadAssetString("shader/vs.vsh"), ShellViewModel.MaxBone),
                               Util.ReadAssetString("shader/fs.fsh")));

            mGLSL.Add("builtin:default_alpha",
                      new GLSL(String.Format(Util.ReadAssetString("shader/vs.vsh"), ShellViewModel.MaxBone),
                               Util.ReadAssetString("shader/fs_alpha.fsh")));

            mGLSL.Add("builtin:nomotion",
                      new GLSL(Util.ReadAssetString("shader/vs_nm.vsh"), Util.ReadAssetString("shader/fs.fsh")));

            mGLSL.Add("builtin:nomotion_alpha",
                      new GLSL(Util.ReadAssetString("shader/vs_nm.vsh"), Util.ReadAssetString("shader/fs_alpha.fsh")));

            // render targets
            mRT = new Dictionary <String, RenderTarget>();
            mRT.Add("screen", new RenderTarget());

            GLES20.GlBindFramebuffer(GLES20.GlFramebuffer, 0);
        }