/// <summary> /// Render each frame. /// This method is called when Android.Opengl.GLSurfaceView.IRenderer's OnDrawFrame. /// </summary> /// <param name="frame">ARFrame</param> public void OnDrawFrame(ARFrame frame) { ShaderUtil.CheckGlError(TAG, "On draw frame start."); if (frame == null) { return; } if (frame.HasDisplayGeometryChanged) { frame.TransformDisplayUvCoords(mTexBuffer, mTexTransformedBuffer); } Clear(); GLES20.GlDisable(GLES20.GlDepthTest); GLES20.GlDepthMask(false); GLES20.GlUseProgram(mProgram); // Set the texture ID. GLES20.GlBindTexture(GLES11Ext.GlTextureExternalOes, mExternalTextureId); // Set the projection matrix. GLES20.GlUniformMatrix4fv(mMatrix, 1, false, mProjectionMatrix, 0); GLES20.GlUniformMatrix4fv(mCoordMatrix, 1, false, coordMatrixs, 0); // Set the vertex. GLES20.GlEnableVertexAttribArray(mPosition); GLES20.GlVertexAttribPointer(mPosition, 2, GLES20.GlFloat, false, 0, mVerBuffer); // Set the texture coordinates. GLES20.GlEnableVertexAttribArray(mCoord); GLES20.GlVertexAttribPointer(mCoord, 2, GLES20.GlFloat, false, 0, mTexTransformedBuffer); // Number of vertices. GLES20.GlDrawArrays(GLES20.GlTriangleStrip, 0, 4); GLES20.GlDisableVertexAttribArray(mPosition); GLES20.GlDisableVertexAttribArray(mCoord); GLES20.GlDepthMask(true); GLES20.GlEnable(GLES20.GlDepthTest); ShaderUtil.CheckGlError(TAG, "On draw frame end."); }