HTML5 improvements

Previous topic - Next topic

Kitty Hello

I copy the icon.png to the distribute folder.
I managed to get ASYNCIFY running. Now infinite loops with SHOWSCREEN will work - which makes DDGui's combo boxes etc. fully working. But also, all code should just run without any modifications. I don't think performance will be an issue anymore. Today's mobile phones are more powerfull than the computers we had when experimenting with emscripten/html5.

Here's what I did - but it does not beep on my Android mobile Firefox :(

https://www.glbasic.com/beep_timer/BeepTimer.html

I pushed my changes to git.

Qedo

I confirm it doesn't play on Firefox mobile and I also add Google Chrome mobile
How can I access git for changes?

Paul Smith

I love it when updates and fixes are being worked on, But I have the same question as Qedo. Does a push to GIT mean it will start to roll out on a STEAM update or do we have to do something manually?
Amstrad CPC 6128, ATARI STE.
Acer  SW5-173 & AMD RYZEN 7,RTX 3060TI

Paul Smith

Confirmed your Bleep does not work on Android Firefox.

I noticed firefox can be a little particular with sound as can Chrome, I tried a few settings for a bleep and in the end I used WAV 8/16bit 16/22/41 khz stereo(Mono didn't work) and these works on all platforms so far.

My Key click sound works on Firefox on my android.

https://paulsmith6175gmailcom.itch.io/bc

This is a work in progress and once its sorted I will create a thread with all the little things I discovered on my journey like how to get the full phone resolution not the 360x760ish, Audio formats, reading the screen width and height
Amstrad CPC 6128, ATARI STE.
Acer  SW5-173 & AMD RYZEN 7,RTX 3060TI

erico

Nice work guys!
I have to get into hltml5 at some point soon.
Probably not game related but for a few tools.

Qedo

GLOBAL a$  = NETWEBGET$("jsonplaceholder.typicode.com","/users?_limit=3",80,2048, 5000)

any idea because in GLBasic  work and in HTML5 no?  bug?

Paul Smith

Not used that command, but others like NETWEBEND dont work.

I've been short on time this month and was looking into using alternative inline for NETWEBEND. I have two methods that need Ironing out. This code is from a google search. And needs formatting correctly.

    INLINE
    #include <emscripten.h>
    emscripten_run_script("window.open(\"" + url$ + "\", \"_blank\");");
    ENDINLINE

the other is

INLINE
    #include <emscripten.h>

    EM_ASM_({
        window.open(url, '_blank');  // Open the URL in a new tab
    }, url$);
   
    ENDINLINE

Not tried the first one but the second one opens a page, just not the right link.  :D
Hopefully someone smarter than me will fix this is seconds.


Amstrad CPC 6128, ATARI STE.
Acer  SW5-173 & AMD RYZEN 7,RTX 3060TI

Kitty Hello

it's url_Str. The $ is replaced by _Str in C++.

Qedo

Paul, but can you compile these 2 examples in html5?
stop compiling because;

"fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated."

Paul Smith

I can't seem to use strings. This won't compile 
}, url$);  or {, url_Str);
The version I was supposed to show was  }); that just opens a new tab. It does compile but just a blank page.

This code does work and will open the correct page, strange thing is the // shows as comments after the https: but compiles fine.

INLINE
        EM_ASM({
       window.open('https://www.glbasic.com', '_blank');
    });
   ENDINLINE

Hope this helps
Amstrad CPC 6128, ATARI STE.
Acer  SW5-173 & AMD RYZEN 7,RTX 3060TI

Qedo

for me impassable road nothing works.  Thanks anyway

Qedo

#11
for my app (server-client) I will change (sigh) to Js and node.js

I have a hope, I will try the latest updates  of html5 from git

Paul Smith

I assume GLBASIC uses the SDL2 library when compiling to HTML5.

I've been messing with music formats in browsers and it looks like firefox is the least compatible, anyways I was trying to understand if using the SDL2 mixer to play MOD/S3m would work better.

As I know very little about C/C++ importing into GLBasic, I was hoping someone could give me any pointers.

I can see GLBasic adds the path to the .h files location for HTML.
would it be used like
INLINE
#include "SDL.h"
#include "SDL_mixer.h"
ENDINLINE

or would it be import / require.

#require "SDL.h"
#require "SDL_mixer.h"

IMPORT "C" int SDL_Init(int flags)
IMPORT "C" void SDL_Quit()
IMPORT "C" int Mix_OpenAudio(int frequency, unsigned short format, int channels, int chunksize)
IMPORT "C" void Mix_CloseAudio()
IMPORT "C" void Mix_FreeMusic(void* music)
IMPORT "C" void* Mix_LoadMUS(const char* file)
IMPORT "C" int Mix_PlayMusic(void* music, int loops)

If anyone can help, I would be grateful.

 



 
Amstrad CPC 6128, ATARI STE.
Acer  SW5-173 & AMD RYZEN 7,RTX 3060TI

dreamerman

As fast answer I can tell you that there are few examples how to use SDL2 code in GLB, you can check those posts:
https://www.glbasic.com/forum/index.php?topic=11401.msg100530#msg100530
https://www.glbasic.com/forum/index.php?topic=11313.msg100666#msg100666
look for attached files, by my self I'm using SDL2 code directly from Inline, don't know if that would work for HTML5, maybe that Import function will be needed.
Check my source code editor for GLBasic - link Update: 20.04.2020

Paul Smith

Thanks dreamerman, I did search the forum and only found info from the 3rd part topic. I'm sure this forum plays tricks on me. :D  I'll read the treads and hopefully come up with a solution.
Amstrad CPC 6128, ATARI STE.
Acer  SW5-173 & AMD RYZEN 7,RTX 3060TI