MCPcopy Create free account
hub / github.com/cogentcore/core / newRenderWindow

Function newRenderWindow

core/renderwindow.go:103–146  ·  view source on GitHub ↗

newRenderWindow creates a new window with given internal name handle, display name, and options. This is called by Stage.newRenderWindow which handles setting the opts and other infrastructure.

(name, title string, opts *system.NewWindowOptions)

Source from the content-addressed store, hash-verified

101// display name, and options. This is called by Stage.newRenderWindow
102// which handles setting the opts and other infrastructure.
103func newRenderWindow(name, title string, opts *system.NewWindowOptions) *renderWindow {
104 w := &renderWindow{}
105 w.name = name
106 w.title = title
107 var err error
108 w.SystemWindow, err = system.TheApp.NewWindow(opts)
109 if err != nil {
110 fmt.Printf("Cogent Core NewRenderWindow error: %v \n", err)
111 return nil
112 }
113 w.SystemWindow.SetName(title)
114 w.SystemWindow.SetTitleBarIsDark(matcolor.SchemeIsDark)
115 w.SystemWindow.SetCloseReqFunc(func(win system.Window) {
116 rc := w.renderContext()
117 rc.lock()
118 defer rc.unlock()
119 w.closing = true
120 // ensure that everyone is closed first
121 for _, kv := range w.mains.stack.Order {
122 if kv.Value == nil || kv.Value.Scene == nil || kv.Value.Scene.This == nil {
123 continue
124 }
125 if !kv.Value.Scene.Close() {
126 w.closing = false
127 return
128 }
129 }
130 win.Close()
131 })
132
133 drw := w.SystemWindow.Drawer()
134 drw.SetMaxTextures(system.MaxTexturesPerSet * 3) // use 3 sets
135 w.renderScenes.maxIndex = system.MaxTexturesPerSet * 2 // reserve last for sprites
136
137 // win.SystemWin.SetDestroyGPUResourcesFunc(func() {
138 // for _, ph := range win.Phongs {
139 // ph.Destroy()
140 // }
141 // for _, fr := range win.Frames {
142 // fr.Destroy()
143 // }
144 // })
145 return w
146}
147
148// MainScene returns the current [renderWindow.mains] top Scene,
149// which is the current window or full window dialog occupying the RenderWindow.

Callers 1

newRenderWindowMethod · 0.85

Calls 11

renderContextMethod · 0.95
lockMethod · 0.80
unlockMethod · 0.80
NewWindowMethod · 0.65
SetNameMethod · 0.65
SetTitleBarIsDarkMethod · 0.65
SetCloseReqFuncMethod · 0.65
CloseMethod · 0.65
DrawerMethod · 0.65
SetMaxTexturesMethod · 0.65
PrintfMethod · 0.45

Tested by

no test coverage detected