コード例 #1
0
ファイル: Bgfx.cs プロジェクト: PowerStateFailure/SharpBgfx
 /// <summary>
 /// Initializes the graphics library on the specified adapter.
 /// </summary>
 /// <param name="backend">The backend API to use for rendering.</param>
 /// <param name="adapter">The adapter on which to create the device.</param>
 /// <param name="callbackHandler">A set of handlers for various library callbacks.</param>
 public static void Init(RendererBackend backend = RendererBackend.Default, Adapter adapter = default(Adapter), ICallbackHandler callbackHandler = null)
 {
     NativeMethods.bgfx_init(
         backend,
         (ushort)adapter.Vendor,
         (ushort)adapter.DeviceId,
         CallbackShim.CreateShim(callbackHandler ?? new DefaultCallbackHandler()),
         IntPtr.Zero
         );
 }
コード例 #2
0
ファイル: Bgfx.cs プロジェクト: jooo000hn/SharpBgfx
        /// <summary>
        /// Initializes the graphics library on the specified adapter.
        /// </summary>
        /// <param name="settings">Settings that control initialization, or <c>null</c> to use sane defaults.</param>
        /// <returns><c>true</c> if initialization succeeds; otherwise, <c>false</c>.</returns>
        public static bool Init(InitSettings settings = null)
        {
            InitSettings.Native native;
            NativeMethods.bgfx_init_ctor(&native);

            settings         = settings ?? new InitSettings();
            native.Backend   = settings.Backend;
            native.VendorId  = (ushort)settings.Adapter.Vendor;
            native.DeviceId  = (ushort)settings.Adapter.DeviceId;
            native.Width     = (uint)settings.Width;
            native.Height    = (uint)settings.Height;
            native.Flags     = (uint)settings.ResetFlags;
            native.Callbacks = CallbackShim.CreateShim(settings.CallbackHandler ?? new DefaultCallbackHandler());

            return(NativeMethods.bgfx_init(&native));
        }
コード例 #3
0
ファイル: Bgfx.cs プロジェクト: PowerStateFailure/SharpBgfx
 /// <summary>
 /// Closes the library and releases all resources.
 /// </summary>
 public static void Shutdown()
 {
     NativeMethods.bgfx_shutdown();
     CallbackShim.FreeShim();
 }
コード例 #4
0
ファイル: Callbacks.cs プロジェクト: prepare/SharpBgfx
            public unsafe DelegateSaver(ICallbackHandler handler, CallbackShim* shim)
            {
                this.handler = handler;
                reportError = ReportError;
                reportDebug = ReportDebug;
                getCachedSize = GetCachedSize;
                getCacheEntry = GetCacheEntry;
                setCacheEntry = SetCacheEntry;
                saveScreenShot = SaveScreenShot;
                captureStarted = CaptureStarted;
                captureFinished = CaptureFinished;
                captureFrame = CaptureFrame;

                shim->reportError = Marshal.GetFunctionPointerForDelegate(reportError);
                shim->reportDebug = Marshal.GetFunctionPointerForDelegate(reportDebug);
                shim->getCachedSize = Marshal.GetFunctionPointerForDelegate(getCachedSize);
                shim->getCacheEntry = Marshal.GetFunctionPointerForDelegate(getCacheEntry);
                shim->setCacheEntry = Marshal.GetFunctionPointerForDelegate(setCacheEntry);
                shim->saveScreenShot = Marshal.GetFunctionPointerForDelegate(saveScreenShot);
                shim->captureStarted = Marshal.GetFunctionPointerForDelegate(captureStarted);
                shim->captureFinished = Marshal.GetFunctionPointerForDelegate(captureFinished);
                shim->captureFrame = Marshal.GetFunctionPointerForDelegate(captureFrame);
            }