Torque 3D Embedded Browser (WebKit)
by Josh Engebretson · in Torque 3D Professional · 01/15/2010 (8:55 pm) · 305 replies
Hey guys,
Here are some highlights:
1) It uses QtWebKit which is based off Apple's WebKit, the same HTML5/Canvas based web rendering engine from Chrome, Safari, Adobe AIR
2) QtWebKit is *easily* the best designed embeddable web browser I have found in exhaustive travels... (I actually compiled Chrome from source at one point, not recommended). Qt is *extremely* well supported and owned by Nokia who recently paid $153,000,000 for it. So, it is probably going to be around for some time.
3) Flash works :)
4) It is setup as a GuiControl so interacts perfectly with mouse events, control overlap, filters...
There are currently 3 rendering modes:

1) Render to Texture: This mode renders the web view to an offscreen buffer and then uploads it to a GFXTexHandle. It uses the Torque GUI system input for mouse and keyboard. As we're rendering to a texture, compositing and rendering to 3d surfaces is possible. Flash renders as long as it is set to windowless mode in the HTML (not a big deal). Instead of using Flash for anything other than presentation/video playback, I would suggest looking into Canvas/HTML5/CSS animations/effects in this mode.

2) Render Native: This mode integrates a native child window with Gui Control, giving the best of both worlds :) There is no need to render to texture as we're using an actual clipped child HWND which uses the Torque GUI system for position/extents and focus :) Transparency does not currently work, however under Vista/Win7 this should be possible. I should be able to get masking working with minimal effort, which would allow for shaped windows and transparent areas.

3) Render Popup: This mode pops up a standalone window, which is owned by the application and consistent in scripting with other modes. This is useful for things like integrated document browsing, tutorial video watching, game doc reading, game forum reading, etc... where you don't want to crowd your game interface with browser. However, you want CLOSE scripted integration with a standard browser (no worries of IE/Mozilla/Chrome), which isn't possible with the current "launch browser" functionality.
These modes work with HTTPS adding a nice way to authenticate to servers, secure purchasing, etc.
It is still pretty early in the development and the idea with the code release will be to get feedback on usability and features... especially WRT integration with Javascript on the page, etc.
EDIT: The first version has been released and is available HERE
Regards,
- Josh Engebretson
Mythos Labs, LLC
Here are some highlights:
1) It uses QtWebKit which is based off Apple's WebKit, the same HTML5/Canvas based web rendering engine from Chrome, Safari, Adobe AIR
2) QtWebKit is *easily* the best designed embeddable web browser I have found in exhaustive travels... (I actually compiled Chrome from source at one point, not recommended). Qt is *extremely* well supported and owned by Nokia who recently paid $153,000,000 for it. So, it is probably going to be around for some time.
3) Flash works :)
4) It is setup as a GuiControl so interacts perfectly with mouse events, control overlap, filters...
There are currently 3 rendering modes:

1) Render to Texture: This mode renders the web view to an offscreen buffer and then uploads it to a GFXTexHandle. It uses the Torque GUI system input for mouse and keyboard. As we're rendering to a texture, compositing and rendering to 3d surfaces is possible. Flash renders as long as it is set to windowless mode in the HTML (not a big deal). Instead of using Flash for anything other than presentation/video playback, I would suggest looking into Canvas/HTML5/CSS animations/effects in this mode.

2) Render Native: This mode integrates a native child window with Gui Control, giving the best of both worlds :) There is no need to render to texture as we're using an actual clipped child HWND which uses the Torque GUI system for position/extents and focus :) Transparency does not currently work, however under Vista/Win7 this should be possible. I should be able to get masking working with minimal effort, which would allow for shaped windows and transparent areas.

3) Render Popup: This mode pops up a standalone window, which is owned by the application and consistent in scripting with other modes. This is useful for things like integrated document browsing, tutorial video watching, game doc reading, game forum reading, etc... where you don't want to crowd your game interface with browser. However, you want CLOSE scripted integration with a standard browser (no worries of IE/Mozilla/Chrome), which isn't possible with the current "launch browser" functionality.
These modes work with HTTPS adding a nice way to authenticate to servers, secure purchasing, etc.
It is still pretty early in the development and the idea with the code release will be to get feedback on usability and features... especially WRT integration with Javascript on the page, etc.
EDIT: The first version has been released and is available HERE
Regards,
- Josh Engebretson
Mythos Labs, LLC
About the author
http://www.TheEngine.Co
#122
I follow both engines since I've been a licensee for years. Other than small mods, not a lot has been added. There was a lot more when FPSC code was in a more close-knit community of the dev's on their forums. There have been some cool additions since, but a lot of community additions made into the core while it has been slower to take traction in the wild.
09/18/2010 (9:48 pm)
The LGPL and Apache licenses are quite different than the GPL. personally, I really like the LGPL attribution for the FPSC engine. It keeps the core engine source open for the most part while allowing linking to commercial or closed solutions.I follow both engines since I've been a licensee for years. Other than small mods, not a lot has been added. There was a lot more when FPSC code was in a more close-knit community of the dev's on their forums. There have been some cool additions since, but a lot of community additions made into the core while it has been slower to take traction in the wild.
#123
So not all the code is open and it is not public domain but it is free and available for the people willing to help, and if those people had to pay 1000$ to help many could not afford it or simply will not help at all.
I do not think that opening the core source will decrease revenue from sales but it should bring more developers and increase the revenue when those developers pay for support or for full source code access either way development cycles will benefit from more contributions, testing and debugging by more people willing and able to help.
09/19/2010 (7:21 am)
@DavidSo not all the code is open and it is not public domain but it is free and available for the people willing to help, and if those people had to pay 1000$ to help many could not afford it or simply will not help at all.
I do not think that opening the core source will decrease revenue from sales but it should bring more developers and increase the revenue when those developers pay for support or for full source code access either way development cycles will benefit from more contributions, testing and debugging by more people willing and able to help.
#124
1. The open browser options works fine (slightly distorted if I use the second posted code)
2. The play demo option tries to load and just before the Torque screen would disappear an error dialog appears "MatInstance::getStateHint The processed material is null!"
Looks like the render as texture option is a problem
Had no problems with beta 1, vs2008 express, vista
09/23/2010 (9:45 am)
Returning to the code in hand for beta 21. The open browser options works fine (slightly distorted if I use the second posted code)
2. The play demo option tries to load and just before the Torque screen would disappear an error dialog appears "MatInstance::getStateHint The processed material is null!"
Looks like the render as texture option is a problem
Had no problems with beta 1, vs2008 express, vista
#125
10/26/2010 (11:47 am)
What version is current? Has this been updated since its inital post?
#126
Is it possible to load a file from disc ?
11/03/2010 (4:41 pm)
I have the same problem as Jamie62 with beta 2, vs2008, sevenIs it possible to load a file from disc ?
#127
I copied over all the files in the "config" directory, and ran "generateprojects", is there something else I am missing?
I am getting these errors with both the Webkit demo, and my own project.
I can build the engine using the /FORCE:MULTIPLE but that causes intermittent crashes at runtime (originating from qtwebkit.dll).
12/16/2010 (8:31 pm)
I am having the same problem as several previous posters. The engine compiles, but when linking, I get the following errors:1>zlib_DEBUG.lib(inflate.obj) : error LNK2005: _inflateInit2_ already defined in QtCore4.lib(QtCore4.dll) 1>zlib_DEBUG.lib(inflate.obj) : error LNK2005: _inflate already defined in QtCore4.lib(QtCore4.dll) 1>zlib_DEBUG.lib(inflate.obj) : error LNK2005: _inflateEnd already defined in QtCore4.lib(QtCore4.dll) 1>zlib_DEBUG.lib(deflate.obj) : error LNK2005: _deflateInit2_ already defined in QtCore4.lib(QtCore4.dll) 1>zlib_DEBUG.lib(deflate.obj) : error LNK2005: _deflate already defined in QtCore4.lib(QtCore4.dll) 1>zlib_DEBUG.lib(deflate.obj) : error LNK2005: _deflateEnd already defined in QtCore4.lib(QtCore4.dll) 1>zlib_DEBUG.lib(compress.obj) : error LNK2005: _compress2 already defined in QtCore4.lib(QtCore4.dll)
I copied over all the files in the "config" directory, and ran "generateprojects", is there something else I am missing?
I am getting these errors with both the Webkit demo, and my own project.
I can build the engine using the /FORCE:MULTIPLE but that causes intermittent crashes at runtime (originating from qtwebkit.dll).
#128
12/23/2010 (6:54 am)
Am I the only one getting a black rectangle anywhere the flash content is supposed to be? I'm wondering if I need to do something specific with my flash installs... :/
#129
1. Install Safari browser from Apple
2. Install the latest version of Flash, it will detect Safari and install a webkit compatible flash plugin which your webkit torque game will detect
3. Enjoy
That would mean you would have to get anyone installing your game to have previously installed Safari and then flash
You don't need to recompile after the install as flash is loaded at runtime
Anyone have success with beta 2 or 3 with the render to texture issue
01/07/2011 (10:55 am)
I had similar problems with flash though not sure if the same, but this worked for me1. Install Safari browser from Apple
2. Install the latest version of Flash, it will detect Safari and install a webkit compatible flash plugin which your webkit torque game will detect
3. Enjoy
That would mean you would have to get anyone installing your game to have previously installed Safari and then flash
You don't need to recompile after the install as flash is loaded at runtime
Anyone have success with beta 2 or 3 with the render to texture issue
#130
I'm going to try a compile of 4.7.1 and see how that goes.
01/07/2011 (5:03 pm)
@Jamie62: Thanks, but still no dice.I'm going to try a compile of 4.7.1 and see how that goes.
#131
1) Got the 4.7.1 from here.
2) Unzipped it into a directory and moved it to the Qt directory as QtCustom4.7.1 (following Josh's directions for 4.6.2).
3) Applied the patches as per Josh's instructions.
4) Recompiled Qt as per the instructions given by Josh.
5) Opened the WebKitDemo project where I had previously compiled 4.6.2, and pointed the relevant directories to 4.7.1 (why you want them in the /Qt/ directory in the first place- much easier to do).
6) Recompiled. Contemplated life at least six times while I waited...
7) I also added these lines for my own usage into GuiWebCore::run() in guiWebCore.cpp around line 97 (you'll see the line for the plugins, and I put it right after that):
Edit: For some reason the second line of code here is getting split at the ->
8) Now, I did the compile and had an issue with Flash, and while I'm not totally sure if it was me or the code, try this if Flash still asses-out on you. Below the above lines, change:
This:
To this:
Yep, it's just uncommenting those lines.
9) I stuck NPSWF32.dll into the game/plugins directory (I also stick a lot of the dlls in here). I got this by googling for manual Flash installs, and got a zip from this tutorial. If you're running 64-bit you may need to find another download, I haven't tried it on a 64-bit machine.
10) Compiling the WebKitDemo is a rebuild just like in the resource.
After that, I was able to get to YouTube in the demo and play movies, and then I proved to myself that I'm not any good at the Aztec-styled Tetris clone at flashgames247.com. I was also able to open local files inside the /game/ directory (plain text and html), but not outside of it. That's because of the way GuiWebView::loadURL() handles the "file:///" string, appending the game path on it.
You can modify that if you like, but I left it as it is in the resource because I don't need or want to touch anything outside the game directory (really, it kinda gets sloppy really fast if you do).
Anyways, that's how I got Flash and 4.7.1 working. Hope it helps.
01/08/2011 (4:00 pm)
Okay, got Flash working with 4.7.1, and made a few small changes as well:1) Got the 4.7.1 from here.
2) Unzipped it into a directory and moved it to the Qt directory as QtCustom4.7.1 (following Josh's directions for 4.6.2).
3) Applied the patches as per Josh's instructions.
4) Recompiled Qt as per the instructions given by Josh.
5) Opened the WebKitDemo project where I had previously compiled 4.6.2, and pointed the relevant directories to 4.7.1 (why you want them in the /Qt/ directory in the first place- much easier to do).
6) Recompiled. Contemplated life at least six times while I waited...
7) I also added these lines for my own usage into GuiWebCore::run() in guiWebCore.cpp around line 97 (you'll see the line for the plugins, and I put it right after that):
Edit: For some reason the second line of code here is getting split at the ->
QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalStorageEnabled, true); QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
8) Now, I did the compile and had an issue with Flash, and while I'm not totally sure if it was me or the code, try this if Flash still asses-out on you. Below the above lines, change:
This:
//QStringList paths;
//paths.append(QDir::currentPath());
//paths.append(QDir::currentPath() + QString("/plugins"));
//QCoreApplication::setLibraryPaths ( paths );To this:
QStringList paths;
paths.append(QDir::currentPath());
paths.append(QDir::currentPath() + QString("/plugins"));
QCoreApplication::setLibraryPaths ( paths );Yep, it's just uncommenting those lines.
9) I stuck NPSWF32.dll into the game/plugins directory (I also stick a lot of the dlls in here). I got this by googling for manual Flash installs, and got a zip from this tutorial. If you're running 64-bit you may need to find another download, I haven't tried it on a 64-bit machine.
10) Compiling the WebKitDemo is a rebuild just like in the resource.
After that, I was able to get to YouTube in the demo and play movies, and then I proved to myself that I'm not any good at the Aztec-styled Tetris clone at flashgames247.com. I was also able to open local files inside the /game/ directory (plain text and html), but not outside of it. That's because of the way GuiWebView::loadURL() handles the "file:///" string, appending the game path on it.
You can modify that if you like, but I left it as it is in the resource because I don't need or want to touch anything outside the game directory (really, it kinda gets sloppy really fast if you do).
Anyways, that's how I got Flash and 4.7.1 working. Hope it helps.
#132
Is that T3D - 1.1.3 or 1.1.1 ?
01/13/2011 (1:07 pm)
Nice work Ted, I've didn't have to do that voodoo to get 4.7 to workIs that T3D - 1.1.3 or 1.1.1 ?
#133
Please guide me or give me some hints or direction on how to achieve it if possible. Thanks.
01/18/2011 (7:39 am)
Hi guys, just wondering is it possible to use this in TGEA 1.8.2.Please guide me or give me some hints or direction on how to achieve it if possible. Thanks.
#134
be sure to copy the plugins folder from the webkit source to the game folder as this contains some libraries which render the images
01/21/2011 (4:21 am)
Ted's fix really helps if you want to redistribute web kit as part of a gamebe sure to copy the plugins folder from the webkit source to the game folder as this contains some libraries which render the images
#135
01/25/2011 (1:41 pm)
Will the webkit implementation work in Torque 3D 2009 Pro 1.1 Beta 3? Or, is it still only working in Torque 3D 2009 Pro 1.1 Beta 1?
#136
01/26/2011 (7:43 am)
Nevermind, I see that changes were made for beta 2 by Ted.
#137
01/26/2011 (7:45 am)
@Philip: The changes I made were on Beta 1- I haven't tested with any other beta version yet.
#138
I'm trying to implement QT 4.7.1, following your code changes, to beta 3.
01/26/2011 (8:24 am)
@ted: Sorry I misread. Someone else had mentioned in the forum that they were trying to implement the webkit in beta2.I'm trying to implement QT 4.7.1, following your code changes, to beta 3.
#139
I used Konrad's code changes to get the webkit to work in beta 3 plus I changed the following code:
In the matTextureTarget.h file, I changed the following line of code from:
GFXTextureObject* getTexture( U32 index = 0 ) const;
to:
virtual GFXTextureObject* getTexture( U32 index = 0 ) const;
I did this so that the getTexture function in my WebTextureMap class would be called instead of the one in the NamedTexTarget class.
If there is a better way to do this, let me know.
Also, I am using QT 4.7.1. It is working well, but I am getting blue question marks instead of images on websites.
One thing I noticed as well is that when you are playing a video on one of the textures or you are using Ustream and watching a broadcast on one of the textures, if you click outside of the game on a browser, the video slows down and gets choppy, but if you click on the video in the game on the texture, then the video plays at normal speed and looks good.
Ustream works well and has the same 2 second delay as if you were watching the broadcast on a regular web page outside of the game.
02/01/2011 (6:09 am)
I was able to use QT 4.7.1 with Beta 3.I used Konrad's code changes to get the webkit to work in beta 3 plus I changed the following code:
In the matTextureTarget.h file, I changed the following line of code from:
GFXTextureObject* getTexture( U32 index = 0 ) const;
to:
virtual GFXTextureObject* getTexture( U32 index = 0 ) const;
I did this so that the getTexture function in my WebTextureMap class would be called instead of the one in the NamedTexTarget class.
If there is a better way to do this, let me know.
Also, I am using QT 4.7.1. It is working well, but I am getting blue question marks instead of images on websites.
One thing I noticed as well is that when you are playing a video on one of the textures or you are using Ustream and watching a broadcast on one of the textures, if you click outside of the game on a browser, the video slows down and gets choppy, but if you click on the video in the game on the texture, then the video plays at normal speed and looks good.
Ustream works well and has the same 2 second delay as if you were watching the broadcast on a regular web page outside of the game.
#140
You have to change the code from:
virtual GFXTextureObject* getTargetTexture( U32 mrtIndex ) const { return mCtrl->getTexture(); }
to:
virtual GFXTextureObject* getTexture( U32 mrtIndex = 0 ) const { return mCtrl->getTexture(); }
02/01/2011 (6:12 am)
I forgot to mention that you also have to change some code in the WebTextureMap class that is located in the guiWebCtrl.h file.You have to change the code from:
virtual GFXTextureObject* getTargetTexture( U32 mrtIndex ) const { return mCtrl->getTexture(); }
to:
virtual GFXTextureObject* getTexture( U32 mrtIndex = 0 ) const { return mCtrl->getTexture(); }
Torque Owner Tomer Bar-Shlomo
Tomar.biz VRDate.com
Regarding this extension I am still waiting for an easy patch to the stock or AFX 2.0 version and even if I could get all the source I need here I rather pay and get support than do it alone, very few people are willing to mess around with the code anyway.