Ejemplo n.º 1
0
        public NSOpenGLPixelFormat(params object [] attribs)
            : this(ConvertToAttributes (attribs))
        {
            if (attribs == null)
                throw new ArgumentNullException ("attribs");

            unsafe {
                var copy = new NSOpenGLPixelFormatAttribute [attribs.Length + 1 /* null termination */];
                for (int i = 0; i < attribs.Length; i++) {
                    var input = attribs [i];
                    if (input is NSOpenGLPixelFormatAttribute) {
                        copy [i] = (NSOpenGLPixelFormatAttribute) input;
                    } else {
                        copy [i] = (NSOpenGLPixelFormatAttribute) (int) input;
                    }
                }

                fixed (NSOpenGLPixelFormatAttribute* pArray = copy){
                    if (IsDirectBinding) {
                        Handle = XamCore.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr (this.Handle, selInitWithAttributes, new IntPtr((void*)pArray ));
                    } else {
                        Handle = XamCore.ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper_IntPtr (this.SuperHandle, selInitWithAttributes, new IntPtr((void*)pArray));
                    }
                }

            }
        }
Ejemplo n.º 2
0
        private void AddPixelAttrib(List <NSOpenGLPixelFormatAttribute> attributes, NSOpenGLPixelFormatAttribute attribute, int value)
        {
            Debug.Print("{0} : {1}", attribute, value);

            attributes.Add(attribute);
            attributes.Add((NSOpenGLPixelFormatAttribute)value);
        }
        public NSOpenGLPixelFormat(params object [] attribs) : this(ConvertToAttributes(attribs))
        {
            if (attribs == null)
            {
                throw new ArgumentNullException("attribs");
            }

            unsafe {
                var copy = new NSOpenGLPixelFormatAttribute [attribs.Length + 1 /* null termination */];
                for (int i = 0; i < attribs.Length; i++)
                {
                    var input = attribs [i];
                    if (input is NSOpenGLPixelFormatAttribute)
                    {
                        copy [i] = (NSOpenGLPixelFormatAttribute)input;
                    }
                    else
                    {
                        copy [i] = (NSOpenGLPixelFormatAttribute)(int)input;
                    }
                }

                fixed(NSOpenGLPixelFormatAttribute *pArray = copy)
                {
                    if (IsDirectBinding)
                    {
                        Handle = XamCore.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr(this.Handle, selInitWithAttributes, new IntPtr((void *)pArray));
                    }
                    else
                    {
                        Handle = XamCore.ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper_IntPtr(this.SuperHandle, selInitWithAttributes, new IntPtr((void *)pArray));
                    }
                }
            }
        }
        public NSOpenGLPixelFormat(NSOpenGLPixelFormatAttribute[] attribs) : base(NSObjectFlag.Empty)
        {
            if (attribs == null)
            {
                throw new ArgumentNullException("attribs");
            }

            unsafe
            {
                NSOpenGLPixelFormatAttribute [] copy = new NSOpenGLPixelFormatAttribute [attribs.Length + 1];
                Array.Copy(attribs, 0, copy, 0, attribs.Length);

                fixed(NSOpenGLPixelFormatAttribute *pArray = copy)
                {
                    if (IsDirectBinding)
                    {
                        Handle = MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr(this.Handle, selInitWithAttributes, new IntPtr((void *)pArray));
                    }
                    else
                    {
                        Handle = MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper_IntPtr(this.SuperHandle, selInitWithAttributes, new IntPtr((void *)pArray));
                    }
                }
            }
        }
Ejemplo n.º 5
0
		public NSOpenGLPixelFormat (NSOpenGLPixelFormatAttribute[] attribs) : base (NSObjectFlag.Empty)
		{
			if (attribs == null)
				throw new ArgumentNullException ("attribs");

			unsafe {
				NSOpenGLPixelFormatAttribute [] copy = new NSOpenGLPixelFormatAttribute [attribs.Length+1];
				Array.Copy (attribs, 0, copy, 0, attribs.Length);

				fixed (NSOpenGLPixelFormatAttribute* pArray = copy){
					if (IsDirectBinding) {
						Handle = MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr (this.Handle, selInitWithAttributes, new IntPtr((void*)pArray ));
					} else {
						Handle = MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper_IntPtr (this.SuperHandle, selInitWithAttributes, new IntPtr((void*)pArray));
					}
				}
				
			}
		}
Ejemplo n.º 6
0
        private void Initialize()
        {
            WantsBestResolutionOpenGLSurface = true;

            var attrs = new NSOpenGLPixelFormatAttribute[]
            {
                //NSOpenGLPixelFormatAttribute.OpenGLProfile, (NSOpenGLPixelFormatAttribute)NSOpenGLProfile.VersionLegacy,
                NSOpenGLPixelFormatAttribute.Accelerated,
                NSOpenGLPixelFormatAttribute.DoubleBuffer,
                NSOpenGLPixelFormatAttribute.Multisample,

                NSOpenGLPixelFormatAttribute.ColorSize, (NSOpenGLPixelFormatAttribute)32,
                NSOpenGLPixelFormatAttribute.AlphaSize, (NSOpenGLPixelFormatAttribute)8,
                NSOpenGLPixelFormatAttribute.DepthSize, (NSOpenGLPixelFormatAttribute)24,
                NSOpenGLPixelFormatAttribute.StencilSize, (NSOpenGLPixelFormatAttribute)8,
                NSOpenGLPixelFormatAttribute.SampleBuffers, (NSOpenGLPixelFormatAttribute)1,
                NSOpenGLPixelFormatAttribute.Samples, (NSOpenGLPixelFormatAttribute)4,
                (NSOpenGLPixelFormatAttribute)0,
            };

            PixelFormat = new NSOpenGLPixelFormat(attrs);
        }
Ejemplo n.º 7
0
        static uint [] ConvertToAttributes(object [] args)
        {
            var list = new List <uint> ();

            for (int i = 0; i < args.Length; i++)
            {
                if (args [i] is NSOpenGLPixelFormatAttribute)
                {
                    NSOpenGLPixelFormatAttribute v = (NSOpenGLPixelFormatAttribute)args [i];
                    switch (v)
                    {
                    case NSOpenGLPixelFormatAttribute.AllRenderers:
                    case NSOpenGLPixelFormatAttribute.DoubleBuffer:
                    case NSOpenGLPixelFormatAttribute.Stereo:
                    case NSOpenGLPixelFormatAttribute.MinimumPolicy:
                    case NSOpenGLPixelFormatAttribute.MaximumPolicy:
                    case NSOpenGLPixelFormatAttribute.OffScreen:
                    case NSOpenGLPixelFormatAttribute.FullScreen:
                    case NSOpenGLPixelFormatAttribute.SingleRenderer:
                    case NSOpenGLPixelFormatAttribute.NoRecovery:
                    case NSOpenGLPixelFormatAttribute.Accelerated:
                    case NSOpenGLPixelFormatAttribute.ClosestPolicy:
                    case NSOpenGLPixelFormatAttribute.Robust:
                    case NSOpenGLPixelFormatAttribute.BackingStore:
                    case NSOpenGLPixelFormatAttribute.Window:
                    case NSOpenGLPixelFormatAttribute.MultiScreen:
                    case NSOpenGLPixelFormatAttribute.Compliant:
                    case NSOpenGLPixelFormatAttribute.PixelBuffer:

                    // Not listed in the docs, but header file implies it
                    case NSOpenGLPixelFormatAttribute.RemotePixelBuffer:
                    case NSOpenGLPixelFormatAttribute.AuxDepthStencil:
                    case NSOpenGLPixelFormatAttribute.ColorFloat:
                    case NSOpenGLPixelFormatAttribute.Multisample:
                    case NSOpenGLPixelFormatAttribute.Supersample:
                    case NSOpenGLPixelFormatAttribute.SampleAlpha:
                    case NSOpenGLPixelFormatAttribute.AllowOfflineRenderers:
                    case NSOpenGLPixelFormatAttribute.AcceleratedCompute:
                    case NSOpenGLPixelFormatAttribute.MPSafe:
                        list.Add((uint)v);
                        break;

                    case NSOpenGLPixelFormatAttribute.AuxBuffers:
                    case NSOpenGLPixelFormatAttribute.ColorSize:
                    case NSOpenGLPixelFormatAttribute.AlphaSize:
                    case NSOpenGLPixelFormatAttribute.DepthSize:
                    case NSOpenGLPixelFormatAttribute.StencilSize:
                    case NSOpenGLPixelFormatAttribute.AccumSize:
                    case NSOpenGLPixelFormatAttribute.RendererID:
                    case NSOpenGLPixelFormatAttribute.ScreenMask:
                    case NSOpenGLPixelFormatAttribute.OpenGLProfile:

                    // not listed in the docs, but header file implies it
                    case NSOpenGLPixelFormatAttribute.SampleBuffers:
                    case NSOpenGLPixelFormatAttribute.Samples:
                    case NSOpenGLPixelFormatAttribute.VirtualScreenCount:
                        list.Add((uint)(int)v);
                        i++;
                        if (i >= args.Length)
                        {
                            throw new ArgumentException("Attribute " + v + " needs a value");
                        }
                        list.Add((uint)(int)args [i]);
                        break;
                    }
                }
                else if (args [i] is int && (int)args [i] == 0 && i == args.Length - 1)
                {
                    list.Add(0);
                }
                else
                {
                    throw new ArgumentException($"The specified attribute is not of type NSOpenGLPixelFormatAttribute: {args [i]}");
                }
            }

            if (args.Length == 0 || !(args[args.Length - 1] is int) || ((int)args [args.Length - 1]) != 0)
            {
                list.Add(0);
            }

            return(list.ToArray());
        }
Ejemplo n.º 8
0
 private void AddPixelAttrib(List<NSOpenGLPixelFormatAttribute> attributes, NSOpenGLPixelFormatAttribute attribute)
 {
     Debug.Print(attribute.ToString());
     
     attributes.Add(attribute);
 }
Ejemplo n.º 9
0
 private void AddPixelAttrib(List<NSOpenGLPixelFormatAttribute> attributes, NSOpenGLPixelFormatAttribute attribute, int value)
 {
     Debug.Print("{0} : {1}", attribute, value);
     
     attributes.Add(attribute);
     attributes.Add((NSOpenGLPixelFormatAttribute)value);
 }
        /// <summary>
        /// <para>Returns an NSOpenGLPixelFormat object initialized with specified pixel format attributes.</para>
        /// <para>Original signature is '- (id)initWithAttributes:(const NSOpenGLPixelFormatAttribute *)attribs'</para>
        /// <para>Available in Mac OS X v10.0 and later.</para>
        /// </summary>

        public NSOpenGLPixelFormat(NSOpenGLPixelFormatAttribute[] attribs) : this(attribs.Select(attribute => Convert.ToUInt32(attribute)).ToArray())
        {
        }
Ejemplo n.º 11
0
        private void AddPixelAttrib(List <NSOpenGLPixelFormatAttribute> attributes, NSOpenGLPixelFormatAttribute attribute)
        {
            Debug.Print(attribute.ToString());

            attributes.Add(attribute);
        }