Spherical forums

Sphere Development => Sphere General => Topic started by: ninjasword on April 11, 2013, 01:25:18 am

Title: embedding sphere into a browser
Post by: ninjasword on April 11, 2013, 01:25:18 am
is it possible to embed a game that u make in sphere onto a webpage and have a visitor to the site download support for the game? u kno like a flash game...
Title: Re: embedding sphere into a browser
Post by: Radnen on April 11, 2013, 02:17:54 am

is it possible to embed a game that u make in sphere onto a webpage and have a visitor to the site download support for the game? u kno like a flash game...


Not currently. Eggbert had a way of downloading games to play on your computer, but it was by no means an embedded Sphere engine. I was going to do this but never got around to it.

In fact I'm waiting on pixi.js (http://www.goodboydigital.com/pixi-js-has-landed/) to have a bit more support (well fonts at least), and then perhaps I'll use that to make a webGL implementation of Sphere. With a JS to JS interface, rather than the C++ to JS interface of a desktop engine. Plus it would be supported on all OS's and mobile phones.
Title: Re: embedding sphere into a browser
Post by: Metallix on April 11, 2013, 04:32:52 am
Yeah, Sphere is JavaScript and when I heard the first time of HTML5 and all the stuff that comes with it, I was thinking about a HTMLSphere. Last week I tried to have a update/render loop running in HTML and Sphere using the same game scripts. It was working. Rectangle() was drawing a rectangle in my webpage and in sphere. The problem is that it requires the main game loop written in a specific way, which is not cool if you want to support already written sphere games. Also the MapEngine() call is a problem, because in Sphere it does not return as long the map engine runs... For performance reasons I want to use window.requestAnimationFrame(), but that stands against the way how sphere works with its FlipScreen() rendering...
Title: Re: embedding sphere into a browser
Post by: ninjasword on April 15, 2013, 01:30:16 am

Yeah, Sphere is JavaScript and when I heard the first time of HTML5 and all the stuff that comes with it, I was thinking about a HTMLSphere. Last week I tried to have a update/render loop running in HTML and Sphere using the same game scripts. It was working. Rectangle() was drawing a rectangle in my webpage and in sphere. The problem is that it requires the main game loop written in a specific way, which is not cool if you want to support already written sphere games. Also the MapEngine() call is a problem, because in Sphere it does not return as long the map engine runs... For performance reasons I want to use window.requestAnimationFrame(), but that stands against the way how sphere works with its FlipScreen() rendering...


so yes it could but it would require heavy modding?

personally i think the capability to put a sphere game into a browser like a flash game could really let sphere grow
Title: Re: embedding sphere into a browser
Post by: Flying Jester on April 15, 2013, 02:38:09 am
I think that a solution like JavaSphere would be the best bet for that. Maybe even just a modified version of JavaSphere.
Title: Re: embedding sphere into a browser
Post by: N E O on April 15, 2013, 03:28:53 pm
The hardest part, really, about re-implementing Sphere for web usage seems to be recreating all the default map engine logic. Besides relying on a stable animation loop, it also assumes all the underlying pieces (and nothing more) are already taken care of, IIRC.
Title: Re: embedding sphere into a browser
Post by: Metallix on April 15, 2013, 05:04:06 pm
Haha, yes, the map engine ^^ Were there ever a running rework if it?

To be honest I do not really think the sphere map-engine is something I would port to html. I think it is not worth the effort. I would rather give radnens map editor the ability to export maps to json and create a new js based map engine, that can read those maps. it would then be usable in both environments...
Title: Re: embedding sphere into a browser
Post by: Radnen on April 15, 2013, 05:25:00 pm

Haha, yes, the map engine ^^ Were there ever a running rework if it?

To be honest I do not really think the sphere map-engine is something I would port to html. I think it is not worth the effort. I would rather give radnens map editor the ability to export maps to json and create a new js based map engine, that can read those maps. it would then be usable in both environments...


You're right, an exporter would be a great idea. But, I won't make such an exporter until a new map specification has been made, and I've got a lot of other stuff to do as well.
Title: Re: embedding sphere into a browser
Post by: Metallix on April 16, 2013, 03:24:54 am
Of course this was not a direct feature request^^ don't worry :)
Title: Re: embedding sphere into a browser
Post by: DaVince on April 16, 2013, 09:09:09 am

The hardest part, really, about re-implementing Sphere for web usage seems to be recreating all the default map engine logic. Besides relying on a stable animation loop, it also assumes all the underlying pieces (and nothing more) are already taken care of, IIRC.

In my experience, another hard part is game loops themselves. Sphere games usually rely on some infinite while loop, while Javascript on the web doesn't work that way at all (it prevents the page from updating, ever). Unless worker threads could somehow fix this?
Title: Re: embedding sphere into a browser
Post by: N E O on April 16, 2013, 12:02:10 pm
There are a few HTML5 JS game engines that pull off the game loop portion easily, so I'm sure we can study one or two to see how it's done cleanly on the web.
Title: Re: embedding sphere into a browser
Post by: Metallix on April 16, 2013, 02:33:26 pm
Yes, worker threads I am already using in my experimental solution. With them the requirescript function is very easy to implement. They also solve partially the problem with that while loop as main game loop. But I think in the end there would be a solution that can not get best performance because we try to emulate spheres behavior. I think it will be much better to write games in a way that they are good on both platforms by providing a layer written in js that hides the differences of both platforms.
Title: Re: embedding sphere into a browser
Post by: DaVince on April 16, 2013, 05:20:27 pm
Sounds like an idea, but you'd intentionally be breaking any backwards compatibility with existing Sphere games if you do that. It's a choice you could make, I suppose, though any existing games would have to be ported then.
Title: Re: embedding sphere into a browser
Post by: Flying Jester on April 16, 2013, 07:32:04 pm
I seriously think something like JavaSphere is the way to go. Would it be possible to embed the output of a locally running copy of Sphere into a webpage?
Title: Re: embedding sphere into a browser
Post by: Mooch on April 17, 2013, 02:43:16 am
I looked up Sphere again and re-registered to the new forums specifically because of Canvas, I was gonna make this exact topic. Perhaps with better grammar and spelling >_>

Actually, all I want is a JavaScript API based on Sphere. You know, like LimeJS, gameQuery, Cotton or whatever. I've been having trouble trying to learn how to make games in Canvas, and all those APIs suck. If I had these (http://wiki.spheredev.org/Functions) functions to work with, though, I'd be set.
Title: Re: embedding sphere into a browser
Post by: Metallix on April 18, 2013, 05:23:01 pm
Hmm ok, another evening wasted playing around with sphere/html5. The webworker approach is doing well. But I learned that the canvas is a bit mean when it comes to pixel perfect rendering. While rectangles are okay, drawing a pixel perfect line without anti alias is somehow impossible in the context2d. The only option you have there is to implement those graphic primitves functions by manipulating a image data array. I don't think that the performance will be acceptable this way. The other option is webGL. I found that http://threejs.org/ could be a good layer for rendering. But fonts, audio and map engine would be still a huge problem.

There could be another option for porting sphere to a browser:
https://github.com/kripken/emscripten/wiki
This would actually compile the sphere engine itself to javascript. But I have not checked the details.
Title: Re: embedding sphere into a browser
Post by: Radnen on April 18, 2013, 05:52:26 pm
I have already mentioned https://github.com/GoodBoyDigital/pixi.js, it uses WebGL and I think can be used to great effect especially for 2D games. It boasts a really nice sprite batcher, which has some amazing performance benefits. If I were to start on a Web based Sphere, I'd really start there.
Title: Re: embedding sphere into a browser
Post by: Flying Jester on April 18, 2013, 05:55:23 pm
Funny thing, I've heard (http://chadaustin.me/) of emscripten before.

While rectangles are okay, drawing a pixel perfect line without anti alias is somehow impossible in the context2d. The only option you have there is to implement those graphic primitves functions by manipulating a image data array. I don't think that the performance will be acceptable this way.


Conceptually, that's exactly how TurboSphere draws lines. And rectangles, and circles, and everything. It's actually faster when I need alpha.
Title: Re: embedding sphere into a browser
Post by: Metallix on April 19, 2013, 02:18:29 am
Heh, I know that guy ;)

Hmm yeah, there are some good js libraries out there... For that primitive drawing I did a test once on a 640x480 canvas and it was a bit disappointing if I had to draw on the whole screen which is very common in games. Meh...
Title: Re: embedding sphere into a browser
Post by: DaVince on April 23, 2013, 07:06:06 am

Hmm ok, another evening wasted playing around with sphere/html5. The webworker approach is doing well. But I learned that the canvas is a bit mean when it comes to pixel perfect rendering. While rectangles are okay, drawing a pixel perfect line without anti alias is somehow impossible in the context2d.

Have you tried subtracting 0.5 pixels from your graphic positions? Canvas draws stuff in the middle, so drawing a 1 pixel line on for example an y axis of 0 will cause it to draw an antialiased grey line on the area surrounding it, instead.
Title: Re: embedding sphere into a browser
Post by: Metallix on April 23, 2013, 04:56:30 pm
yes, I knew about this trick. It did not fixed all my issues. A non-straight line would still be anti aliased. Some of us may think that this good, but I think it can destroy the look and feel of a game. Anyway, yesterday I did a webGL approach with three.js and got some very promising results. First I went for pixi.js but it is still in a very early stage and It did not offer the interface I would like to have. three.js instead gives me some good low level access to webGL but keeps it still simple enough. This low level access is very good if you go to implement the graphic primitives and want to get the best performance. I will play a bit more with it. Let's see where this leads to ^^
Title: Re: embedding sphere into a browser
Post by: Eggbertx on April 26, 2013, 05:19:12 pm

Not currently. Eggbert had a way of downloading games to play on your computer, but it was by no means an embedded Sphere engine. I was going to do this but never got around to it.

JavaSphere was originally intended to use Rhino to play Sphere games in the browser, with all of Sphere's functiosn emulated in Java. When that turned out to be way too difficult at the time (I could probably pull it off now, but I don't have the time and I admittedly haven't even been working with Sphere much lately) I turned it into the downloader, which was still pretty buggy. And the site it was on is down anyway.
Title: Re: embedding sphere into a browser
Post by: Radnen on May 11, 2013, 10:53:54 pm
Have fun: http://radnen.tengudev.com/spheretest/

It's still in early alpha.
Title: Re: embedding sphere into a browser
Post by: Flying Jester on May 11, 2013, 11:13:28 pm
Huh, doesn't seem to work for me. It just sits there loading, and then times out.
Title: Re: embedding sphere into a browser
Post by: Radnen on May 12, 2013, 01:01:26 am
What browser are you using, and what version? The shim I made for pixi.js is extremely lightweight, so this sounds really disturbing to me. :(

Edit:
Wait a minute... My entire tengudev web space is gone! :-\

Edit:
It's back up, weird. Anyways, I've tested and it works in IE 8, Chrome v26.*, and Firefox "late enough one". the demo is a moving image, a static image, both at opacity 0.5, and if you hit the asterisk key on the num-pad you see the fps on the upper-left hand corner. And now you can move the image with the Sphere's mouse API, click anywhere and an image will be set to that location. Can't do right click, sadly.

Metallix you said this:

For performance reasons I want to use window.requestAnimationFrame(), but that stands against the way how sphere works with its FlipScreen() rendering...


But I was able to get around it. I fill a queue that emulates the blits to a backbuffer. Then when the animFrame is called it draws the items in the queue, removing each element along the way. This emulates the backbuffer/flipscreen calls we are used to in Sphere. take a look at the source for the above demo. It uses pixi.js for the webGL rendering.

The source for the above demo looks exactly like sphere API:
Code: (javascript) [Select]

image.blit(120 + j, 64);
image.blit(x, y);

if (IsMouseButtonPressed(MOUSE_LEFT)) {
  x = GetMouseX();
  y = GetMouseY();
}

j += up ? 1 : -1;
if (up && j == 64) up = false;
if (!up && j == 0) up = true;

if (IsKeyPressed(KEY_UP)) { y--; }
if (IsKeyPressed(KEY_DOWN)) { y++; }
if (IsKeyPressed(KEY_LEFT)) { x--; }
if (IsKeyPressed(KEY_RIGHT)) { x++; }

font.drawText(4, 270, "Mouse Click: Set image position.");
font.drawText(4, 285, "Arrow Keys: Move image around.");


One caveat: the game loop cannot be a while(true). But so long as you manually change that and make sure other loops don't happen, then your game should port over perfectly (once I finish the API).
Title: Re: embedding sphere into a browser
Post by: Flying Jester on May 12, 2013, 06:28:39 pm
Ah, yes it's working now.

Very nice.
Title: Re: embedding sphere into a browser
Post by: Metallix on May 13, 2013, 06:26:10 am
Very nice!

I went for the graphic primitives approach using three.js. But currently I am stuck in implementing a bitmap font renderer ^^
I think we both went for the same approach filling a buffer and draw it on flip screen. I also do not support while(true) gameloops. I recommend putting everything into a web worker. I am still not sure if I will continue my approach, since you are also going to create a web version. Can you draw pixel perfect lines in pixi.js? I found that much easier in three.js. But the question is, do we want anti alias or not in a web sphere? For my three.js approach I probably wait until turbo sphere has a stable graphics open gl plugin and see if I can adapt the gl code there... if I will continue it at all.
Title: Re: embedding sphere into a browser
Post by: ninjasword on May 13, 2013, 08:55:21 am

Have fun: http://radnen.tengudev.com/spheretest/

It's still in early alpha.


wow super cool

what version of sphere is that?

ps. i know im just a junior script kid at best, but if there is anything anyone needs done to help any of their projects to move this forward, i would love to help, oh and btw it works fine on chrome
Title: Re: embedding sphere into a browser
Post by: DaVince on May 13, 2013, 10:50:00 am

what version of sphere is that?

No version; just an implementation of some of Sphere's functions, as far as I can see. A good start!
Title: Re: embedding sphere into a browser
Post by: Radnen on May 13, 2013, 01:25:51 pm

I went for the graphic primitives approach using three.js. But currently I am stuck in implementing a bitmap font renderer ^^
I think we both went for the same approach filling a buffer and draw it on flip screen. I also do not support while(true) gameloops. I recommend putting everything into a web worker. I am still not sure if I will continue my approach, since you are also going to create a web version. Can you draw pixel perfect lines in pixi.js? I found that much easier in three.js. But the question is, do we want anti alias or not in a web sphere? For my three.js approach I probably wait until turbo sphere has a stable graphics open gl plugin and see if I can adapt the gl code there... if I will continue it at all.


pixi.js supports bitmap fonts! But there are some things it can't do, and that would be graphics primitives. I'll have to find out how by hand... Pixi.js will soon have a rendertarget, maybe it will be possible to do some stuff there.

My greatest concern is trying to open binary filetypes. In JS you have a FileReader, which works great when trying to read a binary file. But now I need to strip embedded image data out of a window style so I can draw it to screen.
Title: Re: embedding sphere into a browser
Post by: alpha123 on May 13, 2013, 02:47:43 pm
Typed arrays (https://developer.mozilla.org/en-US/docs/JavaScript/Typed_arrays) are pretty useful for that sort of thing.
Title: Re: embedding sphere into a browser
Post by: N E O on May 13, 2013, 03:55:22 pm
@Metallix & @Radnen - do you want a web-sphere repo officially created and Radnen can write the 'pixi' branch while Metallix write the 'threejs' branch?

(edit - created web-sphere repo (https://github.com/sphere-group/web-sphere); also added DaVince so he can get his CanvasSphere stuff onto it as 'canvas' branch or something; enjoy!)
Title: Re: embedding sphere into a browser
Post by: Radnen on May 13, 2013, 04:31:21 pm
Sweet a question and it's answer. I don't know how far along I can get but I'll see about pushing to the branch.

@alpha123: nice! But that's not where I'm stuck with binary files. I'm stuck pulling an image out of a file to be used elsewhere in the code.
Title: Re: embedding sphere into a browser
Post by: DaVince on May 13, 2013, 05:20:53 pm

(edit - created web-sphere repo (https://github.com/sphere-group/web-sphere); also added DaVince so he can get his CanvasSphere stuff onto it as 'canvas' branch or something; enjoy!)

That's awesome, but I'd rather contribute to other implementations since CanvaSphere was basically crap. Also, I think I lost the code, anyway.
Title: Re: embedding sphere into a browser
Post by: Metallix on May 15, 2013, 06:45:23 pm
Small update: I just had a while( true ) game loop running in the browser :) Web workers are doing the trick ^^
Title: Re: embedding sphere into a browser
Post by: Radnen on May 15, 2013, 08:45:32 pm
Do you mind if I steal your idea? :)
Title: Re: embedding sphere into a browser
Post by: Metallix on May 16, 2013, 03:57:06 am
Its on github in three-sphere branch :) Go for it!

But I am still not sure if that is the way to go... if you remove the Delay() in the main loop it was blocking my chrome sometimes. Web workers do not support a sleep method :/ That means Delay is currently implemented like you would do it in Sphere 1.6 causing a high CPU usage...
Title: Re: embedding sphere into a browser
Post by: Flying Jester on May 16, 2013, 04:57:56 pm
I do know that Chrome's V8 has a way of properly sleeping. It might be exposed to script in Chrome (or similarly other browsers) in a browser specific way.
Title: Re: embedding sphere into a browser
Post by: alpha123 on May 17, 2013, 01:13:26 am
It's not exposed to JS as far as I know, although you could probably cook something up involving setTimeout or possibly requestAnimationFrame.
Title: Re: embedding sphere into a browser
Post by: Metallix on May 17, 2013, 04:03:03 am
Yes, there are currently ways to "sleep" for an amount of time, but no method actually will work like the Delay(ms) function which should return only after that time. At least we have while( true ) that is not blocking the browser ^^ A sleep function would be a nice addition but is not required to emulate the old sphere.
Title: Re: embedding sphere into a browser
Post by: DaVince on May 17, 2013, 03:15:20 pm

Small update: I just had a while( true ) game loop running in the browser :) Web workers are doing the trick ^^

Freakin' awesome. :)
Title: Re: embedding sphere into a browser
Post by: Metallix on May 20, 2013, 08:56:39 am
I commited a version that renders two rectangles on the canvas. For that while true problem we should maybe introduce an optional game_update function next to the default game function every sphere game needs. Old sphere games can have their while loop in the game function, but new games should use the game_update function to be nicer to the CPU.

old:
Code: (javascript) [Select]

function game() {
    while( true ) {
        // render
    }
}


new:
Code: (javascript) [Select]

function game() {
    // init
}
function game_update() {
    // render
}
Title: Re: embedding sphere into a browser
Post by: N E O on May 24, 2013, 07:30:48 pm
FYI Radnen, I just tried the demo app from your link on my HP Touchpad tablet running Android (unofficial Cyanogenmod 10) and the 'touch' event doesn't register as a 'click' event and 'swipe' doesn't analogue to arrow keys or anything like that. For the web engine we may want to consider handling tablet/smartphone input methods as well as standard inputs.
Title: Re: embedding sphere into a browser
Post by: Radnen on May 24, 2013, 07:46:15 pm

FYI Radnen, I just tried the demo app from your link on my HP Touchpad tablet running Android (unofficial Cyanogenmod 10) and the 'touch' event doesn't register as a 'click' event and 'swipe' doesn't analogue to arrow keys or anything like that. For the web engine we may want to consider handling tablet/smartphone input methods as well as standard inputs.


Good thing to add, will get to it when I can.
Title: Re: embedding sphere into a browser
Post by: Rukiri on May 27, 2013, 02:46:11 pm
I personally do not think this is a good idea, unless you're talking about sphere 2.0, sphere is ancient.
If you want to develop games for the web try out stencyl, wait for 3.0 though as Haxe will be the default language. 
Title: Re: embedding sphere into a browser
Post by: N E O on May 28, 2013, 02:20:57 pm
The main reason the discussion of Sphere as a web app even exists is because we use JavaScript, a primarily web oriented language, as our higher level scripting language and web browsers already have tried-and-tested JS engines running, so why not build a bridge to take advantage of what they already have?
Title: Re: embedding sphere into a browser
Post by: DaVince on May 28, 2013, 04:37:41 pm

I personally do not think this is a good idea, unless you're talking about sphere 2.0, sphere is ancient.
If you want to develop games for the web try out stencyl, wait for 3.0 though as Haxe will be the default language.

Hmm, but wouldn't you like to see Sphere's easy API usable for web games, too? I personally know I'd like that. And yeah, progress is already being made with this.
Title: Re: embedding sphere into a browser
Post by: alpha123 on May 28, 2013, 04:49:52 pm
I wonder if it's possible to compile TurboSphere with Emscripten (https://github.com/kripken/emscripten) and get good performance thanks to asm.js (http://asmjs.org/) and WebGL (https://developer.mozilla.org/en-US/docs/Web/WebGL). It might be possible with regular Sphere with SphereGL as well. The hard part is we'd probably have to mock V8's API to use the JS VM asm.js would be running on, since compiling a JS runtime to JS isn't exactly good for performance. :P
Epic Games and Mozilla got Unreal Engine running (http://www.unrealengine.com/html5/) in a browser with asm.js and WebGL with decent performance, so it should be totally doable. At the moment it only gets good performance in FF 23+, but it will run at some speed in any browser with WebGL.
Title: Re: embedding sphere into a browser
Post by: N E O on May 28, 2013, 07:18:06 pm
@alpha123 - before we even consider Emscripten I'd actually like to see any of the four current Sphere versions (1.5, 1.6 beta 4, 1.7 alpha, TurboSphere) compile with Clang or Apple's XCode version first. Most of our compilation instructions assume gcc and while that's certainly reliable for the foreseeable future I'd like to make sure we continue to supply more options whenever possible.

We also kinda need to update the MSVC workflow too...
Title: Re: embedding sphere into a browser
Post by: Flying Jester on May 29, 2013, 01:09:39 am
I would hope that using Emscripten we wouldn't also be compiling the JS engine as well using it.

Since TS seems to compile at least mostly with XCode, I would think that (except for V8) it would work (from a technical standpoint) with emscripten as well. And TS works very well with MSVC, too, using Scons or solution files. But the problem is obviously the JS engine.

Which raises the interesting question of whether you can compile V8 using LLVM bytecode, and then using emscripten into JavaScript to be run (possibly) on a native version of V8. V8 seems to be always on the edge of not compiling right or not compiling at all anyway even when precisely following the instructions. It sounds like a very interesting idea, but also a bit like madness. JS engines (the ones we use in Sphere stuff) go to great lengths to turn the fluid JS to something that can be grappled with the rigid C++. It sounds quite inelegant to then turn that rigid C++ back into fluid JS, and run it on a differently compiled version of itself. The one possible saving grace could be to modify V8 so that its built-in JS code is run on the browser's engine instead of on the resulting engine, but I'm not sure that's feasible to begin with, and I don't think that the built-in JS code in V8 is all that extensive.

It could be useful to use emscripten to compile modified versions of TS plugins (the backends, parts that aren't entrenched in talking to V8) and Sphere video drivers maybe (I'm not sure quite what emscripten is capable of), and have those work with a JS or HTML5 core. That sounds like a much more reasonable scheme to me. And it would mean that quite possibly the same source code could produce Linux, Mac, and Windows native plugins, and web-TS plugins. But that is an aweful lot of work.

Just personally, I'm not sure what is gained by having a Sphere-like API that is run by a browser. I still think a more elegant and much simpler (and likely higher performance) solution would be to perfect a JavaSphere like system. With HTML5 and WebGL, I would think that there may be a way to even redirect the output of the engine to a frame in a browser.
Title: Re: embedding sphere into a browser
Post by: Radnen on May 29, 2013, 01:31:09 am
Jest: well that's why the web based Sphere ideas exists: to harness the power of the browsers JS environment for use in Sphere. How awkward would it be to compile the JS engine when you'd be running it in a browser that already has one (and possibly a newer faster version of it too).

The way I see Web-Sphere is that it'll get better / faster as the two main driving technologies: JS and WebGL get faster and better over the next couple of years. And that's all without recompiling! It'll just happen!
Title: Re: embedding sphere into a browser
Post by: ninjasword on June 10, 2013, 01:33:59 pm

well that's why the web based Sphere ideas exists


actually i just wanna put my games up on the interwebs, and i love sphere, thats why i started this conversation. im glad to know such a straight-forward (or so it appeared at first) solution to my problem existed. too bad im such a noob i cant help the idea grow!
Title: Re: embedding sphere into a browser
Post by: ninjasword on June 29, 2013, 10:05:32 am
welp, since i guess everyone else dropped this inexplicably, i gunna switch from my game into this. and only this.

i love sphere. i want to share it with other people. i want to share what it can do. i want sphere to grow.
Title: Re: embedding sphere into a browser
Post by: Radnen on June 29, 2013, 02:16:18 pm

welp, since i guess everyone else dropped this inexplicably


Yeah because it's a whole lot of work! You can still share Sphere games with friends though, and someday there might just be a web version of it, but not anytime soon.
Title: Re: embedding sphere into a browser
Post by: ninjasword on June 29, 2013, 07:27:37 pm

Yeah because it's a whole lot of work! You can still share Sphere games with friends though, and someday there might just be a web version of it, but not anytime soon.


too bad everyone isnt working together to find a way to make sphere a better program
Title: Re: embedding sphere into a browser
Post by: Radnen on June 29, 2013, 07:58:54 pm
Hey, hey, everyone's busy with their own projects, for example without me there wouldn't be an awesome .NET editor for Sphere. And FlyingJester is working on a newer more modern Sphere design called TurboSphere. Just because you can't get an online version of it doesn't mean we aren't all trying our part here.
Title: Re: embedding sphere into a browser
Post by: Flying Jester on June 29, 2013, 08:16:11 pm
Perhaps if I wasn't the one working on the new engine (not including 1.7 or Yet Another Sphere Clone, but 1.7 has been dormant and YASC is much younger than TurboSphere), there would be more activity on this front, though.

I will admit it. I don't really care about making the Sphere API available in a web browser.

Of course, if you really want this, Sphere is open source. If you really want it, you can try to compile it yourself using emscripten. You can try and get the Sphere_GL drivers working with WebGL.
Title: Re: embedding sphere into a browser
Post by: ninjasword on June 29, 2013, 09:16:58 pm
ty jester for helping this noob get started, i will contribute to sphere as u all have, i will make this my one goal in life. i thank everyone that has already contributed to this thread giving me lots of ground work to play around on.
Title: Re: embedding sphere into a browser
Post by: ninjasword on July 02, 2013, 02:01:30 pm
whelp, ur right radnen! it sure is alot of work. too much for me. which sucks cause i really liked sphere. well, honestly, like is too weak a word.

i wish u guys luck with turbo sphere, radnen sphere, sphere 1.7, and all the other current ways u have split up development of sphere and locked it down into oblivion without a cohesive future.

ps and the way u guys quit this thread when i brought up the fact that i came up with the idea is both sad and pathetic. enjoy the dead end u guys made for urselves.
Title: Re: embedding sphere into a browser
Post by: N E O on July 02, 2013, 03:13:35 pm
...What just happened?
Title: Re: embedding sphere into a browser
Post by: Radnen on July 02, 2013, 03:32:50 pm
Welp.
Title: Re: embedding sphere into a browser
Post by: DaVince on July 02, 2013, 04:26:02 pm
Not really sure what to say, considering Sphere hasn't been more alive than it currently is since ages, thanks to all the development going on here. But what I do know is that there are plenty of successful game engines that don't have a browser-based thing, and they're doing great. Sphere fills its own niche, and having it work in the browser is currently considered a great extra by most. It's more important to have a modern version of the engine and editor, first, if you ask me.

Quote
i wish u guys luck with turbo sphere, radnen sphere, sphere 1.7, and all the other current ways u have split up development of sphere and locked it down into oblivion without a cohesive future.

If you're talking about "splitting up development", you mean in TurboSphere, TurboSphere and TurboSphere? Because that's where the engine development mainly is. Radnen is doing an editor. Sphere 1.7 isn't being developed any more as far as I know.

Edit: kay. Went as far as deleting his account. Not sure what exactly happened, here.
Title: Re: embedding sphere into a browser
Post by: alpha123 on July 02, 2013, 04:59:03 pm
o_O
Uh, thanks DaVince. :o


Sphere 1.7 isn't being developed any more as far as I know.

That's correct, although if I feel like prototyping any new features I might work on it. The big issue is the age of the code: the SpiderMonkey API has changed SO MUCH in newer releases that it's as difficult to upgrade to SM 24 as it would be to switch to V8. Even 1.8.5, which I tried to upgrade to, has changed enough that the current 1.7 has a nasty habit of crashing due to some changes in garbage collection and compartments that would probably require changing a lot of code to fix.
Title: Re: embedding sphere into a browser
Post by: Flying Jester on July 02, 2013, 07:44:07 pm
...huh.

It wasn't I who tried to embed Sphere, it was Eggbert with JavaSphere (or perhaps it was another person and another project as well), but it wasn't me.

I think you shouldn't really be hitting any problems with GC compartments, though. I thought that in this case, you'd only have one compartment (unless this has to do with having a startup game)?

Speaking of prototyping new features, are you still planning on making a sqlite plugin for TurboSphere? I'd really like to get some outside feedback on the plugin system, ideally from someone who is trying to actually use it.
Title: Re: embedding sphere into a browser
Post by: alpha123 on July 02, 2013, 08:01:13 pm

I think you shouldn't really be hitting any problems with GC compartments, though. I thought that in this case, you'd only have one compartment (unless this has to do with having a startup game)?

I'm not fully sure what my problems are, actually. I highly suspect them to be GC related though. The compartments thing came from the fact that 1) they didn't exist pre-1.8.5, 2) they gave me a lot of trouble when I was upgrading, and 3) the documentation on them is extremely scarce. I work on the open-source RTS 0 A.D. (http://play0ad.com) and we have a very smart guy working on upgrading to SpiderMonkey 24 (from 1.8.5) and it's very difficult. Fortunately we're one of the most prominent SpiderMonkey embedders and got some help from the SpiderMonkey team. Unfortunately Mozilla basically stopped caring about embedders after about version 1.8.1.

Quote

Speaking of prototyping new features, are you still planning on making a sqlite plugin for TurboSphere? I'd really like to get some outside feedback on the plugin system, ideally from someone who is trying to actually use it.

Oh, yes, I almost forgot about that. I'd be happy to. I'm pretty busy with school right now and have 3 programming projects going on (a Common Lisp web app, my RPG using Sphere, and a platformer with Love2D (http://love2d.org/)).
Title: Re: embedding sphere into a browser
Post by: Flying Jester on July 02, 2013, 08:11:30 pm
The big issue is the age of the code: the SpiderMonkey API has changed SO MUCH in newer releases that it's as difficult to upgrade to SM 24 as it would be to switch to V8.


I'm not fully sure what my problems are, actually. I highly suspect them to be GC related though. The compartments thing came from the fact that 1) they didn't exist pre-1.8.5, 2) they gave me a lot of trouble when I was upgrading, and 3) the documentation on them is extremely scarce.


I didn't really expect this. I knew Sphere was old, but I didn't think it would be like that. I guess that helps to explain why no one seems to be, or as I thought they should be, (as I've thought they would for quite some time) wondering why I would bother to reinvent the wheel instead of fixing up the old one. I always thought I was taking the hard way out, starting from scratch and using a different JS VM!
Title: Re: embedding sphere into a browser
Post by: Fat Cerberus on July 02, 2013, 10:15:06 pm
Oftentimes starting from scratch is less work in the long run than trying to modernize outdated code. :)
Title: Re: embedding sphere into a browser
Post by: DaVince on July 03, 2013, 05:20:01 am

o_O
Uh, thanks DaVince. :o

Lol, sorry if I jumped to conclusions! It's just that not much visible has been happening in that regard, you know? Though I do appreciate the work you did so far. ;)
Title: Re: embedding sphere into a browser
Post by: alpha123 on July 03, 2013, 01:55:44 pm

Lol, sorry if I jumped to conclusions! It's just that not much visible has been happening in that regard, you know? Though I do appreciate the work you did so far. ;)

Haha, you didn't jump to conclusions at all! I was thanking you for deleting the odd fellow.
Like I said, you're correct about Sphere 1.7 not being developed anymore.


By the way, what are the possibilities of using Sphere with NaCl in Chrome?
Title: Re: embedding sphere into a browser
Post by: N E O on July 03, 2013, 03:26:09 pm

By the way, what are the possibilities of using Sphere with NaCl in Chrome?


Do you mean as a glorified webapp or porting the work done on TurboSphere? If the former, I'm sure that both pixi.js and three.js (and whatever third web framework I may choose to experiment with in the future) have some way of tapping into NaCl (either built-in or allow some external shim to hook into the NaCl APIs) to take advantage of its capabilities. If the latter, maybe Jester's done some research in to that.
Title: Re: embedding sphere into a browser
Post by: Radnen on July 03, 2013, 03:35:49 pm
I stopped my port at drawing primitives. But I see in the pixi.js roadmap, primitive support which is nice. My only concern right now is trying to read in windowstyle, map, and spriteset info.

This test site has an example of a loaded windowstyle. But I'm not too sure about it. http://radnen.tengudev.com/spheretest/test.html
Title: Re: embedding sphere into a browser
Post by: N E O on July 03, 2013, 04:56:46 pm
@Radnen - Your ParseData might be taking data[64] as a byte instead of as a 16-bit LE word, same with data[66]. Maybe fixing that will fix the loop for that singular bitmap (the top-left corner it seems)? Also, your loop is only going 1 byte at a time instead of taking the 32-bit RGBA pixel at once.

Also, how does one specify a v2.1 RWS as per the doc (https://github.com/sphere-group/sphere-doc/blob/master/internal/windowstyle.rws.txt)?
Title: Re: embedding sphere into a browser
Post by: DaVince on July 03, 2013, 05:11:50 pm


Lol, sorry if I jumped to conclusions! It's just that not much visible has been happening in that regard, you know? Though I do appreciate the work you did so far. ;)

Haha, you didn't jump to conclusions at all! I was thanking you for deleting the odd fellow.

Sorry, that was poorly worded by me. I meant he deleted his own account!
Title: Re: embedding sphere into a browser
Post by: alpha123 on July 03, 2013, 05:53:37 pm

Do you mean as a glorified webapp or porting the work done on TurboSphere?

I mean the latter, trying to get TurboSphere to run in NaCl.


Sorry, that was poorly worded by me. I meant he deleted his own account!

@_@
Title: Re: embedding sphere into a browser
Post by: Flying Jester on July 03, 2013, 05:58:07 pm


Lol, sorry if I jumped to conclusions! It's just that not much visible has been happening in that regard, you know? Though I do appreciate the work you did so far. ;)

Haha, you didn't jump to conclusions at all! I was thanking you for deleting the odd fellow.
Like I said, you're correct about Sphere 1.7 not being developed anymore.


By the way, what are the possibilities of using Sphere with NaCl in Chrome?


I know that V8 has a makefile for NaCl (although I've never seen anything about using it). And TurboSphere has been pretty good about porting so far--getting V8 compiled is almost always the struggle I've had.

It might help that I'm also working on both a permanent replacement for the SDL 1.2 graphics plugin, a shiny new SDL 2.0 plugin, and also an SDL-less OpenGL graphics plugin (ideally to make ports to Android or iOS easier--if Apple ever allows run-time code generation on iOS).


Also, how does one specify a v2.1 RWS as per the doc (https://github.com/sphere-group/sphere-doc/blob/master/internal/windowstyle.rws.txt)?


I believe the options make one that properly takes advantage of edge offsets with the old editor are in the background properties (the same place to specify a background gradient).
Title: Re: embedding sphere into a browser
Post by: N E O on July 04, 2013, 12:32:23 am
Created Sphere Web Utilities (http://forums.spheredev.org/index.php/topic,129.0.html), so far loads Radnen's test windowstyle into 9 <canvas> elements (one per piece).