Dispose() public method

Disposes of the GameWindow, releasing all resources consumed by it.
public Dispose ( ) : void
return void
Beispiel #1
3
        public static void Main()
        {
            // Create static (global) window instance
            Window = new OpenTK.GameWindow();

            // Hook up the initialize callback
            Window.Load += new EventHandler<EventArgs>(Initialize);
            // Hook up the update callback
            Window.UpdateFrame += new EventHandler<FrameEventArgs>(Update);
            // Hook up the render callback
            Window.RenderFrame += new EventHandler<FrameEventArgs>(Render);
            // Hook up the shutdown callback
            Window.Unload += new EventHandler<EventArgs>(Shutdown);

            // Set window title and size
            Window.Title = "Game Name";
            Window.ClientSize = new Size(30*8, 30*6);
            Window.VSync = VSyncMode.On;
            // Run the game at 60 frames per second. This method will NOT return
            // until the window is closed.
            Window.Run(60.0f);

            // If we made it down here the window was closed. Call the windows
            // Dispose method to free any resources that the window might hold
            Window.Dispose();

            #if DEBUG
            Console.WriteLine("\nFinished executing, press any key to exit...");
            Console.ReadKey();
            #endif
        }
        public static void Main()
        {
            //create static(global) window instance
            Window = new OpenTK.GameWindow();

            //hook up the initialize callback
            Window.Load += new EventHandler<EventArgs>(Initialize);
            //hook up the update callback
            Window.UpdateFrame += new EventHandler<FrameEventArgs>(Update);
            //hook up render callback
            Window.RenderFrame += new EventHandler<FrameEventArgs>(Render);
            //hook up shutdown callback
            Window.Unload += new EventHandler<EventArgs>(Shutdown);
            Window.VSync = VSyncMode.On;

            //set window title and size
            Window.Title = "Game Name";
            Window.ClientSize = new Size(800, 600);
            //run game at 60fps. will not return until window is closed
            Window.Run(60.0f);

            Window.Dispose();
            #if DEBUG
            Console.ReadLine();
            #endif
        }
Beispiel #3
0
        public static void Main()
        {
            //create static(global) window instance
            Window = new OpenTK.GameWindow();

            //hook up the initialize callback
            Window.Load += new EventHandler <EventArgs>(Initialize);
            //hook up the update callback
            Window.UpdateFrame += new EventHandler <FrameEventArgs>(Update);
            //hook up render callback
            Window.RenderFrame += new EventHandler <FrameEventArgs>(Render);
            //hook up shutdown callback
            Window.Unload += new EventHandler <EventArgs>(Shutdown);
            Window.VSync   = VSyncMode.On;

            //set window title and size
            Window.Title      = "Game Name";
            Window.ClientSize = new Size(800, 600);
            //run game at 60fps. will not return until window is closed
            Window.Run(60.0f);

            Window.Dispose();
#if DEBUG
            Console.ReadLine();
#endif
        }
        public override void shutdown()
        {
            base.shutdown();

            _window.Close();
            _window.Dispose();
        }
Beispiel #5
0
 public void Dispose()
 {
     if (Threading.BackgroundContext != null)
     {
         Threading.BackgroundContext.Dispose();
         Threading.BackgroundContext = null;
         Threading.WindowInfo        = null;
     }
     window.Dispose();
 }
Beispiel #6
0
 //entry point of application, not overwritten
 public virtual void Main(string[] args)
 {
     Window              = new OpenTK.GameWindow();
     Window.Load        += new EventHandler <EventArgs>(OpenTKInitialize);
     Window.UpdateFrame += new EventHandler <FrameEventArgs>(OpenTKUpdate);
     Window.RenderFrame += new EventHandler <FrameEventArgs>(OpenTKRender);
     Window.Unload      += new EventHandler <EventArgs>(OpenTKShutdown);
     Window.Title        = "Sample Application";
     Window.ClientSize   = new System.Drawing.Size(800, 600);
     Instance.Resize(800, 600);
     Window.VSync = VSyncMode.On;
     Window.Run(60.0f);
     Window.Dispose();
 }
Beispiel #7
0
 static void Main(string[] args)
 {
     Window = new OpenTK.GameWindow();
     Window.Title = "Items";
     Window.Load += new EventHandler<EventArgs>(Initialize);
     Window.UpdateFrame += new EventHandler<FrameEventArgs>(Update);
     Window.RenderFrame += new EventHandler<FrameEventArgs>(Render);
     Window.Unload += new EventHandler<EventArgs>(Shutdown);
     Window.Run(60.0);
     Window.Dispose();
     #if DEBUG
     Console.WriteLine("\nFinished executing, press any key to exit...");
     Console.ReadKey();
     #endif
 }
Beispiel #8
0
        static void Main(string[] args)
        {
            Window              = new OpenTK.GameWindow();
            Window.Title        = "RayCaster";
            Window.ClientSize   = new System.Drawing.Size(800, 600);
            Window.Load        += new EventHandler <EventArgs>(Initialize);
            Window.UpdateFrame += new EventHandler <FrameEventArgs>(Update);
            Window.RenderFrame += new EventHandler <FrameEventArgs>(Render);
            Window.Unload      += new EventHandler <EventArgs>(Shutdown);
            Window.Run(60.0f);
            Window.Dispose();
#if DEBUG
            Console.WriteLine("\nFinished executing, press any key to exit...");
            Console.ReadKey();
#endif
        }
Beispiel #9
0
        public Window(int Width, int Height, string Title, bool UseOGLThree = false)
        {
            var tempWindowForContext = new GameWindow(100, 100) { Visible = false };
            GL.GetFloat(GetPName.MajorVersion, out major);
            GL.GetFloat(GetPName.MinorVersion, out minor);
            tempWindowForContext.Dispose();

            Firefly.LatestAvailableVersion = (int)major * 10 + (int)minor;

            GameWindow = new GameWindow(Width, Height,
                new GraphicsMode(new ColorFormat(8, 8, 8, 8),//RGBA
                    8, 8, 8),//Depth, stencil, samples
                Title,
                GameWindowFlags.Default,//Fullscreen/windowed
                DisplayDevice.Default, //Monitor
                UseOGLThree ? 3 : 2, UseOGLThree ? 0 : 0, UseOGLThree ? GraphicsContextFlags.ForwardCompatible : GraphicsContextFlags.Default);//OGL version
            GameWindow.VSync = VSyncMode.Off;
        }
Beispiel #10
0
        public static void Main(string[] args) {
            //create new window
            Window = new MainGameWindow();
            Axiis = new Grid();
            TheGame = new CameraExample();
            TheGame.Resize(Window.Width, Window.Height);
            Window.Load += new EventHandler<EventArgs>(Initialize);
            Window.UpdateFrame += new EventHandler<FrameEventArgs>(Update);
            Window.RenderFrame += new EventHandler<FrameEventArgs>(Render);
            Window.Unload += new EventHandler<EventArgs>(Shutdown);

            Window.Title = "Game Name";
            Window.ClientSize = new System.Drawing.Size(800, 600);
            Window.VSync = VSyncMode.On;
            //run 60fps
            Window.Run(60.0f);

            //Dispose at end
            Window.Dispose();
        }
Beispiel #11
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    // Dispose/release managed objects
                    window.Dispose();
                }

                // Release native resources
                if (Threading.BackgroundContext != null)
                {
                    Threading.BackgroundContext.Dispose();
                    Threading.BackgroundContext = null;
                    Threading.WindowInfo        = null;
                }

                disposed = true;
            }
        }
Beispiel #12
0
        public static void Main(string[] args)
        {
            //create new window
            Window  = new MainGameWindow();
            Axiis   = new Grid();
            TheGame = new CameraExample();
            TheGame.Resize(Window.Width, Window.Height);
            Window.Load        += new EventHandler <EventArgs>(Initialize);
            Window.UpdateFrame += new EventHandler <FrameEventArgs>(Update);
            Window.RenderFrame += new EventHandler <FrameEventArgs>(Render);
            Window.Unload      += new EventHandler <EventArgs>(Shutdown);

            Window.Title      = "Game Name";
            Window.ClientSize = new System.Drawing.Size(800, 600);
            Window.VSync      = VSyncMode.On;
            //run 60fps
            Window.Run(60.0f);

            //Dispose at end
            Window.Dispose();
        }
Beispiel #13
0
 public void Dispose()
 {
     window.Dispose();
 }
Beispiel #14
0
 internal void Dispose()
 {
     OpenTkGameWindow.Dispose();
 }
Beispiel #15
0
        public CAdapter()
        {
            var tempWindow = new GameWindow();
            GraphicsMode bestMode = tempWindow.Context.GraphicsMode;
            var tempContext = new Context(tempWindow.Context);
            var implementation = tempContext.Implementation;
            apiVersion = new ApiVersion((byte)implementation.MajorVersion, (byte)implementation.MinorVersion);
            restrictions = new AdapterRestrictions
            {
                UniformBufferSlots = tempContext.Implementation.MaxUniformBufferBindings,
                SamplerSlots = tempContext.Implementation.MaxCombinedTextureImageUnits, // todo Make those separate
                ShaderResourceSlots = tempContext.Implementation.MaxCombinedTextureImageUnits,
                UnorderedAccessResourceSlots = 0, // todo Set it
                MaxVertexStreams = tempContext.Implementation.MaxVertexAttributes,
                MaxVertexStreamElementCount = 16, // todo: set it
                MaxStreamOutputTargets = tempContext.Implementation.MaxTransformFeedbackSeparateComponents, // todo: make sure
                MaxViewports = tempContext.Implementation.MaxViewports,
                MaxRenderTargets = tempContext.Implementation.MaxColorAttachments,
                MaxThreadGroupsX = 0, // todo: set it,
                MaxThreadGroupsY = 0, // todo: set it,
                MaxThreadGroupsZ = 0,  // todo: set it
                MaxThreadGroupsTotal = 0
            };

            adapterDesc = new AdapterDescription
            {
                Description = GL.GetString(StringName.Renderer),
                VendorId = 0,
                DeviceId = 0,
                SubSysId = 0,
                Revision = 0,
                DedicatedVideoMemory = 0,
                DedicatedSystemMemory = 0,
                SharedSystemMemory = 0,
                AdapterLuidHigh = 0,
                AdapterLuidLow = 0,
                Flags = AdapterFlags.None
            };

            tempWindow.Dispose();

            outputs = GetAvailableDisplays().Select((d, i) => new COutput(d, i)).ToArray();

            //foreach (var format in DisplayColorFormats)
            //{
            //    var expectedColorFormat = CtObjectGL.ColorFormat(format);
            //
            //    tempWindow = new GameWindow(1, 1, new GraphicsMode(expectedColorFormat, bestMode.Depth, bestMode.Stencil));
            //    var actualColorFormat = tempWindow.Context.GraphicsMode.ColorFormat;
            //    tempWindow.Dispose();
            //
            //    if (expectedColorFormat.Red == actualColorFormat.Red &&
            //        expectedColorFormat.Green == actualColorFormat.Green &&
            //        expectedColorFormat.Blue == actualColorFormat.Blue &&
            //        expectedColorFormat.Alpha == actualColorFormat.Alpha)
            //    {
            //        supportedDisplayFormats.Add(format);
            //    }
            //}
        }
Beispiel #16
0
        public void Run()
        {
            _gameWindow = new GameWindow(1280, 720);

            try
            {
                _gameWindow.Title = "CubeHack";
                _gameWindow.VSync = VSyncMode.On;

                /* This sequence seems necessary to bring the window to the front reliably. */
                _gameWindow.WindowState = WindowState.Maximized;
                _gameWindow.WindowState = WindowState.Minimized;
                _gameWindow.Visible = true;
                _gameWindow.WindowState = WindowState.Maximized;

                _gameWindow.KeyDown += OnKeyDown;
                _gameWindow.KeyPress += OnKeyPress;
                _gameWindow.KeyUp += OnKeyUp;

                _gameLoop.RenderFrame += RenderFrame;
                try
                {
                    _gameLoop.Run(_gameWindow);
                }
                finally
                {
                    _gameLoop.RenderFrame -= RenderFrame;
                }
            }
            finally
            {
                _gameWindow.Dispose();
                _gameWindow = null;
            }
        }