Exemple #1
0
        public override void Present(float deltaTime)
        {
            IGL10 gl = _glGraphics.GL10;

            gl.GlViewport(0, 0, _glGraphics.Width, _glGraphics.Height);
            gl.GlClearColor(0, 0, 0, 1);
            gl.GlClear(GL10.GlColorBufferBit);
            gl.GlMatrixMode(GL10.GlProjection);
            gl.GlLoadIdentity();
            gl.GlOrthof(0, 540, 0, 960, 1, -1);
            gl.GlEnable(GL10.GlTexture2d);


            gl.GlBlendFunc(GL10.GlSrcAlpha, GL10.GlOneMinusSrcAlpha);
            gl.GlEnable(GL10.GlBlend);

            gl.GlBindTexture(GL10.GlTexture2d, _textureId);



            gl.GlEnableClientState(GL10.GlVertexArray);
            gl.GlEnableClientState(GL10.GlTextureCoordArray);

            _vertices.Position(0);
            gl.GlVertexPointer(2, GL10.GlFloat, _vertexSize, _vertices);
            _vertices.Position(2);
            gl.GlTexCoordPointer(2, GL10.GlFloat, _vertexSize, _vertices);
            gl.GlDrawArrays(GL10.GlTriangles, 0, 3);
            //gl.GlDisableClientState(GL10.GlVertexArray);
            //gl.GlDisableClientState(GL10.GlTextureCoordArray);
        }
        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);
        }
Exemple #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);
        }
Exemple #4
0
        public override void Resume()
        {
            IGL10 gl = _glGraphics.GL10;

            gl.GlViewport(0, 0, _glGraphics.Width, _glGraphics.Height);
            gl.GlClearColor(0, 0, 1, 1);


            gl.GlMatrixMode(GL10.GlProjection);
            gl.GlLoadIdentity();
            gl.GlOrthof(0, 320, 0, 480, 1, -1);
            gl.GlEnable(GL10.GlBlend);
            gl.GlEnable(GL10.GlTexture2d);
            _textureRgb.Reload();
            _textureRgba.Reload();
        }
 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);
 }
Exemple #6
0
        public void OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config)
        {
            gl.GlClearColor(0.0f, 0.0f, 0.0f, 0.5f);

            gl.GlClearDepthf(1.0f);
            gl.GlEnable(IGL10Constants.GL_DEPTH_TEST);
            gl.GlDepthFunc(IGL10Constants.GL_LEQUAL);

            gl.GlHint(IGL10Constants.GL_PERSPECTIVE_CORRECTION_HINT,
                      IGL10Constants.GL_NICEST);
        }
        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 override void Present(float deltaTime)
        {
            IGL10 gl = _glGraphics.GL10;

            gl.GlViewport(0, 0, _glGraphics.Width, _glGraphics.Height);
            gl.GlClear(GL10.GlColorBufferBit);
            gl.GlMatrixMode(GL10.GlProjection);
            gl.GlLoadIdentity();
            gl.GlOrthof(0, 540, 0, 960, 1, -1);
            gl.GlEnable(GL10.GlTexture2d);

            _texture.BindTexture();

            gl.GlEnableClientState(GL10.GlVertexArray);
            gl.GlEnableClientState(GL10.GlTextureCoordArray);
            _vertices.Position(0);
            gl.GlVertexPointer(2, GL10.GlFloat, _vertexSize, _vertices);
            _vertices.Position(2);
            gl.GlTexCoordPointer(2, GL10.GlFloat, _vertexSize, _vertices);
            gl.GlDrawElements(GL10.GlTriangles, 6, GL10.GlUnsignedShort, _indices);
        }
        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);
        }
Exemple #10
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);
        }
Exemple #11
0
 public void OnSurfaceCreated(IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config)
 {
     // Set the background frame color
      // ������Ӱƽ��
      gl.GlShadeModel(GL10.GlSmooth);
      // ��ɫ����
      gl.GlClearColor(0.5f, 0.6f, 0.6f, 1.0f);
      // ������Ȼ���
      gl.GlClearDepthf(1.0f);
      // ������Ȳ���
      gl.GlEnable(GL10.GlDepthTest);
      // ������Ȳ��Ե�����
      gl.GlDepthFunc(GL10.GlLequal);
      // ����ϵͳ��͸�ӽ�������
      gl.GlHint(GL10.GlPerspectiveCorrectionHint, GL10.GlNicest);
 }