go-gl / gl

Go bindings for OpenGL (generated via glow)
MIT License
1.09k stars 73 forks source link

Cannot cross-compile from Linux to Windows #155

Open vonaka opened 1 year ago

vonaka commented 1 year ago

I'm trying to compile my application from Linux to Windows. I use go-gl jointly with go-sdl2 and to compile the program I follow these instructions. Additionally, I set CGO_CFLAGS to -DTAG_WINDOWS -D_WIN32 and CGO_LDFLAGS to -lopengl32 and I run go build with WGL tag:

env CGO_ENABLED="1" CC="/usr/bin/x86_64-w64-mingw32-gcc" GOOS="windows" \
CGO_LDFLAGS="-lmingw32 -lSDL2 -lSDL2_image -lSDL2_ttf -lopengl32" \
CGO_CFLAGS="-D_REENTRANT -DTAG_WINDOWS -D_WIN32" \
go build -tags WGL -x test.go

Unfortunately, when I run the program on my Windows machine gl.Init fails to load glGetnTexImage. Following README, I call gl.Init after activating OpenGL context:

sdl.SetHint(sdl.HINT_RENDER_DRIVER, "opengl")
if glContext, err = window.GLCreateContext(); err != nil {
    //...
}
window.GLMakeCurrent(glContext)
if err = gl.Init(); err != nil {
    //...
}

On Windows I have opengl 4.6.

duysqubix commented 1 year ago

Does this have an update by any chance?

Attempting to do the same thing, but:

package command-line-arguments
        imports github.com/duysqubix/gobc/internal/windows
        imports github.com/gopxl/pixel/v2/pixelgl
        imports github.com/go-gl/gl/v3.3-core/gl: build constraints exclude all Go files in /home/rpl-node/go/pkg/mod/github.com/go-gl/gl@v0.0.0-20211210172815-726fda9656d6/v3.3-core/gl
vincent-alxr commented 9 months ago

Does this have an update by any chance?

Attempting to do the same thing, but:

package command-line-arguments
        imports github.com/duysqubix/gobc/internal/windows
        imports github.com/gopxl/pixel/v2/pixelgl
        imports github.com/go-gl/gl/v3.3-core/gl: build constraints exclude all Go files in /home/rpl-node/go/pkg/mod/github.com/go-gl/gl@v0.0.0-20211210172815-726fda9656d6/v3.3-core/gl

I haved this issue, ensure mingw is correctly set in your var environnement