예제 #1
0
            public BackgroundContext(MonoGameAndroidGameView view)
            {
                _view = view ?? throw new ArgumentNullException(nameof(view));

                foreach (var v in OpenGL.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());
                }

                var 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());
                }
            }
        private void Initialize(Context context, Point size)
        {
            _clientBounds = new Rectangle(0, 0, size.X, size.Y);

            GameView = new MonoGameAndroidGameView(context, this, _game);
            GameView.RenderOnUIThread = AndroidGameActivity.Instance.RenderOnUIThread;
            GameView.RenderFrame     += OnRenderFrame;
            GameView.UpdateFrame     += OnUpdateFrame;

            GameView.RequestFocus();
            GameView.FocusableInTouchMode = true;
        }