~eliasnaur/gio

4 2

Embed Gio with other OpenGL rendering

Zhao Wang
Details
Message ID
<CAHQ-fMaYCFnskcZ-Ndtv=DZcBQJaKApXArkWohXGY5hT-f_HWw@mail.gmail.com>
DKIM signature
pass
Download raw message
On Tue, Jan 26, 2021 at 5:51 AM Elias Naur <mail@eliasnaur.com> wrote:
>
> If you don't mind, let's continue this discussion on the Gio mailing
> list[0], as I'm sure embedding will interest others. If you agree, send
> your replies CC'ed ~eliasnaur/gio@lists.sr.ht.
>
> [0] https://lists.sr.ht/~eliasnaur/gio
>

Sounds good. Sharing this with Gio mailing list now and modified title

> On Mon Jan 25, 2021 at 17:40, Zhao Wang wrote:
> > On Mon, Jan 25, 2021 at 2:05 AM Elias Naur <mail@eliasnaur.com> wrote:
> > >
> > > On Mon Jan 25, 2021 at 7:08 AM CET, Zhao Wang wrote:
> > > > Hi Elias,
> > > >
> > > > On Sat, Jan 23, 2021 at 2:12 AM Elias Naur <mail@eliasnaur.com> wrote:
> > > > >
> > > > > On Sat Jan 23, 2021 at 9:53 AM CET, Zhao Wang wrote:
> > > > >
> > > > > Another option is to share rendered textures between D3D11 and OpenGL
> > > > > ES. If you're using ANGLE for OpenGL ES anyway, there are extensions such
> > > > > as [2] that may allow clean mixing of OpenGL and Direct3D.
> > > > >
> > > >
> > > > Thanks for the info, I will take a look at this later too. However, we
> > > > use standard
> > > > OpenGL ES API, requiring to use extensions might not work for us as it
> > > > will likely
> > > > require many changes to existing game rendering libraries (written in
> > > > TypeScript
> > > > and bindings through JavascriptCore on iOS and V8 on android)
> > > >
> > >
> > > The extension is question is an EGL extension, and (if it works) will
> > > only be used by the top-level machinery to render D3D11 Gio content into
> > > a shared texture that OpenGL can use as any other texture.
> > >
> > > In other words, I think (but haven't tried) the extension allows this
> > > flow:
> > >
> > > 1. Create GLFW native window using ANGLE for as the OpenGL
> > > implementation.
> > > 2. Use ANGLE extension to create a texture shared between OpenGL
> > > and D3D11.
> > > 2. Render game content (OpenGL) into the window.
> > > 3. Render Gio content (D3D11) into the off-screen texture.
> > > 4. Use OpenGL to render the off-screen texture on top of the game
> > > content.
> > >
> >
> > The current GLFW example in gio-example is not doing this flow, right?
> > I likely need to research more to understand this better. An example will
> > be very helpful if you have one or can easily get one.
> >
>
> I found an ANGLE test[1] that seems to demonstrate what we need. I also
> found a possibly outdated article in the discontinued microsoft fork of
> Angle, [2].
>
> [1] https://github.com/google/angle/blob/master/src/tests/egl_tests/EGLPresentPathD3D11Test.cpp
> [2] https://github.com/Microsoft/angle/wiki/Interop-with-other-DirectX-code
>

Cool, thank you, Will check this out

> > > > >
> > > > > > > The example mixes custom OpenGL and Gio. However, note that more work is
> > > > > > > required to mix different GPU APIs. As long as separate windows are ok,
> > > > > > > you can use Gio windows for Gio content and GLFW windows for OpenGL
> > > > > > > content.
> > > > > > >
> > > > > >
> > > > > > Currently, Is it possible to have a GIO window only for GIO contents,
> > > > > > and
> > > > > > then allow tapping GIO window buttons to display a GLFW window? Based on
> > > > > > what you said above, it seems to be possible. I tried it earlier but
> > > > > > failed. I will try again later.
> > > > > >
> > > > > >
> > > > >
> > > > > Mixing windows from GLFW and Gio *should* work, or be able to work with
> > > > > few tweaks. If you have, say, a patch against the glfw example and an
> > > > > error I can take a look.
> > > >
> > > > I used gio-example/multiwindow example, made a commit here[1]. Now when
> > > > I click "More" button, it will cause the app non-responding without
> > > > showing any errors.
> > > >
> > >
> > > Which platform are you testing this on? Note that the app.Main call
> > > blocks forever, which means that you should move the event processing of
> > > the GLFW window into a separate goroutine.
> >
> > For this one, I was testing on Mac OS. I will make some changes to try
> > to get it to work based on your suggestions. Thanks.
> >
>
> Oh yes, Apple :) macOS has the additional requirement that all GUI
> manipulation happen on the main thread. In particular there can only be
> one NSApp delegate. Gio sets up its own delegate[3], and I'm sure GLFW
> sets up a different one.
>
> I don't expect too much trouble getting Gio and GLFW to coordinate the
> global state on macOS, but since you're going to need game/gui mixing
> anyway, I suggest staying with only GLFW windows for now. You should
> see no loss of functionality: a given GLFW window can certainly contain
> either Gio content or game content, as demonstrated by the glfw example.
> And you lose no generality because you require OpenGL, at least for now.
>
> [3] https://git.sr.ht/~eliasnaur/gio/tree/main/item/app/internal/window/os_macos.m#L216
>

I see, making sense. Mac OS X will be something less priority for me.
So will stick with GLFW for now

> > > On Mon Jan 25, 2021 at 8:43 AM CET, Zhao Wang wrote:
> > > > I just tried the GLFW example on windows, it failed as expected as
> > > > shown by the attachment.
> > > >
> > > > It panic when trying to GetString for Extension during initializing a
> > > > new backend.
> > > >
> > >
> > > The OpenGL backend depends on ANGLE to work. I have an old build here[0]
> > > if you like. Place the DLLs in the same directory as the GLFW binary (or
> > > the current directory if you're using `go run`).
> > >
> >
> > Regarding running the glfw example on windows, I put these DLLs in the
> > same directory as the GLFW binary and do "go run". I got this error when
> > creating new backend:
> >
> > "2021/01/25 16:52:52 failed to parse OpenGL ES version ()"
> >
> > It returns empty string for OpenGL ES version and thus failed at this line
> > in NewBackend method:
> >
> > "glimpl.ParseGLVersion()"
> >
> > Will dig more into this to collect more information.
> >
>
> I found and fixed an issue that should fix the above error [4]. Please
> try again.
>
> Elias
>
> [4] https://gioui.org/commit/57872856e8c5b5de

Tried again with latest Gio, seems still the same problem. I made
a commit here [0]. Do I need to include the ANGEL binaries?
I am not sure if the ones [1] you gave me already include
everything we need.

[0] https://github.com/zwang/gio-example/commit/3c34d05d121ba722f6bd8b926f21ef1fb3246988
[1] https://drive.google.com/file/d/1k2950mHNtR2iwhweHS1rJ7reChTa3rki/view?usp=sharing
Details
Message ID
<C8U3CE44HI5S.35ZOX10ETRGZK@testmac>
In-Reply-To
<CAHQ-fMaYCFnskcZ-Ndtv=DZcBQJaKApXArkWohXGY5hT-f_HWw@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
On Tue Jan 26, 2021 at 23:41 CET, Zhao Wang wrote:
> On Tue, Jan 26, 2021 at 5:51 AM Elias Naur <mail@eliasnaur.com> wrote:
> > On Mon Jan 25, 2021 at 17:40, Zhao Wang wrote:
> > > On Mon, Jan 25, 2021 at 2:05 AM Elias Naur <mail@eliasnaur.com> wrote:
> > > > On Mon Jan 25, 2021 at 8:43 AM CET, Zhao Wang wrote:
> > > > > I just tried the GLFW example on windows, it failed as expected as
> > > > > shown by the attachment.
> > > > >
> > > > > It panic when trying to GetString for Extension during initializing a
> > > > > new backend.
> > > > >
> > > >
> > > > The OpenGL backend depends on ANGLE to work. I have an old build here[0]
> > > > if you like. Place the DLLs in the same directory as the GLFW binary (or
> > > > the current directory if you're using `go run`).
> > > >
> > >
> > > Regarding running the glfw example on windows, I put these DLLs in the
> > > same directory as the GLFW binary and do "go run". I got this error when
> > > creating new backend:
> > >
> > > "2021/01/25 16:52:52 failed to parse OpenGL ES version ()"
> > >
> > > It returns empty string for OpenGL ES version and thus failed at this line
> > > in NewBackend method:
> > >
> > > "glimpl.ParseGLVersion()"
> > >
> > > Will dig more into this to collect more information.
> > >
> >
> > I found and fixed an issue that should fix the above error [4]. Please
> > try again.
> >
> > Elias
> >
> > [4] https://gioui.org/commit/57872856e8c5b5de
>
> Tried again with latest Gio, seems still the same problem. I made
> a commit here [0]. Do I need to include the ANGEL binaries?
> I am not sure if the ones [1] you gave me already include
> everything we need.
>
> [0] https://github.com/zwang/gio-example/commit/3c34d05d121ba722f6bd8b926f21ef1fb3246988
> [1] https://drive.google.com/file/d/1k2950mHNtR2iwhweHS1rJ7reChTa3rki/view?usp=sharing

The Gio fix only covered the kitchen example on Linux/Wine. Testing on
Windows proper revealed another issue: the glfw example always selects
the desktop OpenGL, which on Windows is something different than ANGLE.
Gio and GLFW thus ends up with different OpenGL function pointers.

I added support for EGL to the glfw example here: [0]. The OpenGL ES
bindings package "github.com/go-gl/gl/v3.1/gles2" does not build on
macOS[1], so you'll have to outcomment the gles2 references to see it in
action on Windows.

It doesn't actually work on Windows either without this fix to the
glow generator[2]. You'll need to run the generator to generate a
compatible package:

$ cd glow-with-pr-112
$ go build ./glow generate -api=gles2 -version=3.1
$ mv gl/*.go ../gl/v3.1/gles2 # a checkout version of github.com/go-gl/gl

Finally, you'll need the EGL headers and of course the ANGLE EGL library
to run the example on Windows:

$ cd gl
$ go mod init github.com/go-gl/gl
$ cd ../gio-example
$ go mod edit -replace github.com/go-gl/gl=../gl
$ CGO_FLAGS="-I<path to angle checkout>\include" CGO_LDFLAGS="-L<path to libEGL.dll>" go run -tags egl ./glfw

The "egl" tag instructs go-gl to use the EGL mechanism to load function
pointers.

Now this is all quite cumbersome. Even with the generator patch
upstreamed and go-gl updated, you still need to use different packages
"github.com/go-gl/gl/v3.3-core/gl" vs "github.com/go-gl/gl/v3.1/gles2"
to cover both macOS (only desktop OpenGL) and Windows (ANGLE). Even
though most functions behave the same.

However, note that the trouble is only about the OpenGL function
pointers (glActiveTexture, glDrawArrays etc.). Your game may already
have a facility to acquire function pointers, or you can create one
tailored to your use-case. From scratch, or using go-gl or Gio's
code as a starting point.

[0] https://git.sr.ht/~eliasnaur/gio-example/commit/c7035e4f63b1a70da0593b7b173f59b63765d640
[1] https://github.com/go-gl/gl/issues/125
[2] https://github.com/go-gl/glow/pull/112

Elias
Details
Message ID
<CAHQ-fMYSe0OXg-=vpJGuKFDLEnQSjtZXLy03CZ1UdGGYiyw4Xw@mail.gmail.com>
In-Reply-To
<C8U3CE44HI5S.35ZOX10ETRGZK@testmac> (view parent)
DKIM signature
pass
Download raw message
This works, thank you!

On Wed, Jan 27, 2021 at 8:45 AM Elias Naur <mail@eliasnaur.com> wrote:
>
> On Tue Jan 26, 2021 at 23:41 CET, Zhao Wang wrote:
> > On Tue, Jan 26, 2021 at 5:51 AM Elias Naur <mail@eliasnaur.com> wrote:
> > > On Mon Jan 25, 2021 at 17:40, Zhao Wang wrote:
> > > > On Mon, Jan 25, 2021 at 2:05 AM Elias Naur <mail@eliasnaur.com> wrote:
> > > > > On Mon Jan 25, 2021 at 8:43 AM CET, Zhao Wang wrote:
> > > > > > I just tried the GLFW example on windows, it failed as expected as
> > > > > > shown by the attachment.
> > > > > >
> > > > > > It panic when trying to GetString for Extension during initializing a
> > > > > > new backend.
> > > > > >
> > > > >
> > > > > The OpenGL backend depends on ANGLE to work. I have an old build here[0]
> > > > > if you like. Place the DLLs in the same directory as the GLFW binary (or
> > > > > the current directory if you're using `go run`).
> > > > >
> > > >
> > > > Regarding running the glfw example on windows, I put these DLLs in the
> > > > same directory as the GLFW binary and do "go run". I got this error when
> > > > creating new backend:
> > > >
> > > > "2021/01/25 16:52:52 failed to parse OpenGL ES version ()"
> > > >
> > > > It returns empty string for OpenGL ES version and thus failed at this line
> > > > in NewBackend method:
> > > >
> > > > "glimpl.ParseGLVersion()"
> > > >
> > > > Will dig more into this to collect more information.
> > > >
> > >
> > > I found and fixed an issue that should fix the above error [4]. Please
> > > try again.
> > >
> > > Elias
> > >
> > > [4] https://gioui.org/commit/57872856e8c5b5de
> >
> > Tried again with latest Gio, seems still the same problem. I made
> > a commit here [0]. Do I need to include the ANGEL binaries?
> > I am not sure if the ones [1] you gave me already include
> > everything we need.
> >
> > [0] https://github.com/zwang/gio-example/commit/3c34d05d121ba722f6bd8b926f21ef1fb3246988
> > [1] https://drive.google.com/file/d/1k2950mHNtR2iwhweHS1rJ7reChTa3rki/view?usp=sharing
>
> The Gio fix only covered the kitchen example on Linux/Wine. Testing on
> Windows proper revealed another issue: the glfw example always selects
> the desktop OpenGL, which on Windows is something different than ANGLE.
> Gio and GLFW thus ends up with different OpenGL function pointers.
>
> I added support for EGL to the glfw example here: [0]. The OpenGL ES
> bindings package "github.com/go-gl/gl/v3.1/gles2" does not build on
> macOS[1], so you'll have to outcomment the gles2 references to see it in
> action on Windows.
>
> It doesn't actually work on Windows either without this fix to the
> glow generator[2]. You'll need to run the generator to generate a
> compatible package:
>
> $ cd glow-with-pr-112
> $ go build ./glow generate -api=gles2 -version=3.1
> $ mv gl/*.go ../gl/v3.1/gles2 # a checkout version of github.com/go-gl/gl
>
Will this change be made to github.com/go-gl/gl/v3.1/gles2 master too?
Sounds like it should be.

> Finally, you'll need the EGL headers and of course the ANGLE EGL library
> to run the example on Windows:
>
> $ cd gl
> $ go mod init github.com/go-gl/gl
> $ cd ../gio-example
> $ go mod edit -replace github.com/go-gl/gl=../gl
> $ CGO_FLAGS="-I<path to angle checkout>\include" CGO_LDFLAGS="-L<path to libEGL.dll>" go run -tags egl ./glfw
>
> The "egl" tag instructs go-gl to use the EGL mechanism to load function
> pointers.
>
This works for me with some changes. I first put the flags into
environment variables.
Then used CGO_CFLAGS instead of CGO_FLAGS.
Then when I run, I go to gio-example/glfw foder, run go run -tags egl main.go
In gio-example/glfw, I have the generated angle libs as attached above
in angels.zip

> Now this is all quite cumbersome. Even with the generator patch
> upstreamed and go-gl updated, you still need to use different packages
> "github.com/go-gl/gl/v3.3-core/gl" vs "github.com/go-gl/gl/v3.1/gles2"
> to cover both macOS (only desktop OpenGL) and Windows (ANGLE). Even
> though most functions behave the same.
>
> However, note that the trouble is only about the OpenGL function
> pointers (glActiveTexture, glDrawArrays etc.). Your game may already
> have a facility to acquire function pointers, or you can create one
> tailored to your use-case. From scratch, or using go-gl or Gio's
> code as a starting point.
>
This is indeed cumbersome, I will definitely checkout go-gl and Gio's code
as examples. Thank you very much for your help.

> [0] https://git.sr.ht/~eliasnaur/gio-example/commit/c7035e4f63b1a70da0593b7b173f59b63765d640
> [1] https://github.com/go-gl/gl/issues/125
> [2] https://github.com/go-gl/glow/pull/112
>
> Elias
Details
Message ID
<C8UM5K2IF52G.SP1LVXU7VNVS@testmac>
In-Reply-To
<CAHQ-fMYSe0OXg-=vpJGuKFDLEnQSjtZXLy03CZ1UdGGYiyw4Xw@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
On Wed Jan 27, 2021 at 23:45 CET, Zhao Wang wrote:
> This works, thank you!
>
> On Wed, Jan 27, 2021 at 8:45 AM Elias Naur <mail@eliasnaur.com> wrote:
> >
> > On Tue Jan 26, 2021 at 23:41 CET, Zhao Wang wrote:
> > > On Tue, Jan 26, 2021 at 5:51 AM Elias Naur <mail@eliasnaur.com> wrote:
> > > > On Mon Jan 25, 2021 at 17:40, Zhao Wang wrote:
> > > > > On Mon, Jan 25, 2021 at 2:05 AM Elias Naur <mail@eliasnaur.com> wrote:
> > > > > > On Mon Jan 25, 2021 at 8:43 AM CET, Zhao Wang wrote:
> > > > > > > I just tried the GLFW example on windows, it failed as expected as
> > > > > > > shown by the attachment.
> > > > > > >
> > > > > > > It panic when trying to GetString for Extension during initializing a
> > > > > > > new backend.
> > > > > > >
> > > > > >
> > > > > > The OpenGL backend depends on ANGLE to work. I have an old build here[0]
> > > > > > if you like. Place the DLLs in the same directory as the GLFW binary (or
> > > > > > the current directory if you're using `go run`).
> > > > > >
> > > > >
> > > > > Regarding running the glfw example on windows, I put these DLLs in the
> > > > > same directory as the GLFW binary and do "go run". I got this error when
> > > > > creating new backend:
> > > > >
> > > > > "2021/01/25 16:52:52 failed to parse OpenGL ES version ()"
> > > > >
> > > > > It returns empty string for OpenGL ES version and thus failed at this line
> > > > > in NewBackend method:
> > > > >
> > > > > "glimpl.ParseGLVersion()"
> > > > >
> > > > > Will dig more into this to collect more information.
> > > > >
> > > >
> > > > I found and fixed an issue that should fix the above error [4]. Please
> > > > try again.
> > > >
> > > > Elias
> > > >
> > > > [4] https://gioui.org/commit/57872856e8c5b5de
> > >
> > > Tried again with latest Gio, seems still the same problem. I made
> > > a commit here [0]. Do I need to include the ANGEL binaries?
> > > I am not sure if the ones [1] you gave me already include
> > > everything we need.
> > >
> > > [0] https://github.com/zwang/gio-example/commit/3c34d05d121ba722f6bd8b926f21ef1fb3246988
> > > [1] https://drive.google.com/file/d/1k2950mHNtR2iwhweHS1rJ7reChTa3rki/view?usp=sharing
> >
> > The Gio fix only covered the kitchen example on Linux/Wine. Testing on
> > Windows proper revealed another issue: the glfw example always selects
> > the desktop OpenGL, which on Windows is something different than ANGLE.
> > Gio and GLFW thus ends up with different OpenGL function pointers.
> >
> > I added support for EGL to the glfw example here: [0]. The OpenGL ES
> > bindings package "github.com/go-gl/gl/v3.1/gles2" does not build on
> > macOS[1], so you'll have to outcomment the gles2 references to see it in
> > action on Windows.
> >
> > It doesn't actually work on Windows either without this fix to the
> > glow generator[2]. You'll need to run the generator to generate a
> > compatible package:
> >
> > $ cd glow-with-pr-112
> > $ go build ./glow generate -api=gles2 -version=3.1
> > $ mv gl/*.go ../gl/v3.1/gles2 # a checkout version of github.com/go-gl/gl
> >
> Will this change be made to github.com/go-gl/gl/v3.1/gles2 master too?
> Sounds like it should be.
>

Yeah. I leaved it as soon as I discovered a fix and that go-gl/gl
contains what I think is a design flaw (that you can't mix gl and gles2
calls, even though they behave identically). I figured you had your own
way of loading GL function pointers anyway, making the point moot.

PR 112 is merged, so it would be easy to do if you need it.

> > Finally, you'll need the EGL headers and of course the ANGLE EGL library
> > to run the example on Windows:
> >
> > $ cd gl
> > $ go mod init github.com/go-gl/gl
> > $ cd ../gio-example
> > $ go mod edit -replace github.com/go-gl/gl=../gl
> > $ CGO_FLAGS="-I<path to angle checkout>\include" CGO_LDFLAGS="-L<path to libEGL.dll>" go run -tags egl ./glfw
> >
> > The "egl" tag instructs go-gl to use the EGL mechanism to load function
> > pointers.
> >
> This works for me with some changes. I first put the flags into
> environment variables.
> Then used CGO_CFLAGS instead of CGO_FLAGS.
> Then when I run, I go to gio-example/glfw foder, run go run -tags egl main.go
> In gio-example/glfw, I have the generated angle libs as attached above
> in angels.zip
>

Ah, sorry for the typo. My Windows machine don't have access to my email
so I typed the line manually.

Elias
Details
Message ID
<CAHQ-fMZAqzrG7u5y0roNtE-ippisEibVpYxzQ4ZD-oATP5H5bw@mail.gmail.com>
In-Reply-To
<C8UM5K2IF52G.SP1LVXU7VNVS@testmac> (view parent)
DKIM signature
pass
Download raw message
On Wed, Jan 27, 2021 at 11:30 PM Elias Naur <mail@eliasnaur.com> wrote:
>
> On Wed Jan 27, 2021 at 23:45 CET, Zhao Wang wrote:
> > This works, thank you!
> >
> > On Wed, Jan 27, 2021 at 8:45 AM Elias Naur <mail@eliasnaur.com> wrote:
> > >
> > > On Tue Jan 26, 2021 at 23:41 CET, Zhao Wang wrote:
> > > > On Tue, Jan 26, 2021 at 5:51 AM Elias Naur <mail@eliasnaur.com> wrote:
> > > > > On Mon Jan 25, 2021 at 17:40, Zhao Wang wrote:
> > > > > > On Mon, Jan 25, 2021 at 2:05 AM Elias Naur <mail@eliasnaur.com> wrote:
> > > > > > > On Mon Jan 25, 2021 at 8:43 AM CET, Zhao Wang wrote:
> > > > > > > > I just tried the GLFW example on windows, it failed as expected as
> > > > > > > > shown by the attachment.
> > > > > > > >
> > > > > > > > It panic when trying to GetString for Extension during initializing a
> > > > > > > > new backend.
> > > > > > > >
> > > > > > >
> > > > > > > The OpenGL backend depends on ANGLE to work. I have an old build here[0]
> > > > > > > if you like. Place the DLLs in the same directory as the GLFW binary (or
> > > > > > > the current directory if you're using `go run`).
> > > > > > >
> > > > > >
> > > > > > Regarding running the glfw example on windows, I put these DLLs in the
> > > > > > same directory as the GLFW binary and do "go run". I got this error when
> > > > > > creating new backend:
> > > > > >
> > > > > > "2021/01/25 16:52:52 failed to parse OpenGL ES version ()"
> > > > > >
> > > > > > It returns empty string for OpenGL ES version and thus failed at this line
> > > > > > in NewBackend method:
> > > > > >
> > > > > > "glimpl.ParseGLVersion()"
> > > > > >
> > > > > > Will dig more into this to collect more information.
> > > > > >
> > > > >
> > > > > I found and fixed an issue that should fix the above error [4]. Please
> > > > > try again.
> > > > >
> > > > > Elias
> > > > >
> > > > > [4] https://gioui.org/commit/57872856e8c5b5de
> > > >
> > > > Tried again with latest Gio, seems still the same problem. I made
> > > > a commit here [0]. Do I need to include the ANGEL binaries?
> > > > I am not sure if the ones [1] you gave me already include
> > > > everything we need.
> > > >
> > > > [0] https://github.com/zwang/gio-example/commit/3c34d05d121ba722f6bd8b926f21ef1fb3246988
> > > > [1] https://drive.google.com/file/d/1k2950mHNtR2iwhweHS1rJ7reChTa3rki/view?usp=sharing
> > >
> > > The Gio fix only covered the kitchen example on Linux/Wine. Testing on
> > > Windows proper revealed another issue: the glfw example always selects
> > > the desktop OpenGL, which on Windows is something different than ANGLE.
> > > Gio and GLFW thus ends up with different OpenGL function pointers.
> > >
> > > I added support for EGL to the glfw example here: [0]. The OpenGL ES
> > > bindings package "github.com/go-gl/gl/v3.1/gles2" does not build on
> > > macOS[1], so you'll have to outcomment the gles2 references to see it in
> > > action on Windows.
> > >
> > > It doesn't actually work on Windows either without this fix to the
> > > glow generator[2]. You'll need to run the generator to generate a
> > > compatible package:
> > >
> > > $ cd glow-with-pr-112
> > > $ go build ./glow generate -api=gles2 -version=3.1
> > > $ mv gl/*.go ../gl/v3.1/gles2 # a checkout version of github.com/go-gl/gl
> > >
> > Will this change be made to github.com/go-gl/gl/v3.1/gles2 master too?
> > Sounds like it should be.
> >
>
> Yeah. I leaved it as soon as I discovered a fix and that go-gl/gl
> contains what I think is a design flaw (that you can't mix gl and gles2
> calls, even though they behave identically). I figured you had your own
> way of loading GL function pointers anyway, making the point moot.
>

Cool, this is great to know. I am planning to use go-gl's gl function pointers.
This is something to watch out for then.

> PR 112 is merged, so it would be easy to do if you need it.
>
> > > Finally, you'll need the EGL headers and of course the ANGLE EGL library
> > > to run the example on Windows:
> > >
> > > $ cd gl
> > > $ go mod init github.com/go-gl/gl
> > > $ cd ../gio-example
> > > $ go mod edit -replace github.com/go-gl/gl=../gl
> > > $ CGO_FLAGS="-I<path to angle checkout>\include" CGO_LDFLAGS="-L<path to libEGL.dll>" go run -tags egl ./glfw
> > >
> > > The "egl" tag instructs go-gl to use the EGL mechanism to load function
> > > pointers.
> > >
> > This works for me with some changes. I first put the flags into
> > environment variables.
> > Then used CGO_CFLAGS instead of CGO_FLAGS.
> > Then when I run, I go to gio-example/glfw foder, run go run -tags egl main.go
> > In gio-example/glfw, I have the generated angle libs as attached above
> > in angels.zip
> >
>
> Ah, sorry for the typo. My Windows machine don't have access to my email
> so I typed the line manually.
>
> Elias

No problem at all. Thanks again for the help!
Reply to thread Export thread (mbox)