work towards getting imgui properly working in viewer
This commit is contained in:
parent
676610386d
commit
0e1e1a51f0
@ -60,7 +60,6 @@ func Init() error {
|
||||
io.KeyMap(imguiKey, nativeKey)
|
||||
}
|
||||
|
||||
singleton.fontTexture = createFontTexture()
|
||||
singleton.isInit = true
|
||||
|
||||
return nil
|
||||
@ -87,6 +86,10 @@ func NewFrame(windowSize math.Vec2i) error {
|
||||
return ErrWasNotInit
|
||||
}
|
||||
|
||||
if singleton.fontTexture == 0 {
|
||||
singleton.fontTexture = createFontTexture()
|
||||
}
|
||||
|
||||
// Setup display size (every frame to accommodate for window resizing)
|
||||
io := imgui.CurrentIO()
|
||||
io.SetDisplaySize(imgui.Vec2{X: float32(windowSize.X), Y: float32(windowSize.Y)})
|
||||
|
@ -70,6 +70,21 @@ func Shutdown() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func CreateWindow(title string, width, height int, scene Scene) (*Window, error) {
|
||||
if !state.isInit {
|
||||
return nil, ErrWasNotInit
|
||||
}
|
||||
|
||||
window, err := newWindow(title, width, height, scene)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
state.windows = append(state.windows, window)
|
||||
|
||||
return window, err
|
||||
}
|
||||
|
||||
func ProcessEvents() error {
|
||||
if !state.isInit {
|
||||
return ErrWasNotInit
|
||||
@ -91,21 +106,6 @@ func ProcessEvents() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func CreateWindow(title string, width, height int, scene Scene) (*Window, error) {
|
||||
if !state.isInit {
|
||||
return nil, ErrWasNotInit
|
||||
}
|
||||
|
||||
window, err := newWindow(title, width, height, scene)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
state.windows = append(state.windows, window)
|
||||
|
||||
return window, err
|
||||
}
|
||||
|
||||
func advanceWindows() {
|
||||
for _, window := range state.windows {
|
||||
window.advance()
|
||||
|
@ -29,13 +29,13 @@ func newWindow(title string, width, height int, scene Scene) (*Window, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sdlGlContext, err := sdlWindow.GLCreateContext()
|
||||
sdlRenderer, err := sdl.CreateRenderer(sdlWindow, -1, sdl.RENDERER_ACCELERATED)
|
||||
if err != nil {
|
||||
sdlWindow.Destroy()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sdlRenderer, err := sdl.CreateRenderer(sdlWindow, -1, sdl.RENDERER_ACCELERATED)
|
||||
sdlGlContext, err := sdlWindow.GLCreateContext()
|
||||
if err != nil {
|
||||
sdlWindow.Destroy()
|
||||
return nil, err
|
||||
@ -83,7 +83,9 @@ func (w *Window) RenderTexture(texture *Texture, srcRect, dstRect math.Rect4i) {
|
||||
func (w *Window) advance() {
|
||||
imgui_backend.NewFrame(w.displaySize())
|
||||
w.scene.Advance(w)
|
||||
|
||||
imgui.Render()
|
||||
|
||||
w.sdlWindow.GLMakeCurrent(w.sdlGlContext)
|
||||
imgui_backend.Render(w.displaySize(), w.bufferSize(), imgui.RenderedDrawData())
|
||||
w.sdlWindow.GLSwap()
|
||||
|
Loading…
Reference in New Issue
Block a user