OpenB3D from Javascript

Started by angros47, December 30, 2022, 01:22:20

Previous topic - Next topic

angros47

A wrapper to use the web version of OpenB3D from JavaScript, with no need to install Emscripten

https://github.com/angros47/OpenB3D-JS

Have fun

angros47

I just added the file OS3DJS.js , that implements 3d audio, with commands CreateListener, Load3DSound, EmitSound

William

thanks angros. i think a web target could be good (although maybe i prefer a native app) had felt a web target would be a good target. how does it work, i mean to run an executable or its not an executable? @angros47
im still interested in oldschool app/gamedev

angros47

You are welcome! You can use OpenB3D to create native apps, too, for desktop. I have heard of people compiling it for android, too, but I haven't tried. When you talk about a native app, what platform are you talking about? Android, iOs, Windows, Linux, OSX?

To use it on web, there are two options: the first one is to use Emscripten, and write your program in a language supported by Emscripten (it can be C, C++, FreeBasic...). The advantage is that you can port a program you originally wrote for desktop to web with only few changes
Another solution is to use the JavaScript wrapper, and write the app in JavaScript: it is a bit different, but it will allow you to use all the features available in a web page (widgets, canvas, videos...). Also, it can be used without having to install and configure Emscripten, so setting up a computer for developing is much easier.

The result is a web page with some script and a .wasm file, you need to host it on a web server (even a local one) for the scripts to work, or to run your browser with some parameters to enable script loading files even from local pages.

William

#4
ahh, that answers my question. yes native but in a browser or an executable, im not all too familiar with latest browser app execution particularly with javascript/html5 or emscripten

i would like to use html5 build target but that bmx web target only uses emscripten and that target isnt compiling any longer, all well. i do not know i will have completed my app aowwhh

yes i was asking how openb3d would work with javascript for a web target but i see its a wrapper, i hadnt known very much about javascript, i thought it was going to be outdated/left behind before later versions.
im still interested in oldschool app/gamedev

angros47

Emscripten is a compiler, based on clang (a C/C++ compiler), and produces an output that can be run in browser: the output can be in JavaScript, or in WebAssembly (faster); in origin it produced only JavaScript, later it became able to use a subset of JavaScript simpler to run, that was compiled faster on some browser, and in the end evolved to WebAssembly.

JavaScript is not outdated at all, on the contrary, it has made obsolete and replaced other formats like Flash or SilverLight.

If you come from BlitzMax, the main difference you'll find in JavaScript is that it's totally event driven. You cannot have a never ending main loop in your program, or the page will get stuck, you must have a main function that is called at specified intervals. Also, commands that require some time to be executed won't block execution (or they would block the whole page), instead they trigger a callback function when they are completed. It's a different paradigm