Ejemplo n.º 1
0
/*
		public void CreatePixmapSurface (EGLConfig config)
		{
			Surface = egl.EglCreatePixmapSurface (Display, config, null ,null);
			if (Surface == null || Surface == EGL10.EglNoSurface)
				throw EglException.GenerateException ("EglCreatePixmapSurface", egl, null);
		}
*/
		public void DestroySurface ()
		{
			if (eglSurface != EGL10.EglNoSurface) {
				IEGL10 egl = EGLContext.EGL.JavaCast<IEGL10> ();
				try	{
					egl.EglMakeCurrent (eglDisplay, EGL10.EglNoSurface, EGL10.EglNoSurface, EGL10.EglNoContext);
					if (!egl.EglDestroySurface (eglDisplay, eglSurface))
						Log.Warn ("AndroidWindow", "Failed to destroy surface {0}.", eglSurface);
				}
				catch (Java.Lang.IllegalArgumentException)	{
					Log.Warn ("AndroidWindow", "Failed to destroy surface {0}. Illegal Argument", eglSurface);
				}
				eglSurface = null;
			}
		}
Ejemplo n.º 2
0
		public EGLConfig GetConfigFromDrawable( EGLSurface drawable, int width, int height )
		{
#warning CAN NOT CAST EGLCONFIG > INT[], how's that possible? :S
			throw new NotSupportedException();
			//EGLConfig glConfig = null;
			//if (!EGLCONTEXT.EGL11.EglQuerySurface(_glDisplay, drawable, Javax.Microedition.Khronos.Egl.EGL10Consts.EglConfigId, null))
			//{
			//    throw new AxiomException("Fail to get config from drawable");
			//}
			//EGLCONTEXT.EGL11.EglQuerySurface(_glDisplay, drawable, Javax.Microedition.Khronos.Egl.EGL10Consts.EglWidth, new int[] { width });
			//EGLCONTEXT.EGL11.EglQuerySurface(_glDisplay, drawable, Javax.Microedition.Khronos.Egl.EGL10Consts.EglHeight, new int[] { height });

			//return glConfig;
		}
Ejemplo n.º 3
0
		public void CreatePBufferSurface (EGLConfig config)
		{
			eglSurface = CreatePBufferSurface (config, null);
		}
Ejemplo n.º 4
0
		public void CreateSurface (EGLConfig config)
		{
			if (refHolder == null) {
				CreatePBufferSurface (config);
				return;
			}

			IEGL10 egl = EGLContext.EGL.JavaCast<IEGL10> ();
			eglSurface = egl.EglCreateWindowSurface (eglDisplay, config, ((Java.Lang.Object)Holder), null);
			if (eglSurface == null || eglSurface == EGL10.EglNoSurface)
				throw EglException.GenerateException ("EglCreateWindowSurface", egl, null);
		}
Ejemplo n.º 5
0
		void Init (GraphicsMode mode, IWindowInfo win, IGraphicsContext sharedContext,
										int major, int minor, GraphicsContextFlags flags)
		{
			window = win as AndroidWindow;
			if (window == null)
				throw new ArgumentException ("win");

			AndroidGraphicsContext shared = sharedContext as AndroidGraphicsContext;

			egl = EGLContext.EGL.JavaCast<IEGL10> ();

			window.InitializeDisplay ();

			if (mode == null)
				mode = new GraphicsMode ();

			if (mode is AndroidGraphicsMode) {
				GraphicsMode = mode;
			} else {
				GraphicsMode = new AndroidGraphicsMode (window.Display, major, mode);
			}

			if (shared != null && !PBufferSupported)
				throw new EglException ("Multiple Context's are not supported by this device");

			if (Mode.Config == null)
				Mode.Initialize (window.Display, major);

			/*
			 * Create an OpenGL ES context. We want to do this as rarely as possible, an
			 * OpenGL context is a somewhat heavy object.
			 */
			int EglContextClientVersion = 0x3098;
			int EglContextMinorVersion = 0x30fb;
			int[] attribList = null;
			if (major >= 2) {
				string extensions = egl.EglQueryString (window.Display, Egl.Egl.EXTENSIONS);
				if (minor > 0 && !string.IsNullOrEmpty (extensions) && extensions.Contains ("EGL_KHR_create_context")) {
					attribList = new int [] { EglContextClientVersion, major,
						EglContextMinorVersion, minor,
						EGL10.EglNone
					};
				} else {
					attribList = new int [] { EglContextClientVersion, major,
						EGL10.EglNone
					};
				}
			}

			EGLContext = egl.EglCreateContext (window.Display,
						EGLConfig,
						shared != null && shared.EGLContext != null ? shared.EGLContext : EGL10.EglNoContext,
						attribList);

			if (EGLContext == EGL10.EglNoContext)
				throw EglException.GenerateException ("EglCreateContext == EGL10.EglNoContext", egl, null);

			if (shared != null && shared.EGLContext != null) {
				egl.EglMakeCurrent (window.Display, EGL10.EglNoSurface, EGL10.EglNoSurface, EGL10.EglNoContext);
				int[] pbufferAttribList = new int [] { EGL10.EglWidth, 64, EGL10.EglHeight, 64, EGL10.EglNone };
				surface = window.CreatePBufferSurface (EGLConfig, pbufferAttribList);
				if (surface == EGL10.EglNoSurface)
					throw new EglException ("Could not create PBuffer for shared context!");
			}
		}
Ejemplo n.º 6
0
        private void DestroySurfaceHelper()
        {
            // Assumes lockObject is locked

            if(!(eglSurface == null || eglSurface == EGL10Consts.EglNoSurface))
            {
                if(!egl.EglMakeCurrent(eglDisplay, EGL10Consts.EglNoSurface,
                            EGL10Consts.EglNoSurface, EGL10Consts.EglNoContext))
                    throw new ExEnSurfaceException(AddEGLError("Could not unbind EGL surface"));

                if(!egl.EglDestroySurface(eglDisplay, eglSurface))
                    throw new ExEnSurfaceException(AddEGLError("Could not destroy EGL surface"));
            }

            eglSurface = null;
        }
Ejemplo n.º 7
0
        private void CreateEGLSurface()
        {
            // Assumes lockObject is locked

            ExEnLog.WriteLine("ExEnAndroidSurfaceView.CreateEGLSurface Begin");

            // If there is an existing surface, destroy the old one
            DestroySurfaceHelper();

            eglSurface = egl.EglCreateWindowSurface(eglDisplay, eglConfig, (Java.Lang.Object)this.Holder, null);
            if(eglSurface == null || eglSurface == EGL10Consts.EglNoSurface)
                throw new ExEnSurfaceException(AddEGLError("Could not create EGL window surface"));

            if(!egl.EglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext))
                throw new ExEnSurfaceException(AddEGLError("Could not make EGL current"));

            eglSurfaceAvailable = true;

            if(gdm != null)
                gdm.InternalDeviceReady(this, surfaceWidth, surfaceHeight, orientation);

            ExEnLog.WriteLine("ExEnAndroidSurfaceView.CreateEGLSurface End");
        }