示例#1
0
effVOID EFF3DHtmlWindow::Initialise()
{

	EFF3DDevice * device = EFF3DGetDevice();

	if ( device == NULL )
	{
		return;
	}

	Awesomium::WebCore * webCore = device->GetWebCore();

    if ( webView == NULL)
    {
        webView = webCore->CreateWebView(width, height);

		/*EFFInputManager * inputManager = EFF3DGetDevice()->GetInputManager();

		inputManager->OnKeyPressed += EFFEventCall(this, &EFF3DWebGUIWindow::KeyPressed);
		inputManager->OnKeyReleased += EFFEventCall(this, &EFF3DWebGUIWindow::KeyReleased);

		inputManager->OnMouseMove += EFFEventCall(this, &EFF3DWebGUIWindow::MouseMoved);
		inputManager->OnMouseButtonPressed += EFFEventCall(this, &EFF3DWebGUIWindow::MousePressed);
		inputManager->OnMouseButtonReleased += EFFEventCall(this, &EFF3DWebGUIWindow::MouseReleased);

		clientHandler.onTitleChanged = OnTitleChanged;
		clientHandler.onURLChanged = OnURLChanged;
		webView->setClientHandler(&clientHandler);*/
    }


}
void AwesomeSilkApp::update()
{
	// update the Awesomium engine
	mWebCorePtr->Update();
    
	// create or update our OpenGL Texture from the webview
	if( ! mWebViewPtr->IsLoading() && ph::awesomium::isDirty( mWebViewPtr ) )
	{
		try {
			// set texture filter to NEAREST if you don't intend to transform (scale, rotate) it
			gl::Texture::Format fmt;
			fmt.setMagFilter( GL_NEAREST );
            
			// get the texture using a handy conversion function
			mWebTexture = ph::awesomium::toTexture( mWebViewPtr, fmt );
		}
		catch( const std::exception &e ) {
			console() << e.what() << std::endl;
		}
        
		// update the window title to reflect the loaded content
		char title[1024];
		mWebViewPtr->title().ToUTF8( title, 1024 );
        
		app::getWindow()->setTitle( title );
	}
}
void AwesomeSilkApp::setup()
{
    setWindowPos(Vec2i(100,200));
	// set Awesomium logging to verbose
	Awesomium::WebConfig cnf;
	cnf.log_level = Awesomium::kLogLevel_Verbose;
#if defined( CINDER_MAC )
	std::string frameworkPath = ( getAppPath() / "Contents" / "MacOS" ).string();
	cnf.package_path = Awesomium::WebString::CreateFromUTF8( frameworkPath.c_str(), frameworkPath.size() );
#endif
    
	// initialize the Awesomium web engine
	mWebCorePtr = Awesomium::WebCore::Initialize( cnf );
    
	// create a webview
	mWebViewPtr = mWebCorePtr->CreateWebView( getWindowWidth(), getWindowHeight() );
	mWebViewPtr->LoadURL( Awesomium::WebURL( Awesomium::WSLit( "http://localhost/~vgusev/silk/silk/WebContent/silk.html" ) ) );
	mWebViewPtr->Focus();
    
	// load and create a "loading" icon
	try { mLoadingTexture = gl::Texture( loadImage( loadAsset( "loading.png" ) ) ); }
	catch( const std::exception &e ) { console() << "Error loading asset: " << e.what() << std::endl; }
    
    DialogWebViewListener *listener = new DialogWebViewListener();
    mWebViewPtr->set_dialog_listener(listener);
    
    mTextureSyphon.setName("Cinder Texture");
    useSyphon = false;
}
void _TBOX_PREFIX_App::setup()
{
	// set Awesomium logging to verbose
	Awesomium::WebConfig cnf;
	cnf.log_level = Awesomium::kLogLevel_Verbose;

	// initialize the Awesomium web engine
	mWebCorePtr = Awesomium::WebCore::Initialize( cnf );

	// create a webview
	mWebViewPtr = mWebCorePtr->CreateWebView( getWindowWidth(), getWindowHeight() );
	mWebViewPtr->LoadURL( Awesomium::WebURL( Awesomium::WSLit( "http://libcinder.org" ) ) );
	mWebViewPtr->Focus();

	// load and create a "loading" icon
	try { mLoadingTexture = gl::Texture( loadImage( loadAsset( "loading.png" ) ) ); }
	catch( const std::exception &e ) { console() << "Error loading asset: " << e.what() << std::endl; }
}
void _TBOX_PREFIX_App::update()
{
	// update the Awesomium engine
	mWebCorePtr->Update();

	// create or update our OpenGL Texture from the webview
	if( ! mWebViewPtr->IsLoading() && ph::awesomium::isDirty( mWebViewPtr ) ) 
	{
		try {
			// set texture filter to NEAREST if you don't intend to transform (scale, rotate) it
			gl::Texture::Format fmt; 
			fmt.setMagFilter( GL_NEAREST );

			// get the texture using a handy conversion function
			mWebTexture = ph::awesomium::toTexture( mWebViewPtr, fmt );
		}
		catch( const std::exception &e ) {
			console() << e.what() << std::endl;
		}
	}
}