Exemple #1
0
        /// <summary>
        /// 初始化上下文
        /// </summary>
        /// <param name="context"></param>
        private void Initialize(Context context)
        {
            _clientBounds = new Rectangle(0, 0, context.Resources.DisplayMetrics.WidthPixels, context.Resources.DisplayMetrics.HeightPixels);
            GameView      = new AndroidGameView(context, this, _game);
            //GameView.LogFPS = true;
            GameView.RenderOnUIThread = Game.Activity.RenderOnUIThread;
            GameView.RenderFrame     += OnRenderFrame;
            GameView.UpdateFrame     += OnUpdateFrame;

            GameView.RequestFocus();
            GameView.FocusableInTouchMode = true;
        }
Exemple #2
0
 public BackgroundContext(AndroidGameView view)
 {
     this.view = view;
     foreach (var v in EW.Framework.GLESVersion.GetSupportedGLESVersions())
     {
         eglContext = view.egl.EglCreateContext(view.eglDisplay, view.eglConfig, EGL10.EglNoContext, v.GetAttributes());
         if (eglContext == null || eglContext == EGL10.EglNoContext)
         {
             continue;
         }
         break;
     }
     if (eglContext == null || eglContext == EGL10.EglNoContext)
     {
         eglContext = null;
         throw new Exception("Could not create EGL context" + view.GetErrorAsString());
     }
     int[] pbufferAttribList = new int[] { EGL10.EglWidth, 64, EGL10.EglHeight, 64, EGL10.EglNone };
     surface = view.CreatePBufferSurface(view.eglConfig, pbufferAttribList);
     if (surface == EGL10.EglNoSurface)
     {
         throw new Exception("Could not create Pbuffer Surface" + view.GetErrorAsString());
     }
 }