Jump to content

  • Log In with Google      Sign In   
  • Create Account


Awesomium Framework, rendering problems C++ and DirectX11!


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 Celiasson   Members   -  Reputation: 492

Like
0Likes
Like

Posted 08 January 2013 - 03:50 AM

Hi everyone,

I'm using Awesomium(www.awesomium.com), version 1.7, to store a website and then render it to a plane in my application. The plan is to have some kind of GUI system connected to a home page and continuously render the site on the plane and update it once something has happened on the site.

Now, the problem is that I have not idea where to start with this framework. The documentation for 1.7 is completely different from the 1.6.6 version and there's no sample code or tutorials to be found anywhere. So far I've initialized the entire thing and have been able to load a website and save it to a PNG. I can then, of course, just render the PNG to the plane and it works.

However, loading a website, saving it to file only to load it from file and render it is a huge waste of resources so I'm trying to skip the SaveToPNG - stage. The problem is that I have no idea how to use the Awesomium Framework for rendering. In the old version there were RenderBuffers and Render calls to be made from those buffers, but the 1.7 version has that completely changed and I can't find the equivalent ways to do this in the 1.7.

Using the 1.6.6 version is not an option since it's not compatible with VS2010. Even if I set the VS2010 to use the old compiler from VS2008(which should work) it doesn't work.

What I've done so far is load the website onto a Awesomium::BitmapSurface object, but I don't know what to do with the data in it. The Awesomium::BitmapSurface contains a buffer with raw 32-bit BGRA format and I can get the bitmap height and width in pixels as well.

If anyone can help me out I would be very grateful, thanks in advance

Sincerely,

ClockWise

Edited by PwFClockWise, 08 January 2013 - 03:53 AM.


Sponsor:

#2 noizex   Members   -  Reputation: 853

Like
1Likes
Like

Posted 08 January 2013 - 05:03 AM

You could probably initialize texture using BitmapSurface data. But best way in 1.7 seems to be creating your own Surface subclass that should provide Paint and Scroll methods. Check this: http://awesomium.com/docs/1_7_rc3/cpp_api/class_awesomium_1_1_surface.html.

Just make your own DXTextureSurface that inherits from Surface class and provide Paint method that would directly update texture whenever its called. It looks like WebCore has a method set_surface_factory that allows you to provide your own factory that will produce DXTextureSurfaces when needed, instead of default BitmapSurface.

Edited by noizex, 08 January 2013 - 05:04 AM.


#3 Celiasson   Members   -  Reputation: 492

Like
0Likes
Like

Posted 08 January 2013 - 06:05 AM

You could probably initialize texture using BitmapSurface data. But best way in 1.7 seems to be creating your own Surface subclass that should provide Paint and Scroll methods. Check this: http://awesomium.com/docs/1_7_rc3/cpp_api/class_awesomium_1_1_surface.html.

Just make your own DXTextureSurface that inherits from Surface class and provide Paint method that would directly update texture whenever its called. It looks like WebCore has a method set_surface_factory that allows you to provide your own factory that will produce DXTextureSurfaces when needed, instead of default BitmapSurface.


Something is up with the website at that link, but the link works. Will check it later when the site works. I was also looking into making my own stuff there, but the problem is that I don't really understand how the functions in the Surface class works. The Paint function is confusing me. I don't understand what it wants as parameters.

Thanks for your help thus far!



#4 noizex   Members   -  Reputation: 853

Like
1Likes
Like

Posted 08 January 2013 - 06:34 AM

You could probably initialize texture using BitmapSurface data. But best way in 1.7 seems to be creating your own Surface subclass that should provide Paint and Scroll methods. Check this: http://awesomium.com/docs/1_7_rc3/cpp_api/class_awesomium_1_1_surface.html.

Just make your own DXTextureSurface that inherits from Surface class and provide Paint method that would directly update texture whenever its called. It looks like WebCore has a method set_surface_factory that allows you to provide your own factory that will produce DXTextureSurfaces when needed, instead of default BitmapSurface.


Something is up with the website at that link, but the link works. Will check it later when the site works. I was also looking into making my own stuff there, but the problem is that I don't really understand how the functions in the Surface class works. The Paint function is confusing me. I don't understand what it wants as parameters.

Thanks for your help thus far!

 
Sorry, it seems I pasted link with a dot at the end and it borked. This is correct link: http://awesomium.com/docs/1_7_rc3/cpp_api/class_awesomium_1_1_surface.html
 
This is how Paint method should look like:

virtual void Awesomium::Surface::Paint	(	
unsigned char * 	        src_buffer,
int 	                        src_row_span,
const Awesomium::Rect & 	src_rect,
const Awesomium::Rect & 	dest_rect 
)	

 
Whats not clear for you here? Obviously it gives you buffer that contains image data, provides row span information thats also required (you can calculate it yourself having enough info but they give it to you already), format is 32-bit BGRA so you already have all the info to create a texture out of this. The only hard thing here is that it obviously paints only the part that changes, not always re-paints full view, so you have to handle partial updates.
 
Once you have your own Surface class and set its factory, whenever WebView is rendered, it will set up your texture by instancing DXTextureSurface (or whatever you name that class). It will be then available through WebView's method "surface", so whenever you want to draw that WebView you can do something like this (pseudocode):
 

DXTextureSurface* surface = (DXTextureSurface*)mywebview->surface();
DrawTexturedQuad(surface->GetTextureHandle())

Where GetTextureHandle returns whatever you use to identify DirectX's texture (I use OpenGL so can't provide more accurate example here). 



#5 Celiasson   Members   -  Reputation: 492

Like
0Likes
Like

Posted 08 January 2013 - 06:52 AM

The thing that is confusing to me is the src_buffer parameter, I don't understand what kind of buffer I'm supposed to send in. Let's say I have loaded a website into a surface. The site then updates and I need to repaint the texture. How would I use surface->Paint() to do this?

Thanks once again!

 



#6 noizex   Members   -  Reputation: 853

Like
1Likes
Like

Posted 08 January 2013 - 07:01 AM

The thing that is confusing to me is the src_buffer parameter, I don't understand what kind of buffer I'm supposed to send in. Let's say I have loaded a website into a surface. The site then updates and I need to repaint the texture. How would I use surface->Paint() to do this?

Thanks once again!

Errm. Its not you thats sending data to Paint method, its the internals of Awesomium that do this. You have to define class that has Paint method and receive this data in that method, and use it to initialize/update texture. Its called automatically by Awesomium when it renders WebView, so you dont really need to call Paint yourself. Once you set the factory and load some page in WebView, you call webview->surface() to retrieve that Surface, which should have your page prepared as a texture (or a bitmap data if you use default BitmapSurface).

Check this example: http://wiki.awesomium.com/tutorials/tutorial-1-hello-awesomium.html

You want to do exactly the same but with your own class, that instead of keeping image data in memory, will upload it as a texture to GPU and keep handle to that texture, so you can retrieve it by calling surface->GetTexture() and then use that texture to draw a quad.

Edited by noizex, 08 January 2013 - 07:04 AM.


#7 Celiasson   Members   -  Reputation: 492

Like
0Likes
Like

Posted 08 January 2013 - 07:11 AM

Ahhh, now I understand rofl. When I checked the former documentation of 1.6.6 there was a class called RenderBuffer and a method called Render() so I assumed that Paint() was the new render function that you call yourself. But now I understand. This should be very easy then. Thanks to you I won't waste more hours with something that I'm not even supposed to call myself ^^

If I could upvote more than once I would, thanks!



#8 Celiasson   Members   -  Reputation: 492

Like
0Likes
Like

Posted 09 January 2013 - 08:20 AM

Edit: Figured it out myself, problem should be solved now.

Edited by PwFClockWise, 09 January 2013 - 12:36 PM.


#9 Celiasson   Members   -  Reputation: 492

Like
0Likes
Like

Posted 15 January 2013 - 05:52 AM

So I encountered a problem when trying to inject mouse and keyboard. I think I've done it right since I pass the right Events to them, but nothing is updated. I'm beginning to realize that I have a hard time understanding what is actually needed to interact with my WebView object.

Do I have to implement my own WebViewListener to be able to interact with my WebView, such as typing, clicking and what not?

Edit: Forgot an update method in my loop. Still have no idea what to do with Listeners, but for now I don't need them.

Edited by PwFClockWise, 16 January 2013 - 02:37 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS