Esempio n. 1
0
        void MyAGLReportError(string function)
        {
            Agl.AglError err = Agl.GetError();

            if (err != Agl.AglError.NoError)
            {
                throw new Exception(String.Format(
                                        "AGL Error from function {0}: {1}  {2}",
                                        function, err, Agl.ErrorString(err)));
            }
        }
Esempio n. 2
0
        void Dispose(bool disposing)
        {
            if (IsDisposed || Handle.Handle == IntPtr.Zero)
            {
                return;
            }

            Debug.Print("Disposing of AGL context.");
            Agl.aglSetCurrentContext(IntPtr.Zero);

            //Debug.Print("Setting drawable to null for context {0}.", Handle.Handle);
            //Agl.aglSetDrawable(Handle.Handle, IntPtr.Zero);

            // I do not know MacOS allows us to destroy a context from a separate thread,
            // like the finalizer thread.  It's untested, but worst case is probably
            // an exception on application exit, which would be logged to the console.

            // Actually, it seems to crash the mono runtime. -AMK 2013

            Debug.Print("Destroying context");
            if (Agl.aglDestroyContext(Handle.Handle) == true)
            {
                Debug.Print("Context destruction completed successfully.");
                Handle = ContextHandle.Zero;
                return;
            }

            // failed to destroy context.
            Debug.WriteLine("Failed to destroy context.");
            Debug.WriteLine(Agl.ErrorString(Agl.GetError()));

            // don't throw an exception from the finalizer thread.
            if (disposing)
            {
                throw new Exception(Agl.ErrorString(Agl.GetError()));
            }

            disposed = true;
        }
Esempio n. 3
0
        public GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil,
                                               int samples, ColorFormat accum, int buffers, bool stereo, out IntPtr pixelformat)
        {
            do
            {
                pixelformat = SelectPixelFormat(
                    color, depth, stencil, samples, accum, buffers, stereo);

                if (pixelformat == IntPtr.Zero)
                {
                    if (!RelaxGraphicsMode(
                            ref color, ref depth, ref stencil, ref samples, ref accum,
                            ref buffers, ref stereo))
                    {
                        throw new GraphicsModeException("Requested GraphicsMode not available, error: " + Agl.GetError());
                    }
                }
            }while (pixelformat == IntPtr.Zero);

            return(GetGraphicsModeFromPixelFormat(pixelformat));
        }