예제 #1
0
            public viewwindow(IRenderer render, IRenderOwner renderer, Widget widget, CGRect frame, NSOpenGLContext ctx)
                : base(frame)
            {
                this.mainthread = Thread.CurrentThread;

                this.render   = render;
                this.renderer = renderer;
                this.window   = widget;

                base.WantsBestResolutionOpenGLSurface = true;
                this.WantsLayer = true;

                this.openglctx = ctx;

                Trace.Assert(this.openglctx != null, "no NSOpenGLContext context");

                //                    this.openglctx.CGLContext.Handle

                this.openglctx.CGLContext.Lock();
                try
                {
                    this.openglctx.MakeCurrentContext();

                    this._ctx = new _GraphicsContext(); // created from active content
                }
                catch { throw; }
                finally
                {
                    NSOpenGLContext.ClearCurrentContext();
                    this.openglctx.CGLContext.Unlock();
                }

                /*      var wBackend = Xwt.Toolkit.CurrentEngine.GetSafeBackend(widget.ParentWindow) as Xwt.Backends.IWindowFrameBackend;
                 *    var win = wBackend.Window as NSWindow;
                 *
                 *    while (win.ParentWindow != null)
                 *    {
                 *        win = win.ParentWindow;
                 *    }
                 * //     win.DidChangeValue+= Win_DidChangeValue;
                 *    win.DidChangeBackingProperties+= Win_DidChangeBackingProperties;
                 *    win.DidChangeScreenProfile+= Win_DidChangeScreenProfile;
                 *    win.DidExpose+= Win_DidExpose;
                 *    win.DidMiniaturize+= Win_DidMiniaturize;
                 *    win.DidChangeScreen+= Win_DidChangeScreen;*/
            }
예제 #2
0
                public override NSOpenGLContext GetOpenGLContext(NSOpenGLPixelFormat pixelFormat)
                {
                    this._ctx2?.Dispose();
                    this._ctx2 = null;

                    var r = new NSOpenGLContext(pixelFormat /*GetOpenGLPixelFormat(0)*/, this.owner.openglctx);

                    if (r != null)
                    {
                        var error = CGLEnable(r.CGLContext.Handle, 313); //
                        Trace.Assert(r.CGLContext.Handle != this.owner.openglctx.CGLContext.Handle);
                        {
                            r.CGLContext.Lock();
                            r.MakeCurrentContext();
                            this._ctx2 = new _GraphicsContext(); // register active context handle
                            NSOpenGLContext.ClearCurrentContext();
                            r.CGLContext.Unlock();
                        }
                        return(r);
                    }
                    return(null);
                }
예제 #3
0
 public override void Release(CGLContext glContext)
 {
     this._ctx2?.Dispose();
     this._ctx2 = null;
     base.Release(glContext);
 }