remove unnecessary context creation

This commit is contained in:
Alex Yatskov 2018-12-29 22:18:48 -08:00
parent 8ab9c5e1ce
commit caf1aac6e6

View File

@ -10,10 +10,9 @@ import (
) )
type Window struct { type Window struct {
sdlWindow *sdl.Window sdlWindow *sdl.Window
sdlGlContext sdl.GLContext sdlRenderer *sdl.Renderer
sdlRenderer *sdl.Renderer scene Scene
scene Scene
} }
func newWindow(title string, width, height int, scene Scene) (*Window, error) { func newWindow(title string, width, height int, scene Scene) (*Window, error) {
@ -35,13 +34,7 @@ func newWindow(title string, width, height int, scene Scene) (*Window, error) {
return nil, err return nil, err
} }
sdlGlContext, err := sdlWindow.GLCreateContext() window := &Window{sdlWindow, sdlRenderer, scene}
if err != nil {
sdlWindow.Destroy()
return nil, err
}
window := &Window{sdlWindow, sdlGlContext, sdlRenderer, scene}
if err := scene.Init(window); err != nil { if err := scene.Init(window); err != nil {
return nil, err return nil, err
} }
@ -62,7 +55,6 @@ func (w *Window) Destroy() error {
return err return err
} }
w.sdlGlContext = nil
w.sdlWindow = nil w.sdlWindow = nil
return nil return nil
@ -86,7 +78,6 @@ func (w *Window) advance() {
w.scene.Advance(w) w.scene.Advance(w)
w.sdlWindow.GLMakeCurrent(w.sdlGlContext)
imgui.Render() imgui.Render()
imgui_backend.Render(w.displaySize(), w.bufferSize(), imgui.RenderedDrawData()) imgui_backend.Render(w.displaySize(), w.bufferSize(), imgui.RenderedDrawData())
w.sdlWindow.GLSwap() w.sdlWindow.GLSwap()