Raz Posted June 23, 2011 Share Posted June 23, 2011 Hey there! A member of our team just informed me that someone had a chat with him about using Awesomium in combination with Leadwerks and C#. He mentioned he was going to release the code some time this week. Unfortunately, it seems that he couldn't remember who it was. So if you're the one who sent us the message, it'd be awesome if you could quickly send us a PM or post in here, cause I'd really like to get in touch with you. Best Regards, Philipp Quote Link to comment Share on other sites More sharing options...
klepto2 Posted June 23, 2011 Share Posted June 23, 2011 hi, it was me who was contacting you. I'm currently working on some Extensions to the LE.Net Wrapper including a class which handle Awesomium. Some details can be found in my blog here: http://www.leadwerks.com/werkspace/blog/16/entry-672-extending-lenet/ And here is a newer screenshot which shows a small test app with interactive Awesomium on a cube. (Mouse and Keyboard input is working) Feel free to contact me via MSN/ICQ or Mail. Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Raz Posted June 23, 2011 Author Share Posted June 23, 2011 Very, very nice I'll be sure to come back to you about it! Switching from DirectX to OpenGL, I was stunned at how horribly different things are handled in OpenGL. In DirectX it was a matter of minutes to figure out how to use Awesomium with the (now obviously deprecated) MDX wrapper, but OpenGL and things like TAO, OpenTK... damn xD Greets, Philipp Quote Link to comment Share on other sites More sharing options...
klepto2 Posted June 23, 2011 Share Posted June 23, 2011 To be honest, i have the same problem with directx It just was a matter of 2 minutes to get awesomium working with LE. Of course you need some knowledge about handling Leadwerks textures with raw opengl, but than it is really simple. public void Render() { if (m_webView.IsDirty() && !m_loading) { Rect r = m_webView.GetDirtyBounds(); RenderBuffer buffer = m_webView.Render(); UploadToTexture(buffer,r); } } private void UploadToTexture(RenderBuffer buffer, Rect rect) { LE.BindTexture(m_rendertarget); int size =buffer.GetRowspan() / LE.TextureWidth(m_rendertarget); int ptr = (int)buffer.GetBuffer() + (rect.x) * size + (rect.y) * buffer.GetRowspan(); Gl.glTexSubImage2D(Gl.GL_TEXTURE_2D, 0, rect.x, rect.y,rect.width ,rect.height, Gl.GL_BGRA, Gl.GL_UNSIGNED_BYTE, (IntPtr)ptr); } As you see there is no real magic behind it Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Raz Posted June 23, 2011 Author Share Posted June 23, 2011 No really, its pretty much the same operation in DirectX I assume you're using TAO to handle the raw OpenGL commands, right? [EDIT] Yea, apparently its TAO. Unfortunately the whole program crashes with no error (just says "has stopped working"). I haven't changed much in the UploadToTexture function, but I wasn't sure where you got your m_rendertarget from, so I just used 0 for texunit 0. private void UploadToTexture(RenderBuffer buffer, AwesomiumSharp.Rect rect) { webTexture.Bind(0); int size = buffer.GetRowspan() / webTexture.Width; int ptr = (int)buffer.GetBuffer() + (rect.x) * size + (rect.y) * buffer.GetRowspan(); Gl.glTexSubImage2D(Gl.GL_TEXTURE_2D, 0, rect.x, rect.y, rect.width, rect.height, Gl.GL_BGRA, Gl.GL_UNSIGNED_BYTE, (IntPtr)ptr); } [EDIT 2] Narrowed it down to two issues I suppose will be fixed when understanding what exactly Texture.Bind() does. When first calling UploadToTexture, everything's working just fine. Upon calling it a second time, it makes the program crash. I suppose it has to do with the way you write data to the texture. I think I'm supposed to somehow "revert" webTexture.BInd() after the call to glTexSubImage2D(), but I'm not sure on how to do that... Greets, Philipp Quote Link to comment Share on other sites More sharing options...
klepto2 Posted June 24, 2011 Share Posted June 24, 2011 the webTexture needs to be the same size as the WebView and this part: if (m_webView.IsDirty() && !m_loading) { Rect r = m_webView.GetDirtyBounds(); RenderBuffer buffer = m_webView.Render(); UploadToTexture(buffer,r); } is important, otherwise the rect maybe undefined if the view isn't dirty, alternatively you can leave the rect out of the code and upload the whole renderbuffer to the texture. Gl.glTexSubImage2D(Gl.GL_TEXTURE_2D, 0, 0, 0, webTexture.Width, webTexture.Height, Gl.GL_BGRA, Gl.GL_UNSIGNED_BYTE, Buffer.GetBuffer()); Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Raz Posted June 24, 2011 Author Share Posted June 24, 2011 Thanks a lot for the clarification Managed to get it working just fine with the rect info included. Quote Link to comment Share on other sites More sharing options...
Raz Posted June 26, 2011 Author Share Posted June 26, 2011 Hm, okay, now I'm a bit stuck with handling input.. I'm currently trying to hack around Leadwerk's system by using a low-level hook with "SetWindowsHookEx()", but that doesn't yield too good results.. Would you mind posting the code you used to receive input and reroute it to Awesomium? Greets, Philipp Quote Link to comment Share on other sites More sharing options...
klepto2 Posted June 27, 2011 Share Posted June 27, 2011 Here is the promised Sample (just a .cs file) and a first (Alpha stage) of 3 of my Leadwerks.Extensions Library. The input system maps the original Leadwerks functions into an eventbased system including missing up-commands. Leadwerks.Extensions.Alpha1.zip Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Raz Posted June 27, 2011 Author Share Posted June 27, 2011 Hm, okay, so basically you're doing the same thing I originally intended to do to handle input events - that is, polling each key each Update(). Idk if that's such a good idea performance-wise. I read up a lot on the message loop of windows and thought that might've been a better solution, but if you think there's no huge trade-off in performance, that's fine. Quote Link to comment Share on other sites More sharing options...
Blitzbat Posted July 20, 2011 Share Posted July 20, 2011 Hey there. If I start this example I get this strange problem: I don't know how to fix this problem. Thanks for your help! Quote Link to comment Share on other sites More sharing options...
klepto2 Posted July 20, 2011 Share Posted July 20, 2011 this is a shader bug i postet a short time before in the bugtracker. Open the shader.pak and edit the 'Mesh/mesh_diffuse_fullbright.frag' and remove the line which defines texture 2 so that the file looks like this: #define LW_DIFFUSE texture0 #define LW_FULLBRIGHT include "mesh.frag" Also you need to copy the dlls and AwesomiumProcess.exe from Awsomium SDK into your output folder. Once the official .NET part is finished i will release a full Package with working Samples. Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Blitzbat Posted July 20, 2011 Share Posted July 20, 2011 this is a shader bug i postet a short time before in the bugtracker. Open the shader.pak and edit the 'Mesh/mesh_diffuse_fullbright.frag' and remove the line which defines texture 2 so that the file looks like this: #define LW_DIFFUSE texture0 #define LW_FULLBRIGHT include "mesh.frag" Also you need to copy the dlls and AwesomiumProcess.exe from Awsomium SDK into your output folder. Once the official .NET part is finished i will release a full Package with working Samples. Thanks for this hint but now my cube is black 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.