Blitz meets FireFox!

Community Forums/Showcase/Blitz meets FireFox!

Picklesworth(Posted 2005) [#1]
Remember my Embedded Program test that was bumped a week ago?
Well, I brushed up on my C++ (not very well though... the code is a mess), learned about NPAPI, and wrote the most amazing thing ever written.
I know that it works perfectly under FireFox, and it should also work smoothly in any other web browser that did not make a stupid attempt to break the Internet. (Namely: Internet Explorer)



This is exactly what it looks like
It is a Blitz Basic 3d program (actually, this could be any program), being loaded up and implanted, seemlessly, within a web browser window. It does not have a direct interface with the browser, but theoretically a DLL which I do not know how to write could pull this off quite easily.
Source and a running example will come once I clean up the code and throw in a few features.
Oh, and the titlebar is only there because I threw in a second call to Graphics3d without bothering to patch up other stuff due to my current excitedness.

What does this mean? It will soon be very possible to write a program which can be used by a web browser to view special file formats with very limited knowledge in C++ and without having to mess around with crazy NPAPI stuff.


I AM VERY HAPPY


deps(Posted 2005) [#2]
Never heard about NPAPI before, is this Win32 only or can it be easily ported over to Linux/MacOS?


Perturbatio(Posted 2005) [#3]
http://en.wikipedia.org/wiki/NPAPI


Picklesworth(Posted 2005) [#4]
DoorMan 0.1, fully operational test.
Download: http://crumbsoftware.f2o.org/files/BlitzPlugin.zip
Because I do not know how to write the installer for this, you will need to follow the steps below.
How to install:
--Dump SelfEmbedder.exe, along with BlitzClose.dll, in C:\. Sorry to you weird non-C-drive people... I hard-coded this test.
--Go into the folder for your web browser... There is hopefully a plugins directory. Into there, dump npbasic.dll.
--Now, run BlitzPlugin.htm using the web browser into which you have dumped the plugin.

Hopefully, it will work.



Background information is in the HTML file.

Other notes:
-If you don't believe that this works, or want to see something to further demonstrate the awsomeness of this technique, check the "Put Blitz 3d inside of anything" thread that BlitzPlugin.htm has a link to. Run Main.exe with this new SelfEmbedder in place. You'll see that it still works perfectly :)
-Contrary to popular belief, scroll bars work perfectly on here.
-I have problems where the app completely panics when another instance of itself pops up, but that usually happens with B3d. I guess that's more reason to be using Max for the actual program. Although, the program that I'm striving to be better than (Blaxxun Contact) also does this... AND it has a memory leak :)
-Does anyone happen to know of/have code that acts as a full alternative to Blitz's mouse input commands? The default commands appear to be affected in a bad way by the window gaining and losing focus.


Enjoy!
What do you think?


po(Posted 2005) [#5]
Wow. Now that is cool.. So you have to have the blitz app on your harddrive for it to work?


Picklesworth(Posted 2005) [#6]
Yes, it has to be on the hard drive.
The plugin could be programmed to download it automatically, though. (Although, then again, the plugin also as to be on the hard drive until I get it properly registered...)


John Blackledge(Posted 2005) [#7]
Good work, Mr Pick. Following this with interest.


maximo(Posted 2005) [#8]
Of what use it is if it can't run on Internet Explorer? If you can get this working with IE as well and I'll even buy it it you decide not to give it for free! ;)


Hotcakes(Posted 2005) [#9]
Well you could use this for Firefox and OSA for IE. =]


maximo(Posted 2005) [#10]
>OSA for IE.

What OSA?


TartanTangerine (was Indiepath)(Posted 2005) [#11]
Yes this is very good. It's odd how people stumble upon things at similar times. We've got a similar project in development designed purely for delivery of games, it can actually deliver any .exe via the web. We currently use OSA for IE and will be using our plugin for Firefox and compatible browsers.

Our method differs slightly from what is being done here, we do not rely on your application being able to attach it'self to a window handle, we attach to you. We've had no issues so far with regard to mouse or keyboard controllers - we do have some minor issues and expect that everything will be finished and shipping within a week or so.

Here is a link of the plug in action : http://indiepath.com/tim/firefox.avi


Picklesworth(Posted 2005) [#12]
To run this in IE: http://www.mozilla.org/projects/plugins/plugin-host-control.html

I just haven't gotten around to it yet :)

Neat little thing... I have Stevie G.'s TANX game working within the web browser. I just added my SelfEmbedder startup code to the top, if api_isWindow(Parent)=0 then end, to the main loop, and compiled.
http://crumbsoftware.f2o.org/files/TANX_selfembedder.zip ... Just replace C:\SelfEmbedder.exe with this.

If you want, you can do the same using the SelfEmbedder framework here:

Please report anything that does and does not work.

For some reason, it would appear that Blitz applications cannot make sounds when they aren't in a top-level window. A bit of a shame, but it could be fixed.

I've decided that the best way to remove that horrible hard-coded stuff from my plugin is to pass an argument to it through HTML... It may be interesting.


That's interesting, Indiepath :)
I've actually been hoping to do this for about a year, but I only recently discovered how to do a web plugin thanks to Wikipedia (and reverse thanks to Google).
How are you grabbing the window? (Methinks you are using CreateProcess and keeping track of it from there, but that's only a wild uneducated guess.)


TartanTangerine (was Indiepath)(Posted 2005) [#13]
Ah that's a little secret for now (handles and parents). I've just sorted out all the window positioning, stupid API!


BlackJumper(Posted 2005) [#14]
This continues to look very interesting. Thanks for pioneering and for sharing your findings. Keep up the good work.

Is it likely that dynamic HTML variables could be used to influence the embedded Blitz window ? (e.g. use Javascript form elements to communicate with the game)


splinux(Posted 2005) [#15]
great! very useful!


TartanTangerine (was Indiepath)(Posted 2005) [#16]
Quick Question, how are you terminating the process in the plugin? how are you killing the blitz.exe?


Matt McFarland(Posted 2005) [#17]
check out this firefox competition: http://www.codersworkshop.com/viewpost.php?id=41139


Picklesworth(Posted 2005) [#18]
Wow, thanks Matt :D
*Glances at Indiepath with evil eyes*
jk :)

Quick Question, how are you terminating the process in the plugin? how are you killing the blitz.exe?

I'm terminating the Blitz exe through the Blitz exe:
Repeat	
	;Your Code Here
Until api_IsWindow(Parent)=0



TartanTangerine (was Indiepath)(Posted 2005) [#19]
Hmnn okay.. I need to do some more work on killing the process.


John Blackledge(Posted 2005) [#20]
I'm sorry, I seem to be missing something here.

What is the actual purpose?
How is this any different (apart from being very clever) from asking someone to download a normal demo from your site?


TartanTangerine (was Indiepath)(Posted 2005) [#21]
Money! Having a game that is accessible to more people = more orders. More orders = More money $$$ Ching Ching.


Picklesworth(Posted 2005) [#22]
How is this any different (apart from being very clever) from asking someone to download a normal demo from your site?

It's not about providing demos of games! Think about the wide array of applications you could develop, when you can have them actually brought up automatically, by a web browser, in order to view particular kinds of files... You could make the next Flash plugin, have a file viewer plugin for your own program, or design a new video file format and have it instantly able to run inside of a web browser :)

This plugin allows you to do stuff like those big plugins such as Quicktime, Flash and RealPlayer. The user downloads the program to be plugged in, and now a brand new way to view content over the Internet is instantly unlocked!


John Blackledge(Posted 2005) [#23]
Sorry - still not getting this.

You're still asking the user to download something first (a plugin, whatever).
Ok, then you hold the actual content/scene to be viewed on your server.
How do your get the plugin to utilise the resources on the server?


Picklesworth(Posted 2005) [#24]
How do your get the plugin to utilise the resources on the server?

At the moment, the embedded program is completely standalone. Accessing the plugin's DLL via the Blitz program would fix this... I am considering running a few experiments.

The idea is that the application becomes more useful once it's popped into a plugin interface, because it is activated automatically when needed, it recieves arguments from the HTML document (I got that fully operational just now), and it can be embedded directly inside of the web browser (which gives an excellent feeling of integration).

For now, until I somehow miraculously manage to get the NPAPI to the extent where it can be accessed by Blitz, downloading server content is performed via the embedded program. (Blitz).


John Blackledge(Posted 2005) [#25]
it recieves arguments from the HTML document

Hah! Now I see where you're going. Nice one, round of applause and good luck!


Najdorf(Posted 2005) [#26]
I think this has been done already, aint it?

http://www.miniclip.com/supergerball/supergerball.htm


TartanTangerine (was Indiepath)(Posted 2005) [#27]
Not with Firefox it ain't.


Dock(Posted 2005) [#28]
Best of luck with this - I can't wait to see this fully fledged in action. The potential for a browser lead blitz3d app is huge.


BlackD(Posted 2005) [#29]
Meh. OSA-kit already does this on the browser that most people are using (including downloading the app). But it'll be nice to see it working on a cross-platform browser. :)

+BlackD


maximo(Posted 2005) [#30]
I just tested OSA-kit and none of the samples worked after I installed it. It was just a page with an image missing and some text saying it's safe to install it. So much for this kit. If I can't run it, there must be lots of other not being able to run it. I tested it using IE.


Picklesworth(Posted 2005) [#31]
Meh. OSA-kit already does this on the browser that most people are using (including downloading the app). But it'll be nice to see it working on a cross-platform browser. :)

The idea for this is different from the numerously previously mentioned product. It is to produce file-viewers and such.
What I mean by this is that the web browser can individually decide to use your Blitz-built plugin, if it is installed, in order to view a file. This file could be anything, ranging from images to movies or even your own creation!
The plugin can also, if need be, be called explicitly -- or even be just a plugin that does the same thing as OSA-Kit, being called explicitly with an argument containing the EXE file to be executed (or downloaded and executed).

The important thing that makes this totally different from OSA-Kit and others like that is that it is not accessed directly by the HTML file. The HTML document simply has the Embed tag for a particular file type, or a particular plugin, and then the browser will decide to run your plugin, or any other plugin that handles that file type, in order to view the file.

For the purpose of running demos of games without needing to download them, I am certain that OSA-Kit does a better job, because it downloads directly through the web browser, whereas a Blitz app doing that would be openning up an entirely new connection, and using a regular Blitz downloading routine... which isn't exactly fast.

As an example of how this plugin which I have built is unique, I will use this example: I could write a plugin with a MIME type of images/jpeg, and a file type setting of .jpg. This plugin could be built to, instead of displaying the image, display a scene depicting a bunch of tanks duking it out where the image would otherwise be.


I'll have my full thing coming soon (except, presently, without sound...), at which point hopefully all will be better explained... Just sorting out passing arguments to the HTML file. Why are there so many ways to create a string???!!!!
It is now able to boot up the correct file. (A temporary feature for debugging purposes which the programmer is expected to remove, replacing FilePath with a relative path to the executable in the browser plugin folder... or a path stored in the registry).


Dock(Posted 2005) [#32]
Do you think it would be possible for the Blitz app to pass values back to the server also? Could it, for example, be used as a primative paint application, or anything that the user does?


Picklesworth(Posted 2005) [#33]
Only time will tell...
The Blitz app could potentially communicate with the same DLL that executed it (the web plugin dll)... so it is quite possible. Not yet, though... I only started this a week ago :)


TartanTangerine (was Indiepath)(Posted 2005) [#34]
Think windows messages.