Layout

We'll begin with the basic application layout; to start with, we update our draw() function to call a separate drawLayout() function where we'll add our new code. This new function will need to be passed the height of the window to correctly fill the vertical space, as you'll see later:

func draw(win *glfw.Window, ctx *nk.Context) {
nk.NkPlatformNewFrame()
width, height := win.GetSize()
bounds := nk.NkRect(0, 0, float32(width), float32(height))
update := nk.NkBegin(ctx, "", bounds, nk.WindowNoScrollbar)

if update > 0 {
drawLayout(win, ctx, height)
}
nk.NkEnd(ctx)

gl.Viewport(0, 0, int32(width), int32(height))
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.ClearColor(0x10, 0x10, 0x10, 0xff)
nk.NkPlatformRender(nk.AntiAliasingOn, 512 * 1024, 128 * 1024)
}

The preceding code is fairly standard for painting a window with nk. Let's jump straight into our new layout code.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.19.174