public override void Dispose()
 {
     canvas.Dispose();
     skin.Dispose();
     renderer.Dispose();
     base.Dispose();
 }
Example #2
0
 public static void Dispose()
 {
     if (!disposed)
     {
         canvas.Dispose();
         skin.Dispose();
         renderer.Dispose();
         disposed = true;
     }
 }
Example #3
0
        protected override void OnUnload(EventArgs e)
        {
            gwenCanvas.Dispose();
            gwenSkin.Dispose();
            gwenRenderer.Dispose();

            UnloadLevel();
            UnloadDebugMeshes();

            base.OnUnload(e);
        }
Example #4
0
        private void DisposeUnmanaged()
        {
            //TODO[GL]: 这个对象的 Dispose 内会抛空引用异常,待查
            try
            {
                GwenTextureProvider.Instance.ReleaseAllTextures();

                m_renderContext.Font.Dispose();
                m_canvas.Dispose();
                m_skin.Dispose();
                m_renderer.Dispose();
            }
            catch (NullReferenceException)
            {
            }
        }
Example #5
0
 /// <summary>
 /// UnloadContent will be called once per game and is the place to unload
 /// game-specific content.
 /// </summary>
 protected override void UnloadContent()
 {
     if (canvas != null)
     {
         canvas.Dispose();
         canvas = null;
     }
     if (skin != null)
     {
         skin.Dispose();
         skin = null;
     }
     if (renderer != null)
     {
         renderer.Dispose();
         renderer = null;
     }
 }
Example #6
0
 /// <summary>
 /// UnloadContent will be called once per game and is the place to unload
 /// game-specific content.
 /// </summary>
 protected override void UnloadContent()
 {
     if (m_Canvas != null)
     {
         m_Canvas.Dispose();
         m_Canvas = null;
     }
     if (m_Skin != null)
     {
         m_Skin.Dispose();
         m_Skin = null;
     }
     if (m_Renderer != null)
     {
         m_Renderer.Dispose();
         m_Renderer = null;
     }
 }
Example #7
0
 public override void Dispose()
 {
     if (m_Canvas != null)
     {
         m_Canvas.Dispose();
         m_Canvas = null;
     }
     if (m_Skin != null)
     {
         m_Skin.Dispose();
         m_Skin = null;
     }
     if (m_Renderer != null)
     {
         m_Renderer.Dispose();
         m_Renderer = null;
     }
     base.Dispose();
 }
Example #8
0
        protected override void Dispose(bool disposing)
        {
            if (m_Canvas != null)
            {
                m_Canvas.Dispose();
                m_Canvas = null;
            }
            if (m_Skin != null)
            {
                m_Skin.Dispose();
                m_Skin = null;
            }
            if (m_Renderer != null)
            {
                m_Renderer.Dispose();
                m_Renderer = null;
            }

            base.Dispose();
        }
Example #9
0
        void TearDownGL()
        {
            EAGLContext.SetCurrentContext(context);

            if (m_Canvas != null)
            {
                m_Canvas.Dispose();
                m_Canvas = null;
            }
            if (m_Skin != null)
            {
                m_Skin.Dispose();
                m_Skin = null;
            }
            if (m_Renderer != null)
            {
                m_Renderer.Dispose();
                m_Renderer = null;
            }
        }
Example #10
0
        public void DestroyCanvas(Canvas canvas)
        {
            if (Canvas == canvas)
                SetCanvas (null);

            canvas.Dispose ();
        }
 protected override void UnloadContent()
 {
     canvas.Dispose();
     skin.Dispose();
     renderer.Dispose();
 }
Example #12
0
        static void Main()
        {
            //try
            {
                const int width = 1024;
                const int height = 768;

                // Create main window
                m_Window = new RenderWindow(new VideoMode(width, height), "GWEN.Net SFML test", Styles.Titlebar|Styles.Close|Styles.Resize, new ContextSettings(32, 0));

                // Setup event handlers
                m_Window.Closed += OnClosed;
                m_Window.KeyPressed += OnKeyPressed;
                m_Window.Resized += OnResized;
                m_Window.KeyReleased += window_KeyReleased;
                m_Window.MouseButtonPressed += window_MouseButtonPressed;
                m_Window.MouseButtonReleased += window_MouseButtonReleased;
                m_Window.MouseWheelMoved += window_MouseWheelMoved;
                m_Window.MouseMoved += window_MouseMoved;
                m_Window.TextEntered += window_TextEntered;

                //m_Window.SetFramerateLimit(60);

                const int fps_frames = 50;
                List<long> ftime = new List<long>(fps_frames);
                long lastTime = 0;

                // create GWEN renderer
                Renderer.SFML gwenRenderer = new Renderer.SFML(m_Window);

                // Create GWEN skin
                //Skin.Simple skin = new Skin.Simple(GwenRenderer);
                Skin.TexturedBase skin = new Skin.TexturedBase(gwenRenderer, "DefaultSkin.png");

                // set default font
                Font defaultFont = new Font(gwenRenderer) {Size = 10, FaceName = "Arial Unicode MS"};
                
                // try to load, fallback if failed
                if (gwenRenderer.LoadFont(defaultFont))
                {
                    gwenRenderer.FreeFont(defaultFont);
                }
                else // try another
                {
                    defaultFont.FaceName = "Arial";
                    if (gwenRenderer.LoadFont(defaultFont))
                    {
                        gwenRenderer.FreeFont(defaultFont);
                    }
                    else // try default
                    {
                        defaultFont.FaceName = "OpenSans.ttf";
                    }
                }

                skin.SetDefaultFont(defaultFont.FaceName);
                defaultFont.Dispose(); // skin has its own

                // Create a Canvas (it's root, on which all other GWEN controls are created)
                m_Canvas = new Canvas(skin);
                m_Canvas.SetSize(width, height);
                m_Canvas.ShouldDrawBackground = true;
                m_Canvas.BackgroundColor = System.Drawing.Color.FromArgb(255, 150, 170, 170);
                m_Canvas.KeyboardInputEnabled = true;

                // create the unit test control
                m_UnitTest = new UnitTest.UnitTest(m_Canvas);

                // Create GWEN input processor
                m_Input = new Input.SFML();
                m_Input.Initialize(m_Canvas, m_Window);

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                while (m_Window.IsOpen())
                {
                    m_Window.SetActive();
                    m_Window.DispatchEvents();
                    m_Window.Clear();

                    // Clear depth buffer
                    Gl.glClear(Gl.GL_DEPTH_BUFFER_BIT | Gl.GL_COLOR_BUFFER_BIT);

                    if (ftime.Count == fps_frames)
                        ftime.RemoveAt(0);

                    ftime.Add(stopwatch.ElapsedMilliseconds - lastTime);
                    lastTime = stopwatch.ElapsedMilliseconds;

                    if (stopwatch.ElapsedMilliseconds > 1000)
                    {
                        m_UnitTest.Fps = 1000f * ftime.Count / ftime.Sum();
                        stopwatch.Restart();
                    }

                    // render GWEN canvas
                    m_Canvas.RenderCanvas();

                    m_Window.Display();
                }

                // we only need to dispose the canvas, it will take care of disposing all its children
                m_Canvas.Dispose();
                
                // also dispose of these
                skin.Dispose();
                gwenRenderer.Dispose();
            }
            //catch (Exception e)
            //{
                //String msg = String.Format("Exception: {0}\n{1}", e.Message, e.StackTrace);
                //MessageBox.Show(msg);
            //}

            m_Window.Dispose();
        }