Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] support integration with go-sdl2 binding? #923

Open
shellohunter opened this issue Nov 30, 2024 · 5 comments
Open

[Feature Request] support integration with go-sdl2 binding? #923

shellohunter opened this issue Nov 30, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@shellohunter
Copy link

Related problem

No response

Your request

I know that giu can work with sdl2 backend, but it goes with sdl2 cgo, right?
Is it possible to integrate giu with go-sdl2 ((https://github.com/veandco/go-sdl2) ? I mean, seamlessly.
yesterday I gave it a try and it seems they two have their owen deps, and work independently.

Alternative solution

No response

Additional context

No response

@shellohunter shellohunter added the enhancement New feature or request label Nov 30, 2024
@gucio321
Copy link
Collaborator

you can deffinitly integrate cimgui-go with go-sdl if you want (however idk why would you need this as ther is an sdl backend already - I'm not a big fan of it but iirc @AllenDang had some reasons to do this with CGO for glfw and I did similar thing for sdl).

In case of giu - Technically its 100% possible to make giu use sdl instead of glfw, but it wan't tested yet 😄. You can be the first one who tries.

(I think laud here):
Technically you need to override giu.Context.backend with sdlbackend from cimgui-go. The problem is that backdne.Backend is a generic type so this might be difficult to write this variable in giu 🤔
if you change

// before
type GIUContext struct {
        backend backend.Backend[glfwbackend.GLFWWindowFlags]
// after
type GIUContext[FLAGST ~int] struct {
        backend backend.Backend[FLAGST]

Now it will be difficutl to define giu.Context variable's type

This might require some cimgui-go refactor as well

@shellohunter
Copy link
Author

Here's my scenario: I've been working on a go-sdl2 project for a couple of days, it goes well, then I want to add a gui toolset for it, so I found giu. the demo was pretty cute, exactly what I'm looking for. I think there should be more gl-sdl2 users thinking about the same thing.

unfortunately, once I introduce giu into the project, my go-sdl2 program keeps throwing unknown errors. I mean, some of the go-sdl2 api stop working and give me an empty error. those errors are all gone if I eliminate giu code.

After some debugging, I realized that the two projects were not working the way I expected.

Thanks for you suggestion. giu is quite a new thing to me, I'll dig for a while see if I can make it~

@gucio321
Copy link
Collaborator

@shellohunter as far as I see, the thing you're looking for is rather cimgui-go, not giu.
We try to keep giu as simple as possible. Especially we want users don't need to care about so called backend (opengl/glfw/sdl things) so giu is really top-level. We can ofc consider adding some features to change backend (as long as it is fully optional)

Generally first of all you need to implement your use-case with cimgui-go

@shellohunter
Copy link
Author

yes, you would be right.
I thought cimgui-go was a auto-generated binding, so i post it here since giu is more active, :-)
actually I also tried cimgui-go with go-sdl2, and I got the same errors. so, the situation is pretty much the same. hopefully replacing the backend could be the way out.

@gucio321
Copy link
Collaborator

yes, you need to implement backend almost from scratch as contexts and other things must match your sdl and opengl instnce.

I thought cimgui-go was a auto-generated binding

cimgui-go/backend is 100% manually-writen 😄

btw, if you like discord we've started a server:

Discord Shield

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants