コード例 #1
0
        public CGLPixelFormat(CGLPixelFormatAttribute[] attributes, out int npix)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException("attributes");
            }
            var pixelFormatOut = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));
            var npixOut        = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));
            var marshalAttribs = new CGLPixelFormatAttribute [attributes.Length + 1];

            Array.Copy(attributes, marshalAttribs, attributes.Length);

            CGLErrorCode ret = CGLChoosePixelFormat(marshalAttribs, pixelFormatOut, npixOut);

            if (ret != CGLErrorCode.NoError)
            {
                Marshal.FreeHGlobal(pixelFormatOut);
                Marshal.FreeHGlobal(npixOut);
                throw new Exception("CGLChoosePixelFormat returned: " + ret);
            }

            this.handle = Marshal.ReadIntPtr(pixelFormatOut);
            npix        = Marshal.ReadInt32(npixOut);
            Marshal.FreeHGlobal(pixelFormatOut);
            Marshal.FreeHGlobal(npixOut);
        }
コード例 #2
0
        void Initialize(CGLPixelFormatAttribute[] attributes, out int npix)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException("attributes");
            }
            IntPtr pixelFormatOut;
            var    marshalAttribs = new CGLPixelFormatAttribute [attributes.Length + 1];

            Array.Copy(attributes, marshalAttribs, attributes.Length);

            CGLErrorCode ret = CGLChoosePixelFormat(marshalAttribs, out pixelFormatOut, out npix);

            if (ret != CGLErrorCode.NoError)
            {
                throw new Exception("CGLChoosePixelFormat returned: " + ret);
            }

            this.handle = pixelFormatOut;
        }
コード例 #3
0
        static IntPtr Create(CGLPixelFormatAttribute[] attributes, out int npix)
        {
            if (attributes is null)
            {
                throw new ArgumentNullException(nameof(attributes));
            }
            IntPtr pixelFormatOut;
            var    marshalAttribs = new CGLPixelFormatAttribute [attributes.Length + 1];

            Array.Copy(attributes, marshalAttribs, attributes.Length);

            CGLErrorCode ret = CGLChoosePixelFormat(marshalAttribs, out pixelFormatOut, out npix);

            if (ret != CGLErrorCode.NoError)
            {
                throw new Exception("CGLChoosePixelFormat returned: " + ret);
            }

            return(pixelFormatOut);
        }
コード例 #4
0
		public CGLPixelFormat (CGLPixelFormatAttribute[] attributes, out int npix)
		{
			if (attributes == null)
				throw new ArgumentNullException ("attributes");
			var pixelFormatOut = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (IntPtr)));
			var npixOut = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (IntPtr)));
			var marshalAttribs = new CGLPixelFormatAttribute [attributes.Length + 1];

			Array.Copy (attributes, marshalAttribs, attributes.Length);

			CGLErrorCode ret = CGLChoosePixelFormat (marshalAttribs, pixelFormatOut, npixOut);

			if (ret != CGLErrorCode.NoError) {
				Marshal.FreeHGlobal (pixelFormatOut);
				Marshal.FreeHGlobal (npixOut);
				throw new Exception ("CGLChoosePixelFormat returned: " + ret);
			}

			this.handle = Marshal.ReadIntPtr (pixelFormatOut);
			npix = Marshal.ReadInt32 (npixOut);
			Marshal.FreeHGlobal (pixelFormatOut);
			Marshal.FreeHGlobal (npixOut);
		}
コード例 #5
0
		extern static CGLErrorCode CGLChoosePixelFormat (CGLPixelFormatAttribute[] attributes, IntPtr pix, IntPtr npix);
コード例 #6
0
 public CGLPixelFormat(CGLPixelFormatAttribute[] attributes, out int npix)
 {
     Initialize (attributes, out npix);
 }
コード例 #7
0
        void Initialize(CGLPixelFormatAttribute[] attributes, out int npix)
        {
            if (attributes == null)
                throw new ArgumentNullException ("attributes");
            IntPtr pixelFormatOut;
            var marshalAttribs = new CGLPixelFormatAttribute [attributes.Length + 1];

            Array.Copy (attributes, marshalAttribs, attributes.Length);

            CGLErrorCode ret = CGLChoosePixelFormat (marshalAttribs, out pixelFormatOut, out npix);

            if (ret != CGLErrorCode.NoError) {
                throw new Exception ("CGLChoosePixelFormat returned: " + ret);
            }

            this.handle = pixelFormatOut;
        }
コード例 #8
0
 static extern CGLErrorCode CGLChoosePixelFormat(CGLPixelFormatAttribute[] attributes, out IntPtr /* CGLPixelFormatObj* */ pix, out int /* GLint* */ npix);
コード例 #9
0
ファイル: OpenGLLayer.cs プロジェクト: kangaroo/monomac
                public override CGLPixelFormat CopyCGLPixelFormatForDisplayMask (uint mask)
                {
                        
                        // make sure to add a null value
                        CGLPixelFormatAttribute[] attribs = new CGLPixelFormatAttribute[] { 
							CGLPixelFormatAttribute.Accelerated, 
							CGLPixelFormatAttribute.DoubleBuffer, CGLPixelFormatAttribute.ColorSize, (CGLPixelFormatAttribute)24, CGLPixelFormatAttribute.DepthSize, (CGLPixelFormatAttribute)16 };
                        
                        int numPixs = -1;
                        CGLPixelFormat pixelFormat = new CGLPixelFormat (attribs, out numPixs);
                        return pixelFormat;
                }