GLBasic forum

Main forum => GLBasic - en => Topic started by: Kitty Hello on 2024-Aug-27

Title: HTML5 improvements
Post by: Kitty Hello on 2024-Aug-27
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.
Title: Re: HTML5 improvements
Post by: Qedo on 2024-Aug-27
I confirm it doesn't play on Firefox mobile and I also add Google Chrome mobile
How can I access git for changes?
Title: Re: HTML5 improvements
Post by: Paul Smith on 2024-Aug-28
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?
Title: Re: HTML5 improvements
Post by: Paul Smith on 2024-Sep-01
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 (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
Title: Re: HTML5 improvements
Post by: erico on 2024-Sep-02
Nice work guys!
I have to get into hltml5 at some point soon.
Probably not game related but for a few tools.
Title: Re: HTML5 improvements
Post by: Qedo on 2024-Sep-29
GLOBAL a$  = NETWEBGET$("jsonplaceholder.typicode.com","/users?_limit=3",80,2048, 5000)

any idea because in GLBasic  work and in HTML5 no?  bug?
Title: Re: HTML5 improvements
Post by: Paul Smith on 2024-Sep-30
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.


Title: Re: HTML5 improvements
Post by: Kitty Hello on 2024-Oct-02
it's url_Str. The $ is replaced by _Str in C++.
Title: Re: HTML5 improvements
Post by: Qedo on 2024-Oct-05
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."
Title: Re: HTML5 improvements
Post by: Paul Smith on 2024-Oct-05
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
Title: Re: HTML5 improvements
Post by: Qedo on 2024-Oct-05
for me impassable road nothing works.  Thanks anyway
Title: Re: HTML5 improvements
Post by: Qedo on 2024-Oct-05
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
Title: Re: HTML5 improvements
Post by: Paul Smith on 2024-Nov-10
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.

 



 
Title: Re: HTML5 improvements
Post by: dreamerman on 2024-Nov-10
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.
Title: Re: HTML5 improvements
Post by: Paul Smith on 2024-Nov-10
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.
Title: Re: HTML5 improvements
Post by: Qedo on 2024-Nov-11
perhaps regarding the use of SDL2 in HTML5 this thread might also interest you:
https://www.glbasic.com/forum/index.php?topic=11576.msg102261#msg102261