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); }
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; }
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); }
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); }
extern static CGLErrorCode CGLChoosePixelFormat (CGLPixelFormatAttribute[] attributes, IntPtr pix, IntPtr npix);
public CGLPixelFormat(CGLPixelFormatAttribute[] attributes, out int npix) { Initialize (attributes, out npix); }
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; }
static extern CGLErrorCode CGLChoosePixelFormat(CGLPixelFormatAttribute[] attributes, out IntPtr /* CGLPixelFormatObj* */ pix, out int /* GLint* */ npix);
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; }