• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
PwFClockWise

Awesomium Framework, rendering problems C++ and DirectX11!

8 posts in this topic

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
0

Share this post


Link to post
Share on other sites
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
1

Share this post


Link to post
Share on other sites
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!

0

Share this post


Link to post
Share on other sites

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). 

1

Share this post


Link to post
Share on other sites

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!

 

0

Share this post


Link to post
Share on other sites
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
1

Share this post


Link to post
Share on other sites

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!

0

Share this post


Link to post
Share on other sites
Edit: Figured it out myself, problem should be solved now. Edited by PwFClockWise
0

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0