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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
 /** Called when the surface is created or recreated.
  * Reinitialize OpenGL related stuff here*/
 public void OnSurfaceCreated(IGL10 gl, EGLConfig config)
 {
     gl.GlClearColor(1.0f, 1.0f, 1.0f, 1.0f);
     //Here we create the 3D object and initialize textures, shaders, etc.
     monkeyMesh = new Mesh();
     monkeyMesh.InitMesh(context.Assets, "media/monkey.json", "media/texture.png");
 }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        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 OnSurfaceChanged (IGL10 gl, int width, int height)
		{
			// Replace the current matrix with the identity matrix
			gl.GlMatrixMode (GL10.GlProjection);
			gl.GlLoadIdentity(); // OpenGL docs
			gl.GlOrthof (-2, 2, -2, 2, -1, 10);

			// Translates 4 units into the screen.
			gl.GlMatrixMode (GL10.GlModelview);
			//gl.GlTranslatef(0, 0, -4); // OpenGL docs

			gl.GlClearColor (255, 255, 255, 255);
			gl.GlClear(GL10.GlColorBufferBit | // OpenGL docs.
			           GL10.GlDepthBufferBit);
		}
Exemplo n.º 8
0
        public void OnSurfaceChanged(IGL10 gl, int width, int height)
        {
            // Replace the current matrix with the identity matrix
            gl.GlMatrixMode(GL10.GlProjection);
            gl.GlLoadIdentity();             // OpenGL docs
            gl.GlOrthof(-2, 2, -2, 2, -1, 10);

            // Translates 4 units into the screen.
            gl.GlMatrixMode(GL10.GlModelview);
            //gl.GlTranslatef(0, 0, -4); // OpenGL docs

            gl.GlClearColor(255, 255, 255, 255);
            gl.GlClear(GL10.GlColorBufferBit |             // OpenGL docs.
                       GL10.GlDepthBufferBit);
        }
Exemplo n.º 9
0
        public override void Resume()
        {
            IGL10 gl = _glGraphics.GL10;

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


            gl.GlMatrixMode(GL10.GlProjection);
            gl.GlLoadIdentity();
            gl.GlOrthof(0, 540, 0, 960, 1, -1);

            gl.GlEnable(GL10.GlTexture2d);
            _texture.Reload();
            //_texture.BindTexture ();
        }
Exemplo n.º 10
0
 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);
 }
Exemplo n.º 11
0
        /** Called when the surface is created or recreated.
         * Reinitialize OpenGL related stuff here*/
        public void OnSurfaceCreated(IGL10 gl, EGLConfig config)
        {
            gl.GlClearColor(1.0f, 1.0f, 1.0f, 1.0f);
            //Here we create the 3D object and initialize textures, shaders, etc.

            monkeyMesh       = new Mesh();
            monkeyMeshYellow = new Mesh();
            monkeyMeshBlue   = new Mesh();
            monkeyMeshRed    = new Mesh();
            monkeyMeshGray   = new Mesh();

            Task.Run(async() =>
            {
                try
                {
                    ((Activity)context).RunOnUiThread(() =>
                    {
                        progressDialog = ProgressDialog.Show(context, "Loading textures", "The 3D template textures of this tutorial have not been loaded yet\n(this may take a while)", true);
                    });
                    monkeyMesh.InitMesh(context.Assets, "media/monkey.json", "media/texture.png");
                    monkeyMeshYellow.InitMesh(context.Assets, "media/monkey.json", "media/texture.png");
                    monkeyMeshBlue.InitMesh(context.Assets, "media/monkey.json", "media/texture2.png");
                    monkeyMeshRed.InitMesh(context.Assets, "media/monkey.json", "media/texture3.png");
                    monkeyMeshGray.InitMesh(context.Assets, "media/monkey.json", "media/texturegray.png");
                    monkeyMesh = monkeyMeshGray; // Initially we want to display the gray monkey

                    if (progressDialog != null)
                    {
                        progressDialog.Dismiss();
                    }
                }
                catch (System.OperationCanceledException ex)
                {
                    Console.WriteLine("init failed: {ex.Message}");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            });
        }
Exemplo n.º 12
0
        public void OnDrawFrame(IGL10 gl)
        {
            mObserver.OnDrawFrame();

            gl.GlClearColor(Color.GetRedComponent(mBackgroundColor) / 255f,
                            Color.GetGreenComponent(mBackgroundColor) / 255f,
                            Color.GetBlueComponent(mBackgroundColor) / 255f,
                            Color.GetAlphaComponent(mBackgroundColor) / 255f);
            gl.GlClear(GL10.GlColorBufferBit);
            gl.GlLoadIdentity();

            if (USE_PERSPECTIVE_PROJECTION)
            {
                gl.GlTranslatef(0, 0, -6f);
            }

            for (int i = 0; i < mCurlMeshes.Count; ++i)
            {
                mCurlMeshes.ElementAt(i).OnDrawFrame(gl);
            }
        }
Exemplo n.º 13
0
        /** Called when the surface is created or recreated.
         * Reinitialize OpenGL related stuff here*/
        public void OnSurfaceCreated(IGL10 gl, EGLConfig config)
        {
            gl.GlClearColor(1.0f, 1.0f, 1.0f, 1.0f);
            //Here we create the 3D object and initialize textures, shaders, etc.

            Task.Run(async() =>
            {
                try
                {
                    InitMeshes();
                }
                catch (OperationCanceledException ex)
                {
                    Console.WriteLine("init failed: {ex.Message}");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            });
        }
Exemplo n.º 14
0
        /// <summary>
        /// Raises the draw frame event.
        /// </summary>
        /// <param name="gl">Gl.</param>
        public void OnDrawFrame(IGL10 gl)
        {
            lock (_triangles)
            {
                // Replace the current matrix with the identity matrix
                gl.GlMatrixMode(GL10.GlProjection);
                gl.GlLoadIdentity(); // OpenGL docs
                gl.GlOrthof(_left, _right, _bottom, _top, -1, 1);


                SimpleColor color = SimpleColor.FromKnownColor(KnownColor.White);
                gl.GlClearColor(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f);
                gl.GlClear(GL10.GlColorBufferBit);

                for (int idx = 0; idx < _triangles.Count; idx++)
                {
                    gl.GlVertexPointer(3, GL10.GlFloat, 0, _triangles[idx].Vertices);
                    gl.GlEnableClientState(GL10.GlVertexArray);
                    gl.GlColorPointer(4, GL10.GlUnsignedByte, 0, _triangles[idx].Colors);
                    gl.GlEnableClientState(GL10.GlColorArray);

                    gl.GlDrawArrays(GL10.GlTriangleStrip, 0, _triangles[idx].Count);
                }

                for (int idx = 0; idx < _lines.Count; idx++)
                {
                    gl.GlVertexPointer(3, GL10.GlFloat, 0, _lines[idx].Vertices);
                    gl.GlEnableClientState(GL10.GlVertexArray);

                    color = new SimpleColor()
                    {
                        Value = _lines[idx].Color
                    };
                    gl.GlColor4f(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f);
                    gl.GlLineWidth(_lines[idx].Width);
                    gl.GlDrawArrays(GL10.GlLineStrip, 0, _lines[idx].Count);
                }
            }
        }
        /** Called when the surface is created or recreated.
         * Reinitialize OpenGL related stuff here*/
        public void OnSurfaceCreated(IGL10 gl, EGLConfig config)
        {
            gl.GlClearColor(1.0f, 1.0f, 1.0f, 1.0f);
            //Here we create the 3D object and initialize textures, shaders, etc.

            monkeyMesh = new Mesh();
            videoMesh  = new VideoMesh((Activity)context);

            Task.Run(async() =>
            {
                try
                {
                    ((Activity)context).RunOnUiThread(() =>
                    {
                        progressDialog = ProgressDialog.Show(context, "Loading textures", "The 3D and video template textures of this tutorial have not been loaded yet", true);
                    });

                    monkeyMesh.InitMesh(context.Assets, "media/monkey.json", "media/texture.png");

                    videoMesh.InitMesh(context.Assets, "media/pikkart_video.mp4", "media/pikkart_keyframe.png", 0, false, null);

                    if (progressDialog != null)
                    {
                        progressDialog.Dismiss();
                    }
                }
                catch (System.OperationCanceledException ex)
                {
                    Console.WriteLine("init failed: {ex.Message}");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            });
        }
Exemplo n.º 16
0
 /** Called when the surface is created or recreated.
  * Reinitialize OpenGL related stuff here*/
 public void OnSurfaceCreated(IGL10 gl, EGLConfig config)
 {
     gl.GlClearColor(1.0f, 1.0f, 1.0f, 1.0f);
 }
        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);
        }
Exemplo n.º 18
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);
 }
Exemplo n.º 19
0
		/// <summary>
		/// Raises the draw frame event.
		/// </summary>
		/// <param name="gl">Gl.</param>
        public void OnDrawFrame(IGL10 gl)
        {
            lock (_triangles)
            {
                // Replace the current matrix with the identity matrix
                gl.GlMatrixMode(GL10.GlProjection);
                gl.GlLoadIdentity(); // OpenGL docs
                gl.GlOrthof(_left, _right, _bottom, _top, -1, 1);


                SimpleColor color = SimpleColor.FromKnownColor(KnownColor.White);
                gl.GlClearColor(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f);
                gl.GlClear(GL10.GlColorBufferBit);

                for (int idx = 0; idx < _triangles.Count; idx++)
                {
                    gl.GlVertexPointer(3, GL10.GlFloat, 0, _triangles[idx].Vertices);
                    gl.GlEnableClientState(GL10.GlVertexArray);
                    gl.GlColorPointer(4, GL10.GlUnsignedByte, 0, _triangles[idx].Colors);
                    gl.GlEnableClientState(GL10.GlColorArray);

                    gl.GlDrawArrays(GL10.GlTriangleStrip, 0, _triangles[idx].Count);
                }

                for (int idx = 0; idx < _lines.Count; idx++)
                {
                    gl.GlVertexPointer(3, GL10.GlFloat, 0, _lines[idx].Vertices);
                    gl.GlEnableClientState(GL10.GlVertexArray);

                    color = new SimpleColor()
                    {
                        Value = _lines[idx].Color
                    };
                    gl.GlColor4f(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f);
                    gl.GlLineWidth(_lines[idx].Width);
                    gl.GlDrawArrays(GL10.GlLineStrip, 0, _lines[idx].Count);
                }
            }
        }