metalayer
metalayer

Reputation: 69

Why does AwesomiumComponent drop framerate to nothing?

I have the following method making use of this class - http://strikelimit.co.uk/m/?p=421

        private void AwesomeMenu()
    {
            // Awesomium Menus
            Rectangle UX_rect = new Rectangle(100, 100, 500, 500);
            AwesomiumComponent UX = new AwesomiumComponent("www.google.com", UX_rect);
            Texture2D UX_tex = UX.GetTexture(GraphicsDevice);
            spriteBatch.Begin();
            spriteBatch.Draw(UX_tex, UX_rect, Color.White);
            spriteBatch.End();        
    }

When I call this method in Draw() the framerate drops to nothing as my webview object is refreshed every time Draw is called. When I try to call it in Initialize() there is a slight delay as the URI is loaded once but the window isn't drawn. I need to draw the webview object to the screen and update it only when the user interacts with it, what is the best approach for this?

Upvotes: 0

Views: 42

Answers (1)

user585968
user585968

Reputation:

It appears AwesomiumComponent takes quite a while to fetch the web page.

update it only when the user interacts with it

Rather than perform AwesomiumComponent("www.google.com", UX_rect) each frame, fetch it only when the user interacts with it. You should perform the fetching asynchronously to improve performance rather than block your game loop.

When it becomes invalidated, fetch the web page and use a RenderTarget to render to a texture.

Otherwise, render the texture every frame and it shall be much faster.

Upvotes: 1

Related Questions