GithubHelp home page GithubHelp logo

Web platform about raylib-go HOT 3 CLOSED

gen2brain avatar gen2brain commented on May 26, 2024
Web platform

from raylib-go.

Comments (3)

gen2brain avatar gen2brain commented on May 26, 2024

Now there is a different problem, _emscripten_set_main_loop issue is solved with this https://github.com/gen2brain/raylib-go/blob/master/raylib/external/scripts/emcc-generate-js.sh#L15 .

Function that is set with SetMainLoop(somefunc, 0, true) is running in loop as it should, but doesn't render anything on screen, first frame is visible and then just gray background.

http://81.4.106.254/raylib-go/

from raylib-go.

gen2brain avatar gen2brain commented on May 26, 2024

I have a clue now what is wrong. The only working functions in raylib_js.go for now are the one that doesn't return or accept structs, like InitWindow() for example, the others should be called like this, via ccall http://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#interacting-with-code-call-javascript-from-native and http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html#ccall.

Something like this in GopherJS:

// LoadWaveEx is used, not _LoadWaveEx name that is exported
js.Global.Get("Module").Call("ccall", "LoadWaveEx", "array",
		[]string{"array", "number", "number", "number", "number"},
		[]interface{}{data, sampleCount, sampleRate, sampleSize, channels})

But then, there is again problem for all functions that work with structs passed by value. Structs can be converted to []byte with unsafe or encodings/binary, so GopherJS pass it as TypedArray, argument type from emscripten side is then array, but return type can not be array, only number or string, emscripten complains then, because it can not know size.

I will look more what can be done with http://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_and_javascript/WebIDL-Binder.html#webidl-binder and http://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_and_javascript/embind.html#embind , results can be complete bindings to raylib in javascript, example is box2d here https://github.com/kripken/box2d.js , that can than be easily used from GopherJS .

Edit: embind example here emscripten-core/emscripten#3083 (comment)

from raylib-go.

gen2brain avatar gen2brain commented on May 26, 2024

Closing for now, don't have time for this, I tried to use embind but it is not so easy.

from raylib-go.

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.