glfw3 backend for go.wde

362 views
Skip to first unread message

Gerard

unread,
Jul 25, 2013, 5:06:44 AM7/25/13
to go-...@googlegroups.com
Hello everybody,

Is someone working on a glfw3 backend for go.wde?


Gerard


John Asmuth

unread,
Jul 25, 2013, 8:01:56 AM7/25/13
to go-...@googlegroups.com

Actually, I am, though only now and then. Any interest in helping out? I could share what I've done so far - basically I've set up the glfw backbend to launch correctly, but I haven't done any of the drawing or event watching.

--
You received this message because you are subscribed to the Google Groups "go-uik" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-uik+un...@googlegroups.com.
To post to this group, send email to go-...@googlegroups.com.
Visit this group at http://groups.google.com/group/go-uik.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Gerard

unread,
Jul 25, 2013, 8:33:07 AM7/25/13
to go-...@googlegroups.com, jas...@cs.rutgers.edu
Well, I am interested. It's quite a puzzle. The event handling shouldn't be too difficult (I guess?) but I have some questions about the drawing stuff.

Besides that, did you use the method of Russ Cox for making glfw thread safe? I have it working like that.

John Asmuth

unread,
Jul 25, 2013, 8:37:16 AM7/25/13
to go-...@googlegroups.com

I haven't made any gl calls yet, and I'm not familiar with what Russ did, but the flush method needs to execute in a locked goroutine that we create for glfw.Init. should be straight forward. I'll see if I can make that available when I get into work!

Robin Eklind

unread,
Jul 25, 2013, 8:54:48 AM7/25/13
to go-...@googlegroups.com, jas...@cs.rutgers.edu
If you are interested in some helper functions to make 2d drawing with OpenGL easy I suggest you to take a look at:

http://godoc.org/github.com/Agon/baukasten/gl

The library isn't under active development but it's good for inspiration.

Cheers /u

John Asmuth

unread,
Jul 25, 2013, 9:53:53 AM7/25/13
to go-...@googlegroups.com
Unfortunately I think I must have turned off dropbox sync on my computer at home, so I can't push the skeleton i made so far. I'll try to remember tonight.

Thanks for the pointer - though for go.wde/glfw I intend to have the only gl operation be that which is needed to paste the raster on the screen :) I might want to use it elsewhere though, so I appreciate the tip.


Gerard

unread,
Jul 25, 2013, 10:05:01 AM7/25/13
to go-...@googlegroups.com, jas...@cs.rutgers.edu
Can you tell me in a few words what makes github.com/Agon/baukasten/gll different from github.com/go-gl/gl ?

John Asmuth

unread,
Jul 25, 2013, 10:06:43 AM7/25/13
to go-...@googlegroups.com
No. They might not know about each other (duplicated effort). I do know that github.com/go-gl is attempting to be a collection of all useful/maintained gl packages for go, so it has a good chance of working going forward.


--

Anthony Starks

unread,
Jul 25, 2013, 10:51:12 AM7/25/13
to go-...@googlegroups.com
I'll also offer github.com/ajstarks/openvg to the mix


On Thu, Jul 25, 2013 at 8:54 AM, Robin Eklind <fresh.g...@gmail.com> wrote:

--

Gerard

unread,
Jul 25, 2013, 11:01:01 AM7/25/13
to go-...@googlegroups.com
A bit extra info

What I have done so far is clone github.com/go-gl/glfw3  into github.com/grd/glfw3 and implemented https://code.google.com/p/go-wiki/wiki/LockOSThread
There is also the famous "gears" app and that works (with goroutines).

Then I cloned github.com/skelterjohn/go.wde into github.com/grd/go.wde and added the glfw3 backend and the according test. And it compiles! 
It doesn't run however :-(

Solved issues:
- glfw.Init is called from glfw.init (after LockOSThread) on the main thread
- wde.Run is redirected to glfw.Main
- wdetest is almost intact

Open issues:
- How to access OpenGL functions?
- The event system of glfw3 works very different than that of go.wde
    However the callback functions might/should solve that
- How to access the buffers of a window?
- How to implement glfw3.SwapBuffers? go.wde solves this (I guess) with
    CopyRGBA(), but glfw3 doesn't.
- How to properly shutdown the app? Why is this a problem? 
    Because glfw3.Main() is blocking a proper shutdown.

Gerard

Gerard

unread,
Jul 26, 2013, 6:29:00 AM7/26/13
to go-...@googlegroups.com
Update

The wdetest doesn't crash anymore :-)

The code is still very ugly and has limited functionality. I will clean it up this weekend.

For the wdetest I added 2D OpenGL for the window. But it's not so easy to generate a OpenGL backend for draw2d. The buffers of OpenGL and 2D image are very different (AFAIK). So I just removed the buffer from the window struct and let OpenGL handle the rendering. This meant redefining the draw.Image Set function, the go.wde Screen function and the go.wde FlushImage function.

Event handling is still lacking and the same for the second window rendering (black rectangles on a black background).

Suggestions / Remarks are welcome.

Gerard

Gerard

unread,
Jul 26, 2013, 12:41:57 PM7/26/13
to go-...@googlegroups.com
Last update for today

Event handling is getting there. There was a nasty issue with glfw3 and that's solved. The close functionality works a bit.
The second window is rendering ok now. Solved it with channels.
Added README.md which mentions the progress and issues.

Gerard

John Asmuth

unread,
Jul 26, 2013, 1:49:44 PM7/26/13
to go-...@googlegroups.com
In https://github.com/grd/go.wde/blob/master/wdeglfw3/wdeglfw3.go#L181, are you sure that's a good way to do it?

The method I was planning to use was to draw to an image.RGBA in memory, and then send that over as a texture whenever .FlushImage() was called. A separate gl call for each .SetPixel() is *really* expensive... and if we use an image.RGBA as the screen, lots of drawing code checks to see if that's the type being used and will access the .Pixels directly (and much more quickly).


Gerard

unread,
Jul 26, 2013, 2:53:06 PM7/26/13
to go-...@googlegroups.com, jas...@cs.rutgers.edu
Using SetPixel() is terrible indeed. However it's only for the wde test. I guess that for go.uik other features such as rectangle, triangle etc will be used (and because OpenGL doesn't use a buffer in the function calls, these functions can be used (relatively easy) as a alternative for draw2d. Then you can really benefit from OpenGL (AFAIK). However, it's absolutely not concurrent.

That said, I will search for a method to implement FlushImage. I haven't found it yet and am curious.

John Asmuth

unread,
Jul 26, 2013, 2:54:50 PM7/26/13
to go-...@googlegroups.com
You can load the image.RGBA.Pixels into a bound texture, and draw that.

Gerard

unread,
Jul 27, 2013, 5:11:58 AM7/27/13
to go-...@googlegroups.com, jas...@cs.rutgers.edu
PTAL

Robin Eklind

unread,
Jul 28, 2013, 12:16:54 PM7/28/13
to go-...@googlegroups.com, jas...@cs.rutgers.edu
"github.com/Agon/baukasten/gl" is a wrapper library around "github.com/chsc/gogl/gl33" which makes it convenient to blit 2d images. I don't know the internal details of the library but know that it is easy to use for drawing 2d with OpenGL.

Gerard

unread,
Jul 29, 2013, 8:58:01 AM7/29/13
to go-...@googlegroups.com
I finished up the coding. In Ubuntu 12.10 64-bit it works. Also the go.uik examples work. I placed one in the test directory.
The results are noted in the README file. There are still some issues, but it's quite workable.
It's just changing of one line in the import and then it runs.

Gerard

John Asmuth

unread,
Jul 29, 2013, 2:06:33 PM7/29/13
to go-...@googlegroups.com
Awesome! That's how it should be. If you make a pull request I'll note some of the things that need to change around in there.



Gerard

--
You received this message because you are subscribed to the Google Groups "go-uik" group.
Reply all
Reply to author
Forward
0 new messages