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 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(); } }
void FutureValueCallback::handleCallback(const CppArgumentList& args, CppVariant* result) { Awesomium::JSArguments jsArgs; initFromCppArgumentList(args, jsArgs); view->handleFutureJSValueCallback(jsArgs); result->SetNull(); }
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; } }
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; } } }
void AwesomeSilkApp::shutdown() { // properly shutdown Awesomium on exit if( mWebViewPtr ) mWebViewPtr->Destroy(); Awesomium::WebCore::Shutdown(); }
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() ); }
void Release() { if (view_private) view_private->Destroy(), view_private = nullptr; }