Code Monkey home page Code Monkey logo

Comments (5)

tfriedel6 avatar tfriedel6 commented on July 22, 2024

Hi, at the moment that is not possible. At some point I would like to try it, but probably not soon.

from canvas.

dicecko avatar dicecko commented on July 22, 2024

I'm just new to webassembly and only have read about GO, sorry if don't really understand the languages yet.
Maybe I was a bit strict with 'directly'.
Can you create a Webassembly with this library to create a canvas and then in one JS call draw that entire canvas in the DOM?

from canvas.

tfriedel6 avatar tfriedel6 commented on July 22, 2024

No worries. So this library doesn't do anything with HTML or JS at the moment, it is pure Go and uses the system OpenGL driver to render. This is not available in a Webassembly context, so it won't work there. To make it work would require a separate implementation for Webassembly, which would be possible but I just have not started it yet.

from canvas.

dicecko avatar dicecko commented on July 22, 2024

Okay clear and thank you. I read into GO a couple of hours yesterday and it looks really cool!
I found that they now have https://golang.org/pkg/syscall/js/
This basically let's you import the DOM objects and directly call the JS functions and therefor also Canvas objects which solves the problem I had with Emscripten.

I would like to check if I understand it correctly now.

  1. If you would've used WebGL instead of OpenGL it did work in Webassembly right?

  2. With this library it only works if you compile it for that specific OS platform. So if I want to run it on Linux I have to use a Linux compiler, Windows a Windows compiler and Android/iOS "The GO Mobile" project?

Thanks in advance

from canvas.

tfriedel6 avatar tfriedel6 commented on July 22, 2024

Sure thing.

  1. Yes, that would have worked. Although of course with Webassembly you have access to the 2D Canvas as well, so it could have used that directly. I used OpenGL here only because I didn't really see an alternative, and the whole reason I wanted this library was that I used the canvas a lot but preferred to use Go rather than JS

  2. The library is pure Go, but you will need to supply an OpenGL context. The code that does that will probably have to be compiled on the specific platform, just as you said. But I'm not sure, the go-sdl project for example seems to include precompiled libraries, so it may be possible to cross compile for all platforms using that. I must admit I'm not sure about this though.

from canvas.

Related Issues (20)

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.