Exemplo n.º 1
0
        protected override void Dispose(bool disposing)
        {
            // Try to bind the OpenGL context before calling the shutdown event
            try
            {
                _openGLContext?.MakeCurrent(_nativeWindow);
            }
            catch (Exception) { }

            Device.DisposeGpu();
            NpadManager.Dispose();

            // Unbind context and destroy everything
            try
            {
                _openGLContext?.MakeCurrent(null);
            }
            catch (Exception) { }

            _openGLContext.Dispose();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            NativeWindowBase window = PlatformHelper.CreateWindow(FramebufferFormat.Default, 0, 0, 250, 250);

            OpenGLContextBase context = PlatformHelper.CreateOpenGLContext(FramebufferFormat.Default, 3, 3, OpenGLContextFlags.Compat);

            context.Initialize(window);
            context.MakeCurrent(window);

            GL.LoadBindings(new OpenToolkitBindingsContext(context));

            window.Show();

            GL.ClearColor(1.0f, 0.5f, 1.0f, 1.0f);
            GL.Clear(ClearBufferMask.ColorBufferBit);

            window.SwapBuffers();

            Console.WriteLine($"OpenGL vendor: {GL.GetString(StringName.Vendor)}");
            Console.WriteLine($"OpenGL version: {GL.GetString(StringName.Version)}");
            Console.WriteLine($"OpenGL renderer: {GL.GetString(StringName.Renderer)}");
            Console.WriteLine($"OpenGL context profile mask: {GL.GetInteger((GetPName)All.ContextProfileMask)}");
            Console.WriteLine($"OpenGL context flags: {GL.GetInteger((GetPName)All.ContextFlags)}");

            Thread.Sleep(2000);

            window.Dispose();

            Console.WriteLine($"Dispose OpenGL context!");
            context.Dispose();

            string vendor2 = GL.GetString(StringName.Vendor);

            Console.WriteLine($"OpenGL vendor: {vendor2}");

            window.Dispose();
        }
Exemplo n.º 3
0
 public void Dispose()
 {
     _context.Dispose();
     _window.Dispose();
 }