golang-ui / nuklear

This project provides Go bindings for nuklear.h — a small ANSI C GUI library.
https://github.com/vurtun/nuklear
MIT License
1.57k stars 98 forks source link

SDL2 build failure #84

Closed kondratev closed 4 years ago

kondratev commented 4 years ago

Environment: $ env | grep GO111MODULE

GO111MODULE=on

$ go version

go version go1.13.6 linux/amd64

$ git log --pretty=oneline | head -n1

f0bd027f267b002b45310df19d1b1191932cf884 Update nuklear to 4.01.0 and add clipboard support for GLFW_GL3. (#81)

$ git branch

* master

Build: $ cd cmd/nk-example-sdl2/ $ go build -tags sdl2 main.go

go: finding github.com/xlab/closer latest
go: finding github.com/go-gl/gl latest
go: finding github.com/golang-ui/nuklear latest
# command-line-arguments
./main.go:57:48: undefined: MustAsset
./main.go:111:37: undefined: flag
./main.go:114:37: undefined: flag
./main.go:131:19: cannot use nk.NkColorPicker(ctx, state.bgColor, nk.ColorFormatRGBA) (type nk.Colorf) as type nk.Color in assignment
./main.go:131:48: cannot use state.bgColor (type nk.Color) as type nk.Colorf in argument to nk.NkColorPicker
kondratev commented 4 years ago

this fix a sdl build

diff --git a/cmd/nk-example-sdl2/main.go b/cmd/nk-example-sdl2/main.go
index 4c0243b..011e675 100644
--- a/cmd/nk-example-sdl2/main.go
+++ b/cmd/nk-example-sdl2/main.go
@@ -128,7 +128,9 @@ func gfxMain(win *sdl.Window, ctx *nk.Context, state *State) {
                        size := nk.NkVec2(nk.NkWidgetWidth(ctx), 400)
                        if nk.NkComboBeginColor(ctx, state.bgColor, size) > 0 {
                                nk.NkLayoutRowDynamic(ctx, 120, 1)
-                               state.bgColor = nk.NkColorPicker(ctx, state.bgColor, nk.ColorFormatRGBA)
+                               cf := nk.NkColorCf(state.bgColor)
+                               cf = nk.NkColorPicker(ctx, cf, nk.ColorFormatRGBA)
+                               state.bgColor = nk.NkRgbCf(cf)
                                nk.NkLayoutRowDynamic(ctx, 25, 1)
                                r, g, b, a := state.bgColor.RGBAi()
                                r = nk.NkPropertyi(ctx, "#R:", 0, r, 255, 1, 1)
swathinsankaran commented 4 years ago

Hi,

I am getting the same error. Is there any workaround for this?

Error: ./main.go:112:37: undefined: flag ./main.go:115:37: undefined: flag

Regards, Swathin

xlab commented 4 years ago

@kondratev @swathins079 you should not build main.go only, the package has other files as well, including util.go

Build the binary:

go build -tags sdl2 github.com/golang-ui/nuklear/cmd/nk-example-sdl2

or install:

go install -tags sdl2 github.com/golang-ui/nuklear/cmd/nk-example-sdl2