GLBasic forum

Main forum => Announcements => Topic started by: Kitty Hello on 2012-Nov-08

Title: HTML5 / JavaScript ist starting to get useful
Post by: Kitty Hello on 2012-Nov-08
Howdy,

the HTML5 port is getting into shape. I found some bugs and have a working demo now. See attached file.
Next step is to pack the resources from the Media directory into the html and then compress the output with a gzip option. But it's all no big problem anymore I guess.

It's a bit slow on my Opera browser. Maybe it's Opera, maybe another bug. It's using WebGL, btw.

One tiny bitter pill is there to swallow, though. The structured programming of GLBasic will have to be changed for HTML5. There's no way to write code like:
Code (glbasic) Select

WHILE TRUE
   PRINT "X", 0,0
   SHOWSCREEN

for JavaScript. It would lock the browser and that would kill the script soon.

So, GLBasic (V11) already supports a new mechanism for this (cross platform, of course).
The key is the GLB_ON_LOOP sub, and the command SETLOOPSUB, that are new.

Here's the HTML5 example attached as code:
Code (glbasic) Select

LIMITFPS 60
STDOUT "In main game now\n"
GLOBAL stary%[]
DIM stary%[300]
FOREACH y IN stary[]
y = -RND(400)
NEXT

// SETLOOPSUB "GLB_ON_LOOP" // - GLBasic V11 calls this at the END of "main"

STDOUT "finishing the main loop now\n"


@SUB GLB_ON_LOOP: // this is called by the framework after the "main" init module
LOCAL spd% = 0, x% = 0
FOREACH y IN stary[]
spd = bAND(spd+1, 3)
INC y, spd+1
PRINT "*", x, y
IF y>400 THEN y=-32
INC x
NEXT

PRINT "Merry Christmas, HoHoHo", 32,(1+SIN(GETTIMERALL()/10.)) * 64+60

SHOWSCREEN

ENDSUB





[attachment deleted by admin]
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: Wampus on 2012-Nov-09
Can't wait to play with this. Go Gernot!  :good:
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: bigsofty on 2012-Nov-09
Very cool stuff!  :good: I had a wee look at the produced Javascript too... :O
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: Ruidesco on 2012-Nov-09
It does work well in Firefox. :good:
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: spicypixel on 2012-Nov-09
What's the effective overhead in Kb for a HTML5 project? For example would a simple "Hello World!" have 300Kb core js code regardless, more? less?
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: erico on 2012-Nov-09
aaaalmost there :)
this should open up a new dimension, I wonder what people here have in mind for it.

Great work Gernot! :booze:
I will try and get Papai Noel to deliver you some this year.

Now, if I get this right, a home page could then be programed with GLB right?
Should work on almost every browser but IE, right?

Really great to hear advancements on this front.
Congrats! :good: 
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: Hemlos on 2012-Nov-09
Looks and works great! Cant wait to give it a shot!

I noticed the fullscreen doesnt scale up, but it does fill the screen with a black background.
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: mentalthink on 2012-Nov-09
Uhhhhu!!! This it´s very very nice!!!

In Firefox for me runs very fine!!! super-smooth and quick!!!
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: backslider on 2012-Nov-12
Wow!

This is really nice, Gernot!
I can't wait for a Web GLBasic Game! :)

Show the monkey who the boss is. (only a joke) :D
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: jestermon on 2012-Nov-12
WOW. Perfect under Firefox. Smooth and fast. I can see network analysis and management front-end programs with hundreds of bells and whistles. Can't wait for it.
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: MrTAToad on 2012-Nov-12
It doesn't seem to like Internet Explorer 9 unfortunately - just get "Downloading" and an empty box - so it looks like all browsers except that are supported :)

It'll be interesting to see what sprites are like!
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: Ruidesco on 2012-Nov-12
IE doesn't support WebGL at all.
MS making friends yet again.

Well, to be honest you can install a plug-in for WebGL support. But it just doesn't support it natively like the rest of the world does.
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: MrTAToad on 2012-Nov-12
It's no great loss not being able to use the current version of Internet Explorer
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: spacefractal on 2012-Nov-12
Look like its a nice solution . I do allready something like that in Greedy Mouse, so I could adapt it very easy (that property in the java applets public void run() did the extract same thing and then its easier for me doing something similar). Howover the game mightbeen a tad too big for online use, but could been fun if its could been integrate that way for new platforms mightbeen....
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: D2O on 2012-Nov-13
FF          geht
Chrome geht aber kein Fullscreen
IE          geht nicht, leeres fenster
Opera   geht nicht, leeres fenster
Safarie  geht nicht, leeres fenster

Video: ~5mb
http://www.deuteriumoxid.com/glbasic/GLBHTML5.avi (http://www.deuteriumoxid.com/glbasic/GLBHTML5.avi)
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: backslider on 2012-Nov-13
Quote from: D2O on 2012-Nov-13
IE          geht nicht, leeres fenster

Hast du im IE mal F5 nach der Genehmigung gedrückt?
Bei den anderen Browsern siehts ja böse aus. :(

Aber bei Gernot gehts ja im Opera, kann also auch ne Windows-Konfiguration sein.
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: Hemlos on 2012-Nov-13
Quote from: Hemlos on 2012-Nov-09
Looks and works great! Cant wait to give it a shot!

I noticed the fullscreen doesnt scale up, but it does fill the screen with a black background.

I was using chrome, it worked good, but fullscreen didnt scale up.

In IE i only get "Downloading..." message, a textbox, and a fullscreen button.
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: MrTAToad on 2012-Nov-13
Yes, it wont work with Internet Explorer - blame Microsoft :)
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: mentalthink on 2012-Nov-13
in Safari appears the Window but it´s in white... if pulse the button , scale but nothing appears...
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: Kitty Hello on 2012-Nov-14
for Opera you have to enable WebGL support manually. google it up.
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: D2O on 2012-Nov-14
@ Kitty Hello,
danke, habe das hier darauf gefunden:
http://opera-info.de/forum/index.php?page=UserBlogEntry&entryID=24 (http://opera-info.de/forum/index.php?page=UserBlogEntry&entryID=24)
Jetzt läufts auch im Opera.

Nur der Fullscreen geht bei mir nicht.
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: bigsofty on 2012-Nov-14
MS recently announced IE 10 for Windows 7, anyone tried that version?
Title: Re: Re: HTML5 / JavaScript ist starting to get useful
Post by: fuzzy70 on 2012-Nov-14
Quote from: bigsofty on 2012-Nov-14
MS recently announced IE 10 for Windows 7, anyone tried that version?

Would be interesting as that would mean a u-turn from M$ as they said they would never support webgl due to it being a "security risk" or something.

Lee

Sent from my GT-I5700 using Tapatalk 2

Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: Schranz0r on 2012-Nov-14
Win7 64Bit, Firefox 16.0.2 = PERFECT!
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: Kitty Hello on 2012-Nov-15
Tiny update. DDgui works on HTML5. Amazing!

Only the font has a black background. I'll have to investigate.
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: MrTAToad on 2012-Nov-15
Should be a simple fix :)
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: mentalthink on 2012-Nov-15
This can be very very, usually I do my self buttons... but DDGUI it´s very quick for make interfaces...

<3 <3
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: Wampus on 2012-Nov-16
On my puter Firefox seems a less smooth than Chrome, although the fullscreen mode works perfect in Firefox. Maybe have too many add-ons and plugins installed.
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: Ruidesco on 2012-Nov-16
You can always try restarting with all add-ons disabled from the Help menu and see if the performance is still worse.
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: Wampus on 2012-Nov-17
That was way, way smoother. Hmm. Its not like I don't have CPU cycles to spare. Time to hunt the performance hog.  >:D
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: MrTAToad on 2012-Nov-17
I presume file I/O isn't allowed, beyond the ability to save data as one long text cookie...
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: Ruidesco on 2012-Nov-17
Well, HTML5 started a new client-side storage system based on two objects, sessionStorage and localStorage. The first exists for the duration of the session and the second exists without expiration. Like cookies, it only stores strings but it's as easy as the objects just being key/value collections.

Example:

Code (glbasic) Select
sessionStorage.start = new Date();
if(!localStorage.playerName) localStorage.playerName = "Ruidesco"


Etc.
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: MrTAToad on 2012-Nov-17
Looks like some new commands will be needed then!
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: Marmor on 2012-Nov-18
Could not create canvas - [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMHTMLCanvasElement.getContext]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: file:///C:/DOKUME~1/niccy/LOKALE~1/Temp/Tempor%C3%A4res%20Verzeichnis%201%20f%C3%BCr%20_support(1).zip/_support.html :: <TOP_LEVEL> :: line 79"  data: no]
SDL_SetVideoMode seems to be 1
Screen BPP: 32
:puke:

win xp / ff  last version 16.0.2
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: MrTAToad on 2012-Nov-18
Have you tried the things mentioned here : http://support.mozilla.org/en-US/questions/937842
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: MrTAToad on 2012-Nov-30
Will we be able to get rid of that initialisation text (or is that just output from the DEBUG command) ?
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: Kitty Hello on 2012-Dec-14
You can change the HTML template website. At least, that's the plan. So you can hide the console.
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: Kitty Hello on 2013-Jan-16
Did I post this already?
http://www.glbasic.com/beta/output.html
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: bigsofty on 2013-Jan-16
Now that's impressive, I can see where this is going now!  :good:
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: Ian Price on 2013-Jan-16
Nice :)
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: mentalthink on 2013-Jan-16
Yes Gernnot you put this example, but for me don't works when I press the full Screen...
But the Beta runs Html right now?¿, always when I try to compile in Html5 I always have troubles... I'm a bit confused how it's working fine...

Another quesion whit the Sdl2 whats will be better, the sounds?¿ for make effects?¿, and/or perhaps it's for running more quickly the code
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: erico on 2013-Jan-16
Great demo ho ho ho!
Works great on my chrome end.

We are in for great things this year! :booze:
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: kanonet on 2013-Jan-16
No Problems with fullscreen on firefox 18.
The general background is grey, but each letter has a black box around it (its not transparent!), is this intended?
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: mentalthink on 2013-Jan-16
I equal than kanonet, it's exactly the same...
Title: Re: HTML5 / JavaScript ist starting to get useful
Post by: kaotiklabs on 2013-Jan-16
how is the integration going? any eta?

Im no sure but the file size seems reduced, Im right?

eitherway great work!