Inheritance: IGraphicsMode
Example #1
0
        void CreateContext(GraphicsMode mode, CarbonWindowInfo carbonWindow, IntPtr shareContextRef, bool fullscreen)
        {
            Debug.Print("AGL pixel format attributes:");

            AGLPixelFormat myAGLPixelFormat;

            // Choose a pixel format with the attributes we specified.
            IntPtr gdevice;
            IntPtr cgdevice = GetQuartzDevice(carbonWindow);

            if (cgdevice == IntPtr.Zero)
            {
                cgdevice = (IntPtr)DisplayDevice.Default.Id;
            }

            OSStatus status = Carbon.API.DMGetGDeviceByDisplayID(cgdevice, out gdevice, false);

            if (status != OSStatus.NoError)
            {
                throw new MacOSException(status, "DMGetGDeviceByDisplayID failed.");
            }

            IGraphicsMode selector = new MacOSGraphicsMode(gdevice);

            Mode = selector.SelectGraphicsMode(
                mode.ColorFormat, mode.Depth, mode.Stencil, mode.Samples,
                mode.AccumulatorFormat, mode.Buffers, mode.Stereo);
            MyAGLReportError("aglChoosePixelFormat");

            Debug.Print("Creating AGL context.  Sharing with {0}", shareContextRef);
            myAGLPixelFormat = Mode.Index.Value;

            // create the context and share it with the share reference.
            Handle = new ContextHandle(Agl.aglCreateContext(myAGLPixelFormat, shareContextRef));
            MyAGLReportError("aglCreateContext");

            // Free the pixel format from memory.
            Agl.aglDestroyPixelFormat(myAGLPixelFormat);
            MyAGLReportError("aglDestroyPixelFormat");

            Debug.Print("IsControl: {0}", carbonWindow.IsControl);

            SetDrawable(carbonWindow);
            SetBufferRect(carbonWindow);
            Update(carbonWindow);

            MakeCurrent(carbonWindow);
            Debug.Print("context: {0}", Handle.Handle);
        }
Example #2
0
        void CreateContext(GraphicsMode mode, CarbonWindowInfo carbonWindow, IntPtr shareContextRef, bool fullscreen)
        {
            Debug.Print("AGL pixel format attributes:");
            
            AGLPixelFormat myAGLPixelFormat;
            
            // Choose a pixel format with the attributes we specified.
            IntPtr gdevice;
            IntPtr cgdevice = GetQuartzDevice(carbonWindow);
                
            if (cgdevice == IntPtr.Zero)
                cgdevice = (IntPtr)DisplayDevice.Default.Id;
                
            OSStatus status = Carbon.API.DMGetGDeviceByDisplayID(cgdevice, out gdevice, false);
                
            if (status != OSStatus.NoError)
                throw new MacOSException(status, "DMGetGDeviceByDisplayID failed.");

            IGraphicsMode selector = new MacOSGraphicsMode(gdevice);
            Mode = selector.SelectGraphicsMode(
                mode.ColorFormat, mode.Depth, mode.Stencil, mode.Samples,
                mode.AccumulatorFormat, mode.Buffers, mode.Stereo);
            MyAGLReportError("aglChoosePixelFormat");

            Debug.Print("Creating AGL context.  Sharing with {0}", shareContextRef);
            myAGLPixelFormat = Mode.Index.Value;

            // create the context and share it with the share reference.
            Handle = new ContextHandle(Agl.aglCreateContext(myAGLPixelFormat, shareContextRef));
            MyAGLReportError("aglCreateContext");

            // Free the pixel format from memory.
            Agl.aglDestroyPixelFormat(myAGLPixelFormat);
            MyAGLReportError("aglDestroyPixelFormat");
            
            Debug.Print("IsControl: {0}", carbonWindow.IsControl);
            
            SetDrawable(carbonWindow);
            SetBufferRect(carbonWindow);
            Update(carbonWindow);
            
            MakeCurrent(carbonWindow);
            Debug.Print("context: {0}", Handle.Handle);
        }