anttooking's picture

GraphicsContext crash

Project:The Open Toolkit library
Version:all versions
Category:bug report

Hello, this is a minor inconveniance and think that it may be a bug ( allthough minor ). It Involves A GraphicsContext class losing its handle to the window (for windows) that it was given through an IWindowInfo. It crashes with Error six unless a reference to the IWindowInfo is kept. I thought I would report it as it took me an hour to realise what was going on.

The method wich crashes is SwapBuffers().

Here is a trace when the IWindowInfo reference is not kept:

at OpenTK.Platform.Windows.WinGLContext.SwapBuffers()
at OpenTK.Graphics.GraphicsContext.SwapBuffers()
at Ant.Core.Window.SwapBuffers() in C:\Users\Ant\AppData\Local\Temporary Projects\AntEngine\Core\Window.cs:line 64
at Ant.main.Main(String[] args) in C:\Users\Ant\AppData\Local\Temporary Projects\AntEngine\main.cs:line 27
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

An example of what my class looked like:

class Window
        GraphicsContext graphicsContext;
        WindowForm windowForm;
        // If this is not kept then the application will crash after a few seconds.
        IWindowInfo info;
        public Window()
            //Create the form:
            windowForm = new WindowForm();
            ///Create a window graphics context:
            info = Utilities.CreateWindowsWindowInfo(windowForm.Handle);
            graphicsContext = new GraphicsContext(
                new GraphicsMode(),