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
                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;
                }