Esempio n. 1
0
        /// <summary>
        /// Releases all resources used by the <see cref="VideoCoreWindow"/> object.
        /// </summary>
        /// <param name="disposing">
        /// </param>
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_ElementHandle != 0)
                {
                    uint updateHandle = Bcm.vc_dispmanx_update_start(0);
                    Bcm.vc_dispmanx_element_remove(updateHandle, _ElementHandle);
                    Bcm.vc_dispmanx_update_submit_sync(updateHandle);

                    _ElementHandle = 0;
                }

                if (_DispManxDisplay != 0)
                {
                    Bcm.vc_dispmanx_display_close(_DispManxDisplay);
                    _DispManxDisplay = 0;
                }

                if (_NativeWindowLock != null)
                {
                    _NativeWindowLock.Dispose();
                    _NativeWindowLock = null;
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Copy memory.
 /// </summary>
 /// <param name="dst">
 /// A <see cref="IntPtr"/> that specify the address of the destination unmanaged memory.
 /// </param>
 /// <param name="src">
 /// A <see cref="Array"/> that specify the source array object.
 /// </param>
 /// <param name="bytes">
 /// A <see cref="ulong"/> that specify the number of bytes to copy.
 /// </param>
 public static void Copy(IntPtr dst, Array src, ulong bytes)
 {
     using (MemoryLock srcLock = new MemoryLock(src)) {
         _CopyPointer(
             dst.ToPointer(),
             srcLock.Address.ToPointer(),
             bytes
             );
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Copy memory.
 /// </summary>
 /// <param name="dst">
 /// A <see cref="Array"/> that specify the address of the destination unmanaged memory.
 /// </param>
 /// <param name="src">
 /// A <see cref="IntPtr"/> that specify the source array object.
 /// </param>
 /// <param name="bytes">
 /// A <see cref="ulong"/> that specify the number of bytes to copy.
 /// </param>
 public static void Copy(Array dst, IntPtr src, ulong bytes)
 {
     using (MemoryLock dstLock = new MemoryLock(dst)) {
         _CopyPointer(
             dstLock.Address.ToPointer(),
             src.ToPointer(),
             bytes
             );
     }
 }
Esempio n. 4
0
        private void DrawLines2f_GL_1_1(Vertex2f[] vertices)
        {
            if ((vertices.Length % 2) != 0)
            {
                throw new ArgumentException("length not a multiple of 2", "vertices");
            }

            using (MemoryLock memoryLock = new MemoryLock(vertices)) {
                // Setup arrays
                Gl.VertexPointer(2, VertexPointerType.Float, 0, memoryLock.Address);
                Gl.EnableClientState(EnableCap.VertexArray);
                // Draw arrays
                Gl.DrawArrays(PrimitiveType.Lines, 0, vertices.Length);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Construct a fullscreen window.
        /// </summary>
        public VideoCoreWindow()
        {
            try {
                int width, height;

                KhronosApi.LogComment("Creating VideoCore IV native window");

                if (Bcm.graphics_get_display_size(0 /* LCD */, out width, out height) < 0)
                {
                    throw new InvalidOperationException("unable to get BCM display size");
                }

                Bcm.VC_RECT_T dstRect = new Bcm.VC_RECT_T(0, 0, width, height);
                Bcm.VC_RECT_T srcRect = new Bcm.VC_RECT_T(0, 0, width << 16, height << 16);

                if ((_DispManxDisplay = Bcm.vc_dispmanx_display_open(0 /* LCD */)) == 0)
                {
                    throw new InvalidOperationException("unable to open DispManX display");
                }

                // Update - Add element
                uint updateHandle = Bcm.vc_dispmanx_update_start(0);
                _ElementHandle = Bcm.vc_dispmanx_element_add(updateHandle, _DispManxDisplay, 0, dstRect, 0, srcRect, 0, IntPtr.Zero, IntPtr.Zero, Bcm.DISPMANX_TRANSFORM_T.DISPMANX_NO_ROTATE);
                Bcm.vc_dispmanx_update_submit_sync(updateHandle);

                // Native window
                _NativeWindow         = new EGL_DISPMANX_WINDOW_T();
                _NativeWindow.element = _ElementHandle;
                _NativeWindow.width   = width;
                _NativeWindow.height  = height;

                // Keep native window pinned
                _NativeWindowLock = new MemoryLock(_NativeWindow);

                KhronosApi.LogComment("VideoCore IV Native Window is 0x{0}", _NativeWindowLock.Address.ToString("X"));
            } catch {
                Dispose();
                throw;
            }
        }
		private void DrawLines2f_GL_1_1(Vertex2f[] vertices)
		{
			if ((vertices.Length % 2) != 0)
				throw new ArgumentException("length not a multiple of 2", "vertices");

			using (MemoryLock memoryLock = new MemoryLock(vertices)) {
				// Setup arrays
				Gl.VertexPointer(2, VertexPointerType.Float, 0, memoryLock.Address);
				Gl.EnableClientState(EnableCap.VertexArray);
				// Draw arrays
				Gl.DrawArrays(PrimitiveType.Lines, 0, vertices.Length);
			}
		}