Example #1
0
        protected override void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                CleanUpTextures();

                if (videoTextureCache != null)
                {
                    videoTextureCache.Flush(CVOptionFlags.None);
                    videoTextureCache.Dispose();
                }

                if (context != null)
                {
                    context.Dispose();
                }
            }

            GL.DeleteFramebuffers(1, ref frameBufferHandle);
            GL.DeleteRenderbuffers(1, ref colorBufferHandle);
            disposed = true;

            base.Dispose(disposing);
        }
Example #2
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            context.Dispose();
            glContext.Dispose();
        }
Example #3
0
 protected virtual void Dispose(bool disposing)
 {
     if (EAGLContext != null)
     {
         EAGLContext.Dispose();
     }
     EAGLContext = null;
 }
Example #4
0
        internal override void Initialize(GameContext gameContext)
        {
            GameContext = gameContext;

            gameForm = gameContext.GameView;
            nativeWindow = new WindowHandle(AppContextType.iOS, gameForm);

            gameForm.Load += gameForm_Load;
            gameForm.Unload += gameForm_Unload;
            gameForm.RenderFrame += gameForm_RenderFrame;
            
            // get the OpenGL ES version
            var contextAvailable = false;
            foreach (var version in OpenGLUtils.GetGLVersions(gameContext.RequestedGraphicsProfile))
            {
                var contextRenderingApi = MajorVersionTOEAGLRenderingAPI(version);
                EAGLContext contextTest = null;
                try
                {
                    contextTest = new EAGLContext(contextRenderingApi);

                    // delete extra context
                    if (contextTest != null)
                        contextTest.Dispose();

                    gameForm.ContextRenderingApi = contextRenderingApi;
                    contextAvailable = true;
                }
                catch (Exception)
                {
                    // TODO: log message
                }
            }

            if (!contextAvailable)
                throw new Exception("Graphics context could not be created.");

            gameForm.LayerColorFormat = MonoTouch.OpenGLES.EAGLColorFormat.RGBA8;
            //gameForm.LayerRetainsBacking = false;

            // Setup the initial size of the window
            var width = gameContext.RequestedWidth;
            if (width == 0)
            {
                width = (int)(gameForm.Size.Width * gameForm.ContentScaleFactor);
            }

            var height = gameContext.RequestedHeight;
            if (height == 0)
            {
                height = (int)(gameForm.Size.Height * gameForm.ContentScaleFactor);
            }

            gameForm.Size = new Size(width, height);

            //gameForm.Resize += OnClientSizeChanged;
        }
Example #5
0
 void DestroyContext()
 {
     EAGLContext.SetCurrentContext(_glContext);
     GL.DeleteRenderbuffers(1, ref _db);
     GL.DeleteRenderbuffers(1, ref _cb);
     GL.DeleteFramebuffers(1, ref _fb);
     _db = _cb = _fb = 0;
     _glContext.Dispose();
     _alContext.Dispose();
 }
Example #6
0
 protected override void Dispose(bool disposing)
 {
     if (IsDisposed)
     {
         return;
     }
     if (EAGLContext != null)
     {
         EAGLContext.Dispose();
     }
     EAGLContext = null;
     IsDisposed  = true;
 }
 protected override void Dispose(bool disposing)
 {
     if (!IsDisposed)
     {
         if (disposing)
         {
             if (EAGLContext != null)
             {
                 EAGLContext.Dispose();
             }
             EAGLContext = null;
         }
         IsDisposed = true;
     }
 }
Example #8
0
        protected override void Initialize(GameContext <iOSWindow> gameContext)
        {
            gameForm     = gameContext.Control.GameView;
            nativeWindow = new WindowHandle(AppContextType.iOS, gameForm, gameForm.Handle);

            gameForm.Load        += gameForm_Load;
            gameForm.Unload      += gameForm_Unload;
            gameForm.RenderFrame += gameForm_RenderFrame;

            // get the OpenGL ES version
            var contextAvailable = false;

            foreach (var version in OpenGLUtils.GetGLVersions(gameContext.RequestedGraphicsProfile))
            {
                var         contextRenderingApi = MajorVersionTOEAGLRenderingAPI(version);
                EAGLContext contextTest         = null;
                try
                {
                    contextTest = new EAGLContext(contextRenderingApi);

                    // delete extra context
                    if (contextTest != null)
                    {
                        contextTest.Dispose();
                    }

                    gameForm.ContextRenderingApi = contextRenderingApi;
                    contextAvailable             = true;
                    break;
                }
                catch (Exception)
                {
                    // TODO: log message
                }
            }

            if (!contextAvailable)
            {
                throw new Exception("Graphics context could not be created.");
            }

            gameForm.LayerColorFormat = EAGLColorFormat.RGBA8;
            //gameForm.LayerRetainsBacking = false;

            currentOrientation = UIApplication.SharedApplication.StatusBarOrientation;
        }
Example #9
0
        internal override void Initialize(GameContext gameContext)
        {
            GameContext = gameContext;

            gameForm = gameContext.GameView;
            nativeWindow = new WindowHandle(AppContextType.iOS, gameForm);

            gameForm.Load += gameForm_Load;
            gameForm.Unload += gameForm_Unload;
            gameForm.RenderFrame += gameForm_RenderFrame;
            
            // get the OpenGL ES version
            var contextAvailable = false;
            foreach (var version in OpenGLUtils.GetGLVersions(gameContext.RequestedGraphicsProfile))
            {
                var contextRenderingApi = MajorVersionTOEAGLRenderingAPI(version);
                EAGLContext contextTest = null;
                try
                {
                    contextTest = new EAGLContext(contextRenderingApi);

                    // delete extra context
                    if (contextTest != null)
                        contextTest.Dispose();

                    gameForm.ContextRenderingApi = contextRenderingApi;
                    contextAvailable = true;
                    break;
                }
                catch (Exception)
                {
                    // TODO: log message
                }
            }

            if (!contextAvailable)
                throw new Exception("Graphics context could not be created.");

            gameForm.LayerColorFormat = EAGLColorFormat.RGBA8;
            //gameForm.LayerRetainsBacking = false;
        }
Example #10
0
 public void Dispose()
 {
     Context?.Dispose();
     Context = null;
 }
Example #11
0
        internal override void Initialize(GameContext gameContext)
        {
            GameContext = gameContext;

            gameForm     = gameContext.GameView;
            nativeWindow = new WindowHandle(AppContextType.iOS, gameForm);

            gameForm.Load        += gameForm_Load;
            gameForm.Unload      += gameForm_Unload;
            gameForm.RenderFrame += gameForm_RenderFrame;

            // get the OpenGL ES version
            var contextAvailable = false;

            foreach (var version in OpenGLUtils.GetGLVersions(gameContext.RequestedGraphicsProfile))
            {
                var         contextRenderingApi = MajorVersionTOEAGLRenderingAPI(version);
                EAGLContext contextTest         = null;
                try
                {
                    contextTest = new EAGLContext(contextRenderingApi);

                    // delete extra context
                    if (contextTest != null)
                    {
                        contextTest.Dispose();
                    }

                    gameForm.ContextRenderingApi = contextRenderingApi;
                    contextAvailable             = true;
                }
                catch (Exception)
                {
                    // TODO: log message
                }
            }

            if (!contextAvailable)
            {
                throw new Exception("Graphics context could not be created.");
            }

            gameForm.LayerColorFormat = MonoTouch.OpenGLES.EAGLColorFormat.RGBA8;
            //gameForm.LayerRetainsBacking = false;

            // Setup the initial size of the window
            var width = gameContext.RequestedWidth;

            if (width == 0)
            {
                width = (int)(gameForm.Size.Width * gameForm.ContentScaleFactor);
            }

            var height = gameContext.RequestedHeight;

            if (height == 0)
            {
                height = (int)(gameForm.Size.Height * gameForm.ContentScaleFactor);
            }

            gameForm.Size = new Size(width, height);

            //gameForm.Resize += OnClientSizeChanged;
        }