Exemple #1
0
 protected override void OnHandleCreated(EventArgs e)
 {
     base.OnHandleCreated(e);
     if (platformRenderContext == null)
     {
         platformRenderContext = new Graphics.Platform.Vulkan.PlatformRenderContext();
         PlatformRenderer.Initialize(platformRenderContext);
     }
     RecreateSwapchain();
 }
Exemple #2
0
 public void MakeCurrent()
 {
     EglMakeCurrent();
     if (platformRenderContext == null)
     {
         platformRenderContext = new Graphics.Platform.OpenGL.PlatformRenderContext();
         PlatformRenderer.Initialize(platformRenderContext);
     }
     platformRenderContext.Begin(0);
 }
Exemple #3
0
 protected override void OnHandleCreated(EventArgs e)
 {
     base.OnHandleCreated(e);
     if (platformRenderContext == null)
     {
         platformRenderContext = new Graphics.Platform.Vulkan.PlatformRenderContext();
         PlatformRenderer.Initialize(platformRenderContext);
     }
     swapchain = new Graphics.Platform.Vulkan.Swapchain(platformRenderContext, Handle, ClientSize.Width, ClientSize.Height);
 }
Exemple #4
0
 protected override void OnHandleCreated(EventArgs e)
 {
     base.OnHandleCreated(e);
     windowInfo      = OpenTK.Platform.Utilities.CreateWindowsWindowInfo(Handle);
     graphicsContext = new OpenTK.Graphics.GraphicsContext(graphicsMode, windowInfo, major, minor, graphicsContextFlags);
     graphicsContext.MakeCurrent(windowInfo);
     graphicsContext.LoadAll();
     graphicsContext.SwapInterval = VSync ? 1 : 0;
     if (platformRenderContext == null)
     {
         platformRenderContext = new Graphics.Platform.OpenGL.PlatformRenderContext();
         PlatformRenderer.Initialize(platformRenderContext);
     }
     graphicsContext.MakeCurrent(null);
 }
Exemple #5
0
 private void SetupContextAndFramebuffer()
 {
     if (mgleaglContext == null)
     {
         ConfigureLayer();
         try {
             mgleaglContext = new EAGLContext(EAGLRenderingAPI.OpenGLES3);
         } catch {
             mgleaglContext = new EAGLContext(EAGLRenderingAPI.OpenGLES2);
         }
         MakeCurrent();
         renderContext = new PlatformRenderContext();
         PlatformRenderer.Initialize(renderContext);
     }
     DestroyFramebuffer();
     CreateFramebuffer();
 }
Exemple #6
0
        public void Draw(MTKView view)
        {
            if (vkContext == null)
            {
                vkContext = new Graphics.Platform.Vulkan.PlatformRenderContext();
                PlatformRenderer.Initialize(vkContext);
            }
            if (vkSwapChain == null)
            {
                shouldUpdateMetalLayerSize = true;
            }
            if (shouldUpdateMetalLayerSize)
            {
                var screen       = Window?.Screen ?? UIScreen.MainScreen;
                var drawableSize = Bounds.Size;
                drawableSize.Width     *= screen.NativeScale;
                drawableSize.Height    *= screen.NativeScale;
                metalLayer.DrawableSize = drawableSize;
                if (vkSwapChain == null)
                {
                    vkSwapChain = new Graphics.Platform.Vulkan.Swapchain(vkContext, this.Handle, (int)metalLayer.DrawableSize.Width, (int)metalLayer.DrawableSize.Height);
                }
                else
                {
                    vkSwapChain.Resize((int)metalLayer.DrawableSize.Width, (int)metalLayer.DrawableSize.Height);
                }
                shouldUpdateMetalLayerSize = false;
            }
            shouldUpdateMetalLayerSize = false;
            var curUpdateTime = stopwatch.Elapsed;

            if (prevUpdateTime == TimeSpan.Zero)
            {
                prevUpdateTime = curUpdateTime;
            }
            var delta = (float)(curUpdateTime - prevUpdateTime).TotalSeconds;

            UpdateFrame?.Invoke(delta);
            prevUpdateTime = curUpdateTime;
            RenderFrame?.Invoke();
        }