GithubHelp home page GithubHelp logo

inkyblackness / imgui-go Goto Github PK

View Code? Open in Web Editor NEW
805.0 805.0 99.0 2.3 MB

Go wrapper library for "Dear ImGui" (https://github.com/ocornut/imgui)

License: Other

Go 8.82% C++ 81.03% C 10.11% Shell 0.04%
dear-imgui go golang gui hacktoberfest imgui toolkit ui wrapper

imgui-go's Introduction

Dear ImGui for Go

Go Doc Go Report Card Lint Status

Discontinued

This repository is no longer maintained as per 2022-12-31. Please consider using https://github.com/AllenDang/cimgui-go instead. That project is an auto-generated wrapper and makes it easier to be at the latest version of Dear ImGui.

You may also have a look at this fork https://github.com/eliasdaler/imgui-go , the owner intended to continue to support it.


This library is a Go wrapper for Dear ImGui.

This wrapper started as a special-purpose wrapper for use within InkyBlackness. However, it is self-contained and can be used for other purposes as well.

This wrapper is

  • hand-crafted, for Go
  • documented
  • versioned
  • with ported examples in a separate repository (see below)

Screenshot from example

API naming

Names of types and functions follow closely those of Dear ImGui.

For functions that have optional parameters, the following schema is applied:

  • There is the "verbose" variant, followed by the letter V, such as ButtonV(id string, size Vec2) bool
  • Next to it there is the "idiomatic" variant, without any optional parameter, such as Button(id string) bool.
  • The idiomatic variant calls the verbose variant with the default values for the optional parameters. Functions that don't have optional parameters don't come in a verbose variant.

The Dear ImGui functions IO() and Style() have been renamed to be CurrentIO() and CurrentStyle(). This was done because their returned types have the same name, causing a name clash. With the Current prefix, they also better describe what they return.

API philosophy

This library does not intend to export all the functions of the wrapped Dear ImGui. The following filter applies as a rule of thumb:

  • Functions marked as "obsolete" are not available. (The corresponding C code isn't even compiled - disabled by define)
  • "Shortcut" Functions, which combine language features and/or other Dear ImGui functions, are not available. There may be exceptions for this if the shortcut exists in Dear ImGui code base (e.g. ImGui::Text which does printf style string formatting)
  • Functions that are not needed by InkyBlackness are ignored. This doesn't mean that they can't be in the wrapper, they are simply not a priority. Feel free to propose an implementation or make a pull request, respecting the previous points :)

Version philosophy

This library does not mirror the versions of the wrapped Dear ImGui. The semantic versioning of this wrapper is defined as:

  • Major changes: (Breaking) changes in API or behaviour. Typically done through changes in Dear ImGui.
  • Minor changes: Extensions in API. Typically done through small version increments of Dear ImGui and/or exposing further features in a compatible way.
  • Patch changes: Bug fixes - either in the wrapper or the wrapped Dear ImGui, given that the API & behaviour remains the same.

At the moment, this library uses version 1.85 of Dear ImGui.

Examples

A separate repository was created to host ported examples and reference implementations. See repository inkyblackness/imgui-go-examples.

It contains reference implementations for libraries such as GLFW3 and SDL2, using OpenGL.

The screenshot above was created with such an example.

Extras

FreeType font rendering

If the FreeType library is available for your platform, you can enable using it with the build tag imguifreetype - as in

go build -tags="imguifreetype"

This extra is based on the reference implementation from Dear ImGui.

If you set the build tag, yet the corresponding support has not been added to the library, you will receive a build error. Contributions to support more build environments are happily accepted. See file FreeType.go.

If you are trying to do this on MS Windows with MinGW and receive an error like pkg-config: exec: "pkg-config": executable file not found in %PATH%, refer to online guides on how to add this to your installation.

Alternatives

Since 2022-08, there is https://github.com/AllenDang/cimgui-go , which is an auto-generated wrapper that makes it easier to be at the latest version of Dear ImGui. It is recommended to use that one instead.

Before inkyblackness/imgui-go was created, the following alternatives were considered - and ignored:

  • kdrag0n/go-imgui (no longer available). Reasons for dismissal at time of decision:
    • Auto-generated bloat, which doesn't help
    • Was using old API (1.5x)
    • Did not compile
    • Project appeared to be abandoned
  • Extrawurst/cimgui. Reasons for dismissal at time of decision:
    • Was using old API (1.5x), 1.6x was attempted
    • Apparently semi-exposed the C++ API, especially through the structures
    • Adding this adds another dependency
    • Note: cimgui has since switched to an auto-generated method. You can use that instead of this manually curated wrapper here.

License

The project is available under the terms of the New BSD License (see LICENSE file). The licenses of included sources are stored in the _licenses folder.

imgui-go's People

Contributors

0xd61 avatar dertseha avatar eliasdaler avatar flaviopontes avatar foosoft avatar galaco avatar greenlightning avatar hperigo avatar jetsetilly avatar kaishuu0123 avatar konstantin8105 avatar melaurent avatar mmp avatar mspindelhirn avatar nazzrim avatar neclepsio avatar ptxmac avatar pwiecz avatar r00tc0d3 avatar semmulder avatar somersf avatar spair avatar supudo avatar tehgoat avatar the-goodies avatar thegtproject avatar thelucy avatar thothothotho avatar vityaschel avatar ym1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imgui-go's Issues

FreeType support under Windows using MinGW

To get it working under Windows, using a properly setup MinGW environment (a port of GNU development environment), I simply deleted the _linux tag fom the name of FreeTypeEnabled_linux.go.

Everything works as expected. Please add a tag we can use for any linux-like build environment.

undefined: imgui.TextUnformatted

I checked out the latest master. When build I get:

imgui-go/_examples/opengl3_example  
go build
./main.go:59:4: undefined: imgui.TextUnformatted
./main.go:68:4: undefined: imgui.TextUnformatted
./main.go:75:4: undefined: imgui.TextUnformatted

Any idea what causes this?
When I change it to imgui.Text(...) it works

Load GlyphRangesChineseFull takes nearly 6 seconds, way too slow...

Hi, @dertseha

I'm working on a app which needs to display content of web pages crawled by crawlers.
Currently the biggest issue is load GlyphRangesChineseFull takes nearly 6 seconds, and there still lots of chinese characters are not included.

I read the documents of imgui and found out GlyphRangesBuilder might be the solution. I could calculate all the characters need to be displayed and create GlyphRanges for them before rendering.

So I tried below solution.

                 fonts := Context.IO().Fonts()

		ranges := imgui.NewGlyphRanges()
		builder := imgui.NewFontGlyphRangesBuilder()

		// Compose all the strings need to be displayed
		var runes []rune
		for k := range fs.charMap {
			runes = append(runes, k)
		}

		builder.AddText(string(runes))
		builder.BuildRanges(ranges)

		fonts.AddFontFromFileTTFV(fs.fontPath, fs.fontSize, imgui.DefaultFontConfig, ranges.Data())
		alpha8 := fonts.TextureDataAlpha8()
		textureId, _ := Context.renderer.LoadAlpha8(alpha8)
		fonts.SetTextureID(textureId)

Here is the renderer side code

func (renderer *OpenGL3) LoadAlpha8(img *Alpha8Image) (TextureID, error) {
	// Upload texture to graphics system
	var lastTexture int32
	var handle uint32
	gl.GetIntegerv(gl.TEXTURE_BINDING_2D, &lastTexture)
	gl.GenTextures(1, &handle)
	gl.BindTexture(gl.TEXTURE_2D, handle)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR) // minification filter
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR) // magnification filter
	gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, int32(img.Width), int32(img.Height), 0, gl.ALPHA, gl.UNSIGNED_BYTE, gl.Ptr((*C.uint)(img.Pixels)))
	gl.GenerateMipmap(gl.TEXTURE_2D)

	// Restore state
	gl.BindTexture(gl.TEXTURE_2D, uint32(lastTexture))

	// Add Image Type to last 8 bit of the texture id to use different shader to render bitmap correctly.
	textureId := TextureID(handle)
	imageType := TextureID(1)

	textureId |= imageType << 56
	return textureId, nil
}

But all the characters displayed as black squares.
I'm I doing things right?

How to provide examples with lib being a module?

Although v1.4.0 now also sports a go.mod file to become a proper module, I believe to have an issue with the examples now - they won't compile (easily).

History: In order to be "ignored", I've put them in an underscore-prefixed path (_examples). This essentially makes sure the compiler doesn't cascade into that directory by accident. (This already causes a slight issue with the linter, because that one also ignores it, and you have to enter it manually and run the linter there again.)

I've tried creating .mod file with the go mod tool, yet it wouldn't add the dependencies to it, so I guess this setup isn't supported.
I want to avoid making the examples visible, as this would then add indirect dependencies to libraries (glfw/sdl/...) not everyone wanted -- I assume.

So far I came up with two solutions:

For me, b) sounds more approachable. a) makes incompatible changes (user has to do different import path), and also doesn't feel right. After all, the examples aren't a "main" part of the project. This project provides a library.

To stay compatible in terms of "getting a project that comes with its own examples", b) could be extended by adding a git module: Make the examples project a git module under the directory _examples.

The more I rubberduck about this, the more it seems that this (idea b) seems to be the proper solution. I'll still let it rest a little bit to think it over - and perhaps further ideas I didn't consider come along.
I also wonder how other such library projects approach this.

IsWindowFocused()

iggIsWindowFocused() in imguiWrapper.cpp (line 584) is incorrectly calling IsWindowHovered()

IggBool iggIsWindowFocused(int flags)
{
return ImGui::IsWindowHovered(flags) ? 1 : 0;
}

undefined

Ciao,
during installation these messages came out:

MacBook-Pro-di-Franco:~ francom$ go get -u github.com/inkyblackness/imgui-go
# github.com/inkyblackness/imgui-go
go/src/github.com/inkyblackness/imgui-go/imgui.go:998:26: undefined: FocusedFlagsDefault
go/src/github.com/inkyblackness/imgui-go/imgui.go:1010:26: undefined: HoveredFlagsDefault
MacBook-Pro-di-Franco:~ francom$ go version
go version go1.13.6 darwin/amd64

What's I wrong ?

Thanks
Franco

IsAnyItemActive()

Please can you add IsAnyItemActive(). I've vendored the latest version and added it myself and it's caused no problems.

Thankyou

Creating non-default font texture takes much longer than in native build

Found through #6, the function call of FontAtlas.Build() (through call such as FontAtlas.GetTexDataAsAlpha8() takes considerably longer (several seconds) than the native build when using non-default unicode fonts, such as Chinese ones.

From a cursory investigation I'm quite puzzled as to why this happens.
The only hunch that I have so far is a difference in compiler optimization, as this one so far has been found under Windows, where MSVC (native) and mingw (go) are in use. To cross verify, a Chinese font needs to be cross-tested under Linux.
Other than that, perhaps there are other #defines in play between the native and Go variants.

Refactoring coordination

I completed my refactoring, moving C files in a separate folder, updating upstream to 1.76. I divided imgui.go in several files. It's in the refactor-1 branch of my fork. I'm going to implement the cleaning you you did while merging #97, then I'd open a pull request. It's pretty invasive so I think a little bit of coordination is needed to keep in sync. Are you planning other modifications, or should I pull my refactoring now?

DeltaTime/FrameCount Assert on Windows

Hey, I've been working on an application in Linux using OpenGL and Imgui-go that has been building and running fine. I just tried to build and run it on Windows, using MinGW), it builds fine, but I'm getting the assert below that I wasn't getting running the same thing on Linux. From the stack trace, this looks like a Dear ImGUI issue, but I wanted to start here since I'm not familiar with how imgui-go is initializing ImGUI.

Any advice is greatly appreciated.

My build command:
go build -v -tags='imguifreetype" -tags='glfw'

Stack Trace:

panic: Assertion failed!
File: C:\Users\allen\Dev\go\src\github.com\inkyblackness\imgui-go\imgui/imgui.cpp, Line 6732

Expression: (g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!"


goroutine 6 [running]:
github.com/inkyblackness/imgui-go.glob..func2(0xc000228000, 0x4c, 0xc000228050, 0x4b, 0x1a4c)
        C:/Users/allen/Dev/go/src/github.com/inkyblackness/imgui-go/Assert.go:28 +0xa2
github.com/inkyblackness/imgui-go.iggAssert(0x8a2d90, 0x89f960, 0x3fd5c28f00001a4c)
        C:/Users/allen/Dev/go/src/github.com/inkyblackness/imgui-go/Assert.go:45 +0xac
github.com/inkyblackness/imgui-go._cgoexpwrap_9cc7a7a8d41e_iggAssert(0x8a2d90, 0x89f960, 0x1a4c)
        _cgo_gotypes.go:4069 +0x44
github.com/inkyblackness/imgui-go._Cfunc_iggNewFrame()
        _cgo_gotypes.go:2999 +0x48
github.com/inkyblackness/imgui-go.NewFrame(...)
        C:/Users/allen/Dev/go/src/github.com/inkyblackness/imgui-go/Main.go:18
github.com/dusk125/pixelui.(*UI).NewFrame(0xc00025e000)
        C:/Users/allen/Dev/go/src/github.com/dusk125/pixelui/ui.go:122 +0x60
main.run()
        C:/Users/allen/Dev/go/src/github.com/dusk125/musync/musync.go:96 +0x3c2
github.com/faiface/mainthread.Run.func1(0x737018, 0xc0000540c0)
        C:/Users/allen/Dev/go/src/github.com/faiface/mainthread/mainthread.go:37 +0x2e
created by github.com/faiface/mainthread.Run
        C:/Users/allen/Dev/go/src/github.com/faiface/mainthread/mainthread.go:36 +0xb8

Thanks in advance!

Tree related helper function TreeNodeToLabelSpacing is missing

Hi,

TreeAdvanceToLabelPos as well as GetTreeNodeToLabelSpacing are missing. This makes it a little harder to build nicely aligned tree menus. Is this a scope related choice not to expose these?

I am not a C/C++ dev myself and as such cant promise to make a pull request even if the addition is in scope. But I could give it a try.

UTF-8 not working on windows

UTF8 displays as "??" on windows, untested on other OS.

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\leafB\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=E:\gopath
set GOPROXY=
set GORACE=
set GOROOT=E:\Go
set GOTMPDIR=
set GOTOOLDIR=E:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=E:\TDM-GCC-64\bin\gcc.exe
set CXX=E:\TDM-GCC-64\bin\g++.exe
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=E:\babun\.babun\cygwin\tmp\go-build269235094=/tmp/go-build -gno-record-gcc-switches

https://github.com/inkyblackness
default

InputText support

Hi! Thanks for your great wrapper! Are you planing to include InputText to it?

I gave it a try yesterday, but it keeps crashing with this not so helpful error:

free(): invalid next size (fast)

This is what I added:

//At WrapperConverter.go
func wrapStringPointer(value *string) (wrapped *C.char, finisher func()) {

	if value != nil {
		wrapped = C.CString(*value)
		finisher = func() {
			*value = C.GoString(wrapped)
			C.free(unsafe.Pointer(wrapped))
		} // nolint: gas
	} else {
		finisher = func() {}
	}
	return
}

...

// At imgui.go
// InputText handles user input.
func InputText(label string, buf *string, bufSize int64, flags int) bool {
	labelArg, labelFin := wrapString(label)
	defer labelFin()
	bufArg, bufFin := wrapStringPointer(buf)
	defer bufFin()
	//fmt.Printf("original: %v - %v - %v - %v\n", label, buf, bufSize, flags)
	//fmt.Printf("returned wrapped: %v - %v\n", labelArg, bufArg)
	return C.iggInputText(labelArg, bufArg, C.long(bufSize), C.int(flags)) != 0
}

...

//At imguiWrapper.h
extern IggBool iggInputText(const char* label, char* buf, long buf_size, int flags);
extern IggBool iggInputTextMultiline(const char* label, char* buf, long buf_size, IggVec2 const *size, int flags);

...

//At imguiWrapper.cpp
IggBool iggInputText(const char* label, char* buf, long buf_size, int flags)
{
   return ImGui::InputText(label, buf, buf_size, flags, NULL, NULL);
}

IggBool iggInputTextMultiline(const char* label, char* buf, long buf_size, IggVec2 const *size, int flags)
{
   Vec2Wrapper sizeArg(size);
   return ImGui::InputTextMultiline(label, buf, buf_size, *sizeArg, flags, NULL, NULL);
}

Apart from that, I created InputTextFlags.go to make flags available, you may check all the changes here.

Any ideas on what's the issue? Have you tried to implement this yourself?
Also, I just passed NULL for the callback and user data, but if you have an idea on how to deal with the callback, that'd be great.

Cheers!

Imgui v1.67 upgrade

Imgui was released a few days ago: v1.67.
It would be useful for me if the bundled version were bumped to the latest release; as the Tab Bar API is now out of beta and in the release; something that I require (adding bindings for tabbar is a separate issue)

Since its a minor version bump (1.61->1.67) there shouldn't be any compatibility issues.

I'm happy to raise a PR myself for this if its reasonable.

Load colorful png and render to gui turns to gray.

Backend: GLFW/GL3

I created a function to load png as texture.

func (renderer *OpenGL3) createImageTexture(img *image.RGBA) (uint32, error) {
	// Upload texture to graphics system
	var lastTexture int32
	var handle uint32
	gl.GetIntegerv(gl.TEXTURE_BINDING_2D, &lastTexture)
	gl.GenTextures(1, &handle)
	gl.BindTexture(gl.TEXTURE_2D, handle)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR) // minification filter
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR) // magnification filter
	gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, int32(img.Bounds().Dx()), int32(img.Bounds().Dy()), 0, gl.RGBA, gl.UNSIGNED_BYTE, gl.Ptr(img.Pix))
	gl.GenerateMipmap(gl.TEXTURE_2D)

	// Restore state
	gl.BindTexture(gl.TEXTURE_2D, uint32(lastTexture))

	return handle, nil
}

Then I tried to load this

gopher

imgFile, err := os.Open("gopher.png")
if err != nil {
	panic(err)
}
defer imgFile.Close()

// Decode detexts the type of image as long as its image/<type> is imported
img, _, err := image.Decode(imgFile)
if err != nil {
	panic(err)
}

rect := img.Bounds()
rgba := image.NewRGBA(rect)
draw.Draw(rgba, rect, img, rect.Min, draw.Src)

imageID, err = w.LoadImage(rgba)
if err != nil {
	panic(err)
}

And display to gui by

imgui.Image(imageID, imgui.Vec2{X: 128, Y: 128})

Here is it, gray

屏幕快照 2019-09-11 下午10 14 01

Any thoughts?

Put two InputText in frame will cause weird issue.

  1. Put two InputText in frame.
  2. Click the first one, it cannot get focus, cannot input anything.
  3. Click the second one, it gains the focus, input something, two InputText will has same string I've entered.

Here is the sample code:

var str1 string
var str2 string
for !p.ShouldStop() {
    p.ProcessEvents()
    p.NewFrame()
    imgui.NewFrame()
    {
        imgui.Begin("Test")
        imgui.InputText("", &str1)
        imgui.InputText("", &str2)
        imgui.End()
    }
...
}

NULL instead of nullptr when running on El Capitan

I just downloaded this package to try it out, but had to make this change to WrapperConverter.h in order for it to compile under El Capitan (10.11.6) and go version go1.11.1 darwin/amd64

diff --git a/WrapperConverter.h b/WrapperConverter.h
index c4a09c2..ff6f14b 100644
--- a/WrapperConverter.h
+++ b/WrapperConverter.h
@@ -14,9 +14,9 @@ class TypeWrapper
 {
 public:
    TypeWrapper(IggType *iggValue)
-      :  iggValue(iggValue), imguiValue(nullptr)
+      :  iggValue(iggValue), imguiValue(NULL)
    {
-      if (iggValue != nullptr)
+      if (iggValue != NULL)
       {
          imguiValue = &imguiBuffer;
          importValue(*imguiValue, *iggValue);
@@ -24,9 +24,9 @@ public:
    }
 
    TypeWrapper(IggType const *constIggValue)
-      :  iggValue(nullptr), imguiValue(nullptr)
+      :  iggValue(NULL), imguiValue(NULL)
    {
-      if (constIggValue != nullptr)
+      if (constIggValue != NULL)
       {
          imguiValue = &imguiBuffer;
          importValue(*imguiValue, *constIggValue);
@@ -35,7 +35,7 @@ public:
 
    ~TypeWrapper()
    {
-      if (iggValue != nullptr)
+      if (iggValue != NULL)
       {
          exportValue(*iggValue, *imguiValue);
       }

IO.SetDisplaySize doesn't work?

Hi,
This might not be an issue but a discussion. :P
I noticed that GLFW v3.3 just add a callback "SetSizeCallBack" which will be called when window's size is changed.
So I tried to implement a live-resize of all imgui widgets.

In PlatformGlfw, I add the call back like below and fmt.Println(width, height) shows it works fine.

func (platform *GLFW) installCallbacks() {
	platform.window.SetMouseButtonCallback(platform.mouseButtonChange)
	platform.window.SetScrollCallback(platform.mouseScrollChange)
	platform.window.SetKeyCallback(platform.keyChange)
	platform.window.SetCharCallback(platform.charChange)
	platform.window.SetSizeCallback(platform.sizeChange)
}
func (platform *GLFW) sizeChange(window *glfw.Window, width, height int) {
	platform.imguiIO.SetDisplaySize(Vec2{X: float32(width), Y: float32(height)})
}

But during outer window resizing, imgui doesn't update. Am I missing something to make it work?

Selectable doesn't work.

Selectable should behave like a toggle, but I cannot get it work.

var selected bool
func loop(..) {
  selected = imgui.SelectableV("Selectable", selected, 0, imgui.Vec2{})
  fmt.Println(selected)
}

From log I can see that when mouse down, selected is True, mouse up, selected is False again.
This makes it would never to selected.

The font display not clear on macOS

environment:
MacOS 10.12.6

The font display not clear , but native imgui is no problem please see the screenshots:

imgui-go screenshots:

2018-08-24 6 07 39

native cpp imgui screenshots:

2018-08-24 6 08 32

example panic

example example_glfw_opengl3

console

The program hangs when the window is closed.

panic stack

fatal error: exitsyscall: syscall frame is no longer valid

goroutine 1 [running, locked to thread]:
runtime.throw(0x41f2f2a, 0x2d)
	/Users/fanbingxin/local/go/src/runtime/panic.go:774 +0x72 fp=0xc000048e48 sp=0xc000048e18 pc=0x402c562
runtime.exitsyscall()
	/Users/fanbingxin/local/go/src/runtime/proc.go:2957 +0x27d fp=0xc000048e78 sp=0xc000048e48 pc=0x403519d
runtime.cgocallbackg(0x0)
	/Users/fanbingxin/local/go/src/runtime/cgocall.go:188 +0xa3 fp=0xc000048ee0 sp=0xc000048e78 pc=0x4004e83
runtime.cgocallback_gofunc(0x40474ec, 0x4057dc0, 0xc000048f60, 0xc000048f90)
	/Users/fanbingxin/local/go/src/runtime/asm_amd64.s:793 +0x9b fp=0xc000048f00 sp=0xc000048ee0 pc=0x4055e5b
runtime.asmcgocall(0x4057dc0, 0xc000048f60)
	/Users/fanbingxin/local/go/src/runtime/asm_amd64.s:640 +0x42 fp=0xc000048f08 sp=0xc000048f00 pc=0x4055cf2
runtime.libcCall(0x4057dc0, 0xc000048f60, 0xc0000240b8)
	/Users/fanbingxin/local/go/src/runtime/sys_darwin.go:46 +0x6c fp=0xc000048f38 sp=0xc000048f08 pc=0x40474ec
runtime.exit(0xc000000000)
	/Users/fanbingxin/local/go/src/runtime/sys_darwin.go:220 +0x31 fp=0xc000048f60 sp=0xc000048f38 pc=0x4047aa1
runtime.main()
	/Users/fanbingxin/local/go/src/runtime/proc.go:225 +0x272 fp=0xc000048fe0 sp=0xc000048f60 pc=0x402df42
runtime.goexit()
	/Users/fanbingxin/local/go/src/runtime/asm_amd64.s:1357 +0x1 fp=0xc000048fe8 sp=0xc000048fe0 pc=0x4056581
example_glfw_opengl3(4340,0x7fff99676380) malloc: *** error for object 0x451a0c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
panic during panic
SIGABRT: abort
PC=0x7fff60d7eb66 m=0 sigcode=0

goroutine 0 [idle]:
runtime.exit(0xc000000000)
	/Users/fanbingxin/local/go/src/runtime/sys_darwin.go:220 +0x31 fp=0xc000048f60 sp=0xc000048f38 pc=0x4047aa1
runtime.main()
	/Users/fanbingxin/local/go/src/runtime/proc.go:225 +0x272 fp=0xc000048fe0 sp=0xc000048f60 pc=0x402df42
runtime.goexit()
	/Users/fanbingxin/local/go/src/runtime/asm_amd64.s:1357 +0x1 fp=0xc000048fe8 sp=0xc000048fe0 pc=0x4056581

goroutine 1 [running, locked to thread]:
runtime.systemstack_switch()
	/Users/fanbingxin/local/go/src/runtime/asm_amd64.s:330 fp=0xc000048de0 sp=0xc000048dd8 pc=0x40544d0
runtime.fatalthrow()
	/Users/fanbingxin/local/go/src/runtime/panic.go:826 +0x57 fp=0xc000048e18 sp=0xc000048de0 pc=0x402c737
runtime.throw(0x41f2f2a, 0x2d)
	/Users/fanbingxin/local/go/src/runtime/panic.go:774 +0x72 fp=0xc000048e48 sp=0xc000048e18 pc=0x402c562
runtime.exitsyscall()
	/Users/fanbingxin/local/go/src/runtime/proc.go:2957 +0x27d fp=0xc000048e78 sp=0xc000048e48 pc=0x403519d
runtime.cgocallbackg(0x0)
	/Users/fanbingxin/local/go/src/runtime/cgocall.go:188 +0xa3 fp=0xc000048ee0 sp=0xc000048e78 pc=0x4004e83
runtime.cgocallback_gofunc(0x40474ec, 0x4057dc0, 0xc000048f60, 0xc000048f90)
	/Users/fanbingxin/local/go/src/runtime/asm_amd64.s:793 +0x9b fp=0xc000048f00 sp=0xc000048ee0 pc=0x4055e5b
runtime.asmcgocall(0x4057dc0, 0xc000048f60)
	/Users/fanbingxin/local/go/src/runtime/asm_amd64.s:640 +0x42 fp=0xc000048f08 sp=0xc000048f00 pc=0x4055cf2
runtime.libcCall(0x4057dc0, 0xc000048f60, 0xc0000240b8)
	/Users/fanbingxin/local/go/src/runtime/sys_darwin.go:46 +0x6c fp=0xc000048f38 sp=0xc000048f08 pc=0x40474ec
runtime.exit(0xc000000000)
	/Users/fanbingxin/local/go/src/runtime/sys_darwin.go:220 +0x31 fp=0xc000048f60 sp=0xc000048f38 pc=0x4047aa1
runtime.main()
	/Users/fanbingxin/local/go/src/runtime/proc.go:225 +0x272 fp=0xc000048fe0 sp=0xc000048f60 pc=0x402df42
runtime.goexit()
	/Users/fanbingxin/local/go/src/runtime/asm_amd64.s:1357 +0x1 fp=0xc000048fe8 sp=0xc000048fe0 pc=0x4056581

rax    0x0
rbx    0x7fff99676380
rcx    0x7ffeefbff328
rdx    0x0
rdi    0x307
rsi    0x6
rbp    0x7ffeefbff360
rsp    0x7ffeefbff328
r8     0x0
r9     0x0
r10    0x0
r11    0x206
r12    0x307
r13    0x4
r14    0x6
r15    0x2d
rip    0x7fff60d7eb66
rflags 0x206
cs     0x7
fs     0x0
gs     0x0
example_glfw_opengl3(4340,0x7fff99676380) malloc: *** error for object 0x451a0c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
stack trace unavailable
example_glfw_opengl3(4340,0x7fff99676380) malloc: *** error for object 0x451a0c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
example_glfw_opengl3(4340,0x7fff99676380) malloc: *** error for object 0x451a0c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
example_glfw_opengl3(4340,0x7fff99676380) malloc: *** error for object 0x451a0c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
example_glfw_opengl3(4340,0x7fff99676380) malloc: *** error for object 0x451a0c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
example_glfw_opengl3(4340,0x7fff99676380) malloc: *** error for object 0x451a0c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
example_glfw_opengl3(4340,0x7fff99676380) malloc: *** error for object 0x451a0c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
example_glfw_opengl3(4340,0x7fff99676380) malloc: *** error for object 0x451a0c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
example_glfw_opengl3(4340,0x7fff99676380) malloc: *** error for object 0x451a0c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
example_glfw_opengl3(4340,0x7fff99676380) malloc: *** error for object 0x451a0c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
example_glfw_opengl3(4340,0x7fff99676380) malloc: *** error for object 0x451a0c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
example_glfw_opengl3(4340,0x7fff99676380) malloc: *** error for object 0x451a0c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
example_glfw_opengl3(4340,0x7fff99676380) malloc: *** error for object 0x451a0c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
example_glfw_opengl3(4340,0x7fff99676380) malloc: *** error for object 0x451a0c0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
fatal: morestack on gsignal

Custom fonts

How do I use a custom font with with lib using glfw as I am still pretty new to glfw in golang

InsertBytes() null pointer dereference

Calling InsertBytes() with bytes argument of length zero can panic the program.

The call to C.iggInputTextCallbackDataInsertBytes() should be inside the byteCount > 0 block.

	if (offset < 0) || (offset > data.bufTextLen()) {
		panic("invalid offset")
	}
	var bytesPtr *C.char
	byteCount := len(bytes)
	if byteCount > 0 {
		bytesPtr = (*C.char)(unsafe.Pointer(&bytes[0]))
		C.iggInputTextCallbackDataInsertBytes(data.handle, C.int(offset), bytesPtr, C.int(byteCount))
	}
}

Docking?

Are there any plans to bring in features from the imgui docking branch?

type [1073741824]uint16 too large

set GOARCH=386
\example_glfw_opengl3> go build -v -tags 'glfw' -o 32.exe .

D:\Golib\pkg\mod\github.com\inkyblackness\imgui-go\[email protected]\AllocatedGlyphRanges.go:32:16: type [1073741824]uint16 too large
D:\Golib\pkg\mod\github.com\inkyblackness\imgui-go\[email protected]\GlyphRanges.go:24:16: type [1073741824]uint16 too large

SetKeyboardFocusHere()

Please can you add SetKeyboardFocusHere(). I've vendored the latest version and added it myself and it's caused no problems.

I'd issue a pull request but frankly, I don't understand the tagging system at all.

Thank-you.

v2.0.0 can not be imported

Well, trying to do a proper v2 upgrade did not work out as intended.

Trying to upgrade imgui-go-examples to use v2.0.0 brings this error:

require github.com/inkyblackness/imgui-go: version "v2.0.0" invalid: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2

Trying to figure out what is intended.

Popup modal doesn't work

Popup doesn't show after I click the button.

        if imgui.Button("Click Me") {
		imgui.OpenPopup("Confirm")

		if imgui.BeginPopupModalV("Confirm", nil, imgui.WindowFlagsAlwaysAutoResize) {

			imgui.Text("Confirm to quit?")
			imgui.Separator()

			if imgui.Button("Yes") {
				imgui.CloseCurrentPopup()
			}
			imgui.SameLine()
			if imgui.Button("No") {
				imgui.CloseCurrentPopup()
			}

			imgui.EndPopup()
		}
	}

feat: MouseWheel

I have added a method to get the MouseWheel values from the IO, it is returned as a Vec2 where X is horizontal scroll, and y vertical scroll.
I can create a merge request if people agree with the change
melaurent@cd66bec

Cannot paste text to InputText by Cmd+v.

OS: MacOS 10.14.5

Platform: GLFW
Renderer:OpenGL3

Reproduce steps:

  1. Copy text from some other app by Cmd+c
  2. Click input text control
  3. Cmd+v

Expected result:
The text has been pasted into input text.

Actual result:
No text is pasted.

If I entered some text into input text control, select them, Cmd+c or Cmd+x, then Cmd+v will paste selected text into the input text.

Looks like the app has it's own clipboard, and cannot share with OS?

Light and Classic styles

I'm curious if you'd be interested in adding ports of the functions to set the "light" and "classic" styles that the C++ library offers? It looks like it would be pretty simple to create 2 funcs to match, something like StyleColorsLight(Style) and StyleColorsClassic(Style), and then use the color values from the C++ source to set all the appropriate style ids.

I'd be happy to write those and submit a pull request if you'd like to add it to your port.

By the way, thank you so much for porting the excellent Imgui library to Go. It is an oasis in a desert of quality gui packages in Go.

imgui.Image's render as monochrome

Hello,
Sort of my first time trying to get something like this to work. Trying to render a texture with imgui using imgui.Image - however the output is monochrome (tinted by whatever tint color is).

Example:
Image

Both of those 2 textures should be rendered in color but are monochromed somwhere between my call to Image() with the textureId and it drawing to the screen.

Also fails with the top image which is a framebuffer texture. Both of the 2 above textures render to the framebuffer texture just fine but the framebuffer texture itself gets monochromed (which i guess is consistent with the other textures).

Im using the glfw3 and opengl3 base but running opengl 4.1.

Any pointers to where to look or what to try would be appreciated.

android/arm build failure using gomobile

imgui-go version: v2.4.0
host os: macos 10.15.4
target: android/arm
golang version: go version go1.14.3 darwin/amd64 (via brew)
gomobile version: gomobile version +4c31acb Sun Mar 29 12:56:38 2020 +0000 (android); androidSDK=
android-ndk: 21

gomobile build -target=android/arm ./cmd/rogueliz
gomobile: go build -buildmode=c-shared -o /var/folders/bg/nsdt68_n3dj_cznhv6jb2wf00000gn/T/gomobile-work-444068505/lib/armeabi-v7a/librogueliz.so rogueliz/cmd/rogueliz failed: exit status 2
# github.com/inkyblackness/imgui-go/v2
warning: unknown warning option '-Wno-subobject-linkage' [-Wunknown-warning-option]
# github.com/inkyblackness/imgui-go/v2
../go/pkg/mod/github.com/inkyblackness/imgui-go/[email protected]/AllocatedGlyphRanges.go:34:16: type [1073741824]uint16 too large
../go/pkg/mod/github.com/inkyblackness/imgui-go/[email protected]/GlyphRanges.go:24:16: type [1073741824]uint16 too large

android/arm64 builds fine, so it looks like something is overflowing 32 bits (?) but I'm not familiar enough with the imgui-go code to know what it's doing at these points to offer a fix.

How to get startet with examples

I have an error when I try this example. imgui-go/_examples/opengl3_example/

Unresolved reference imguiGlfw3Init

What should I do?

imgui.BeginV not working?

Hi,

I've been trying to use:

if imgui.BeginV("Hello, world!", &aWindow, 0) {
...
}
imgui.End()

But ImGui::Begin always retuns 1 ?! Maybe it's a bug in ImgUI?

I could be mislead, please ignore if that's the case.

Cheers, and thanks for imgui-go.

Add fontawesome (AddFontFromFileTTFV)

Hey. help solve the problem when trying to connect the fontawawsome font through the AddFontFromFileTTFV function instead of the "?" icons.
Безымянный
font const

ICON_MIN_FA = 0xf000
ICON_MAX_FA = 0xf941
....
ICON_FA_ANGLE_DOWN = '\uf107'
ICON_FA_ANGLE_LEFT = '\uf104'
if imgui.ButtonV(string(ICON_FA_ANGLE_LEFT), app.buttonSizeBigSquare) {

}
imgui.SameLine()
if imgui.ButtonV(fmt.Sprintf("%c", ICON_FA_ANGLE_LEFT), app.buttonSizeBigSquare) {

}
imgui.SameLine()
if imgui.ButtonV(fmt.Sprintf("%#U", ICON_FA_ANGLE_LEFT), app.buttonSizeBigSquare) {

}
imgui.SameLine()
if imgui.ButtonV(fmt.Sprintf("%+q", ICON_FA_ANGLE_LEFT), app.buttonSizeBigSquare) {

}
imgui.SameLine()
if imgui.ButtonV(fmt.Sprintf("%v", ICON_FA_ANGLE_LEFT), app.buttonSizeBigSquare) {

}
imgui.SameLine()
if imgui.ButtonV(fmt.Sprintf("%s", ICON_FA_ANGLE_LEFT), app.buttonSizeBigSquare) {

}

code add font

fonts := imgui.CurrentIO().Fonts()

fonts.AddFontDefault()

fileFA := "font/fa-regular-400.ttf"
fontConfigFA := imgui.NewFontConfig()
//fontConfigFA.SetGlyphMinAdvanceX(float32(ICON_MIN_FA))
//fontConfigFA.SetGlyphMaxAdvanceX(float32(ICON_MAX_FA))
fontConfigFA.SetMergeMode(true)
fontConfigFA.SetPixelSnapH(true)
var builderFA imgui.GlyphRangesBuilder
builderFA.Add(rune(ICON_MIN_FA), rune(ICON_MAX_FA))
//builderFA.Add(ICON_FA_ANGLE_LEFT, ICON_FA_ANGLE_DOWN)

rangesFA := builderFA.Build()


fonts.AddFontFromFileTTFV(fileFA, 16, fontConfigFA, rangesFA.GlyphRanges)
image := fonts .TextureDataAlpha8()
	
var lastTexture int32
gl.GetIntegerv(gl.TEXTURE_BINDING_2D, &lastTexture)
gl.GenTextures(1, &renderer.fontTexture)
gl.BindTexture(gl.TEXTURE_2D, renderer.fontTexture)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
gl.PixelStorei(gl.UNPACK_ROW_LENGTH, 0)
gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RED, int32(image.Width), int32(image.Height),
	0, gl.RED, gl.UNSIGNED_BYTE, image.Pixels)

fonts .SetTextureID(imgui.TextureID(renderer.fontTexture))

gl.BindTexture(gl.TEXTURE_2D, uint32(lastTexture))

What could be the problem and how it can be solved.

Exception 0xc0000005 - unknown pc

Hey there,

I seem to have an issue with imgui-go and I can't really figure it out where it is. Trying to run the following code:

Main.go //added this function to your Main.go

func Main() {
	Begin("Hello World")
	if BeginMenuBar() {
		if BeginMenu("Menu") {
			EndMenu()
		}
		if BeginMenu("Examples") {
			EndMenu()
		}
		if BeginMenu("Tools") {
			EndMenu()
		}

		EndMenuBar()
	}

	Text(fmt.Sprintf("dear imgui says hello. (%s)", Version()))
}

Main_test.go

func TestVersion(t *testing.T) {
	imgui.Main()
	assert.Equal(t, true, true)
}

I get this following exception:

=== RUN   TestVersion
Exception 0xc0000005 0x0 0x1a14 0xaa8427
PC=0xaa8427

runtime: unknown pc 0xaa8427
stack: frame={sp:0xf9ffbff3d0, fp:0x0} stack=[0x0,0xf9ffbff710)

000000f9ffbff2d0:  00000048ece34201  00000000009a7f9e <testing.tRunner+30> 
000000f9ffbff2e0:  00000265ed1a0000  00000265ed1a7f58 
000000f9ffbff2f0:  0000000000000001  ffffffffffbff4a8 
000000f9ffbff300:  00000000009a7d00 <testing.(*common).runCleanup+224>  0000000000000005 
000000f9ffbff310:  000000c00000ac00  00000265ed1a7f60 
000000f9ffbff320:  0000000000000000  0000000000000001 
000000f9ffbff330:  00000265ed1a7f50  0000000000af3780 
000000f9ffbff340:  0000000000000000  00000000009a7fc7 <testing.tRunner+71> 
000000f9ffbff350:  00000265ed1a0150  0000000000c5a401 
000000f9ffbff360:  0000000000000005  0000000000000080 
000000f9ffbff370:  00000265ed1a7f50  000000f9ffbff488 
000000f9ffbff380:  0000000000000005  00000000009218a1 <runtime.goexit+1> 
000000f9ffbff390:  0000000000af3780  000000f9ffbff668 
000000f9ffbff3a0:  0000000000910b2f <runtime.gentraceback+3791>  0000000000000002 
000000f9ffbff3b0:  00000265ed1a1360  0000000000000005 
000000f9ffbff3c0:  0000000000000000  00000265ed1a0150 
000000f9ffbff3d0: <00000000ffffffff  0000000000000007 
000000f9ffbff3e0:  0000000000000000  0000000000000001 
000000f9ffbff3f0:  00000000009a7fc6 <testing.tRunner+70>  0000000000000005 
000000f9ffbff400:  00000000009a7fc7 <testing.tRunner+71>  0000000000000000 
000000f9ffbff410:  0000d251fff946d6  0000000000000000 
000000f9ffbff420:  0000000000000000  000000c000073fc8 
000000f9ffbff430:  000000c00000acf0  0000000000000020 
000000f9ffbff440:  0000000000000000  0000000000000000 
000000f9ffbff450:  000002652e00002e  00000265ed1a2914 
000000f9ffbff460:  0000000000000000  00007ffeb50001b4 
000000f9ffbff470:  0000000000030000  0000000007000007 
000000f9ffbff480:  00000265ece14e50  00000000009a7fc7 <testing.tRunner+71> 
000000f9ffbff490:  000000480008fb38  000000002e00002e 
000000f9ffbff4a0:  0000000000000000  00000000b50001b4 
000000f9ffbff4b0:  0000000000000000  000000002e00002e 
000000f9ffbff4c0:  000001180008fa23  0000000000000000 
runtime: unknown pc 0xaa8427
stack: frame={sp:0xf9ffbff3d0, fp:0x0} stack=[0x0,0xf9ffbff710)

000000f9ffbff2d0:  00000048ece34201  00000000009a7f9e <testing.tRunner+30> 
000000f9ffbff2e0:  00000265ed1a0000  00000265ed1a7f58 
000000f9ffbff2f0:  0000000000000001  ffffffffffbff4a8 
000000f9ffbff300:  00000000009a7d00 <testing.(*common).runCleanup+224>  0000000000000005 
000000f9ffbff310:  000000c00000ac00  00000265ed1a7f60 
000000f9ffbff320:  0000000000000000  0000000000000001 
000000f9ffbff330:  00000265ed1a7f50  0000000000af3780 
000000f9ffbff340:  0000000000000000  00000000009a7fc7 <testing.tRunner+71> 
000000f9ffbff350:  00000265ed1a0150  0000000000c5a401 
000000f9ffbff360:  0000000000000005  0000000000000080 
000000f9ffbff370:  00000265ed1a7f50  000000f9ffbff488 
000000f9ffbff380:  0000000000000005  00000000009218a1 <runtime.goexit+1> 
000000f9ffbff390:  0000000000af3780  000000f9ffbff668 
000000f9ffbff3a0:  0000000000910b2f <runtime.gentraceback+3791>  0000000000000002 
000000f9ffbff3b0:  00000265ed1a1360  0000000000000005 
000000f9ffbff3c0:  0000000000000000  00000265ed1a0150 
000000f9ffbff3d0: <00000000ffffffff  0000000000000007 
000000f9ffbff3e0:  0000000000000000  0000000000000001 
000000f9ffbff3f0:  00000000009a7fc6 <testing.tRunner+70>  0000000000000005 
000000f9ffbff400:  00000000009a7fc7 <testing.tRunner+71>  0000000000000000 
000000f9ffbff410:  0000d251fff946d6  0000000000000000 
000000f9ffbff420:  0000000000000000  000000c000073fc8 
000000f9ffbff430:  000000c00000acf0  0000000000000020 
000000f9ffbff440:  0000000000000000  0000000000000000 
000000f9ffbff450:  000002652e00002e  00000265ed1a2914 
000000f9ffbff460:  0000000000000000  00007ffeb50001b4 
000000f9ffbff470:  0000000000030000  0000000007000007 
000000f9ffbff480:  00000265ece14e50  00000000009a7fc7 <testing.tRunner+71> 
000000f9ffbff490:  000000480008fb38  000000002e00002e 
000000f9ffbff4a0:  0000000000000000  00000000b50001b4 
000000f9ffbff4b0:  0000000000000000  000000002e00002e 
000000f9ffbff4c0:  000001180008fa23  0000000000000000 

goroutine 6 [syscall]:
github.com/inkyblackness/imgui-go/v2._Cfunc_iggBegin(0x265ed1a7f60, 0x0, 0x0, 0xc000000000)
	_cgo_gotypes.go:386 +0x54
github.com/inkyblackness/imgui-go/v2.BeginV(0xb806e6, 0xb, 0x0, 0x0, 0x0)
	C:/Users/wenga/go/src/awesomeProject6/Window.go:92 +0xa9
github.com/inkyblackness/imgui-go/v2.Begin(...)
	C:/Users/wenga/go/src/awesomeProject6/Window.go:97
github.com/inkyblackness/imgui-go/v2.Main()
	C:/Users/wenga/go/src/awesomeProject6/Main.go:36 +0x49
github.com/inkyblackness/imgui-go/v2_test.TestVersion(0xc00005f380)
	C:/Users/wenga/go/src/awesomeProject6/Main_test.go:12 +0x29
testing.tRunner(0xc00005f380, 0xb92ed0)
	C:/Program Files/Go/src/testing/testing.go:1123 +0xef
created by testing.(*T).Run
	C:/Program Files/Go/src/testing/testing.go:1168 +0x2b3

goroutine 1 [chan receive]:
testing.(*T).Run(0xc00005f380, 0xb807d8, 0xb, 0xb92ed0, 0x947401)
	C:/Program Files/Go/src/testing/testing.go:1169 +0x2da
testing.runTests.func1(0xc00005f200)
	C:/Program Files/Go/src/testing/testing.go:1439 +0x7f
testing.tRunner(0xc00005f200, 0xc000123de0)
	C:/Program Files/Go/src/testing/testing.go:1123 +0xef
testing.runTests(0xc000004700, 0xb1da00, 0x15, 0x15, 0x0, 0x0, 0x0, 0x8bf630)
	C:/Program Files/Go/src/testing/testing.go:1437 +0x310
testing.(*M).Run(0xc00016e000, 0x0)
	C:/Program Files/Go/src/testing/testing.go:1345 +0x1f5
main.main()
	_testmain.go:85 +0x145
rax     0xc000074000
rbx     0xc000073e78
rcx     0x265ed1a7f60
rdi     0xc000074000
rsi     0x0
rbp     0xc000073e38
rsp     0xf9ffbff3d0
r8      0x0
r9      0x0
r10     0x2
r11     0xc00006aeb0
r12     0xb50d40
r13     0xbb8659
r14     0x0
r15     0x200
rip     0xaa8427
rflags  0x10206
cs      0x33
fs      0x53
gs      0x2b


Process finished with exit code 1

Clearly there is something happening with C.iggBegin(idArg, openArg, C.int(flags)) != 0. I can reproduce this issue on two different PCs. Imgui was running perfectly last December (hence the v2.6.0). The C++ Dear Imgui is working fine without issues.

If you need anything else, let me know.

OS: Windows 10 20H2
GPU: Nvidia
imgui-go version: v2.6.0 (same issue with v3.0.0)

Statement about cimgui not up to date

Hi,

I could see at the readme:

Extrawurst/cimgui. Reasons for dismissal at time of decision:

Was using old API (1.5x), 1.6x was attempted
Apparently semi-exposed the C++ API, especially through the structures
Adding this adds another dependency 

This is no longer true: The C-binding is now programatically generated so it is always up to date.
You can even generate it for whatever branch and version you desire. You can include ImGui internal API if you need it, It provides json files with information relevant to functions, structs and enums in order to allow binding makers to regenerate their bindings programatically.

I am open to questions, suggestions to facilitate the making of your binding.

imguiWrapperTypes.h should use "uintptr_t" instead of "void*"

In Go 1.14, the Go compiler added a "checkptr" feature that detects misuse of unsafe.Pointer. It's triggering within imgui-go because of conversions like here:

return C.IggTextureID(id)

The problem is IggTextureID is declared in imguiWrapperTypes.h as typedef void *IggTextureID. This makes cgo use unsafe.Pointer when representing this type in Go.

If you instead #include <stdint.h> and use typedef uintptr_t IggTextureID, the error should go away.

Version 1.76

Version 1.76 is out, please consider update your great wrapper. Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.