golang-ui / nuklear Goto Github PK
View Code? Open in Web Editor NEWThis project provides Go bindings for nuklear.h — a small ANSI C GUI library.
Home Page: https://github.com/vurtun/nuklear
License: MIT License
This project provides Go bindings for nuklear.h — a small ANSI C GUI library.
Home Page: https://github.com/vurtun/nuklear
License: MIT License
Hey guys!
Initial spec:
So I've got MinGW and Go as checked versions here:
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-6.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --target=mingw32 --with-gmp=/mingw --with-mpfr --with-mpc=/mingw --with-isl=/mingw --prefix=/mingw --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-6.3.0-1' --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --enable-libgomp --disable-libvtv --enable-nls
Thread model: win32
gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)go version
go version go1.9.2 windows/amd64
However, when I run the go install github.com/golang-ui/nuklear/nk
or even using go get
it throws this error:
go install github.com/golang-ui/nuklear/nk
github.com/go-gl/glfw/v3.2/glfw
cc1.exe: sorry, unimplemented: 64-bit mode not compiled in
github.com/go-gl/gl/v3.2-core/gl
cc1.exe: sorry, unimplemented: 64-bit mode not compiled in
go get github.com/golang-ui/nuklear/nk
github.com/go-gl/glfw/v3.2/glfw
cc1.exe: sorry, unimplemented: 64-bit mode not compiled in
github.com/go-gl/gl/v3.2-core/gl
cc1.exe: sorry, unimplemented: 64-bit mode not compiled in
How can I resolve this issue?
Hey,
I wanted to alter the spacing of my custom widgets in a small application of mine and found out that there are no setter and getter for this. So I simply created my own ones. Is it in your interest to include those into the main project or don't you want any of those as there would be a lot variables that can only be accessed by adding custom setter and getter?
Maybe I also overlooked a function giving me control of the spacing. The code I inserted in etc.go
is simply this:
func (w *StyleWindow) Spacing() *Vec2 {
return (*Vec2)(&w.spacing)
}
func (w *StyleWindow) Padding() *Vec2 {
return (*Vec2)(&w.padding)
}
func (w *StyleWindow) GroupPadding() *Vec2 {
return (*Vec2)(&w.group_padding)
}
func SetSpacing(ctx *Context, v Vec2) {
*ctx.Style().Window().Spacing() = v
}
func SetPadding(ctx *Context, v Vec2) {
*ctx.Style().Window().Padding() = v
}
func SetGroupPadding(ctx *Context, v Vec2) {
*ctx.Style().Window().GroupPadding() = v
}
Thanks
I am trying to do a build of the example, but got a small issue
x-MacBook-Pro:nk-example apple$ pwd
/Users/apple/workspace/go/src/github.com/golang-ui/nuklear/cmd/nk-example
x-MacBook-Pro:nk-example apple$ go run main.go
# github.com/golang-ui/nuklear/nk
ld: library not found for -lglfw3
clang: error: linker command failed with exit code 1 (use -v to see invocation)
so, i tried to do a build form root, but make fails because it cant find cgogen.
where can i get cgogen ?
x-MacBook-Pro:nuklear apple$ pwd
/Users/apple/workspace/go/src/github.com/golang-ui/nuklear
x-MacBook-Pro:nuklear apple$ make
cgogen nk.yml
make: cgogen: No such file or directory
make: *** [all] Error 1
__
Also i checked that glfw works so we knows that good.
x-MacBook-Pro:nuklear apple$ cd $GOPATH/src/github.com/go-gl/glfw/v3.2/glfw
x-MacBook-Pro:glfw apple$ pwd
/Users/apple/workspace/go/src/github.com/go-gl/glfw/v3.2/glfw
x-MacBook-Pro:glfw apple$ ls
GLFW_C_REVISION.txt c_glfw_windows.go glfw.go native_darwin.go vulkan.go
build.go context.go input.c native_linbsd.go window.c
c_glfw.go error.c input.go native_windows.go window.go
c_glfw_darwin.go error.go monitor.c time.go
c_glfw_linbsd.go glfw monitor.go util.go
x-MacBook-Pro:glfw apple$ go get -u github.com/go-gl/glfw/v3.2/glfw
x-MacBook-Pro:glfw apple$ pwd
/Users/apple/workspace/go/src/github.com/go-gl/glfw/v3.2/glfw
x-MacBook-Pro:glfw apple$ cd ..
x-MacBook-Pro:v3.2 apple$ pwd
/Users/apple/workspace/go/src/github.com/go-gl/glfw/v3.2
x-MacBook-Pro:v3.2 apple$ cd ..
x-MacBook-Pro:glfw apple$ pwd
/Users/apple/workspace/go/src/github.com/go-gl/glfw
x-MacBook-Pro:glfw apple$ code .
x-MacBook-Pro:glfw apple$ go run main.go
x-MacBook-Pro:glfw apple$ WORKS ! Can see blank screen...
Hiya! I'm getting an issue when trying to go get this:
go get github.com/golang-ui/nuklear/nk
# github.com/go-gl/glfw/v3.2/glfw
In file included from C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glf
w/glfw/src/win32_init.c:33:0,
from C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glf
w\c_glfw_windows.go:4:
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_init.
c:34:13: warning: 'GUID_DEVINTERFACE_HID' initialized and declared 'extern'
DEFINE_GUID(GUID_DEVINTERFACE_HID,0x4d1e55b2,0xf16f,0x11cf,0x88,0xcb,0x00,0x11,
0x11,0x00,0x00,0x30);
^
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_joyst
ick.c:57:13: warning: 'IID_IDirectInput8W' initialized and declared 'extern'
DEFINE_GUID(IID_IDirectInput8W,0xbf798031,0x483a,0x4da2,0xaa,0x99,0x5d,0x64,0xe
d,0x36,0x97,0x00);
^
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_joyst
ick.c:58:13: warning: 'GUID_XAxis' initialized and declared 'extern'
DEFINE_GUID(GUID_XAxis,0xa36d02e0,0xc9f3,0x11cf,0xbf,0xc7,0x44,0x45,0x53,0x54,0
x00,0x00);
^
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_joyst
ick.c:59:13: warning: 'GUID_YAxis' initialized and declared 'extern'
DEFINE_GUID(GUID_YAxis,0xa36d02e1,0xc9f3,0x11cf,0xbf,0xc7,0x44,0x45,0x53,0x54,0
x00,0x00);
^
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_joyst
ick.c:60:13: warning: 'GUID_ZAxis' initialized and declared 'extern'
DEFINE_GUID(GUID_ZAxis,0xa36d02e2,0xc9f3,0x11cf,0xbf,0xc7,0x44,0x45,0x53,0x54,0
x00,0x00);
^
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_joyst
ick.c:61:13: warning: 'GUID_RxAxis' initialized and declared 'extern'
DEFINE_GUID(GUID_RxAxis,0xa36d02f4,0xc9f3,0x11cf,0xbf,0xc7,0x44,0x45,0x53,0x54,
0x00,0x00);
^
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_joyst
ick.c:62:13: warning: 'GUID_RyAxis' initialized and declared 'extern'
DEFINE_GUID(GUID_RyAxis,0xa36d02f5,0xc9f3,0x11cf,0xbf,0xc7,0x44,0x45,0x53,0x54,
0x00,0x00);
^
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_joyst
ick.c:63:13: warning: 'GUID_RzAxis' initialized and declared 'extern'
DEFINE_GUID(GUID_RzAxis,0xa36d02e3,0xc9f3,0x11cf,0xbf,0xc7,0x44,0x45,0x53,0x54,
0x00,0x00);
^
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_joyst
ick.c:64:13: warning: 'GUID_Slider' initialized and declared 'extern'
DEFINE_GUID(GUID_Slider,0xa36d02e4,0xc9f3,0x11cf,0xbf,0xc7,0x44,0x45,0x53,0x54,
0x00,0x00);
^
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_joyst
ick.c:65:13: warning: 'GUID_Button' initialized and declared 'extern'
DEFINE_GUID(GUID_Button,0xa36d02f0,0xc9f3,0x11cf,0xbf,0xc7,0x44,0x45,0x53,0x54,
0x00,0x00);
^
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_joyst
ick.c:66:13: warning: 'GUID_POV' initialized and declared 'extern'
DEFINE_GUID(GUID_POV,0xa36d02f2,0xc9f3,0x11cf,0xbf,0xc7,0x44,0x45,0x53,0x54,0x0
0,0x00);
^
In file included from C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glf
w\c_glfw_windows.go:9:0:
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_windo
w.c: In function 'updateCursorImage':
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_windo
w.c:259:41: warning: passing argument 2 of 'LoadCursorW' from incompatible point
er type [-Wincompatible-pointer-types]
SetCursor(LoadCursorW(NULL, IDC_ARROW));
^~~~~~~~~
In file included from c:\mingw\include\windows.h:48:0,
from C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glf
w/glfw/src/win32_platform.h:68,
from C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glf
w/glfw/src/internal.h:167,
from C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glf
w/glfw/src/win32_init.c:28,
from C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glf
w\c_glfw_windows.go:4:
c:\mingw\include\winuser.h:3999:27: note: expected 'LPCWSTR {aka const short uns
igned int *}' but argument is of type 'CHAR * {aka char *}'
WINUSERAPI HCURSOR WINAPI LoadCursorW (HINSTANCE, LPCWSTR);
^~~~~~~~~~~
In file included from C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glf
w\c_glfw_windows.go:9:0:
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_windo
w.c: In function 'translateCursorShape':
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_windo
w.c:288:20: warning: return from incompatible pointer type [-Wincompatible-point
er-types]
return IDC_ARROW;
^~~~~~~~~
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_windo
w.c:290:20: warning: return from incompatible pointer type [-Wincompatible-point
er-types]
return IDC_IBEAM;
^~~~~~~~~
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_windo
w.c:292:20: warning: return from incompatible pointer type [-Wincompatible-point
er-types]
return IDC_CROSS;
^~~~~~~~~
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_windo
w.c:294:20: warning: return from incompatible pointer type [-Wincompatible-point
er-types]
return IDC_HAND;
^~~~~~~~
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_windo
w.c:296:20: warning: return from incompatible pointer type [-Wincompatible-point
er-types]
return IDC_SIZEWE;
^~~~~~~~~~
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_windo
w.c:298:20: warning: return from incompatible pointer type [-Wincompatible-point
er-types]
return IDC_SIZENS;
^~~~~~~~~~
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_windo
w.c: In function '_glfwRegisterWindowClassWin32':
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_windo
w.c:948:42: warning: passing argument 2 of 'LoadCursorW' from incompatible point
er type [-Wincompatible-pointer-types]
wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
^~~~~~~~~
In file included from c:\mingw\include\windows.h:48:0,
from C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glf
w/glfw/src/win32_platform.h:68,
from C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glf
w/glfw/src/internal.h:167,
from C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glf
w/glfw/src/win32_init.c:28,
from C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glf
w\c_glfw_windows.go:4:
c:\mingw\include\winuser.h:3999:27: note: expected 'LPCWSTR {aka const short uns
igned int *}' but argument is of type 'CHAR * {aka char *}'
WINUSERAPI HCURSOR WINAPI LoadCursorW (HINSTANCE, LPCWSTR);
^~~~~~~~~~~
In file included from C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glf
w\c_glfw_windows.go:9:0:
C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_windo
w.c:959:31: warning: passing argument 2 of 'LoadImageW' from incompatible pointe
r type [-Wincompatible-pointer-types]
IDI_APPLICATION, IMAGE_ICON,
^~~~~~~~~~~~~~~
In file included from c:\mingw\include\windows.h:48:0,
from C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glf
w/glfw/src/win32_platform.h:68,
from C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glf
w/glfw/src/internal.h:167,
from C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glf
w/glfw/src/win32_init.c:28,
from C:\Users\Claudia\dev\go\src\github.com\go-gl\glfw\v3.2\glf
w\c_glfw_windows.go:4:
c:\mingw\include\winuser.h:4011:26: note: expected 'LPCWSTR {aka const short uns
igned int *}' but argument is of type 'CHAR * {aka char *}'
WINUSERAPI HANDLE WINAPI LoadImageW (HINSTANCE, LPCWSTR, UINT, int, int, UINT);
^~~~~~~~~~
I'm also getting a similar problem when downloading manually as zip and trying to go install
Hi,
Seems like I'm responsible for the recent 2.0.0 version bump in Nuklear (vurtun/nuklear#517) :|
So, when would an update of the bindings to 2.0.0 feasible? The problem is that 2.0.0 introduces breaking API changes.
I could cook up a PR for the required changes if wanted. But I don't see any way to gracefully handle the breaking API change.
Hi, @xlab
I did:
And got:
go-bindata -pkg main templates/
make: go-bindata: Command not found
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 127
Please, HELP!!
When calling nk.NkEditString (or NkEditStringZeroTerminated) the nuklear wrapper will send the underlying slice Data out to C, but it never updates the length of the buffer. So if the user edits the string in the editbox, the buffer that the Go code has will always have the same length and won't update properly.
A quick hack that I created to get around the problem is to wrap the function and return a new string from the buffer (which could be improved to only create the string when necessary, but this was just a proof of concept).
func editString(ctx *nk.Context, flags nk.Flags, bufferStr string, filter nk.PluginFilter) (string, nk.Flags) {
const extraBuffer = 64
len := int32(len(bufferStr))
max := len + extraBuffer
haxBuffer := make([]byte, 0, max)
haxBuffer = append(haxBuffer, bufferStr...)
retflags := nk.NkEditStringZeroTerminated(ctx, flags, haxBuffer, max, filter)
rawData := (*C.char)(unsafe.Pointer((*reflect.SliceHeader)(unsafe.Pointer(&haxBuffer)).Data))
return C.GoString(rawData), retflags
}
Hi,
when go build
ing nk-example
on Win10 64 bits using go 1.8.3, the following error log appears:
C:\Go\PATH\src\github.com\golang-ui\nuklear\cmd\nk-example>go build
# github.com/golang-ui/nuklear/cmd/nk-example
C:\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
C:\Users\Saad\AppData\Local\Temp\go-link-061616495\000001.o: In function `glfwSwapBuffers':
C:\Go\PATH\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/context.c:609: undefined reference to `__assert_func'
C:\Users\Saad\AppData\Local\Temp\go-link-061616495\000001.o: In function `glfwExtensionSupported':
C:\Go\PATH\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/context.c:642: undefined reference to `__assert_func'
C:\Users\Saad\AppData\Local\Temp\go-link-061616495\000001.o: In function `glfwGetProcAddress':
C:\Go\PATH\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/context.c:707: undefined reference to `__assert_func'
C:\Users\Saad\AppData\Local\Temp\go-link-061616495\000001.o: In function `glfwGetInputMode':
C:\Go\PATH\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/input.c:153: undefined reference to `__assert_func'
C:\Users\Saad\AppData\Local\Temp\go-link-061616495\000001.o: In function `glfwSetInputMode':
C:\Go\PATH\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/input.c:174: undefined reference to `__assert_func'
C:\Users\Saad\AppData\Local\Temp\go-link-061616495\000001.o:C:\Go\PATH\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/input.c:262: more undefined references to `__assert_func' follow
C:\Users\Saad\AppData\Local\Temp\go-link-061616495\000002.o: In function `_cgo_2daa1da745f8_C2func_calloc':
/c/Go/PATH/src/github.com/golang-ui/nuklear/nk/cgo-gcc-prolog:42: undefined reference to `__errno'
/c/Go/PATH/src/github.com/golang-ui/nuklear/nk/cgo-gcc-prolog:44: undefined reference to `__errno'
C:\Users\Saad\AppData\Local\Temp\go-link-061616495\000002.o: In function `nk_insert_window':
C:\Go\PATH\src\github.com\golang-ui\nuklear\nk/nuklear.h:18401: undefined reference to `__assert_func'
C:\Go\PATH\src\github.com\golang-ui\nuklear\nk/nuklear.h:18402: undefined reference to `__assert_func'
C:\Go\PATH\src\github.com\golang-ui\nuklear\nk/nuklear.h:18396: undefined reference to `__assert_func'
C:\Go\PATH\src\github.com\golang-ui\nuklear\nk/nuklear.h:18395: undefined reference to `__assert_func'
C:\Users\Saad\AppData\Local\Temp\go-link-061616495\000002.o: In function `nk_do_button':
C:\Go\PATH\src\github.com\golang-ui\nuklear\nk/nuklear.h:14036: undefined reference to `__assert_func'
C:\Users\Saad\AppData\Local\Temp\go-link-061616495\000002.o:C:\Go\PATH\src\github.com\golang-ui\nuklear\nk/nuklear.h:14038: more undefined references to `__assert_func' follow
collect2.exe: error: ld returned 1 exit status
go version go1.8.3 windows/amd64
>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-7.1.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,objc,obj-c++,fortran,ada --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev2, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld
Thread model: posix
gcc version 7.1.0 (Rev2, Built by MSYS2 project)
I'm attempting to write an interactive scatter plot graph. Currently I don't see a chart type for it yet, hence i'm trying draw the dots/data points on a canvas. However I found difficulties in rendering many dots.
a) There are occasional glitches when trying to render many elements. My code below is mostly based on cmd/nk-example/main.go with the gfxmain()
containing below loop
if nk.NkBegin(ctx, "Title", bounds, nk.WindowTitle|nk.WindowNoScrollbar) > 0 {
canvas := nk.NkWindowGetCanvas(ctx)
for fy := 50; fy <= 450; fy += 10 {
for fx := 50; fx <= 450; fx += 10 {
c1 := nk.NkRect(float32(fx), float32(fy), 5.0, 5.0)
nk.NkFillCircle(canvas, c1, nk.NkRgb(171, 239, 29))
}
}
}
nk.NkEnd(ctx)
I found a related vurtun/nuklear/issue 419, but failed to find the equivalent control for glDrawElements
through the go binding.
b) The number of dots that can be drawn are restricted by the value of maxVertexBuffer
and maxElementBuffer
. The scatter plot application wouldn't know the data (how many dots would be).
Is there an example on how to solve the above points ? or perhaps advice or suggestions on what should I do ?
I'm not an expert in GL, only knows basic concepts along with some experience in Qt.
I'd appreciate any help, thank you.
Full test case here: https://gist.github.com/wolfgang42/07e8a2677c7f6e36393bdca862bebac2
From reading runtime/cgo.go
it looks like somehow the nuklear bindings have gotten into some kind of can't happen state, but I don't know enough about how any of this works to be able to figure out how this could happen.
I have been unable to determine how to get text entry input widget working. I have been looking at the functions in nk.go and their return types but haven't got very far (widget doesn't display).
te := nk.NewTextEdit()
nk.NkTexteditText(te, "foo", 100)
I understand the documentation is limited. I don't understand C code so reading through the nuklear.h file was difficult.
I just need a text entry field to send some arguments to a go program. I have got the buttons working.
Also is there a way to display scrolling text like the output of a terminal window?
Any pointers would be most appreciated! I was very excited to use this library after trying for a few days to get it running on FreeBSD.
Hey,
So, this is might not be this libary's problem, although, it might need some additional functions to expose more things, such as a func (p *Panel) IsClosed().
But the owner of the other repo doesn't seem all that active, so I thought I post here too as you are more active and could possible help me out.
So, what say you about this: vurtun/nuklear#361 ?
Thanks!
I have the possibility to use table? I can not find anything.
I'm trying to develop an small program that normally has one small control window, but might open up larger temporary windows for more complex and context dependent situations.
However at present the closet I can get is an error like:
github.com/golang-ui/nuklear/nk/nuklear.h:18633: nk_begin_titled: Assertion `win->seq != ctx->seq' failed.
signal: aborted (core dumped)
** (extra at end)
From that error and the documentation it references I know I'm /somehow/ supposed to manage application state... however it's unclear how to do that. As far as I can tell after a few hours of searching, there's something that either I've missed, or that doesn't yet exist in the golang-ui/nuklear library for switching or passing it a context state.
impl_glfw_gl3.go line 260 defines a package global variable...
var state = &platformState{
ogl: &platformDevice{},
}
Which impl_glfw_common.go (27) NkPlatformInit assigns the window and a created state to, as well as calling NkInitDefault (that calls the underlying nk_init_default library binding) that initializes the nuklear context for the window as well.
The structure NkPlatformInit and that single global state heavily suggests that I can't actually have multiple distinct OS level windows. I don't think that's necessarily a limitation of the underlying Nuklear library, but it seems like it might require a major refactoring of this library to use it in a multiple contexts friendly way. Previously I've used higher level frameworks that make such architectural decisions for me, so I'm not even sure if multiple contexts is a good idea.
// near github.com/golang-ui/nuklear/nk/nuklear.h:18633
/* update window */
win->flags &= ~(nk_flags)(NK_WINDOW_PRIVATE-1);
win->flags |= flags;
if (!(win->flags & (NK_WINDOW_MOVABLE | NK_WINDOW_SCALABLE)))
win->bounds = bounds;
/* If this assert triggers you either:
*
* I.) Have more than one window with the same name or
* II.) You forgot to actually draw the window.
* More specific you did not call `nk_clear` (nk_clear will be
* automatically called for you if you are using one of the
* provided demo backends). */
NK_ASSERT(win->seq != ctx->seq);
win->seq = ctx->seq;
if (!ctx->active && !(win->flags & NK_WINDOW_HIDDEN)) {
ctx->active = win;
ctx->end = win;
}
Getting this build error,
C:\Program Files (x86)\Console2>go get github.com/golang-ui/nuklear/cmd/nk-example
/# github.com/go-gl/glfw/v3.2/glfw
In file included from C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw\c_glfw_windows.go:6:0:
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c: In function 'createMonitor':
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:68:5: warning: implicit declaration of function 'wcscpy' [-Wimplicit-function-declaration]
wcscpy(monitor->win32.adapterName, adapter->DeviceName);
^~~~~~
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c: In function '_glfwPlatformIsSameMonitor':
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:228:9: warning: implicit declaration of function 'wcslen' [-Wimplicit-function-declaration]
if (wcslen(first->win32.displayName))
^~~~~~
C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:229:16: warning: implicit declaration of function 'wcscmp' [-Wimplicit-function-declaration]
return wcscmp(first->win32.displayName, second->win32.displayName) == 0;
^~~~~~
/# github.com/golang-ui/nuklear/cmd/nk-example
C:\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
C:\Users\Martin\AppData\Local\Temp\go-link-052590467\go.o: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
GCC:
C:\Program Files (x86)\Console2>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-6.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --target=mingw32 --with-gmp=/mingw --with-mpfr --with-mpc=/mingw --with-isl=/mingw --prefix=/mingw --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-6.3.0-1' --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --enable-libgomp --disable-libvtv --enable-nls
Thread model: win32
gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)
Go:
C:\Program Files (x86)\Console2>go version
go version go1.10.3 windows/amd64
Hi there,
I am developing an app in golang and using nice library nuklear. But when i styling window of my app etc background color, i can not set background color. I want to use ctx->style.window.background example. But in golang has not same code. I try ctx.Style() , but this code not continue about background. Could you add styling code in golang, ASAP or Can you help me? I am waiting for this.
Thanks for this Go wrapper, it is awesome.
I am trying to change the drawing logic in order to achieve better performance in a simple desktop application. I would like to limit the GL draw calls to actual user interactions or render buffer changes. In the c nuklear documentation I see that it is possible by defining NK_ZERO_COMMAND_MEMORY
and by comparing the last draw commands with the new ones, using memcmp
and memcpy
.
Here's my attempt at it, by modifying impl_glfw_gl3.go
:
NK_ZERO_COMMAND_MEMORY
definition:
#define NK_IMPLEMENTATION
#define NK_GLFW_GL3_IMPLEMENTATION
#define NK_ZERO_COMMAND_MEMORY
#include "nuklear.h"
*/
import "C"
memcmp
and memcpy
wrappers:
func memcmp(arg0 *Buffer, arg1 *Buffer, csize _Ctype_ulonglong) int32 {
carg0, _ := (unsafe.Pointer(arg0)), cgoAllocsUnknown
carg1, _ := (unsafe.Pointer(arg1)), cgoAllocsUnknown
cresu, _ := C.memcmp(carg0, carg1, csize)
return int32(cresu)
}
func memcpy(arg0 *Buffer, arg1 *Buffer, csize _Ctype_ulonglong) {
carg0, _ := (unsafe.Pointer(arg0)), cgoAllocsUnknown
carg1, _ := (unsafe.Pointer(arg1)), cgoAllocsUnknown
C.memcpy(carg0, carg1, csize)
}
Definition of a buffer for the last frame commands:
type platformDevice struct {
cmds *Buffer
lastCmds *Buffer
...
Initialization:
func deviceCreate() {
dev := state.ogl
dev.cmds = NewBuffer()
NkBufferInitDefault(dev.cmds)
dev.lastCmds = NewBuffer()
NkBufferInitDefault(dev.lastCmds)
...
And finally, the comparison and copy in the NkPlatformRender
function:
gl.UnmapBuffer(gl.ARRAY_BUFFER)
gl.UnmapBuffer(gl.ARRAY_BUFFER)
gl.UnmapBuffer(gl.ELEMENT_ARRAY_BUFFER)
if memcmp(dev.cmds, dev.lastCmds, state.ctx.memory.allocated) != 0 {
memcpy(dev.lastCmds, dev.cmds, state.ctx.memory.allocated)
var offset uintptr
// iterate over and execute each draw command
NkDrawForeach(state.ctx, dev.cmds, func(cmd *DrawCommand) {
....
Unfortunately this doesn't look to work on the demo application... all I see is a blue background (the default color). I tried to debug and memcmp
returns -1
only the first time, then always 0
... weird.
Any thought about this attempt?
@strangebroadcasts we have a problem
macOS Sierra 10.12.1
go version go1.8 darwin/amd64
$ nk-example-sdl2
2017/03/28 13:38:58 SDL2: created window 400x500
panic: vert_shdr failed to compile
goroutine 1 [running, locked to thread]:
github.com/golang-ui/nuklear/nk.deviceCreate()
/Users/xlab/Documents/dev/go/src/github.com/golang-ui/nuklear/nk/impl_sdl2_gl3.go:150 +0x580
github.com/golang-ui/nuklear/nk.NkPlatformInit(0x461e8f0, 0x47d20c0, 0x1, 0x2)
/Users/xlab/Documents/dev/go/src/github.com/golang-ui/nuklear/nk/impl_sdl2_common.go:45 +0x91
main.main()
/Users/xlab/Documents/dev/go/src/github.com/golang-ui/nuklear/cmd/nk-example-sdl2/main.go:49 +0x3e6
Hi, @xlab
I went to cd $GOPATH/src/github.com/golang-ui/nuklear/cmd/nk-android
Did: make toolchain
And got:
/build/tools/make_standalone_toolchain.py
--api=21 --install-dir=/home/r3mb0/GoMobile/src/github.com/golang-ui/nuklear/cmd/nk-android/toolchain
--arch=arm --stl libc++
make: /build/tools/make_standalone_toolchain.py: Command not found
Makefile:9: recipe for target 'toolchain' failed
make: *** [toolchain] Error 127
Hi,
nk-example fails to run:
2017/05/09 23:18:26 APIUnavailable: EGL: Failed to get EGL display: One or more argument values are invalid
On Linux, with go 1.7... Is this a bug?
I tried to change the background color of a window:
ctx.style.window.background = nk.NkRgb(0,120,215)
and when building, Golang stopped with an error saying that style
was not exported.
I'm not sure how you would go about this in cgogen, but I think that the underlying c structs in nuklear.h need to be extracted or modified in some way so that they are exported or capitalized.
So, if I want to build this (in Linux), how exactly should I make things work if I get this:
./main.go:48: undefined: nk.NkGLFW3Init
./main.go:48: undefined: nk.GLFW3InstallCallbacks
./main.go:51: undefined: nk.NkGLFW3FontStashBegin
./main.go:53: undefined: nk.NkGLFW3FontStashEnd
./main.go:72: undefined: nk.NkGLFW3Shutdown
./main.go:89: undefined: nk.NkGLFW3NewFrame
./main.go:138: undefined: nk.NkGLFW3Render
when running "go build" from the nk-example folder. Or, if I structure things "the Go way" in src folder.
$ go get github.com/golang-ui/nuklear/cmd/nk-example
$ nk-example
works fine. But I'm trying to set things up so I can build "the normal way", but I get the above annoyance. I do have the nk.go file in $GOPATH/src/github.com/golang-ui/nuklear/nk/ folder, and the nk.a file, but it's not found anyway for some reason... What am I missing here?
There is a problem with the handling of enter keys. The backend returns different codes for the normal enter key and the keypad enter key, but nuklear.h checks only one. This is very confusing. We can either change nuklear.h and check both, or we can modify impl_glfw_common.go to deliver the same code for both . Both are easy to do. Which way is best?
Looking at Nuklear and the godoc for this project I'd thought that perhaps I load images via the standard library's image.Image and then pass an unsafe pointer to the loaded struct but this doesn't seem to be the case.
I can't quite seem to find how it's done, how do you load and use images with these Go bindings?
I'm on Fedora 25 Linux and I needed to install a lot of development libraries and now, when I try to go get github.com/golang-ui/nuklear/nk
I'm getting the error:
# github.com/go-gl/glfw/v3.2/glfw
/usr/bin/ld: cannot find -lXi
collect2: error: ld returned 1 exit status
What am I missing?
This issue is similar to #30, but seems not to have with fonts to do. It fails either after some time, or while dragging the window (holding the mouse button down for >10 sec). This is on an Windows 10 PC.
Sometimes it fails only in the Goland debugger. Failures are either inside NkConvert() or inside NkLabel() and are typicaly "Exception 0xc0000005 0x8 0x0 0x0, PC=0x0, signal arrived during external code execution"
To provoke the error I usually have to add heavy network traffic over tcpip, and I have to use pictures. It improves if I move as much as possible of network handling etc outside the nk.NkPlatformNewFrame() and nk.NkEnd(ctx) pair.
The picture routines comes from the example in https://github.com/xlab/libvpx-go/blob/master/cmd/webm-player/view.go as I have not found any other information on how to include drawings/pictures in nuklear.
I have included an example that crashes consitently in my Goland debugger (but not when run as an exe) Debugging this kind of problems is extremely difficult, and if I can not get the Nukelar framework to work reliably, I have to drop it and find something else (which seems to be impossible).
Wanted to try this on Windows and after running:
go get github.com/golang-ui/nuklear/nk
it gave me:
# github.com/golang-ui/nuklear/nk
In file included from Go\src\github.com\golang-ui\nuklear\nk\cgo_helpers.go:11:0:
./nuklear_glfw_gl3.h:16:24: fatal error: GLFW/glfw3.h: No such file or directory
#include <GLFW/glfw3.h>
^
compilation terminated.
I have GLFW 3.2 for Go installed and I am using go1.7.3 windows/amd64. Also I have MinGW_x64 installed and added to path.
To troubleshoot I copied folder containing missing file:
%GOPATH%\src\github.com\go-gl\glfw\v3.2\glfw\glfw\include\GLFW
to nuklear folder:
%GOPATH%\src\github.com\golang-ui\nuklear\nk
and building started to throw those errors:
# github.com/golang-ui/nuklear/nk
In file included from Go\src\github.com\golang-ui\nuklear\nk\impl_glfw.go:16:0:
./nuklear_glfw_gl3.h: In function 'nk_glfw3_device_create':
./nuklear_glfw_gl3.h:94:18: error: unknown type name 'GLchar'
static const GLchar *vertex_shader =
^~~~~~
./nuklear_glfw_gl3.h:107:18: error: unknown type name 'GLchar'
static const GLchar *fragment_shader =
^~~~~~
./nuklear_glfw_gl3.h:121:37: error: 'GL_VERTEX_SHADER' undeclared (first use in
this function)
dev->vert_shdr = glCreateShader(GL_VERTEX_SHADER);
^~~~~~~~~~~~~~~~
./nuklear_glfw_gl3.h:121:37: note: each undeclared identifier is reported only o
nce for each function it appears in
./nuklear_glfw_gl3.h:122:37: error: 'GL_FRAGMENT_SHADER' undeclared (first use i
n this function)
dev->frag_shdr = glCreateShader(GL_FRAGMENT_SHADER);
^~~~~~~~~~~~~~~~~~
./nuklear_glfw_gl3.h:127:35: error: 'GL_COMPILE_STATUS' undeclared (first use in
this function)
glGetShaderiv(dev->vert_shdr, GL_COMPILE_STATUS, &status);
^~~~~~~~~~~~~~~~~
./nuklear_glfw_gl3.h:134:31: error: 'GL_LINK_STATUS' undeclared (first use in th
is function)
glGetProgramiv(dev->prog, GL_LINK_STATUS, &status);
^~~~~~~~~~~~~~
./nuklear_glfw_gl3.h:155:22: error: 'GL_ARRAY_BUFFER' undeclared (first use in t
his function)
glBindBuffer(GL_ARRAY_BUFFER, dev->vbo);
^~~~~~~~~~~~~~~
./nuklear_glfw_gl3.h:156:22: error: 'GL_ELEMENT_ARRAY_BUFFER' undeclared (first
use in this function)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dev->ebo);
^~~~~~~~~~~~~~~~~~~~~~~
./nuklear_glfw_gl3.h: In function 'nk_glfw3_render':
./nuklear_glfw_gl3.h:215:21: error: 'GL_FUNC_ADD' undeclared (first use in this
function)
glBlendEquation(GL_FUNC_ADD);
^~~~~~~~~~~
./nuklear_glfw_gl3.h:220:21: error: 'GL_TEXTURE0' undeclared (first use in this
function)
glActiveTexture(GL_TEXTURE0);
^~~~~~~~~~~
./nuklear_glfw_gl3.h:235:22: error: 'GL_ARRAY_BUFFER' undeclared (first use in t
his function)
glBindBuffer(GL_ARRAY_BUFFER, dev->vbo);
^~~~~~~~~~~~~~~
./nuklear_glfw_gl3.h:236:22: error: 'GL_ELEMENT_ARRAY_BUFFER' undeclared (first
use in this function)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dev->ebo);
^~~~~~~~~~~~~~~~~~~~~~~
./nuklear_glfw_gl3.h:238:64: error: 'GL_STREAM_DRAW' undeclared (first use in th
is function)
glBufferData(GL_ARRAY_BUFFER, max_vertex_buffer, NULL, GL_STREAM_DRAW);
^~~~~~~~~~~~~~
./nuklear_glfw_gl3.h:242:49: error: 'GL_WRITE_ONLY' undeclared (first use in thi
s function)
vertices = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
This project looks like what I need so please help me make it work.
Compiling the example with the OpenGl 2.1 backend works, but running the example results in a blank window. The background color is set, but no UI is drawn.
How to test:
v3.2-core
to v2.1
go build -tags opengl2
or go build -tags "sdl2,opengl2"
state.width and state.height are declared as ints, and are being assigned with a win.GetSize which return int32s
Hey!
Seems this nk_stroke_line isn't available in the Go API (nk_draw_list_stroke_line is though). I assume the nk.yml needs to be updated to include it as well?
There is a bunch of others missing too, such as:
nk_stroke_curve
nk_stroke_rect
...
Thanks!
Hi,
nk-example crash on my workstation, which infos can I provide to help debugging this issue ?
`[forth@mjolnir nk-example]$ go build -v
github.com/golang-ui/glfw
github.com/golang-ui/nuklear/nk
In file included from ../../nk/impl_glfw.go:16:0:
../../nk/nuklear_glfw_gl3.h: Dans la fonction ‘nk_glfw3_render’:
../../nk/nuklear_glfw_gl3.h:242:18: attention : assignment makes pointer from integer without a cast [-Wint-conversion]
vertices = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
^
../../nk/nuklear_glfw_gl3.h:243:18: attention : assignment makes pointer from integer without a cast [-Wint-conversion]
elements = glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY);
^
github.com/golang-ui/nuklear/cmd/nk-example`
`[forth@mjolnir nk-example]$ ./nk-example
2016/09/27 11:47:04 glfw: created window 400x500
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x5d8cc002 pc=0x4f7098]
runtime stack:
runtime.throw(0x57e87b, 0x2a)
/usr/lib/go/src/runtime/panic.go:566 +0x95
runtime.sigpanic()
/usr/lib/go/src/runtime/sigpanic_unix.go:12 +0x2cc
goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x51a210, 0xc42004dae8, 0xc400000000)
/usr/lib/go/src/runtime/cgocall.go:131 +0x110 fp=0xc42004da98 sp=0xc42004da58
github.com/golang-ui/nuklear/nk._Cfunc_nk_glfw3_render(0x8000000000001, 0x3f80000000020000)
??:0 +0x45 fp=0xc42004dae8 sp=0xc42004da98
github.com/golang-ui/nuklear/nk.NkGLFW3Render(0x8000000000001, 0x3f80000000020000)
/home/forth/go/src/github.com/golang-ui/nuklear/nk/nk.go:3482 +0x39 fp=0xc42004db08 sp=0xc42004dae8
main.gfxMain(0x22a8090, 0x834bb0, 0xc42000c3c0)
/home/forth/go/src/github.com/golang-ui/nuklear/cmd/nk-example/main.go:145 +0x2ba fp=0xc42004dd18 sp=0xc42004db08
main.main()
/home/forth/go/src/github.com/golang-ui/nuklear/cmd/nk-example/main.go:87 +0x652 fp=0xc42004df48 sp=0xc42004dd18
runtime.main()
/usr/lib/go/src/runtime/proc.go:183 +0x1f4 fp=0xc42004dfa0 sp=0xc42004df48
runtime.goexit()
/usr/lib/go/src/runtime/asm_amd64.s:2086 +0x1 fp=0xc42004dfa8 sp=0xc42004dfa0
goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/usr/lib/go/src/runtime/asm_amd64.s:2086 +0x1
goroutine 5 [syscall]:
os/signal.signal_recv(0x0)
/usr/lib/go/src/runtime/sigqueue.go:116 +0x157
os/signal.loop()
/usr/lib/go/src/os/signal/signal_unix.go:22 +0x22
created by os/signal.init.1
/usr/lib/go/src/os/signal/signal_unix.go:28 +0x41
goroutine 6 [select, locked to thread]:
runtime.gopark(0x589010, 0x0, 0x57579a, 0x6, 0x18, 0x2)
/usr/lib/go/src/runtime/proc.go:259 +0x13a
runtime.selectgoImpl(0xc42002a730, 0x0, 0x18)
/usr/lib/go/src/runtime/select.go:423 +0x11d9
runtime.selectgo(0xc42002a730)
/usr/lib/go/src/runtime/select.go:238 +0x1c
runtime.ensureSigM.func1()
/usr/lib/go/src/runtime/signal1_unix.go:304 +0x2f3
runtime.goexit()
/usr/lib/go/src/runtime/asm_amd64.s:2086 +0x1
goroutine 7 [select]:
github.com/xlab/closer.(*closer).wait(0xc42007a000)
/home/forth/go/src/github.com/xlab/closer/closer.go:102 +0x2a2
created by github.com/xlab/closer.newCloser
/home/forth/go/src/github.com/xlab/closer/closer.go:94 +0x262`
I need to change the text color. The following function does it, but it has to be placed in etc.go, because the fields are not public. `The push/pop functions have the same problem. Is there a better way to do it, or could this routine be included in the library?
func SetTextColor(ctx *Context, color Color) {
var style *Style
style = ctx.Style()
text := &style.text
text.color.r = color.r
text.color.g = color.g
text.color.b = color.b
}
``
I have installed the NDK and have my variables set. The make command fails with the following:
simulator@ubuntu:~/go/src/github.com/golang-ui/nuklear/cmd/nk-android$ make
mkdir -p android/jni/lib
CC="/home/simulator/go/src/github.com/golang-ui/nuklear/cmd/nk-android/toolchain/bin/arm-linux-androideabi-gcc" \
CXX="/home/simulator/go/src/github.com/golang-ui/nuklear/cmd/nk-android/toolchain/bin/arm-linux-androideabi-g++" \
CGO_CFLAGS="-march=armv7-a -std=c99" \
GOOS=android \
GOARCH=arm \
GOARM=7 \
CGO_ENABLED=1 \
go build -tags gles3 -buildmode=c-shared -o android/jni/lib/libnkactivity.so
# runtime/cgo
/tmp/go-build851112965/runtime/cgo/_obj/gcc_android.o:gcc_android.c:function fatalf: error: undefined reference to 'stderr'
/tmp/go-build851112965/runtime/cgo/_obj/gcc_libinit.o:gcc_libinit.c:function x_cgo_sys_thread_create: error: undefined reference to 'stderr'
/tmp/go-build851112965/runtime/cgo/_obj/gcc_util.o:gcc_util.c:function x_cgo_thread_start: error: undefined reference to 'stderr'
collect2: error: ld returned 1 exit status
Makefile:14: recipe for target 'build' failed
make: *** [build] Error 2
simulator@ubuntu:~/go/src/github.com/golang-ui/nuklear/cmd/nk-android$ printenv | grep NDK
NDK=/home/simulator/Android/Sdk/ndk-bundle
simulator@ubuntu:~/go/src/github.com/golang-ui/nuklear/cmd/nk-android$ printenv | grep ANDROID
ANDROID_HOME=/home/simulator/Android/Sdk/
simulator@ubuntu:~/go/src/github.com/golang-ui/nuklear/cmd/nk-android$
Hi again,
I have converted some example code from nuklear (C) to nk and I cannot figure out why the menu does not display.
The Menu bar appears, and is clickable. But when it toggles on there is nothing visible on screen...
nk.NkMenubarBegin(ctx)
nk.NkLayoutRowBegin(ctx, nk.LayoutStaticRow, 25, 1)
nk.NkLayoutRowPush(ctx, 45)
if nk.NkMenuBeginLabel(ctx, "File", nk.TextAlignLeft, nk.NkVec2(120, 200)) > 0 {
nk.NkLayoutRowDynamic(ctx, 25, 1)
if nk.NkMenuItemLabel(ctx, "Quit", nk.TextAlignLeft) > 0 {
win.SetShouldClose(true)
}
nk.NkMenuEnd(ctx)
}
nk.NkMenubarEnd(ctx)
I didn't wanted to make a PR for this. Please correct the typo on README file, more exactly Desktop demo is written as Destop demo.
I have observed that isn't updated anymore. Is this maintained yet?
Hey!
I just found out about https://github.com/aarzilli/nucular and was wondering if this project can help that in any way? I guess not as this is more of a quick way of exposing the C code, although didn't the Google folks use a tool to "convert" C into Go code?
The following commands all provide the same error output:
go get github.com/golang-ui/nuklear/nk
go get github.com/golang-ui/nuklear/cmd/nk-example
go get -tags opengl2 github.com/golang-ui/nuklear/nk
Output:
# github.com/golang-ui/nuklear/nk
nk/etc.go:9: undefined: Context
nk/etc.go:9: undefined: Input
Go 1.9.2 x64
Linux Mint 18.3 x64
I'm sure I've missed something. I know I've got opengl installed properly, I've been toying with go-gl for other stuff and had it building and running properly. I'm not sure what else there is to forget.
Structures inside ConvertConfig are allocated but not freed by PassRef. Here's a diff of what I needed to modify in the generated code to stop the memory leak:
diff --git a/nk/cgo_helpers.go b/nk/cgo_helpers.go
index a1694bb..0f56276 100644
--- a/nk/cgo_helpers.go
+++ b/nk/cgo_helpers.go
@@ -2754,7 +2754,9 @@ func unpackSDrawVertexLayoutElement(x []DrawVertexLayoutElement) (unpacked *C.st
}
v0 := *(*[]C.struct_nk_draw_vertex_layout_element)(unsafe.Pointer(h0))
for i0 := range x {
- v0[i0], _ = x[i0].PassValue()
+ var valueAllocs *cgoAllocMap
+ v0[i0], valueAllocs = x[i0].PassValue()
+ allocs.Borrow(valueAllocs)
}
h := (*sliceHeader)(unsafe.Pointer(&v0))
unpacked = (*C.struct_nk_draw_vertex_layout_element)(unsafe.Pointer(h.Data))
@@ -2809,6 +2811,7 @@ func (x *ConvertConfig) PassRef() (*C.struct_nk_convert_config, *cgoAllocMap) {
mem82bf4c25 := allocStructNkConvertConfigMemory(1)
ref82bf4c25 := (*C.struct_nk_convert_config)(mem82bf4c25)
allocs82bf4c25 := new(cgoAllocMap)
+ allocs82bf4c25.Add(mem82bf4c25)
var cglobal_alpha_allocs *cgoAllocMap
ref82bf4c25.global_alpha, cglobal_alpha_allocs = (C.float)(x.GlobalAlpha), cgoAllocsUnknown
allocs82bf4c25.Borrow(cglobal_alpha_allocs)
@@ -3105,6 +3108,7 @@ func (x *DrawVertexLayoutElement) PassRef() (*C.struct_nk_draw_vertex_layout_ele
memeb0614d6 := allocStructNkDrawVertexLayoutElementMemory(1)
refeb0614d6 := (*C.struct_nk_draw_vertex_layout_element)(memeb0614d6)
allocseb0614d6 := new(cgoAllocMap)
+ allocseb0614d6.Add(memeb0614d6)
var cattribute_allocs *cgoAllocMap
refeb0614d6.attribute, cattribute_allocs = (C.enum_nk_draw_vertex_layout_attribute)(x.Attribute), cgoAllocsUnknown
allocseb0614d6.Borrow(cattribute_allocs)
diff --git a/nk/impl_glfw_gl3.go b/nk/impl_glfw_gl3.go
index 04981b6..8db6621 100644
--- a/nk/impl_glfw_gl3.go
+++ b/nk/impl_glfw_gl3.go
@@ -97,6 +97,9 @@ func NkPlatformRender(aa AntiAliasing, maxVertexBuffer, maxElementBuffer int) {
NkBufferInitFixed(vbuf, vertices, Size(maxVertexBuffer))
NkBufferInitFixed(ebuf, elements, Size(maxElementBuffer))
NkConvert(state.ctx, dev.cmds, vbuf, ebuf, config)
+ vbuf.Free()
+ ebuf.Free()
+ config.Free()
gl.UnmapBuffer(gl.ARRAY_BUFFER)
gl.UnmapBuffer(gl.ELEMENT_ARRAY_BUFFER)
It would be nice to be able to paste in NkEdit... It seems there's some kind of copy/pasting capability via callbacks implemented in nuklear, but not found here.
The NkCombo() fails. The problem seems to be in unpackArgSString(). The string list supplied to NkCombo() will be modified and the original strings will be destroyed. This is not systematic. Sometimes it fails when the debugger is run, and sometimes when running standalone. Restarting can make the error disapear. Testing with agressive garbage collection seems to increase the error rate.
Using NkComboboxString() works fine. You just have to concatenate the strings with \x00 as separator.
Demo application cloned from https://github.com/golang-ui/nuklear/tree/master/cmd/nk-example crashes after a certain amount of seconds, sometimes immediately, sometimes after a minute.
Barts-MacBook-Pro:8bitmmo-updater bart$ ./8bitmmo-updater
2017/09/26 16:20:42 glfw: created window 400x500
2017/09/26 16:20:44 [INFO] button pressed!
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xdf50340]
runtime stack:
runtime.throw(0x41ada04, 0x2a)
/usr/local/Cellar/go/1.9/libexec/src/runtime/panic.go:605 +0x95
runtime.sigpanic()
/usr/local/Cellar/go/1.9/libexec/src/runtime/signal_unix.go:351 +0x2b8
goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x40ea040, 0xc420053b10, 0x100)
/usr/local/Cellar/go/1.9/libexec/src/runtime/cgocall.go:132 +0xe4 fp=0xc420053ac8 sp=0xc420053a88 pc=0x4004a34
github.com/go-gl/gl/v3.2-core/gl._Cfunc_glowDrawElements(0x7fffaac1d5a7, 0x7800000004, 0x1403, 0x0)
github.com/go-gl/gl/v3.2-core/gl/_obj/_cgo_gotypes.go:4057 +0x45 fp=0xc420053b10 sp=0xc420053ac8 pc=0x40ac785
github.com/go-gl/gl/v3.2-core/gl.DrawElements.func1(0x7fffaac1d5a7, 0x7800000004, 0xffffc3e800001403, 0x0)
/Users/bart/go/src/github.com/go-gl/gl/v3.2-core/gl/package.go:5798 +0x82 fp=0xc420053b48 sp=0xc420053b10 pc=0x40c7332
github.com/go-gl/gl/v3.2-core/gl.DrawElements(0x7800000004, 0x800000001403, 0x0)
/Users/bart/go/src/github.com/go-gl/gl/v3.2-core/gl/package.go:5798 +0x4f fp=0xc420053b78 sp=0xc420053b48 pc=0x40aec9f
github.com/golang-ui/nuklear/nk.NkPlatformRender.func1(0x500efe0)
/Users/bart/go/src/github.com/golang-ui/nuklear/nk/impl_glfw_gl3.go:123 +0x129 fp=0xc420053bd0 sp=0xc420053b78 pc=0x40d6569
github.com/golang-ui/nuklear/nk.NkDrawForeach(0x503f800, 0x462bfb0, 0xc420053c78)
/Users/bart/go/src/github.com/golang-ui/nuklear/nk/etc.go:90 +0x4f fp=0xc420053c08 sp=0xc420053bd0 pc=0x40d291f
github.com/golang-ui/nuklear/nk.NkPlatformRender(0x3e40c0c200000001, 0x80000, 0x20000)
/Users/bart/go/src/github.com/golang-ui/nuklear/nk/impl_glfw_gl3.go:110 +0x4d0 fp=0xc420053d00 sp=0xc420053c08 pc=0x40d3e70
main.gfxMain(0xc4200b8000, 0x503f800, 0xc4200be0d0)
/Users/bart/Documents/Projects/8bitmmo-updater/updater.go:147 +0x1bc fp=0xc420053d80 sp=0xc420053d00 pc=0x40e7aac
main.main()
/Users/bart/Documents/Projects/8bitmmo-updater/updater.go:84 +0x6b5 fp=0xc420053f80 sp=0xc420053d80 pc=0x40e7785
runtime.main()
/usr/local/Cellar/go/1.9/libexec/src/runtime/proc.go:185 +0x20d fp=0xc420053fe0 sp=0xc420053f80 pc=0x402c70d
runtime.goexit()
/usr/local/Cellar/go/1.9/libexec/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc420053fe8 sp=0xc420053fe0 pc=0x4057a71
goroutine 5 [syscall]:
os/signal.signal_recv(0x0)
/usr/local/Cellar/go/1.9/libexec/src/runtime/sigqueue.go:131 +0xa7
os/signal.loop()
/usr/local/Cellar/go/1.9/libexec/src/os/signal/signal_unix.go:22 +0x22
created by os/signal.init.0
/usr/local/Cellar/go/1.9/libexec/src/os/signal/signal_unix.go:28 +0x41
goroutine 6 [select, locked to thread]:
runtime.gopark(0x41af320, 0x0, 0x41a453a, 0x6, 0x18, 0x1)
/usr/local/Cellar/go/1.9/libexec/src/runtime/proc.go:277 +0x12c
runtime.selectgo(0xc42003ef50, 0xc42007a2a0)
/usr/local/Cellar/go/1.9/libexec/src/runtime/select.go:395 +0x1138
runtime.ensureSigM.func1()
/usr/local/Cellar/go/1.9/libexec/src/runtime/signal_unix.go:511 +0x1fe
runtime.goexit()
/usr/local/Cellar/go/1.9/libexec/src/runtime/asm_amd64.s:2337 +0x1
goroutine 18 [select]:
github.com/xlab/closer.(*closer).wait(0xc420096000)
/Users/bart/go/src/github.com/xlab/closer/closer.go:103 +0x163
created by github.com/xlab/closer.newCloser
/Users/bart/go/src/github.com/xlab/closer/closer.go:95 +0x201
Not pressing any button or other interaction. System is running fine - enough memory, and have not experienced any issue similar to this before.
Hi,
follows errors on build
# github.com/golang-ui/nuklear/nk
In file included from src\github.com\golang-ui\nuklear\nk\cgo_helpers.go:11:0:
./nuklear_glfw_gl2.h:16:24: fatal error: GLFW/glfw3.h: No such file or directory
compilation terminated.
C:\goworkspace>go get -x github.com/golang-ui/nuklear/nk
WORK=C:\Users\Marc\AppData\Local\Temp\go-build622038790
mkdir -p $WORK\github.com\golang-ui\nuklear\nk\_obj\
mkdir -p $WORK\github.com\golang-ui\nuklear\
cd c:\goworkspace\src\github.com\golang-ui\nuklear\nk
CGO_LDFLAGS="-g" "-O2" "-lglfw3" "-lopengl32" "-lgdi32" "-lm" "-Wl,--allow-multiple-definition" "C:\\Go\\pkg\\tool\\windows_amd64\\cgo.exe" -objdir "C:\\Users\\Marc\\AppData\\Local\\Temp\\go-build622038790\\github.com\\golang-ui\\nuklear\\nk\\_obj\\" -importpath github.com/golang-ui/nuklear/nk -- -I "C:\\Users\\Marc\\AppData\\Local\\Temp\\go-build622038790\\github.com\\golang-ui\\nuklear\\nk\\_obj\\" -g -O2 -DNK_INCLUDE_FIXED_TYPES -DNK_INCLUDE_STANDARD_IO -DNK_INCLUDE_DEFAULT_ALLOCATOR -DNK_INCLUDE_FONT_BAKING -DNK_INCLUDE_DEFAULT_FONT -Wno-implicit-function-declaration -DNK_INCLUDE_FIXED_TYPES -DNK_INCLUDE_STANDARD_IO -DNK_INCLUDE_DEFAULT_ALLOCATOR -DNK_INCLUDE_FONT_BAKING -DNK_INCLUDE_DEFAULT_FONT -Wno-implicit-function-declaration -DNK_INCLUDE_FIXED_TYPES -DNK_INCLUDE_STANDARD_IO -DNK_INCLUDE_DEFAULT_ALLOCATOR -DNK_INCLUDE_FONT_BAKING -DNK_INCLUDE_DEFAULT_FONT -DNK_INCLUDE_VERTEX_BUFFER_OUTPUT -D_GLFW_WIN32 -DNK_INCLUDE_FIXED_TYPES -DNK_INCLUDE_STANDARD_IO -DNK_INCLUDE_DEFAULT_ALLOCATOR -DNK_INCLUDE_FONT_BAKING -DNK_INCLUDE_DEFAULT_FONT -Wno-implicit-function-declaration -DNK_INCLUDE_FIXED_TYPES -DNK_INCLUDE_STANDARD_IO -DNK_INCLUDE_DEFAULT_ALLOCATOR -DNK_INCLUDE_FONT_BAKING -DNK_INCLUDE_DEFAULT_FONT -Wno-implicit-function-declaration cgo_helpers.go color.go const.go font.go impl_glfw.go nk.go types.go
# github.com/golang-ui/nuklear/nk
In file included from src\github.com\golang-ui\nuklear\nk\cgo_helpers.go:11:0:
./nuklear_glfw_gl2.h:16:24: fatal error: GLFW/glfw3.h: No such file or directory
compilation terminated.
MinGW-W64 is installed
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=C:/mingw-w64/x86_64-5.3.0-posix-seh-rt_v4-rev0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/5.3.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-5.3.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw530/x86_64-530-posix-seh-rt_v4-rev0/mingw64 --with-gxx-include-dir=/mingw64/x86_64-w64-mingw32/include/c++ --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-isl-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw530/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw530/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw530/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw530/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-seh-rev0, Built by MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -I/c/mingw530/x86_64-530-posix-seh-rt_v4-rev0/mingw64/opt/include -I/c/mingw530/prerequisites/x86_64-zlib-static/include -I/c/mingw530/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -I/c/mingw530/x86_64-530-posix-seh-rt_v4-rev0/mingw64/opt/include -I/c/mingw530/prerequisites/x86_64-zlib-static/include -I/c/mingw530/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS= LDFLAGS='-pipe -L/c/mingw530/x86_64-530-posix-seh-rt_v4-rev0/mingw64/opt/lib -L/c/mingw530/prerequisites/x86_64-zlib-static/lib -L/c/mingw530/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: posix
gcc version 5.3.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project)
On built with LiteIDE
go build github.com/go-gl/glfw/v3.2/glfw: c:\go\pkg\tool\windows_amd64\cgo.exe: exit status 2
go build github.com/go-gl/gl/v3.2-core/gl: c:\go\pkg\tool\windows_amd64\cgo.exe: exit status 2
go build github.com/golang-ui/nuklear/nk: c:\go\pkg\tool\windows_amd64\cgo.exe: exit status 2
Fehler: Prozess beendet mit Rückgabewert 1.
On c:\go\pkg\tool\windows_amd64\cgo.exe: is nothing this cgo.exe
Whats the problem?
It renders one frame and then just freezes.
I creating gui application with multiple goroute functionality. Some of goroute execute another application (exec.Command) with parsing output. At this momen application have only one goroute for rendering and dispatch event. When i try dispatch event application raise exeption
signal arrived during external code execution
github.com/golang-ui/nuklear/nk._Cfunc_nk_convert(0x307fd0, 0xe0aa70, 0x7a94930, 0x7a949b0, 0x7a958d0, 0xc000000000)
github.com/golang-ui/nuklear/nk/_obj/_cgo_gotypes.go:3065 +0x54
github.com/golang-ui/nuklear/nk.NkConvert.func1(0x307fd0, 0xe0aa70, 0x7a94930, 0x7a949b0, 0x7a958d0, 0x20000)
C:/Users/212402712/go/src/github.com/golang-ui/nuklear/nk/nk.go:155 +0x167
github.com/golang-ui/nuklear/nk.NkConvert(0x307fd0, 0xe0aa70, 0x7a94930, 0x7a949b0, 0xc04206fd18, 0xc04206fce0)
C:/Users/212402712/go/src/github.com/golang-ui/nuklear/nk/nk.go:155 +0x68
github.com/golang-ui/nuklear/nk.NkPlatformRender(0x1, 0x80000, 0x20000)
C:/Users/212402712/go/src/github.com/golang-ui/nuklear/nk/impl_glfw_gl3.go:99 +0x448
I'm currently working on a small cross-plattform rendering framework to cook up small, private projects. One of the core concepts required for this is the possibility to switch rendering backends on-the-fly.
The first step to this is go-gl/gl#85, which allows to have multiple OpenGL versions "initialized" at the same time. However, the deal breaker is this binding at the moment. As it stands, applications can only be compiled with either OpenGL 2 or 3 (+ glfw vs sdl) support - not both.
The long-term solution would be to move the rendering backends around (e.g. to a new backends package, with an unique naming stretegy), so that they can be used in conjunction (they cant at the moment due to deliberately same method names, kept disjunct only by build tags).
A possible short term solution would be to provide a (default?) build tag to compile no rendering backend at all - this would prompt the lib-user to write his or her own, but would also grant more freedom.
Combining both long and short term solutions could prompt extraction of the rendering backends to own projects, which can be maintained on their own (e.g. the planed(?) vulkan backend).
Hi, @xlab.
Unfortunately I did find this from the project documentation either from posted issues.
Can anyone tell for the nob like me, please?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.