Rick Posted May 30, 2015 Share Posted May 30, 2015 Playing around with awesomium to see what it's about. I'm having issues trying to get the contents of the awecomium buffer to a leadwerks texture. The screen is just black. Just curious if anyone has done this before and has any tips on how to do this. Texture* uiTex = Texture::Create(window->GetWidth(), window->GetHeight()); unsigned char* pixels = (unsigned char*)malloc(uiTex->GetMipmapSize(0)); // copy surface to LE texture and draw that texture to screen BitmapSurface* surface = static_cast<BitmapSurface*>(view->surface()); if (surface->is_dirty()) { //surface->SaveToPNG(WSLit("C:\\Users\\Rick Piller\\Documents\\awesomium.png")); surface->CopyTo(pixels, 1024, 32, true, false); uiTex->SetPixels((char*)pixels); context->DrawImage(uiTex, 0, 0); } Saving the surface to png (commented part out) works so I know the surface from Awesomium is valid. So clearly I messed up the CopyTo() part. I just hardcoded some values for testing but I'm not 100% how this is working behind the scenes but pixels is the same value before it goes into CopyTo() as it is when it comes out so clearly something about my parameters are messing this up, but not exactly sure how they work compared to the LE texture. Here is the Awesomium CopyTo() functions header: /// /// Copy this bitmap to a certain destination. Will also set the dirty /// bit to False. /// /// @param dest_buffer A pointer to the destination pixel buffer. /// /// @param dest_row_span The number of bytes per-row of the destination. /// /// @param dest_depth The depth (number of bytes per pixel, is usually 4 /// for BGRA surfaces and 3 for BGR surfaces). /// /// @param convert_to_rgba Whether or not we should convert BGRA to RGBA. /// /// @param flip_y Whether or not we should invert the bitmap vertically. /// void CopyTo(unsigned char* dest_buffer, int dest_row_span, int dest_depth, bool convert_to_rgba, bool flip_y) const; I'm not 100% sure what dest_row_span would be from leadwerks. I'm also not sure what dest_depth or if I would need convert_to_rgba or flip_y. Those last 2 are boolean so I could figure them out I think once I get what dest_row_span and dest_depth should be as I suspect those 2 are causing me issues. 1 Quote Link to comment Share on other sites More sharing options...
Rick Posted May 30, 2015 Author Share Posted May 30, 2015 Nevermind. Looks like this works: surface->CopyTo(pixels, uiTex->GetWidth() * 4, 4, true, false); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.