예제 #1
0
        internal GraphicsContext(IntPtr graphics_surface_ptr, int width, int height)
        {
            var timer = Stopwatch.StartNew();

            Bgfx.SetPlatformData(new PlatformData
            {
                WindowHandle = graphics_surface_ptr
            });

            var bgfx_callback_handler = new BgfxCallbackHandler();

            var settings = new InitSettings
            {
                Backend         = RendererBackend.Default,
                ResetFlags      = ResetFlags.Vsync,
                Width           = width,
                Height          = height,
                CallbackHandler = bgfx_callback_handler
            };

            Bgfx.Init(settings);

            Console.WriteLine($" > GFX INIT : {timer.Elapsed.TotalSeconds.ToString()}");

            var caps = Bgfx.GetCaps();

            Info = new GraphicsInfo(caps.Backend, caps.MaxTextureSize);

            Console.WriteLine($"GRAPHICS BACKEND : {Info.RendererBackend.ToString()}");

            index_buffers = new IndexBuffer[16];
        }
예제 #2
0
        private void ImplInitialize(IntPtr graphics_surface_ptr, int width, int height)
        {
            Bgfx.SetPlatformData(new PlatformData
            {
                WindowHandle = graphics_surface_ptr
            });

            var bgfx_callback_handler = new BgfxCallbackHandler();

            var settings = new InitSettings
            {
                Backend         = RendererBackend.Default,
                ResetFlags      = ResetFlags.Vsync,
                Width           = width,
                Height          = height,
                CallbackHandler = bgfx_callback_handler
            };

            Bgfx.Init(settings);


            var caps = Bgfx.GetCaps();

            GraphicsBackend gfx_backend = GraphicsBackend.OpenGL;

            switch (caps.Backend)
            {
            case RendererBackend.OpenGL: gfx_backend = GraphicsBackend.OpenGL; break;

            case RendererBackend.Direct3D11:
            case RendererBackend.Direct3D12:
            case RendererBackend.Direct3D9:
                gfx_backend = GraphicsBackend.OpenGL; break;
            }

            Info = new GraphicsInfo(gfx_backend, caps.MaxTextureSize);
        }