Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


Awesomium and OSG - cannot render to a geode


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
No replies to this topic

#1 Gasim   Members   -  Reputation: 207

Like
0Likes
Like

Posted 26 May 2012 - 01:34 PM

Hello,
I have been trying to integrate awesomium UI to OSG. What I am trying to do is to create a HUD overlay and then design the whole UI in html. Here is the code. Ill explain the unclear stuff in the comments:


void GraphicsSystem::createHUD() {
  //geometry of hudGeode, projectionMatrix etc. here. Details are not relevant for my problem.
  osg::StateSet * ss = new osg::StateSet;
  ss->setTextureAttributeAndModes(0, hudTexture, osg::StateAttribute::ON);
  ss->setMode(GL_BLEND, osg::StateAttribute::ON);
  ss->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
  ss->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
  ss->setRenderBinDetails(11, "RenderBin");
  hudGeode->setStateSet(ss);
}


void GraphicsSystem::renderHUD(unsigned char * data) {

image->setImage(800,600,1,4,[b]GL_BGRA[/b], GL_UNSIGNED_BYTE, data, osg::Image::NO_DELETE, 1);
hudTexture->setImage(image);

}

//hudTexture and image are members of the class GraphicsSystem

and here is the awesomium update view function:

void AwesomiumUI::updateView() {
  const awe_renderbuffer * rbuffer = awe_webview_render(view);
  awe_renderbuffer_save_to_png(rbuffer, str2awe("test.png"), false);
  const unsigned char * buffer = awe_renderbuffer_get_buffer(rbuffer);
  Base::sys()->sendEvent(new Event1<const unsigned char*>("renderHUD", buffer));
}

When I run it I get the following error:


Warning: detected OpenGL error 'invalid enumerant' at after RenderBin::draw(..)


Couple things I know for sure:
  • AwesomuimUI's render buffer is not empty because awe_renderbuffer_save_to_png is saving a file test.png correctly
  • The StateSet does not have any issues because I have created a trigger to change the texture dynamically and it worked.
  • The problem is maybe in the image->setImage(...). Maybe the formattings of render buffers in Awesomium and OSG are different. I am still looking it up.
If anyone can help me, I would really appreciate it.

Thanks in advance,
Gasim

EDIT: I have fixed the issue. The problem was I was not using the right texture type. Awesomium is using GL_BGRA. I have bolded it in the code above. But I still need help. The texture is flipped vertically. How can I flip it back using osg?

Edited by Gasim, 26 May 2012 - 02:22 PM.


Sponsor:



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