Unindent() public static method

public static Unindent ( ) : void
return void
Ejemplo n.º 1
0
        /// <summary>
        /// Detects the unix kernel by p/invoking uname (libc).
        /// </summary>
        /// <returns></returns>
        private static string DetectUnixKernel()
        {
            Debug.Print("Size: {0}", Marshal.SizeOf(typeof(utsname)).ToString());
            Debug.Flush();
            utsname uts = new utsname();

            uname(out uts);
            Debug.WriteLine("System:");
            Debug.Indent();
            Debug.WriteLine(uts.sysname);
            Debug.WriteLine(uts.nodename);
            Debug.WriteLine(uts.release);
            Debug.WriteLine(uts.version);
            Debug.WriteLine(uts.machine);
            Debug.Unindent();
            return(uts.sysname.ToString());
        }
Ejemplo n.º 2
0
        // Checks whether the parameter is a primitive type or consists of primitive types recursively.
        // Throws a NotSupportedException if it is not.
        static bool CheckType(Type type)
        {
            //Debug.Print("Checking type {0} (size: {1} bytes).", type.Name, Marshal.SizeOf(type));
            if (type.IsPrimitive)
            {
                return(true);
            }

            FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            Debug.Indent();
            foreach (FieldInfo field in fields)
            {
                if (!CheckType(field.FieldType))
                {
                    return(false);
                }
            }
            Debug.Unindent();

            return(true);
        }
Ejemplo n.º 3
0
        private IntPtr SelectPixelFormat(GraphicsMode mode, int majorVersion, int minorVersion)
        {
            List <NSOpenGLPixelFormatAttribute> attributes = new List <NSOpenGLPixelFormatAttribute>();

            var profile = NSOpenGLProfile.VersionLegacy;

            if (majorVersion > 3 || (majorVersion == 3 && minorVersion >= 2))
            {
                profile = NSOpenGLProfile.Version3_2Core;
                Debug.Print("Running the OpenGL core profile.");
            }
            else
            {
                Debug.Print("Running the legacy OpenGL profile. Start with version major=3, minor=2 or later for the 3.2 profile.");
            }

            Debug.Print("NSGL pixel format attributes:");
            Debug.Indent();

            AddPixelAttrib(attributes, NSOpenGLPixelFormatAttribute.OpenGLProfile, (int)profile);

            if (mode.ColorFormat.BitsPerPixel > 0)
            {
                AddPixelAttrib(attributes, NSOpenGLPixelFormatAttribute.ColorSize, mode.ColorFormat.BitsPerPixel);
            }

            if (mode.Depth > 0)
            {
                AddPixelAttrib(attributes, NSOpenGLPixelFormatAttribute.DepthSize, mode.Depth);
            }

            if (mode.Stencil > 0)
            {
                AddPixelAttrib(attributes, NSOpenGLPixelFormatAttribute.StencilSize, mode.Stencil);
            }

            if (mode.AccumulatorFormat.BitsPerPixel > 0)
            {
                AddPixelAttrib(attributes, NSOpenGLPixelFormatAttribute.AccumSize, mode.AccumulatorFormat.BitsPerPixel);
            }

            if (mode.Samples > 1)
            {
                AddPixelAttrib(attributes, NSOpenGLPixelFormatAttribute.SampleBuffers, 1);
                AddPixelAttrib(attributes, NSOpenGLPixelFormatAttribute.Samples, mode.Samples);
            }

            if (mode.Buffers > 1)
            {
                AddPixelAttrib(attributes, NSOpenGLPixelFormatAttribute.DoubleBuffer);
            }

            // If at least a single accelerated pixel format is available,
            // then use that. If no accelerated formats are available, fall
            // back to software rendering.
            if (IsAccelerationSupported())
            {
                AddPixelAttrib(attributes, NSOpenGLPixelFormatAttribute.Accelerated);
            }

            AddPixelAttrib(attributes, (NSOpenGLPixelFormatAttribute)0);

            Debug.Unindent();

            Debug.Write("Attribute array:  ");
            for (int i = 0; i < attributes.Count; i++)
            {
                Debug.Write(attributes[i].ToString() + "  ");
            }
            Debug.WriteLine("");

            // Create pixel format
            var pixelFormat = Cocoa.SendIntPtr(Class.Get("NSOpenGLPixelFormat"), Selector.Alloc);

            unsafe
            {
                fixed(NSOpenGLPixelFormatAttribute *ptr = attributes.ToArray())
                {
                    pixelFormat = Cocoa.SendIntPtr(pixelFormat, Selector.Get("initWithAttributes:"), (IntPtr)ptr);
                }
            }

            return(pixelFormat);
        }
Ejemplo n.º 4
0
        private void CreateContext(GraphicsMode mode, CocoaWindowInfo cocoaWindow, IntPtr shareContextRef, int majorVersion, int minorVersion, bool fullscreen)
        {
            // Prepare attributes
            List <NSOpenGLPixelFormatAttribute> attributes = new List <NSOpenGLPixelFormatAttribute>();

            var profile = NSOpenGLProfile.VersionLegacy;

            if (majorVersion > 3 || (majorVersion == 3 && minorVersion >= 2))
            {
                profile = NSOpenGLProfile.Version3_2Core;
                Debug.Print("Running the OpenGL core profile.");
            }
            else
            {
                Debug.Print("Running the legacy OpenGL profile. Start with version major=3, minor=2 or later for the 3.2 profile.");
            }

            Debug.Print("NSGL pixel format attributes:");
            Debug.Indent();

            AddPixelAttrib(attributes, NSOpenGLPixelFormatAttribute.OpenGLProfile, (int)profile);
            AddPixelAttrib(attributes, NSOpenGLPixelFormatAttribute.DoubleBuffer);
            AddPixelAttrib(attributes, NSOpenGLPixelFormatAttribute.Accelerated);
            AddPixelAttrib(attributes, NSOpenGLPixelFormatAttribute.ColorSize, mode.ColorFormat.BitsPerPixel);

            if (mode.Depth > 0)
            {
                AddPixelAttrib(attributes, NSOpenGLPixelFormatAttribute.DepthSize, mode.Depth);
            }

            if (mode.Stencil > 0)
            {
                AddPixelAttrib(attributes, NSOpenGLPixelFormatAttribute.StencilSize, mode.Stencil);
            }

            if (mode.AccumulatorFormat.BitsPerPixel > 0)
            {
                AddPixelAttrib(attributes, NSOpenGLPixelFormatAttribute.AccumSize, mode.AccumulatorFormat.BitsPerPixel);
            }

            if (mode.Samples > 1)
            {
                AddPixelAttrib(attributes, NSOpenGLPixelFormatAttribute.SampleBuffers, 1);
                AddPixelAttrib(attributes, NSOpenGLPixelFormatAttribute.Samples, mode.Samples);
            }

            AddPixelAttrib(attributes, (NSOpenGLPixelFormatAttribute)0);

            Debug.Unindent();

            Debug.Write("Attribute array:  ");
            for (int i = 0; i < attributes.Count; i++)
            {
                Debug.Write(attributes[i].ToString() + "  ");
            }
            Debug.WriteLine("");

            // Create pixel format
            var pixelFormat = Cocoa.SendIntPtr(Class.Get("NSOpenGLPixelFormat"), Selector.Alloc);

            unsafe
            {
                fixed(NSOpenGLPixelFormatAttribute *ptr = attributes.ToArray())
                {
                    pixelFormat = Cocoa.SendIntPtr(pixelFormat, Selector.Get("initWithAttributes:"), (IntPtr)ptr);
                }
            }

            // Create context
            var context = Cocoa.SendIntPtr(NSOpenGLContext, Selector.Alloc);

            context = Cocoa.SendIntPtr(context, Selector.Get("initWithFormat:shareContext:"), pixelFormat, shareContextRef);

            // Release pixel format
            Cocoa.SendVoid(pixelFormat, Selector.Release);
            pixelFormat = IntPtr.Zero;

            // Attach the view
            Cocoa.SendVoid(context, Selector.Get("setView:"), cocoaWindow.ViewHandle);
            Cocoa.SendVoid(cocoaWindow.ViewHandle, Selector.Get("setWantsBestResolutionOpenGLSurface:"), true);

            // Finalize
            Handle = new ContextHandle(context);
            Mode   = GetGraphicsMode(context);

            Update(cocoaWindow);
            MakeCurrent(cocoaWindow);
        }