public void OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config)
        {
            gl.GlClearColor(0f, 0f, 0f, 1f);
            gl.GlShadeModel(GL10.GlSmooth);
            gl.GlHint(GL10.GlPerspectiveCorrectionHint, GL10.GlNicest);
            gl.GlHint(GL10.GlLineSmoothHint, GL10.GlNicest);
            gl.GlHint(GL10.GlPolygonSmoothHint, GL10.GlNicest);
            gl.GlEnable(GL10.GlLineSmooth);
            gl.GlDisable(GL10.GlDepthTest);
            gl.GlDisable(GL10.GlCullFaceCapability);

            mObserver.OnSurfaceCreated();
        }
        public void OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config)
        {
            /*
             * By default, OpenGL enables features that improve quality
             * but reduce performance. One might want to tweak that
             * especially on software renderer.
             */
            gl.GlDisable(GL10.GlDither);

            /*
             * Some one-time OpenGL initialization can be made here
             * probably based on features of this particular context
             */
            gl.GlHint(GL10.GlPerspectiveCorrectionHint, GL10.GlFastest);

            if (mTranslucentBackground)
            {
                gl.GlClearColor(0, 0, 0, 0);
            }
            else
            {
                gl.GlClearColor(1, 1, 1, 1);
            }

            gl.GlEnable(GL10.GlCullFaceCapability);
            gl.GlShadeModel(GL10.GlSmooth);
            gl.GlEnable(GL10.GlDepthTest);
        }
Beispiel #3
0
        public void OnSurfaceCreated(IGL10 gl, EGLConfig config)
        {
            /*
             * By default, OpenGL enables features that improve quality
             * but reduce performance. One might want to tweak that
             * especially on software renderer.
             */
            gl.GlDisable(GL10.GlDither);

            /*
             * Some one-time OpenGL initialization can be made here
             * probably based on features of this particular context
             */
            gl.GlHint(GL10.GlPerspectiveCorrectionHint, GL10.GlFastest);

            if (mTranslucentBackground)
            {
                gl.GlClearColor(0, 0, 0, 0);
            }
            else
            {
                gl.GlClearColor(1, 1, 1, 1);
            }

            // FIXME: Mono.Android.dll misses this constant. Filed as #3531.
            gl.GlEnable(2884);            //GL10.GlCullFace);
            gl.GlShadeModel(GL10.GlSmooth);
            gl.GlEnable(GL10.GlDepthTest);
        }
 public void OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config)
 {
     // 关闭抗抖动
     gl.GlDisable(GL10.GlDither);
     // 设置系统对透视进行修正
     gl.GlHint(GL10.GlPerspectiveCorrectionHint, GL10.GlFastest);
     gl.GlClearColor(0, 0, 0, 0);
     // 设置阴影平滑模式
     gl.GlShadeModel(GL10.GlSmooth);
     // 启用深度测试
     gl.GlEnable(GL10.GlDepthTest);
     // 设置深度测试的类型
     gl.GlDepthFunc(GL10.GlLequal);
     // 启用2D纹理贴图
     gl.GlEnable(GL10.GlTexture2d);
     // 装载纹理
     loadTexture(gl);
 }
        public void OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config)
        {
            /*
             * By default, OpenGL enables features that improve quality
             * but reduce performance. One might want to tweak that
             * especially on software renderer.
             */
            gl.GlDisable (GL10.GlDither);

            /*
             * Some one-time OpenGL initialization can be made here
             * probably based on features of this particular context
             */
            gl.GlHint (GL10.GlPerspectiveCorrectionHint, GL10.GlFastest);

            if (mTranslucentBackground)
                gl.GlClearColor (0,0,0,0);
            else
                gl.GlClearColor (1,1,1,1);

            // FIXME: Mono.Android.dll misses this constant. Filed as #3531.
            gl.GlEnable(2884);//GL10.GlCullFace);
            gl.GlShadeModel(GL10.GlSmooth);
            gl.GlEnable(GL10.GlDepthTest);
        }
Beispiel #6
0
        public void OnDrawFrame(IGL10 gl)
        {
            // First allocate texture if there is not one yet.
            if (DRAW_TEXTURE && mTextureIds == null)
            {
                // Generate texture.
                mTextureIds = new int[2];
                gl.GlGenTextures(2, mTextureIds, 0);
                foreach (int textureId in mTextureIds)
                {
                    // Set texture attributes.
                    gl.GlBindTexture(GL10.GlTexture2d, textureId);
                    gl.GlTexParameterf(GL10.GlTexture2d,
                                       GL10.GlTextureMinFilter, GL10.GlNearest);
                    gl.GlTexParameterf(GL10.GlTexture2d,
                                       GL10.GlTextureMagFilter, GL10.GlNearest);
                    gl.GlTexParameterf(GL10.GlTexture2d, GL10.GlTextureWrapS,
                                       GL10.GlClampToEdge);
                    gl.GlTexParameterf(GL10.GlTexture2d, GL10.GlTextureWrapT,
                                       GL10.GlClampToEdge);
                }
            }

            if (DRAW_TEXTURE && mTexturePage.TexturesChanged)
            {
                gl.GlBindTexture(GL10.GlTexture2d, mTextureIds[0]);
                Bitmap texture = mTexturePage.GetTexture(mTextureRectFront,
                                                         CurlPage.SIDE_FRONT);
                GLUtils.TexImage2D(GL10.GlTexture2d, 0, texture, 0);
                texture.Recycle();

                mTextureBack = mTexturePage.HasBackTexture;
                if (mTextureBack)
                {
                    gl.GlBindTexture(GL10.GlTexture2d, mTextureIds[1]);
                    texture = mTexturePage.GetTexture(mTextureRectBack,
                                                      CurlPage.SIDE_BACK);
                    GLUtils.TexImage2D(GL10.GlTexture2d, 0, texture, 0);
                    texture.Recycle();
                }
                else
                {
                    mTextureRectBack.Set(mTextureRectFront);
                }

                mTexturePage.Recycle();
                Reset();
            }

            // Some 'global' settings.
            gl.GlEnableClientState(GL10.GlVertexArray);

            // TODO: Drop shadow drawing is done temporarily here to hide some
            // problems with its calculation.
            if (DRAW_SHADOW)
            {
                gl.GlDisable(GL10.GlTexture2d);
                gl.GlEnable(GL10.GlBlend);
                gl.GlBlendFunc(GL10.GlSrcAlpha, GL10.GlOneMinusSrcAlpha);
                gl.GlEnableClientState(GL10.GlColorArray);
                gl.GlColorPointer(4, GL10.GlFloat, 0, mBufShadowColors);
                gl.GlVertexPointer(3, GL10.GlFloat, 0, mBufShadowVertices);
                gl.GlDrawArrays(GL10.GlTriangleStrip, 0, mDropShadowCount);
                gl.GlDisableClientState(GL10.GlColorArray);
                gl.GlDisable(GL10.GlBlend);
            }

            if (DRAW_TEXTURE)
            {
                gl.GlEnableClientState(GL10.GlTextureCoordArray);
                gl.GlTexCoordPointer(2, GL10.GlFloat, 0, mBufTexCoords);
            }
            gl.GlVertexPointer(3, GL10.GlFloat, 0, mBufVertices);
            // Enable color array.
            gl.GlEnableClientState(GL10.GlColorArray);
            gl.GlColorPointer(4, GL10.GlFloat, 0, mBufColors);

            // Draw front facing blank vertices.
            gl.GlDisable(GL10.GlTexture2d);
            gl.GlDrawArrays(GL10.GlTriangleStrip, 0, mVerticesCountFront);

            // Draw front facing texture.
            if (DRAW_TEXTURE)
            {
                gl.GlEnable(GL10.GlBlend);
                gl.GlEnable(GL10.GlTexture2d);

                if (!mFlipTexture || !mTextureBack)
                {
                    gl.GlBindTexture(GL10.GlTexture2d, mTextureIds[0]);
                }
                else
                {
                    gl.GlBindTexture(GL10.GlTexture2d, mTextureIds[1]);
                }

                gl.GlBlendFunc(GL10.GlSrcAlpha, GL10.GlOneMinusSrcAlpha);
                gl.GlDrawArrays(GL10.GlTriangleStrip, 0, mVerticesCountFront);

                gl.GlDisable(GL10.GlBlend);
                gl.GlDisable(GL10.GlTexture2d);
            }

            int backStartIdx = Math.Max(0, mVerticesCountFront - 2);
            int backCount    = mVerticesCountFront + mVerticesCountBack - backStartIdx;

            // Draw back facing blank vertices.
            gl.GlDrawArrays(GL10.GlTriangleStrip, backStartIdx, backCount);

            // Draw back facing texture.
            if (DRAW_TEXTURE)
            {
                gl.GlEnable(GL10.GlBlend);
                gl.GlEnable(GL10.GlTexture2d);

                if (mFlipTexture || !mTextureBack)
                {
                    gl.GlBindTexture(GL10.GlTexture2d, mTextureIds[0]);
                }
                else
                {
                    gl.GlBindTexture(GL10.GlTexture2d, mTextureIds[1]);
                }

                gl.GlBlendFunc(GL10.GlSrcAlpha, GL10.GlOneMinusSrcAlpha);
                gl.GlDrawArrays(GL10.GlTriangleStrip, backStartIdx, backCount);

                gl.GlDisable(GL10.GlBlend);
                gl.GlDisable(GL10.GlTexture2d);
            }

            // Disable textures and color array.
            gl.GlDisableClientState(GL10.GlTextureCoordArray);
            gl.GlDisableClientState(GL10.GlColorArray);

            if (DRAW_POLYGON_OUTLINES)
            {
                gl.GlEnable(GL10.GlBlend);
                gl.GlBlendFunc(GL10.GlSrcAlpha, GL10.GlOneMinusSrcAlpha);
                gl.GlLineWidth(1.0f);
                gl.GlColor4f(0.5f, 0.5f, 1.0f, 1.0f);
                gl.GlVertexPointer(3, GL10.GlFloat, 0, mBufVertices);
                gl.GlDrawArrays(GL10.GlLineStrip, 0, mVerticesCountFront);
                gl.GlDisable(GL10.GlBlend);
            }

            if (DRAW_CURL_POSITION)
            {
                gl.GlEnable(GL10.GlBlend);
                gl.GlBlendFunc(GL10.GlSrcAlpha, GL10.GlOneMinusSrcAlpha);
                gl.GlLineWidth(1.0f);
                gl.GlColor4f(1.0f, 0.5f, 0.5f, 1.0f);
                gl.GlVertexPointer(2, GL10.GlFloat, 0, mBufCurlPositionLines);
                gl.GlDrawArrays(GL10.GlLines, 0, mCurlPositionLinesCount * 2);
                gl.GlDisable(GL10.GlBlend);
            }

            if (DRAW_SHADOW)
            {
                gl.GlEnable(GL10.GlBlend);
                gl.GlBlendFunc(GL10.GlSrcAlpha, GL10.GlOneMinusSrcAlpha);
                gl.GlEnableClientState(GL10.GlColorArray);
                gl.GlColorPointer(4, GL10.GlFloat, 0, mBufShadowColors);
                gl.GlVertexPointer(3, GL10.GlFloat, 0, mBufShadowVertices);
                gl.GlDrawArrays(GL10.GlTriangleStrip, mDropShadowCount,
                                mSelfShadowCount);
                gl.GlDisableClientState(GL10.GlColorArray);
                gl.GlDisable(GL10.GlBlend);
            }

            gl.GlDisableClientState(GL10.GlVertexArray);
        }