Example #1
0
        /// <summary>
        /// Initializes the dispmanx features of the host.
        /// </summary>
        internal static void Init()
        {
            // Has the BcmHost been initialized already?
            if (Devices != null)
            {
                return;
            }

            bcm_host_init();
            Devices = new List <DisplayDevice>();

            // The raspberry pi dispmanx code is customized to have only 1 display, but it can have more when the offical lcd is added. So we really  ought to check for more displays.
            // Unfortunately there is no dispmanx function to enumerate the displays, or get a count of them. So resort to testing a few and seeing what sticks.
            for (uint i = 0; i < 32; i++)
            {
                IntPtr   handle = vc_dispmanx_display_open(i);
                ModeInfo mode   = new ModeInfo();
                if (handle == IntPtr.Zero)
                {
                    continue;
                }
                if (vc_dispmanx_display_get_info(handle, ref mode) < 0 || mode.DisplayNumber != i)                 // this checks if the dispmanx software returned the actual display number.
                {
                    continue;
                }
                Devices.Add(new DisplayDevice(mode));
                vc_dispmanx_display_close(handle);
            }

            glGetError();
            // If you are thinking WTF? then yes. At the time I made this, the libbrcmEGL.so depends on a few exports from libbrcmGLESv2.so (even though I'm going to use OpenVG.so in the end).
            // But it does not declare this as a requirement since this would be a circular import (gles depends on egl). To fix this we have to make sure to touch libbrcmGLESv2.so before
            // touching libEGL.so. This causes them both to be loaded in the right order. But this has to happen before we touch libEGL. So this is one of the few places where this is
            // possible. And even though this works now, this depends on CLI specifics (mono in this case), so there is no guarantee this will keep working. So to force libbrcmGLESv2.so to load
            // choose an innocent function from gles and call it.
        }
Example #2
0
 internal DisplayDevice(ModeInfo mode)
 {
     Mode = mode;
 }
Example #3
0
 [DllImport("libbcm_host.so")] internal static extern int vc_dispmanx_display_get_info(IntPtr handle, ref ModeInfo currentmode);