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