func (me *context) Window(winf *ngctx.WinProfile, bufSize *ngctx.BufferBits, ctxProf *ngctx.CtxProfile) (window ngctx.Window, err error) { glfw.WindowHint(glfw.Samples, winf.MultiSampling) glfw.WindowHint(glfw.RedBits, bufSize.Color.R) glfw.WindowHint(glfw.GreenBits, bufSize.Color.G) glfw.WindowHint(glfw.BlueBits, bufSize.Color.B) glfw.WindowHint(glfw.AlphaBits, bufSize.Color.A) glfw.WindowHint(glfw.DepthBits, bufSize.Depth) glfw.WindowHint(glfw.StencilBits, bufSize.Stencil) glfw.WindowHint(glfw.ContextVersionMajor, ctxProf.Version.Major) glfw.WindowHint(glfw.ContextVersionMinor, ctxProf.Version.Minor) glfw.WindowHint(glfw.OpenglProfile, glfw.OpenglCoreProfile) if ctxProf.ForwardCompat { glfw.WindowHint(glfw.OpenglForwardCompatible, 1) } var mon *glfw.Monitor if winf.FullScreen { mon, err = glfw.GetPrimaryMonitor() } if err == nil { var win *glfw.Window if win, err = glfw.CreateWindow(winf.Width, winf.Height, winf.Title, mon, nil); win != nil { window = newWindow(win) if winf.FullScreen { win.SetInputMode(glfw.Cursor, glfw.CursorHidden) } } } return }
// Open opens a new OS window via GLFW. func Open(width, height int, title string) (*Window, error) { var wnd *glfw3.Window errc := make(chan error) mainc <- func() { var err error wnd, err = glfw3.CreateWindow(width, height, title, nil, nil) errc <- err if err == nil { wnd.SetInputMode(glfw3.Cursor, glfw3.CursorNormal) wnd.Restore() } } err := <-errc if err != nil { return nil, err } return openFromWindow(wnd) }
// New creates a new OS window via GLFW as a ui.Environment. func New(width, height int, title string) (ui.Environment, error) { var wnd *glfw.Window errc := make(chan error) mainc <- func() { var err error wnd, err = glfw.CreateWindow(width, height, title, nil, nil) errc <- err if err == nil { wnd.SetInputMode(glfw.Cursor, glfw.CursorNormal) } } err := <-errc if err != nil { return nil, err } w := &env{ Window: wnd, } w.init() return w, nil }