Skip to content

Commit c2d6fe7

Browse files
committed
step toward shared graphic contexts
1 parent 1f6835e commit c2d6fe7

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

nimx/private/windows/sdl_window.nim

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ proc updatePixelRatio(w: SdlWindow) {.inline.} =
186186
w.pixelRatio = w.scaleFactor()
187187
w.viewportPixelRatio = w.pixelRatio
188188

189-
proc initSdlWindow(w: SdlWindow, r: view.Rect) =
189+
proc initSdlWindow(w: SdlWindow, gfx: GraphicsContext, r: view.Rect) =
190190
initSDLIfNeeded()
191191
when defined(ios) or defined(android):
192192
w.isFullscreen = true
@@ -210,13 +210,13 @@ proc initSdlWindow(w: SdlWindow, r: view.Rect) =
210210
if w.sdlGlContext == nil:
211211
error "Could not create context!"
212212
discard glMakeCurrent(w.impl, w.sdlGlContext)
213-
w.gfx = newGraphicsContext()
213+
w.gfx = if gfx.isNil: newGraphicsContext() else: gfx
214214

215215
mainApplication().addWindow(w)
216216
discard w.impl.setData("__nimx_wnd", cast[pointer](w))
217217

218218
method init*(w: SdlWindow, gfx: GraphicsContext, r: view.Rect) =
219-
w.initSdlWindow(r)
219+
w.initSdlWindow(gfx, r)
220220
let r = w.getOsWindowFrame()
221221
procCall w.Window.init(w.gfx, r)
222222
w.onResize(r.size)
@@ -241,9 +241,10 @@ proc newSdlWindow*(r: view.Rect): SdlWindow =
241241
newSdlWindow(nil, r)
242242

243243
method show*(w: SdlWindow)=
244-
if w.impl.isNil:
245-
w.initSdlWindow(w.frame)
246-
w.setFrameOrigin zeroPoint
244+
assert not w.impl.isNil
245+
# if w.impl.isNil:
246+
# w.initSdlWindow(w.frame)
247+
# w.setFrameOrigin zeroPoint
247248

248249
w.impl.showWindow()
249250
w.impl.raiseWindow()

0 commit comments

Comments
 (0)