get imgui properly running in viewer

This commit is contained in:
Alex Yatskov 2018-12-29 17:04:37 -08:00
parent 0e1e1a51f0
commit 723f55186b
3 changed files with 6 additions and 3 deletions

View File

@ -299,7 +299,7 @@ func createFontTexture() uint32 {
// Store our identifier // Store our identifier
io.Fonts().SetTextureID(imgui.TextureID(fontTexture)) io.Fonts().SetTextureID(imgui.TextureID(fontTexture))
// Restore singleton // Restore state
gl.BindTexture(gl.TEXTURE_2D, uint32(lastTexture)) gl.BindTexture(gl.TEXTURE_2D, uint32(lastTexture))
return fontTexture return fontTexture
} }

View File

@ -82,11 +82,11 @@ 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.sdlRenderer.Clear()
w.scene.Advance(w) w.scene.Advance(w)
imgui.Render() imgui.Render()
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()
} }

View File

@ -5,6 +5,7 @@ import (
"log" "log"
"os" "os"
imgui "github.com/FooSoft/imgui-go"
"github.com/FooSoft/lazarus/formats/dat" "github.com/FooSoft/lazarus/formats/dat"
"github.com/FooSoft/lazarus/formats/dc6" "github.com/FooSoft/lazarus/formats/dc6"
"github.com/FooSoft/lazarus/math" "github.com/FooSoft/lazarus/math"
@ -62,6 +63,8 @@ func (s *scene) Init(window *platform.Window) error {
} }
func (s *scene) Advance(window *platform.Window) error { func (s *scene) Advance(window *platform.Window) error {
imgui.Text("Hello")
window.RenderTexture( window.RenderTexture(
s.texture, s.texture,
math.Rect4i{X: 0, Y: 0, W: 256, H: 256}, math.Rect4i{X: 0, Y: 0, W: 256, H: 256},