public virtual void SwapBuffers() { AssertValid(); AssertContext(); gl.BindRenderbuffer(All.RenderbufferOes, renderbuffer); GraphicsContext.SwapBuffers(); }
private void CreateFrameBuffer(CAEAGLLayer eaglLayer) { int oldRenderbuffer = 1; gl.GetInteger(All.RenderbufferBindingOes, out oldRenderbuffer); gl.GenRenderbuffers(1, out renderbuffer); gl.BindRenderbuffer(All.RenderbufferOes, renderbuffer); if (!EAGLContext.RenderBufferStorage((uint)All.RenderbufferOes, eaglLayer)) { gl.DeleteRenderbuffers(1, ref renderbuffer); renderbuffer = 0; gl.BindRenderbuffer(All.RenderbufferBindingOes, oldRenderbuffer); throw new InvalidOperationException("Error with EAGLContext.RenderBufferStorage!"); } gl.BindFramebuffer(All.FramebufferOes, framebuffer); gl.FramebufferRenderbuffer(All.FramebufferOes, All.ColorAttachment0Oes, All.RenderbufferOes, renderbuffer); Size newSize = new Size( (int)Math.Round(eaglLayer.Bounds.Size.Width), (int)Math.Round(eaglLayer.Bounds.Size.Height)); Size = newSize; gl.Viewport(0, 0, newSize.Width, newSize.Height); gl.Scissor(0, 0, newSize.Width, newSize.Height); }
protected virtual void CreateFrameBuffer() { AssertValid(); if (LayerColorFormat == null) { throw new InvalidOperationException("Set the LayerColorFormat property to an EAGLColorFormat value before calling Run()."); } CAEAGLLayer eaglLayer = (CAEAGLLayer)Layer; eaglLayer.DrawableProperties = NSDictionary.FromObjectsAndKeys( new NSObject [] { NSNumber.FromBoolean(LayerRetainsBacking), LayerColorFormat }, new NSObject [] { EAGLDrawableProperty.RetainedBacking, EAGLDrawableProperty.ColorFormat } ); ConfigureLayer(eaglLayer); GraphicsContext = Utilities.CreateGraphicsContext(ContextRenderingApi); gl = GLCalls.GetGLCalls(ContextRenderingApi); int oldFramebuffer = 0, oldRenderbuffer = 1; gl.GetInteger(All.FramebufferBindingOes, ref oldFramebuffer); gl.GetInteger(All.RenderbufferBindingOes, ref oldRenderbuffer); gl.GenRenderbuffers(1, ref renderbuffer); gl.BindRenderbuffer(All.RenderbufferOes, renderbuffer); if (!EAGLContext.RenderBufferStorage((uint)All.RenderbufferOes, eaglLayer)) { gl.DeleteRenderbuffers(1, ref renderbuffer); renderbuffer = 0; gl.BindRenderbuffer(All.RenderbufferBindingOes, oldRenderbuffer); throw new InvalidOperationException("Error with EAGLContext.RenderBufferStorage!"); } gl.GenFramebuffers(1, ref framebuffer); gl.BindFramebuffer(All.FramebufferOes, framebuffer); gl.FramebufferRenderbuffer(All.FramebufferOes, All.ColorAttachment0Oes, All.RenderbufferOes, renderbuffer); Size newSize = new Size( (int)Math.Round(eaglLayer.Bounds.Size.Width), (int)Math.Round(eaglLayer.Bounds.Size.Height)); Size = newSize; gl.Viewport(0, 0, newSize.Width, newSize.Height); gl.Scissor(0, 0, newSize.Width, newSize.Height); frameBufferWindow = new WeakReference(Window); frameBufferLayer = new WeakReference(Layer); }
protected virtual void CreateFrameBuffer() { AssertValid(); if (LayerColorFormat == null) throw new InvalidOperationException("Set the LayerColorFormat property to an EAGLColorFormat value before calling Run()."); CAEAGLLayer eaglLayer = (CAEAGLLayer) Layer; eaglLayer.DrawableProperties = NSDictionary.FromObjectsAndKeys ( new NSObject [] {NSNumber.FromBoolean(LayerRetainsBacking), LayerColorFormat}, new NSObject [] {EAGLDrawableProperty.RetainedBacking, EAGLDrawableProperty.ColorFormat} ); ConfigureLayer(eaglLayer); GraphicsContext = Utilities.CreateGraphicsContext(ContextRenderingApi); gl = GLCalls.GetGLCalls(ContextRenderingApi); int oldFramebuffer = 0, oldRenderbuffer = 1; gl.GetInteger(All.FramebufferBindingOes, ref oldFramebuffer); gl.GetInteger(All.RenderbufferBindingOes, ref oldRenderbuffer); gl.GenRenderbuffers(1, ref renderbuffer); gl.BindRenderbuffer(All.RenderbufferOes, renderbuffer); if (!EAGLContext.RenderBufferStorage((uint) All.RenderbufferOes, eaglLayer)) { gl.DeleteRenderbuffers(1, ref renderbuffer); renderbuffer = 0; gl.BindRenderbuffer(All.RenderbufferBindingOes, oldRenderbuffer); throw new InvalidOperationException("Error with EAGLContext.RenderBufferStorage!"); } gl.GenFramebuffers (1, ref framebuffer); gl.BindFramebuffer (All.FramebufferOes, framebuffer); gl.FramebufferRenderbuffer (All.FramebufferOes, All.ColorAttachment0Oes, All.RenderbufferOes, renderbuffer); Size newSize = new Size( (int) Math.Round(eaglLayer.Bounds.Size.Width), (int) Math.Round(eaglLayer.Bounds.Size.Height)); Size = newSize; gl.Viewport(0, 0, newSize.Width, newSize.Height); gl.Scissor(0, 0, newSize.Width, newSize.Height); frameBufferWindow = new WeakReference(Window); frameBufferLayer = new WeakReference(Layer); }
protected virtual void CreateFrameBuffer() { AssertValid(); if (LayerColorFormat == null) { throw new InvalidOperationException("Set the LayerColorFormat property to an EAGLColorFormat value before calling Run()."); } CAEAGLLayer eaglLayer = (CAEAGLLayer)Layer; eaglLayer.DrawableProperties = NSDictionary.FromObjectsAndKeys( new NSObject [] { NSNumber.FromBoolean(LayerRetainsBacking), LayerColorFormat }, new NSObject [] { EAGLDrawableProperty.RetainedBacking, EAGLDrawableProperty.ColorFormat } ); ConfigureLayer(eaglLayer); int major = 0, minor = 0; switch (ContextRenderingApi) { case EAGLRenderingAPI.OpenGLES1: major = 1; minor = 1; break; case EAGLRenderingAPI.OpenGLES2: major = 2; minor = 0; break; case EAGLRenderingAPI.OpenGLES3: major = 3; minor = 0; break; default: throw new ArgumentException("Unsupported EAGLRenderingAPI version: " + ContextRenderingApi); } GraphicsContext = new GraphicsContext(GraphicsMode.Default, WindowInfo, major, minor, GraphicsContextFlags.Embedded); GraphicsContext.MakeCurrent(WindowInfo); gl = GLCalls.GetGLCalls(ContextRenderingApi); int oldFramebuffer = 0, oldRenderbuffer = 1; gl.GetInteger(All.FramebufferBindingOes, out oldFramebuffer); gl.GetInteger(All.RenderbufferBindingOes, out oldRenderbuffer); gl.GenRenderbuffers(1, out renderbuffer); gl.BindRenderbuffer(All.RenderbufferOes, renderbuffer); if (!EAGLContext.RenderBufferStorage((uint)All.RenderbufferOes, eaglLayer)) { gl.DeleteRenderbuffers(1, ref renderbuffer); renderbuffer = 0; gl.BindRenderbuffer(All.RenderbufferBindingOes, oldRenderbuffer); throw new InvalidOperationException("Error with EAGLContext.RenderBufferStorage!"); } gl.GenFramebuffers(1, out framebuffer); gl.BindFramebuffer(All.FramebufferOes, framebuffer); gl.FramebufferRenderbuffer(All.FramebufferOes, All.ColorAttachment0Oes, All.RenderbufferOes, renderbuffer); Size newSize = new Size( (int)Math.Round(eaglLayer.Bounds.Size.Width), (int)Math.Round(eaglLayer.Bounds.Size.Height)); Size = newSize; gl.Viewport(0, 0, newSize.Width, newSize.Height); gl.Scissor(0, 0, newSize.Width, newSize.Height); frameBufferWindow = new WeakReference(Window); frameBufferLayer = new WeakReference(Layer); }