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
#82
04/18/2010 (8:32 am)
Could you add a link to the most recent version with all the bugs fixed so far?
#83
I know Qt does not natively support java applets at the moment, but was wondering if it was possible to get java applets to run via plugins.
06/09/2010 (11:42 pm)
Just wonder, has anyone managed to get javascript/java applets to run in the browser ? I've managed to integrate this resource. But when trying to run Java Applets, there is an error which says the browser recognizes the applet tag but is not running it.I know Qt does not natively support java applets at the moment, but was wondering if it was possible to get java applets to run via plugins.
#84
You could try downloading the Java runtime plugin installer for Firefox and installing it (even without Firefox installed). Maybe it will write to the correct registry settings and you can use it with the WebKit.
06/10/2010 (5:26 am)
@Cai: you'll need a NAPI plugin. However I have no idea how do you use browser plugins with this resource. In the example screenshots Flash is working, so I suppose WebKit can "borrow" plugins from other NAPI browsers installed by searching for them on the registry. Chrome does that: if you install a plugin on Firefox, it will be available in Chrome.You could try downloading the Java runtime plugin installer for Firefox and installing it (even without Firefox installed). Maybe it will write to the correct registry settings and you can use it with the WebKit.
#85
07/26/2010 (9:41 pm)
[removed]
#86
07/26/2010 (9:42 pm)
[removed]
#87
07/27/2010 (3:11 am)
@Steven: You must add files to the sources of your project and rebuild all. To do this, you need the Pro version of the T3D.
#88
As it turns out it was a simple mistake of torison running the old project (In this case Test2.exe) instead of the new WebKitDemo.exe when you launch the project
I feel so dumb now, haha. Its really amazing the stuff you can do with this, I'll go ahead and add OpenSSL support to it and make a few bucks off him for the trouble! ;)
07/27/2010 (4:18 am)
Oh, I know that Alfio. I kept removing things to get it under 1000 words so I cut off the end part. My friend (Who is more of a scripter) owns the full pro version of Torque 3D. He got really excited (as did I) when he was the WebKit demo. I was helping him integrate it into the engine. As it turns out it was a simple mistake of torison running the old project (In this case Test2.exe) instead of the new WebKitDemo.exe when you launch the project
I feel so dumb now, haha. Its really amazing the stuff you can do with this, I'll go ahead and add OpenSSL support to it and make a few bucks off him for the trouble! ;)
#89
07/27/2010 (4:20 am)
I really hope Torque integrates this into their engine by default. The licensing with the Qt toolkit is iffy, but I'm sure it can be worked out so both sides are happy ... then we can really sit back and enjoy some cool projects using the WebKit!
#90
07/27/2010 (9:42 pm)
ok, hope that integrates next t3d release.....this week?
#91
07/27/2010 (10:06 pm)
I prefer it to be a drop-in resource, or something you can enable/disable using the projectCode.conf file, since it greatly increases the executable size.
#92
The current version doesn't compile. The main culprit seems to be the class MatTextureTarget which has been replaced with a class NamedTexTarget that has different methods. EngineEnumTable has also changed.
08/19/2010 (3:10 pm)
Is there a version of the webkit updated for Beta 2? The current version doesn't compile. The main culprit seems to be the class MatTextureTarget which has been replaced with a class NamedTexTarget that has different methods. EngineEnumTable has also changed.
#93
08/24/2010 (9:52 am)
Same issue here tried to rename to NamedTexTarget but some of the function calls needed are not in NamedTexTarget
#94
Or anybody knows where can I find precompiled Qt with SSL supported Webkit?
08/25/2010 (9:51 am)
I can't open any websites with https protocol. (unfortunately I can't login to facebook...) I hope compiling Qt with OpenSSL may help. Is there anybody who compiled succesfully Qt with SSL support?Or anybody knows where can I find precompiled Qt with SSL supported Webkit?
#95
08/25/2010 (12:49 pm)
Not with the latest beta, but yes. See my instructions earlier in the thread.
#96
08/25/2010 (1:25 pm)
Oh sorry, I found it... Thanks!
#97
Do you know any oppurtunity to test the compiled webkit with the SSL feature?
I compiled it using your instructions but still can't open https sites...
I didn't see any error messages during the compilation processes but it doesn't works...
09/13/2010 (7:03 pm)
Hi Jason,Do you know any oppurtunity to test the compiled webkit with the SSL feature?
I compiled it using your instructions but still can't open https sites...
I didn't see any error messages during the compilation processes but it doesn't works...
#98
I used the following configure command:
The only disadvantage with this solution is I have to provide the compiled SSL library DLL's (libeay32.dll, ssleay32.dll).
09/14/2010 (8:17 pm)
I found a solution which worked. I used "-openssl-linked" option suggested on this page: doc.qt.nokia.com/4.6/ssl.htmlI used the following configure command:
configure -opensource -openssl-linked -I C:/openssl-0.9.8/linc32 -L C:/openssl-0.9.8l/out32dll -no-phonon -no-multimedia -no-script -no-opengl -no-openvg -no-qt3support -no-dbus -no-scripttools -nomake demos -nomake examples -fast -release
The only disadvantage with this solution is I have to provide the compiled SSL library DLL's (libeay32.dll, ssleay32.dll).
#99
We've set some time aside with Tamas to port the resource to Beta 2. We work with a heavily modified codebase, and can't support this, but here are the required changes to the original package.
There may be some differences from the original implementation, I'm not sure. See if this works for you or if this gives you some help with porting.
09/15/2010 (8:50 pm)
Hi guysWe've set some time aside with Tamas to port the resource to Beta 2. We work with a heavily modified codebase, and can't support this, but here are the required changes to the original package.
There may be some differences from the original implementation, I'm not sure. See if this works for you or if this gives you some help with porting.
--- web/guiWebCtrl.cpp Thu Feb 18 00:09:48 2010
+++ web/guiWebCtrl.cpp Wed Sep 15 22:15:19 2010
@@ -15,17 +16,19 @@
#include "gui/core/guiCanvas.h"
#include "guiWebCore.h"
-static const EnumTable::Enums renderModeEnums[] =
-{
- { GuiWebView::RENDER_TEXTURE, "texture" },
- { GuiWebView::RENDER_NATIVE, "native" },
- { GuiWebView::RENDER_POPUP, "popup" },
-};
-
-static const EnumTable gRenderModeTable( "GUIWEBCTRL_RENDERMODE_ENUM", 3, &renderModeEnums[0] );
-
-IMPLEMENT_CONOBJECT(GuiWebCtrl);
-
+IMPLEMENT_CONOBJECT( GuiWebCtrl );
+
+ImplementEnumType( RenderModeType,
+ "Type of render mode for the control.nn"
+ "@ingroup GuiWebCtrl" )
+ { GuiWebView::RENDER_TEXTURE, "texture",
+ "Render to texture mode." },
+ { GuiWebView::RENDER_NATIVE, "native",
+ "Native mode." },
+ { GuiWebView::RENDER_POPUP, "popup",
+ "Popup mode." },
+EndImplementEnumType;
+
GuiWebCtrl::GuiWebCtrl(void)
{
mWebViewId = -1;
@@ -77,7 +80,7 @@
void GuiWebCtrl::initPersistFields()
{
- addField( "renderMode", TypeEnum, Offset( mMode, GuiWebCtrl ), 1, &gRenderModeTable );
+ addField( "renderMode", TYPEID<RenderModeType>(), Offset( mMode, GuiWebCtrl ), "Render mode type" );
addField( "targetName", TypeRealString, Offset(mTextureTargetName, GuiWebCtrl), "Material texture target" );
addField( "fps", TypeS32, Offset(mRefreshFPS, GuiWebCtrl), "Refresh framerate for RENDER_TEXTURE mode, 20fps is the default" );
@@ -127,7 +130,8 @@
if (mTextureTargetName.isNotEmpty())
{
mWebTexture = new WebTextureMap(this);
- MatTextureTarget::registerTarget( mTextureTargetName, mWebTexture);
+ //MatTextureTarget::registerTarget( mTextureTargetName, mWebTexture);
+ mWebTexture->registerWithName( mTextureTargetName );
}
GuiCanvas::getGuiCanvasFrameSignal().notify( this, &GuiWebCtrl::_handleCanvasFrameEvent );
@@ -159,7 +163,7 @@
if (mWebTexture)
{
- MatTextureTarget::unregisterTarget( mTextureTargetName, NULL );
+ //MatTextureTarget::unregisterTarget( mTextureTargetName, NULL );
delete mWebTexture;
mWebTexture = NULL;
}
@@ -451,3 +455,35 @@
{
object->loadURL(argv[2]);
}
+
+// >>>
+bool GuiWebCtrl::onInputEvent(const InputEventInfo & event)
+{
+ if(event.deviceType == MouseDeviceType &&
+ event.objInst == KEY_BUTTON1 && event.action == SI_BREAK)
+ {
+ // if the right mouse pass thru is enabled,
+ // we want to reactivate mouse on a right mouse button up
+ GuiCanvas *pCanvas = getRoot();
+ if( !pCanvas )
+ return false;
+
+ PlatformWindow *pWindow = static_cast<GuiCanvas*>(getRoot())->getPlatformWindow();
+ if( !pWindow )
+ return false;
+
+ PlatformCursorController *pController = pWindow->getCursorController();
+ if( !pController )
+ return false;
+
+ pWindow->setMouseLocked(false);
+ pCanvas->setCursorON( true );
+
+ //mouseUnlock();
+ //pCanvas->setForceMouseToGUI(false);
+ }
+ // we return false so that the canvas can properly process the right mouse button up...
+ return false;
+}
+
+// <<<
--- web/guiWebCtrl.h Thu Feb 18 00:09:48 2010
+++ web/guiWebCtrl.h Wed Sep 15 22:09:44 2010
@@ -160,6 +160,8 @@
bool onKeyUp(const GuiEvent &event);
bool onKeyRepeat(const GuiEvent &event);
+ bool onInputEvent(const InputEventInfo & event); // >>> <<<
+
void setFirstResponder();
void onLoseFirstResponder();
@@ -181,7 +183,7 @@
DECLARE_DESCRIPTION( "A control that displays an embedded web control" );
};
-class WebTextureMap : public MatTextureTarget
+class WebTextureMap : public NamedTexTarget
{
public:
@@ -198,6 +200,7 @@
GuiWebCtrl *mCtrl;
};
-
+typedef GuiWebView::RenderMode RenderModeType;
+DefineEnumType( RenderModeType );
#endif
#100
09/15/2010 (8:50 pm)
... continued--- web/guiWebView.h Thu Feb 18 00:09:48 2010
+++ web/guiWebView.h Thu Apr 29 18:12:37 2010
@@ -18,6 +18,8 @@
class GuiWebCore;
+DECLARE_SCOPE( QTWebkitAPI );
+
// This is meant only for internal use, see GuiWebCtrl.h for some documentation
class GuiWebPage : public QWebPage {
--- myGameTSCtrl.cpp Thu Feb 18 00:09:48 2010
+++ myGameTSCtrl.cpp Wed Sep 15 21:44:45 2010
@@ -73,11 +73,11 @@
{
if (r.texCoord[0] != -1)
{
- Material* m = dynamic_cast <Material *> (r.material->getMaterial());
+ Material* m = ( r.material ? dynamic_cast< Material* >( r.material->getMaterial() ) : 0 ); // >>> <<< http://www.torquepowered.com/community/forums/viewthread/109335/4#comment-736607
if (m && m->mDiffuseMapFilename[0].isNotEmpty() && m->mDiffuseMapFilename[0].substr( 0, 1 ).equal("#"))
{
String texTargetBufferName = m->mDiffuseMapFilename[0].substr(1, m->mDiffuseMapFilename[0].length() - 1);
- MatTextureTarget *texTarget = MatTextureTarget::findTargetByName( texTargetBufferName );
+ NamedTexTargetRef texTarget = NamedTexTarget::find( texTargetBufferName );
if (texTarget)
{
@@ -127,11 +127,11 @@
{
if (r.texCoord[0] != -1)
{
- Material* m = dynamic_cast <Material *> (r.material->getMaterial());
+ Material* m = ( r.material ? dynamic_cast< Material* >( r.material->getMaterial() ) : 0 ); // >>> <<< http://www.torquepowered.com/community/forums/viewthread/109335/4#comment-736607
if (m && m->mDiffuseMapFilename[0].isNotEmpty() && m->mDiffuseMapFilename[0].substr( 0, 1 ).equal("#"))
{
String texTargetBufferName = m->mDiffuseMapFilename[0].substr(1, m->mDiffuseMapFilename[0].length() - 1);
- MatTextureTarget *texTarget = MatTextureTarget::findTargetByName( texTargetBufferName );
+ NamedTexTargetRef texTarget = NamedTexTarget::find( texTargetBufferName );
if (texTarget)
{
GuiWebCtrl* w = dynamic_cast<GuiWebCtrl*> (Sim::findObject(texTargetBufferName));
@@ -177,11 +177,11 @@
{
if (r.texCoord[0] != -1)
{
- Material* m = dynamic_cast <Material *> (r.material->getMaterial());
+ Material* m = ( r.material ? dynamic_cast< Material* >( r.material->getMaterial() ) : 0 ); // >>> <<< http://www.torquepowered.com/community/forums/viewthread/109335/4#comment-736607
if (m && m->mDiffuseMapFilename[0].isNotEmpty() && m->mDiffuseMapFilename[0].substr( 0, 1 ).equal("#"))
{
String texTargetBufferName = m->mDiffuseMapFilename[0].substr(1, m->mDiffuseMapFilename[0].length() - 1);
- MatTextureTarget *texTarget = MatTextureTarget::findTargetByName( texTargetBufferName );
+ NamedTexTargetRef texTarget = NamedTexTarget::find( texTargetBufferName );
if (texTarget)
{
@@ -261,10 +261,8 @@
return false;
}
-
void MyGameTSCtrl::onRightMouseUp(const GuiEvent & event)
{
- /*
GuiCanvas *pCanvas = getRoot();
if( !pCanvas )
return;
@@ -281,8 +279,6 @@
// script functions are lockMouse(true); Canvas.cursorOff();
pWindow->setMouseLocked(false);
pCanvas->setCursorON( true );
- */
-
}
void MyGameTSCtrl::onRender(Point2I offset, const RectI &updateRect)
Associate Josh Engebretson
Engine/source/ts/tsCollision.cpp in
bool TSMesh::castRayOpcode( const Point3F &s, const Point3F &e, RayInfo *info, TSMaterialList *materials )
Point3F min(F32_MAX, F32_MAX, F32_MAX);
Point3F max(F32_MIN, F32_MIN, F32_MIN);
should be:
Point3F min(F32_MAX, F32_MAX, F32_MAX);
Point3F max(-F32_MAX, -F32_MAX, -F32_MAX);