Ejemplo n.º 1
0
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 );
	}
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
void AwesomeSilkApp::draw()
{
	gl::clear();
    
	if( mWebTexture )
	{
		gl::color( Color::white() );
		gl::draw( mWebTexture );
        if (useSyphon){
            mTextureSyphon.publishTexture(&mWebTexture); //publish our texture
        }
	}
    
	// show spinner while loading
	if( mLoadingTexture && mWebViewPtr && mWebViewPtr->IsLoading() )
	{
		gl::pushModelView();
        
		gl::translate( 0.5f * Vec2f( getWindowSize() ) );
		gl::scale( 0.5f, 0.5f );
		gl::rotate( 180.0f * float( getElapsedSeconds() ) );
		gl::translate( -0.5f * Vec2f( mLoadingTexture.getSize() ) );
		
		gl::color( Color::white() );
		gl::enableAlphaBlending();
		gl::draw( mLoadingTexture );
		gl::disableAlphaBlending();
        
		gl::popModelView();
	}
}
void _TBOX_PREFIX_App::draw()
{
	gl::clear(); 

	if( mWebTexture )
	{
		gl::color( Color::white() );
		gl::draw( mWebTexture );
	}

	// show spinner while loading 
	if( mLoadingTexture && mWebViewPtr && mWebViewPtr->IsLoading() )
	{
		gl::pushModelView();

		gl::translate( 0.5f * Vec2f( getWindowSize() ) );
		gl::scale( 0.5f, 0.5f );
		gl::rotate( 180.0f * float( getElapsedSeconds() ) );
		gl::translate( -0.5f * Vec2f( mLoadingTexture.getSize() ) );
		
		gl::color( Color::white() );
		gl::enableAlphaBlending();
		gl::draw( mLoadingTexture );
		gl::disableAlphaBlending();

		gl::popModelView();
	}
}
Ejemplo n.º 5
0
void FutureValueCallback::handleCallback(const CppArgumentList& args, CppVariant* result)
{
	Awesomium::JSArguments jsArgs;
	initFromCppArgumentList(args, jsArgs);

	view->handleFutureJSValueCallback(jsArgs);
	result->SetNull();
}
Ejemplo n.º 6
0
	void Initialize(
		_In_ Web::Implementation *web,
		_In_ INT32 view_width, _In_ INT32 view_height,
		_In_ Web::Session::Implementation *resources
		)
	{
		if (view_private) return;
		view_private = web->core_private->CreateWebView(
			view_width, view_height, resources->session_private,
			Awesomium::WebViewType::kWebViewType_Offscreen
			),
			// set event handlers for the current view
			view_private->set_view_listener(this),
			view_private->set_load_listener(this),
			view_private->set_process_listener(this),
			view_private->set_js_method_handler(this);
	}
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; }
}
Ejemplo n.º 8
0
void CheckKeyboardFocusCallback::handleCallback(const CppArgumentList& args, CppVariant* result)
{
	Awesomium::JSArguments jsArgs;
	initFromCppArgumentList(args, jsArgs);

	if(jsArgs.size())
		view->handleCheckKeyboardFocus(jsArgs[0].toBoolean());

	result->SetNull();
}
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;
		}
	}
}
Ejemplo n.º 10
0
void AwesomeSilkApp::shutdown()
{
	// properly shutdown Awesomium on exit
	if( mWebViewPtr ) mWebViewPtr->Destroy();
	Awesomium::WebCore::Shutdown();
}
Ejemplo n.º 11
0
void AwesomeSilkApp::resize()
{
	// resize webview if window resizes
	if( mWebViewPtr )
		mWebViewPtr->Resize( getWindowWidth(), getWindowHeight() );
}
void _TBOX_PREFIX_App::shutdown()
{
	// properly shutdown Awesomium on exit
	if( mWebViewPtr ) mWebViewPtr->Destroy();
	Awesomium::WebCore::Shutdown();
}
void _TBOX_PREFIX_App::resize()
{
	// resize webview if window resizes
	if( mWebViewPtr )
		mWebViewPtr->Resize( getWindowWidth(), getWindowHeight() );
}
Ejemplo n.º 14
0
	void Release()
	{
		if (view_private)
			view_private->Destroy(),
			view_private = nullptr;
	}